semiotic 3.0.0 → 3.0.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 +23 -10
- package/README.md +66 -63
- package/ai/cli.js +34 -21
- package/ai/dist/componentRegistry.js +2 -0
- package/ai/dist/mcp-server.js +54 -0
- package/ai/examples.md +75 -0
- package/ai/schema.json +71 -0
- package/ai/system-prompt.md +3 -0
- package/dist/{ChartGrid.d.ts → components/ChartGrid.d.ts} +9 -7
- package/dist/{LinkedCharts.d.ts → components/LinkedCharts.d.ts} +34 -1
- package/dist/{Tooltip → components/Tooltip}/Tooltip.d.ts +9 -2
- package/dist/{charts → components/charts}/index.d.ts +2 -0
- package/dist/{charts → components/charts}/network/ChordDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/CirclePack.d.ts +2 -0
- package/dist/{charts → components/charts}/network/ForceDirectedGraph.d.ts +2 -0
- package/dist/components/charts/network/OrbitDiagram.d.ts +78 -0
- package/dist/{charts → components/charts}/network/SankeyDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/TreeDiagram.d.ts +2 -0
- package/dist/{charts → components/charts}/network/Treemap.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/BarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/BoxPlot.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/DonutChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/DotPlot.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/GroupedBarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/PieChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/StackedBarChart.d.ts +2 -0
- package/dist/{charts → components/charts}/ordinal/SwarmPlot.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +23 -0
- package/dist/{charts → components/charts}/shared/hooks.d.ts +23 -1
- package/dist/components/charts/shared/stringDistance.d.ts +11 -0
- package/dist/{charts → components/charts}/shared/tooltipUtils.d.ts +1 -1
- package/dist/{charts → components/charts}/shared/types.d.ts +6 -0
- package/dist/{charts → components/charts}/shared/withChartWrapper.d.ts +10 -0
- package/dist/{charts → components/charts}/xy/AreaChart.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/BubbleChart.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/ConnectedScatterplot.d.ts +3 -0
- package/dist/{charts → components/charts}/xy/Heatmap.d.ts +8 -0
- package/dist/{charts → components/charts}/xy/LineChart.d.ts +26 -0
- package/dist/{charts → components/charts}/xy/Scatterplot.d.ts +3 -0
- package/dist/{charts → components/charts}/xy/StackedAreaChart.d.ts +8 -0
- package/dist/{export → components/export}/exportChart.d.ts +6 -1
- package/dist/components/semiotic-ai.d.ts +61 -0
- package/dist/components/semiotic-data.d.ts +7 -0
- package/dist/components/semiotic-network.d.ts +14 -0
- package/dist/components/semiotic-ordinal.d.ts +18 -0
- package/dist/components/semiotic-realtime.d.ts +22 -0
- package/dist/components/semiotic-server.d.ts +1 -0
- package/dist/components/semiotic-xy.d.ts +16 -0
- package/dist/components/semiotic.d.ts +57 -0
- package/dist/{server → components/server}/renderToStaticSVG.d.ts +7 -0
- package/dist/{stream → components/stream}/NetworkSVGOverlay.d.ts +20 -0
- package/dist/{stream → components/stream}/OrdinalSVGOverlay.d.ts +8 -0
- package/dist/{stream → components/stream}/PipelineStore.d.ts +7 -0
- package/dist/{stream → components/stream}/SVGOverlay.d.ts +15 -0
- package/dist/components/stream/SceneToSVG.d.ts +20 -0
- package/dist/components/stream/hitTestUtils.d.ts +23 -0
- package/dist/{stream → components/stream}/networkTypes.d.ts +10 -2
- package/dist/{stream → components/stream}/ordinalTypes.d.ts +16 -10
- package/dist/components/stream/renderers/areaCanvasRenderer.d.ts +2 -0
- package/dist/{stream → components/stream}/types.d.ts +12 -0
- package/dist/components/stream/useStalenessCheck.d.ts +16 -0
- package/dist/{types → components/types}/legendTypes.d.ts +5 -0
- 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.d.ts +3 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +1 -0
- package/dist/semiotic-ordinal.d.ts +1 -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/canvasMock.d.ts +2 -0
- package/dist/test-utils/canvasMock.d.ts +20 -0
- package/dist/test-utils/frameMock.d.ts +78 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +7 -15
- package/dist/stream/renderers/areaCanvasRenderer.d.ts +0 -7
- /package/dist/{Annotation.d.ts → components/Annotation.d.ts} +0 -0
- /package/dist/{CategoryColors.d.ts → components/CategoryColors.d.ts} +0 -0
- /package/dist/{ChartContainer.d.ts → components/ChartContainer.d.ts} +0 -0
- /package/dist/{ChartErrorBoundary.d.ts → components/ChartErrorBoundary.d.ts} +0 -0
- /package/dist/{ContextLayout.d.ts → components/ContextLayout.d.ts} +0 -0
- /package/dist/{DetailsPanel.d.ts → components/DetailsPanel.d.ts} +0 -0
- /package/dist/{Legend.d.ts → components/Legend.d.ts} +0 -0
- /package/dist/{ThemeProvider.d.ts → components/ThemeProvider.d.ts} +0 -0
- /package/dist/{charts → components/charts}/ordinal/Histogram.d.ts +0 -0
- /package/dist/{charts → components/charts}/ordinal/RidgelinePlot.d.ts +0 -0
- /package/dist/{charts → components/charts}/ordinal/ViolinPlot.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeHeatmap.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeHistogram.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeLineChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeSwarmChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/realtime/RealtimeWaterfallChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/ChartError.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/annotationRules.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/colorUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/formatUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/legendUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/loess.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/networkUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/selectionUtils.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/statisticalOverlays.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/validateChartData.d.ts +0 -0
- /package/dist/{charts → components/charts}/shared/validateProps.d.ts +0 -0
- /package/dist/{charts → components/charts}/xy/MinimapChart.d.ts +0 -0
- /package/dist/{charts → components/charts}/xy/ScatterplotMatrix.d.ts +0 -0
- /package/dist/{data → components/data}/fromVegaLite.d.ts +0 -0
- /package/dist/{data → components/data}/transforms.d.ts +0 -0
- /package/dist/{export → components/export}/chartConfig.d.ts +0 -0
- /package/dist/{export → components/export}/selectionSerializer.d.ts +0 -0
- /package/dist/{geometry → components/geometry}/sankeyLinks.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/BinAccumulator.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/IncrementalExtent.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/RingBuffer.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/renderers/types.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/renderers/waterfallRenderer.d.ts +0 -0
- /package/dist/{realtime → components/realtime}/types.d.ts +0 -0
- /package/dist/{store → components/store}/ObservationStore.d.ts +0 -0
- /package/dist/{store → components/store}/SelectionStore.d.ts +0 -0
- /package/dist/{store → components/store}/ThemeStore.d.ts +0 -0
- /package/dist/{store → components/store}/TooltipStore.d.ts +0 -0
- /package/dist/{store → components/store}/createStore.d.ts +0 -0
- /package/dist/{store → components/store}/useObservation.d.ts +0 -0
- /package/dist/{store → components/store}/useSelection.d.ts +0 -0
- /package/dist/{stream → components/stream}/CanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/DataSourceAdapter.d.ts +0 -0
- /package/dist/{stream → components/stream}/MarginalGraphics.d.ts +0 -0
- /package/dist/{stream → components/stream}/NetworkCanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/NetworkPipelineStore.d.ts +0 -0
- /package/dist/{stream → components/stream}/OrdinalCanvasHitTester.d.ts +0 -0
- /package/dist/{stream → components/stream}/OrdinalPipelineStore.d.ts +0 -0
- /package/dist/{stream → components/stream}/ParticlePool.d.ts +0 -0
- /package/dist/{stream → components/stream}/SceneGraph.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamNetworkFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamOrdinalFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/StreamXYFrame.d.ts +0 -0
- /package/dist/{stream → components/stream}/accessorUtils.d.ts +0 -0
- /package/dist/{stream → components/stream}/keyboardNav.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/chordLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/forceLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/hierarchyLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/index.d.ts +0 -0
- /package/dist/{stream → components/stream}/layouts/sankeyLayoutPlugin.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/barScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/connectorScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/pieScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/pointScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/statisticalScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/timelineScene.d.ts +0 -0
- /package/dist/{stream → components/stream}/ordinalSceneBuilders/types.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/barCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/boxplotCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/candlestickCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/connectorCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/heatmapCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/lineCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkArcRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkCircleRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkEdgeRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkParticleRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/networkRectRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/pointCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/swarmCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/types.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/violinCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/waterfallCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/renderers/wedgeCanvasRenderer.d.ts +0 -0
- /package/dist/{stream → components/stream}/useResponsiveSize.d.ts +0 -0
- /package/dist/{types → components/types}/annotationTypes.d.ts +0 -0
- /package/dist/{types → components/types}/generalTypes.d.ts +0 -0
- /package/dist/{types → components/types}/interactionTypes.d.ts +0 -0
- /package/dist/{types → components/types}/networkTypes.d.ts +0 -0
- /package/dist/{types → components/types}/ordinalTypes.d.ts +0 -0
package/dist/network.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),o=require("d3-force"),a=require("d3-scale"),i=require("d3-chord"),c=require("d3-shape"),s=require("d3-hierarchy");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=l(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var o;for(let a=0;this.capacity>a;a++){const i=this.particles[a];if(!i.active)continue;const c=r[i.edgeIndex];if(!c||!c.bezier){i.active=!1;continue}const s=n&&null!==(o=n[i.edgeIndex])&&void 0!==o?o:1;if(i.t+=e*t*s*(c.bezier.circular?.3:1),i.t>=1){i.active=!1;continue}const l=y(c.bezier,i.t,i.offset);i.x=l.x,i.y=l.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function y(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const o=e.length,a=t*o,i=Math.min(Math.floor(a),o-1),c=a-i,[s,l,u,d]=e[i],h=g(s,l,u,d,c),f=d.x-s.x,y=d.y-s.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;h.x+=-y/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,o,a,i]=e.points,c=g(n,o,a,i,t),s=i.x-n.x,l=i.y-n.y,u=Math.sqrt(s*s+l*l);if(u>.001){const t=s/u;c.x+=-l/u*r*e.halfWidth*2,c.y+=t*r*e.halfWidth*2}return c}function g(e,t,r,n,o){const a=1-o,i=a*a,c=i*a,s=o*o,l=s*o;return{x:c*e.x+3*i*o*t.x+3*a*s*r.x+l*n.x,y:c*e.y+3*i*o*t.y+3*a*s*r.y+l*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],o=[],a=[],i={},c=[];function s(e){a[e]=!1,i.hasOwnProperty(e)&&Object.keys(i[e]).forEach(function(t){delete i[e][t],a[t]&&s(t)})}function l(e){var t,n,d=!1;for(o.push(e),a[e]=!0,t=0;c[e].length>t;t++)(n=c[e][t])===r?(u(r,o),d=!0):a[n]||(d=l(n));if(d)s(e);else for(t=0;c[e].length>t;t++){var h=i[n=c[e][t]];h||(i[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),a=Array(t),i=Array(t),c=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,o[s]=!1,a[s]=0,i[s]=-1,c[s]=[];var l,u=0,d=[],h=[];function f(t){var s=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>a[t]){for(var y=a[t];f.length>y;++y){var g=f[y];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,s.push(g),l.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>i[g]||c[t].push(i[g])}a[t]=y}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var b=s[y];if(o[b]=!1,p.push(b),v.push(c[b]),m+=c[b].length,i[b]=d.length,b===t){s.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}l.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);h[s]=l}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),a=1/0,i=0;o.length>i;i++)for(var c=0;o[i].length>c;c++)a>o[i][c]&&(a=o[i][c],r=i);var s=o[r];if(!s)return!1;var l=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:a,adjList:l}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,c=f.adjList){for(var y=0;c.length>y;y++)for(var g=0;c[y].length>g;g++){var p=c[y][g];a[+p]=!1,i[p]={}}l(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function L(e,t){var r=E(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function E(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function A(e,t){return t(e)}function D(e){return P(e.source)}function S(e){return P(e.target)}function P(e){return(e.y0+e.y1)/2}function T(e){return e.virtual?0:e.value}function M(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function O(e){return e.target.depth}function N(e,t){return e.sourceLinks.length?e.depth:t-1}function W(e,t){return e.y0-t.y0}function $(e,t){return t.y0-e.y0}function _(e,t){return e.y1-t.y1}function C(e,t){return t.y1-e.y1}function I(e,t){return j(e.source,t.source)||e.index-t.index}function R(e,t){return j(e.target,t.target)||e.index-t.index}function j(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function B(e,t){return F(e)==F(t)?"bottom"==e.circularLinkType?$(e,t):W(e,t):F(t)-F(e)}function F(e){return e.target.column-e.source.column}function z(e,t){return H(e)==H(t)}function H(e){return e.y0-e.y1>0?"up":"down"}function Y(e,t,n,o,a){let i=e;var c=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,c))});var s=r.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),X(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),X(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+a+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-a-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==r&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?$:W);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(l=i.links.filter(function(e){return e.target.column==r&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?C:_),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+a+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-a-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,a=(t+n)/2;return"M"+t+","+r+"C"+a+","+r+" "+a+","+o+" "+n+","+o}(e)}),i}function X(e,t,r){e.sort(B);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var a=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=a+e._circularWidth/2;else{for(var i=0;n.length>i;i++){var c=n[i];if(c!==e&&c.circularPathData&&void 0!==c.circularPathData.verticalBuffer&&G(e,c)){var s=c.circularPathData.verticalBuffer+(c._circularWidth||c.width)/2+r;a=s>a?s:a}}e.circularPathData.verticalBuffer=a+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function Z(e){return e.nodes}function K(e){return e.links}function Q(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var a=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?M(t,n)-M(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==M(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,o,a,i){var c=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,l=i;l>0;--l)u(s*=.99,n),d();function u(t,n){var o=c.length;c.forEach(function(a){var i=a.length,c=a[0].depth;a.forEach(function(a){var s;if(a.sourceLinks.length||a.targetLinks.length)if(a.partOfCycle&&M(a,n)>0){var l=r.mean(a.sourceLinks,S),u=r.mean(a.targetLinks,D),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-P(a))*t*.3;a.y0+=h,a.y1+=h}}else if(0==c&&1==i)a.y0=e.y1/2-(s=a.y1-a.y0)/2,a.y1=e.y1/2+s/2;else if(c==o-1&&1==i)a.y0=e.y1/2-(s=a.y1-a.y0)/2,a.y1=e.y1/2+s/2;else if(1==a.targetLinks.length&&1==a.targetLinks[0].source.sourceLinks.length)s=a.y1-a.y0,a.y0=a.targetLinks[0].source.y0,a.y1=a.y0+s;else{var f=r.mean(a.sourceLinks,S),y=r.mean(a.targetLinks,D),g=((f&&y?(f+y)/2:f||y)-P(a))*t;a.y0+=g,a.y1+=g}})})}function d(){c.forEach(function(r){var n,i,c,s=e.y0,l=r.length;for(r.sort(t||j),c=0;l>c;++c)(i=s-(n=r[c]).y0)>0&&(n.y0+=i,n.y1+=i),s=n.y1+o;if((i=s-o-e.y1)>0)for(s=n.y0-=i,n.y1-=i,c=l-2;c>=0;--c)(i=(n=r[c]).y1+a-s)>0&&(n.y0-=i,n.y1-=i),s=n.y0})}}function U(e){e.nodes.forEach(function(e){e.sourceLinks.sort(R),e.targetLinks.sort(I)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,a=24,i=8,c=null,s=V,l=N,u=void 0,d=32,h=2,f=Z,y=K;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof o&&(o=e.target=p(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var a=e.links[o],i=a.source.index,c=a.target.index;n[i]||(n[i]=[]),n[c]||(n[c]=[]),-1===n[i].indexOf(c)&&n[i].push(c)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var l={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){A(e,t)!=A(o.source,t)&&A(e,t)!=A(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,T),r.sum(e.targetLinks,T)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,o,a;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var i=0,c=t(e.nodes[0]);e.nodes.forEach(function(e){i=t(e)==c?i:i+1,c=t(e)==c?c:t(e),e.column=i})}for(n=e.nodes,o=[],a=0;n.length;++a,n=o,o=[])n.forEach(function(e){e.depth=a,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],a=0;n.length;++a,n=o,o=[])n.forEach(function(e){e.height=a,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,a):e.column})}(f,u,l);var y=i;if(null!==c){var g=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(g,function(e){return e.length});m>1&&(y=Math.max(1,(o-t)*c/(m-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var a=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=a,e.links.forEach(function(t){t.width=t.value*e.ky});var i=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,a),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return A(r.source,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!z(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var a=e.y0;n.forEach(function(e){e.y0=a+e.width/2,a+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var a=r+1,i=0;o>a;a++)i+=n[a].width;t.y0=e.y1-i-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return A(r.target,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!z(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=L(t,e);return e.y0-r}if(t.source.column>e.source.column)return L(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var a=e.y0;n.forEach(function(e){e.y1=a+e.width/2,a+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var a=r+1,i=0;o>a;a++)i+=n[a].width;t.y1=e.y1-i-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,o=!1,a=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(a=!0)}),0==o||0==a){var i=r.min(t,function(e){return e.y0}),c=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(c-i);function l(t){return(t-i)/(c-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),Y(f,s,h,10,8)}(g),g}return g.update=function(e){return U(e),Y(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(a=+e,g):a},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(c=+e,g):c},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:q(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:q(e),g):l},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],g):[[e,t],[n,o]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],g):[n-e,o-t]},g}const te=e=>{let r,n,o,a,i,c,s,l,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,a=e.y0+e.sankeyWidth/2,i=e.source.y1,c=e.target.y0,s=t.interpolateNumber(i,c),l=s(.5),u=s(.5),`M${r},${i}C${r},${l} ${n},${u} ${n},${c}L${o},${c}C${o},${u} ${a},${l} ${a},${i}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),o=s(.5),a=s(.5),i=e.y0-e.sankeyWidth/2,c=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${i}C${o},${i} ${a},${c} ${n},${c}L${n},${l}C${a},${l} ${o},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,a=o.targetX,i=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const c=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(a-o.leftFullExtent)));return`M${t},${n-r}L${t+c},${n-r}L${t+c},${n+r}L${t},${n+r}ZM${a},${i-r}L${a-s},${i-r}L${a-s},${i+r}L${a},${i+r}Z`}const a=o.sourceX,i=o.sourceY,c=o.targetX,s=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${a},${i-h*r}L${l},${i-h*r}L${l+n},${i-h*r+h*f}L${l+n},${d+h*n-h*f}L${l+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${c},${s-h*r}L${c},${s+h*r}L${u+n},${s+h*r}L${u+n},${d-h*n}L${l-n},${d-h*n}L${l-n},${i+h*r}L${a},${i+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(O))-1:0},justify:N},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,a,i,c,s,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(o=r.nodeWidth)&&void 0!==o?o:15,y=null!==(a=r.nodePaddingRatio)&&void 0!==a?a:.05,g=null!==(i=r.iterations)&&void 0!==i?i:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||N).nodeId(e=>e.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const a=n.circularPathData,i=(null!==(s=null!==(c=n._circularWidth)&&void 0!==c?c:n.width)&&void 0!==s?s:0)/2;e>a.leftFullExtent-i&&(e=a.leftFullExtent-i),a.rightFullExtent+i>t&&(t=a.rightFullExtent+i),r>a.verticalFullExtent-i&&(r=a.verticalFullExtent-i),a.verticalFullExtent+i>o&&(o=a.verticalFullExtent+i)}const a=t-e,i=o-r,u=n[0],d=n[1];if(a>0&&i>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/a,d/i),n=-e*t+(u-a*t)/2,o=-r*t+(d-i*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(l=e.width)&&void 0!==l?l:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",a=k.get(`${n}\0${o}`);if(a){a.y0=e.y0,a.y1=e.y1,a.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,a.circular=!!e.circular,a.circularPathData=e.circularPathData,a._circularWidth=e._circularWidth,a._circularStub=e._circularStub,a.path=e.path,a.circularLinkType=e.circularLinkType,a.direction=d;const t=x.get(n),r=x.get(o);t&&(a.source=t),r&&(a.target=r)}}},buildScene(e,t,r,o){var a,i,c,s;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(a=r.edgeOpacity)&&void 0!==a?a:.5,f=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},o={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const o=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=o.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+a},${t.sourceY-r}L${t.sourceX+a},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+a}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let a;if(a=e.circular&&e.circularPathData?re(e):te(e),!a)continue;const l={fill:o.fill||n,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};v.push({type:"bezier",pathD:a,bezierCache:e.bezier,style:l,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const a=t?t(r):r.id;if(!a)continue;let i,c,s;"down"===l?(i=r.x0+e/2,c=r.y1+14,s="middle"):(o[0]/2>r.x0+e/2?(i=r.x0-6,s="end"):(i=r.x1+6,s="start"),c=r.y0+n/2),m.push({x:i,y:c,text:a+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},ae={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var a,i;if(0===e.length)return;const c=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,l=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const r=e[t];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;r.x=l+e*Math.cos(n),r.y=u+e*Math.sin(n)}}const d=ie(r.nodeSize,r.nodeSizeRange,e),h=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),f=n[1]/n[0],y=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",o.forceX(n[0]/2).strength(.1*f)).force("y",o.forceY(n[1]/2).strength(.1));if(y.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));y.force("link",h),y.force("link").links(e)}.1>y.alpha()&&y.alpha(1),y.stop();for(let e=0;c>e;++e)y.tick();const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var a,i,c;const s=r.nodeStyle,l=r.edgeStyle,u=ie(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=l?l(e):{},o={stroke:n.stroke||"#999",strokeWidth:null!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(c=n.opacity)&&void 0!==c?c:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:o,datum:e})}if(!1!==r.showLabels){const t=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ie(e,t,n){var o,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const c=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>c[0];const l=null!==(o=r.min(s))&&void 0!==o?o:0,u=null!==(i=r.max(s))&&void 0!==i?i:1;if(l===u)return()=>(c[0]+c[1])/2;const d=a.scaleLinear().domain([l,u]).range(c).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?c[0]:d(n)}}const ce=n.schemeCategory10,se={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:a=20,sortGroups:s}=r,l=Math.min(n[0],n[1])/2,u=l-a,d=n[0]/2,h=n[1]/2,f=(y=r.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=g.get("string"==typeof e.source?e.source:e.source.id),n=g.get(t);if(void 0===r||void 0===n)continue;const o=f(e);v[r][n]=o}const m=i.chord().padAngle(o);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const L=new Map;for(const e of t)L.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=L.get(`${r}\0${n}`)||L.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,a;const{groupWidth:c=20,edgeOpacity:s=.5}=r,l=Math.min(n[0],n[1])/2,u=l-c,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:ce,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=i.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let a;a=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const i=f?f(r):{},c={fill:a,stroke:i.stroke||"black",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:i.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:c,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=le(r,d,h);let o="#999";if(y)o=y(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===g&&r?o=v.get(r.id)||o:t&&(o=v.get(t.id)||o)}const i=y?y(e):{},c={fill:o,fillOpacity:null!==(a=i.fillOpacity)&&void 0!==a?a:s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};x.push({type:"ribbon",pathD:n,style:c,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=l+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const a=(e.startAngle+e.endAngle)/2,i=a-Math.PI/2;k.push({x:d+Math.cos(i)*n,y:h+Math.sin(i)*n,text:o+"",anchor:a>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function le(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let a=0;for(;n.length>a;){const e=n[a];if("M"===e||"L"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)o.push(Number(n[a])+t+""),a++,n.length>a&&!isNaN(Number(n[a]))&&(o.push(Number(n[a])+r+""),a++);else if("C"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)for(let e=0;3>e&&n.length>a&&!isNaN(Number(n[a]));e++)o.push(Number(n[a])+t+""),a++,n.length>a&&!isNaN(Number(n[a]))&&(o.push(Number(n[a])+r+""),a++);else if("Q"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)for(let e=0;2>e&&n.length>a&&!isNaN(Number(n[a]));e++)o.push(Number(n[a])+t+""),a++,n.length>a&&!isNaN(Number(n[a]))&&(o.push(Number(n[a])+r+""),a++);else if("A"===e)for(o.push(e),a++;n.length>a&&!isNaN(Number(n[a]));)o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&o.push(n[a++]),n.length>a&&(o.push(Number(n[a])+t+""),a++),n.length>a&&(o.push(Number(n[a])+r+""),a++);else"Z"===e||"z"===e?(o.push(e),a++):(o.push(n[a]),a++)}return o.join(" ")}const ue={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const a=r.__hierarchyRoot;if(!a)return;const i=r.chartType,c=(l=r.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(a,c);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(i){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",a=s.tree();a.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),a(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",a=s.cluster();a.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),a(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var o,a;const i=null!==(o=t.padding)&&void 0!==o?o:4,c=null!==(a=t.paddingTop)&&void 0!==a?a:0,l=s.treemap().size([r,n]).tile(s.treemapBinary).padding(i);c>0&&l.paddingTop(c),l(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var o;const a=null!==(o=t.padding)&&void 0!==o?o:4;s.pack().size([r,n]).padding(a)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var o;s.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],a={id:ge(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?de(a,n,r):"treemap"===i||"partition"===i?he(a,n):"circlepack"===i&&fe(a,n),a.__hierarchyNode=n,e.push(a),g.set(n,a)}if("tree"===i||"cluster"===i)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),a=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,a){var i,c,s,l,u;const d=[],h=[],f=[],y=r.treeOrientation||"vertical",g="radial"===y,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;g&&(e+=p,n+=v);const a=o(t);let c=a.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(c=b[t.depth%b.length]);const s={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(c=r.edgeOpacity)&&void 0!==c?c:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,o=t.y,i=r.x,c=r.y;g&&(n+=p,o+=v,i+=p,c+=v);const u=ye(n,o,i,c,y),d=a(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=pe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,a,i=r.x,c=r.y;if(g&&(i+=p,c+=v),g){const e=i-p,t=c-v,r=Math.sqrt(e*e+t*t);r>0?(n=i+e/r*10,o=c+t/r*10,a=0>e?"end":"start"):(n=i,o=c-12,a="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=i-m-6,a="end"):(n=i+m+6,a="start"),o=c):(n=i,o=c+m+14,a="middle");f.push({x:n,y:o,text:e+"",anchor:a,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,o,a);case"treemap":case"partition":return function(e,t,r,n){var o,a;const i=[],c=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,a=r.y1-r.y0;if(0>=e||0>=a)continue;const c=n(r);let l=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(l=s[r.depth%s.length]);const u={fill:l,stroke:c.stroke||"#fff",strokeWidth:null!==(o=c.strokeWidth)&&void 0!==o?o:1,opacity:c.opacity};i.push({type:"rect",x:r.x0,y:r.y0,w:e,h:a,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;if((null===(a=n.data)||void 0===a?void 0:a.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const i=r?r(n):n.id;i&&(30>e||16>o||c.push({x:n.x0+e/2,y:n.y0+o/2,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,o)/6))}))}}return{sceneNodes:i,sceneEdges:[],labels:c}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,a,i,c,s;const l=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const c=n(r);let s=c.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:c.stroke||"#fff",strokeWidth:null!==(a=c.strokeWidth)&&void 0!==a?a:1,opacity:null!==(i=c.opacity)&&void 0!==i?i:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const t of e){const e=null!==(c=t.__radius)&&void 0!==c?c:5,n=r?r(t):t.id;if(!n)continue;if(15>e)continue;const o=!((null===(s=t.data)||void 0===s?void 0:s.children)&&t.data.children.length>0);u.push({x:t.x,y:o?t.y:t.y-e+14,text:n+"",anchor:"middle",baseline:o?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:o?void 0:"#000",stroke:o?void 0:"#fff",strokeWidth:o?void 0:3,paintOrder:o?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function de(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function he(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function fe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ye(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}function ge(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function pe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}const ve={sankey:oe,force:ae,chord:se,tree:ue,cluster:ue,treemap:ue,circlepack:ue,partition:ue};function me(e){return ve[e]}class be{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new f(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:a="target",valueAccessor:i="value"}=this.config,c="function"==typeof n?n:e=>e[n],s="function"==typeof o?o:e=>e[o],l="function"==typeof a?a:e=>e[a],u="function"==typeof i?i:e=>{var t;return null!==(t=e[i])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=c(t)+"";this.nodes.set(e,Object.assign(Object.assign({},xe(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=l(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},xe(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},xe(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let a=!1;const i="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=i,this.nodes.has(t)||(this.nodes.set(t,xe(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,a=!0),this.nodes.has(r)||(this.nodes.set(r,xe(r)),this.nodeTimestamps.set(r,i),this.tension+=this.tensionConfig.newNode,a=!0);const c=this.edgeKey(t,r),s=this.edges.get(c);return s?(s.value+=n,this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.weightChange):(this.edges.set(c,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(c,i),this.tension+=this.tensionConfig.newEdge,a=!0),o||a||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=me(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(r,n,this.config,e),t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear();for(const e of r)this.nodes.set(e.id,e);for(const e of n)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const o=new Set(this.nodes.keys()),a=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of o)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)o.has(e)||this.removedNodes.add(e);for(const e of a)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)a.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=o,this.previousEdgeKeys=a,this.layoutVersion++}buildScene(e){const t=me(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:a,labels:i}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=a,this.labels=i}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),r=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*r,e.x1=e._prevX1+(e._targetX1-e._prevX1)*r,e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*r);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const a=r.y1,i=n.y0,c=t.interpolateNumber(a,i);return{circular:!1,points:[{x:e.y0,y:a},{x:e.y0,y:c(.5)},{x:e.y1,y:c(.5)},{x:e.y1,y:i}],halfWidth:o}}const a=r.x1,i=n.x0,c=t.interpolateNumber(a,i);return{circular:!1,points:[{x:a,y:e.y0},{x:c(.5),y:e.y0},{x:c(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],a=r.x-t.x,i=r.y-t.y;o.push([t,{x:t.x+a/3,y:t.y+i/3},{x:t.x+2*a/3,y:t.y+2*i/3},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,a;const i=this.config.pulse;if(!i)return;const c=null!==(t=i.duration)&&void 0!==t?t:500,s=null!==(r=i.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(n=i.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;c>o&&(t._pulseIntensity=1-o/c,t._pulseColor=s,t._pulseGlowRadius=l)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,i="object"==typeof r.target?null===(a=r.target)||void 0===a?void 0:a.id:r.target;if(!n||!i)continue;const l=this.edgeTimestamps.get(`${n}\0${i}`);if(!l)continue;const u=e-l;c>u&&(t._pulseIntensity=1-u/c,t._pulseColor=s)}}applyDecay(){var e,t,r,n,o;const a=this.config.decay;if(!a)return;const i=null!==(e=a.minOpacity)&&void 0!==e?e:.1,c=this.nodeTimestamps.size;if(1>=c)return;const s=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),l=new Map;for(let e=0;s.length>e;e++)l.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=l.get(s);if(void 0===u)continue;const d=c-1-u;let h;switch(a.type){case"linear":h=i+(1-d/(c-1))*(1-i);break;case"exponential":{const e=null!==(t=a.halfLife)&&void 0!==t?t:c/2;h=i+Math.pow(.5,d/e)*(1-i);break}case"step":h=(null!==(r=a.stepThreshold)&&void 0!==r?r:.5*c)>d?1:i;break;default:h=1}const f=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",a=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",i=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const c=this.nodes.get(r);if(!c)continue;const s=n.metric(c);let l=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(l=o):l=a,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),i&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=l,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function xe(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ke(e,t,r,n,o=30){let a=null,i=o,c=1/0;for(const t of e){const e=we(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;c>r&&(a=e,c=r)}else i>e.distance&&(a=e,i=e.distance)}if(a)return a;for(const e of t){const t=Le(e,r,n);t&&i>t.distance&&(a=t,i=t.distance)}return a}function we(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,o=r-e.cy,a=Math.sqrt(n*n+o*o);return a>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r);case"rect":return function(e,t,r){return e.x>t||t>e.x+e.w||e.y>r||r>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,a=Math.sqrt(n*n+o*o);if(e.innerR-2>a||a>e.outerR+2)return null;let i=Math.atan2(o,n);0>i&&(i+=2*Math.PI);let c,s=e.startAngle,l=e.endAngle;if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),c=s>l?i>=s||l>=i:i>=s&&l>=i,c){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}function Le(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;try{const a=new Path2D(e.pathD),i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.isPointInPath(a,t,r)){const a="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:a&&i?(a.x1+i.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,a=n*n+o*o;if(0===a)return null;let i=((t-e.x1)*n+(r-e.y1)*o)/a;i=Math.max(0,Math.min(1,i));const c=e.x1+i*n,s=e.y1+i*o,l=Math.sqrt(Math.pow(t-c,2)+Math.pow(r-s,2));return l>5?null:{type:"edge",datum:e.datum,x:c,y:s,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=document.createElement("canvas").getContext("2d");if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0}}catch(e){}return null}(e,t,r);default:return null}}function Ee(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:a,labels:i,title:c,legend:s,foregroundGraphics:l,annotations:d,svgAnnotationRules:h}=e;return u.createElement("svg",{width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${a.left},${a.top})`},i.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),d&&h&&d.map((e,n)=>{const o=h(e,n,{width:t,height:r});return o?u.createElement(u.Fragment,{key:"annotation-"+n},o):null}),l),c&&"string"==typeof c?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},c):c?u.createElement("foreignObject",{x:0,y:0,width:n,height:a.top},c):null,s&&"object"==typeof s&&"legendGroups"in s?u.createElement("g",{transform:`translate(${n-a.right+10},${a.top})`},s.legendGroups.map((e,t)=>{var r;return u.createElement("g",{key:"legend-group-"+t},null===(r=e.items)||void 0===r?void 0:r.map((e,t)=>u.createElement("g",{key:"legend-item-"+t,transform:`translate(0,${20*t})`},u.createElement("rect",{x:0,y:0,width:12,height:12,fill:e.color,rx:2}),u.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},e.label))))})):s?u.createElement("g",{transform:`translate(${n-a.right+10},${a.top})`},s):null)}function Ae(e,t){var r,n,o,a,i,c;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const i=t._gradient;if(i){const o=e.createLinearGradient(i.x0,0,i.x1,0),a=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,c=t.style.fill;o.addColorStop(0,1===i.from?c:"transparent"),o.addColorStop(1,1===i.to?c:"transparent"),e.fillStyle=o,e.globalAlpha=a}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(a=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==a?a:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.5*(null!==(c=t.style.opacity)&&void 0!==c?c:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function De(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Se(e,t){var r,n,o,a;if(!t.pathD)return;e.save();const i=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(i)),e.restore()}function Pe(e,t){var r,n;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}Ee.displayName="NetworkSVGOverlay";const Te={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},Me=n.schemeCategory10,Oe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function Ne(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):Me[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Me.length]}function We(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>e[t]))),o=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return a.scaleOrdinal().domain(n).range(r).unknown("#999");const i=Te[r]||Te.category10;if(o&&"function"==typeof i)return e=>i(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(i)?i:Me;return a.scaleOrdinal().domain(n).range(e).unknown("#999")}}const $e={top:20,right:80,bottom:20,left:80},_e={top:40,right:40,bottom:40,left:40},Ce=new Set(["chord","force","circlepack"]),Ie=[800,600],Re={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function je({data:e}){var t,r,n,o,a,i;if("edge"===e.type){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:Re},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const c=e.data,s=null==c?void 0:c.__hierarchyNode;if(s){const e=[];let a=s;for(;a;){const i=null!==(o=null!==(r=null===(t=a.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=a.data)||void 0===n?void 0:n.id)&&void 0!==o?o:c.id;null!=i&&e.unshift(i+""),a=a.parent}e.length>1&&e.shift();const i=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:Re},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===i?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof c.value?c.value.toLocaleString():c.value+""))}const l=((null===(a=c.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(i=c.targetLinks)||void 0===i?void 0:i.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:Re},u.createElement("div",{style:{fontWeight:600}},c.id),null!=c.value&&c.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const Be=e.forwardRef(function(t,r){const{chartType:n,nodes:o,edges:a,data:i,initialEdges:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:f="target",valueAccessor:y="value",childrenAccessor:g,hierarchySum:p,orientation:v="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,iterations:k=300,forceStrength:w=.1,padAngle:L=.01,groupWidth:E=20,sortGroups:A,edgeSort:D,treeOrientation:S="vertical",edgeType:P="curve",padding:T,paddingTop:M,tensionConfig:O,showParticles:N=!1,particleStyle:W,nodeStyle:$,edgeStyle:_,colorBy:C,colorScheme:I="category10",edgeColorBy:R="source",edgeOpacity:j=.5,colorByDepth:B=!1,nodeSize:F=8,nodeSizeRange:z=[5,20],nodeLabel:H,showLabels:Y=!0,size:X=Ie,responsiveWidth:G,responsiveHeight:q,margin:V,className:Z,background:K,enableHover:Q=!0,tooltipContent:J,customHoverBehavior:U,customClickBehavior:ee,onObservation:te,chartId:re,onTopologyChange:ne,annotations:oe,svgAnnotationRules:ae,legend:ie,title:ce,foregroundGraphics:se,backgroundGraphics:le,decay:ue,pulse:de,staleness:he,thresholds:fe}=t,ye=Ce.has(n)?_e:$e,[ge,pe]=function(t,r,n){const o=e.useRef(null),[a,i]=e.useState(null);return e.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;i(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&a?a.w:t[0],n&&a?a.h:t[1]]]}(X,G,q),ve=Object.assign(Object.assign({},ye),V),me=pe[0]-ve.left-ve.right,xe=pe[1]-ve.top-ve.bottom,we=e.useMemo(()=>Object.assign(Object.assign({},d),O),[O]),Le=e.useMemo(()=>Object.assign(Object.assign({},h),W),[W]),Te=e.useMemo(()=>({chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:f,valueAccessor:y,childrenAccessor:g,hierarchySum:p,orientation:v,nodeAlign:m,nodePaddingRatio:b,nodeWidth:x,iterations:k,forceStrength:w,padAngle:L,groupWidth:E,sortGroups:A,edgeSort:D,treeOrientation:S,edgeType:P,padding:T,paddingTop:M,tensionConfig:we,showParticles:N,particleStyle:Le,nodeStyle:$,edgeStyle:_,nodeLabel:H,showLabels:Y,colorBy:C,colorScheme:I,edgeColorBy:R,edgeOpacity:j,colorByDepth:B,nodeSize:F,nodeSizeRange:z,decay:ue,pulse:de,staleness:he,thresholds:fe}),[n,s,l,f,y,g,p,v,m,b,x,k,w,L,E,A,D,S,P,T,M,we,N,Le,$,_,H,Y,C,I,R,j,B,F,z,ue,de,he,fe]),Oe=e.useRef(null),Ne=e.useRef(0),We=e.useRef(0),Re=e.useRef(!0),Be=e.useRef(()=>{}),Fe=e.useRef(null);Fe.current||(Fe.current=new be(Te));const[ze,He]=e.useState(null),[Ye,Xe]=e.useState(0),[Ge,qe]=e.useState(0),[Ve,Ze]=e.useState(!1),Ke=e.useRef(null),Qe=e.useRef(new Map),Je=e.useRef(0),Ue=e.useCallback(e=>{if("function"==typeof C)return C(e);if("string"==typeof C&&e.data){const t=e.data[C];if(void 0!==t){if(!Qe.current.has(t+"")){const e=Array.isArray(I)?I:Me;Qe.current.set(t+"",e[Je.current++%e.length])}return Qe.current.get(t+"")}}if(!Qe.current.has(e.id)){const t=Array.isArray(I)?I:Me;Qe.current.set(e.id,t[Je.current++%t.length])}return Qe.current.get(e.id)},[C,I]),et=e.useCallback(e=>{if("function"==typeof R)return R(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===R&&r?Ue(r):t?Ue(t):"#999"},[R,Ue]),tt=e.useCallback(e=>{if(!(null==W?void 0:W.colorBy))return et(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Le.colorBy&&r?Ue(r):t?Ue(t):"#999"},[null==W?void 0:W.colorBy,Le.colorBy,Ue,et]),rt="sankey"===n&&N||!!de,nt=e.useCallback(()=>{Ne.current&&!rt||Ne.current||(Ne.current=requestAnimationFrame(()=>Be.current()))},[rt]);e.useEffect(()=>{var e;null===(e=Fe.current)||void 0===e||e.updateConfig(Te),Re.current=!0,nt()},[Te,nt]);const ot=e.useCallback(()=>{const e=Fe.current;if(!e)return;e.runLayout([me,xe]),e.buildScene([me,xe]),Re.current=!0;const t=Array.isArray(I)?I:Me,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];Qe.current.has(n.id)||Qe.current.set(n.id,t[e%t.length])}if(Je.current=r.length,Xe(e.layoutVersion),ne){const{nodes:t,edges:r}=e.getLayoutData();ne(t,r)}},[me,xe,ne,I]),at=e.useCallback(e=>{const t=Fe.current;t&&(t.ingestEdge(e)&&ot(),nt())},[ot,nt]),it=e.useCallback(e=>{const t=Fe.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&ot(),nt()},[ot,nt]),ct=e.useCallback(()=>{var e;null===(e=Fe.current)||void 0===e||e.clear(),Qe.current.clear(),Je.current=0,Xe(0),He(null),Ke.current=null,Re.current=!0,nt()},[nt]),st=e.useCallback(()=>{const e=Fe.current;e&&(e.tension+=999,ot(),nt())},[ot,nt]);e.useImperativeHandle(r,()=>({push:at,pushMany:it,clear:ct,getTopology:()=>{var e,t;return null!==(t=null===(e=Fe.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Fe.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:st,getTension:()=>{var e,t;return null!==(t=null===(e=Fe.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[at,it,ct,st]);const lt=["tree","cluster","treemap","circlepack","partition"].includes(n),ut=lt?i||(Array.isArray(a)?void 0:a):void 0;e.useEffect(()=>{const e=Fe.current;if(e)if(lt&&ut)e.ingestHierarchy(ut,[me,xe]),e.buildScene([me,xe]),Re.current=!0,nt();else{const t=o||[],r=Array.isArray(a)?a:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[me,xe]),e.buildScene([me,xe]);const n=Array.isArray(I)?I:Me,i=Array.from(e.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Qe.current.has(t.id)||Qe.current.set(t.id,n[e%n.length])}Je.current=i.length,Re.current=!0,nt()}},[o,a,i,ut,lt,me,xe,Te,nt,I]),e.useEffect(()=>{c&&c.length>0&&it(c)},[]);const dt=e.useCallback(e=>{if(U&&U(e),te){const t=Date.now();te(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:re}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:re})}},[U,te,re]),ht=e.useCallback(e=>{if(ee&&ee(e),te){const t=Date.now();te(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:re}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:re})}},[ee,te,re]),ft=e.useRef(()=>{}),yt=e.useRef(()=>{});ft.current=e=>{if(!Q)return;const t=Oe.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ve.left,o=e.clientY-r.top-ve.top;if(0>n||n>me||0>o||o>xe)return void(Ke.current&&(Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),nt()));const a=Fe.current;if(!a)return;const i=ke(a.sceneNodes,a.sceneEdges,n,o);if(!i)return void(Ke.current&&(Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),nt()));const c={type:i.type,data:i.datum,x:i.x,y:i.y};Ke.current=c,He(c),dt&&(dt(c),Re.current=!0),nt()},yt.current=()=>{Ke.current&&(Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),nt())};const gt=e.useRef(()=>{});gt.current=e=>{if(!ee&&!te)return;const t=Oe.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ve.left,o=e.clientY-r.top-ve.top;if(0>n||n>me||0>o||o>xe)return;const a=Fe.current;if(!a)return;const i=ke(a.sceneNodes,a.sceneEdges,n,o);ht(i?{type:i.type,data:i.datum,x:i.x,y:i.y}:null)},e.useCallback(e=>ft.current(e),[]);const pt=e.useCallback(()=>yt.current(),[]),vt=e.useCallback(e=>gt.current(e),[]),mt=e.useRef(-1),bt=e.useCallback(e=>{const t=Fe.current;if(!t)return;const r=function(e){const t=[];for(const r of e)"circle"===r.type&&null!=r.cx?t.push({x:r.cx,y:r.cy,datum:r.datum}):"rect"===r.type&&null!=r.x?t.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum}):"arc"===r.type&&null!=r.cx&&t.push({x:r.cx,y:r.cy,datum:r.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return;const n=mt.current,o=function(e,t,r){switch(e){case"ArrowRight":case"ArrowDown":return r-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return r-1;case"Escape":return-1;default:return null}}(e.key,0>n?-1:n,r.length);if(null===o)return;if(e.preventDefault(),0>o)return mt.current=-1,Ke.current=null,He(null),dt&&(dt(null),Re.current=!0),void nt();const a=0>n?0:o;mt.current=a;const i=r[a],c={type:"node",data:i.datum,x:i.x,y:i.y};Ke.current=c,He(c),dt&&(dt(c),Re.current=!0),nt()},[dt,nt]),xt=e.useCallback(e=>{mt.current=-1,ft.current(e)},[]);Be.current=()=>{var e,t,r;Ne.current=0;const n=Oe.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const a=Fe.current;if(!a)return;const i=performance.now(),c=We.current?Math.min((i-We.current)/1e3,.1):.016;We.current=i;const s=a.advanceTransition(i);(s||Re.current)&&a.buildScene([me,xe]);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=pe[0]*l,n.height=pe[1]*l,n.style.width=pe[0]+"px",n.style.height=pe[1]+"px",o.scale(l,l),o.translate(ve.left,ve.top),o.clearRect(-ve.left,-ve.top,pe[0],pe[1]),K&&(o.fillStyle=K,o.fillRect(0,0,me,xe)),ue&&a.applyDecay(),de&&a.applyPulse(i),fe&&a.applyThresholds(i),a.applyTopologyDiff(i);const u=null!==(e=null==he?void 0:he.threshold)&&void 0!==e?e:5e3,d=he&&a.lastIngestTime>0&&i-a.lastIngestTime>u;if(d&&(o.globalAlpha=null!==(t=null==he?void 0:he.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Ae(e,r);break;case"line":De(e,r);break;case"ribbon":Se(e,r);break;case"curved":Pe(e,r)}}(o,a.sceneEdges),function(e,t){var r,n,o;for(const a of t){if("rect"!==a.type)continue;const t=a;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(o,a.sceneNodes),function(e,t){var r,n,o,a;for(const i of t){if("circle"!==i.type)continue;const t=i;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const r=null!==(a=t._pulseGlowRadius)&&void 0!==a?a:4,n=t.r+r*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,n,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(o,a.sceneNodes),function(e,t){var r,n,o;for(const a of t){if("arc"!==a.type)continue;const t=a;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(o,a.sceneNodes),N&&a.particlePool&&!d){const e=Array.from(a.edges.values());if(e.length>0){!function(e,t,r,n){var o,a;const i=null!==(o=n.spawnRate)&&void 0!==o?o:h.spawnRate,c=null!==(a=n.maxPerEdge)&&void 0!==a?a:h.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=c)continue;const a=o.value*i*r*(o.bezier.circular?.3:1),s=Math.floor(a),l=a-s;let u=s;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<c;t++)e.spawn(n)}}(a.particlePool,e,c,Le);const t=.5*(null!==(r=Le.speedMultiplier)&&void 0!==r?r:1);let n;if(Le.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}a.particlePool.step(c,t,e,n),function(e,t,r,n,o){var a,i;const c=null!==(a=n.radius)&&void 0!==a?a:h.radius,s=null!==(i=n.opacity)&&void 0!==i?i:h.opacity;e.globalAlpha=s;for(let a=0;t.particles.length>a;a++){const i=t.particles[a];if(!i.active)continue;const s=r[i.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(s);e.beginPath(),e.arc(i.x,i.y,c,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(o,a.particlePool,e,Le,tt)}}d&&(o.globalAlpha=1);const f=Re.current;Re.current=!1,(f||s)&&qe(e=>e+1),(rt||s||a.hasActivePulses||a.hasActiveThresholds||a.hasActiveTopologyDiff)&&(Ne.current=requestAnimationFrame(()=>Be.current()))},e.useEffect(()=>(nt(),()=>{Ne.current&&(cancelAnimationFrame(Ne.current),Ne.current=0)}),[nt]),e.useEffect(()=>{Re.current=!0,nt()},[n,me,xe,K,nt]),e.useEffect(()=>{if(!he)return;const e=setInterval(()=>{var e;const t=Fe.current;if(!t||0===t.lastIngestTime)return;const r="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=he.threshold)&&void 0!==e?e:5e3,o=r-t.lastIngestTime>n;o!==Ve&&(Ze(o),Re.current=!0,nt())},1e3);return()=>clearInterval(e)},[he,Ve,nt]);const kt=Q&&ze?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ve.left+ze.x,top:ve.top+ze.y,transform:`translate(${ze.x>.6*me?"calc(-100% - 12px)":"12px"}, ${.3*xe>ze.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},J?J(ze):u.createElement(je,{data:ze})):null,wt=Fe.current;return u.createElement("div",{ref:ge,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":"string"==typeof ce?ce:"Network chart",tabIndex:0,style:{position:"relative",width:G?"100%":pe[0],height:q?"100%":pe[1]},onMouseMove:Q?xt:void 0,onMouseLeave:Q?pt:void 0,onClick:ee||te?vt:void 0,onKeyDown:bt},le&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:pe[0],height:pe[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${ve.left},${ve.top})`},le)),u.createElement("canvas",{ref:Oe,style:{position:"absolute",top:0,left:0}}),u.createElement(Ee,{width:me,height:xe,totalWidth:pe[0],totalHeight:pe[1],margin:ve,labels:(null==wt?void 0:wt.labels)||[],title:ce,legend:ie,foregroundGraphics:se,annotations:oe,svgAnnotationRules:ae,annotationFrame:Ge}),kt,(null==he?void 0:he.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===he.badgePosition?{top:4,left:4}:"bottom-left"===he.badgePosition?{bottom:4,left:4}:"bottom-right"===he.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ve?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ve?"STALE":"LIVE"))});Be.displayName="StreamNetworkFrame";const Fe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function ze(e,t){return"function"==typeof t?t(e):e[t]}function He(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Ye(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:r,format:n,style:o={},className:a=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let i;const c=[];if(r){const t=ze(e,r);i=He(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,o,a;"string"==typeof t?(r=t,o=t,a=n):(r=t.label,o=t.accessor||t.key||"",a=t.format||n);const i=ze(e,o);c.push({label:r,value:He(i,a)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){i=He(e[r],n);break}if(!i){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(i=He(e[t[0]],n))}}const s=Object.assign(Object.assign({},Fe),o);return u.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:s},i&&u.createElement("div",{style:{fontWeight:c.length>0?"bold":"normal"}},i),c.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&i?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}(e)))}const Xe=e.createContext(null);function Ge(t){const r=e.createContext(null),n=qe(t);return[function({children:n}){const o=e.useMemo(()=>qe(t),[]);return u.createElement(r.Provider,{value:o,children:n})},t=>{var o;const a=null!==(o=e.useContext(r))&&void 0!==o?o:n;return function(t,r){const[n,o]=e.useState(r);return e.useLayoutEffect(()=>t(()=>o(r)),[t]),n}(a.subscribe,()=>t(a.getState()))}]}function qe(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function Ve(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function Ze(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Ke,Qe]=Ge(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Ze(n,t),a=new Map(o.clauses);return a.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:a})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),a=new Map(n.clauses);return a.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:a})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=Ze(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}}));function Je(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,a=Qe(e=>e.selections.get(o)),i=Qe(e=>e.setClause),c=Qe(e=>e.clearClause),s=e.useMemo(()=>!!a&&a.clauses.size>0,[a]);return{predicate:e.useMemo(()=>a&&0!==a.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(Ve(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(a,n):()=>!0,[a,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};i(o,{clientId:n,type:"point",fields:t})},[n,o,i]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};i(o,{clientId:n,type:"interval",fields:t})},[n,o,i]),clear:e.useCallback(()=>{c(o,n)},[c,o,n]),clientId:n}}const[Ue,et]=Ge(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),tt="#007bff";function rt(t,r,n="category10"){const o=e.useContext(Xe);return e.useMemo(()=>{if(r&&"function"!=typeof r)return o&&Object.keys(o).length>0?e=>o[e]||We(t,r,n)(e):We(t,r,n)},[t,r,n,o])}function nt({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:a,chartType:i,chartId:c}){const s=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(r,n),l=Je({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:a,selectPoints:i,clear:c}=Je({name:r});return{onHover:e.useCallback(e=>{if(!e)return void c();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&i(t)},[n,i,c,r]),predicate:o,isActive:a}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),d=et(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:l.isActive,predicate:l.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(a||d){const r={timestamp:Date.now(),chartType:i||"unknown",chartId:c};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const i=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});a&&a(i),d&&d(i)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});a&&a(e),d&&d(e)}}},[r,u,a,i,c,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(a||d){const n={timestamp:Date.now(),chartType:i||"unknown",chartId:c};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const i=Object.assign(Object.assign({},n),{type:"click",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});a&&a(i),d&&d(i)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});a&&a(e),d&&d(e)}}},[a,d,i,c])}}const ot={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function at(e,t,r){var n,o,a,i,c,s;const l=ot[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?l.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?l.height:r.height,showAxes:l.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:l.showGrid,enableHover:null!==(i=t.enableHover)&&void 0!==i?i:!!t.linkedHover||l.enableHover,showLegend:null!==(c=t.showLegend)&&void 0!==c?c:l.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:l.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:l.marginDefaults}}function it({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class ct extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var r,n;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:u.createElement(it,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function st({componentName:e,width:t,height:r,children:n}){return u.createElement(ct,{fallback:n=>u.createElement(it,{componentName:e,message:n.message,width:t,height:r})},n)}function lt(e,t){if(0===t.length)return null;const r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||t[0]}function ut({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function dt({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:a}){if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(a&&t&&t.length>0){const r=(i=t,i.length>3?[i[0],i[Math.floor(i.length/2)],i[i.length-1]]:i).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(a))if(o&&"string"==typeof o&&!(o in r)){const r=lt(o,t),a=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${a}`}}}var i;return null}function ht(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:a,margin:i,className:c,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:y="category10",nodeSize:g=8,nodeSizeRange:p=[5,20],edgeWidth:v=1,edgeColor:m="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:L={},onObservation:E,chartId:A,selection:D,linkedHover:S}=t,P=n.width,T=n.height,M=n.enableHover,O=n.showLegend,N=null!==(r=n.showLabels)&&void 0!==r&&r,W=n.title,$=o||[],_=a||[],C=rt($,f,y),I=e.useMemo(()=>e=>{const t={};return t.fill=f?Ne(e.data||e,f,C):tt,"number"==typeof g&&(t.r=g),t},[f,C,g]),R=e.useMemo(()=>e=>({stroke:m,strokeWidth:"number"==typeof v?v:"function"==typeof v?v(e):e[v]||1,opacity:b}),[v,m,b]),j=e.useMemo(()=>{if(N&&h)return"function"==typeof h?h:e=>e[h]},[N,h]),{legend:B,margin:F}=function({data:t,colorBy:r,colorScale:n,showLegend:o,userMargin:a,defaults:i={top:50,bottom:60,left:70,right:40}}){const c=void 0!==o?o:!!r,s=e.useMemo(()=>{if(c&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:a}){const i=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(o=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),i=a?n(a,t,r):r?r(o):"#000000";return{label:o+"",color:i}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==o&&(t.stroke=o),void 0!==a&&(t.strokeWidth=a),t},type:"fill",items:i,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:Ne})},[c,r,t,n]),l=e.useMemo(()=>{const e=Object.assign(Object.assign({},i),a);return s&&120>e.right&&(e.right=120),e},[i,a,s]);return{legend:s,margin:l}}({data:$,colorBy:f,colorScale:C,showLegend:O,userMargin:i,defaults:n.marginDefaults}),{customHoverBehavior:z}=nt({selection:D,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ForceDirectedGraph",chartId:A}),H=dt({componentName:"ForceDirectedGraph",nodes:o,edges:a,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:s}});return H?u.createElement(it,{componentName:"ForceDirectedGraph",message:H,width:P,height:T}):u.createElement(st,{componentName:"ForceDirectedGraph",width:P,height:T},u.createElement(Be,Object.assign({chartType:"force",nodes:$,edges:_,size:[P,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:d,iterations:x,forceStrength:k,nodeStyle:I,edgeStyle:R,colorBy:f,colorScheme:y,nodeSize:g,nodeSizeRange:p,nodeLabel:j,showLabels:N,enableHover:M,tooltipContent:w?e=>Ye(w)(e.data):void 0,customHoverBehavior:S||E?z:void 0,legend:B,className:c,title:W},L)))}function ft(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function yt(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],a="function"==typeof n?n(e):e[n];o.add(t),o.add(a)}),Array.from(o).map(e=>({id:e}))}function gt(e){return"function"==typeof e?e:t=>t[e]||1}function pt({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:a={}}){return i=>{const c=Object.assign({fillOpacity:o},a);if("function"==typeof e)c.fill=e(i);else if("source"===e){const e="object"==typeof i.source?i.source:null;t&&e?c.fill=Ne(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof i.target?i.target:null;t&&e?c.fill=Ne(e.data||e,t,r):e&&(c.fill=n(e,e.index).fill)}else"gradient"===e&&(c.fill="#999",c.fillOpacity=.7*o);return c}}function vt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:o,edges:a,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",orientation:p="horizontal",nodeAlign:v="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:L,frameProps:E={},onObservation:A,chartId:D,selection:S,linkedHover:P}=t,T=n.width,M=n.height,O=n.enableHover,N=null===(r=n.showLabels)||void 0===r||r,W=n.title,$=a||[],_=e.useMemo(()=>yt(o,$,s,l),[o,$,s,l]),C=rt(_,f,y),I=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?Ne(e.data||e,f,C):"#4d430c",t},[f,C]),R=e.useMemo(()=>pt({edgeColorBy:g,colorBy:f,colorScale:C,nodeStyleFn:I,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,C,I,k]),j=e.useMemo(()=>{if(!N)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[N,x,h]),B=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:F,customClickBehavior:z}=nt({selection:S,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:A,chartType:"SankeyDiagram",chartId:D}),H=dt({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return H?u.createElement(it,{componentName:"SankeyDiagram",message:H,width:T,height:M}):u.createElement(st,{componentName:"SankeyDiagram",width:T,height:M},u.createElement(Be,Object.assign({chartType:"sankey",nodes:_,edges:$,size:[T,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,orientation:p,nodeAlign:v,nodePaddingRatio:m,nodeWidth:b,nodeStyle:I,edgeStyle:R,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:k,edgeSort:w,nodeLabel:j,showLabels:N,enableHover:O,tooltipContent:L?e=>Ye(L)(e.data):void 0,customHoverBehavior:P||A?F:void 0,customClickBehavior:A?z:void 0,className:c,title:W},E)))}function mt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:a,margin:i,className:c,sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",padAngle:p=.01,groupWidth:v=20,sortGroups:m,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:L,chartId:E,selection:A,linkedHover:D}=t,S=n.width,P=n.height,T=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,O=n.title,N=a||[],W=e.useMemo(()=>yt(o,N,s,l),[o,N,s,l]),$=rt(W,f,y),_=e.useMemo(()=>(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=Ne(e.data||e,f,$);else{const a=Array.isArray(y)?y:Te[y]||Me,i=Array.isArray(a)?a:Me,c=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=i[c%i.length]}return o},[f,$,y]),C=e.useMemo(()=>pt({edgeColorBy:g,colorBy:f,colorScale:$,nodeStyleFn:_,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,$,_,x]),I=e.useMemo(()=>{if(!M)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[M,b,h]),R=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:j}=nt({selection:A,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,chartType:"ChordDiagram",chartId:E}),B=dt({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return B?u.createElement(it,{componentName:"ChordDiagram",message:B,width:S,height:P}):u.createElement(st,{componentName:"ChordDiagram",width:S,height:P},u.createElement(Be,Object.assign({chartType:"chord",nodes:W,edges:N,size:[S,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:l,valueAccessor:d,padAngle:p,groupWidth:v,sortGroups:m,nodeStyle:_,edgeStyle:C,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:x,nodeLabel:I,showLabels:M,enableHover:T,tooltipContent:k?e=>Ye(k)(e.data):void 0,customHoverBehavior:D||L?j:void 0,className:c,title:O},w)))}function bt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:i,layout:c="tree",orientation:s="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:y="category10",colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:L,linkedHover:E}=t,A=n.width,D=n.height,S=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,T=n.title,M=rt(e.useMemo(()=>ft(o,l),[o,l]),g?void 0:f,y),O=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Oe[(e.depth||0)%Oe.length]:f?Ne(e.data||e,f,M):tt,t},[f,g,M]),N=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),W=e.useMemo(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return gt(d)},[c,d]),$=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:_}=nt({selection:L,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),C=ut({componentName:"TreeDiagram",data:o});return C?u.createElement(it,{componentName:"TreeDiagram",message:C,width:A,height:D}):u.createElement(st,{componentName:"TreeDiagram",width:A,height:D},u.createElement(Be,Object.assign({chartType:c,data:o,size:[A,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:W,treeOrientation:s,edgeType:p,nodeStyle:O,edgeStyle:N,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:P?v||h:void 0,showLabels:P,enableHover:S,tooltipContent:b?e=>Ye(b)(e.data):void 0,customHoverBehavior:E||k?_:void 0,className:i,title:T},x)))}function xt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:a,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:y="leaf",nodeLabel:g,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:L}=t,E=n.width,A=n.height,D=n.enableHover,S=null===(r=n.showLabels)||void 0===r||r,P=n.title,{activeSelectionHook:T,customHoverBehavior:M}=nt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:L}),O=e.useCallback(e=>{if(!e)return M(null);const t=e.data||e;M({data:(null==t?void 0:t.data)||t})},[M]),N=rt(e.useMemo(()=>ft(o,c),[o,c]),f?void 0:d,h),W=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?Oe[(e.depth||0)%Oe.length]:d?Ne(e.data||e,d,N):tt,t},[d,f,N]),$=e.useMemo(()=>T?e=>{var t;const r=Object.assign({},W(e));if(T.isActive)if(T.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(r,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(r,x.unselectedStyle)}return r}:W,[W,T,x]),_=e.useMemo(()=>gt(s),[s]),C=void 0!==v?v:S&&"parent"===y?18:void 0,I=Object.assign(Object.assign({},n.marginDefaults),a),R=ut({componentName:"Treemap",data:o});return R?u.createElement(it,{componentName:"Treemap",message:R,width:E,height:A}):u.createElement(st,{componentName:"Treemap",width:E,height:A},u.createElement(Be,Object.assign({chartType:"treemap",data:o,size:[E,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:I,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:_,padding:p,paddingTop:C,nodeStyle:$,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:S?g||l:void 0,showLabels:S,enableHover:D,tooltipContent:m?e=>Ye(m)(e.data):void 0},(k||w)&&{customHoverBehavior:O},{className:i,title:P},b)))}function kt(t){var r;const n=at(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:i,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:y,circleOpacity:g=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x,selection:k,linkedHover:w}=t,L=n.width,E=n.height,A=n.enableHover,D=null===(r=n.showLabels)||void 0===r||r,S=n.title,P=rt(e.useMemo(()=>ft(o,c),[o,c]),f?void 0:d,h),T=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?Oe[(e.depth||0)%Oe.length]:d?Ne(e.data||e,d,P):tt,t},[d,f,P,g]),M=e.useMemo(()=>gt(s),[s]),O=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:N}=nt({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),W=ut({componentName:"CirclePack",data:o});return W?u.createElement(it,{componentName:"CirclePack",message:W,width:L,height:E}):u.createElement(st,{componentName:"CirclePack",width:L,height:E},u.createElement(Be,Object.assign({chartType:"circlepack",data:o,size:[L,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:O,nodeIDAccessor:l,childrenAccessor:c,hierarchySum:M,padding:p,nodeStyle:T,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:D?y||l:void 0,showLabels:D,enableHover:A,tooltipContent:v?e=>Ye(v)(e.data):void 0,customHoverBehavior:w||b?N:void 0,className:i,title:S},m)))}"undefined"!=typeof process&&process,ht.displayName="ForceDirectedGraph",vt.displayName="SankeyDiagram",mt.displayName="ChordDiagram",bt.displayName="TreeDiagram",xt.displayName="Treemap",kt.displayName="CirclePack",exports.ChordDiagram=mt,exports.CirclePack=kt,exports.ForceDirectedGraph=ht,exports.SankeyDiagram=vt,exports.StreamNetworkFrame=Be,exports.TreeDiagram=bt,exports.Treemap=xt;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),o=require("d3-force"),i=require("d3-scale"),a=require("d3-chord"),l=require("d3-shape"),s=require("d3-hierarchy");function c(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=c(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const l=r[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=y(l.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function y(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const o=e.length,i=t*o,a=Math.min(Math.floor(i),o-1),l=i-a,[s,c,u,d]=e[a],h=g(s,c,u,d,l),f=d.x-s.x,y=d.y-s.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;h.x+=-y/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,o,i,a]=e.points,l=g(n,o,i,a,t),s=a.x-n.x,c=a.y-n.y,u=Math.sqrt(s*s+c*c);if(u>.001){const t=s/u;l.x+=-c/u*r*e.halfWidth*2,l.y+=t*r*e.halfWidth*2}return l}function g(e,t,r,n,o){const i=1-o,a=i*i,l=a*i,s=o*o,c=s*o;return{x:l*e.x+3*a*o*t.x+3*i*s*r.x+c*n.x,y:l*e.y+3*a*o*t.y+3*i*s*r.y+c*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],o=[],i=[],a={},l=[];function s(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&s(t)})}function c(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;l[e].length>t;t++)(n=l[e][t])===r?(u(r,o),d=!0):i[n]||(d=c(n));if(d)s(e);else for(t=0;l[e].length>t;t++){var h=a[n=l[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),l=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,o[s]=!1,i[s]=0,a[s]=-1,l[s]=[];var c,u=0,d=[],h=[];function f(t){var s=[t],c=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var g=f[y];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>a[g]||l[t].push(a[g])}i[t]=y}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var b=s[y];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=d.length,b===t){s.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}c.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[s]=c}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var l=0;o[a].length>l;l++)i>o[a][l]&&(i=o[a][l],r=a);var s=o[r];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];i[+p]=!1,a[p]={}}c(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=L(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function E(e,t){var r=L(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function A(e,t){return t(e)}function D(e){return C(e.source)}function S(e){return C(e.target)}function C(e){return(e.y0+e.y1)/2}function P(e){return e.virtual?0:e.value}function M(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function O(e){return e.target.depth}function N(e,t){return e.sourceLinks.length?e.depth:t-1}function I(e,t){return e.y0-t.y0}function W(e,t){return t.y0-e.y0}function T(e,t){return e.y1-t.y1}function $(e,t){return t.y1-e.y1}function _(e,t){return R(e.source,t.source)||e.index-t.index}function B(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function j(e,t){return H(e)==H(t)?"bottom"==e.circularLinkType?W(e,t):I(e,t):H(t)-H(e)}function H(e){return e.target.column-e.source.column}function z(e,t){return F(e)==F(t)}function F(e){return e.y0-e.y1>0?"up":"down"}function Y(e,t,n,o,i){let a=e;var l=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,l))});var s=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),X(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),X(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,l=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?W:I);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?$:T),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),a}function X(e,t,r){e.sort(j);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var l=n[a];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&G(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+r;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function Z(e){return e.nodes}function K(e){return e.links}function Q(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?M(t,n)-M(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==M(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,o,i,a){var l=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,c=a;c>0;--c)u(s*=.99,n),d();function u(t,n){var o=l.length;l.forEach(function(i){var a=i.length,l=i[0].depth;i.forEach(function(i){var s;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&M(i,n)>0){var c=r.mean(i.sourceLinks,S),u=r.mean(i.targetLinks,D),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-C(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==l&&1==a)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(l==o-1&&1==a)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)s=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+s;else{var f=r.mean(i.sourceLinks,S),y=r.mean(i.targetLinks,D),g=((f&&y?(f+y)/2:f||y)-C(i))*t;i.y0+=g,i.y1+=g}})})}function d(){l.forEach(function(r){var n,a,l,s=e.y0,c=r.length;for(r.sort(t||R),l=0;c>l;++l)(a=s-(n=r[l]).y0)>0&&(n.y0+=a,n.y1+=a),s=n.y1+o;if((a=s-o-e.y1)>0)for(s=n.y0-=a,n.y1-=a,l=c-2;l>=0;--l)(a=(n=r[l]).y1+i-s)>0&&(n.y0-=a,n.y1-=a),s=n.y0})}}function U(e){e.nodes.forEach(function(e){e.sourceLinks.sort(B),e.targetLinks.sort(_)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,i=24,a=8,l=null,s=V,c=N,u=void 0,d=32,h=2,f=Z,y=K;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof o&&(o=e.target=p(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,l=i.target.index;n[a]||(n[a]=[]),n[l]||(n[l]=[]),-1===n[a].indexOf(l)&&n[a].push(l)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){A(e,t)!=A(o.source,t)&&A(e,t)!=A(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,P),r.sum(e.targetLinks,P)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,l=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==l?a:a+1,l=t(e)==l?l:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(f,u,c);var y=a;if(null!==l){var g=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(g,function(e){return e.length});m>1&&(y=Math.max(1,(o-t)*l/(m-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,i),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return A(r.source,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!z(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return A(r.target,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!z(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=E(t,e);return e.y0-r}if(t.source.column>e.source.column)return E(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),l=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(l-a);function c(t){return(t-a)/(l-a)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),Y(f,s,h,10,8)}(g),g}return g.update=function(e){return U(e),Y(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(i=+e,g):i},g.nodePadding=function(e){return arguments.length?(a=+e,g):a},g.nodePaddingRatio=function(e){return arguments.length?(l=+e,g):l},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:q(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),g):s},g.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:q(e),g):c},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],g):[[e,t],[n,o]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],g):[n-e,o-t]},g}const te=e=>{let r,n,o,i,a,l,s,c,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.y1,l=e.target.y0,s=t.interpolateNumber(a,l),c=s(.5),u=s(.5),`M${r},${a}C${r},${c} ${n},${u} ${n},${l}L${o},${l}C${o},${u} ${i},${c} ${i},${a}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),o=s(.5),i=s(.5),a=e.y0-e.sankeyWidth/2,l=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${a}C${o},${a} ${i},${l} ${n},${l}L${n},${c}C${i},${c} ${o},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+l},${n-r}L${t+l},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-s},${a-r}L${i-s},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${c},${a-h*r}L${c+n},${a-h*r+h*f}L${c+n},${d+h*n-h*f}L${c+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${l},${s-h*r}L${l},${s+h*r}L${u+n},${s+h*r}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${a+h*r}L${i},${a+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(O))-1:0},justify:N},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,l,s,c,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(o=r.nodeWidth)&&void 0!==o?o:15,y=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||N).nodeId(e=>e.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(s=null!==(l=n._circularWidth)&&void 0!==l?l:n.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",i=k.get(`${n}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(n),r=x.get(o);t&&(i.source=t),r&&(i.target=r)}}},buildScene(e,t,r,o){var i,a,l,s;const c="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,f=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},o={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const o=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+i},${t.sourceY-r}L${t.sourceX+i},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:c,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?re(e):te(e),!i)continue;const c={fill:o.fill||n,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};v.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const i=t?t(r):r.id;if(!i)continue;let a,l,s;"down"===c?(a=r.x0+e/2,l=r.y1+14,s="middle"):(o[0]/2>r.x0+e/2?(a=r.x0-6,s="end"):(a=r.x1+6,s="start"),l=r.y0+n/2),m.push({x:a,y:l,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},ie={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const l=null!==(i=r.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(a=r.forceStrength)&&void 0!==a?a:.1,c=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const r=e[t];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;r.x=c+e*Math.cos(n),r.y=u+e*Math.sin(n)}}const d=ae(r.nodeSize,r.nodeSizeRange,e),h=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),f=n[1]/n[0],y=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",o.forceX(n[0]/2).strength(.1*f)).force("y",o.forceY(n[1]/2).strength(.1));if(y.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));y.force("link",h),y.force("link").links(e)}.1>y.alpha()&&y.alpha(1),y.stop();for(let e=0;l>e;++e)y.tick();const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var i,a,l;const s=r.nodeStyle,c=r.edgeStyle,u=ae(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=c?c(e):{},o={stroke:n.stroke||"#999",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=n.opacity)&&void 0!==l?l:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:o,datum:e})}if(!1!==r.showLabels){const t=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ae(e,t,n){var o,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const l=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>l[0];const c=null!==(o=r.min(s))&&void 0!==o?o:0,u=null!==(a=r.max(s))&&void 0!==a?a:1;if(c===u)return()=>(l[0]+l[1])/2;const d=i.scaleLinear().domain([c,u]).range(l).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?l[0]:d(n)}}const le=n.schemeCategory10,se={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=r,c=Math.min(n[0],n[1])/2,u=c-i,d=n[0]/2,h=n[1]/2,f=(y=r.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=g.get("string"==typeof e.source?e.source:e.source.id),n=g.get(t);if(void 0===r||void 0===n)continue;const o=f(e);v[r][n]=o}const m=a.chord().padAngle(o);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=l.arc().innerRadius(u).outerRadius(c);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const E=new Map;for(const e of t)E.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=E.get(`${r}\0${n}`)||E.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:l=20,edgeOpacity:s=.5}=r,c=Math.min(n[0],n[1])/2,u=c-l,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:le,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=a.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const a=f?f(r):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:c,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:l,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=ce(r,d,h);let o="#999";if(y)o=y(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===g&&r?o=v.get(r.id)||o:t&&(o=v.get(t.id)||o)}const a=y?y(e):{},l={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:n,style:l,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=c+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:d+Math.cos(a)*n,y:h+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function ce(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const ue={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,l=(c=r.childrenAccessor)?"function"==typeof c?c:e=>e[c]:void 0;var c;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(i,l);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=s.tree();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=s.cluster();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=s.treemap().size([r,n]).tile(s.treemapBinary).padding(a);l>0&&c.paddingTop(l),c(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;s.pack().size([r,n]).padding(i)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var o;s.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],i={id:ge(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===a||"cluster"===a?de(i,n,r):"treemap"===a||"partition"===a?he(i,n):"circlepack"===a&&fe(i,n),i.__hierarchyNode=n,e.push(i),g.set(n,i)}if("tree"===a||"cluster"===a)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,l,s,c,u;const d=[],h=[],f=[],y=r.treeOrientation||"vertical",g="radial"===y,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;g&&(e+=p,n+=v);const i=o(t);let l=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(l=b[t.depth%b.length]);const s={fill:l,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(l=r.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,o=t.y,a=r.x,l=r.y;g&&(n+=p,o+=v,a+=p,l+=v);const u=ye(n,o,a,l,y),d=i(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=pe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,l=r.y;if(g&&(a+=p,l+=v),g){const e=a-p,t=l-v,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=l+t/r*10,i=0>e?"end":"start"):(n=a,o=l-12,i="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=a-m-6,i="end"):(n=a+m+6,i="start"),o=l):(n=a,o=l+m+14,i="middle");f.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const l=n(r);let c=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=s[r.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};a.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;if((null===(i=n.data)||void 0===i?void 0:i.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const a=r?r(n):n.id;a&&(30>e||16>o||l.push({x:n.x0+e/2,y:n.y0+o/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,o)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:l}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,l,s;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const l=n(r);let s=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const t of e){const e=null!==(l=t.__radius)&&void 0!==l?l:5,n=r?r(t):t.id;if(!n)continue;if(15>e)continue;const o=!((null===(s=t.data)||void 0===s?void 0:s.children)&&t.data.children.length>0);u.push({x:t.x,y:o?t.y:t.y-e+14,text:n+"",anchor:"middle",baseline:o?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:o?void 0:"#000",stroke:o?void 0:"#fff",strokeWidth:o?void 0:3,paintOrder:o?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function de(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function he(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function fe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ye(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}function ge(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function pe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}const ve={sankey:oe,force:ie,chord:se,tree:ue,cluster:ue,treemap:ue,circlepack:ue,partition:ue};function me(e){return ve[e]}class be{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new f(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof n?n:e=>e[n],s="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=l(t)+"";this.nodes.set(e,Object.assign(Object.assign({},xe(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=c(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},xe(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},xe(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,xe(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,xe(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,r),s=this.edges.get(l);return s?(s.value+=n,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=me(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(r,n,this.config,e),t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear();for(const e of r)this.nodes.set(e.id,e);for(const e of n)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const o=new Set(this.nodes.keys()),i=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of o)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)o.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=o,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=me(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),r=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*r,e.x1=e._prevX1+(e._targetX1-e._prevX1)*r,e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*r);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=r.y1,a=n.y0,l=t.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:l(.5)},{x:e.y1,y:l(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=r.x1,a=n.x0,l=t.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:l(.5),y:e.y0},{x:l(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,i;const a=this.config.pulse;if(!a)return;const l=null!==(t=a.duration)&&void 0!==t?t:500,s=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=a.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;l>o&&(t._pulseIntensity=1-o/l,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const c=this.edgeTimestamps.get(`${n}\0${a}`);if(!c)continue;const u=e-c;l>u&&(t._pulseIntensity=1-u/l,t._pulseColor=s)}}applyDecay(){var e,t,r,n,o;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,l=this.nodeTimestamps.size;if(1>=l)return;const s=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;s.length>e;e++)c.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const d=l-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(l-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:l/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*l)>d?1:a;break;default:h=1}const f=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",a=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const l=this.nodes.get(r);if(!l)continue;const s=n.metric(l);let c=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function xe(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ke(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function we(e,t,r,n,o=30){let i=null,a=o,l=1/0;for(const t of e){const e=Ee(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;l>r&&(i=e,l=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Se(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Ee(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,r);case"rect":return function(e,t,r){const n=function(e,t,r){return r.x>e||e>r.x+r.w||r.y>t||t>r.y+r.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:r.x+r.w/2,cy:r.y+r.h/2}}(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=ke(Math.atan2(o,n)),l=ke(e.startAngle),s=ke(e.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let Le=null,Ae=null;function De(){return Ae||(Le=document.createElement("canvas"),Le.width=1,Le.height=1,Ae=Le.getContext("2d")),Ae}function Se(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=De();if(!a)return null;if(a.isPointInPath(i,t,r)){const i="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const l=e.x1+a*n,s=e.y1+a*o,c=Math.sqrt(Math.pow(t-l,2)+Math.pow(r-s,2));return c>5?null:{type:"edge",datum:e.datum,x:l,y:s,distance:c}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=De();if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0}}catch(e){}return null}(e,t,r);default:return null}}const Ce={fill:e=>u.createElement("rect",{style:e,width:20,height:20}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function Pe(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Ce[r])(n(e,t)),o}function Me(){return u.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function Oe(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Ne(e){const{legendGroups:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,title:a="Legend",width:l=100,height:s=20,orientation:c="vertical"}=e,d="vertical"===c?(({legendGroups:e,width:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i})=>{let a=30;const l=[];return e.forEach((e,s)=>{a+=5,l.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:a,x2:t,y2:a})),a+=10,e.label&&(a+=20,l.push(u.createElement("text",{key:"legend-text-"+s,y:a,className:"legend-group-label"},e.label)),a+=10),l.push(u.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${a})`},((e,t,r,n,o)=>{const{type:i="fill",styleFn:a,items:l}=e,s=[];let c=0;const d=!(!t&&!r);return l.forEach((e,l)=>{const h=Pe(e,l,i,a),f=Oe(e,n,o),y=o&&o.size>0&&o.has(e.label);s.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${c})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,style:{cursor:d?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},y&&u.createElement(Me,null),h,u.createElement("text",{y:15,x:30},e.label))),c+=25}),s})(e,r,n,o,i))),a+=25*e.items.length+10}),l})({legendGroups:t,width:l,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i}):(({legendGroups:e,title:t,height:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a})=>{let l=0;const s=[],c=!1===t?10:40;return e.forEach((t,d)=>{t.label&&(s.push(u.createElement("text",{key:"legend-text-"+d,transform:`translate(${l},${c}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),l+=20);const h=((e,t,r,n,o)=>{const{type:i="fill",styleFn:a,items:l}=e,s=[];let c=0;const d=!(!t&&!r);return l.forEach((e,l)=>{const h=Pe(e,l,i,a),f=Oe(e,n,o),y=o&&o.size>0&&o.has(e.label);s.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${c},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,style:{cursor:d?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},y&&u.createElement(Me,null),h,u.createElement("text",{y:15,x:25},e.label))),c+=35,c+=8*e.label.length}),{items:s,offset:c}})(t,n,o,i,a);s.push(u.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(${l},${c})`},h.items)),l+=h.offset+5,e[d+1]&&s.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:l,y1:c-10,x2:l,y2:r+c+10})),l+=15}),u.createElement("g",null,!1!==t&&u.createElement("line",{x1:0,x2:l+10,y1:c-10,y2:c-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:t,title:a,height:s,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i});return u.createElement("g",null,void 0!==a&&u.createElement("text",{className:"legend-title",y:20,x:"horizontal"===c?0:l/2,textAnchor:"horizontal"===c?"start":"middle"},a),d)}function Ie(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,foregroundGraphics:y,sceneNodes:g,annotations:p,svgAnnotationRules:v}=e;return u.createElement(u.Fragment,null,u.createElement("svg",{width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),p&&p.filter(e=>"widget"!==e.type).map((e,n)=>{if(v){const o=v(e,n,{width:t,height:r,sceneNodes:g});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),y),l&&"string"==typeof l?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?u.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},l):null,s&&u.createElement("g",{transform:`translate(${n-i.right+10},${i.top})`},"object"==typeof s&&!u.isValidElement(s)&&"legendGroups"in s?u.createElement(Ne,{legendGroups:s.legendGroups,title:"",width:100,customHoverBehavior:c,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f}):s)),null==p?void 0:p.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{var r,n,o,a,l,s,c,d,h;const f=g.find(t=>{var r,n,o,i,a;return t.id===e.nodeId||(null===(r=t.datum)||void 0===r?void 0:r.id)===e.nodeId||(null===(o=null===(n=t.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(a=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===e.nodeId});if(!f)return null;const y=i.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(n=f.x)&&void 0!==n?n:0),p=i.top+(null!==(o=f.cy)&&void 0!==o?o:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),v=null!==(l=e.dx)&&void 0!==l?l:0,m=null!==(s=e.dy)&&void 0!==s?s:-16,b=null!==(c=e.width)&&void 0!==c?c:32,x=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:u.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return u.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:y+v-b/2,top:p+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}Ie.displayName="NetworkSVGOverlay";const We="undefined"==typeof window||"undefined"==typeof document;function Te(e,t){var r,n,o,i,a,l;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,l=t.style.fill;o.addColorStop(0,1===a.from?l:"transparent"),o.addColorStop(1,1===a.to?l:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function $e(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function _e(e,t){var r,n,o,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function Be(e,t){var r,n;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}const Re={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},je=n.schemeCategory10,He=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function ze(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):je[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%je.length]}function Fe(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>e[t]))),o=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return i.scaleOrdinal().domain(n).range(r).unknown("#999");const a=Re[r]||Re.category10;if(o&&"function"==typeof a)return e=>a(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(a)?a:je;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}const Ye={top:20,right:80,bottom:20,left:80},Xe={top:40,right:40,bottom:40,left:40},Ge=new Set(["chord","force","circlepack"]),qe=[800,600],Ve={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ze({data:e}){var t,r,n,o,i,a;if("edge"===e.type){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:Ve},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const l=e.data,s=null==l?void 0:l.__hierarchyNode;if(s){const e=[];let i=s;for(;i;){const a=null!==(o=null!==(r=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==o?o:l.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:Ve},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=l.value&&l.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(i=l.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:Ve},u.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,d!==c&&` (weighted: ${d.toLocaleString()})`))}const Ke=e.forwardRef(function(t,r){var n,o,i;const{chartType:a,nodes:s,edges:c,data:f,initialEdges:y,nodeIDAccessor:g="id",sourceAccessor:p="source",targetAccessor:v="target",valueAccessor:m="value",childrenAccessor:b,hierarchySum:x,orientation:k="horizontal",nodeAlign:w="justify",nodePaddingRatio:E=.05,nodeWidth:L=15,iterations:A=300,forceStrength:D=.1,padAngle:S=.01,groupWidth:C=20,sortGroups:P,edgeSort:M,treeOrientation:O="vertical",edgeType:N="curve",padding:I,paddingTop:W,tensionConfig:T,showParticles:$=!1,particleStyle:_,nodeStyle:B,edgeStyle:R,colorBy:j,colorScheme:H="category10",edgeColorBy:z="source",edgeOpacity:F=.5,colorByDepth:Y=!1,nodeSize:X=8,nodeSizeRange:G=[5,20],nodeLabel:q,showLabels:V=!0,size:Z=qe,responsiveWidth:K,responsiveHeight:Q,margin:J,className:U,background:ee,enableHover:te=!0,tooltipContent:re,customHoverBehavior:ne,customClickBehavior:oe,onObservation:ie,chartId:ae,onTopologyChange:le,annotations:se,svgAnnotationRules:ce,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:fe,legendIsolatedCategories:ye,title:ge,foregroundGraphics:pe,backgroundGraphics:ve,decay:me,pulse:xe,staleness:ke,thresholds:Ee}=t,Le=Ge.has(a)?Xe:Ye,[Ae,De]=function(t,r,n){const o=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;a(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&i?i.w:t[0],n&&i?i.h:t[1]]]}(Z,K,Q),Se=Object.assign(Object.assign({},Le),J),Ce=De[0]-Se.left-Se.right,Pe=De[1]-Se.top-Se.bottom,Me=e.useMemo(()=>Object.assign(Object.assign({},d),T),[T]),Oe=e.useMemo(()=>Object.assign(Object.assign({},h),_),[_]),Ne=e.useMemo(()=>({chartType:a,nodeIDAccessor:g,sourceAccessor:p,targetAccessor:v,valueAccessor:m,childrenAccessor:b,hierarchySum:x,orientation:k,nodeAlign:w,nodePaddingRatio:E,nodeWidth:L,iterations:A,forceStrength:D,padAngle:S,groupWidth:C,sortGroups:P,edgeSort:M,treeOrientation:O,edgeType:N,padding:I,paddingTop:W,tensionConfig:Me,showParticles:$,particleStyle:Oe,nodeStyle:B,edgeStyle:R,nodeLabel:q,showLabels:V,colorBy:j,colorScheme:H,edgeColorBy:z,edgeOpacity:F,colorByDepth:Y,nodeSize:X,nodeSizeRange:G,decay:me,pulse:xe,staleness:ke,thresholds:Ee}),[a,g,p,v,m,b,x,k,w,E,L,A,D,S,C,P,M,O,N,I,W,Me,$,Oe,B,R,q,V,j,H,z,F,Y,X,G,me,xe,ke,Ee]),Re=e.useRef(null),He=e.useRef(0),ze=e.useRef(0),Fe=e.useRef(!0),Ve=e.useRef(()=>{}),Ke=e.useRef(null);Ke.current||(Ke.current=new be(Ne));const[Qe,Je]=e.useState(null),[Ue,et]=e.useState(0),[tt,rt]=e.useState(0),[nt,ot]=e.useState(!1),it=e.useRef(null),at=e.useRef(new Map),lt=e.useRef(0),st=e.useCallback(e=>{if("function"==typeof j)return j(e)+"";if("string"==typeof j&&e.data){const t=e.data[j];if(void 0!==t){if(!at.current.has(t+"")){const e=Array.isArray(H)?H:je;at.current.set(t+"",e[lt.current++%e.length])}return at.current.get(t+"")}}if(!at.current.has(e.id)){const t=Array.isArray(H)?H:je;at.current.set(e.id,t[lt.current++%t.length])}return at.current.get(e.id)},[j,H]),ct=e.useCallback(e=>{if("function"==typeof z)return z(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===z&&r?st(r):t?st(t):"#999"},[z,st]),ut=e.useCallback(e=>{if(!(null==_?void 0:_.colorBy))return ct(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Oe.colorBy&&r?st(r):t?st(t):"#999"},[null==_?void 0:_.colorBy,Oe.colorBy,st,ct]),dt="sankey"===a&&$||!!xe,ht=e.useCallback(()=>{He.current&&!dt||He.current||(He.current=requestAnimationFrame(()=>Ve.current()))},[dt]);e.useEffect(()=>{var e;null===(e=Ke.current)||void 0===e||e.updateConfig(Ne),Fe.current=!0,ht()},[Ne,ht]);const ft=e.useCallback(()=>{const e=Ke.current;if(!e)return;e.runLayout([Ce,Pe]),e.buildScene([Ce,Pe]),Fe.current=!0;const t=Array.isArray(H)?H:je,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];at.current.has(n.id)||at.current.set(n.id,t[e%t.length])}if(lt.current=r.length,et(e.layoutVersion),le){const{nodes:t,edges:r}=e.getLayoutData();le(t,r)}},[Ce,Pe,le,H]),yt=e.useCallback(e=>{const t=Ke.current;t&&(t.ingestEdge(e)&&ft(),ht())},[ft,ht]),gt=e.useCallback(e=>{const t=Ke.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&ft(),ht()},[ft,ht]),pt=e.useCallback(()=>{var e;null===(e=Ke.current)||void 0===e||e.clear(),at.current.clear(),lt.current=0,et(0),Je(null),it.current=null,Fe.current=!0,ht()},[ht]),vt=e.useCallback(()=>{const e=Ke.current;e&&(e.tension+=999,ft(),ht())},[ft,ht]);e.useImperativeHandle(r,()=>({push:yt,pushMany:gt,clear:pt,getTopology:()=>{var e,t;return null!==(t=null===(e=Ke.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ke.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:vt,getTension:()=>{var e,t;return null!==(t=null===(e=Ke.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[yt,gt,pt,vt]);const mt=["tree","cluster","treemap","circlepack","partition"].includes(a),bt=mt?f||(Array.isArray(c)?void 0:c):void 0;e.useEffect(()=>{const e=Ke.current;if(e)if(mt&&bt)e.ingestHierarchy(bt,[Ce,Pe]),e.buildScene([Ce,Pe]),Fe.current=!0,ht();else{const t=s||[],r=Array.isArray(c)?c:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[Ce,Pe]),e.buildScene([Ce,Pe]);const n=Array.isArray(H)?H:je,o=Array.from(e.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];at.current.has(t.id)||at.current.set(t.id,n[e%n.length])}lt.current=o.length,Fe.current=!0,ht()}},[s,c,f,bt,mt,Ce,Pe,Ne,ht,H]),e.useEffect(()=>{y&&y.length>0&>(y)},[]);const xt=e.useCallback(e=>{if(ne&&ne(e),ie){const t=Date.now();ie(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ae}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ae})}},[ne,ie,ae]),kt=e.useCallback(e=>{if(oe&&oe(e),ie){const t=Date.now();ie(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ae}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ae})}},[oe,ie,ae]),wt=e.useRef(()=>{}),Et=e.useRef(()=>{});wt.current=e=>{if(!te)return;const t=Re.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Se.left,o=e.clientY-r.top-Se.top;if(0>n||n>Ce||0>o||o>Pe)return void(it.current&&(it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),ht()));const i=Ke.current;if(!i)return;const a=we(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(it.current&&(it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),ht()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};it.current=l,Je(l),xt&&(xt(l),Fe.current=!0),ht()},Et.current=()=>{it.current&&(it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),ht())};const Lt=e.useRef(()=>{});Lt.current=e=>{if(!oe&&!ie)return;const t=Re.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Se.left,o=e.clientY-r.top-Se.top;if(0>n||n>Ce||0>o||o>Pe)return;const i=Ke.current;if(!i)return;const a=we(i.sceneNodes,i.sceneEdges,n,o);kt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},e.useCallback(e=>wt.current(e),[]);const At=e.useCallback(()=>Et.current(),[]),Dt=e.useCallback(e=>Lt.current(e),[]),St=e.useRef(-1),Ct=e.useCallback(e=>{const t=Ke.current;if(!t)return;const r=function(e){const t=[];for(const r of e)"circle"===r.type&&null!=r.cx?t.push({x:r.cx,y:r.cy,datum:r.datum}):"rect"===r.type&&null!=r.x?t.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum}):"arc"===r.type&&null!=r.cx&&t.push({x:r.cx,y:r.cy,datum:r.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return;const n=St.current,o=function(e,t,r){switch(e){case"ArrowRight":case"ArrowDown":return r-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return r-1;case"Escape":return-1;default:return null}}(e.key,0>n?-1:n,r.length);if(null===o)return;if(e.preventDefault(),0>o)return St.current=-1,it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),void ht();const i=0>n?0:o;St.current=i;const a=r[i],l={type:"node",data:a.datum,x:a.x,y:a.y};it.current=l,Je(l),xt&&(xt(l),Fe.current=!0),ht()},[xt,ht]),Pt=e.useCallback(e=>{St.current=-1,wt.current(e)},[]);Ve.current=()=>{var e,t,r;He.current=0;const n=Re.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Ke.current;if(!i)return;const a=performance.now(),l=ze.current?Math.min((a-ze.current)/1e3,.1):.016;ze.current=a;const s=i.advanceTransition(a);(s||Fe.current)&&i.buildScene([Ce,Pe]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=De[0]*c,n.height=De[1]*c,n.style.width=De[0]+"px",n.style.height=De[1]+"px",o.scale(c,c),o.translate(Se.left,Se.top),o.clearRect(-Se.left,-Se.top,De[0],De[1]),ee&&(o.fillStyle=ee,o.fillRect(0,0,Ce,Pe)),me&&i.applyDecay(),xe&&i.applyPulse(a),Ee&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==ke?void 0:ke.threshold)&&void 0!==e?e:5e3,d=ke&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(o.globalAlpha=null!==(t=null==ke?void 0:ke.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Te(e,r);break;case"line":$e(e,r);break;case"ribbon":_e(e,r);break;case"curved":Be(e,r)}}(o,i.sceneEdges),function(e,t){var r,n,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(o,i.sceneNodes),function(e,t){var r,n,o,i;for(const a of t){if("circle"!==a.type)continue;const t=a;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const r=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,n=t.r+r*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,n,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(o,i.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(o,i.sceneNodes),$&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:h.spawnRate,l=null!==(i=n.maxPerEdge)&&void 0!==i?i:h.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=l)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<l;t++)e.spawn(n)}}(i.particlePool,e,l,Oe);const t=.5*(null!==(r=Oe.speedMultiplier)&&void 0!==r?r:1);let n;if(Oe.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(l,t,e,n),function(e,t,r,n,o){var i,a;const l=null!==(i=n.radius)&&void 0!==i?i:h.radius,s=null!==(a=n.opacity)&&void 0!==a?a:h.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const s=r[a.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(s);e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(o,i.particlePool,e,Oe,ut)}}d&&(o.globalAlpha=1);const f=Fe.current;Fe.current=!1,(f||s)&&rt(e=>e+1),(dt||s||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(He.current=requestAnimationFrame(()=>Ve.current()))},e.useEffect(()=>(ht(),()=>{He.current&&(cancelAnimationFrame(He.current),He.current=0)}),[ht]),e.useEffect(()=>{Fe.current=!0,ht()},[a,Ce,Pe,ee,ht]),function(t,r,n,o,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=r.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=s-l.lastIngestTime>c;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}(ke,Ke,Fe,ht,nt,ot);const Mt=te&&Qe?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Se.left+Qe.x,top:Se.top+Qe.y,transform:`translate(${Qe.x>.6*Ce?"calc(-100% - 12px)":"12px"}, ${.3*Pe>Qe.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},re?re(Qe):u.createElement(Ze,{data:Qe})):null;if(We){const e=Ke.current;if(e){const t=["tree","cluster","treemap","circlepack","partition"].includes(a),r=t?f||(Array.isArray(c)?void 0:c):void 0;if(t&&r)e.ingestHierarchy(r,[Ce,Pe]),e.buildScene([Ce,Pe]);else{const t=s||[],r=Array.isArray(c)?c:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[Ce,Pe]),e.buildScene([Ce,Pe]))}}const t=null!==(n=null==e?void 0:e.sceneNodes)&&void 0!==n?n:[],r=null!==(o=null==e?void 0:e.sceneEdges)&&void 0!==o?o:[],d=null!==(i=null==e?void 0:e.labels)&&void 0!==i?i:[];return u.createElement("div",{className:"stream-network-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof ge?ge:"Network chart",style:{position:"relative",width:De[0],height:De[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:De[0],height:De[1],style:{position:"absolute",left:0,top:0}},ve&&u.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ve),u.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ee&&u.createElement("rect",{x:0,y:0,width:Ce,height:Pe,fill:ee}),r.map((e,t)=>function(e,t){switch(e.type){case"line":return u.createElement("line",{key:"net-edge-"+t,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":case"ribbon":return u.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return u.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":return u.createElement("circle",{key:"net-circle-"+t,cx:e.cx,cy:e.cy,r:e.r,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"rect":return u.createElement("rect",{key:"net-rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"arc":{const r=e,n=l.arc().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return u.createElement("path",{key:"net-arc-"+t,d:n,transform:`translate(${r.cx},${r.cy})`,fill:r.style.fill||"#4e79a7",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),d.map((e,t)=>function(e,t){return u.createElement("text",{key:"net-label-"+t,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,t)).filter(Boolean))),u.createElement(Ie,{width:Ce,height:Pe,totalWidth:De[0],totalHeight:De[1],margin:Se,labels:d,sceneNodes:t,title:ge,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:fe,legendIsolatedCategories:ye,foregroundGraphics:pe,annotations:se,svgAnnotationRules:ce,annotationFrame:0}))}const Ot=Ke.current;return u.createElement("div",{ref:Ae,className:"stream-network-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof ge?ge:"Network chart",tabIndex:0,style:{position:"relative",width:K?"100%":De[0],height:Q?"100%":De[1]},onMouseMove:te?Pt:void 0,onMouseLeave:te?At:void 0,onClick:oe||ie?Dt:void 0,onKeyDown:Ct},ve&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:De[0],height:De[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ve)),u.createElement("canvas",{ref:Re,style:{position:"absolute",top:0,left:0}}),u.createElement(Ie,{width:Ce,height:Pe,totalWidth:De[0],totalHeight:De[1],margin:Se,labels:(null==Ot?void 0:Ot.labels)||[],sceneNodes:null==Ot?void 0:Ot.sceneNodes,title:ge,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:fe,legendIsolatedCategories:ye,foregroundGraphics:pe,annotations:se,svgAnnotationRules:ce,annotationFrame:tt}),Mt,(null==ke?void 0:ke.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ke.badgePosition?{top:4,left:4}:"bottom-left"===ke.badgePosition?{bottom:4,left:4}:"bottom-right"===ke.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:nt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},nt?"STALE":"LIVE"))});Ke.displayName="StreamNetworkFrame";const Qe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Je(e,t){return"function"==typeof t?t(e):e[t]}function Ue(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function et(e={}){const{fields:t,title:r,format:n,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(r){const t=Je(e,r);a=Ue(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,o,i;"string"==typeof t?(r=t,o=t,i=n):(r=t.label,o=t.accessor||t.key||"",i=t.format||n);const a=Je(e,o);l.push({label:r,value:Ue(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=Ue(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Ue(e[t[0]],n))}}const s=Object.assign(Object.assign({},Qe),o);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:s},a&&u.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}function tt(e){return!0===e?et():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?et(e):et())}const rt=e.createContext(null),nt="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function ot(t){const r=e.createContext(null),n=it(t);return[function({children:n}){const o=e.useMemo(()=>it(t),[]);return u.createElement(r.Provider,{value:o,children:n})},t=>{var o;const i=null!==(o=e.useContext(r))&&void 0!==o?o:n;return function(t,r){const[n,o]=e.useState(r);return nt(()=>t(()=>o(r)),[t]),n}(i.subscribe,()=>t(i.getState()))}]}function it(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function at(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function lt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[st,ct]=ot(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=lt(n,t),i=new Map(o.clauses);return i.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),i=new Map(n.clauses);return i.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=lt(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}})),[ut,dt]=ot(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function ht(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=ct(e=>e.selections.get(o)),a=ct(e=>e.setClause),l=ct(e=>e.clearClause),s=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(at(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:e.useCallback(()=>{l(o,n)},[l,o,n]),clientId:n}}const ft=e.createContext(!1),yt="#007bff";function gt(t,r,n="category10"){const o=e.useContext(rt);return e.useMemo(()=>{if(r&&"function"!=typeof r)return o&&Object.keys(o).length>0?e=>o[e]||Fe(t,r,n)(e):Fe(t,r,n)},[t,r,n,o])}function pt({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:l}){const s=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(r,n),c=ht({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:a,clear:l}=ht({name:r});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&a(t)},[n,a,l,r]),predicate:o,isActive:i}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),d=dt(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||d){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),d&&d(e)}}},[r,u,i,a,l,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},n),{type:"click",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,a,l])}}function vt(t,r,n){const[o,i]=e.useState(null),[a,l]=e.useState(new Set),s=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&l(t=>{const r=new Set(t);return r.has(e.label)?r.delete(e.label):r.add(e.label),r.size===n.length?new Set:r})},[t,n.length]),u=e.useMemo(()=>{if(!t||"none"===t||!r)return null;const e="string"==typeof r?r:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof r?r(t):null)===o}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const n=e?t[e]:"function"==typeof r?r(t):null;return a.has(n)}}:null},[t,r,o,a]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:s,onLegendClick:c,legendSelectionHook:u}}const mt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function bt(e,t,r){var n,o,i,a,l,s;const c=mt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?c.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?c.height:r.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function xt({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class kt extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var r,n;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:u.createElement(xt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function wt({componentName:e,width:t,height:r,children:n}){return u.createElement(kt,{fallback:n=>u.createElement(xt,{componentName:e,message:n.message,width:t,height:r})},n)}"undefined"!=typeof process&&process;const Et={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Lt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function At(e,t,r,n){return!1===n||e&&Array.isArray(e)&&e.length>0||e&&!Array.isArray(e)?null:u.createElement("div",{style:Object.assign(Object.assign({},Et),{width:t,height:r})},n||"No data available")}function Dt(e,t,r){if(!e)return null;const n=Math.min(5,Math.floor(r/40)),o=Math.max(8,Math.floor(r/(3*n))),i=Math.max(6,Math.floor(r/(2.5*n))),a=Math.floor((r-(n*(o+i)-i))/2);return u.createElement("div",{style:{width:t,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:n},(e,r)=>u.createElement("div",{key:r,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Lt),{position:"absolute",top:a+r*(o+i),left:Math.floor(.1*t),width:30+Math.round(50*Math.random())+"%",height:o,opacity:.5+r%2*.2})})))}function St(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function Ct(e,t){var r;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(r=function(e,t,r=3){let n,o=r+1;for(const r of t){const t=St(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}(e,t,3))&&void 0!==r?r:null)}function Pt({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Mt({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const r=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){const r=Ct(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}function Ot(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:l,nodeIDAccessor:s="id",sourceAccessor:c="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:y="category10",nodeSize:g=8,nodeSizeRange:p=[5,20],edgeWidth:v=1,edgeColor:m="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:E={},onObservation:L,chartId:A,selection:D,linkedHover:S,loading:C,emptyContent:P,legendInteraction:M}=t,O=n.width,N=n.height,I=n.enableHover,W=n.showLegend,T=null!==(r=n.showLabels)&&void 0!==r&&r,$=n.title,_=Dt(C,O,N);if(_)return _;const B=At(i,O,N,P);if(B)return B;const R=o||[],j=i||[],H=gt(R,f,y),z=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of R){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[R,f]),F=vt(M,f,z),Y=e.useMemo(()=>e=>{const t={};return t.fill=f?ze(e.data||e,f,H):yt,"number"==typeof g&&(t.r=g),t},[f,H,g]),X=e.useMemo(()=>e=>({stroke:m,strokeWidth:"number"==typeof v?v:"function"==typeof v?v(e):e[v]||1,opacity:b}),[v,m,b]),G=e.useMemo(()=>{if(T&&h)return"function"==typeof h?h:e=>e[h]},[T,h]),{legend:q,margin:V}=function({data:t,colorBy:r,colorScale:n,showLegend:o,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(ft),s=void 0!==o?o:!l&&!!r,c=e.useMemo(()=>{if(s&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(o=>{const i=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),a=i?n(i,t,r):r?r(o):"#000000";return{label:o+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==o&&(t.stroke=o),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:ze})},[s,r,t,n]),u=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),i);return c&&120>e.right&&(e.right=120),e},[a,i,c]);return{legend:c,margin:u}}({data:R,colorBy:f,colorScale:H,showLegend:W,userMargin:a,defaults:n.marginDefaults}),{customHoverBehavior:Z}=pt({selection:D,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,chartType:"ForceDirectedGraph",chartId:A}),K=Mt({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:s}});return K?u.createElement(xt,{componentName:"ForceDirectedGraph",message:K,width:O,height:N}):u.createElement(wt,{componentName:"ForceDirectedGraph",width:O,height:N},u.createElement(Ke,Object.assign({chartType:"force",nodes:R,edges:j,size:[O,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:d,iterations:x,forceStrength:k,nodeStyle:Y,edgeStyle:X,colorBy:f,colorScheme:y,nodeSize:g,nodeSizeRange:p,nodeLabel:G,showLabels:T,enableHover:I,tooltipContent:w?e=>tt(w)(e.data):void 0,customHoverBehavior:S||L?Z:void 0,legend:q},M&&"none"!==M&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:l,title:$},E)))}function Nt(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function It(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],i="function"==typeof n?n(e):e[n];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function Wt(e){return"function"==typeof e?e:t=>t[e]||1}function Tt({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const l=Object.assign({fillOpacity:o},i);if("function"==typeof e)l.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?l.fill=ze(e.data||e,t,r):e&&(l.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?l.fill=ze(e.data||e,t,r):e&&(l.fill=n(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*o);return l}}function $t(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:o,edges:i,margin:a,className:l,sourceAccessor:s="source",targetAccessor:c="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",orientation:p="horizontal",nodeAlign:v="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:E,frameProps:L={},onObservation:A,chartId:D,selection:S,linkedHover:C,loading:P,emptyContent:M,legendInteraction:O}=t,N=n.width,I=n.height,W=n.enableHover,T=null===(r=n.showLabels)||void 0===r||r,$=n.title,_=Dt(P,N,I);if(_)return _;const B=At(i,N,I,M);if(B)return B;const R=i||[],j=e.useMemo(()=>It(o,R,s,c),[o,R,s,c]),H=gt(j,f,y),z=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of j){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[j,f]),F=vt(O,f,z),Y=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?ze(e.data||e,f,H):"#4d430c",t},[f,H]),X=e.useMemo(()=>Tt({edgeColorBy:g,colorBy:f,colorScale:H,nodeStyleFn:Y,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,H,Y,k]),G=e.useMemo(()=>{if(!T)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[T,x,h]),q=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:V,customClickBehavior:Z}=pt({selection:S,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:A,chartType:"SankeyDiagram",chartId:D}),K=Mt({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return K?u.createElement(xt,{componentName:"SankeyDiagram",message:K,width:N,height:I}):u.createElement(wt,{componentName:"SankeyDiagram",width:N,height:I},u.createElement(Ke,Object.assign({chartType:"sankey",nodes:j,edges:R,size:[N,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:c,valueAccessor:d,orientation:p,nodeAlign:v,nodePaddingRatio:m,nodeWidth:b,nodeStyle:Y,edgeStyle:X,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:k,edgeSort:w,nodeLabel:G,showLabels:T,enableHover:W,tooltipContent:E?e=>tt(E)(e.data):void 0,customHoverBehavior:C||A?V:void 0,customClickBehavior:A?Z:void 0},O&&"none"!==O&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:l,title:$},L)))}function _t(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:l,sourceAccessor:s="source",targetAccessor:c="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",padAngle:p=.01,groupWidth:v=20,sortGroups:m,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:E,chartId:L,selection:A,linkedHover:D,loading:S,emptyContent:C,legendInteraction:P}=t,M=n.width,O=n.height,N=n.enableHover,I=null===(r=n.showLabels)||void 0===r||r,W=n.title,T=Dt(S,M,O);if(T)return T;const $=At(i,M,O,C);if($)return $;const _=i||[],B=e.useMemo(()=>It(o,_,s,c),[o,_,s,c]),R=gt(B,f,y),j=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of B){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[B,f]),H=vt(P,f,j),z=e.useMemo(()=>(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=ze(e.data||e,f,R);else{const i=Array.isArray(y)?y:Re[y]||je,a=Array.isArray(i)?i:je,l=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[l%a.length]}return o},[f,R,y]),F=e.useMemo(()=>Tt({edgeColorBy:g,colorBy:f,colorScale:R,nodeStyleFn:z,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,R,z,x]),Y=e.useMemo(()=>{if(!I)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[I,b,h]),X=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:G}=pt({selection:A,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ChordDiagram",chartId:L}),q=Mt({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return q?u.createElement(xt,{componentName:"ChordDiagram",message:q,width:M,height:O}):u.createElement(wt,{componentName:"ChordDiagram",width:M,height:O},u.createElement(Ke,Object.assign({chartType:"chord",nodes:B,edges:_,size:[M,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:c,valueAccessor:d,padAngle:p,groupWidth:v,sortGroups:m,nodeStyle:z,edgeStyle:F,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:x,nodeLabel:Y,showLabels:I,enableHover:N,tooltipContent:k?e=>tt(k)(e.data):void 0,customHoverBehavior:D||E?G:void 0},P&&"none"!==P&&{legendHoverBehavior:H.onLegendHover,legendClickBehavior:H.onLegendClick,legendHighlightedCategory:H.highlightedCategory,legendIsolatedCategories:H.isolatedCategories},{className:l,title:W},w)))}function Bt(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:i,className:a,layout:l="tree",orientation:s="vertical",childrenAccessor:c="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:y="category10",colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:E,linkedHover:L,loading:A,legendInteraction:D}=t,S=n.width,C=n.height,P=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,O=n.title,N=Dt(A,S,C);if(N)return N;const I=e.useMemo(()=>Nt(o,c),[o,c]),W=gt(I,g?void 0:f,y),T=e.useMemo(()=>{if(!f||g)return[];const e=new Set;for(const t of I){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[I,f,g]),$=vt(D,g?void 0:f,T),_=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?He[(e.depth||0)%He.length]:f?ze(e.data||e,f,W):yt,t},[f,g,W]),B=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),R=e.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return Wt(d)},[l,d]),j=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:H}=pt({selection:E,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),z=Pt({componentName:"TreeDiagram",data:o});return z?u.createElement(xt,{componentName:"TreeDiagram",message:z,width:S,height:C}):u.createElement(wt,{componentName:"TreeDiagram",width:S,height:C},u.createElement(Ke,Object.assign({chartType:l,data:o,size:[S,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:j,nodeIDAccessor:h,childrenAccessor:c,hierarchySum:R,treeOrientation:s,edgeType:p,nodeStyle:_,edgeStyle:B,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:M?v||h:void 0,showLabels:M,enableHover:P,tooltipContent:b?e=>tt(b)(e.data):void 0,customHoverBehavior:L||k?H:void 0},D&&"none"!==D&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories},{className:a,title:O},x)))}function Rt(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:y="leaf",nodeLabel:g,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:E,loading:L,legendInteraction:A}=t,D=n.width,S=n.height,C=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,M=n.title,O=Dt(L,D,S);if(O)return O;const{activeSelectionHook:N,customHoverBehavior:I}=pt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:E}),W=e.useCallback(e=>{if(!e)return I(null);const t=e.data||e;I({data:(null==t?void 0:t.data)||t})},[I]),T=e.useMemo(()=>Nt(o,l),[o,l]),$=gt(T,f?void 0:d,h),_=e.useMemo(()=>{if(!d||f)return[];const e=new Set;for(const t of T){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[T,d,f]),B=vt(A,f?void 0:d,_),R=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?He[(e.depth||0)%He.length]:d?ze(e.data||e,d,$):yt,t},[d,f,$]),j=e.useMemo(()=>N?e=>{var t;const r=Object.assign({},R(e));if(N.isActive)if(N.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(r,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(r,x.unselectedStyle)}return r}:R,[R,N,x]),H=e.useMemo(()=>Wt(s),[s]),z=void 0!==v?v:P&&"parent"===y?18:void 0,F=Object.assign(Object.assign({},n.marginDefaults),i),Y=Pt({componentName:"Treemap",data:o});return Y?u.createElement(xt,{componentName:"Treemap",message:Y,width:D,height:S}):u.createElement(wt,{componentName:"Treemap",width:D,height:S},u.createElement(Ke,Object.assign({chartType:"treemap",data:o,size:[D,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:H,padding:p,paddingTop:z,nodeStyle:j,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:P?g||c:void 0,showLabels:P,enableHover:C,tooltipContent:m?e=>tt(m)(e.data):void 0},(k||w)&&{customHoverBehavior:W},A&&"none"!==A&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:M},b)))}function jt(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:y,circleOpacity:g=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x,selection:k,linkedHover:w,loading:E,legendInteraction:L}=t,A=n.width,D=n.height,S=n.enableHover,C=null===(r=n.showLabels)||void 0===r||r,P=n.title,M=Dt(E,A,D);if(M)return M;const O=e.useMemo(()=>Nt(o,l),[o,l]),N=gt(O,f?void 0:d,h),I=e.useMemo(()=>{if(!d||f)return[];const e=new Set;for(const t of O){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[O,d,f]),W=vt(L,f?void 0:d,I),T=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?He[(e.depth||0)%He.length]:d?ze(e.data||e,d,N):yt,t},[d,f,N,g]),$=e.useMemo(()=>Wt(s),[s]),_=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:B}=pt({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),R=Pt({componentName:"CirclePack",data:o});return R?u.createElement(xt,{componentName:"CirclePack",message:R,width:A,height:D}):u.createElement(wt,{componentName:"CirclePack",width:A,height:D},u.createElement(Ke,Object.assign({chartType:"circlepack",data:o,size:[A,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:$,padding:p,nodeStyle:T,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:C?y||c:void 0,showLabels:C,enableHover:S,tooltipContent:v?e=>tt(v)(e.data):void 0,customHoverBehavior:w||b?B:void 0},L&&"none"!==L&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:P},m)))}Ot.displayName="ForceDirectedGraph",$t.displayName="SankeyDiagram",_t.displayName="ChordDiagram",Bt.displayName="TreeDiagram",Rt.displayName="Treemap",jt.displayName="CirclePack";const Ht=["#93c5fd","#fca5a5","#86efac","#fde68a","#c4b5fd","#f9a8d4","#a5f3fc"];function zt(t){const r=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,title:t.title},{width:600,height:600}),{data:n,childrenAccessor:o="children",nodeIdAccessor:i="name",colorBy:a,colorScheme:s="category10",colorByDepth:c=!1,orbitMode:d="flat",orbitSize:h=2.95,speed:f=.25,revolution:y=e=>1/(e.depth+1),eccentricity:g=1,showRings:p=!0,nodeRadius:v=6,showLabels:m=!1,animated:b=!0,tooltip:x,foregroundGraphics:k,className:w,annotations:E,selection:L,linkedHover:A,onObservation:D,chartId:S,loading:C}=t,P=r.width,M=r.height,O=r.title,N=Dt(C,P,M);if(N)return N;const I=e.useMemo(()=>"function"==typeof o?o:e=>e[o],[o]),W=e.useMemo(()=>"function"==typeof i?i:e=>{var t;return(null!==(t=e[i])&&void 0!==t?t:"")+""},[i]),T=e.useMemo(()=>"function"==typeof v?v:()=>v,[v]),{customHoverBehavior:$}=pt({selection:L,linkedHover:A,fallbackFields:a?["string"==typeof a?a:""]:[],onObservation:D,chartType:"OrbitDiagram",chartId:S}),_=gt(e.useMemo(()=>{const e=[];return function t(r){e.push(r);const n=I(r);n&&n.forEach(t)}(n),e},[n,I]),c?void 0:a,s),{nodes:B,rings:R,eccentricityFn:j}=e.useMemo(()=>function(e,t,r,n,o,i,a){const s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o),c="number"==typeof i?()=>i:i,u="number"==typeof a?()=>a:a,d=[],h=[],f={datum:e,x:t[0]/2,y:t[1]/2,ring:Math.min(t[0],t[1])/2*.85,angle:0,depth:0,id:n(e)};return d.push(f),function e(t){const o=r(t.datum);if(!(null==o?void 0:o.length))return;t.children=[];const i=o.length;let a=0,f=0,y=0;for(;i>f;)f+=s[Math.min(y,s.length-1)],y++,a++;let g=0;for(let i=0;a>i;i++){const f=s[Math.min(i,s.length-1)],y=o.slice(g,g+f);if(!y.length)break;const p=(i+1)/a,v=t.parent?t.ring/c(t)*p:t.ring*p,m=l.pie().value(e=>{var t;return(null===(t=r(e))||void 0===t?void 0:t.length)?4:1}).sort(null)(y),b=u(t);h.push({source:t,x:t.x,y:t.y,r:v,ry:v*b});for(let r=0;y.length>r;r++){const o=(m[r].startAngle+m[r].endAngle)/2,i={datum:y[r],x:t.x+v*Math.sin(o),y:t.y+v*Math.cos(o)*b,ring:v,angle:o,depth:t.depth+1,parent:t,id:n(y[r])};t.children.push(i),d.push(i),e(i)}g+=f}}(f),{nodes:d,rings:h,eccentricityFn:u}}(n,[P,M],I,W,d,h,g),[n,P,M,I,W,d,h,g]),[,H]=e.useState(0),z=e.useRef(0),F=f*(Math.PI/360);e.useEffect(()=>{if(!b)return;let e;const t=()=>{z.current++,function(e,t,r,n,o,i){for(const t of e){if(!t.parent)continue;const e=t.angle+r*n*o(t),a=i(t);t.x=t.parent.x+t.ring*Math.sin(e),t.y=t.parent.y+t.ring*Math.cos(e)*a}for(const e of t)e.x=e.source.x,e.y=e.source.y}(B,R,z.current,F,y,j),H(e=>e+1),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[b,B,R,F,y,j]);const[Y,X]=e.useState(null),G=e.useCallback(e=>{X(e),$&&$(e?{data:e.datum,x:e.x,y:e.y}:null)},[$]),q=e.useCallback(e=>c?Ht[e.depth%Ht.length]:a?ze(e.datum,a,_):yt,[a,c,_]),V=Pt({componentName:"OrbitDiagram",data:n});return V?u.createElement(xt,{componentName:"OrbitDiagram",message:V,width:P,height:M}):u.createElement(wt,{componentName:"OrbitDiagram",width:P,height:M},u.createElement("div",{className:"semiotic-orbit-diagram"+(w?" "+w:""),role:"img","aria-label":"string"==typeof O?O:"Orbit diagram",tabIndex:0,style:{position:"relative",width:P,height:M}},u.createElement("svg",{width:P,height:M},p&&R.map((e,t)=>u.createElement("ellipse",{key:"ring-"+t,cx:e.x,cy:e.y,rx:e.r,ry:e.ry,fill:"none",stroke:"currentColor",strokeWidth:.5,opacity:.15})),B.map((e,t)=>e.parent?u.createElement("line",{key:"edge-"+t,x1:e.parent.x,y1:e.parent.y,x2:e.x,y2:e.y,stroke:"currentColor",strokeWidth:.5,opacity:.1}):null),B.map((e,t)=>{const r=T(e),n=q(e),o=Y===e;return u.createElement("g",{key:"node-"+t},u.createElement("circle",{cx:e.x,cy:e.y,r:o?1.5*r:r,fill:n,stroke:"white",strokeWidth:o?2:1,opacity:0===e.depth?1:.85,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>G(e),onMouseLeave:()=>G(null)}),m&&r>4&&u.createElement("text",{x:e.x,y:e.y+r+12,textAnchor:"middle",fontSize:10,fill:"currentColor",opacity:.7},W(e.datum)))}),null==E?void 0:E.map((e,t)=>{var r,n,o,i,a;if("widget"!==e.type)return null;const l=e.nodeId?B.find(t=>t.id===e.nodeId):null;if(!l)return null;const s=null!==(r=e.dx)&&void 0!==r?r:0,c=null!==(n=e.dy)&&void 0!==n?n:-16,d=null!==(o=e.width)&&void 0!==o?o:32,h=null!==(i=e.height)&&void 0!==i?i:32,f=null!==(a=e.content)&&void 0!==a?a:u.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return u.createElement("foreignObject",{key:"ann-"+t,x:l.x+s-d/2,y:l.y+c-h/2,width:d,height:h,style:{overflow:"visible",pointerEvents:"auto"}},u.createElement("div",{style:{width:d,height:h,display:"flex",alignItems:"center",justifyContent:"center"}},f))}),k),Y&&x&&u.createElement("div",{style:{position:"absolute",left:Y.x+12,top:Y.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},x(Y)),Y&&!x&&u.createElement("div",{style:{position:"absolute",left:Y.x+12,top:Y.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},u.createElement("strong",null,W(Y.datum)),Y.depth>0&&u.createElement("span",{style:{opacity:.7}}," (depth ",Y.depth,")")),O&&u.createElement("div",{style:{position:"absolute",top:8,left:0,width:"100%",textAlign:"center",fontSize:14,fontWeight:600,color:"currentColor",pointerEvents:"none"}},O)))}zt.displayName="OrbitDiagram",exports.ChordDiagram=_t,exports.CirclePack=jt,exports.ForceDirectedGraph=Ot,exports.OrbitDiagram=zt,exports.SankeyDiagram=$t,exports.StreamNetworkFrame=Ke,exports.TreeDiagram=Bt,exports.Treemap=Rt;
|