semiotic 3.1.2 → 3.2.0
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 +134 -216
- package/LICENSE +197 -10
- package/README.md +1 -0
- package/ai/dist/componentRegistry.js +6 -0
- package/ai/dist/mcp-server.js +115 -5
- package/ai/examples.md +93 -0
- package/ai/schema.json +3916 -878
- package/ai/system-prompt.md +27 -0
- package/dist/components/ThemeProvider.d.ts +5 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +1 -1
- package/dist/components/charts/index.d.ts +8 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +1 -0
- package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +1 -0
- package/dist/components/charts/ordinal/DotPlot.d.ts +1 -0
- package/dist/components/charts/ordinal/FunnelChart.d.ts +55 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +1 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +1 -0
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -0
- package/dist/components/charts/shared/colorManipulation.d.ts +15 -0
- package/dist/components/charts/shared/formatUtils.d.ts +28 -0
- package/dist/components/charts/shared/hatchPattern.d.ts +35 -0
- package/dist/components/charts/shared/hooks.d.ts +16 -1
- package/dist/components/charts/shared/legendUtils.d.ts +2 -1
- package/dist/components/charts/shared/selectionUtils.d.ts +11 -0
- package/dist/components/charts/shared/statisticalOverlays.d.ts +49 -5
- package/dist/components/charts/shared/types.d.ts +4 -1
- package/dist/components/charts/xy/Heatmap.d.ts +1 -1
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +71 -0
- package/dist/components/realtime/types.d.ts +2 -0
- package/dist/components/semiotic-ai.d.ts +3 -0
- package/dist/components/semiotic-ordinal.d.ts +3 -0
- package/dist/components/semiotic-themes.d.ts +64 -0
- package/dist/components/semiotic-xy.d.ts +1 -0
- package/dist/components/semiotic.d.ts +11 -5
- package/dist/components/store/ThemeStore.d.ts +22 -2
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -0
- package/dist/components/stream/PipelineStore.d.ts +2 -0
- package/dist/components/stream/SVGOverlay.d.ts +5 -3
- package/dist/components/stream/accessorUtils.d.ts +14 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +27 -0
- package/dist/components/stream/ordinalSceneBuilders/funnelScene.d.ts +26 -0
- package/dist/components/stream/ordinalTypes.d.ts +16 -2
- package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +12 -0
- package/dist/components/stream/renderers/trapezoidCanvasRenderer.d.ts +15 -0
- package/dist/components/stream/sceneUtils.d.ts +10 -0
- package/dist/components/stream/types.d.ts +10 -3
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +1 -0
- 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-ordinal.d.ts +3 -0
- package/dist/semiotic-statisticalOverlays-D8LhSbQt.js +1 -0
- package/dist/semiotic-themes.d.ts +64 -0
- package/dist/semiotic-themes.min.js +1 -0
- package/dist/semiotic-themes.module.min.js +1 -0
- package/dist/semiotic-xy.d.ts +1 -0
- package/dist/semiotic.d.ts +11 -5
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy-statisticalOverlays-C2PPlmXv.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +24 -5
- package/dist/semiotic-ai-statisticalOverlays-C1f7TYyD.js +0 -1
- package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +0 -1
- package/dist/xy-statisticalOverlays-C1f7TYyD.js +0 -1
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"),i=require("d3-scale"),a=require("d3-chord"),s=require("d3-shape"),c=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 y{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 s=r[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const c=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*c*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const l=g(s.bezier,a.t,a.offset);a.x=l.x,a.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 g(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),s=i-a,[c,l,u,d]=e[a],h=f(c,l,u,d,s),y=d.x-c.x,g=d.y-c.y,p=Math.sqrt(y*y+g*g);if(p>.001){const e=y/p;h.x+=-g/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,s=f(n,o,i,a,t),c=a.x-n.x,l=a.y-n.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;s.x+=-l/u*r*e.halfWidth*2,s.y+=t*r*e.halfWidth*2}return s}function f(e,t,r,n,o){const i=1-o,a=i*i,s=a*i,c=o*o,l=c*o;return{x:s*e.x+3*a*o*t.x+3*i*c*r.x+l*n.x,y:s*e.y+3*a*o*t.y+3*i*c*r.y+l*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function m(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,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),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var g=i[t];y.length>g;++g){var f=y[g];if(0>r[f]){r[f]=n[f]=u,o[f]=!0,u+=1,c.push(f),l.push(f);break}o[f]&&(n[t]=0|Math.min(n[t],n[f])),0>a[f]||s[t].push(a[f])}i[t]=g}else{if(n[t]===r[t]){var p=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var b=c[g];if(o[b]=!1,p.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){c.length=g;break}}d.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var g=h[c];if(0!==g.length){g.sort(function(e,t){return e-t}),l=[g[0]];for(var f=1;g.length>f;f++)g[f]!==g[f-1]&&l.push(g[f]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],r=a);var c=o[r];if(!c)return!1;var l=e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})});return{leastVertex:i,adjList:l}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var g=0;s.length>g;g++)for(var f=0;s[g].length>f;f++){var p=s[g][f];i[+p]=!1,a[p]={}}l(r),r+=1}else r=h}return n}function v(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 A(e,t){var r=S(e),n=k(t)/Math.tan(r);return"up"==v(e)?e.y1-n:e.y1+n}function w(e,t){var r=S(e),n=k(t)/Math.tan(r);return"up"==v(e)?e.y1+n:e.y1-n}function S(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function E(e,t){return t(e)}function L(e){return O(e.source)}function D(e){return O(e.target)}function O(e){return(e.y0+e.y1)/2}function j(e){return e.virtual?0:e.value}function P(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 C(e){return e.target.depth}function M(e,t){return e.sourceLinks.length?e.depth:t-1}function I(e,t){return e.y0-t.y0}function N(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 W(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 B(e,t){return z(e)==z(t)?"bottom"==e.circularLinkType?N(e,t):I(e,t):z(t)-z(e)}function z(e){return e.target.column-e.source.column}function H(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 s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var c=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=a.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),q(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),q(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,s=e.circularLinkType,l=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});l.sort("bottom"==e.circularLinkType?N:I);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=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?$:T),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(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=c-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 q(e,t,r){e.sort(B);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 s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&X(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function X(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function G(e){return function(){return e}}function V(e){return e.index}function K(e){return e.nodes}function Z(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,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=O(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=O(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?r.idx-n.idx:1:-1:o-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?P(t,n)-P(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==P(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 U(e,t,n,o,i,a){var s=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 c=1,l=a;l>0;--l)u(c*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var c;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&P(i,n)>0){var l=r.mean(i.sourceLinks,D),u=r.mean(i.targetLinks,L),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-O(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)c=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+c;else{var y=r.mean(i.sourceLinks,D),g=r.mean(i.targetLinks,L),f=((y&&g?(y+g)/2:y||g)-O(i))*t;i.y0+=f,i.y1+=f}})})}function d(){s.forEach(function(r){var n,a,s,c=e.y0,l=r.length;for(r.sort(t||R),s=0;l>s;++s)(a=c-(n=r[s]).y0)>0&&(n.y0+=a,n.y1+=a),c=n.y1+o;if((a=c-o-e.y1)>0)for(c=n.y0-=a,n.y1-=a,s=l-2;s>=0;--s)(a=(n=r[s]).y1+i-c)>0&&(n.y0-=a,n.y1-=a),c=n.y0})}}function J(e){e.nodes.forEach(function(e){e.sourceLinks.sort(W),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,s=null,c=V,l=M,u=void 0,d=32,h=2,y=K,g=Z;function f(){var f={nodes:y.apply(null,arguments),links:g.apply(null,arguments)};return function(y){y.x0=e,y.y0=t,y.x1=n,y.y1=o,y.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)})}(y,c),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=m(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(y,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){E(e,t)!=E(o.source,t)&&E(e,t)!=E(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))})}(y,c),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,j),r.sum(e.targetLinks,j)),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)})})}(y),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(y,u,l);var g=a;if(null!==s){var f=r.groups(y.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),v=r.max(f,function(e){return e.length});v>1&&(g=Math.max(1,(o-t)*s/(v-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})})(y,g,i),Q(y,u,c),U(y,u,c,g,g,d),J(y),Y(y,c,h,10,8),Q(y,u,c),U(y,u,c,g,g,d),J(y),Y(y,c,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 E(r.source,t)==E(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(!H(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=A(t,e);return e.y1-r}if(t.target.column>e.target.column)return A(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}})})}(y,c),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return E(r.target,t)==E(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(!H(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=w(t,e);return e.y0-r}if(t.source.column>e.source.column)return w(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}})})}(y,c),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}),s=r.max(t,function(e){return e.y1}),c=(e.y1-e.y0)/(s-a);function l(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>c?(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*c})):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})})}}(y),Y(y,c,h,10,8)}(f),f}return f.update=function(e){return J(e),Y(e,c,h,10,8),e},f.nodeWidth=function(e){return arguments.length?(i=+e,f):i},f.nodePadding=function(e){return arguments.length?(a=+e,f):a},f.nodePaddingRatio=function(e){return arguments.length?(s=+e,f):s},f.nodes=function(e){return arguments.length?(y="function"==typeof e?e:G(e),f):y},f.links=function(e){return arguments.length?(g="function"==typeof e?e:G(e),f):g},f.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:G(e),f):c},f.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:G(e),f):l},f.nodeSort=function(e){return arguments.length?(u=e,f):u},f.iterations=function(e){return arguments.length?(d=+e,f):d},f.circularLinkGap=function(e){return arguments.length?(h=+e,f):h},f.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],f):[[e,t],[n,o]]},f.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],f):[n-e,o-t]},f}const te=e=>{let r,n,o,i,a,s,c,l,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,s=e.target.y0,c=t.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${r},${a}C${r},${l} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${l} ${i},${a}Z`):(r=e.source.x1,n=e.target.x0,c=t.interpolateNumber(r,n),o=c(.5),i=c(.5),a=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${a}C${o},${a} ${i},${s} ${n},${s}L${n},${l}C${i},${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,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+s},${n-r}L${t+s},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-c},${a-r}L${i-c},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,s=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,y=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${l},${a-h*r}L${l+n},${a-h*r+h*y}L${l+n},${d+h*n-h*y}L${l+n-y},${d+h*n}L${u-n+y},${d+h*n}L${u-n},${d+h*n-h*y}L${u-n},${c-h*r+h*y}L${u-n+y},${c-h*r}L${s},${c-h*r}L${s},${c+h*r}L${u+n},${c+h*r}L${u+n},${d-h*n}L${l-n},${d-h*n}L${l-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(C))-1:0},justify:M},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,s,c,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",y=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,f=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=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 v;v="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(v).links(m).nodes(p).nodeAlign(ne[h]||M).nodeId(e=>e.id).nodeWidth(y).iterations(f);b.nodePaddingRatio&&b.nodePaddingRatio(g),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 m){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(c=null!==(s=n._circularWidth)&&void 0!==s?s:n.width)&&void 0!==c?c: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 m)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 m){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,s,c;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,y=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,f=new Map;e.forEach((e,t)=>{f.set(e.id,g[t%g.length])});const p=[],m=[],v=[];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||f.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"===y&&r?n=f.get(r.id)||n:t&&(n=f.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))),c=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=o.fill||n;m.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:l,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}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-c},${t.targetY-r}L${t.targetX-c},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-c,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?re(e):te(e),!i)continue;const l={fill:o.fill||n,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:i,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 i=t?t(r):r.id;if(!i)continue;let a,s,c;"down"===l?(a=r.x0+e/2,s=r.y1+14,c="middle"):(o[0]/2>r.x0+e/2?(a=r.x0-6,c="end"):(a=r.x1+6,c="start"),s=r.y0+n/2),v.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}},ie={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,c=n[0]/2,l=n[1]/2,u=r.__previousPositions;let d=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=null==u?void 0:u.get(t.id);e?d++:r?(t.x=r.x,t.y=r.y,d++):h.push(t)}const y=d>0&&.3>=(e.length>0?h.length/e.length:1);if(y){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of h){const n=ae(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=se(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=se(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=c+n*Math.cos(r),e.y=l+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=c+e*Math.cos(o),n.y=l+e*Math.sin(o)}}}const g=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=y?40:g,p=ce(r.nodeSize,r.nodeSizeRange,e),m=e=>p(e),v=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),b=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*m(e))).force("center",o.forceCenter(c,l).strength(.8)).force("x",o.forceX(c).strength(.15)).force("y",o.forceY(l).strength(.15));if(b.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}));b.force("link",v),b.force("link").links(e)}y?b.alpha(.3):.1>b.alpha()&&b.alpha(1),b.stop();for(let e=0;f>e;++e)b.tick();for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=x.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=x.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var i,a,s;const c=r.nodeStyle,l=r.edgeStyle,u=ce(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 y=[],g=[],f=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=c?c(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};y.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!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=n.opacity)&&void 0!==s?s:.6};g.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=(m=r.nodeLabel)?"function"==typeof m?m:e=>e[m]||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);f.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:y,sceneEdges:g,labels:f}}};function ae(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function se(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function ce(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 s=t||[5,20],c=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===c.length)return()=>s[0];const l=null!==(o=r.min(c))&&void 0!==o?o:0,u=null!==(a=r.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([l,u]).range(s).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?s[0]:d(n)}}const le=n.schemeCategory10,ue={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:c}=r,l=Math.min(n[0],n[1])/2,u=l-i,d=n[0]/2,h=n[1]/2,y=(g=r.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,m=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=f.get("string"==typeof e.source?e.source:e.source.id),n=f.get(t);if(void 0===r||void 0===n)continue;const o=y(e);m[r][n]=o}const v=a.chord().padAngle(o);c&&v.sortGroups(c);const b=v(m),x=b.groups,k=s.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 A=new Map;for(const t of e)A.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=A.get("string"==typeof e.source?e.source:e.source.id),n=A.get(t);r&&(e.source=r),n&&(e.target=n)}const w=new Map;for(const e of t)w.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=w.get(`${r}\0${n}`)||w.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:s=20,edgeOpacity:c=.5}=r,l=Math.min(n[0],n[1])/2,u=l-s,d=n[0]/2,h=n[1]/2,y=r.nodeStyle,g=r.edgeStyle,f=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:le,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const v=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=y?y(r).fill||m.get(r.id)||p[t%p.length]:m.get(r.id)||p[t%p.length];const a=y?y(r):{},s={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:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:s,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=v(t);if(!r)continue;const n=de(r,d,h);let o="#999";if(g)o=g(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===f&&r?o=m.get(r.id)||o:t&&(o=m.get(t.id)||o)}const a=g?g(e):{},s={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:n,style:s,datum:e})}if(!1!==r.showLabels){const t=(A=r.nodeLabel)?"function"==typeof A?A:e=>e[A]||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 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 A;return{sceneNodes:b,sceneEdges:x,labels:k}}};function de(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(" ")}function he(e){const[t,r,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}const ye={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=(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=c.hierarchy(i,s);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,y]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=c.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,y);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=c.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,y);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,l=c.treemap().size([r,n]).tile(c.treemapBinary).padding(a);s>0&&l.paddingTop(s),l(e)}(d,r,h,y);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;c.pack().size([r,n]).padding(i)(e)}(d,r,h,y);break;case"partition":!function(e,t,r,n){var o;c.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,y)}const g=d.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;g.length>t;t++){const n=g[t],i={id:ve(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?ge(i,n,r):"treemap"===a||"partition"===a?fe(i,n):"circlepack"===a&&pe(i,n),i.__hierarchyNode=n,e.push(i),f.set(n,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const r=f.get(e.parent),n=f.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,s,c,l,u;const d=[],h=[],y=[],g=r.treeOrientation||"vertical",f="radial"===g,p=n[0]/2,m=n[1]/2,v="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;f&&(e+=p,n+=m);const i=o(t);let s=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const c={fill:s,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:v,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(s=r.edgeOpacity)&&void 0!==s?s:.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,s=r.y;f&&(n+=p,o+=m,a+=p,s+=m);const u=me(n,o,a,s,g),d=i(e),y={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(c=d.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:k};h.push({type:"curved",pathD:u,style:y,datum:e})}if(!1!==r.showLabels){const t=be(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(f&&(a+=p,s+=m),f){const e=a-p,t=s-m,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===g?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=a-v-6,i="end"):(n=a+v+6,i="start"),o=s):(n=a,o=s+v+14,i="middle");y.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:y}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i;const a=[],s=[],c=["#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 s=n(r);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(l=c[r.depth%c.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.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=be(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const l of e){const e=l.x1-l.x0,u=l.y1-l.y0;if(0>=e||0>=u)continue;const d=!((null===(i=l.data)||void 0===i?void 0:i.children)&&l.data.children.length>0);if(!a){if("leaf"===o&&!d)continue;if("parent"===o&&d)continue}const h=r?r(l):l.id;if(!h)continue;if((d?30:40)>e||(d?16:14)>u)continue;let y=n(l).fill||"#4d430c";t.colorByDepth&&void 0!==l.depth&&(y=c[l.depth%c.length]);const g=he(y);s.push(d?{x:l.x0+e/2,y:l.y0+u/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:g}:{x:l.x0+4,y:l.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:g})}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,s,c;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 s=n(r);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=d[r.depth%d.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.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=be(t.nodeLabel);for(const o of e){const e=null!==(s=o.__radius)&&void 0!==s?s:5,i=r?r(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=n(o).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(l=d[o.depth%d.length]),a){const t=he(l);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:o.x,y:o.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ge(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 fe(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 pe(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 me(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 ve(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 be(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}function xe(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const ke={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){var i,a;const c=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),l=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var r;return(null!==(r=e[t])&&void 0!==r?r:"")+""}}(r.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),d=null!==(i=r.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=r.orbitEccentricity)&&void 0!==a?a:1,y="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,f=xe(r);f.metaMap.clear(),n.length=0,o.length=0;const p=new Map;function m(e){var t;const r=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,r+1),0===r?e:`${e}__${r}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(l(e));n.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),f.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,p){const v=c(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,A=0;for(;b>k;)k+=u[Math.min(A,u.length-1)],A++,x++;let w=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],A=v.slice(w,w+k);if(!A.length)break;const S=(b+1)/x,E={id:r,depth:h,data:t,parentId:r},L=p?d/y(E)*S:d*S,D=s.pie().value(e=>{var t;return(null===(t=c(e))||void 0===t?void 0:t.length)?4:1}).sort(null),O=D(A),j=g(E);for(let t=0;A.length>t;t++){const s=(O[t].startAngle+O[t].endAngle)/2,c=A[t],u=m(l(c)),d=i+L*Math.sin(s),y=a+L*Math.cos(s)*j;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:h,data:c}),f.metaMap.set(u,{ring:L,angle:s,depth:h,parentId:r,eccentricity:j}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(c,u,d,y,L,h+1,!0)}w+=k}}(e,k,v,b,x,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,s,c;const l=r.nodeStyle,u=r.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],y=[],g=[];if(!1!==r.orbitShowRings){const t=xe(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;y.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(c),y2:t+r*Math.cos(c)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(t),r=l?l(t):{},n={fill:r.fill||"#6366f1",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=r.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:f.get(e.source),r="object"==typeof e.target?e.target:f.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=d(r);if(4>=e)continue;const n="function"==typeof t?t(r):t&&null!==(c=null===(s=r.data)||void 0===s?void 0:s[t])&&void 0!==c?c:r.id;g.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:y,labels:g}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=xe(t),i=null!==(r=t.orbitSpeed)&&void 0!==r?r:.25,a=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const r=null!==(t=e.depth)&&void 0!==t?t:0;return(r%2==0?1:-1)/(r+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=i*(Math.PI/6),l=new Map;for(const t of e)l.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=l.get(e.parentId);if(!r)continue;const n=e.angle+s*c*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(n),t.y=r.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)},Ae={sankey:oe,force:ie,chord:ue,tree:ye,cluster:ye,treemap:ye,circlepack:ye,partition:ye,orbit:ke};function we(e){return Ae[e]}function Se(e,t,r){return e+(t-e)*r}class Ee{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._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new y(2e3))}updateConfig(e){const t=this.config,r=e;t.__orbitState&&(r.__orbitState=t.__orbitState),t.__hierarchyRoot&&(r.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new y(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,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,s="function"==typeof n?n:e=>e[n],c="function"==typeof o?o:e=>e[o],l="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(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Le(e)),{data:t}))}for(const e of t){const t=c(e)+"",r=l(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Le(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Le(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._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Le(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Le(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);return c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,r,n,o,i,a;const s=we(this.config.chartType);if(!s)return;let c=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(0===c.length&&!s.hierarchical)return;if(this.prepareForRelayout(),s.supportsStreaming&&!s.hierarchical){const e=new Map;for(const s of c)if(void 0!==s._prevX0){const c=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(r=s._prevX0)&&void 0!==r?r:0),l=(null!==(n=s._prevY1)&&void 0!==n?n:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+c/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+l/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(s.computeLayout(c,l,this.config,e),delete this.config.__previousPositions,s.hierarchical&&c.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of c)this.nodes.set(e.id,e);for(const e of l)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();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),c.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 d=new Set(this.nodes.keys()),h=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 d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.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=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=we(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}get isAnimating(){const e=we(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=we(this.config.chartType);if(!(null==r?void 0:r.tick))return!1;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return r.tick(n,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),r=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Se(e._prevX0,e._targetX0,r),e.x1=Se(e._prevX1,e._targetX1,r),e.y0=Se(e._prevY0,e._targetY0,r),e.y1=Se(e._prevY1,e._targetY1,r));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=Se(e._prevY0,e._targetY0,r),e.y1=Se(e._prevY1,e._targetY1,r),e.sankeyWidth=Se(e._prevSankeyWidth,e._targetSankeyWidth,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,s=t.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=r.x1,a=n.x0,s=t.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.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 s=null!==(t=a.duration)&&void 0!==t?t:500,c=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=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;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=c,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,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const l=this.edgeTimestamps.get(`${n}\0${a}`);if(!l)continue;const u=e-l;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=c)}}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,s=this.nodeTimestamps.size;if(1>=s)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const c=this._decaySortedNodes,l=new Map;for(let e=0;c.length>e;e++)l.set(c[e][0],e);for(const e of this.sceneNodes){const c=e.id;if(!c)continue;const u=l.get(c);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*s)>d?1:a;break;default:h=1}const y=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:y*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 s=this.nodes.get(r);if(!s)continue;const c=n.metric(s);let l=null;void 0===n.critical||n.critical>c?void 0===n.warning||n.warning>c||(l=o):l=i,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),a&&(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._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Le(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 De(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Oe(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=je(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;s>r&&(i=e,s=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Ie(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function je(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=De(Math.atan2(o,n)),s=De(e.startAngle),c=De(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let Pe=null,Ce=null;function Me(){return Ce||(Pe=document.createElement("canvas"),Pe.width=1,Pe.height=1,Ce=Pe.getContext("2d")),Ce}function Ie(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=Me();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}}const s=a.lineWidth;a.lineWidth=10;const c=a.isPointInStroke(i,t,r);if(a.lineWidth=s,c)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}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 s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt(Math.pow(t-s,2)+Math.pow(r-c,2));return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=Me();if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);default:return null}}const Ne={fill:e=>u.createElement("rect",{style:e,width:16,height:16}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Te(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Ne[r])(n(e,t)),o}function $e(){return u.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function _e(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function We({config:e,orientation:t="vertical",width:r=100}){const{colorFn:n,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+u.useId();if("horizontal"===t){const e=12,t=Math.min(r,200),a=Math.max(0,(r-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(u.createElement("stop",{key:e,offset:100*t+"%",stopColor:n(o[0]+t*(o[1]-o[0]))}))}return u.createElement("g",{"aria-label":i||"Gradient legend"},u.createElement("defs",null,u.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},l)),i&&u.createElement("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),u.createElement("rect",{x:a,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),u.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])),u.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])))}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(u.createElement("stop",{key:e,offset:100*t+"%",stopColor:n(o[1]-t*(o[1]-o[0]))}))}return u.createElement("g",{"aria-label":i||"Gradient legend"},i&&u.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),u.createElement("defs",null,u.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},l)),u.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),u.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])),u.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])))}function Re(e){const{legendGroups:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:c=100,height:l=20,orientation:d="vertical"}=e,[h,y]=u.useState(0),[g,f]=u.useState(0),p=u.useCallback((e,t)=>{y(e),f(t)},[]),m="vertical"===d?(({legendGroups:e,width:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:l})=>{let d=24;const h=[];return e.forEach((e,y)=>{d+=5,h.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+y,stroke:"gray",x1:0,y1:d,x2:t,y2:d})),d+=8,e.label&&(d+=16,h.push(u.createElement("text",{key:"legend-text-"+y,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),d+=8),h.push(u.createElement("g",{key:"legend-group-"+y,className:"legend-item",transform:`translate(0,${d})`},((e,t,r,n,o,i,a,s,c,l)=>{const{type:d="fill",styleFn:h,items:y}=e,g=[];let f=0;const p=!(!t&&!r),m="isolate"===l||void 0===l&&null!=o;return y.forEach((e,l)=>{const v=Te(e,l,d,h),b=_e(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===i&&l===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:p?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowDown"===r.key||"ArrowUp"===r.key){r.preventDefault();const e=(l+("ArrowDown"===r.key?1:-1)+y.length)%y.length;c(s,e);const t=null===(n=r.currentTarget.parentElement)||void 0===n?void 0:n.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&u.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&u.createElement($e,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=22}),g})(e,r,n,o,i,a,s,y,c,l))),d+=22*e.items.length+8}),h})({legendGroups:t||[],width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:e,height:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:d})=>{let h=0;const y=[];e.forEach((e,t)=>{let r=0;e.label&&(r+=16);const g=((e,t,r,n,o,i,a,s,c,l)=>{const{type:d="fill",styleFn:h,items:y}=e,g=[];let f=0;const p=!(!t&&!r),m="isolate"===l||void 0===l&&null!=o;return y.forEach((e,l)=>{const v=Te(e,l,d,h),b=_e(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${f},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===i&&l===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:p?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowRight"===r.key||"ArrowLeft"===r.key){r.preventDefault();const e=(l+("ArrowRight"===r.key?1:-1)+y.length)%y.length;c(s,e);const t=null===(n=r.currentTarget.parentElement)||void 0===n?void 0:n.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&u.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&u.createElement($e,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=26+7*e.label.length}),{items:g,offset:f}})(e,n,o,i,a,s,c,t,l,d);r+=g.offset+5,y.push(Object.assign(Object.assign({label:e.label},g),{offset:r})),h+=r+12});let g=Math.max(0,(r-h)/2);const f=[];return y.forEach((r,n)=>{const o=e[n];o.label&&(f.push(u.createElement("text",{key:"legend-text-"+n,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),g+=16),f.push(u.createElement("g",{key:"legend-group-"+n,className:"legend-item",transform:`translate(${g},0)`},r.items)),g+=r.offset+5,e[n+1]&&f.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+n,stroke:"gray",x1:g,y1:-8,x2:g,y2:t+0+8})),g+=12}),u.createElement("g",null,f)})({legendGroups:t||[],title:s,height:l,width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:a}),v=!(!r&&!n);return u.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend"},void 0!==s&&""!==s&&"vertical"===d&&u.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function Be(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y,legendPosition:g="right",foregroundGraphics:f,sceneNodes:p,annotations:m,svgAnnotationRules:v}=e;return u.createElement(u.Fragment,null,u.createElement("svg",{role:"img",width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("title",null,"string"==typeof s?s:"Network Chart"),u.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),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)),m&&m.filter(e=>"widget"!==e.type).map((e,n)=>{if(v){const o=v(e,n,{width:t,height:r,sceneNodes:p});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),f),s&&"string"==typeof s?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?u.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},s):null,function(e){const{legend:t,totalWidth:r,totalHeight:n,margin:o,legendPosition:i="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:l,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const y="top"===i||"bottom"===i;let g,f;return"left"===i?(g=4,f=o.top):"top"===i?(g=0,f=a?32:8):"bottom"===i?(g=0,f=n-o.bottom+50):(g=r-o.right+10,f=o.top),u.createElement("g",{transform:`translate(${g}, ${f})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?u.createElement(We,{config:t.gradient,orientation:y?"horizontal":"vertical",width:y?r:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?u.createElement(Re,{legendGroups:t.legendGroups,title:"",width:y?r:100,orientation:y?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:l,isolatedCategories:d,legendInteraction:h}):t)}({legend:c,totalWidth:n,totalHeight:o,margin:i,legendPosition:g,title:s,legendHoverBehavior:l,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y})),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{var r,n,o,a,s,c,l,d,h;const y=p.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(!y)return null;const g=i.left+(null!==(r=y.cx)&&void 0!==r?r:null!=y.x&&null!=y.w?y.x+y.w/2:null!==(n=y.x)&&void 0!==n?n:0),f=i.top+(null!==(o=y.cy)&&void 0!==o?o:null!=y.y&&null!=y.h?y.y+y.h/2:null!==(a=y.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(c=e.dy)&&void 0!==c?c:-16,b=null!==(l=e.width)&&void 0!==l?l: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:g+m-b/2,top:f+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}Be.displayName="NetworkSVGOverlay";const ze="undefined"==typeof window||"undefined"==typeof document,He={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Fe(e,t,r){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?r+", empty":`${r}, ${n.join(", ")}`}function Ye({nodes:e,chartType:t}){var r,n,o,i,a;const s=[];for(const t of e){if(s.length>=50)break;s.push({values:{id:(null===(r=t.datum)||void 0===r?void 0:r.id)||t.id||"",x:Math.round(100*(null!==(o=null!==(n=t.cx)&&void 0!==n?n:t.x)&&void 0!==o?o:0))/100+"",y:Math.round(100*(null!==(a=null!==(i=t.cy)&&void 0!==i?i:t.y)&&void 0!==a?a:0))/100+""}})}if(0===s.length)return null;const c=new Set;for(const e of s)for(const t of Object.keys(e.values))c.add(t);const l=Array.from(c);return u.createElement("table",{style:He,role:"table","aria-label":"Data table for "+t},u.createElement("thead",null,u.createElement("tr",null,l.map(e=>u.createElement("th",{key:e},e)))),u.createElement("tbody",null,s.map((e,t)=>u.createElement("tr",{key:t},l.map(t=>{var r;return u.createElement("td",{key:t},null!==(r=e.values[t])&&void 0!==r?r:"")}))),e.length>50&&u.createElement("tr",null,u.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function qe({hoverPoint:e}){let t="";if(e){const r=e.data||e;t="object"==typeof r?"Focused on data point: "+Object.entries(r).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+r}return u.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:He},t)}function Xe(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ge(e,t,r=.3){Xe(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Ve(e,t,r=.6){var n,o,i,a,s;if(!Xe(t))return;const c=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,l=t.r+c*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,l,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*r,e.stroke()}function Ke(e,t){var r,n,o,i,a,s;if(!t.pathD)return;e.save();const c=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,s=t.style.fill;o.addColorStop(0,1===a.from?s:"transparent"),o.addColorStop(1,1===a.to?s:"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(c)}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!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(c)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(c)),e.restore()}function Ze(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 Qe(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 Ue(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 Je={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},et=n.schemeCategory10,tt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],rt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function nt(e,t,r){if("function"==typeof t){const n=t(e);return r&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||rt.has(t)}(n)?r(n):n}const n=e[t];return r?r(n):et[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+""))%et.length]}function ot(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),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=Je[r]||Je.category10;if(o&&"function"==typeof a){let e=-1/0;for(const t of n){const r=Number(t);r>e&&(e=r)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:et;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function it(t){const r=e.createContext(null),n=at(t);return[function({children:n}){const o=e.useMemo(()=>at(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,a=e.useRef(t);a.current=t;const s=e.useCallback(()=>a.current(i.getState()),[i]),c=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,s,c)}]}function at(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)}}}const st={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ct={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[lt,ut]=it(e=>({theme:st,setTheme(t){e(e=>"light"===t?{theme:st}:"dark"===t?{theme:ct}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}})),dt={top:20,right:80,bottom:20,left:80},ht={top:40,right:40,bottom:40,left:40},yt=new Set(["chord","force","circlepack","orbit"]),gt=[800,600],ft={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 pt({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:ft},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 s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let i=c;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:s.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:ft},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!=s.value&&s.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const l=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),d=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:ft},u.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const mt=e.forwardRef(function(t,r){var n,o,i,a,c,l,y,g,f,p,m;const{chartType:v,nodes:b,edges:x,data:k,initialEdges:A,nodeIDAccessor:w="id",sourceAccessor:S="source",targetAccessor:E="target",valueAccessor:L="value",childrenAccessor:D,hierarchySum:O,orientation:j="horizontal",nodeAlign:P="justify",nodePaddingRatio:C=.05,nodeWidth:M=15,iterations:I=300,forceStrength:N=.1,padAngle:T=.01,groupWidth:$=20,sortGroups:_,edgeSort:W,treeOrientation:R="vertical",edgeType:B="curve",padding:z,paddingTop:H,tensionConfig:F,showParticles:Y=!1,particleStyle:q,nodeStyle:X,edgeStyle:G,colorBy:V,colorScheme:K="category10",edgeColorBy:Z="source",edgeOpacity:Q=.5,colorByDepth:U=!1,nodeSize:J=8,nodeSizeRange:ee=[5,20],nodeLabel:te,showLabels:re=!0,labelMode:ne,size:oe=gt,responsiveWidth:ie,responsiveHeight:ae,margin:se,className:ce,background:le,enableHover:ue=!0,tooltipContent:de,customHoverBehavior:he,customClickBehavior:ye,onObservation:ge,chartId:fe,onTopologyChange:pe,annotations:me,svgAnnotationRules:ve,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:Ae,legendHighlightedCategory:we,legendIsolatedCategories:Se,title:Le,foregroundGraphics:De,backgroundGraphics:je,decay:Pe,pulse:Ce,staleness:Me,thresholds:Ie,accessibleTable:Ne,orbitMode:Te,orbitSize:$e,orbitSpeed:_e,orbitRevolution:We,orbitRevolutionStyle:Re,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Je}=t,tt=yt.has(v)?ht:dt,[rt,nt]=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]]]}(oe,ie,ae),ot=Object.assign(Object.assign({},tt),se),it=nt[0]-ot.left-ot.right,at=nt[1]-ot.top-ot.bottom,st="function"==typeof De?De({size:nt,margin:ot}):De,ct=e.useMemo(()=>Object.assign(Object.assign({},d),F),[F]),lt=e.useMemo(()=>Object.assign(Object.assign({},h),q),[q]),ft=e.useMemo(()=>({chartType:v,nodeIDAccessor:w,sourceAccessor:S,targetAccessor:E,valueAccessor:L,childrenAccessor:D,hierarchySum:O,orientation:j,nodeAlign:P,nodePaddingRatio:C,nodeWidth:M,iterations:I,forceStrength:N,padAngle:T,groupWidth:$,sortGroups:_,edgeSort:W,treeOrientation:R,edgeType:B,padding:z,paddingTop:H,tensionConfig:ct,showParticles:Y,particleStyle:lt,nodeStyle:X,edgeStyle:G,nodeLabel:te,showLabels:re,labelMode:ne,colorBy:V,colorScheme:K,edgeColorBy:Z,edgeOpacity:Q,colorByDepth:U,nodeSize:J,nodeSizeRange:ee,decay:Pe,pulse:Ce,staleness:Me,thresholds:Ie,orbitMode:Te,orbitSize:$e,orbitSpeed:_e,orbitRevolution:We,orbitRevolutionStyle:Re,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Je}),[v,w,S,E,L,D,O,j,P,C,M,I,N,T,$,_,W,R,B,z,H,ct,Y,lt,X,G,te,re,ne,V,K,Z,Q,U,J,ee,Pe,Ce,Me,Ie,Te,$e,_e,We,Re,He,Xe,Je]),mt=e.useRef(null),vt=e.useRef(0),bt=e.useRef(0),xt=e.useRef(!0),kt=ut(e=>e.theme),At=e.useRef(()=>{}),wt=e.useRef(null);wt.current||(wt.current=new Ee(ft));const[St,Et]=e.useState(null),[Lt,Dt]=e.useState(0),[Ot,jt]=e.useState(0),[Pt,Ct]=e.useState(!1),Mt=e.useRef(null),It=e.useRef(new Map),Nt=e.useRef(0),Tt=e.useCallback(e=>{if("function"==typeof V)return V(e)+"";if("string"==typeof V&&e.data){const t=e.data[V];if(void 0!==t){if(!It.current.has(t+"")){const e=Array.isArray(K)?K:et;It.current.set(t+"",e[Nt.current++%e.length])}return It.current.get(t+"")}}if(!It.current.has(e.id)){const t=Array.isArray(K)?K:et;It.current.set(e.id,t[Nt.current++%t.length])}return It.current.get(e.id)},[V,K]),$t=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?Tt(r):t?Tt(t):"#999"},[Z,Tt]),_t=e.useCallback(e=>{if(!(null==q?void 0:q.colorBy))return $t(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===lt.colorBy&&r?Tt(r):t?Tt(t):"#999"},[null==q?void 0:q.colorBy,lt.colorBy,Tt,$t]),Wt="sankey"===v&&Y||!!Ce||null!==(o=null===(n=wt.current)||void 0===n?void 0:n.isAnimating)&&void 0!==o&&o,Rt=e.useCallback(()=>{vt.current&&!Wt||vt.current||(vt.current=requestAnimationFrame(()=>At.current()))},[Wt]);e.useEffect(()=>{var e;null===(e=wt.current)||void 0===e||e.updateConfig(ft),xt.current=!0,Rt()},[ft,Rt]),e.useEffect(()=>{xt.current=!0,Rt()},[kt,Rt]);const Bt=e.useCallback(()=>{const e=wt.current;if(!e)return;e.runLayout([it,at]),e.buildScene([it,at]),xt.current=!0;const t=Array.isArray(K)?K:et,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];It.current.has(n.id)||It.current.set(n.id,t[e%t.length])}if(Nt.current=r.length,Dt(e.layoutVersion),pe){const{nodes:t,edges:r}=e.getLayoutData();pe(t,r)}},[it,at,pe,K]),zt=e.useCallback(e=>{const t=wt.current;t&&(t.ingestEdge(e)&&Bt(),Rt())},[Bt,Rt]),Ht=e.useCallback(e=>{const t=wt.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&Bt(),Rt()},[Bt,Rt]),Ft=e.useCallback(()=>{var e;null===(e=wt.current)||void 0===e||e.clear(),It.current.clear(),Nt.current=0,Dt(0),Et(null),Mt.current=null,xt.current=!0,Rt()},[Rt]),Yt=e.useCallback(()=>{const e=wt.current;e&&(e.tension+=999,Bt(),Rt())},[Bt,Rt]);e.useImperativeHandle(r,()=>({push:zt,pushMany:Ht,clear:Ft,getTopology:()=>{var e,t;return null!==(t=null===(e=wt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=wt.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:Yt,getTension:()=>{var e,t;return null!==(t=null===(e=wt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[zt,Ht,Ft,Yt]);const qt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(v),Xt=qt?k||(Array.isArray(x)?void 0:x):void 0;e.useEffect(()=>{const e=wt.current;if(e)if(qt&&Xt)e.ingestHierarchy(Xt,[it,at]),e.buildScene([it,at]),xt.current=!0,Rt();else{const t=b||[],r=Array.isArray(x)?x:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[it,at]),e.buildScene([it,at]);const n=Array.isArray(K)?K:et,o=Array.from(e.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];It.current.has(t.id)||It.current.set(t.id,n[e%n.length])}Nt.current=o.length,xt.current=!0,Rt()}},[b,x,k,Xt,qt,it,at,ft,Rt,K]),e.useEffect(()=>{A&&A.length>0&&Ht(A)},[]);const Gt=e.useCallback(e=>{if(he&&he(e),ge){const t=Date.now();ge(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:fe}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:fe})}},[he,ge,fe]),Vt=e.useCallback(e=>{if(ye&&ye(e),ge){const t=Date.now();ge(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:fe}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:fe})}},[ye,ge,fe]),Kt=e.useRef(()=>{}),Zt=e.useRef(()=>{});Kt.current=e=>{if(!ue)return;const t=mt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ot.left,o=e.clientY-r.top-ot.top;if(0>n||n>it||0>o||o>at)return void(Mt.current&&(Mt.current=null,Et(null),Gt&&(Gt(null),xt.current=!0),Rt()));const i=wt.current;if(!i)return;const a=Oe(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(Mt.current&&(Mt.current=null,Et(null),Gt&&(Gt(null),xt.current=!0),Rt()));const s=a.datum||{},c=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:a.type,data:s,x:a.x,y:a.y});Mt.current=c,Et(c),Gt&&(Gt(c),xt.current=!0),Rt()},Zt.current=()=>{Mt.current&&(Mt.current=null,Et(null),Gt&&(Gt(null),xt.current=!0),Rt())};const Qt=e.useRef(()=>{});Qt.current=e=>{if(!ye&&!ge)return;const t=mt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ot.left,o=e.clientY-r.top-ot.top;if(0>n||n>it||0>o||o>at)return;const i=wt.current;if(!i)return;const a=Oe(i.sceneNodes,i.sceneEdges,n,o);if(a){const e=a.datum||{};Vt(Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{type:a.type,data:e,x:a.x,y:a.y}))}else Vt(null)},e.useCallback(e=>Kt.current(e),[]);const Ut=e.useCallback(()=>Zt.current(),[]),Jt=e.useCallback(e=>Qt.current(e),[]),er=e.useRef(-1),tr=e.useCallback(e=>{const t=wt.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=er.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 er.current=-1,Mt.current=null,Et(null),Gt&&(Gt(null),xt.current=!0),void Rt();const i=0>n?0:o;er.current=i;const a=r[i],s=a.datum||{},c=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:"node",data:s,x:a.x,y:a.y});Mt.current=c,Et(c),Gt&&(Gt(c),xt.current=!0),Rt()},[Gt,Rt]),rr=e.useCallback(e=>{er.current=-1,Kt.current(e)},[]);At.current=()=>{var e,t,r,n,o,i,a;vt.current=0;const s=mt.current;if(!s)return;const c=s.getContext("2d");if(!c)return;const l=wt.current;if(!l)return;const u=performance.now(),d=bt.current?Math.min((u-bt.current)/1e3,.1):.016;bt.current=u;const y=l.advanceTransition(u),g=l.tickAnimation([it,at],d);(y||xt.current||g)&&l.buildScene([it,at]);const f="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,r,n){const o=e.getContext("2d");if(!o)return null;const i=t[0]*n,a=t[1]*n,s=t[0]+"px",c=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==c&&(e.style.height=c),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(n,0,0,n,0,0),o.translate(r.left,r.top),o}(s,nt,ot,f))return;c.clearRect(-ot.left,-ot.top,nt[0],nt[1]),le&&(c.fillStyle=le,c.fillRect(0,0,it,at)),Pe&&l.applyDecay(),Ce&&l.applyPulse(u),Ie&&l.applyThresholds(u),l.applyTopologyDiff(u);const p=null!==(e=null==Me?void 0:Me.threshold)&&void 0!==e?e:5e3,m=Me&&l.lastIngestTime>0&&u-l.lastIngestTime>p;if(m&&(c.globalAlpha=null!==(t=null==Me?void 0:Me.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Ke(e,r);break;case"line":Ze(e,r);break;case"ribbon":Qe(e,r);break;case"curved":Ue(e,r)}}(c,l.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)),Ge(e,t),e.restore())}}(c,l.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=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()),Ve(e,t),e.restore())}}(c,l.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()}}(c,l.sceneNodes),Y&&l.particlePool&&!m){const e=Array.from(l.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,s=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)>=s)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),c=Math.floor(i),l=i-c;let u=c;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<s;t++)e.spawn(n)}}(l.particlePool,e,d,lt);const t=.5*(null!==(r=lt.speedMultiplier)&&void 0!==r?r:1);let n;if(lt.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)}l.particlePool.step(d,t,e,n),function(e,t,r,n,o){var i,a;const s=null!==(i=n.radius)&&void 0!==i?i:h.radius,c=null!==(a=n.opacity)&&void 0!==a?a:h.opacity;e.globalAlpha=c;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const c=r[a.edgeIndex];if(c){if("function"==typeof n.color){const t="object"==typeof c.source?c.source:null;e.fillStyle=t?n.color(c,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(c);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(c,l.particlePool,e,lt,_t)}}m&&(c.globalAlpha=1);const v=xt.current;if(xt.current=!1,v||y||g){const e=mt.current;e&&e.setAttribute("aria-label",Fe(null!==(o=null===(n=l.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=l.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(v||y||g)&&jt(e=>e+1),(Wt||y||g||l.hasActivePulses||l.hasActiveThresholds||l.hasActiveTopologyDiff)&&(vt.current=requestAnimationFrame(()=>At.current()))},e.useEffect(()=>(Rt(),()=>{vt.current&&(cancelAnimationFrame(vt.current),vt.current=0)}),[Rt]),e.useEffect(()=>{xt.current=!0,Rt()},[v,it,at,le,Rt]),function(t,r,n,o,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=r.current;if(!s||0===s.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=c-s.lastIngestTime>l;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}(Me,wt,xt,Rt,Pt,Ct);const nr=ue&&St?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ot.left+St.x,top:ot.top+St.y,transform:`translate(${St.x>.6*it?"calc(-100% - 12px)":"12px"}, ${.3*at>St.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},de?de(St):u.createElement(pt,{data:St})):null;if(ze){const e=wt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(v),r=t?k||(Array.isArray(x)?void 0:x):void 0;if(t&&r)e.ingestHierarchy(r,[it,at]),e.buildScene([it,at]);else{const t=b||[],r=Array.isArray(x)?x:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[it,at]),e.buildScene([it,at]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],r=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],n=null!==(c=null==e?void 0:e.labels)&&void 0!==c?c:[];return u.createElement("div",{className:"stream-network-frame"+(ce?" "+ce:""),role:"img","aria-label":"string"==typeof Le?Le:"Network chart",style:{position:"relative",width:nt[0],height:nt[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:nt[0],height:nt[1],style:{position:"absolute",left:0,top:0}},je&&u.createElement("g",{transform:`translate(${ot.left},${ot.top})`},je),u.createElement("g",{transform:`translate(${ot.left},${ot.top})`},le&&u.createElement("rect",{x:0,y:0,width:it,height:at,fill:le}),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=s.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),n.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(Be,{width:it,height:at,totalWidth:nt[0],totalHeight:nt[1],margin:ot,labels:n,sceneNodes:t,title:Le,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:Ae,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:st,annotations:me,svgAnnotationRules:ve,annotationFrame:0}))}const or=wt.current;return u.createElement("div",{ref:rt,className:"stream-network-frame"+(ce?" "+ce:""),role:"img","aria-label":"string"==typeof Le?Le:"Network chart",tabIndex:0,style:{position:"relative",width:ie?"100%":nt[0],height:ae?"100%":nt[1],overflow:"visible"},onMouseMove:ue?rr:void 0,onMouseLeave:ue?Ut:void 0,onClick:ye||ge?Jt:void 0,onKeyDown:tr},je&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:nt[0],height:nt[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${ot.left},${ot.top})`},je)),u.createElement("canvas",{ref:mt,"aria-label":Fe(null!==(y=null===(l=null==or?void 0:or.sceneNodes)||void 0===l?void 0:l.length)&&void 0!==y?y:0,null!==(f=null===(g=null==or?void 0:or.sceneEdges)||void 0===g?void 0:g.length)&&void 0!==f?f:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),u.createElement(qe,{hoverPoint:St}),Ne&&u.createElement(Ye,{nodes:null!==(p=null==or?void 0:or.sceneNodes)&&void 0!==p?p:[],edges:null!==(m=null==or?void 0:or.sceneEdges)&&void 0!==m?m:[],chartType:"Network chart"}),u.createElement(Be,{width:it,height:at,totalWidth:nt[0],totalHeight:nt[1],margin:ot,labels:(null==or?void 0:or.labels)||[],sceneNodes:null==or?void 0:or.sceneNodes,title:Le,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:Ae,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:st,annotations:me,svgAnnotationRules:ve,annotationFrame:Ot}),nr,(null==Me?void 0:Me.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Me.badgePosition?{top:4,left:4}:"bottom-left"===Me.badgePosition?{bottom:4,left:4}:"bottom-right"===Me.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Pt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Pt?"STALE":"LIVE"))});mt.displayName="StreamNetworkFrame";const vt={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 bt(e,t){return"function"==typeof t?t(e):e[t]}function xt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":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 kt(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 s=[];if(r){const t=bt(e,r);a=xt(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=bt(e,o);s.push({label:r,value:xt(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=xt(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=xt(e[t[0]],n))}}const c=Object.assign(Object.assign({},vt),o);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:c},a&&u.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.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 At(e){if(!0===e)return kt();if("function"==typeof e){const t=e;return e=>{const r=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==r?null:u.createElement("div",{className:"semiotic-tooltip",style:vt},r)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?kt(e):kt())}const wt=e.createContext(null);function St(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 Et(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Lt,Dt]=it(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Et(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=Et(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}})}})),[Ot,jt]=it(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 Pt(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=Dt(e=>e.selections.get(o)),a=Dt(e=>e.setClause),s=Dt(e=>e.clearClause),c=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(St(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:c,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(()=>{s(o,n)},[s,o,n]),clientId:n}}const Ct=e.createContext(!1),Mt="#007bff";function It(t,r,n="category10"){const o=e.useContext(wt);return e.useMemo(()=>{if(r){if(0===t.length)return o&&Object.keys(o).length>0?e=>o[e]||"#999":void 0;if("function"==typeof r){const e=Array.from(new Set(t.map(e=>r(e)+"")));return o&&Object.keys(o).length>0?e=>o[e]||"#999":ot(e.map(e=>({_cat:e})),"_cat",n)}if(o&&Object.keys(o).length>0){const e=ot(t,r,n);return t=>o[t]||e(t)}return ot(t,r,n)}},[t,r,n,o])}function Nt({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s}){const c=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=Pt({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:s}=Pt({name:r});return{onHover:e.useCallback(e=>{if(!e)return void s();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,s,r]),predicate:o,isActive:i}}({name:(null==c?void 0:c.name)||"hover",fields:(null==c?void 0:c.fields)||n||[]}),d=jt(e=>e.pushObservation),h=t?{isActive:l.isActive,predicate:l.predicate}:null,y=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:s};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,s,d]),g=e.useCallback(e=>{var t,r;if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};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,s]);return{activeSelectionHook:h,customHoverBehavior:y,customClickBehavior:g}}function Tt(t,r,n){const[o,i]=e.useState(null),[a,s]=e.useState(new Set),c=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),l=e.useCallback(e=>{"isolate"===t&&s(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:c,onLegendClick:l,legendSelectionHook:u}}const $t={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 _t(e,t,r){var n,o,i,a,s,c;const l=$t[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!==(i=t.showGrid)&&void 0!==i?i:l.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||l.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:l.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c: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 Wt({componentName:e,message:t,diagnosticHint:r,width:n,height:o}){return u.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,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),r&&u.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},r)))}class Rt 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(Wt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Bt(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 zt(e,t,r=3){let n,o=r+1;for(const r of t){const t=Bt(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}function Ht(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ft(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=zt(e,t,3))&&void 0!==r?r:null)}function Yt({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 qt({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;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=Ht(t).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=Ft(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const Xt={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"}},Gt={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Vt={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},Kt=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Zt=["vertical","horizontal"],Qt={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Kt},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Kt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Kt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Gt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Xt),Vt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Zt},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Xt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Xt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Xt),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Xt),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Zt},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Xt),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xt),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xt),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xt),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Xt),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function Ut(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Jt=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),er=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),tr=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),rr=new Set(["LineChart","AreaChart","StackedAreaChart"]),nr=new Set(["BarChart","StackedBarChart","GroupedBarChart"]);function or(e,t){const r=[],n=function(e,t){const r=[],n=Qt[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Qt).join(", ")}`]};for(const o of n.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);for(const[e,o]of Object.entries(t)){if(null==o)continue;const t=n.props[e];if(t){if(!Ut(o,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${n}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const o=Object.keys(n.props),i=new Set(o);for(const n of Object.keys(t))if(void 0!==t[n]&&!i.has(n)){const t=zt(n,o),i=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(i)}if("array"===n.dataShape){const o=t.data,i={};for(const e of n.dataAccessors){const r=t[e];"string"==typeof r&&(i[e]=r)}const a=function({componentName:e,data:t,accessors:r,requiredProps:n}){if(n)for(const[t,r]of Object.entries(n))if(null==r)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(r){const n=Ht(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in n)){const r=Ft(i,t),n=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}({componentName:e,data:o,accessors:Object.keys(i).length>0?i:void 0});a&&r.push(a)}else if("object"===n.dataShape){const n=Yt({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const o=qt({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});o&&r.push(o)}return{valid:0===r.length,errors:r}}(e,t);for(const e of n.errors)r.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Qt[e]?(function(e,t,r){const n=Qt[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,r),function(e,t,r){const n=t.width,o=t.height;if(void 0===n||"number"==typeof n&&n>0||r.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===o||"number"==typeof o&&o>0||r.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&r.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,r),function(e,t,r){const n=Qt[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in i||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,r),function(e,t,r){Jt.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,r),function(e,t,r){er.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,r),function(e,t,r){const n=Qt[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,r),function(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,r),function(e,t,r){var n;if(!tr.has(e))return;const o=t.rExtent||t.yExtent;o&&Array.isArray(o)&&o.length>=1&&null!=o[0]&&0!==o[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${o[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(n=o[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,r),function(e,t,r){if(!rr.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=t.yAccessor||"y";"string"==typeof o&&n.some(e=>{const t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,r),function(e,t,r){var n,o;const i=null!==(n=t.width)&&void 0!==n?n:600,a=null!==(o=t.height)&&void 0!==o?o:400,s=t.margin;if(!s||"object"!=typeof s)return;const c=(s.left||0)+(s.right||0),l=(s.top||0)+(s.bottom||0);i>c||r.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${c}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>l||r.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${l}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,r),function(e,t,r){var n;const o=Qt[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let r=0;s>r;r++){const o=null===(n=i[r])||void 0===n?void 0:n[e.name];if("number"==typeof o&&Number.isFinite(o)){t=!1;break}}t&&r.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,r),function(e,t,r){if(!nr.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,r),function(e,t,r){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const o=n.bottom;"number"==typeof o&&70>o&&r.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${o}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,r),function(e,t,r){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const o=t.margin;if(!o||"object"!=typeof o)return;const i=o.right;"number"==typeof i&&100>i&&r.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,r),function(e,t,r){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=n[0];if(o&&"object"==typeof o)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const i=o[n];"string"==typeof i&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,r),{ok:r.every(e=>"warning"===e.severity),diagnoses:r}):{ok:0===r.length,diagnoses:r}}var ir;const ar="undefined"!=typeof process&&"production"!==(null===(ir=process.env)||void 0===ir?void 0:ir.NODE_ENV);function sr({componentName:e,width:t,height:r,chartProps:n,children:o}){return u.createElement(Rt,{fallback:o=>{let i="";if(ar&&n)try{const t=or(e,n);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return u.createElement(Wt,{componentName:e,message:o.message,diagnosticHint:i,width:t,height:r})}},o)}const cr={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"},lr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ur(e,t,r,n){return!1===n||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?u.createElement("div",{style:Object.assign(Object.assign({},cr),{width:t,height:r})},n||"No data available"):null}function dr(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({},lr),{position:"absolute",top:a+r*(o+i),left:Math.floor(.1*t),width:30+(37*r+13)%50+"%",height:o,opacity:.5+r%2*.2})})))}const hr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=_t(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:a,edges:s,margin:c,className:l,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:y="target",nodeLabel:g,colorBy:f,colorScheme:p="category10",nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:A=300,forceStrength:w=.1,tooltip:S,frameProps:E={},onObservation:L,chartId:D,selection:O,linkedHover:j,loading:P,emptyContent:C,legendInteraction:M,legendPosition:I}=t,N=i.width,T=i.height,$=i.enableHover,_=i.showLegend,W=null!==(n=i.showLabels)&&void 0!==n&&n,R=i.title,B=dr(P,N,T);if(B)return B;const z=ur(a,N,T,C);if(z)return z;const H=a||[],F=s||[],Y=It(H,f,p),q=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of H){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[H,f]),X=Tt(M,f,q),G=e.useMemo(()=>e=>{const t={};return t.fill=f?nt(e.data||e,f,Y):Mt,"number"==typeof m&&(t.r=m),t},[f,Y,m]),V=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),K=e.useMemo(()=>{if(W&&g)return"function"==typeof g?g:e=>{var t,r,n;return null!==(n=null!==(r=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==r?r:e[g])&&void 0!==n?n:e.id}},[W,g]),{legend:Z,margin:Q,legendPosition:U}=function({data:t,colorBy:r,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40}}){const c=e.useContext(Ct),l=void 0!==o?o:!c&&!!r,u=e.useMemo(()=>{if(l&&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=e.color||"#333",r={fill:t,stroke:t};return void 0!==o&&(r.stroke=o),void 0!==i&&(r.strokeWidth=i),r},type:"fill",items:a,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:nt})},[l,r,t,n]),d=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),a);return u&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[s,a,u,i]);return{legend:u,margin:d,legendPosition:i}}({data:H,colorBy:f,colorScale:Y,showLegend:_,legendPosition:I,userMargin:c,defaults:i.marginDefaults}),{customHoverBehavior:J}=Nt({selection:O,linkedHover:j,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,chartType:"ForceDirectedGraph",chartId:D}),ee=qt({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ee?u.createElement(Wt,{componentName:"ForceDirectedGraph",message:ee,width:N,height:T}):u.createElement(sr,{componentName:"ForceDirectedGraph",width:N,height:T},u.createElement(mt,Object.assign({ref:o,chartType:"force"},null!=a&&{nodes:H},null!=s&&{edges:F},{size:[N,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:y,iterations:A,forceStrength:w,nodeStyle:G,edgeStyle:V,colorBy:f,colorScheme:p,nodeSize:m,nodeSizeRange:v,nodeLabel:K,showLabels:W,enableHover:$,tooltipContent:!1===S?()=>null:At(S)||void 0,customHoverBehavior:j||L?J:void 0,legend:Z,legendPosition:U},M&&"none"!==M&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:l,title:R},E)))});function yr(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 gr(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 fr(e){return"function"==typeof e?e:t=>t[e]||1}function pr({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:o},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=nt(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=nt(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}hr.displayName="ForceDirectedGraph";const mr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:a,edges:s,margin:c,className:l,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p="category10",edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:A,edgeOpacity:w=.5,edgeSort:S,tooltip:E,frameProps:L={},onObservation:D,chartId:O,selection:j,linkedHover:P,loading:C,emptyContent:M,legendInteraction:I}=t,N=i.width,T=i.height,$=i.enableHover,_=null===(n=i.showLabels)||void 0===n||n,W=i.title,R=dr(C,N,T);if(R)return R;const B=ur(s,N,T,M);if(B)return B;const z=s||[],H=e.useMemo(()=>gr(a,z,d,h),[a,z,d,h]),F=It(H,f,p),Y=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of H){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[H,f]),q=Tt(I,f,Y),X=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?nt(e.data||e,f,F):"#4d430c",t},[f,F]),G=e.useMemo(()=>pr({edgeColorBy:m,colorBy:f,colorScale:F,nodeStyleFn:X,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,F,X,w]),V=e.useMemo(()=>{if(!_)return;const e=A||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[_,A,g]),K=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:Z,customClickBehavior:Q}=Nt({selection:j,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:D,chartType:"SankeyDiagram",chartId:O}),U=qt({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return U?u.createElement(Wt,{componentName:"SankeyDiagram",message:U,width:N,height:T}):u.createElement(sr,{componentName:"SankeyDiagram",width:N,height:T},u.createElement(mt,Object.assign({ref:o,chartType:"sankey"},H.length>0&&{nodes:H},null!=s&&{edges:z},{size:[N,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:X,edgeStyle:G,colorBy:f,colorScheme:p,edgeColorBy:m,edgeOpacity:w,edgeSort:S,nodeLabel:V,showLabels:_,enableHover:$,tooltipContent:!1===E?()=>null:At(E)||void 0,customHoverBehavior:P||D?Z:void 0,customClickBehavior:D?Q:void 0},I&&"none"!==I&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories},{className:l,title:W},L)))});mr.displayName="SankeyDiagram";const vr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:s,margin:c,className:l,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p="category10",edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:A=.5,tooltip:w,frameProps:S={},onObservation:E,chartId:L,selection:D,linkedHover:O,loading:j,emptyContent:P,legendInteraction:C}=t,M=i.width,I=i.height,N=i.enableHover,T=null===(n=i.showLabels)||void 0===n||n,$=i.title,_=dr(j,M,I);if(_)return _;const W=ur(s,M,I,P);if(W)return W;const R=s||[],B=e.useMemo(()=>gr(a,R,d,h),[a,R,d,h]),z=It(B,f,p),H=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]),F=Tt(C,f,H),Y=B.length>0,q=e.useMemo(()=>{if(Y)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=nt(e.data||e,f,z);else{const i=Array.isArray(p)?p:Je[p]||et,a=Array.isArray(i)?i:et,s=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[s%a.length]}return o}},[Y,f,z,p]),X=e.useMemo(()=>{if(Y)return pr({edgeColorBy:m,colorBy:f,colorScale:z,nodeStyleFn:q||(e=>({fill:Mt})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[Y,m,f,z,q,A]),G=e.useMemo(()=>{if(!T)return;const e=k||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[T,k,g]),V=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:K}=Nt({selection:D,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ChordDiagram",chartId:L}),Z=qt({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return Z?u.createElement(Wt,{componentName:"ChordDiagram",message:Z,width:M,height:I}):u.createElement(sr,{componentName:"ChordDiagram",width:M,height:I},u.createElement(mt,Object.assign({ref:o,chartType:"chord"},B.length>0&&{nodes:B},null!=s&&{edges:R},{size:[M,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:q,edgeStyle:X,colorBy:f,colorScheme:p,edgeColorBy:m,edgeOpacity:A,nodeLabel:G,showLabels:T,enableHover:N,tooltipContent:!1===w?()=>null:At(w)||void 0,customHoverBehavior:O||E?K:void 0},C&&"none"!==C&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:l,title:$},S)))});function br(t){var r;const n=_t(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:s="tree",orientation:c="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:y,colorScheme:g="category10",colorByDepth:f=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,chartId:A,selection:w,linkedHover:S,loading:E,legendInteraction:L}=t,D=n.width,O=n.height,j=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,C=n.title,M=dr(E,D,O);if(M)return M;const I=e.useMemo(()=>yr(null!=o?o:null,l),[o,l]),N=It(I,f?void 0:y,g),T=e.useMemo(()=>{if(!y||f)return[];const e=new Set;for(const t of I){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[I,y,f]),$=Tt(L,f?void 0:y,T),_=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?tt[(e.depth||0)%tt.length]:y?nt(e.data||e,y,N):Mt,t},[y,f,N]),W=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),R=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return fr(d)},[s,d]),B=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:z}=Nt({selection:w,linkedHover:S,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:A}),H=Yt({componentName:"TreeDiagram",data:o});return H?u.createElement(Wt,{componentName:"TreeDiagram",message:H,width:D,height:O}):u.createElement(sr,{componentName:"TreeDiagram",width:D,height:O},u.createElement(mt,Object.assign({chartType:s},null!=o&&{data:o},{size:[D,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:R,treeOrientation:c,edgeType:p,nodeStyle:_,edgeStyle:W,colorBy:y,colorScheme:g,colorByDepth:f,nodeSize:v,nodeLabel:P?m||h:void 0,showLabels:P,enableHover:j,tooltipContent:!1===b?()=>null:At(b)||void 0,customHoverBehavior:S||k?z:void 0},L&&"none"!==L&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories},{className:a,title:C},x)))}function xr(t){var r;const n=_t(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:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:f,padding:p=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:A,chartId:w,loading:S,legendInteraction:E}=t,L=n.width,D=n.height,O=n.enableHover,j=null===(r=n.showLabels)||void 0===r||r,P=n.title,C=dr(S,L,D);if(C)return C;const{activeSelectionHook:M,customHoverBehavior:I}=Nt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:A,chartType:"Treemap",chartId:w}),N=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(()=>yr(null!=o?o:null,s),[o,s]),$=It(T,y?void 0:d,h),_=e.useMemo(()=>{if(!d||y)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,y]),W=Tt(E,y?void 0:d,_),R=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?tt[(e.depth||0)%tt.length]:d?nt(e.data||e,d,$):Mt,t},[d,y,$]),B=e.useMemo(()=>M?e=>{var t;const r=Object.assign({},R(e));if(M.isActive)if(M.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,M,x]),z=e.useMemo(()=>fr(c),[c]),H=void 0!==m?m:j&&"parent"===g?18:void 0,F=Object.assign(Object.assign({},n.marginDefaults),i),Y=Yt({componentName:"Treemap",data:o});return Y?u.createElement(Wt,{componentName:"Treemap",message:Y,width:L,height:D}):u.createElement(sr,{componentName:"Treemap",width:L,height:D},u.createElement(mt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[L,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:z,padding:p,paddingTop:H,nodeStyle:B,colorBy:d,colorScheme:h,colorByDepth:y,nodeLabel:j?f||l:void 0,showLabels:j,labelMode:g,enableHover:O,tooltipContent:!1===v?()=>null:At(v)||void 0},(k||A)&&{customHoverBehavior:N},E&&"none"!==E&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:P},b)))}function kr(t){var r;const n=_t(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:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:y=!1,nodeLabel:g,circleOpacity:f=.7,padding:p=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:k,linkedHover:A,loading:w,legendInteraction:S}=t,E=n.width,L=n.height,D=n.enableHover,O=null===(r=n.showLabels)||void 0===r||r,j=n.title,P=dr(w,E,L);if(P)return P;const C=e.useMemo(()=>yr(null!=o?o:null,s),[o,s]),M=It(C,y?void 0:d,h),I=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of C){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[C,d,y]),N=Tt(S,y?void 0:d,I),T=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=y?tt[(e.depth||0)%tt.length]:d?nt(e.data||e,d,M):Mt,t},[d,y,M,f]),$=e.useMemo(()=>fr(c),[c]),_=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:W}=Nt({selection:k,linkedHover:A,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),R=Yt({componentName:"CirclePack",data:o});return R?u.createElement(Wt,{componentName:"CirclePack",message:R,width:E,height:L}):u.createElement(sr,{componentName:"CirclePack",width:E,height:L},u.createElement(mt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[E,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:$,padding:p,nodeStyle:T,colorBy:d,colorScheme:h,colorByDepth:y,nodeLabel:O?g||l:void 0,showLabels:O,enableHover:D,tooltipContent:!1===m?()=>null:At(m)||void 0,customHoverBehavior:A||b?W:void 0},S&&"none"!==S&&{legendHoverBehavior:N.onLegendHover,legendClickBehavior:N.onLegendClick,legendHighlightedCategory:N.highlightedCategory,legendIsolatedCategories:N.isolatedCategories},{className:a,title:j},v)))}vr.displayName="ChordDiagram",br.displayName="TreeDiagram",xr.displayName="Treemap",kr.displayName="CirclePack";const Ar=tt;function wr(t){const r=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:n,margin:o,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:l="category10",colorByDepth:d=!1,orbitMode:h="flat",orbitSize:y=2.95,speed:g=.25,revolution:f,revolutionStyle:p,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:A,foregroundGraphics:w,annotations:S,frameProps:E={},onObservation:L,chartId:D,selection:O,linkedHover:j,loading:P}=t,C=r.width,M=r.height,I=r.enableHover,N=r.title,T=dr(P,C,M);if(T)return T;const $=It(e.useMemo(()=>yr(n,a),[n,a]),d?void 0:c,l),_=e.useMemo(()=>{if(Array.isArray(l))return l;const e=Je[l];return Array.isArray(e)?e:et},[l]),W=e.useMemo(()=>e=>{var t;const r={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return r.fill=d?n?_[0]:Ar[(e.depth||0)%Ar.length]:c?nt(e.data||e,c,$):Mt,r.opacity=n?1:.85,r},[c,d,$,_]),R=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),B=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:z}=Nt({selection:O,linkedHover:j,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:L,chartType:"OrbitDiagram",chartId:D}),H=e.useMemo(()=>{if(z)return e=>{z(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[z]),F=Yt({componentName:"OrbitDiagram",data:n});return F?u.createElement(Wt,{componentName:"OrbitDiagram",message:F,width:C,height:M}):u.createElement(sr,{componentName:"OrbitDiagram",width:C,height:M},u.createElement(mt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[C,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:W,edgeStyle:R,colorBy:c,colorScheme:l,colorByDepth:d,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&I,tooltipContent:k?void 0:!1===A?()=>null:At(A)||void 0,customHoverBehavior:j||L?H:void 0,foregroundGraphics:w,annotations:S,className:i,title:N,orbitMode:h,orbitSize:y,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:p,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k},E)))}wr.displayName="OrbitDiagram",exports.ChordDiagram=vr,exports.CirclePack=kr,exports.ForceDirectedGraph=hr,exports.OrbitDiagram=wr,exports.SankeyDiagram=mr,exports.StreamNetworkFrame=mt,exports.TreeDiagram=br,exports.Treemap=xr;
|
|
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"),s=require("d3-shape"),c=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 y{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 s=r[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const c=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*c*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const l=g(s.bezier,a.t,a.offset);a.x=l.x,a.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 g(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),s=i-a,[c,l,u,d]=e[a],h=f(c,l,u,d,s),y=d.x-c.x,g=d.y-c.y,p=Math.sqrt(y*y+g*g);if(p>.001){const e=y/p;h.x+=-g/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,s=f(n,o,i,a,t),c=a.x-n.x,l=a.y-n.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;s.x+=-l/u*r*e.halfWidth*2,s.y+=t*r*e.halfWidth*2}return s}function f(e,t,r,n,o){const i=1-o,a=i*i,s=a*i,c=o*o,l=c*o;return{x:s*e.x+3*a*o*t.x+3*i*c*r.x+l*n.x,y:s*e.y+3*a*o*t.y+3*i*c*r.y+l*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function m(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,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),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var g=i[t];y.length>g;++g){var f=y[g];if(0>r[f]){r[f]=n[f]=u,o[f]=!0,u+=1,c.push(f),l.push(f);break}o[f]&&(n[t]=0|Math.min(n[t],n[f])),0>a[f]||s[t].push(a[f])}i[t]=g}else{if(n[t]===r[t]){var p=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var b=c[g];if(o[b]=!1,p.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){c.length=g;break}}d.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var g=h[c];if(0!==g.length){g.sort(function(e,t){return e-t}),l=[g[0]];for(var f=1;g.length>f;f++)g[f]!==g[f-1]&&l.push(g[f]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],r=a);var c=o[r];if(!c)return!1;var l=e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})});return{leastVertex:i,adjList:l}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var g=0;s.length>g;g++)for(var f=0;s[g].length>f;f++){var p=s[g][f];i[+p]=!1,a[p]={}}l(r),r+=1}else r=h}return n}function v(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 A(e,t){var r=S(e),n=k(t)/Math.tan(r);return"up"==v(e)?e.y1-n:e.y1+n}function w(e,t){var r=S(e),n=k(t)/Math.tan(r);return"up"==v(e)?e.y1+n:e.y1-n}function S(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function E(e,t){return t(e)}function L(e){return D(e.source)}function O(e){return D(e.target)}function D(e){return(e.y0+e.y1)/2}function j(e){return e.virtual?0:e.value}function C(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 P(e){return e.target.depth}function M(e,t){return e.sourceLinks.length?e.depth:t-1}function I(e,t){return e.y0-t.y0}function N(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 W(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 B(e,t){return z(e)==z(t)?"bottom"==e.circularLinkType?N(e,t):I(e,t):z(t)-z(e)}function z(e){return e.target.column-e.source.column}function H(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 s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var c=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=a.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),q(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),q(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,s=e.circularLinkType,l=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});l.sort("bottom"==e.circularLinkType?N:I);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=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?_:T),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(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=c-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 q(e,t,r){e.sort(B);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 s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&X(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function X(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function G(e){return function(){return e}}function V(e){return e.index}function K(e){return e.nodes}function Z(e){return e.links}function U(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,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?r.idx-n.idx:1:-1:o-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?C(t,n)-C(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==C(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 Q(e,t,n,o,i,a){var s=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 c=1,l=a;l>0;--l)u(c*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var c;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&C(i,n)>0){var l=r.mean(i.sourceLinks,O),u=r.mean(i.targetLinks,L),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-D(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)c=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+c;else{var y=r.mean(i.sourceLinks,O),g=r.mean(i.targetLinks,L),f=((y&&g?(y+g)/2:y||g)-D(i))*t;i.y0+=f,i.y1+=f}})})}function d(){s.forEach(function(r){var n,a,s,c=e.y0,l=r.length;for(r.sort(t||R),s=0;l>s;++s)(a=c-(n=r[s]).y0)>0&&(n.y0+=a,n.y1+=a),c=n.y1+o;if((a=c-o-e.y1)>0)for(c=n.y0-=a,n.y1-=a,s=l-2;s>=0;--s)(a=(n=r[s]).y1+i-c)>0&&(n.y0-=a,n.y1-=a),c=n.y0})}}function J(e){e.nodes.forEach(function(e){e.sourceLinks.sort(W),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,s=null,c=V,l=M,u=void 0,d=32,h=2,y=K,g=Z;function f(){var f={nodes:y.apply(null,arguments),links:g.apply(null,arguments)};return function(y){y.x0=e,y.y0=t,y.x1=n,y.y1=o,y.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)})}(y,c),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=m(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(y,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){E(e,t)!=E(o.source,t)&&E(e,t)!=E(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))})}(y,c),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,j),r.sum(e.targetLinks,j)),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)})})}(y),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(y,u,l);var g=a;if(null!==s){var f=r.groups(y.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),v=r.max(f,function(e){return e.length});v>1&&(g=Math.max(1,(o-t)*s/(v-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})})(y,g,i),U(y,u,c),Q(y,u,c,g,g,d),J(y),Y(y,c,h,10,8),U(y,u,c),Q(y,u,c,g,g,d),J(y),Y(y,c,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 E(r.source,t)==E(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(!H(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=A(t,e);return e.y1-r}if(t.target.column>e.target.column)return A(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}})})}(y,c),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return E(r.target,t)==E(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(!H(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=w(t,e);return e.y0-r}if(t.source.column>e.source.column)return w(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}})})}(y,c),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}),s=r.max(t,function(e){return e.y1}),c=(e.y1-e.y0)/(s-a);function l(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>c?(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*c})):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})})}}(y),Y(y,c,h,10,8)}(f),f}return f.update=function(e){return J(e),Y(e,c,h,10,8),e},f.nodeWidth=function(e){return arguments.length?(i=+e,f):i},f.nodePadding=function(e){return arguments.length?(a=+e,f):a},f.nodePaddingRatio=function(e){return arguments.length?(s=+e,f):s},f.nodes=function(e){return arguments.length?(y="function"==typeof e?e:G(e),f):y},f.links=function(e){return arguments.length?(g="function"==typeof e?e:G(e),f):g},f.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:G(e),f):c},f.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:G(e),f):l},f.nodeSort=function(e){return arguments.length?(u=e,f):u},f.iterations=function(e){return arguments.length?(d=+e,f):d},f.circularLinkGap=function(e){return arguments.length?(h=+e,f):h},f.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],f):[[e,t],[n,o]]},f.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],f):[n-e,o-t]},f}const te=e=>{let r,n,o,i,a,s,c,l,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.x1,s=e.target.x0,c=t.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${r},${a}C${r},${l} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${l} ${i},${a}Z`):(r=e.source.x1,n=e.target.x0,c=t.interpolateNumber(r,n),o=c(.5),i=c(.5),a=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${a}C${o},${a} ${i},${s} ${n},${s}L${n},${l}C${i},${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,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+s},${n-r}L${t+s},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-c},${a-r}L${i-c},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,s=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,y=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${l},${a-h*r}L${l+n},${a-h*r+h*y}L${l+n},${d+h*n-h*y}L${l+n-y},${d+h*n}L${u-n+y},${d+h*n}L${u-n},${d+h*n-h*y}L${u-n},${c-h*r+h*y}L${u-n+y},${c-h*r}L${s},${c-h*r}L${s},${c+h*r}L${u+n},${c+h*r}L${u+n},${d-h*n}L${l-n},${d-h*n}L${l-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(P))-1:0},justify:M},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,s,c,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",y=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,f=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=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 v;v="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(v).links(m).nodes(p).nodeAlign(ne[h]||M).nodeId(e=>e.id).nodeWidth(y).iterations(f);b.nodePaddingRatio&&b.nodePaddingRatio(g),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 m){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(c=null!==(s=n._circularWidth)&&void 0!==s?s:n.width)&&void 0!==c?c: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 m)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(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){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(e._edgeKey?e._edgeKey:`${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,s,c;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,y=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,f=new Map;e.forEach((e,t)=>{f.set(e.id,g[t%g.length])});const p=[],m=[],v=[],b=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},o={fill:n.fill||f.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};b.set(t.id,("string"==typeof o.fill?o.fill:null)||f.get(t.id)||"#4d430c"),p.push("down"===l?{type:"rect",x:t.y0,y:t.x0,w:r,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const x=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of x){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";n="function"==typeof y?y(e)||n:"target"===y?b.get(r.id)||f.get(r.id)||n:b.get(t.id)||f.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))),c=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=o.fill||n;m.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:l,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}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-c},${t.targetY-r}L${t.targetX-c},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-c,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?re(e):te(e),!i)continue;const l={fill:o.fill||n,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:l,datum:e})}if(!1!==r.showLabels){const t=(k=r.nodeLabel)?"function"==typeof k?k:e=>e[k]||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,s,c;"down"===l?(a=r.y0+(r.y1-r.y0)/2,s=r.x1+14,c="middle"):(o[0]/2>r.x0+e/2?(a=r.x0-6,c="end"):(a=r.x1+6,c="start"),s=r.y0+n/2),v.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},ie={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,c=n[0]/2,l=n[1]/2,u=r.__previousPositions;let d=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=null==u?void 0:u.get(t.id);e?d++:r?(t.x=r.x,t.y=r.y,d++):h.push(t)}const y=d>0&&.3>=(e.length>0?h.length/e.length:1);if(y){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of h){const n=ae(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=se(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=se(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=c+n*Math.cos(r),e.y=l+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=c+e*Math.cos(o),n.y=l+e*Math.sin(o)}}}const g=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=y?40:g,p=ce(r.nodeSize,r.nodeSizeRange,e),m=e=>p(e),v=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),b=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*m(e))).force("center",o.forceCenter(c,l).strength(.8)).force("x",o.forceX(c).strength(.15)).force("y",o.forceY(l).strength(.15));if(b.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}));b.force("link",v),b.force("link").links(e)}y?b.alpha(.3):.1>b.alpha()&&b.alpha(1),b.stop();for(let e=0;f>e;++e)b.tick();for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=x.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=x.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var i,a,s;const c=r.nodeStyle,l=r.edgeStyle,u=ce(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 y=[],g=[],f=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=c?c(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};y.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!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=n.opacity)&&void 0!==s?s:.6};g.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=(m=r.nodeLabel)?"function"==typeof m?m:e=>e[m]||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);f.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:y,sceneEdges:g,labels:f}}};function ae(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function se(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function ce(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 s=t||[5,20],c=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===c.length)return()=>s[0];const l=null!==(o=r.min(c))&&void 0!==o?o:0,u=null!==(a=r.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([l,u]).range(s).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?s[0]:d(n)}}const le=n.schemeCategory10,ue={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:c}=r,l=Math.min(n[0],n[1])/2,u=l-i,d=n[0]/2,h=n[1]/2,y=(g=r.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,m=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=f.get("string"==typeof e.source?e.source:e.source.id),n=f.get(t);if(void 0===r||void 0===n)continue;const o=y(e);m[r][n]=o}const v=a.chord().padAngle(o);c&&v.sortGroups(c);const b=v(m),x=b.groups,k=s.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 A=new Map;for(const t of e)A.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=A.get("string"==typeof e.source?e.source:e.source.id),n=A.get(t);r&&(e.source=r),n&&(e.target=n)}const w=new Map;for(const e of t)w.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=w.get(`${r}\0${n}`)||w.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:s=20,edgeOpacity:c=.5}=r,l=Math.min(n[0],n[1])/2,u=l-s,d=n[0]/2,h=n[1]/2,y=r.nodeStyle,g=r.edgeStyle,f=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:le,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const v=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=y?y(r).fill||m.get(r.id)||p[t%p.length]:m.get(r.id)||p[t%p.length];const a=y?y(r):{},s={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:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:s,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=v(t);if(!r)continue;const n=de(r,d,h);let o="#999";if(g)o=g(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===f&&r?o=m.get(r.id)||o:t&&(o=m.get(t.id)||o)}const a=g?g(e):{},s={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:n,style:s,datum:e})}if(!1!==r.showLabels){const t=(A=r.nodeLabel)?"function"==typeof A?A:e=>e[A]||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 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 A;return{sceneNodes:b,sceneEdges:x,labels:k}}};function de(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(" ")}function he(e){const[t,r,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}const ye={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=(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=c.hierarchy(i,s);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,y]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=c.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,y);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=c.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,y);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,l=c.treemap().size([r,n]).tile(c.treemapBinary).padding(a);s>0&&l.paddingTop(s),l(e)}(d,r,h,y);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;c.pack().size([r,n]).padding(i)(e)}(d,r,h,y);break;case"partition":!function(e,t,r,n){var o;c.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,y)}const g=d.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;g.length>t;t++){const n=g[t],i={id:ve(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?ge(i,n,r):"treemap"===a||"partition"===a?fe(i,n):"circlepack"===a&&pe(i,n),i.__hierarchyNode=n,e.push(i),f.set(n,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const r=f.get(e.parent),n=f.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,s,c,l,u;const d=[],h=[],y=[],g=r.treeOrientation||"vertical",f="radial"===g,p=n[0]/2,m=n[1]/2,v="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;f&&(e+=p,n+=m);const i=o(t);let s=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const c={fill:s,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:v,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(s=r.edgeOpacity)&&void 0!==s?s:.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,s=r.y;f&&(n+=p,o+=m,a+=p,s+=m);const u=me(n,o,a,s,g),d=i(e),y={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(c=d.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:k};h.push({type:"curved",pathD:u,style:y,datum:e})}if(!1!==r.showLabels){const t=be(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(f&&(a+=p,s+=m),f){const e=a-p,t=s-m,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===g?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=a-v-6,i="end"):(n=a+v+6,i="start"),o=s):(n=a,o=s+v+14,i="middle");y.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:y}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i;const a=[],s=[],c=["#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 s=n(r);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(l=c[r.depth%c.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.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=be(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const l of e){const e=l.x1-l.x0,u=l.y1-l.y0;if(0>=e||0>=u)continue;const d=!((null===(i=l.data)||void 0===i?void 0:i.children)&&l.data.children.length>0);if(!a){if("leaf"===o&&!d)continue;if("parent"===o&&d)continue}const h=r?r(l):l.id;if(!h)continue;if((d?30:40)>e||(d?16:14)>u)continue;let y=n(l).fill||"#4d430c";t.colorByDepth&&void 0!==l.depth&&(y=c[l.depth%c.length]);const g=he(y);s.push(d?{x:l.x0+e/2,y:l.y0+u/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:g}:{x:l.x0+4,y:l.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:g})}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,s,c;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 s=n(r);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=d[r.depth%d.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.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=be(t.nodeLabel);for(const o of e){const e=null!==(s=o.__radius)&&void 0!==s?s:5,i=r?r(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=n(o).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(l=d[o.depth%d.length]),a){const t=he(l);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:o.x,y:o.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ge(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 fe(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 pe(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 me(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 ve(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 be(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}function xe(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const ke={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){var i,a;const c=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),l=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var r;return(null!==(r=e[t])&&void 0!==r?r:"")+""}}(r.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),d=null!==(i=r.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=r.orbitEccentricity)&&void 0!==a?a:1,y="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,f=xe(r);f.metaMap.clear(),n.length=0,o.length=0;const p=new Map;function m(e){var t;const r=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,r+1),0===r?e:`${e}__${r}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(l(e));n.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),f.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,p){const v=c(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,A=0;for(;b>k;)k+=u[Math.min(A,u.length-1)],A++,x++;let w=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],A=v.slice(w,w+k);if(!A.length)break;const S=(b+1)/x,E={id:r,depth:h,data:t,parentId:r},L=p?d/y(E)*S:d*S,O=s.pie().value(e=>{var t;return(null===(t=c(e))||void 0===t?void 0:t.length)?4:1}).sort(null),D=O(A),j=g(E);for(let t=0;A.length>t;t++){const s=(D[t].startAngle+D[t].endAngle)/2,c=A[t],u=m(l(c)),d=i+L*Math.sin(s),y=a+L*Math.cos(s)*j;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:h,data:c}),f.metaMap.set(u,{ring:L,angle:s,depth:h,parentId:r,eccentricity:j}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(c,u,d,y,L,h+1,!0)}w+=k}}(e,k,v,b,x,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,s,c;const l=r.nodeStyle,u=r.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],y=[],g=[];if(!1!==r.orbitShowRings){const t=xe(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;y.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(c),y2:t+r*Math.cos(c)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(t),r=l?l(t):{},n={fill:r.fill||"#6366f1",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=r.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:f.get(e.source),r="object"==typeof e.target?e.target:f.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=d(r);if(4>=e)continue;const n="function"==typeof t?t(r):t&&null!==(c=null===(s=r.data)||void 0===s?void 0:s[t])&&void 0!==c?c:r.id;g.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:y,labels:g}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=xe(t),i=null!==(r=t.orbitSpeed)&&void 0!==r?r:.25,a=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const r=null!==(t=e.depth)&&void 0!==t?t:0;return(r%2==0?1:-1)/(r+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=i*(Math.PI/6),l=new Map;for(const t of e)l.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=l.get(e.parentId);if(!r)continue;const n=e.angle+s*c*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(n),t.y=r.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)},Ae={sankey:oe,force:ie,chord:ue,tree:ye,cluster:ye,treemap:ye,circlepack:ye,partition:ye,orbit:ke};function we(e){return Ae[e]}function Se(e,t,r){return e+(t-e)*r}class Ee{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._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new y(2e3))}updateConfig(e){const t=this.config,r=e;t.__orbitState&&(r.__orbitState=t.__orbitState),t.__hierarchyRoot&&(r.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new y(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,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,s="function"==typeof n?n:e=>e[n],c="function"==typeof o?o:e=>e[o],l="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(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Le(e)),{data:t}))}for(let e=0;t.length>e;e++){const r=t[e],n=c(r)+"",o=l(r)+"",i=Number(u(r))||1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Le(n)),{data:r})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Le(o)),{data:r}));const a=`${n}\0${o}\0${e}`;this.edges.set(a,{source:n,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:a})}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._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Le(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Le(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);let l=!1;return c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||l||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,r,n,o,i,a;const s=we(this.config.chartType);if(!s)return;let c=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(0===c.length&&!s.hierarchical)return;if(this.prepareForRelayout(),s.supportsStreaming&&!s.hierarchical){const e=new Map;for(const s of c)if(void 0!==s._prevX0){const c=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(r=s._prevX0)&&void 0!==r?r:0),l=(null!==(n=s._prevY1)&&void 0!==n?n:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+c/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+l/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(s.computeLayout(c,l,this.config,e),delete this.config.__previousPositions,s.hierarchical&&c.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of c)this.nodes.set(e.id,e);for(let e=0;l.length>e;e++){const t=l[e],r=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=r,this.edges.set(r,t)}}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),c.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 d=new Set(this.nodes.keys()),h=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 d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.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=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=we(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}get isAnimating(){const e=we(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=we(this.config.chartType);if(!(null==r?void 0:r.tick))return!1;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return r.tick(n,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),r=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Se(e._prevX0,e._targetX0,r),e.x1=Se(e._prevX1,e._targetX1,r),e.y0=Se(e._prevY0,e._targetY0,r),e.y1=Se(e._prevY1,e._targetY1,r));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=Se(e._prevY0,e._targetY0,r),e.y1=Se(e._prevY1,e._targetY1,r),e.sankeyWidth=Se(e._prevSankeyWidth,e._targetSankeyWidth,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.x1,a=n.x0,s=t.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=r.x1,a=n.x0,s=t.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.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 s=null!==(t=a.duration)&&void 0!==t?t:500,c=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=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;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=c,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,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const l=this.edgeTimestamps.get(`${n}\0${a}`);if(!l)continue;const u=e-l;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=c)}}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,s=this.nodeTimestamps.size;if(1>=s)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const c=this._decaySortedNodes,l=new Map;for(let e=0;c.length>e;e++)l.set(c[e][0],e);for(const e of this.sceneNodes){const c=e.id;if(!c)continue;const u=l.get(c);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*s)>d?1:a;break;default:h=1}const y=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:y*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 s=this.nodes.get(r);if(!s)continue;const c=n.metric(s);let l=null;void 0===n.critical||n.critical>c?void 0===n.warning||n.warning>c||(l=o):l=i,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),a&&(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._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Le(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 Oe(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function De(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=je(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;s>r&&(i=e,s=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Ie(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function je(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=Oe(Math.atan2(o,n)),s=Oe(e.startAngle),c=Oe(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let Ce=null,Pe=null;function Me(){return Pe||(Ce=document.createElement("canvas"),Ce.width=1,Ce.height=1,Pe=Ce.getContext("2d")),Pe}function Ie(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=Me();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}}const s=a.lineWidth;a.lineWidth=10;const c=a.isPointInStroke(i,t,r);if(a.lineWidth=s,c)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}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 s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt(Math.pow(t-s,2)+Math.pow(r-c,2));return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=Me();if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);default:return null}}const Ne={fill:e=>u.createElement("rect",{style:e,width:16,height:16}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Te(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Ne[r])(n(e,t)),o}function _e(){return u.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function $e(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function We({config:e,orientation:t="vertical",width:r=100}){const{colorFn:n,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+u.useId();if("horizontal"===t){const e=12,t=Math.min(r,200),a=Math.max(0,(r-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(u.createElement("stop",{key:e,offset:100*t+"%",stopColor:n(o[0]+t*(o[1]-o[0]))}))}return u.createElement("g",{"aria-label":i||"Gradient legend"},u.createElement("defs",null,u.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},l)),i&&u.createElement("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),u.createElement("rect",{x:a,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),u.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])),u.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])))}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(u.createElement("stop",{key:e,offset:100*t+"%",stopColor:n(o[1]-t*(o[1]-o[0]))}))}return u.createElement("g",{"aria-label":i||"Gradient legend"},i&&u.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),u.createElement("defs",null,u.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},l)),u.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),u.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])),u.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])))}function Re(e){const{legendGroups:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:c=100,height:l=20,orientation:d="vertical"}=e,[h,y]=u.useState(0),[g,f]=u.useState(0),p=u.useCallback((e,t)=>{y(e),f(t)},[]),m="vertical"===d?(({legendGroups:e,width:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:l})=>{let d=24;const h=[];return e.forEach((e,y)=>{d+=5,h.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+y,stroke:"gray",x1:0,y1:d,x2:t,y2:d})),d+=8,e.label&&(d+=16,h.push(u.createElement("text",{key:"legend-text-"+y,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),d+=8),h.push(u.createElement("g",{key:"legend-group-"+y,className:"legend-item",transform:`translate(0,${d})`},((e,t,r,n,o,i,a,s,c,l)=>{const{type:d="fill",styleFn:h,items:y}=e,g=[];let f=0;const p=!(!t&&!r),m="isolate"===l||void 0===l&&null!=o;return y.forEach((e,l)=>{const v=Te(e,l,d,h),b=$e(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===i&&l===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:p?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowDown"===r.key||"ArrowUp"===r.key){r.preventDefault();const e=(l+("ArrowDown"===r.key?1:-1)+y.length)%y.length;c(s,e);const t=null===(n=r.currentTarget.parentElement)||void 0===n?void 0:n.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&u.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&u.createElement(_e,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=22}),g})(e,r,n,o,i,a,s,y,c,l))),d+=22*e.items.length+8}),h})({legendGroups:t||[],width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:e,height:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:d})=>{let h=0;const y=[];e.forEach((e,t)=>{let r=0;e.label&&(r+=16);const g=((e,t,r,n,o,i,a,s,c,l)=>{const{type:d="fill",styleFn:h,items:y}=e,g=[];let f=0;const p=!(!t&&!r),m="isolate"===l||void 0===l&&null!=o;return y.forEach((e,l)=>{const v=Te(e,l,d,h),b=$e(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${f},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===i&&l===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:p?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowRight"===r.key||"ArrowLeft"===r.key){r.preventDefault();const e=(l+("ArrowRight"===r.key?1:-1)+y.length)%y.length;c(s,e);const t=null===(n=r.currentTarget.parentElement)||void 0===n?void 0:n.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&u.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&u.createElement(_e,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=26+7*e.label.length}),{items:g,offset:f}})(e,n,o,i,a,s,c,t,l,d);r+=g.offset+5,y.push(Object.assign(Object.assign({label:e.label},g),{offset:r})),h+=r+12});let g=Math.max(0,(r-h)/2);const f=[];return y.forEach((r,n)=>{const o=e[n];o.label&&(f.push(u.createElement("text",{key:"legend-text-"+n,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),g+=16),f.push(u.createElement("g",{key:"legend-group-"+n,className:"legend-item",transform:`translate(${g},0)`},r.items)),g+=r.offset+5,e[n+1]&&f.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+n,stroke:"gray",x1:g,y1:-8,x2:g,y2:t+0+8})),g+=12}),u.createElement("g",null,f)})({legendGroups:t||[],title:s,height:l,width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:a}),v=!(!r&&!n);return u.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==s&&""!==s&&"vertical"===d&&u.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function Be(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y,legendPosition:g="right",foregroundGraphics:f,sceneNodes:p,annotations:m,svgAnnotationRules:v}=e;return u.createElement(u.Fragment,null,u.createElement("svg",{role:"img",width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("title",null,"string"==typeof s?s:"Network Chart"),u.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),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)),m&&m.filter(e=>"widget"!==e.type).map((e,n)=>{if(v){const o=v(e,n,{width:t,height:r,sceneNodes:p});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),f),s&&"string"==typeof s?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?u.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},s):null,function(e){const{legend:t,totalWidth:r,totalHeight:n,margin:o,legendPosition:i="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:l,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const y="top"===i||"bottom"===i;let g,f;return"left"===i?(g=4,f=o.top):"top"===i?(g=0,f=a?32:8):"bottom"===i?(g=0,f=n-o.bottom+50):(g=r-o.right+10,f=o.top),u.createElement("g",{transform:`translate(${g}, ${f})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?u.createElement(We,{config:t.gradient,orientation:y?"horizontal":"vertical",width:y?r:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?u.createElement(Re,{legendGroups:t.legendGroups,title:"",width:y?r:100,orientation:y?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:l,isolatedCategories:d,legendInteraction:h}):t)}({legend:c,totalWidth:n,totalHeight:o,margin:i,legendPosition:g,title:s,legendHoverBehavior:l,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y})),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{var r,n,o,a,s,c,l,d,h;const y=p.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(!y)return null;const g=i.left+(null!==(r=y.cx)&&void 0!==r?r:null!=y.x&&null!=y.w?y.x+y.w/2:null!==(n=y.x)&&void 0!==n?n:0),f=i.top+(null!==(o=y.cy)&&void 0!==o?o:null!=y.y&&null!=y.h?y.y+y.h/2:null!==(a=y.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(c=e.dy)&&void 0!==c?c:-16,b=null!==(l=e.width)&&void 0!==l?l: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:g+m-b/2,top:f+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function ze(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}Be.displayName="NetworkSVGOverlay";const He="undefined"==typeof window||"undefined"==typeof document,Fe={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ye(e,t,r){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?r+", empty":`${r}, ${n.join(", ")}`}function qe({nodes:e,chartType:t}){var r,n,o,i,a;const s=[];for(const t of e){if(s.length>=50)break;s.push({values:{id:(null===(r=t.datum)||void 0===r?void 0:r.id)||t.id||"",x:Math.round(100*(null!==(o=null!==(n=t.cx)&&void 0!==n?n:t.x)&&void 0!==o?o:0))/100+"",y:Math.round(100*(null!==(a=null!==(i=t.cy)&&void 0!==i?i:t.y)&&void 0!==a?a:0))/100+""}})}if(0===s.length)return null;const c=new Set;for(const e of s)for(const t of Object.keys(e.values))c.add(t);const l=Array.from(c);return u.createElement("table",{style:Fe,role:"table","aria-label":"Data table for "+t},u.createElement("thead",null,u.createElement("tr",null,l.map(e=>u.createElement("th",{key:e},e)))),u.createElement("tbody",null,s.map((e,t)=>u.createElement("tr",{key:t},l.map(t=>{var r;return u.createElement("td",{key:t},null!==(r=e.values[t])&&void 0!==r?r:"")}))),e.length>50&&u.createElement("tr",null,u.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function Xe({hoverPoint:e}){let t="";if(e){const r=e.data||e;t="object"==typeof r?"Focused on data point: "+Object.entries(r).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+r}return u.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Fe},t)}function Ge(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ve(e,t,r=.3){Ge(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Ke(e,t,r=.6){var n,o,i,a,s;if(!Ge(t))return;const c=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,l=t.r+c*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,l,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*r,e.stroke()}function Ze(e,t){var r,n,o,i,a,s;if(!t.pathD)return;e.save();const c=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,s="string"==typeof t.style.fill?t.style.fill:"#999";o.addColorStop(0,1===a.from?s:"transparent"),o.addColorStop(1,1===a.to?s:"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(c)}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!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(c)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(c)),e.restore()}function Ue(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 Qe(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 Je(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 et={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},tt=n.schemeCategory10,rt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],nt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],ot=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function it(e,t,r){if("function"==typeof t){const n=t(e);return r&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||ot.has(t)}(n)?r(n):n}const n=e[t];return r?r(n):tt[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+""))%tt.length]}function at(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),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=et[r]||et.category10;if(o&&"function"==typeof a){let e=-1/0;for(const t of n){const r=Number(t);r>e&&(e=r)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:tt;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function st(t){const r=e.createContext(null),n=ct(t);return[function({children:n}){const o=e.useMemo(()=>ct(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,a=e.useRef(t);a.current=t;const s=e.useCallback(()=>a.current(i.getState()),[i]),c=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,s,c)}]}function ct(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)}}}const lt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ut={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},dt={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[ht,yt]=st(e=>({theme:lt,setTheme(t){e(e=>{if("light"===t)return{theme:lt};if("dark"===t)return{theme:ut};if("high-contrast"===t)return{theme:dt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?ut:lt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}})),gt={top:20,right:80,bottom:20,left:80},ft={top:40,right:40,bottom:40,left:40},pt=new Set(["chord","force","circlepack","orbit"]),mt=[800,600],vt={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 bt({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:vt},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 s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let i=c;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:s.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:vt},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!=s.value&&s.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const l=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),d=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:vt},u.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const xt=e.forwardRef(function(t,r){var n,o,i,a,c,l,y,g,f,p,m;const{chartType:v,nodes:b,edges:x,data:k,initialEdges:A,nodeIDAccessor:w="id",sourceAccessor:S="source",targetAccessor:E="target",valueAccessor:L="value",childrenAccessor:O,hierarchySum:D,orientation:j="horizontal",nodeAlign:C="justify",nodePaddingRatio:P=.05,nodeWidth:M=15,iterations:I=300,forceStrength:N=.1,padAngle:T=.01,groupWidth:_=20,sortGroups:$,edgeSort:W,treeOrientation:R="vertical",edgeType:B="curve",padding:z,paddingTop:H,tensionConfig:F,showParticles:Y=!1,particleStyle:q,nodeStyle:X,edgeStyle:G,colorBy:V,colorScheme:K="category10",edgeColorBy:Z="source",edgeOpacity:U=.5,colorByDepth:Q=!1,nodeSize:J=8,nodeSizeRange:ee=[5,20],nodeLabel:te,showLabels:re=!0,labelMode:ne,size:oe=mt,responsiveWidth:ie,responsiveHeight:ae,margin:se,className:ce,background:le,enableHover:ue=!0,tooltipContent:de,customHoverBehavior:he,customClickBehavior:ye,onObservation:ge,chartId:fe,onTopologyChange:pe,annotations:me,svgAnnotationRules:ve,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:Ae,legendHighlightedCategory:we,legendIsolatedCategories:Se,title:Le,foregroundGraphics:Oe,backgroundGraphics:je,decay:Ce,pulse:Pe,staleness:Me,thresholds:Ie,accessibleTable:Ne,orbitMode:Te,orbitSize:_e,orbitSpeed:$e,orbitRevolution:We,orbitRevolutionStyle:Re,orbitEccentricity:Fe,orbitShowRings:Ge,orbitAnimated:et}=t,rt=pt.has(v)?ft:gt,[nt,ot]=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]]]}(oe,ie,ae),it=Object.assign(Object.assign({},rt),se),at=ot[0]-it.left-it.right,st=ot[1]-it.top-it.bottom,ct="function"==typeof Oe?Oe({size:ot,margin:it}):Oe,lt=e.useMemo(()=>Object.assign(Object.assign({},d),F),[F]),ut=e.useMemo(()=>Object.assign(Object.assign({},h),q),[q]),dt=e.useMemo(()=>({chartType:v,nodeIDAccessor:w,sourceAccessor:S,targetAccessor:E,valueAccessor:L,childrenAccessor:O,hierarchySum:D,orientation:j,nodeAlign:C,nodePaddingRatio:P,nodeWidth:M,iterations:I,forceStrength:N,padAngle:T,groupWidth:_,sortGroups:$,edgeSort:W,treeOrientation:R,edgeType:B,padding:z,paddingTop:H,tensionConfig:lt,showParticles:Y,particleStyle:ut,nodeStyle:X,edgeStyle:G,nodeLabel:te,showLabels:re,labelMode:ne,colorBy:V,colorScheme:K,edgeColorBy:Z,edgeOpacity:U,colorByDepth:Q,nodeSize:J,nodeSizeRange:ee,decay:Ce,pulse:Pe,staleness:Me,thresholds:Ie,orbitMode:Te,orbitSize:_e,orbitSpeed:$e,orbitRevolution:We,orbitRevolutionStyle:Re,orbitEccentricity:Fe,orbitShowRings:Ge,orbitAnimated:et}),[v,w,S,E,L,O,D,j,C,P,M,I,N,T,_,$,W,R,B,z,H,lt,Y,ut,X,G,te,re,ne,V,K,Z,U,Q,J,ee,Ce,Pe,Me,Ie,Te,_e,$e,We,Re,Fe,Ge,et]),ht=e.useRef(null),vt=e.useRef(0),xt=e.useRef(0),kt=e.useRef(!0),At=yt(e=>e.theme),wt=e.useRef(()=>{}),St=e.useRef(null);St.current||(St.current=new Ee(dt));const[Et,Lt]=e.useState(null),[Ot,Dt]=e.useState(0),[jt,Ct]=e.useState(0),[Pt,Mt]=e.useState(!1),It=e.useRef(null),Nt=e.useRef(new Map),Tt=e.useRef(0),_t=e.useCallback(e=>{if("function"==typeof V)return V(e)+"";if("string"==typeof V&&e.data){const t=e.data[V];if(void 0!==t){if(!Nt.current.has(t+"")){const e=Array.isArray(K)?K:tt;Nt.current.set(t+"",e[Tt.current++%e.length])}return Nt.current.get(t+"")}}if(Nt.current.has(e.id))return Nt.current.get(e.id);const t=Array.isArray(K)?K:tt,r=V?t[Tt.current++%t.length]:t[0];return Nt.current.set(e.id,r),r},[V,K]),$t=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?_t(r):t?_t(t):"#999"},[Z,_t]),Wt=e.useCallback(e=>{if(!(null==q?void 0:q.colorBy))return $t(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===ut.colorBy&&r?_t(r):t?_t(t):"#999"},[null==q?void 0:q.colorBy,ut.colorBy,_t,$t]),Rt="sankey"===v&&Y||!!Pe||null!==(o=null===(n=St.current)||void 0===n?void 0:n.isAnimating)&&void 0!==o&&o,Bt=e.useCallback(()=>{vt.current&&!Rt||vt.current||(vt.current=requestAnimationFrame(()=>wt.current()))},[Rt]);e.useEffect(()=>{var e;null===(e=St.current)||void 0===e||e.updateConfig(dt),kt.current=!0,Bt()},[dt,Bt]),e.useEffect(()=>{kt.current=!0,Bt()},[At,Bt]);const zt=e.useCallback(()=>{var e;const t=St.current;if(!t)return;t.runLayout([at,st]),t.buildScene([at,st]),kt.current=!0;for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&Nt.current.set(r.id,r.style.fill);const r=Array.isArray(K)?K:tt,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Nt.current.has(t.id)||Nt.current.set(t.id,r[e%r.length])}if(Tt.current=n.length,Dt(t.layoutVersion),pe){const{nodes:e,edges:r}=t.getLayoutData();pe(e,r)}},[at,st,pe,K]),Ht=e.useCallback(e=>{const t=St.current;t&&(t.ingestEdge(e)&&zt(),Bt())},[zt,Bt]),Ft=e.useCallback(e=>{const t=St.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&zt(),Bt()},[zt,Bt]),Yt=e.useCallback(()=>{var e;null===(e=St.current)||void 0===e||e.clear(),Nt.current.clear(),Tt.current=0,Dt(0),Lt(null),It.current=null,kt.current=!0,Bt()},[Bt]),qt=e.useCallback(()=>{const e=St.current;e&&(e.tension+=999,zt(),Bt())},[zt,Bt]);e.useImperativeHandle(r,()=>({push:Ht,pushMany:Ft,clear:Yt,getTopology:()=>{var e,t;return null!==(t=null===(e=St.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=St.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:qt,getTension:()=>{var e,t;return null!==(t=null===(e=St.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Ht,Ft,Yt,qt]);const Xt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(v),Gt=Xt?k||(Array.isArray(x)?void 0:x):void 0;e.useEffect(()=>{var e;const t=St.current;if(t)if(Xt&&Gt)t.ingestHierarchy(Gt,[at,st]),t.buildScene([at,st]),kt.current=!0,Bt();else{const r=b||[],n=Array.isArray(x)?x:[];if(0===r.length&&0===n.length)return;t.ingestBounded(r,n,[at,st]),t.buildScene([at,st]);for(const r of t.sceneNodes)r.id&&(null===(e=r.style)||void 0===e?void 0:e.fill)&&Nt.current.set(r.id,r.style.fill+"");const o=Array.isArray(K)?K:tt,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Nt.current.has(t.id)||Nt.current.set(t.id,o[e%o.length])}Tt.current=i.length,kt.current=!0,Bt()}},[b,x,k,Gt,Xt,at,st,dt,Bt,K]),e.useEffect(()=>{A&&A.length>0&&Ft(A)},[]);const Vt=e.useCallback(e=>{if(he&&he(e),ge){const t=Date.now();ge(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:fe}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:fe})}},[he,ge,fe]),Kt=e.useCallback(e=>{if(ye&&ye(e),ge){const t=Date.now();ge(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:fe}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:fe})}},[ye,ge,fe]),Zt=e.useRef(()=>{}),Ut=e.useRef(()=>{});Zt.current=e=>{if(!ue)return;const t=ht.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-it.left,o=e.clientY-r.top-it.top;if(0>n||n>at||0>o||o>st)return void(It.current&&(It.current=null,Lt(null),Vt&&(Vt(null),kt.current=!0),Bt()));const i=St.current;if(!i)return;const a=De(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(It.current&&(It.current=null,Lt(null),Vt&&(Vt(null),kt.current=!0),Bt()));const s=a.datum||{},c=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:a.type,data:s,x:a.x,y:a.y});It.current=c,Lt(c),Vt&&(Vt(c),kt.current=!0),Bt()},Ut.current=()=>{It.current&&(It.current=null,Lt(null),Vt&&(Vt(null),kt.current=!0),Bt())};const Qt=e.useRef(()=>{});Qt.current=e=>{if(!ye&&!ge)return;const t=ht.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-it.left,o=e.clientY-r.top-it.top;if(0>n||n>at||0>o||o>st)return;const i=St.current;if(!i)return;const a=De(i.sceneNodes,i.sceneEdges,n,o);if(a){const e=a.datum||{};Kt(Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{type:a.type,data:e,x:a.x,y:a.y}))}else Kt(null)},e.useCallback(e=>Zt.current(e),[]);const Jt=e.useCallback(()=>Ut.current(),[]),er=e.useCallback(e=>Qt.current(e),[]),tr=e.useRef(-1),rr=e.useCallback(e=>{const t=St.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=tr.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 tr.current=-1,It.current=null,Lt(null),Vt&&(Vt(null),kt.current=!0),void Bt();const i=0>n?0:o;tr.current=i;const a=r[i],s=a.datum||{},c=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:"node",data:s,x:a.x,y:a.y});It.current=c,Lt(c),Vt&&(Vt(c),kt.current=!0),Bt()},[Vt,Bt]),nr=e.useCallback(e=>{tr.current=-1,Zt.current(e)},[]);wt.current=()=>{var e,t,r,n,o,i,a;vt.current=0;const s=ht.current;if(!s)return;const c=s.getContext("2d");if(!c)return;const l=St.current;if(!l)return;const u=performance.now(),d=xt.current?Math.min((u-xt.current)/1e3,.1):.016;xt.current=u;const y=l.advanceTransition(u),g=l.tickAnimation([at,st],d);(y||kt.current||g)&&l.buildScene([at,st]);const f="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,r,n){const o=e.getContext("2d");if(!o)return null;const i=t[0]*n,a=t[1]*n,s=t[0]+"px",c=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==c&&(e.style.height=c),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(n,0,0,n,0,0),o.translate(r.left,r.top),o}(s,ot,it,f))return;c.clearRect(-it.left,-it.top,ot[0],ot[1]),le&&(c.fillStyle=le,c.fillRect(0,0,at,st)),Ce&&l.applyDecay(),Pe&&l.applyPulse(u),Ie&&l.applyThresholds(u),l.applyTopologyDiff(u);const p=null!==(e=null==Me?void 0:Me.threshold)&&void 0!==e?e:5e3,m=Me&&l.lastIngestTime>0&&u-l.lastIngestTime>p;if(m&&(c.globalAlpha=null!==(t=null==Me?void 0:Me.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Ze(e,r);break;case"line":Ue(e,r);break;case"ribbon":Qe(e,r);break;case"curved":Je(e,r)}}(c,l.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)),Ve(e,t),e.restore())}}(c,l.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=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()),Ke(e,t),e.restore())}}(c,l.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()}}(c,l.sceneNodes),Y&&l.particlePool&&!m){const e=Array.from(l.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,s=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)>=s)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),c=Math.floor(i),l=i-c;let u=c;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<s;t++)e.spawn(n)}}(l.particlePool,e,d,ut);const t=.5*(null!==(r=ut.speedMultiplier)&&void 0!==r?r:1);let n;if(ut.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)}l.particlePool.step(d,t,e,n),function(e,t,r,n,o){var i,a;const s=null!==(i=n.radius)&&void 0!==i?i:h.radius,c=null!==(a=n.opacity)&&void 0!==a?a:h.opacity;e.globalAlpha=c;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const c=r[a.edgeIndex];if(c){if("function"==typeof n.color){const t="object"==typeof c.source?c.source:null;e.fillStyle=t?n.color(c,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(c);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(c,l.particlePool,e,ut,Wt)}}m&&(c.globalAlpha=1);const v=kt.current;if(kt.current=!1,v||y||g){const e=ht.current;e&&e.setAttribute("aria-label",Ye(null!==(o=null===(n=l.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=l.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(v||y||g)&&Ct(e=>e+1),(Rt||y||g||l.hasActivePulses||l.hasActiveThresholds||l.hasActiveTopologyDiff)&&(vt.current=requestAnimationFrame(()=>wt.current()))},e.useEffect(()=>(Bt(),()=>{vt.current&&(cancelAnimationFrame(vt.current),vt.current=0)}),[Bt]),e.useEffect(()=>{kt.current=!0,Bt()},[v,at,st,le,Bt]),function(t,r,n,o,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=r.current;if(!s||0===s.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=c-s.lastIngestTime>l;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}(Me,St,kt,Bt,Pt,Mt);const or=ue&&Et?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:it.left+Et.x,top:it.top+Et.y,transform:`translate(${Et.x>.6*at?"calc(-100% - 12px)":"12px"}, ${.3*st>Et.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},de?de(Et):u.createElement(bt,{data:Et})):null;if(He){const e=St.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(v),r=t?k||(Array.isArray(x)?void 0:x):void 0;if(t&&r)e.ingestHierarchy(r,[at,st]),e.buildScene([at,st]);else{const t=b||[],r=Array.isArray(x)?x:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[at,st]),e.buildScene([at,st]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],r=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],n=null!==(c=null==e?void 0:e.labels)&&void 0!==c?c:[];return u.createElement("div",{className:"stream-network-frame"+(ce?" "+ce:""),role:"img","aria-label":"string"==typeof Le?Le:"Network chart",style:{position:"relative",width:ot[0],height:ot[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:ot[0],height:ot[1],style:{position:"absolute",left:0,top:0}},je&&u.createElement("g",{transform:`translate(${it.left},${it.top})`},je),u.createElement("g",{transform:`translate(${it.left},${it.top})`},le&&u.createElement("rect",{x:0,y:0,width:at,height:st,fill:le}),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":{const r=e;return u.createElement("path",{key:"net-edge-"+t,d:r.pathD,fill:ze(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=e;return u.createElement("path",{key:"net-edge-"+t,d:r.pathD,fill:ze(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=e;return u.createElement("path",{key:"net-edge-"+t,d:r.pathD,fill:ze(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const r=e;return u.createElement("circle",{key:"net-circle-"+t,cx:r.cx,cy:r.cy,r:r.r,fill:ze(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=e;return u.createElement("rect",{key:"net-rect-"+t,x:r.x,y:r.y,width:r.w,height:r.h,fill:ze(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=e,n=s.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:ze(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),n.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(Be,{width:at,height:st,totalWidth:ot[0],totalHeight:ot[1],margin:it,labels:n,sceneNodes:t,title:Le,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:Ae,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:ct,annotations:me,svgAnnotationRules:ve,annotationFrame:0}))}const ir=St.current;return u.createElement("div",{ref:nt,className:"stream-network-frame"+(ce?" "+ce:""),role:"img","aria-label":"string"==typeof Le?Le:"Network chart",tabIndex:0,style:{position:"relative",width:ie?"100%":ot[0],height:ae?"100%":ot[1],overflow:"visible"},onMouseMove:ue?nr:void 0,onMouseLeave:ue?Jt:void 0,onClick:ye||ge?er:void 0,onKeyDown:rr},je&&u.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ot[0],height:ot[1],pointerEvents:"none",overflow:"visible"}},u.createElement("g",{transform:`translate(${it.left},${it.top})`},je)),u.createElement("canvas",{ref:ht,"aria-label":Ye(null!==(y=null===(l=null==ir?void 0:ir.sceneNodes)||void 0===l?void 0:l.length)&&void 0!==y?y:0,null!==(f=null===(g=null==ir?void 0:ir.sceneEdges)||void 0===g?void 0:g.length)&&void 0!==f?f:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),u.createElement(Xe,{hoverPoint:Et}),Ne&&u.createElement(qe,{nodes:null!==(p=null==ir?void 0:ir.sceneNodes)&&void 0!==p?p:[],edges:null!==(m=null==ir?void 0:ir.sceneEdges)&&void 0!==m?m:[],chartType:"Network chart"}),u.createElement(Be,{width:at,height:st,totalWidth:ot[0],totalHeight:ot[1],margin:it,labels:(null==ir?void 0:ir.labels)||[],sceneNodes:null==ir?void 0:ir.sceneNodes,title:Le,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:Ae,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:ct,annotations:me,svgAnnotationRules:ve,annotationFrame:jt}),or,(null==Me?void 0:Me.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Me.badgePosition?{top:4,left:4}:"bottom-left"===Me.badgePosition?{bottom:4,left:4}:"bottom-right"===Me.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Pt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Pt?"STALE":"LIVE"))});xt.displayName="StreamNetworkFrame";const kt={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function At(e,t){return"function"==typeof t?t(e):e[t]}function wt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":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 St(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 s=[];if(r){const t=At(e,r);a=wt(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=At(e,o);s.push({label:r,value:wt(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=wt(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=wt(e[t[0]],n))}}const c=Object.assign(Object.assign({},kt),o);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:c},a&&u.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.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 Et(e){if(!0===e)return St();if("function"==typeof e){const t=e;return e=>{const r=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==r?null:u.createElement("div",{className:"semiotic-tooltip",style:kt},r)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?St(e):St())}const Lt=e.createContext(null);function Ot(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 Dt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[jt,Ct]=st(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Dt(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=Dt(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}})}})),[Pt,Mt]=st(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 It(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=Ct(e=>e.selections.get(o)),a=Ct(e=>e.setClause),s=Ct(e=>e.clearClause),c=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(Ot(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:c,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(()=>{s(o,n)},[s,o,n]),clientId:n}}const Nt=e.createContext(!1);function Tt(){var e;const t=yt(e=>e.theme),r=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return r&&r.length>0?r:void 0}function _t(e,t,r,n,o){let i;if(Array.isArray(r))i=r;else if(t&&t.length>0)i=t;else if("string"==typeof r){const e=et[r];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function $t(t,r,n="category10"){const o=e.useContext(Lt);return e.useMemo(()=>{if(r){if(0===t.length)return o&&Object.keys(o).length>0?e=>o[e]||"#999":void 0;if("function"==typeof r){const e=Array.from(new Set(t.map(e=>r(e)+"")));return o&&Object.keys(o).length>0?e=>o[e]||"#999":at(e.map(e=>({_cat:e})),"_cat",n)}if(o&&Object.keys(o).length>0){const e=at(t,r,n);return t=>o[t]||e(t)}return at(t,r,n)}},[t,r,n,o])}function Wt({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s}){const c=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=It({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:s}=It({name:r});return{onHover:e.useCallback(e=>{if(!e)return void s();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,s,r]),predicate:o,isActive:i}}({name:(null==c?void 0:c.name)||"hover",fields:(null==c?void 0:c.fields)||n||[]}),d=Mt(e=>e.pushObservation),h=t?{isActive:l.isActive,predicate:l.predicate}:null,y=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:s};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,s,d]),g=e.useCallback(e=>{var t,r;if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};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,s]);return{activeSelectionHook:h,customHoverBehavior:y,customClickBehavior:g}}function Rt(t,r,n){const[o,i]=e.useState(null),[a,s]=e.useState(new Set),c=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),l=e.useCallback(e=>{"isolate"===t&&s(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:c,onLegendClick:l,legendSelectionHook:u}}u.createContext(void 0);const Bt={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 zt(e,t,r){var n,o,i,a,s,c;const l=Bt[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!==(i=t.showGrid)&&void 0!==i?i:l.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||l.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:l.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c: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:Ht(l.marginDefaults,t.showCategoryTicks,t.orientation)}}function Ht(e,t,r){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===r?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function Ft({componentName:e,message:t,diagnosticHint:r,width:n,height:o}){return u.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,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),r&&u.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},r)))}class Yt 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(Ft,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function qt(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 Xt(e,t,r=3){let n,o=r+1;for(const r of t){const t=qt(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}function Gt(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Vt(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=Xt(e,t,3))&&void 0!==r?r:null)}function Kt({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 Zt({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;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=Gt(t).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=Vt(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const Ut={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"}},Qt={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Jt={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},er=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],tr=["vertical","horizontal"],rr={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:er},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:er},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:er},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Qt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:tr},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Ut),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Ut),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ut),Jt),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Ut),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Ut),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:tr},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Ut),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ut),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ut),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ut),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Ut),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function nr(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const or=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),ir=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),ar=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),sr=new Set(["LineChart","AreaChart","StackedAreaChart"]),cr=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function lr(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[r,n,o]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(r)+.7152*i(n)+.0722*i(o)}function ur(e,t){const r=lr(e),n=lr(t);return null===r||null===n?null:(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}const dr=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function hr(e,t){const r=[],n=function(e,t){const r=[],n=rr[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(rr).join(", ")}`]};for(const o of n.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);for(const[e,o]of Object.entries(t)){if(null==o)continue;const t=n.props[e];if(t){if(!nr(o,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${n}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const o=Object.keys(n.props),i=new Set(o);for(const n of Object.keys(t))if(void 0!==t[n]&&!i.has(n)){const t=Xt(n,o),i=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(i)}if("array"===n.dataShape){const o=t.data,i={};for(const e of n.dataAccessors){const r=t[e];"string"==typeof r&&(i[e]=r)}const a=function({componentName:e,data:t,accessors:r,requiredProps:n}){if(n)for(const[t,r]of Object.entries(n))if(null==r)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(r){const n=Gt(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in n)){const r=Vt(i,t),n=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}({componentName:e,data:o,accessors:Object.keys(i).length>0?i:void 0});a&&r.push(a)}else if("object"===n.dataShape){const n=Kt({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const o=Zt({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});o&&r.push(o)}return{valid:0===r.length,errors:r}}(e,t);for(const e of n.errors)r.push({severity:"error",code:"VALIDATION",message:e,fix:""});return rr[e]?(function(e,t,r){const n=rr[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,r),function(e,t,r){const n=t.width,o=t.height;if(void 0===n||"number"==typeof n&&n>0||r.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===o||"number"==typeof o&&o>0||r.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&r.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,r),function(e,t,r){const n=rr[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in i||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,r),function(e,t,r){or.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,r),function(e,t,r){ir.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,r),function(e,t,r){const n=rr[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,r),function(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,r),function(e,t,r){var n;if(!ar.has(e))return;const o=t.rExtent||t.yExtent;o&&Array.isArray(o)&&o.length>=1&&null!=o[0]&&0!==o[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${o[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(n=o[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,r),function(e,t,r){if(!sr.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=t.yAccessor||"y";"string"==typeof o&&n.some(e=>{const t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,r),function(e,t,r){var n,o;const i=null!==(n=t.width)&&void 0!==n?n:600,a=null!==(o=t.height)&&void 0!==o?o:400,s=t.margin;if(!s||"object"!=typeof s)return;const c=(s.left||0)+(s.right||0),l=(s.top||0)+(s.bottom||0);i>c||r.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${c}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>l||r.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${l}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,r),function(e,t,r){var n;const o=rr[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let r=0;s>r;r++){const o=null===(n=i[r])||void 0===n?void 0:n[e.name];if("number"==typeof o&&Number.isFinite(o)){t=!1;break}}t&&r.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,r),function(e,t,r){if(!cr.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,r),function(e,t,r){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const o=n.bottom;"number"==typeof o&&70>o&&r.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${o}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,r),function(e,t,r){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const o=t.margin;if(!o||"object"!=typeof o)return;const i=o.right;"number"==typeof i&&100>i&&r.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,r),function(e,t,r){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=n[0];if(o&&"object"==typeof o)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const i=o[n];"string"==typeof i&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;const i=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ur(e,o);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,r),function(e,t,r){const n=[];for(const e of dr)"function"==typeof t[e]&&n.push(e);n.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,r),{ok:r.every(e=>"warning"===e.severity),diagnoses:r}):{ok:0===r.length,diagnoses:r}}var yr;const gr="undefined"!=typeof process&&"production"!==(null===(yr=process.env)||void 0===yr?void 0:yr.NODE_ENV);function fr({componentName:e,width:t,height:r,chartProps:n,children:o}){return u.createElement(Yt,{fallback:o=>{let i="";if(gr&&n)try{const t=hr(e,n);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return u.createElement(Ft,{componentName:e,message:o.message,diagnosticHint:i,width:t,height:r})}},o)}const pr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},mr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function vr(e,t,r,n){return!1===n||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?u.createElement("div",{style:Object.assign(Object.assign({},pr),{width:t,height:r})},n||"No data available"):null}function br(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({},mr),{position:"absolute",top:a+r*(o+i),left:Math.floor(.1*t),width:30+(37*r+13)%50+"%",height:o,opacity:.5+r%2*.2})})))}const xr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=zt(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:a,edges:s,margin:c,className:l,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:y="target",nodeLabel:g,colorBy:f,colorScheme:p="category10",nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:A=300,forceStrength:w=.1,tooltip:S,frameProps:E={},onObservation:L,chartId:O,selection:D,linkedHover:j,loading:C,emptyContent:P,legendInteraction:M,legendPosition:I}=t,N=i.width,T=i.height,_=i.enableHover,$=i.showLegend,W=null!==(n=i.showLabels)&&void 0!==n&&n,R=i.title,B=br(C,N,T),z=B?null:vr(a,N,T,P),H=a||[],F=s||[],Y=$t(H,f,p),q=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of H){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[H,f]),X=Rt(M,f,q),G=Tt(),V=e.useMemo(()=>new Map,[]),K=e.useMemo(()=>{if(Array.isArray(p))return p;if(G&&G.length>0)return G;const e=et[p];return Array.isArray(e)?e:tt},[p,G]),Z=e.useMemo(()=>e=>{const t={};return t.fill=f?it(e.data||e,f,Y):_t(0,G,p),"number"==typeof m&&(t.r=m),t},[f,Y,m,G,p,V]),U=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),Q=e.useMemo(()=>{if(W&&g)return"function"==typeof g?g:e=>{var t,r,n;return null!==(n=null!==(r=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==r?r:e[g])&&void 0!==n?n:e.id}},[W,g]),{legend:J,margin:ee,legendPosition:te}=function({data:t,colorBy:r,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:c}){const l=e.useContext(Nt),u=void 0!==o?o:!l&&!!r,d=e.useMemo(()=>{if(u&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i,categories:a}){const s=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?n(a,t,r):r?r(o):rt[i%rt.length];return{label:o+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",r={fill:t,stroke:t};return void 0!==o&&(r.stroke=o),void 0!==i&&(r.strokeWidth=i),r},type:"fill",items:s,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:it,categories:c})},[u,r,t,n,c]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),a);return d&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[s,a,d,i]);return{legend:d,margin:h,legendPosition:i}}({data:H,colorBy:f,colorScale:Y,showLegend:$,legendPosition:I,userMargin:c,defaults:i.marginDefaults}),{customHoverBehavior:re}=Wt({selection:D,linkedHover:j,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,chartType:"ForceDirectedGraph",chartId:O}),ne=Zt({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ne?u.createElement(Ft,{componentName:"ForceDirectedGraph",message:ne,width:N,height:T}):B||z||u.createElement(fr,{componentName:"ForceDirectedGraph",width:N,height:T},u.createElement(xt,Object.assign({ref:o,chartType:"force"},null!=a&&{nodes:H},null!=s&&{edges:F},{size:[N,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ee,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:y,iterations:A,forceStrength:w,nodeStyle:Z,edgeStyle:U,colorBy:f,colorScheme:K,nodeSize:m,nodeSizeRange:v,nodeLabel:Q,showLabels:W,enableHover:_,tooltipContent:!1===S?()=>null:Et(S)||void 0,customHoverBehavior:j||L?re:void 0,legend:J,legendPosition:te},M&&"none"!==M&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:l,title:R},E)))});function kr(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 Ar(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 wr(e){return"function"==typeof e?e:t=>t[e]||1}function Sr({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:o},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=it(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=it(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}xr.displayName="ForceDirectedGraph";const Er=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=zt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:a,edges:s,margin:c,className:l,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p="category10",edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:A,edgeOpacity:w=.5,edgeSort:S,tooltip:E,frameProps:L={},onObservation:O,chartId:D,selection:j,linkedHover:C,loading:P,emptyContent:M,legendInteraction:I}=t,N=i.width,T=i.height,_=i.enableHover,$=null===(n=i.showLabels)||void 0===n||n,W=i.title,R=br(P,N,T),B=R?null:vr(s,N,T,M),z=s||[],H=e.useMemo(()=>Ar(a,z,d,h),[a,z,d,h]),F=$t(H,f,p),Y=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of H){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[H,f]),q=Rt(I,f,Y),X=Tt(),G=e.useMemo(()=>new Map,[]),V=e.useMemo(()=>{if(Array.isArray(p))return p;if(X&&X.length>0)return X;const e=et[p];return Array.isArray(e)?e:tt},[p,X]),K=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?it(e.data||e,f,F):_t(0,X,p),t},[f,F,X,p,G]),Z=e.useMemo(()=>Sr({edgeColorBy:m,colorBy:f,colorScale:F,nodeStyleFn:K,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,F,K,w]),U=e.useMemo(()=>{if(!$)return;const e=A||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[$,A,g]),Q=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:J,customClickBehavior:ee}=Wt({selection:j,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:O,chartType:"SankeyDiagram",chartId:D}),te=Zt({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return te?u.createElement(Ft,{componentName:"SankeyDiagram",message:te,width:N,height:T}):R||B||u.createElement(fr,{componentName:"SankeyDiagram",width:N,height:T},u.createElement(xt,Object.assign({ref:o,chartType:"sankey"},H.length>0&&{nodes:H},null!=s&&{edges:z},{size:[N,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:K,edgeStyle:Z,colorBy:f,colorScheme:V,edgeColorBy:m,edgeOpacity:w,edgeSort:S,nodeLabel:U,showLabels:$,enableHover:_,tooltipContent:!1===E?()=>null:Et(E)||void 0,customHoverBehavior:C||O?J:void 0,customClickBehavior:O?ee:void 0},I&&"none"!==I&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories},{className:l,title:W},L)))});Er.displayName="SankeyDiagram";const Lr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=zt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:s,margin:c,className:l,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p="category10",edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:A=.5,tooltip:w,frameProps:S={},onObservation:E,chartId:L,selection:O,linkedHover:D,loading:j,emptyContent:C,legendInteraction:P}=t,M=i.width,I=i.height,N=i.enableHover,T=null===(n=i.showLabels)||void 0===n||n,_=i.title,$=br(j,M,I),W=$?null:vr(s,M,I,C),R=s||[],B=e.useMemo(()=>Ar(a,R,d,h),[a,R,d,h]),z=$t(B,f,p),H=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]),F=Rt(P,f,H),Y=Tt(),q=e.useMemo(()=>new Map,[]),X=e.useMemo(()=>{if(Array.isArray(p))return p;if(Y&&Y.length>0)return Y;const e=et[p];return Array.isArray(e)?e:tt},[p,Y]),G=B.length>0,V=e.useMemo(()=>{if(G)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=it(e.data||e,f,z);else{const i=Array.isArray(p)?p:et[p]||tt,a=Array.isArray(i)?i:tt,s=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[s%a.length]}return o}},[G,f,z,p]),K=e.useMemo(()=>{if(G)return Sr({edgeColorBy:m,colorBy:f,colorScale:z,nodeStyleFn:V||(e=>({fill:_t(0,Y,p)})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[G,m,f,z,V,A,Y,p,q]),Z=e.useMemo(()=>{if(!T)return;const e=k||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[T,k,g]),U=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:Q}=Wt({selection:O,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ChordDiagram",chartId:L}),J=Zt({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return J?u.createElement(Ft,{componentName:"ChordDiagram",message:J,width:M,height:I}):$||W||u.createElement(fr,{componentName:"ChordDiagram",width:M,height:I},u.createElement(xt,Object.assign({ref:o,chartType:"chord"},B.length>0&&{nodes:B},null!=s&&{edges:R},{size:[M,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:V,edgeStyle:K,colorBy:f,colorScheme:X,edgeColorBy:m,edgeOpacity:A,nodeLabel:Z,showLabels:T,enableHover:N,tooltipContent:!1===w?()=>null:Et(w)||void 0,customHoverBehavior:D||E?Q:void 0},P&&"none"!==P&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:l,title:_},S)))});function Or(t){var r;const n=zt(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:s="tree",orientation:c="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:y,colorScheme:g="category10",colorByDepth:f=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,chartId:A,selection:w,linkedHover:S,loading:E,legendInteraction:L}=t,O=n.width,D=n.height,j=n.enableHover,C=null===(r=n.showLabels)||void 0===r||r,P=n.title,M=br(E,O,D),I=e.useMemo(()=>kr(null!=o?o:null,l),[o,l]),N=$t(I,f?void 0:y,g),T=e.useMemo(()=>{if(!y||f)return[];const e=new Set;for(const t of I){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[I,y,f]),_=Rt(L,f?void 0:y,T),$=Tt(),W=e.useMemo(()=>new Map,[]),R=e.useMemo(()=>{if(Array.isArray(g))return g;if($&&$.length>0)return $;const e=et[g];return Array.isArray(e)?e:tt},[g,$]),B=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?nt[(e.depth||0)%nt.length]:y?it(e.data||e,y,N):_t(0,$,g),t},[y,f,N,$,g,W]),z=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return wr(d)},[s,d]),F=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:Y}=Wt({selection:w,linkedHover:S,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:A}),q=Kt({componentName:"TreeDiagram",data:o});return q?u.createElement(Ft,{componentName:"TreeDiagram",message:q,width:O,height:D}):M||u.createElement(fr,{componentName:"TreeDiagram",width:O,height:D},u.createElement(xt,Object.assign({chartType:s},null!=o&&{data:o},{size:[O,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:H,treeOrientation:c,edgeType:p,nodeStyle:B,edgeStyle:z,colorBy:y,colorScheme:R,colorByDepth:f,nodeSize:v,nodeLabel:C?m||h:void 0,showLabels:C,enableHover:j,tooltipContent:!1===b?()=>null:Et(b)||void 0,customHoverBehavior:S||k?Y:void 0},L&&"none"!==L&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories},{className:a,title:P},x)))}function Dr(t){var r;const n=zt(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:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:f,padding:p=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:A,chartId:w,loading:S,legendInteraction:E}=t,L=n.width,O=n.height,D=n.enableHover,j=null===(r=n.showLabels)||void 0===r||r,C=n.title,P=br(S,L,O),{activeSelectionHook:M,customHoverBehavior:I}=Wt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:A,chartType:"Treemap",chartId:w}),N=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(()=>kr(null!=o?o:null,s),[o,s]),_=$t(T,y?void 0:d,h),$=e.useMemo(()=>{if(!d||y)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,y]),W=Rt(E,y?void 0:d,$),R=Tt(),B=e.useMemo(()=>new Map,[]),z=e.useMemo(()=>{if(Array.isArray(h))return h;if(R&&R.length>0)return R;const e=et[h];return Array.isArray(e)?e:tt},[h,R]),H=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?nt[(e.depth||0)%nt.length]:d?it(e.data||e,d,_):_t(0,R,h),t},[d,y,_,R,h,B]),F=e.useMemo(()=>M?e=>{var t;const r=Object.assign({},H(e));if(M.isActive)if(M.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}:H,[H,M,x]),Y=e.useMemo(()=>wr(c),[c]),q=void 0!==m?m:!j||"parent"!==g&&"all"!==g?void 0:18,X=Object.assign(Object.assign({},n.marginDefaults),i),G=Kt({componentName:"Treemap",data:o});return G?u.createElement(Ft,{componentName:"Treemap",message:G,width:L,height:O}):P||u.createElement(fr,{componentName:"Treemap",width:L,height:O},u.createElement(xt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:Y,padding:p,paddingTop:q,nodeStyle:F,colorBy:d,colorScheme:z,colorByDepth:y,nodeLabel:j?f||l:void 0,showLabels:j,labelMode:g,enableHover:D,tooltipContent:!1===v?()=>null:Et(v)||void 0},(k||A)&&{customHoverBehavior:N},E&&"none"!==E&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:C},b)))}function jr(t){var r;const n=zt(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:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h="category10",colorByDepth:y=!1,nodeLabel:g,circleOpacity:f=.7,padding:p=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:k,linkedHover:A,loading:w,legendInteraction:S}=t,E=n.width,L=n.height,O=n.enableHover,D=null===(r=n.showLabels)||void 0===r||r,j=n.title,C=br(w,E,L),P=e.useMemo(()=>kr(null!=o?o:null,s),[o,s]),M=$t(P,y?void 0:d,h),I=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of P){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[P,d,y]),N=Rt(S,y?void 0:d,I),T=Tt(),_=e.useMemo(()=>new Map,[]),$=e.useMemo(()=>{if(Array.isArray(h))return h;if(T&&T.length>0)return T;const e=et[h];return Array.isArray(e)?e:tt},[h,T]),W=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=y?nt[(e.depth||0)%nt.length]:d?it(e.data||e,d,M):_t(0,T,h),t},[d,y,M,f,T,h,_]),R=e.useMemo(()=>wr(c),[c]),B=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:z}=Wt({selection:k,linkedHover:A,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),H=Kt({componentName:"CirclePack",data:o});return H?u.createElement(Ft,{componentName:"CirclePack",message:H,width:E,height:L}):C||u.createElement(fr,{componentName:"CirclePack",width:E,height:L},u.createElement(xt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[E,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:R,padding:p,nodeStyle:W,colorBy:d,colorScheme:$,colorByDepth:y,nodeLabel:D?g||l:void 0,showLabels:D,enableHover:O,tooltipContent:!1===m?()=>null:Et(m)||void 0,customHoverBehavior:A||b?z:void 0},S&&"none"!==S&&{legendHoverBehavior:N.onLegendHover,legendClickBehavior:N.onLegendClick,legendHighlightedCategory:N.highlightedCategory,legendIsolatedCategories:N.isolatedCategories},{className:a,title:j},v)))}Lr.displayName="ChordDiagram",Or.displayName="TreeDiagram",Dr.displayName="Treemap",jr.displayName="CirclePack";const Cr=nt;function Pr(t){const r=zt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:n,margin:o,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:l="category10",colorByDepth:d=!1,orbitMode:h="flat",orbitSize:y=2.95,speed:g=.25,revolution:f,revolutionStyle:p,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:A,foregroundGraphics:w,annotations:S,frameProps:E={},onObservation:L,chartId:O,selection:D,linkedHover:j,loading:C}=t,P=r.width,M=r.height,I=r.enableHover,N=r.title,T=br(C,P,M),_=$t(e.useMemo(()=>kr(n,a),[n,a]),d?void 0:c,l),$=Tt(),W=e.useMemo(()=>new Map,[]),R=e.useMemo(()=>{if(Array.isArray(l))return l;if($&&$.length>0)return $;const e=et[l];return Array.isArray(e)?e:tt},[l,$]),B=e.useMemo(()=>{if(Array.isArray(l))return l;const e=et[l];return Array.isArray(e)?e:tt},[l]),z=e.useMemo(()=>e=>{var t;const r={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return r.fill=d?n?B[0]:Cr[(e.depth||0)%Cr.length]:c?it(e.data||e,c,_):_t(0,$,l),r.opacity=n?1:.85,r},[c,d,_,B,$,l,W]),H=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),F=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:Y}=Wt({selection:D,linkedHover:j,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:L,chartType:"OrbitDiagram",chartId:O}),q=e.useMemo(()=>{if(Y)return e=>{Y(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Y]),X=Kt({componentName:"OrbitDiagram",data:n});return X?u.createElement(Ft,{componentName:"OrbitDiagram",message:X,width:P,height:M}):T||u.createElement(fr,{componentName:"OrbitDiagram",width:P,height:M},u.createElement(xt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[P,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:z,edgeStyle:H,colorBy:c,colorScheme:R,colorByDepth:d,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&I,tooltipContent:k?void 0:!1===A?()=>null:Et(A)||void 0,customHoverBehavior:j||L?q:void 0,foregroundGraphics:w,annotations:S,className:i,title:N,orbitMode:h,orbitSize:y,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:p,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k},E)))}Pr.displayName="OrbitDiagram",exports.ChordDiagram=Lr,exports.CirclePack=jr,exports.ForceDirectedGraph=xr,exports.OrbitDiagram=Pr,exports.SankeyDiagram=Er,exports.StreamNetworkFrame=xt,exports.TreeDiagram=Or,exports.Treemap=Dr;
|