semiotic 3.2.2 → 3.2.3

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.
Files changed (48) hide show
  1. package/CLAUDE.md +47 -5
  2. package/ai/schema.json +63 -0
  3. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  4. package/dist/components/charts/index.d.ts +2 -0
  5. package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
  6. package/dist/components/charts/ordinal/GaugeChart.d.ts +55 -0
  7. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
  8. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
  9. package/dist/components/charts/shared/hooks.d.ts +4 -1
  10. package/dist/components/charts/shared/types.d.ts +10 -5
  11. package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
  12. package/dist/components/charts/xy/AreaChart.d.ts +17 -2
  13. package/dist/components/charts/xy/LineChart.d.ts +14 -3
  14. package/dist/components/semiotic-ordinal.d.ts +2 -0
  15. package/dist/components/semiotic-utils.d.ts +2 -1
  16. package/dist/components/semiotic.d.ts +3 -3
  17. package/dist/components/store/LinkedCrosshairStore.d.ts +6 -2
  18. package/dist/components/stream/CanvasHitTester.d.ts +13 -0
  19. package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -1
  20. package/dist/components/stream/PipelineStore.d.ts +17 -1
  21. package/dist/components/stream/SVGOverlay.d.ts +11 -5
  22. package/dist/components/stream/hitTestUtils.d.ts +15 -0
  23. package/dist/components/stream/ordinalTypes.d.ts +7 -1
  24. package/dist/components/stream/types.d.ts +54 -5
  25. package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +12 -0
  26. package/dist/components/stream/xySceneBuilders/types.d.ts +15 -0
  27. package/dist/geo.min.js +1 -1
  28. package/dist/geo.module.min.js +1 -1
  29. package/dist/network.min.js +1 -1
  30. package/dist/network.module.min.js +1 -1
  31. package/dist/ordinal.min.js +1 -1
  32. package/dist/ordinal.module.min.js +1 -1
  33. package/dist/realtime.min.js +1 -1
  34. package/dist/realtime.module.min.js +1 -1
  35. package/dist/semiotic-ai.min.js +1 -1
  36. package/dist/semiotic-ai.module.min.js +1 -1
  37. package/dist/semiotic-ordinal.d.ts +2 -0
  38. package/dist/semiotic-utils.d.ts +2 -1
  39. package/dist/semiotic-utils.min.js +1 -1
  40. package/dist/semiotic-utils.module.min.js +1 -1
  41. package/dist/semiotic.d.ts +3 -3
  42. package/dist/semiotic.min.js +1 -1
  43. package/dist/semiotic.module.min.js +1 -1
  44. package/dist/server.min.js +1 -1
  45. package/dist/server.module.min.js +1 -1
  46. package/dist/xy.min.js +1 -1
  47. package/dist/xy.module.min.js +1 -1
  48. package/package.json +8 -5
@@ -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 D(e.source)}function O(e){return D(e.target)}function D(e){return(e.y0+e.y1)/2}function C(e){return e.virtual?0:e.value}function j(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 M(e){return e.target.depth}function I(e,t){return e.sourceLinks.length?e.depth:t-1}function P(e,t){return e.y0-t.y0}function T(e,t){return t.y0-e.y0}function N(e,t){return e.y1-t.y1}function _(e,t){return t.y1-e.y1}function $(e,t){return R(e.source,t.source)||e.index-t.index}function B(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function W(e,t){return z(e)==z(t)?"bottom"==e.circularLinkType?T(e,t):P(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?T:P);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?_:N),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(W);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&&G(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 G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function X(e){return function(){return e}}function V(e){return e.index}function K(e){return e.nodes}function U(e){return e.links}function Z(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?j(t,n)-j(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==j(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&&j(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(B),e.targetLinks.sort($)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,c=V,l=I,u=void 0,d=32,h=2,y=K,g=U;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,C),r.sum(e.targetLinks,C)),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),Z(y,u,c),Q(y,u,c,g,g,d),J(y),Y(y,c,h,10,8),Z(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:X(e),f):y},f.links=function(e){return arguments.length?(g="function"==typeof e?e:X(e),f):g},f.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:X(e),f):c},f.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:X(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=new Set,oe=new WeakMap;function ie(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=oe.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,oe.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;ne.has(e)||(ne.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}const ae={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(M))-1:0},justify:I},se={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(ae[h]||I).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(ie(t,"nodeStyle")):{},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(ie(e,"edgeStyle")):{};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}}},ce={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=le(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=ue(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=ue(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=de(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=de(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(ie(t,"nodeSize")),r=c?c(ie(t,"nodeStyle")):{},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(ie(e,"edgeStyle")):{},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(ie(r,"nodeSize"));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 le(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 ue(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 de(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 he=n.schemeCategory10,ye={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:he,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(ie(r,"nodeStyle")).fill||m.get(r.id)||p[t%p.length]:m.get(r.id)||p[t%p.length];const a=y?y(ie(r,"nodeStyle")):{},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=ge(r,d,h);let o="#999";if(g)o=g(ie(e,"edgeStyle")).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(ie(e,"edgeStyle")):{},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 ge(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const fe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function pe(e){const[t,r,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}function me(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 ve(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 be(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}`}}const xe={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),l=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=c.hierarchy(i,s);u.sum(l),u.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[d,h]=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)}(u,r,d,h);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)}(u,r,d,h);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)}(u,r,d,h);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)}(u,r,d,h);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)}(u,r,d,h)}const y=u.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],i={id:me(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?ke(i,n,r):"treemap"===a||"partition"===a?Ae(i,n):"circlepack"===a&&we(i,n),i.__hierarchyNode=n,e.push(i),g.set(n,i)}if("tree"===a||"cluster"===a)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,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(b=r.nodeSize)?b:5;var b;for(const t of e){let e=t.x,n=t.y;f&&(e+=p,n+=m);const i=o(ie(t,"nodeStyle"));let s=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(s=fe[t.depth%fe.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 x=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=be(n,o,a,s,g),d=i(ie(e,"edgeStyle")),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:x};h.push({type:"curved",pathD:u,style:y,datum:e})}if(!1!==r.showLabels){const t=ve(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=[];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(ie(r,"nodeStyle"));let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=fe[r.depth%fe.length]);const l={fill:c,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:l,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=ve(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,l=c.y1-c.y0;if(0>=e||0>=l)continue;const u=!((null===(i=c.data)||void 0===i?void 0:i.children)&&c.data.children.length>0);if(!a){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=r?r(c):c.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>l)continue;let h=n(ie(c,"nodeStyle")).fill||"#4d430c";t.colorByDepth&&void 0!==c.depth&&(h=fe[c.depth%fe.length]);const y=pe(h);s.push(u?{x:c.x0+e/2,y:c.y0+l/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}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=[];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const s=n(ie(r,"nodeStyle"));let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=fe[r.depth%fe.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=ve(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(ie(o,"nodeStyle")).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(l=fe[o.depth%fe.length]),a){const t=pe(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 ke(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 Ae(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 we(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 Se(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Ee={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=Se(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),C=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)*C;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:C}),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=Se(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(ie(t,"nodeSize")),r=l?l(ie(t,"nodeStyle")):{},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(ie(r,"nodeSize"));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=Se(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)},Le={sankey:se,force:ce,chord:ye,tree:xe,cluster:xe,treemap:xe,circlepack:xe,partition:xe,orbit:Ee};function Oe(e){return Le[e]}function De(e,t,r){return e+(t-e)*r}class Ce{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({},je(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({},je(n)),{data:r})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},je(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,je(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,je(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=Oe(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=Oe(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=Oe(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=Oe(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=De(e._prevX0,e._targetX0,r),e.x1=De(e._prevX1,e._targetX1,r),e.y0=De(e._prevY0,e._targetY0,r),e.y1=De(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=De(e._prevY0,e._targetY0,r),e.y1=De(e._prevY1,e._targetY1,r),e.sankeyWidth=De(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 je(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 Me(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Ie(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=Pe(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=$e(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Pe(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,12)?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=Me(Math.atan2(o,n)),s=Me(e.startAngle),c=Me(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 Te=null,Ne=null;function _e(){return Ne||(Te=document.createElement("canvas"),Te.width=1,Te.height=1,Ne=Te.getContext("2d")),Ne}function $e(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=_e();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=_e();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}}function Be(e,t,r){const{group:n,indexInGroup:o}=t,i=r.byGroup.get(n);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=r.groups.indexOf(n);return r.groups.length-1>e?Re(r,r.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=r.groups.indexOf(n);return e>0?Re(r,r.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*r.flat.length)),r.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*r.flat.length)),0);case"Home":return 0;case"End":return r.flat.length-1;case"Escape":return-1;default:return null}}function Re(e,t,r){const n=e.byGroup.get(t);let o=0,i=Math.abs(n[0].x-r.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-r.x);i>t&&(i=t,o=e)}return n[o]._flatIndex}const We="var(--semiotic-focus, #005fcc)";function ze({active:e,hoverPoint:t,margin:r,size:n,shape:o="circle",width:i,height:a}){if(!e||!t)return null;const s=t.x+r.left,c=t.y+r.top;let l;if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);l=u.createElement("rect",{x:s-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:We,strokeWidth:2,strokeDasharray:"4,2"})}else l=u.createElement("circle","wedge"===o?{cx:s,cy:c,r:12,fill:"none",stroke:We,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:We,strokeWidth:2,strokeDasharray:"4,2"});return u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:n[0],height:n[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},l)}function He({x:e,y:t,containerWidth:r,containerHeight:n,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const c=u.useRef(null),[l,d]=u.useState(null);u.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,r,n]);let h;return h=l?`translate(${l.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${l.height+12>n-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*n>t?"4px":"calc(-100% - 4px)"})`,u.createElement("div",{ref:c,className:a,style:{position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"}},i)}const Fe={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 Ye(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Fe[r])(n(e,t)),o}function qe(){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 Ge(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Xe({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 Ve(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=Ye(e,l,d,h),b=Ge(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(qe,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 g=0;e.label&&(g+=16);const f=((e,t,r,n,o,i,a,s,c,l,d)=>{const{type:h="fill",styleFn:y,items:g}=e,f=[];let p=0,m=0;const v=!(!t&&!r),b="isolate"===l||void 0===l&&null!=o;g.forEach((e,l)=>{const x=Ye(e,l,h,y),k=Ge(e,n,o),A=o&&o.size>0&&o.has(e.label),w=26+7*e.label.length;d&&d>0&&p>0&&p+w>d&&(m++,p=0),f.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${p},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:v?s===i&&l===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?A||!1:void 0,"aria-current":v&&!b&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:v?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)+g.length)%g.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:v?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&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"}),x,A&&u.createElement(qe,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=w});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const A=m+1;return{items:f,offset:x,totalRows:A,totalHeight:22*A}})(e,n,o,i,a,s,c,t,l,d,r);g+=f.offset+5,y.push(Object.assign(Object.assign({label:e.label},f),{offset:g,totalRows:f.totalRows,totalHeight:f.totalHeight})),h+=g+12});let g=h>r?0: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:(r.totalHeight||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 Ke(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(Xe,{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(Ve,{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 Ue(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}Ke.displayName="NetworkSVGOverlay";const Ze="undefined"==typeof window||"undefined"==typeof document,Qe=u.createContext(null),Je={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function et(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(", ")}`}const tt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},rt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},nt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},ot={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},it={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},at={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},st={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ct={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function lt({nodes:e,edges:t,chartType:r,tableId:n,chartTitle:o}){var i,a,s,c,l,d,h,y,g,f,p,m,v,b;const[x,k]=u.useState(!1),A=u.useContext(Qe),w=null!==(i=null==A?void 0:A.visible)&&void 0!==i&&i,S=x||w,E=o?"Data summary for "+o:n?`Data summary for ${r} ${n}`:"Data summary for "+r,L=u.useRef(null),O=u.useCallback(()=>{x||w||k(!0)},[x,w]),D=u.useCallback(e=>{var t;w||(null===(t=L.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[w]);if(!e||0===e.length)return n?u.createElement("span",{id:n,tabIndex:-1,style:Je}):null;if(!S)return u.createElement("div",{id:n,tabIndex:-1,onFocus:O,style:Je,role:"region","aria-label":E},u.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],j=Array.isArray(t)?t:[],M=new Map,I=new Map,P=new Map,T=new Map;for(const e of j){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,r="object"==typeof t.source?null===(s=t.source)||void 0===s?void 0:s.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=r&&""!==r){const e=r+"";I.set(e,(null!==(l=I.get(e))&&void 0!==l?l:0)+1),T.set(e,(null!==(d=T.get(e))&&void 0!==d?d:0)+o)}if(null!=n&&""!==n){const e=n+"";M.set(e,(null!==(h=M.get(e))&&void 0!==h?h:0)+1),P.set(e,(null!==(y=P.get(e))&&void 0!==y?y:0)+o)}}const N=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const r=null!==(f=null===(g=t.datum)||void 0===g?void 0:g.id)&&void 0!==f?f:t.id,n=null!=r?r+"":"node-"+e,o=null!==(p=M.get(n))&&void 0!==p?p:0,i=null!==(m=I.get(n))&&void 0!==m?m:0,a=null!==(v=P.get(n))&&void 0!==v?v:0,s=null!==(b=T.get(n))&&void 0!==b?b:0;N.push({id:n,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}N.sort((e,t)=>t.degree-e.degree);let _=0,$=0;if(N.length>0){let e=0;for(const t of N)e+=t.degree,t.degree>$&&($=t.degree);_=e/N.length}const B=j.some(e=>{var t;const r=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==r?void 0:r.value)&&Number.isFinite(r.value)}),R=[`${N.length} nodes, ${j.length} edges.`];N.length>0&&R.push(`Mean degree: ${tt(_)}, max degree: ${$}.`);const W=N.slice(0,5);return u.createElement("div",{ref:L,id:n,tabIndex:-1,onBlur:D,style:rt,role:"region","aria-label":E},u.createElement("button",{type:"button",onClick:()=>{w&&A&&A.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:ot},"×"),u.createElement("div",{role:"note",style:nt},R.join(" ")),u.createElement("table",{role:"table","aria-label":"Node degree summary for "+r,style:it},u.createElement("caption",{style:ct},"Top ",W.length," of ",N.length," nodes by degree"),u.createElement("thead",null,u.createElement("tr",null,u.createElement("th",{style:at},"id"),u.createElement("th",{style:at},"degree"),u.createElement("th",{style:at},"in"),u.createElement("th",{style:at},"out"),B&&u.createElement("th",{style:at},"w. degree"),B&&u.createElement("th",{style:at},"w. in"),B&&u.createElement("th",{style:at},"w. out"))),u.createElement("tbody",null,W.map((e,t)=>u.createElement("tr",{key:t},u.createElement("td",{style:st},e.id),u.createElement("td",{style:st},e.degree),u.createElement("td",{style:st},e.inDeg),u.createElement("td",{style:st},e.outDeg),B&&u.createElement("td",{style:st},tt(e.wDegree)),B&&u.createElement("td",{style:st},tt(e.wInDeg)),B&&u.createElement("td",{style:st},tt(e.wOutDeg)))))))}function ut({summary:e}){return e?u.createElement("div",{role:"note",style:Je},e):null}function dt({tableId:e}){return u.createElement("a",{href:"#"+e,style:Je,onClick:t=>{t.preventDefault();const r=document.getElementById(e);r&&requestAnimationFrame(()=>r.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Je)}},"Skip to data table")}function ht({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:Je},t)}function yt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function gt(e,t,r=.3){yt(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 ft(e,t,r=.6){var n,o,i,a,s;if(!yt(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 pt(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 mt(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 vt(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 bt(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 xt={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},kt=n.schemeCategory10,At=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],wt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],St=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Et(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")||St.has(t)}(n)?r(n):n}const n=e[t];return r?r(n):kt[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+""))%kt.length]}function Lt(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=xt[r]||xt.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:kt;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function Ot(t){const r=e.createContext(null),n=Dt(t);return[function({children:n}){const o=e.useMemo(()=>Dt(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 Dt(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 Ct={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}},jt={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}},Mt={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"},[It,Pt]=Ot(e=>({theme:Ct,setTheme(t){e(e=>{if("light"===t)return{theme:Ct};if("dark"===t)return{theme:jt};if("high-contrast"===t)return{theme:Mt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?jt:Ct;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||{})})}})}})),Tt={top:20,right:80,bottom:20,left:80},Nt={top:40,right:40,bottom:40,left:40},_t=new Set(["chord","force","circlepack","orbit"]),$t=[800,600],Bt={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 Rt({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:Bt},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:Bt},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:Bt},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 Wt=e.forwardRef(function(t,r){var n,o,i,a,c,l,y,g,f,p,m,v,b,x;const{chartType:k,nodes:A,edges:w,data:S,initialEdges:E,nodeIDAccessor:L="id",sourceAccessor:O="source",targetAccessor:D="target",valueAccessor:C="value",childrenAccessor:j,hierarchySum:M,orientation:I="horizontal",nodeAlign:P="justify",nodePaddingRatio:T=.05,nodeWidth:N=15,iterations:_=300,forceStrength:$=.1,padAngle:B=.01,groupWidth:R=20,sortGroups:W,edgeSort:z,treeOrientation:H="vertical",edgeType:F="curve",padding:Y,paddingTop:q,tensionConfig:G,showParticles:X=!1,particleStyle:V,nodeStyle:K,edgeStyle:U,colorBy:Z,colorScheme:Q="category10",edgeColorBy:J="source",edgeOpacity:ee=.5,colorByDepth:te=!1,nodeSize:re=8,nodeSizeRange:ne=[5,20],nodeLabel:oe,showLabels:ie=!0,labelMode:ae,size:se=$t,responsiveWidth:ce,responsiveHeight:le,margin:ue,className:de,background:he,enableHover:ye=!0,tooltipContent:ge,customHoverBehavior:fe,customClickBehavior:pe,onObservation:me,chartId:ve,onTopologyChange:be,annotations:xe,svgAnnotationRules:ke,legend:Ae,legendPosition:we,legendHoverBehavior:Se,legendClickBehavior:Ee,legendHighlightedCategory:Le,legendIsolatedCategories:Oe,title:De,foregroundGraphics:je,backgroundGraphics:Me,decay:Pe,pulse:Te,staleness:Ne,thresholds:_e,accessibleTable:$e=!0,description:Re,summary:We,orbitMode:Fe,orbitSize:Ye,orbitSpeed:qe,orbitRevolution:Ge,orbitRevolutionStyle:Xe,orbitEccentricity:Ve,orbitShowRings:Qe,orbitAnimated:Je}=t,tt=function(){const[t,r]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return r(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>r(e.matches))},[]),t}(),rt=e.useRef(tt);rt.current=tt;const nt="semiotic-table-"+u.useId(),ot=_t.has(k)?Nt:Tt,[it,at]=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]]]}(se,ce,le),st=Object.assign(Object.assign({},ot),ue),ct=at[0]-st.left-st.right,yt=at[1]-st.top-st.bottom,xt="function"==typeof je?je({size:at,margin:st}):je,At=e.useMemo(()=>Object.assign(Object.assign({},d),G),[G]),wt=e.useMemo(()=>Object.assign(Object.assign({},h),V),[V]),St=e.useMemo(()=>({chartType:k,nodeIDAccessor:L,sourceAccessor:O,targetAccessor:D,valueAccessor:C,childrenAccessor:j,hierarchySum:M,orientation:I,nodeAlign:P,nodePaddingRatio:T,nodeWidth:N,iterations:_,forceStrength:$,padAngle:B,groupWidth:R,sortGroups:W,edgeSort:z,treeOrientation:H,edgeType:F,padding:Y,paddingTop:q,tensionConfig:At,showParticles:X,particleStyle:wt,nodeStyle:K,edgeStyle:U,nodeLabel:oe,showLabels:ie,labelMode:ae,colorBy:Z,colorScheme:Q,edgeColorBy:J,edgeOpacity:ee,colorByDepth:te,nodeSize:re,nodeSizeRange:ne,decay:Pe,pulse:Te,staleness:Ne,thresholds:_e,orbitMode:Fe,orbitSize:Ye,orbitSpeed:qe,orbitRevolution:Ge,orbitRevolutionStyle:Xe,orbitEccentricity:Ve,orbitShowRings:Qe,orbitAnimated:Je}),[k,L,O,D,C,j,M,I,P,T,N,_,$,B,R,W,z,H,F,Y,q,At,X,wt,K,U,oe,ie,ae,Z,Q,J,ee,te,re,ne,Pe,Te,Ne,_e,Fe,Ye,qe,Ge,Xe,Ve,Qe,Je]),Et=e.useRef(null),Lt=e.useRef(0),Ot=e.useRef(0),Dt=e.useRef(!0),Ct=Pt(e=>e.theme),jt=e.useRef(()=>{}),Mt=e.useRef(null);Mt.current||(Mt.current=new Ce(St));const[It,Bt]=e.useState(null),[Wt,zt]=e.useState(0),[Ht,Ft]=e.useState(0),[Yt,qt]=e.useState(!1),Gt=e.useRef(null),Xt=e.useRef(new Map),Vt=e.useRef(0),Kt=e.useCallback(e=>{if("function"==typeof Z)return Z(e)+"";if("string"==typeof Z&&e.data){const t=e.data[Z];if(void 0!==t){if(!Xt.current.has(t+"")){const e=Array.isArray(Q)?Q:kt;Xt.current.set(t+"",e[Vt.current++%e.length])}return Xt.current.get(t+"")}}if(Xt.current.has(e.id))return Xt.current.get(e.id);const t=Array.isArray(Q)?Q:kt,r=Z?t[Vt.current++%t.length]:t[0];return Xt.current.set(e.id,r),r},[Z,Q]),Ut=e.useCallback(e=>{if("function"==typeof J)return J(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===J&&r?Kt(r):t?Kt(t):"#999"},[J,Kt]),Zt=e.useCallback(e=>{if(!(null==V?void 0:V.colorBy))return Ut(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===wt.colorBy&&r?Kt(r):t?Kt(t):"#999"},[null==V?void 0:V.colorBy,wt.colorBy,Kt,Ut]),Qt="sankey"===k&&X||!!Te||null!==(o=null===(n=Mt.current)||void 0===n?void 0:n.isAnimating)&&void 0!==o&&o,Jt=e.useCallback(()=>{Lt.current&&!Qt||Lt.current||(Lt.current=requestAnimationFrame(()=>jt.current()))},[Qt]);e.useEffect(()=>{var e;null===(e=Mt.current)||void 0===e||e.updateConfig(St),Dt.current=!0,Jt()},[St,Jt]),e.useEffect(()=>{Dt.current=!0,Jt()},[Ct,Jt]);const er=e.useCallback(()=>{var e;const t=Mt.current;if(!t)return;t.runLayout([ct,yt]),t.buildScene([ct,yt]),Dt.current=!0;for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&Xt.current.set(r.id,r.style.fill);const r=Array.isArray(Q)?Q:kt,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Xt.current.has(t.id)||Xt.current.set(t.id,r[e%r.length])}if(Vt.current=n.length,zt(t.layoutVersion),be){const{nodes:e,edges:r}=t.getLayoutData();be(e,r)}},[ct,yt,be,Q]),tr=e.useCallback(e=>{const t=Mt.current;t&&(t.ingestEdge(e)&&er(),Jt())},[er,Jt]),rr=e.useCallback(e=>{const t=Mt.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&er(),Jt()},[er,Jt]),nr=e.useCallback(()=>{var e;null===(e=Mt.current)||void 0===e||e.clear(),Xt.current.clear(),Vt.current=0,zt(0),Bt(null),Gt.current=null,Dt.current=!0,Jt()},[Jt]),or=e.useCallback(()=>{const e=Mt.current;e&&(e.tension+=999,er(),Jt())},[er,Jt]);e.useImperativeHandle(r,()=>({push:tr,pushMany:rr,clear:nr,getTopology:()=>{var e,t;return null!==(t=null===(e=Mt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Mt.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:or,getTension:()=>{var e,t;return null!==(t=null===(e=Mt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[tr,rr,nr,or]);const ir=["tree","cluster","treemap","circlepack","partition","orbit"].includes(k),ar=ir?S||(Array.isArray(w)?void 0:w):void 0;e.useEffect(()=>{var e;const t=Mt.current;if(t)if(ir&&ar)t.ingestHierarchy(ar,[ct,yt]),t.buildScene([ct,yt]),Dt.current=!0,Jt();else{const r=A||[],n=Array.isArray(w)?w:[];if(0===r.length&&0===n.length)return;t.ingestBounded(r,n,[ct,yt]),t.buildScene([ct,yt]);for(const r of t.sceneNodes)r.id&&(null===(e=r.style)||void 0===e?void 0:e.fill)&&Xt.current.set(r.id,r.style.fill+"");const o=Array.isArray(Q)?Q:kt,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Xt.current.has(t.id)||Xt.current.set(t.id,o[e%o.length])}Vt.current=i.length,Dt.current=!0,Jt()}},[A,w,S,ar,ir,ct,yt,St,Jt,Q]),e.useEffect(()=>{E&&E.length>0&&rr(E)},[]);const sr=e.useCallback(e=>{if(fe&&fe(e),me){const t=Date.now();me(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ve}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ve})}},[fe,me,ve]),cr=e.useCallback(e=>{if(pe&&pe(e),me){const t=Date.now();me(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ve}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ve})}},[pe,me,ve]),lr=e.useRef(()=>{}),ur=e.useRef(()=>{});lr.current=e=>{if(!ye)return;const t=Et.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-st.left,o=e.clientY-r.top-st.top;if(0>n||n>ct||0>o||o>yt)return void(Gt.current&&(Gt.current=null,Bt(null),sr&&(sr(null),Dt.current=!0),Jt()));const i=Mt.current;if(!i)return;const a=Ie(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(Gt.current&&(Gt.current=null,Bt(null),sr&&(sr(null),Dt.current=!0),Jt()));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});Gt.current=c,Bt(c),sr&&(sr(c),Dt.current=!0),Jt()},ur.current=()=>{Gt.current&&(Gt.current=null,Bt(null),sr&&(sr(null),Dt.current=!0),Jt())};const dr=e.useRef(()=>{});dr.current=e=>{if(!pe&&!me)return;const t=Et.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-st.left,o=e.clientY-r.top-st.top;if(0>n||n>ct||0>o||o>yt)return;const i=Mt.current;if(!i)return;const a=Ie(i.sceneNodes,i.sceneEdges,n,o);if(a){const e=a.datum||{};cr(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 cr(null)},e.useCallback(e=>lr.current(e),[]);const hr=e.useCallback(()=>ur.current(),[]),yr=e.useCallback(e=>dr.current(e),[]),gr=e.useRef(-1),fr=e.useRef(null),pr=e.useRef(-1),mr=e.useCallback(e=>{var t;const r=Mt.current;if(!r)return;const n=function(e){var t,r,n,o,i,a;const s=[];for(const c of e)"circle"===c.type&&null!=c.cx?s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(r=null===(t=c.datum)||void 0===t?void 0:t.id)&&void 0!==r?r:"_default"}):"rect"===c.type&&null!=c.x?s.push({x:c.x+c.w/2,y:c.y+c.h/2,datum:c.datum,shape:"rect",w:c.w,h:c.h,group:null!==(o=null===(n=c.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:"_default"}):"arc"===c.type&&null!=c.cx&&s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(a=null===(i=c.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(r.sceneNodes);if(0===n.length)return;const o=function(e){var t,r;const n=new Map;for(const r of e){const e=null!==(t=r.group)&&void 0!==t?t:"_default";let o=n.get(e);o||(o=[],n.set(e,o)),o.push(r)}for(const e of n.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(n.keys()).sort((e,t)=>{const r=n.get(e),o=n.get(t);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(n.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(r=i[e].datum)||void 0===r?void 0:r.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:o,byGroup:n,idToIdx:a}}(n),i=gr.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),gr.current=0,pr.current=-1;const t=o.flat[0];fr.current={shape:t.shape,w:t.w,h:t.h};const r=t.datum||{},n=Object.assign(Object.assign({},"object"!=typeof r||null===r||Array.isArray(r)?{}:r),{type:"node",data:r,x:t.x,y:t.y});return Gt.current=n,Bt(n),sr&&(sr(n),Dt.current=!0),void Jt()}const a=function(e,t){var r,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(r=i.group)&&void 0!==r?r:"_default",indexInGroup:null!==(n=i._groupIndex)&&void 0!==n?n:0}}(o,i),s=function(e,t,r,n,o){var i,a,s;const c=r.flat[t.flatIndex];if(!c)return Be(e,t,r);const l=null===(i=c.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(a=function(e,t,r){let n=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,c=a.y-t.y;let l=!1;switch(r){case"right":l=s>0&&Math.abs(s)>=Math.abs(c);break;case"left":l=0>s&&Math.abs(s)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(s);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(s)}if(!l)continue;const u=s*s+c*c;o>u&&(o=u,n=i)}return n}(r,c,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return n!==t.flatIndex&&(o.current=-1),n}case"Enter":{if(null==l)return t.flatIndex;const e=function(e,t){var r,n,o;const i=e+"",a=[];for(const e of t){const t=null!==(r=e.datum)&&void 0!==r?r:e,s="object"==typeof t.source?null===(n=t.source)||void 0===n?void 0:n.id:t.source,c="object"==typeof t.target?null===(o=t.target)||void 0===o?void 0:o.id:t.target,l=null!=s,u=null!=c;l&&s+""===i&&u?a.push(c+""):u&&c+""===i&&l&&a.push(s+"")}return a}(l,n);if(0===e.length)return t.flatIndex;const i=null!==(s=r.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const n=Be(e,t,r);return null!==n&&n!==t.flatIndex&&(o.current=-1),n}}}(e.key,a,o,null!==(t=r.sceneEdges)&&void 0!==t?t:[],pr);if(null===s)return;if(e.preventDefault(),0>s)return gr.current=-1,fr.current=null,pr.current=-1,Gt.current=null,Bt(null),sr&&(sr(null),Dt.current=!0),void Jt();gr.current=s;const c=o.flat[s];fr.current={shape:c.shape,w:c.w,h:c.h};const l=c.datum||{},u=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:"node",data:l,x:c.x,y:c.y});Gt.current=u,Bt(u),sr&&(sr(u),Dt.current=!0),Jt()},[sr,Jt]),vr=e.useCallback(e=>{gr.current=-1,fr.current=null,lr.current(e)},[]);jt.current=()=>{var e,t,r,n,o,i,a;Lt.current=0;const s=Et.current;if(!s)return;const c=s.getContext("2d");if(!c)return;const l=Mt.current;if(!l)return;const u=performance.now(),d=Ot.current?Math.min((u-Ot.current)/1e3,.1):.016;Ot.current=u;const y=l.advanceTransition(rt.current?u+1e6:u),g=!rt.current&&y,f=!rt.current&&l.tickAnimation([ct,yt],d);(y||Dt.current||f)&&l.buildScene([ct,yt]);const p="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,at,st,p))return;c.clearRect(-st.left,-st.top,at[0],at[1]),he&&(c.fillStyle=he,c.fillRect(0,0,ct,yt)),Pe&&l.applyDecay(),Te&&l.applyPulse(u),_e&&l.applyThresholds(u),l.applyTopologyDiff(u);const m=null!==(e=null==Ne?void 0:Ne.threshold)&&void 0!==e?e:5e3,v=Ne&&l.lastIngestTime>0&&u-l.lastIngestTime>m;if(v&&(c.globalAlpha=null!==(t=null==Ne?void 0:Ne.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":pt(e,r);break;case"line":mt(e,r);break;case"ribbon":vt(e,r);break;case"curved":bt(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)),gt(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()),ft(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),X&&l.particlePool&&!v){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,wt);const t=.5*(null!==(r=wt.speedMultiplier)&&void 0!==r?r:1);let n;if(wt.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,wt,Zt)}}v&&(c.globalAlpha=1);const b=Dt.current;if(Dt.current=!1,b||g||f){const e=Et.current;e&&e.setAttribute("aria-label",et(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"))}(b||g||f)&&Ft(e=>e+1),(Qt||g||f||l.hasActivePulses||l.hasActiveThresholds||l.hasActiveTopologyDiff)&&(Lt.current=requestAnimationFrame(()=>jt.current()))},e.useEffect(()=>(Jt(),()=>{Lt.current&&(cancelAnimationFrame(Lt.current),Lt.current=0)}),[Jt]),e.useEffect(()=>{Dt.current=!0,Jt()},[k,ct,yt,he,Jt]),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])}(Ne,Mt,Dt,Jt,Yt,qt);const br=ye&&It?u.createElement(He,{x:It.x,y:It.y,containerWidth:ct,containerHeight:yt,margin:st,className:"stream-network-tooltip",zIndex:2},ge?ge(It):u.createElement(Rt,{data:It})):null;if(Ze){const e=Mt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(k),r=t?S||(Array.isArray(w)?void 0:w):void 0;if(t&&r)e.ingestHierarchy(r,[ct,yt]),e.buildScene([ct,yt]);else{const t=A||[],r=Array.isArray(w)?w:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[ct,yt]),e.buildScene([ct,yt]))}}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"+(de?" "+de:""),role:"img","aria-label":Re||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:at[0],height:at[1]}},u.createElement(ut,{summary:We}),u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:at[0],height:at[1],style:{position:"absolute",left:0,top:0}},Me&&u.createElement("g",{transform:`translate(${st.left},${st.top})`},Me),u.createElement("g",{transform:`translate(${st.left},${st.top})`},he&&u.createElement("rect",{x:0,y:0,width:ct,height:yt,fill:he}),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:Ue(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:Ue(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:Ue(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:Ue(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:Ue(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:Ue(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(Ke,{width:ct,height:yt,totalWidth:at[0],totalHeight:at[1],margin:st,labels:n,sceneNodes:t,title:De,legend:Ae,legendPosition:we,legendHoverBehavior:Se,legendClickBehavior:Ee,legendHighlightedCategory:Le,legendIsolatedCategories:Oe,foregroundGraphics:xt,annotations:xe,svgAnnotationRules:ke,annotationFrame:0}))}const xr=Mt.current;return u.createElement("div",{ref:it,className:"stream-network-frame"+(de?" "+de:""),role:"group","aria-label":Re||("string"==typeof De?De:"Network chart"),tabIndex:0,style:{position:"relative",width:ce?"100%":at[0],height:le?"100%":at[1],overflow:"visible"},onKeyDown:mr},$e&&u.createElement(dt,{tableId:nt}),$e&&u.createElement(lt,{nodes:null!==(l=null==xr?void 0:xr.sceneNodes)&&void 0!==l?l:[],edges:null!==(y=null==xr?void 0:xr.sceneEdges)&&void 0!==y?y:[],chartType:"Network chart",tableId:nt,chartTitle:"string"==typeof De?De:void 0}),u.createElement(ut,{summary:We}),u.createElement("div",{role:"img","aria-label":Re||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ye?vr:void 0,onMouseLeave:ye?hr:void 0,onClick:pe||me?yr:void 0},Me&&u.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:at[0],height:at[1],pointerEvents:"none",overflow:"visible"}},u.createElement("g",{transform:`translate(${st.left},${st.top})`},Me)),u.createElement("canvas",{ref:Et,"aria-label":et(null!==(f=null===(g=null==xr?void 0:xr.sceneNodes)||void 0===g?void 0:g.length)&&void 0!==f?f:0,null!==(m=null===(p=null==xr?void 0:xr.sceneEdges)||void 0===p?void 0:p.length)&&void 0!==m?m:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),u.createElement(ht,{hoverPoint:It}),u.createElement(Ke,{width:ct,height:yt,totalWidth:at[0],totalHeight:at[1],margin:st,labels:(null==xr?void 0:xr.labels)||[],sceneNodes:null==xr?void 0:xr.sceneNodes,title:De,legend:Ae,legendPosition:we,legendHoverBehavior:Se,legendClickBehavior:Ee,legendHighlightedCategory:Le,legendIsolatedCategories:Oe,foregroundGraphics:xt,annotations:xe,svgAnnotationRules:ke,annotationFrame:Ht}),u.createElement(ze,{active:gr.current>=0,hoverPoint:It,margin:st,size:at,shape:null===(v=fr.current)||void 0===v?void 0:v.shape,width:null===(b=fr.current)||void 0===b?void 0:b.w,height:null===(x=fr.current)||void 0===x?void 0:x.h}),br,(null==Ne?void 0:Ne.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ne.badgePosition?{top:4,left:4}:"bottom-left"===Ne.badgePosition?{bottom:4,left:4}:"bottom-right"===Ne.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Yt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Yt?"STALE":"LIVE")))});Wt.displayName="StreamNetworkFrame";const zt={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 Ht(e,t){return"function"==typeof t?t(e):e[t]}function Ft(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 Yt(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=Ht(e,r);a=Ft(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=Ht(e,o);s.push({label:r,value:Ft(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=Ft(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Ft(e[t[0]],n))}}const c=Object.assign(Object.assign({},zt),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 qt(e){if(!0===e)return Yt();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:zt},r)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Yt(e):Yt())}const Gt=e.createContext(null);function Xt(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 Vt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Kt,Ut]=Ot(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Vt(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=Vt(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}})}})),[Zt,Qt]=Ot(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let Jt={positions:new Map};const er=new Set;function tr(){for(const e of er)e()}function rr(e,t){const r=Jt.positions.get(e);if(!r||r.sourceId!==t)return;const n=new Map(Jt.positions);n.delete(e),Jt={positions:n},tr()}function nr(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=Ut(e=>e.selections.get(o)),a=Ut(e=>e.setClause),s=Ut(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(Xt(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 or=e.createContext(!1);function ir(){var e;const t=Pt(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 ar(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=xt[r];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function sr(t,r,n){const o=e.useContext(Gt),i=ir();return e.useMemo(()=>{var e;if(!r)return;const a=null!==(e=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof r){const e=Array.from(new Set(t.map(e=>r(e)+"")));if(o&&Object.keys(o).length>0){const t=Lt(e.map(e=>({_cat:e})),"_cat",a);return e=>o[e]||t(e)}return Lt(e.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const e=Lt(t,r,a);return t=>o[t]||e(t)}return Lt(t,r,a)}if(o&&Object.keys(o).length>0){const e=Lt([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[t,r,n,o,i])}function cr({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s,onClick:c}){const l=e.useId(),u=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||t||[],mode:e.mode,xField:e.xField}:null}(r,n),d=nr({name:(null==t?void 0:t.name)||"__unused__"}),h=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:a,clear:s}=nr({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==u?void 0:u.name)||"hover",fields:(null==u?void 0:u.fields)||n||[]}),y=Qt(e=>e.pushObservation),g=t?{isActive:d.isActive,predicate:d.predicate}:null,f=e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==u?void 0:u.mode)&&u.xField){const e=null==t?void 0:t[u.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,r){const n=Jt.positions.get(e);n&&n.xValue===t&&n.sourceId===r||(Jt={positions:new Map(Jt.positions).set(e,{xValue:t,sourceId:r})},tr())}(u.name||"hover",Number(e),l)}"x-position"!==(null==u?void 0:u.mode)&&h.onHover(t)}else"x-position"===(null==u?void 0:u.mode)&&rr(u.name||"hover",l),"x-position"!==(null==u?void 0:u.mode)&&h.onHover(null);if(i||y){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),y&&y(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),y&&y(e)}}},[r,h,u,l,i,a,s,y]),p=e.useCallback(e=>{var t,r,n,o;if(e&&c){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),c(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0})}if(i||y){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},t),{type:"click",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),y&&y(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),y&&y(e)}}},[c,i,y,a,s]);return e.useEffect(()=>{if("x-position"!==(null==u?void 0:u.mode))return;const e=u.name||"hover";return()=>{rr(e,l)}},[null==u?void 0:u.mode,null==u?void 0:u.name,l]),{activeSelectionHook:g,customHoverBehavior:f,customClickBehavior:p,crosshairSourceId:l}}function lr(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 ur={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 dr(e,t,r){var n,o,i,a,s,c;const l=ur[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,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,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:hr(l.marginDefaults,t.showCategoryTicks,t.orientation)}}function hr(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 yr({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 gr 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(yr,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function fr(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 pr(e,t,r=3){let n,o=r+1;for(const r of t){const t=fr(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}function mr(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function vr(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=pr(e,t,3))&&void 0!==r?r:null)}function br({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 xr({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=mr(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=vr(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const kr={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"},onClick:{type:"function"}},Ar={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},wr={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Sr=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Er=["vertical","horizontal"],Lr={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),Ar),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Sr},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({},kr),Ar),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Sr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),Ar),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Sr},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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},normalize:{type:"boolean"},barPadding:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Er},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{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({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},kr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},kr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{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"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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({},kr),{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({},kr),{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:Er},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({},kr),{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({},kr),{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({},kr),{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({},kr),{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({},kr),{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"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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 Or(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dr=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Cr=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),jr=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Mr=new Set(["LineChart","AreaChart","StackedAreaChart"]),Ir=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Pr(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 Tr(e,t){const r=Pr(e),n=Pr(t);return null===r||null===n?null:(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}const Nr=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function _r(e,t){const r=[],n=function(e,t){const r=[],n=Lr[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Lr).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(!Or(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=pr(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=mr(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=vr(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=br({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const o=xr({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 Lr[e]?(function(e,t,r){const n=Lr[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=Lr[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){Dr.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){Cr.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=Lr[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(!jr.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(!Mr.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=Lr[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(!Ir.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=Tr(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=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const o=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;const i=[];for(let e=0;o.length-1>e;e++){const t=Tr(o[e],o[e+1]);null!==t&&1.5>t&&i.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,r),function(e,t,r){const n="string"==typeof t.title&&t.title.trim().length>0,o="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;n||o||i||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,r),function(e,t,r){const n=[];for(const e of Nr)"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 $r;const Br="undefined"!=typeof process&&"production"!==(null===($r=process.env)||void 0===$r?void 0:$r.NODE_ENV);function Rr({componentName:e,width:t,height:r,chartProps:n,children:o}){return u.createElement(gr,{fallback:o=>{let i="";if(Br&&n)try{const t=_r(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(yr,{componentName:e,message:o.message,diagnosticHint:i,width:t,height:r})}},o)}const Wr={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"},zr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Hr(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({},Wr),{width:t,height:r})},n||"No data available"):null}function Fr(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({},zr),{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 Yr=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=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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,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,onClick:O,chartId:D,selection:C,linkedHover:j,loading:M,emptyContent:I,legendInteraction:P,legendPosition:T}=t,N=i.width,_=i.height,$=i.enableHover,B=i.showLegend,R=null!==(n=i.showLabels)&&void 0!==n&&n,W=i.title,z=i.description,H=i.summary,F=i.accessibleTable,Y=Fr(M,N,_),q=Y?null:Hr(a,N,_,I),G=a||[],X=s||[],V=sr(G,f,p),K=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of G){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[G,f]),U=lr(P,f,K),Z=ir(),Q=e.useMemo(()=>new Map,[]),J=e.useMemo(()=>{if(Array.isArray(p))return p;if(Z&&Z.length>0)return Z;const e=xt[p];return Array.isArray(e)?e:kt},[p,Z]),ee=e.useMemo(()=>e=>{const t={};return t.fill=f?Et(e.data||e,f,V):ar(0,Z,p),"number"==typeof m&&(t.r=m),t},[f,V,m,Z,p,Q]),te=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),re=e.useMemo(()=>{if(R&&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}},[R,g]),{legend:ne,margin:oe,legendPosition:ie}=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(or),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):At[i%At.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:Et,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:G,colorBy:f,colorScale:V,showLegend:B,legendPosition:T,userMargin:c,defaults:i.marginDefaults}),{customHoverBehavior:ae,customClickBehavior:se}=cr({selection:C,linkedHover:j,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,onClick:O,chartType:"ForceDirectedGraph",chartId:D}),ce=xr({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ce?u.createElement(yr,{componentName:"ForceDirectedGraph",message:ce,width:N,height:_}):Y||q||u.createElement(Rr,{componentName:"ForceDirectedGraph",width:N,height:_},u.createElement(Wt,Object.assign({ref:o,chartType:"force"},null!=a&&{nodes:G},null!=s&&{edges:X},{size:[N,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:oe,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:y,iterations:A,forceStrength:w,nodeStyle:ee,edgeStyle:te,colorBy:f,colorScheme:J,nodeSize:m,nodeSizeRange:v,nodeLabel:re,showLabels:R,enableHover:$,tooltipContent:!1===S?()=>null:qt(S)||void 0,customHoverBehavior:j||L||O?ae:void 0,customClickBehavior:L||O?se:void 0,legend:ne,legendPosition:ie},P&&"none"!==P&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories},{className:l,title:W,description:z,summary:H,accessibleTable:F},E)))});function qr(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 Xr(e){return"function"==typeof e?e:t=>t[e]||1}function Vr({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=Et(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=Et(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}}Yr.displayName="ForceDirectedGraph";const Kr=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=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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,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,onClick:D,chartId:C,selection:j,linkedHover:M,loading:I,emptyContent:P,legendInteraction:T}=t,N=i.width,_=i.height,$=i.enableHover,B=null===(n=i.showLabels)||void 0===n||n,R=i.title,W=i.description,z=i.summary,H=i.accessibleTable,F=Fr(I,N,_),Y=F?null:Hr(s,N,_,P),q=s||[],G=e.useMemo(()=>Gr(a,q,d,h),[a,q,d,h]),X=sr(G,f,p),V=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of G){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[G,f]),K=lr(T,f,V),U=ir(),Z=e.useMemo(()=>new Map,[]),Q=e.useMemo(()=>{if(Array.isArray(p))return p;if(U&&U.length>0)return U;const e=xt[p];return Array.isArray(e)?e:kt},[p,U]),J=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?Et(e.data||e,f,X):ar(0,U,p),t},[f,X,U,p,Z]),ee=e.useMemo(()=>Vr({edgeColorBy:m,colorBy:f,colorScale:X,nodeStyleFn:J,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,X,J,w]),te=e.useMemo(()=>{if(!B)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}},[B,A,g]),re=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:ne,customClickBehavior:oe}=cr({selection:j,linkedHover:M,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:O,onClick:D,chartType:"SankeyDiagram",chartId:C}),ie=xr({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ie?u.createElement(yr,{componentName:"SankeyDiagram",message:ie,width:N,height:_}):F||Y||u.createElement(Rr,{componentName:"SankeyDiagram",width:N,height:_},u.createElement(Wt,Object.assign({ref:o,chartType:"sankey"},G.length>0&&{nodes:G},null!=s&&{edges:q},{size:[N,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:J,edgeStyle:ee,colorBy:f,colorScheme:Q,edgeColorBy:m,edgeOpacity:w,edgeSort:S,nodeLabel:te,showLabels:B,enableHover:$,tooltipContent:!1===E?()=>null:qt(E)||void 0,customHoverBehavior:M||O||D?ne:void 0,customClickBehavior:O||D?oe:void 0},T&&"none"!==T&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories},{className:l,title:R,description:W,summary:z,accessibleTable:H},L)))});Kr.displayName="SankeyDiagram";const Ur=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=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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,edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:A=.5,tooltip:w,frameProps:S={},onObservation:E,onClick:L,chartId:O,selection:D,linkedHover:C,loading:j,emptyContent:M,legendInteraction:I}=t,P=i.width,T=i.height,N=i.enableHover,_=null===(n=i.showLabels)||void 0===n||n,$=i.title,B=i.description,R=i.summary,W=i.accessibleTable,z=Fr(j,P,T),H=z?null:Hr(s,P,T,M),F=s||[],Y=e.useMemo(()=>Gr(a,F,d,h),[a,F,d,h]),q=sr(Y,f,p),G=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of Y){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[Y,f]),X=lr(I,f,G),V=ir(),K=e.useMemo(()=>new Map,[]),U=e.useMemo(()=>{if(Array.isArray(p))return p;if(V&&V.length>0)return V;const e=xt[p];return Array.isArray(e)?e:kt},[p,V]),Z=Y.length>0,Q=e.useMemo(()=>{if(Z)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=Et(e.data||e,f,q);else{const i=Array.isArray(p)?p:xt[p]||kt,a=Array.isArray(i)?i:kt,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}},[Z,f,q,p]),J=e.useMemo(()=>{if(Z)return Vr({edgeColorBy:m,colorBy:f,colorScale:q,nodeStyleFn:Q||(e=>({fill:ar(0,V,p)})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[Z,m,f,q,Q,A,V,p,K]),ee=e.useMemo(()=>{if(!_)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}},[_,k,g]),te=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:re,customClickBehavior:ne}=cr({selection:D,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,onClick:L,chartType:"ChordDiagram",chartId:O}),oe=xr({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return oe?u.createElement(yr,{componentName:"ChordDiagram",message:oe,width:P,height:T}):z||H||u.createElement(Rr,{componentName:"ChordDiagram",width:P,height:T},u.createElement(Wt,Object.assign({ref:o,chartType:"chord"},Y.length>0&&{nodes:Y},null!=s&&{edges:F},{size:[P,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:Q,edgeStyle:J,colorBy:f,colorScheme:U,edgeColorBy:m,edgeOpacity:A,nodeLabel:ee,showLabels:_,enableHover:N,tooltipContent:!1===w?()=>null:qt(w)||void 0,customHoverBehavior:C||E||L?re:void 0,customClickBehavior:E||L?ne:void 0},I&&"none"!==I&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:l,title:$,description:B,summary:R,accessibleTable:W},S)))});function Zr(t){var r;const n=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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,colorByDepth:f=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,onClick:A,chartId:w,selection:S,linkedHover:E,loading:L,legendInteraction:O}=t,D=n.width,C=n.height,j=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,I=n.title,P=n.description,T=n.summary,N=n.accessibleTable,_=Fr(L,D,C),$=e.useMemo(()=>qr(null!=o?o:null,l),[o,l]),B=sr($,f?void 0:y,g),R=e.useMemo(()=>{if(!y||f)return[];const e=new Set;for(const t of $){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[$,y,f]),W=lr(O,f?void 0:y,R),z=ir(),H=e.useMemo(()=>new Map,[]),F=e.useMemo(()=>{if(Array.isArray(g))return g;if(z&&z.length>0)return z;const e=xt[g];return Array.isArray(e)?e:kt},[g,z]),Y=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?wt[(e.depth||0)%wt.length]:y?Et(e.data||e,y,B):ar(0,z,g),t},[y,f,B,z,g,H]),q=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),G=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return Xr(d)},[s,d]),X=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:V,customClickBehavior:K}=cr({selection:S,linkedHover:E,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:k,onClick:A,chartType:"TreeDiagram",chartId:w}),U=br({componentName:"TreeDiagram",data:o});return U?u.createElement(yr,{componentName:"TreeDiagram",message:U,width:D,height:C}):_||u.createElement(Rr,{componentName:"TreeDiagram",width:D,height:C},u.createElement(Wt,Object.assign({chartType:s},null!=o&&{data:o},{size:[D,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:G,treeOrientation:c,edgeType:p,nodeStyle:Y,edgeStyle:q,colorBy:y,colorScheme:F,colorByDepth:f,nodeSize:v,nodeLabel:M?m||h:void 0,showLabels:M,enableHover:j,tooltipContent:!1===b?()=>null:qt(b)||void 0,customHoverBehavior:E||k||A?V:void 0,customClickBehavior:k||A?K:void 0},O&&"none"!==O&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:I,description:P,summary:T,accessibleTable:N},x)))}function Qr(t){var r;const n=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,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,colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:f,padding:p=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:A,onClick:w,chartId:S,loading:E,legendInteraction:L}=t,O=n.width,D=n.height,C=n.enableHover,j=null===(r=n.showLabels)||void 0===r||r,M=n.title,I=n.description,P=n.summary,T=n.accessibleTable,N=Fr(E,O,D),{activeSelectionHook:_,customHoverBehavior:$,customClickBehavior:B}=cr({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:A,onClick:w,chartType:"Treemap",chartId:S}),R=e.useCallback(e=>{if(!e)return $(null);const t=e.data||e;$({data:(null==t?void 0:t.data)||t})},[$]),W=e.useMemo(()=>qr(null!=o?o:null,s),[o,s]),z=sr(W,y?void 0:d,h),H=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of W){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[W,d,y]),F=lr(L,y?void 0:d,H),Y=ir(),q=e.useMemo(()=>new Map,[]),G=e.useMemo(()=>{if(Array.isArray(h))return h;if(Y&&Y.length>0)return Y;const e=xt[h];return Array.isArray(e)?e:kt},[h,Y]),X=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?wt[(e.depth||0)%wt.length]:d?Et(e.data||e,d,z):ar(0,Y,h),t},[d,y,z,Y,h,q]),V=e.useMemo(()=>_?e=>{var t;const r=Object.assign({},X(e));if(_.isActive)if(_.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}:X,[X,_,x]),K=e.useMemo(()=>Xr(c),[c]),U=void 0!==m?m:!j||"parent"!==g&&"all"!==g?void 0:18,Z=Object.assign(Object.assign({},n.marginDefaults),i),Q=br({componentName:"Treemap",data:o});return Q?u.createElement(yr,{componentName:"Treemap",message:Q,width:O,height:D}):N||u.createElement(Rr,{componentName:"Treemap",width:O,height:D},u.createElement(Wt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[O,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:K,padding:p,paddingTop:U,nodeStyle:V,colorBy:d,colorScheme:G,colorByDepth:y,nodeLabel:j?f||l:void 0,showLabels:j,labelMode:g,enableHover:C,tooltipContent:!1===v?()=>null:qt(v)||void 0},(k||A||w)&&{customHoverBehavior:R},(A||w)&&{customClickBehavior:B},L&&"none"!==L&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:a,title:M,description:I,summary:P,accessibleTable:T},b)))}function Jr(t){var r;const n=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h,colorByDepth:y=!1,nodeLabel:g,circleOpacity:f=.7,padding:p=4,tooltip:m,frameProps:v={},onObservation:b,onClick:x,chartId:k,selection:A,linkedHover:w,loading:S,legendInteraction:E}=t,L=n.width,O=n.height,D=n.enableHover,C=null===(r=n.showLabels)||void 0===r||r,j=n.title,M=n.description,I=n.summary,P=n.accessibleTable,T=Fr(S,L,O),N=e.useMemo(()=>qr(null!=o?o:null,s),[o,s]),_=sr(N,y?void 0:d,h),$=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of N){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[N,d,y]),B=lr(E,y?void 0:d,$),R=ir(),W=e.useMemo(()=>new Map,[]),z=e.useMemo(()=>{if(Array.isArray(h))return h;if(R&&R.length>0)return R;const e=xt[h];return Array.isArray(e)?e:kt},[h,R]),H=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=y?wt[(e.depth||0)%wt.length]:d?Et(e.data||e,d,_):ar(0,R,h),t},[d,y,_,f,R,h,W]),F=e.useMemo(()=>Xr(c),[c]),Y=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:q,customClickBehavior:G}=cr({selection:A,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),X=br({componentName:"CirclePack",data:o});return X?u.createElement(yr,{componentName:"CirclePack",message:X,width:L,height:O}):T||u.createElement(Rr,{componentName:"CirclePack",width:L,height:O},u.createElement(Wt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:F,padding:p,nodeStyle:H,colorBy:d,colorScheme:z,colorByDepth:y,nodeLabel:C?g||l:void 0,showLabels:C,enableHover:D,tooltipContent:!1===m?()=>null:qt(m)||void 0,customHoverBehavior:w||b||x?q:void 0,customClickBehavior:b||x?G:void 0},E&&"none"!==E&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:j,description:M,summary:I,accessibleTable:P},v)))}Ur.displayName="ChordDiagram",Zr.displayName="TreeDiagram",Qr.displayName="Treemap",Jr.displayName="CirclePack";const en=wt;function tn(t){const r=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:n,margin:o,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:l,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,onClick:O,chartId:D,selection:C,linkedHover:j,loading:M}=t,I=r.width,P=r.height,T=r.enableHover,N=r.title,_=r.description,$=r.summary,B=r.accessibleTable,R=Fr(M,I,P),W=sr(e.useMemo(()=>qr(n,a),[n,a]),d?void 0:c,l),z=ir(),H=e.useMemo(()=>new Map,[]),F=e.useMemo(()=>{if(Array.isArray(l))return l;if(z&&z.length>0)return z;const e=xt[l];return Array.isArray(e)?e:kt},[l,z]),Y=e.useMemo(()=>{if(Array.isArray(l))return l;const e=xt[l];return Array.isArray(e)?e:kt},[l]),q=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?Y[0]:en[(e.depth||0)%en.length]:c?Et(e.data||e,c,W):ar(0,z,l),r.opacity=n?1:.85,r},[c,d,W,Y,z,l,H]),G=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),X=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:V,customClickBehavior:K}=cr({selection:C,linkedHover:j,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:L,onClick:O,chartType:"OrbitDiagram",chartId:D}),U=e.useMemo(()=>{if(V)return e=>{V(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[V]),Z=e.useMemo(()=>{if(K)return e=>{K(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[K]),Q=br({componentName:"OrbitDiagram",data:n});return Q?u.createElement(yr,{componentName:"OrbitDiagram",message:Q,width:I,height:P}):R||u.createElement(Rr,{componentName:"OrbitDiagram",width:I,height:P},u.createElement(Wt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[I,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:q,edgeStyle:G,colorBy:c,colorScheme:F,colorByDepth:d,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&T,tooltipContent:k?void 0:!1===A?()=>null:qt(A)||void 0,customHoverBehavior:j||L||O?U:void 0,customClickBehavior:L||O?Z:void 0,foregroundGraphics:w,annotations:S,className:i,title:N,description:_,summary:$,orbitMode:h,orbitSize:y,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:p,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:B},E)))}tn.displayName="OrbitDiagram",exports.ChordDiagram=Ur,exports.CirclePack=Jr,exports.ForceDirectedGraph=Yr,exports.OrbitDiagram=tn,exports.SankeyDiagram=Kr,exports.StreamNetworkFrame=Wt,exports.TreeDiagram=Zr,exports.Treemap=Qr;
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=p(c,l,u,d,s),y=d.x-c.x,g=d.y-c.y,f=Math.sqrt(y*y+g*g);if(f>.001){const e=y/f;h.x+=-g/f*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=p(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 p(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 f(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 p=y[g];if(0>r[p]){r[p]=n[p]=u,o[p]=!0,u+=1,c.push(p),l.push(p);break}o[p]&&(n[t]=0|Math.min(n[t],n[p])),0>a[p]||s[t].push(a[p])}i[t]=g}else{if(n[t]===r[t]){var f=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var b=c[g];if(o[b]=!1,f.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){c.length=g;break}}d.push(f);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 p=1;g.length>p;p++)g[p]!==g[p-1]&&l.push(g[p]);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 p=0;s[g].length>p;p++){var f=s[g][p];i[+f]=!1,a[f]={}}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 C(e.source)}function O(e){return C(e.target)}function C(e){return(e.y0+e.y1)/2}function D(e){return e.virtual?0:e.value}function j(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 M(e){return e.target.depth}function I(e,t){return e.sourceLinks.length?e.depth:t-1}function P(e,t){return e.y0-t.y0}function T(e,t){return t.y0-e.y0}function N(e,t){return e.y1-t.y1}function _(e,t){return t.y1-e.y1}function $(e,t){return R(e.source,t.source)||e.index-t.index}function B(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function W(e,t){return z(e)==z(t)?"bottom"==e.circularLinkType?T(e,t):P(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?T:P);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?_:N),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(W);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&&G(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 G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function X(e){return function(){return e}}function V(e){return e.index}function K(e){return e.nodes}function U(e){return e.links}function Z(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+=C(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=C(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?j(t,n)-j(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==j(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&&j(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-C(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),p=((y&&g?(y+g)/2:y||g)-C(i))*t;i.y0+=p,i.y1+=p}})})}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(B),e.targetLinks.sort($)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,c=V,l=I,u=void 0,d=32,h=2,y=K,g=U;function p(){var p={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=f(n,r)),"object"!=typeof o&&(o=e.target=f(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,D),r.sum(e.targetLinks,D)),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 p=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(p,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),Z(y,u,c),Q(y,u,c,g,g,d),J(y),Y(y,c,h,10,8),Z(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)}(p),p}return p.update=function(e){return J(e),Y(e,c,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(i=+e,p):i},p.nodePadding=function(e){return arguments.length?(a=+e,p):a},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(y="function"==typeof e?e:X(e),p):y},p.links=function(e){return arguments.length?(g="function"==typeof e?e:X(e),p):g},p.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:X(e),p):c},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:X(e),p):l},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}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=new Set,oe=new WeakMap;function ie(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=oe.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,oe.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;ne.has(e)||(ne.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}const ae={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(M))-1:0},justify:I},se={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,p=null!==(a=r.iterations)&&void 0!==a?a:100,f=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(f).nodeAlign(ae[h]||I).nodeId(e=>e.id).nodeWidth(y).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of f)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 f)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 f){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,p=new Map;e.forEach((e,t)=>{p.set(e.id,g[t%g.length])});const f=[],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(ie(t,"nodeStyle")):{},o={fill:n.fill||p.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};b.set(t.id,("string"==typeof o.fill?o.fill:null)||p.get(t.id)||"#4d430c"),f.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)||p.get(r.id)||n:b.get(t.id)||p.get(t.id)||n;const o=d?d(ie(e,"edgeStyle")):{};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:f,sceneEdges:m,labels:v}}},ce={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=le(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=ue(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=ue(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)))),p=y?40:g,f=de(r.nodeSize,r.nodeSizeRange,e),m=e=>f(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;p>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=de(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=[],p=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(ie(t,"nodeSize")),r=c?c(ie(t,"nodeStyle")):{},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 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);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=l?l(ie(e,"edgeStyle")):{},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(ie(r,"nodeSize"));p.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:p}}};function le(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 ue(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 de(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 he=n.schemeCategory10,ye={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 p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const f=e.length,m=Array.from({length:f},()=>Array.from({length:f},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=p.get("string"==typeof e.source?e.source:e.source.id),n=p.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,p=r.edgeColorBy||"source",f=Array.isArray(r.colorScheme)?r.colorScheme:he,m=new Map;e.forEach((e,t)=>{m.set(e.id,f[t%f.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(ie(r,"nodeStyle")).fill||m.get(r.id)||f[t%f.length]:m.get(r.id)||f[t%f.length];const a=y?y(ie(r,"nodeStyle")):{},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=ge(r,d,h);let o="#999";if(g)o=g(ie(e,"edgeStyle")).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===p&&r?o=m.get(r.id)||o:t&&(o=m.get(t.id)||o)}const a=g?g(ie(e,"edgeStyle")):{},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 ge(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const pe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function fe(e){const[t,r,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}function me(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 ve(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 be(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}`}}const xe={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),l=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=c.hierarchy(i,s);u.sum(l),u.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[d,h]=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)}(u,r,d,h);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)}(u,r,d,h);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)}(u,r,d,h);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)}(u,r,d,h);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)}(u,r,d,h)}const y=u.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],i={id:me(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?ke(i,n,r):"treemap"===a||"partition"===a?Ae(i,n):"circlepack"===a&&we(i,n),i.__hierarchyNode=n,e.push(i),g.set(n,i)}if("tree"===a||"cluster"===a)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,s,c,l,u;const d=[],h=[],y=[],g=r.treeOrientation||"vertical",p="radial"===g,f=n[0]/2,m=n[1]/2,v="number"==typeof(b=r.nodeSize)?b:5;var b;for(const t of e){let e=t.x,n=t.y;p&&(e+=f,n+=m);const i=o(ie(t,"nodeStyle"));let s=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(s=pe[t.depth%pe.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 x=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;p&&(n+=f,o+=m,a+=f,s+=m);const u=be(n,o,a,s,g),d=i(ie(e,"edgeStyle")),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:x};h.push({type:"curved",pathD:u,style:y,datum:e})}if(!1!==r.showLabels){const t=ve(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(p&&(a+=f,s+=m),p){const e=a-f,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=[];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(ie(r,"nodeStyle"));let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=pe[r.depth%pe.length]);const l={fill:c,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:l,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=ve(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,l=c.y1-c.y0;if(0>=e||0>=l)continue;const u=!((null===(i=c.data)||void 0===i?void 0:i.children)&&c.data.children.length>0);if(!a){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=r?r(c):c.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>l)continue;let h=n(ie(c,"nodeStyle")).fill||"#4d430c";t.colorByDepth&&void 0!==c.depth&&(h=pe[c.depth%pe.length]);const y=fe(h);s.push(u?{x:c.x0+e/2,y:c.y0+l/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}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=[];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const s=n(ie(r,"nodeStyle"));let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=pe[r.depth%pe.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=ve(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(ie(o,"nodeStyle")).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(l=pe[o.depth%pe.length]),a){const t=fe(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 ke(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 Ae(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 we(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 Se(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Ee={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,p=Se(r);p.metaMap.clear(),n.length=0,o.length=0;const f=new Map;function m(e){var t;const r=null!==(t=f.get(e))&&void 0!==t?t:0;return f.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}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,f){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=f?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),C=O(A),D=g(E);for(let t=0;A.length>t;t++){const s=(C[t].startAngle+C[t].endAngle)/2,c=A[t],u=m(l(c)),d=i+L*Math.sin(s),y=a+L*Math.cos(s)*D;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}),p.metaMap.set(u,{ring:L,angle:s,depth:h,parentId:r,eccentricity:D}),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=Se(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(ie(t,"nodeSize")),r=l?l(ie(t,"nodeStyle")):{},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 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);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(ie(r,"nodeSize"));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=Se(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)},Le={sankey:se,force:ce,chord:ye,tree:xe,cluster:xe,treemap:xe,circlepack:xe,partition:xe,orbit:Ee};function Oe(e){return Le[e]}function Ce(e,t,r){return e+(t-e)*r}class De{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({},je(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({},je(n)),{data:r})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},je(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,je(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,je(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=Oe(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=Oe(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=Oe(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=Oe(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=Ce(e._prevX0,e._targetX0,r),e.x1=Ce(e._prevX1,e._targetX1,r),e.y0=Ce(e._prevY0,e._targetY0,r),e.y1=Ce(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=Ce(e._prevY0,e._targetY0,r),e.y1=Ce(e._prevY1,e._targetY1,r),e.sankeyWidth=Ce(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 je(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 Me(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Ie(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=Pe(t,r,n,o);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=$e(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Pe(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i),s=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,n);return a>s?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=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=Me(Math.atan2(o,n)),s=Me(e.startAngle),c=Me(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 Te=null,Ne=null;function _e(){return Ne||(Te=document.createElement("canvas"),Te.width=1,Te.height=1,Ne=Te.getContext("2d")),Ne}function $e(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=_e();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=_e();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}}function Be(e,t,r){const{group:n,indexInGroup:o}=t,i=r.byGroup.get(n);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=r.groups.indexOf(n);return r.groups.length-1>e?Re(r,r.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=r.groups.indexOf(n);return e>0?Re(r,r.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*r.flat.length)),r.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*r.flat.length)),0);case"Home":return 0;case"End":return r.flat.length-1;case"Escape":return-1;default:return null}}function Re(e,t,r){const n=e.byGroup.get(t);let o=0,i=Math.abs(n[0].x-r.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-r.x);i>t&&(i=t,o=e)}return n[o]._flatIndex}const We="var(--semiotic-focus, #005fcc)";function ze({active:e,hoverPoint:t,margin:r,size:n,shape:o="circle",width:i,height:a}){if(!e||!t)return null;const s=t.x+r.left,c=t.y+r.top;let l;if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);l=u.createElement("rect",{x:s-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:We,strokeWidth:2,strokeDasharray:"4,2"})}else l=u.createElement("circle","wedge"===o?{cx:s,cy:c,r:12,fill:"none",stroke:We,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:We,strokeWidth:2,strokeDasharray:"4,2"});return u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:n[0],height:n[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},l)}function He({x:e,y:t,containerWidth:r,containerHeight:n,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const c=u.useRef(null),[l,d]=u.useState(null);u.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,r,n]);let h;return h=l?`translate(${l.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${l.height+12>n-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*n>t?"4px":"calc(-100% - 4px)"})`,u.createElement("div",{ref:c,className:a,style:{position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"}},i)}const Fe={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 Ye(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Fe[r])(n(e,t)),o}function qe(){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 Ge(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Xe({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 Ve(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,p]=u.useState(0),f=u.useCallback((e,t)=>{y(e),p(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 p=0;const f=!(!t&&!r),m="isolate"===l||void 0===l&&null!=o;return y.forEach((e,l)=>{const v=Ye(e,l,d,h),b=Ge(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:f?s===i&&l===a?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:f?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:f?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&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(qe,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=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:f,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 g=0;e.label&&(g+=16);const p=((e,t,r,n,o,i,a,s,c,l,d)=>{const{type:h="fill",styleFn:y,items:g}=e,p=[];let f=0,m=0;const v=!(!t&&!r),b="isolate"===l||void 0===l&&null!=o;g.forEach((e,l)=>{const x=Ye(e,l,h,y),k=Ge(e,n,o),A=o&&o.size>0&&o.has(e.label),w=26+7*e.label.length;d&&d>0&&f>0&&f+w>d&&(m++,f=0),p.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${f},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:v?s===i&&l===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?A||!1:void 0,"aria-current":v&&!b&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:v?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)+g.length)%g.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:v?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&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"}),x,A&&u.createElement(qe,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=w});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const A=m+1;return{items:p,offset:x,totalRows:A,totalHeight:22*A}})(e,n,o,i,a,s,c,t,l,d,r);g+=p.offset+5,y.push(Object.assign(Object.assign({label:e.label},p),{offset:g,totalRows:p.totalRows,totalHeight:p.totalHeight})),h+=g+12});let g=h>r?0:Math.max(0,(r-h)/2);const p=[];return y.forEach((r,n)=>{const o=e[n];o.label&&(p.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),p.push(u.createElement("g",{key:"legend-group-"+n,className:"legend-item",transform:`translate(${g},0)`},r.items)),g+=r.offset+5,e[n+1]&&p.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+n,stroke:"gray",x1:g,y1:-8,x2:g,y2:(r.totalHeight||t)+0+8})),g+=12}),u.createElement("g",null,p)})({legendGroups:t||[],title:s,height:l,width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:f,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 Ke(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:p,sceneNodes:f,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:f});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),p),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,p;return"left"===i?(g=4,p=o.top):"top"===i?(g=0,p=a?32:8):"bottom"===i?(g=0,p=n-o.bottom+50):(g=r-o.right+10,p=o.top),u.createElement("g",{transform:`translate(${g}, ${p})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?u.createElement(Xe,{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(Ve,{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&&f).map((e,t)=>{var r,n,o,a,s,c,l,d,h;const y=f.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),p=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:p+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Ue(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}Ke.displayName="NetworkSVGOverlay";const Ze="undefined"==typeof window||"undefined"==typeof document,Qe=u.createContext(null),Je={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function et(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(", ")}`}const tt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},rt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},nt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},ot={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},it={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},at={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},st={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ct={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function lt({nodes:e,edges:t,chartType:r,tableId:n,chartTitle:o}){var i,a,s,c,l,d,h,y,g,p,f,m,v,b;const[x,k]=u.useState(!1),A=u.useContext(Qe),w=null!==(i=null==A?void 0:A.visible)&&void 0!==i&&i,S=x||w,E=o?"Data summary for "+o:n?`Data summary for ${r} ${n}`:"Data summary for "+r,L=u.useRef(null),O=u.useCallback(()=>{x||w||k(!0)},[x,w]),C=u.useCallback(e=>{var t;w||(null===(t=L.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[w]);if(!e||0===e.length)return n?u.createElement("span",{id:n,tabIndex:-1,style:Je}):null;if(!S)return u.createElement("div",{id:n,tabIndex:-1,onFocus:O,style:Je,role:"region","aria-label":E},u.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const D=Array.isArray(e)?e:[],j=Array.isArray(t)?t:[],M=new Map,I=new Map,P=new Map,T=new Map;for(const e of j){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,r="object"==typeof t.source?null===(s=t.source)||void 0===s?void 0:s.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=r&&""!==r){const e=r+"";I.set(e,(null!==(l=I.get(e))&&void 0!==l?l:0)+1),T.set(e,(null!==(d=T.get(e))&&void 0!==d?d:0)+o)}if(null!=n&&""!==n){const e=n+"";M.set(e,(null!==(h=M.get(e))&&void 0!==h?h:0)+1),P.set(e,(null!==(y=P.get(e))&&void 0!==y?y:0)+o)}}const N=[];for(let e=0;D.length>e;e++){const t=D[e];if(!t||"object"!=typeof t)continue;const r=null!==(p=null===(g=t.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:t.id,n=null!=r?r+"":"node-"+e,o=null!==(f=M.get(n))&&void 0!==f?f:0,i=null!==(m=I.get(n))&&void 0!==m?m:0,a=null!==(v=P.get(n))&&void 0!==v?v:0,s=null!==(b=T.get(n))&&void 0!==b?b:0;N.push({id:n,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}N.sort((e,t)=>t.degree-e.degree);let _=0,$=0;if(N.length>0){let e=0;for(const t of N)e+=t.degree,t.degree>$&&($=t.degree);_=e/N.length}const B=j.some(e=>{var t;const r=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==r?void 0:r.value)&&Number.isFinite(r.value)}),R=[`${N.length} nodes, ${j.length} edges.`];N.length>0&&R.push(`Mean degree: ${tt(_)}, max degree: ${$}.`);const W=N.slice(0,5);return u.createElement("div",{ref:L,id:n,tabIndex:-1,onBlur:C,style:rt,role:"region","aria-label":E},u.createElement("button",{type:"button",onClick:()=>{w&&A&&A.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:ot},"×"),u.createElement("div",{role:"note",style:nt},R.join(" ")),u.createElement("table",{role:"table","aria-label":"Node degree summary for "+r,style:it},u.createElement("caption",{style:ct},"Top ",W.length," of ",N.length," nodes by degree"),u.createElement("thead",null,u.createElement("tr",null,u.createElement("th",{style:at},"id"),u.createElement("th",{style:at},"degree"),u.createElement("th",{style:at},"in"),u.createElement("th",{style:at},"out"),B&&u.createElement("th",{style:at},"w. degree"),B&&u.createElement("th",{style:at},"w. in"),B&&u.createElement("th",{style:at},"w. out"))),u.createElement("tbody",null,W.map((e,t)=>u.createElement("tr",{key:t},u.createElement("td",{style:st},e.id),u.createElement("td",{style:st},e.degree),u.createElement("td",{style:st},e.inDeg),u.createElement("td",{style:st},e.outDeg),B&&u.createElement("td",{style:st},tt(e.wDegree)),B&&u.createElement("td",{style:st},tt(e.wInDeg)),B&&u.createElement("td",{style:st},tt(e.wOutDeg)))))))}function ut({summary:e}){return e?u.createElement("div",{role:"note",style:Je},e):null}function dt({tableId:e}){return u.createElement("a",{href:"#"+e,style:Je,onClick:t=>{t.preventDefault();const r=document.getElementById(e);r&&requestAnimationFrame(()=>r.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Je)}},"Skip to data table")}function ht({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:Je},t)}function yt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function gt(e,t,r=.3){yt(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 pt(e,t,r=.6){var n,o,i,a,s;if(!yt(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 ft(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 mt(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 vt(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 bt(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 xt={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},kt=n.schemeCategory10,At=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],wt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],St=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Et(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")||St.has(t)}(n)?r(n):n}const n=e[t];return r?r(n):kt[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+""))%kt.length]}function Lt(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=xt[r]||xt.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:kt;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function Ot(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 Dt={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}},jt={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}},Mt={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"},[It,Pt]=Ot(e=>({theme:Dt,setTheme(t){e(e=>{if("light"===t)return{theme:Dt};if("dark"===t)return{theme:jt};if("high-contrast"===t)return{theme:Mt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?jt:Dt;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||{})})}})}})),Tt={top:20,right:80,bottom:20,left:80},Nt={top:40,right:40,bottom:40,left:40},_t=new Set(["chord","force","circlepack","orbit"]),$t=[800,600],Bt={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 Rt({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:Bt},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:Bt},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:Bt},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 Wt=e.forwardRef(function(t,r){var n,o,i,a,c,l,y,g,p,f,m,v,b,x;const{chartType:k,nodes:A,edges:w,data:S,initialEdges:E,nodeIDAccessor:L="id",sourceAccessor:O="source",targetAccessor:C="target",valueAccessor:D="value",childrenAccessor:j,hierarchySum:M,orientation:I="horizontal",nodeAlign:P="justify",nodePaddingRatio:T=.05,nodeWidth:N=15,iterations:_=300,forceStrength:$=.1,padAngle:B=.01,groupWidth:R=20,sortGroups:W,edgeSort:z,treeOrientation:H="vertical",edgeType:F="curve",padding:Y,paddingTop:q,tensionConfig:G,showParticles:X=!1,particleStyle:V,nodeStyle:K,edgeStyle:U,colorBy:Z,colorScheme:Q="category10",edgeColorBy:J="source",edgeOpacity:ee=.5,colorByDepth:te=!1,nodeSize:re=8,nodeSizeRange:ne=[5,20],nodeLabel:oe,showLabels:ie=!0,labelMode:ae,size:se=$t,responsiveWidth:ce,responsiveHeight:le,margin:ue,className:de,background:he,enableHover:ye=!0,tooltipContent:ge,customHoverBehavior:pe,customClickBehavior:fe,onObservation:me,chartId:ve,onTopologyChange:be,annotations:xe,svgAnnotationRules:ke,legend:Ae,legendPosition:we,legendHoverBehavior:Se,legendClickBehavior:Ee,legendHighlightedCategory:Le,legendIsolatedCategories:Oe,title:Ce,foregroundGraphics:je,backgroundGraphics:Me,decay:Pe,pulse:Te,staleness:Ne,thresholds:_e,accessibleTable:$e=!0,description:Re,summary:We,orbitMode:Fe,orbitSize:Ye,orbitSpeed:qe,orbitRevolution:Ge,orbitRevolutionStyle:Xe,orbitEccentricity:Ve,orbitShowRings:Qe,orbitAnimated:Je}=t,tt=function(){const[t,r]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return r(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>r(e.matches))},[]),t}(),rt=e.useRef(tt);rt.current=tt;const nt="semiotic-table-"+u.useId(),ot=_t.has(k)?Nt:Tt,[it,at]=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]]]}(se,ce,le),st=Object.assign(Object.assign({},ot),ue),ct=at[0]-st.left-st.right,yt=at[1]-st.top-st.bottom,xt="function"==typeof je?je({size:at,margin:st}):je,At=e.useMemo(()=>Object.assign(Object.assign({},d),G),[G]),wt=e.useMemo(()=>Object.assign(Object.assign({},h),V),[V]),St=e.useMemo(()=>({chartType:k,nodeIDAccessor:L,sourceAccessor:O,targetAccessor:C,valueAccessor:D,childrenAccessor:j,hierarchySum:M,orientation:I,nodeAlign:P,nodePaddingRatio:T,nodeWidth:N,iterations:_,forceStrength:$,padAngle:B,groupWidth:R,sortGroups:W,edgeSort:z,treeOrientation:H,edgeType:F,padding:Y,paddingTop:q,tensionConfig:At,showParticles:X,particleStyle:wt,nodeStyle:K,edgeStyle:U,nodeLabel:oe,showLabels:ie,labelMode:ae,colorBy:Z,colorScheme:Q,edgeColorBy:J,edgeOpacity:ee,colorByDepth:te,nodeSize:re,nodeSizeRange:ne,decay:Pe,pulse:Te,staleness:Ne,thresholds:_e,orbitMode:Fe,orbitSize:Ye,orbitSpeed:qe,orbitRevolution:Ge,orbitRevolutionStyle:Xe,orbitEccentricity:Ve,orbitShowRings:Qe,orbitAnimated:Je}),[k,L,O,C,D,j,M,I,P,T,N,_,$,B,R,W,z,H,F,Y,q,At,X,wt,K,U,oe,ie,ae,Z,Q,J,ee,te,re,ne,Pe,Te,Ne,_e,Fe,Ye,qe,Ge,Xe,Ve,Qe,Je]),Et=e.useRef(null),Lt=e.useRef(0),Ot=e.useRef(0),Ct=e.useRef(!0),Dt=Pt(e=>e.theme),jt=e.useRef(()=>{}),Mt=e.useRef(null);Mt.current||(Mt.current=new De(St));const[It,Bt]=e.useState(null),[Wt,zt]=e.useState(0),[Ht,Ft]=e.useState(0),[Yt,qt]=e.useState(!1),Gt=e.useRef(null),Xt=e.useRef(new Map),Vt=e.useRef(0),Kt=e.useCallback(e=>{if("function"==typeof Z)return Z(e)+"";if("string"==typeof Z&&e.data){const t=e.data[Z];if(void 0!==t){if(!Xt.current.has(t+"")){const e=Array.isArray(Q)?Q:kt;Xt.current.set(t+"",e[Vt.current++%e.length])}return Xt.current.get(t+"")}}if(Xt.current.has(e.id))return Xt.current.get(e.id);const t=Array.isArray(Q)?Q:kt,r=Z?t[Vt.current++%t.length]:t[0];return Xt.current.set(e.id,r),r},[Z,Q]),Ut=e.useCallback(e=>{if("function"==typeof J)return J(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===J&&r?Kt(r):t?Kt(t):"#999"},[J,Kt]),Zt=e.useCallback(e=>{if(!(null==V?void 0:V.colorBy))return Ut(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===wt.colorBy&&r?Kt(r):t?Kt(t):"#999"},[null==V?void 0:V.colorBy,wt.colorBy,Kt,Ut]),Qt="sankey"===k&&X||!!Te||null!==(o=null===(n=Mt.current)||void 0===n?void 0:n.isAnimating)&&void 0!==o&&o,Jt=e.useCallback(()=>{Lt.current&&!Qt||Lt.current||(Lt.current=requestAnimationFrame(()=>jt.current()))},[Qt]);e.useEffect(()=>{var e;null===(e=Mt.current)||void 0===e||e.updateConfig(St),Ct.current=!0,Jt()},[St,Jt]),e.useEffect(()=>{Ct.current=!0,Jt()},[Dt,Jt]);const er=e.useCallback(()=>{var e;const t=Mt.current;if(!t)return;t.runLayout([ct,yt]),t.buildScene([ct,yt]),Ct.current=!0;for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&Xt.current.set(r.id,r.style.fill);const r=Array.isArray(Q)?Q:kt,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Xt.current.has(t.id)||Xt.current.set(t.id,r[e%r.length])}if(Vt.current=n.length,zt(t.layoutVersion),be){const{nodes:e,edges:r}=t.getLayoutData();be(e,r)}},[ct,yt,be,Q]),tr=e.useCallback(e=>{const t=Mt.current;t&&(t.ingestEdge(e)&&er(),Jt())},[er,Jt]),rr=e.useCallback(e=>{const t=Mt.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&er(),Jt()},[er,Jt]),nr=e.useCallback(()=>{var e;null===(e=Mt.current)||void 0===e||e.clear(),Xt.current.clear(),Vt.current=0,zt(0),Bt(null),Gt.current=null,Ct.current=!0,Jt()},[Jt]),or=e.useCallback(()=>{const e=Mt.current;e&&(e.tension+=999,er(),Jt())},[er,Jt]);e.useImperativeHandle(r,()=>({push:tr,pushMany:rr,clear:nr,getTopology:()=>{var e,t;return null!==(t=null===(e=Mt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Mt.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:or,getTension:()=>{var e,t;return null!==(t=null===(e=Mt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[tr,rr,nr,or]);const ir=["tree","cluster","treemap","circlepack","partition","orbit"].includes(k),ar=ir?S||(Array.isArray(w)?void 0:w):void 0;e.useEffect(()=>{var e;const t=Mt.current;if(t)if(ir&&ar)t.ingestHierarchy(ar,[ct,yt]),t.buildScene([ct,yt]),Ct.current=!0,Jt();else{const r=A||[],n=Array.isArray(w)?w:[];if(0===r.length&&0===n.length)return;t.ingestBounded(r,n,[ct,yt]),t.buildScene([ct,yt]);for(const r of t.sceneNodes)r.id&&(null===(e=r.style)||void 0===e?void 0:e.fill)&&Xt.current.set(r.id,r.style.fill+"");const o=Array.isArray(Q)?Q:kt,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Xt.current.has(t.id)||Xt.current.set(t.id,o[e%o.length])}Vt.current=i.length,Ct.current=!0,Jt()}},[A,w,S,ar,ir,ct,yt,St,Jt,Q]),e.useEffect(()=>{E&&E.length>0&&rr(E)},[]);const sr=e.useCallback(e=>{if(pe&&pe(e),me){const t=Date.now();me(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ve}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ve})}},[pe,me,ve]),cr=e.useCallback(e=>{if(fe&&fe(e),me){const t=Date.now();me(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ve}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ve})}},[fe,me,ve]),lr=e.useRef(()=>{}),ur=e.useRef(()=>{});lr.current=e=>{if(!ye)return;const t=Et.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-st.left,o=e.clientY-r.top-st.top;if(0>n||n>ct||0>o||o>yt)return void(Gt.current&&(Gt.current=null,Bt(null),sr&&(sr(null),Ct.current=!0),Jt()));const i=Mt.current;if(!i)return;const a=Ie(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(Gt.current&&(Gt.current=null,Bt(null),sr&&(sr(null),Ct.current=!0),Jt()));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});Gt.current=c,Bt(c),sr&&(sr(c),Ct.current=!0),Jt()},ur.current=()=>{Gt.current&&(Gt.current=null,Bt(null),sr&&(sr(null),Ct.current=!0),Jt())};const dr=e.useRef(()=>{});dr.current=e=>{if(!fe&&!me)return;const t=Et.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-st.left,o=e.clientY-r.top-st.top;if(0>n||n>ct||0>o||o>yt)return;const i=Mt.current;if(!i)return;const a=Ie(i.sceneNodes,i.sceneEdges,n,o);if(a){const e=a.datum||{};cr(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 cr(null)},e.useCallback(e=>lr.current(e),[]);const hr=e.useCallback(()=>ur.current(),[]),yr=e.useCallback(e=>dr.current(e),[]),gr=e.useRef(-1),pr=e.useRef(null),fr=e.useRef(-1),mr=e.useCallback(e=>{var t;const r=Mt.current;if(!r)return;const n=function(e){var t,r,n,o,i,a;const s=[];for(const c of e)"circle"===c.type&&null!=c.cx?s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(r=null===(t=c.datum)||void 0===t?void 0:t.id)&&void 0!==r?r:"_default"}):"rect"===c.type&&null!=c.x?s.push({x:c.x+c.w/2,y:c.y+c.h/2,datum:c.datum,shape:"rect",w:c.w,h:c.h,group:null!==(o=null===(n=c.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:"_default"}):"arc"===c.type&&null!=c.cx&&s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(a=null===(i=c.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(r.sceneNodes);if(0===n.length)return;const o=function(e){var t,r;const n=new Map;for(const r of e){const e=null!==(t=r.group)&&void 0!==t?t:"_default";let o=n.get(e);o||(o=[],n.set(e,o)),o.push(r)}for(const e of n.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(n.keys()).sort((e,t)=>{const r=n.get(e),o=n.get(t);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(n.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(r=i[e].datum)||void 0===r?void 0:r.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:o,byGroup:n,idToIdx:a}}(n),i=gr.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),gr.current=0,fr.current=-1;const t=o.flat[0];pr.current={shape:t.shape,w:t.w,h:t.h};const r=t.datum||{},n=Object.assign(Object.assign({},"object"!=typeof r||null===r||Array.isArray(r)?{}:r),{type:"node",data:r,x:t.x,y:t.y});return Gt.current=n,Bt(n),sr&&(sr(n),Ct.current=!0),void Jt()}const a=function(e,t){var r,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(r=i.group)&&void 0!==r?r:"_default",indexInGroup:null!==(n=i._groupIndex)&&void 0!==n?n:0}}(o,i),s=function(e,t,r,n,o){var i,a,s;const c=r.flat[t.flatIndex];if(!c)return Be(e,t,r);const l=null===(i=c.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(a=function(e,t,r){let n=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,c=a.y-t.y;let l=!1;switch(r){case"right":l=s>0&&Math.abs(s)>=Math.abs(c);break;case"left":l=0>s&&Math.abs(s)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(s);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(s)}if(!l)continue;const u=s*s+c*c;o>u&&(o=u,n=i)}return n}(r,c,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return n!==t.flatIndex&&(o.current=-1),n}case"Enter":{if(null==l)return t.flatIndex;const e=function(e,t){var r,n,o;const i=e+"",a=[];for(const e of t){const t=null!==(r=e.datum)&&void 0!==r?r:e,s="object"==typeof t.source?null===(n=t.source)||void 0===n?void 0:n.id:t.source,c="object"==typeof t.target?null===(o=t.target)||void 0===o?void 0:o.id:t.target,l=null!=s,u=null!=c;l&&s+""===i&&u?a.push(c+""):u&&c+""===i&&l&&a.push(s+"")}return a}(l,n);if(0===e.length)return t.flatIndex;const i=null!==(s=r.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const n=Be(e,t,r);return null!==n&&n!==t.flatIndex&&(o.current=-1),n}}}(e.key,a,o,null!==(t=r.sceneEdges)&&void 0!==t?t:[],fr);if(null===s)return;if(e.preventDefault(),0>s)return gr.current=-1,pr.current=null,fr.current=-1,Gt.current=null,Bt(null),sr&&(sr(null),Ct.current=!0),void Jt();gr.current=s;const c=o.flat[s];pr.current={shape:c.shape,w:c.w,h:c.h};const l=c.datum||{},u=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:"node",data:l,x:c.x,y:c.y});Gt.current=u,Bt(u),sr&&(sr(u),Ct.current=!0),Jt()},[sr,Jt]),vr=e.useCallback(e=>{gr.current=-1,pr.current=null,lr.current(e)},[]);jt.current=()=>{var e,t,r,n,o,i,a;Lt.current=0;const s=Et.current;if(!s)return;const c=s.getContext("2d");if(!c)return;const l=Mt.current;if(!l)return;const u=performance.now(),d=Ot.current?Math.min((u-Ot.current)/1e3,.1):.016;Ot.current=u;const y=l.advanceTransition(rt.current?u+1e6:u),g=!rt.current&&y,p=!rt.current&&l.tickAnimation([ct,yt],d);(y||Ct.current||p)&&l.buildScene([ct,yt]);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,at,st,f))return;c.clearRect(-st.left,-st.top,at[0],at[1]),he&&(c.fillStyle=he,c.fillRect(0,0,ct,yt)),Pe&&l.applyDecay(),Te&&l.applyPulse(u),_e&&l.applyThresholds(u),l.applyTopologyDiff(u);const m=null!==(e=null==Ne?void 0:Ne.threshold)&&void 0!==e?e:5e3,v=Ne&&l.lastIngestTime>0&&u-l.lastIngestTime>m;if(v&&(c.globalAlpha=null!==(t=null==Ne?void 0:Ne.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":ft(e,r);break;case"line":mt(e,r);break;case"ribbon":vt(e,r);break;case"curved":bt(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)),gt(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()),pt(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),X&&l.particlePool&&!v){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,wt);const t=.5*(null!==(r=wt.speedMultiplier)&&void 0!==r?r:1);let n;if(wt.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,wt,Zt)}}v&&(c.globalAlpha=1);const b=Ct.current;if(Ct.current=!1,b||g||p){const e=Et.current;e&&e.setAttribute("aria-label",et(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"))}(b||g||p)&&Ft(e=>e+1),(Qt||g||p||l.hasActivePulses||l.hasActiveThresholds||l.hasActiveTopologyDiff)&&(Lt.current=requestAnimationFrame(()=>jt.current()))},e.useEffect(()=>(Jt(),()=>{Lt.current&&(cancelAnimationFrame(Lt.current),Lt.current=0)}),[Jt]),e.useEffect(()=>{Ct.current=!0,Jt()},[k,ct,yt,he,Jt]),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])}(Ne,Mt,Ct,Jt,Yt,qt);const br=ye&&It?u.createElement(He,{x:It.x,y:It.y,containerWidth:ct,containerHeight:yt,margin:st,className:"stream-network-tooltip",zIndex:2},ge?ge(It):u.createElement(Rt,{data:It})):null;if(Ze){const e=Mt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(k),r=t?S||(Array.isArray(w)?void 0:w):void 0;if(t&&r)e.ingestHierarchy(r,[ct,yt]),e.buildScene([ct,yt]);else{const t=A||[],r=Array.isArray(w)?w:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[ct,yt]),e.buildScene([ct,yt]))}}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"+(de?" "+de:""),role:"img","aria-label":Re||("string"==typeof Ce?Ce:"Network chart"),style:{position:"relative",width:at[0],height:at[1]}},u.createElement(ut,{summary:We}),u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:at[0],height:at[1],style:{position:"absolute",left:0,top:0}},Me&&u.createElement("g",{transform:`translate(${st.left},${st.top})`},Me),u.createElement("g",{transform:`translate(${st.left},${st.top})`},he&&u.createElement("rect",{x:0,y:0,width:ct,height:yt,fill:he}),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:Ue(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:Ue(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:Ue(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:Ue(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:Ue(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:Ue(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(Ke,{width:ct,height:yt,totalWidth:at[0],totalHeight:at[1],margin:st,labels:n,sceneNodes:t,title:Ce,legend:Ae,legendPosition:we,legendHoverBehavior:Se,legendClickBehavior:Ee,legendHighlightedCategory:Le,legendIsolatedCategories:Oe,foregroundGraphics:xt,annotations:xe,svgAnnotationRules:ke,annotationFrame:0}))}const xr=Mt.current;return u.createElement("div",{ref:it,className:"stream-network-frame"+(de?" "+de:""),role:"group","aria-label":Re||("string"==typeof Ce?Ce:"Network chart"),tabIndex:0,style:{position:"relative",width:ce?"100%":at[0],height:le?"100%":at[1],overflow:"visible"},onKeyDown:mr},$e&&u.createElement(dt,{tableId:nt}),$e&&u.createElement(lt,{nodes:null!==(l=null==xr?void 0:xr.sceneNodes)&&void 0!==l?l:[],edges:null!==(y=null==xr?void 0:xr.sceneEdges)&&void 0!==y?y:[],chartType:"Network chart",tableId:nt,chartTitle:"string"==typeof Ce?Ce:void 0}),u.createElement(ut,{summary:We}),u.createElement("div",{role:"img","aria-label":Re||("string"==typeof Ce?Ce:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ye?vr:void 0,onMouseLeave:ye?hr:void 0,onClick:fe||me?yr:void 0},Me&&u.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:at[0],height:at[1],pointerEvents:"none",overflow:"visible"}},u.createElement("g",{transform:`translate(${st.left},${st.top})`},Me)),u.createElement("canvas",{ref:Et,"aria-label":et(null!==(p=null===(g=null==xr?void 0:xr.sceneNodes)||void 0===g?void 0:g.length)&&void 0!==p?p:0,null!==(m=null===(f=null==xr?void 0:xr.sceneEdges)||void 0===f?void 0:f.length)&&void 0!==m?m:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),u.createElement(ht,{hoverPoint:It}),u.createElement(Ke,{width:ct,height:yt,totalWidth:at[0],totalHeight:at[1],margin:st,labels:(null==xr?void 0:xr.labels)||[],sceneNodes:null==xr?void 0:xr.sceneNodes,title:Ce,legend:Ae,legendPosition:we,legendHoverBehavior:Se,legendClickBehavior:Ee,legendHighlightedCategory:Le,legendIsolatedCategories:Oe,foregroundGraphics:xt,annotations:xe,svgAnnotationRules:ke,annotationFrame:Ht}),u.createElement(ze,{active:gr.current>=0,hoverPoint:It,margin:st,size:at,shape:null===(v=pr.current)||void 0===v?void 0:v.shape,width:null===(b=pr.current)||void 0===b?void 0:b.w,height:null===(x=pr.current)||void 0===x?void 0:x.h}),br,(null==Ne?void 0:Ne.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ne.badgePosition?{top:4,left:4}:"bottom-left"===Ne.badgePosition?{bottom:4,left:4}:"bottom-right"===Ne.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Yt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Yt?"STALE":"LIVE")))});Wt.displayName="StreamNetworkFrame";const zt={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 Ht(e,t){return"function"==typeof t?t(e):e[t]}function Ft(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 Yt(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=Ht(e,r);a=Ft(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=Ht(e,o);s.push({label:r,value:Ft(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=Ft(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Ft(e[t[0]],n))}}const c=Object.assign(Object.assign({},zt),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 qt(e){if(!0===e)return Yt();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:zt},r)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Yt(e):Yt())}const Gt=e.createContext(null);function Xt(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 Vt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Kt,Ut]=Ot(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Vt(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=Vt(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}})}})),[Zt,Qt]=Ot(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let Jt={positions:new Map};const er=new Set;function tr(){for(const e of er)e()}function rr(e,t){const r=Jt.positions.get(e);if(null==r?void 0:r.locked)return;if(!r||r.sourceId!==t)return;const n=new Map(Jt.positions);n.delete(e),Jt={positions:n},tr()}function nr(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=Ut(e=>e.selections.get(o)),a=Ut(e=>e.setClause),s=Ut(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(Xt(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 or=e.createContext(!1);function ir(){var e;const t=Pt(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 ar(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=xt[r];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function sr(t,r,n){const o=e.useContext(Gt),i=ir();return e.useMemo(()=>{var e;if(!r)return;const a=null!==(e=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof r){const e=Array.from(new Set(t.map(e=>r(e)+"")));if(o&&Object.keys(o).length>0){const t=Lt(e.map(e=>({_cat:e})),"_cat",a);return e=>o[e]||t(e)}return Lt(e.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const e=Lt(t,r,a);return t=>o[t]||e(t)}return Lt(t,r,a)}if(o&&Object.keys(o).length>0){const e=Lt([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[t,r,n,o,i])}function cr({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s,onClick:c,hoverHighlight:l,colorByField:u}){const d=e.useId(),h=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||t||[],mode:e.mode,xField:e.xField}:null}(r,n),y=nr({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:a,clear:s}=nr({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==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),p=Qt(e=>e.pushObservation),f=t?{isActive:y.isActive,predicate:y.predicate}:null,[m,v]=e.useState(null),b=u||n[0],x=e.useMemo(()=>{if(!l||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:r=>{var n;return("string"==typeof r[t]?r[t]:(null!==(n=r[t])&&void 0!==n?n:"")+"")===e}}},[l,m,b]),k=e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,r){const n=Jt.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===r||(Jt={positions:new Map(Jt.positions).set(e,{xValue:t,sourceId:r})},tr())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&rr(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(l&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[b];v(null!=r?r+"":null)}else v(null);if(i||p){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),p&&p(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),p&&p(e)}}},[r,g,h,d,i,a,s,p,l,b]),A=e.useCallback(e=>{var t,r,n,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[h.xField];null!=r&&Number.isFinite(Number(r))&&function(e,t,r){const n=Jt.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(Jt.positions);return t.delete(e),Jt={positions:t},tr(),!1}Jt={positions:new Map(Jt.positions).set(e,{xValue:t,sourceId:r,locked:!0})},tr()}(h.name||"hover",Number(r),d)}if(e&&c){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),c(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0})}if(i||p){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},t),{type:"click",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[c,i,p,a,s,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{!function(e,t){const r=Jt.positions.get(e);if(!(null==r?void 0:r.locked))return;if(t&&r.sourceId!==t)return;const n=new Map(Jt.positions);n.delete(e),Jt={positions:n},tr()}(e,d),rr(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:f,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:A,crosshairSourceId:d}}function lr(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 ur={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 dr(e,t,r){var n,o,i,a,s,c;const l=ur[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,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,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:hr(l.marginDefaults,t.showCategoryTicks,t.orientation)}}function hr(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 yr({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 gr 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(yr,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function pr(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 fr(e,t,r=3){let n,o=r+1;for(const r of t){const t=pr(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}function mr(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function vr(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=fr(e,t,3))&&void 0!==r?r:null)}function br({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 xr({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=mr(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=vr(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const kr={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"},onClick:{type:"function"}},Ar={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},wr={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Sr=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Er=["vertical","horizontal"],Lr={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),Ar),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Sr},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({},kr),Ar),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Sr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),Ar),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Sr},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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),Ar),{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({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},normalize:{type:"boolean"},barPadding:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Er},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{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({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Er},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},kr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},kr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},kr),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{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"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},kr),wr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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({},kr),{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({},kr),{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:Er},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({},kr),{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({},kr),{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({},kr),{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({},kr),{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({},kr),{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"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},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 Or(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Cr=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Dr=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),jr=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Mr=new Set(["LineChart","AreaChart","StackedAreaChart"]),Ir=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Pr(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 Tr(e,t){const r=Pr(e),n=Pr(t);return null===r||null===n?null:(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}const Nr=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function _r(e,t){const r=[],n=function(e,t){const r=[],n=Lr[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Lr).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(!Or(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=fr(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=mr(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=vr(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=br({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const o=xr({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 Lr[e]?(function(e,t,r){const n=Lr[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=Lr[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){Cr.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){Dr.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=Lr[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(!jr.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(!Mr.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=Lr[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(!Ir.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=Tr(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=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const o=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;const i=[];for(let e=0;o.length-1>e;e++){const t=Tr(o[e],o[e+1]);null!==t&&1.5>t&&i.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,r),function(e,t,r){const n="string"==typeof t.title&&t.title.trim().length>0,o="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;n||o||i||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,r),function(e,t,r){const n=[];for(const e of Nr)"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 $r;const Br="undefined"!=typeof process&&"production"!==(null===($r=process.env)||void 0===$r?void 0:$r.NODE_ENV);function Rr({componentName:e,width:t,height:r,chartProps:n,children:o}){return u.createElement(gr,{fallback:o=>{let i="";if(Br&&n)try{const t=_r(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(yr,{componentName:e,message:o.message,diagnosticHint:i,width:t,height:r})}},o)}const Wr={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"},zr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Hr(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({},Wr),{width:t,height:r})},n||"No data available"):null}function Fr(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({},zr),{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 Yr=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=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:c,className:l,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:y="target",nodeLabel:g,colorBy:p,colorScheme:f,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,onClick:O,chartId:C,selection:D,linkedHover:j,loading:M,emptyContent:I,legendInteraction:P,legendPosition:T}=t,N=i.width,_=i.height,$=i.enableHover,B=i.showLegend,R=null!==(n=i.showLabels)&&void 0!==n&&n,W=i.title,z=i.description,H=i.summary,F=i.accessibleTable,Y=Fr(M,N,_),q=Y?null:Hr(a,N,_,I),G=a||[],X=s||[],V=sr(G,p,f),K=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of G){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[G,p]),U=lr(P,p,K),Z=ir(),Q=e.useMemo(()=>new Map,[]),J=e.useMemo(()=>{if(Array.isArray(f))return f;if(Z&&Z.length>0)return Z;const e=xt[f];return Array.isArray(e)?e:kt},[f,Z]),ee=e.useMemo(()=>e=>{const t={};return t.fill=p?Et(e.data||e,p,V):ar(0,Z,f),"number"==typeof m&&(t.r=m),t},[p,V,m,Z,f,Q]),te=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),re=e.useMemo(()=>{if(R&&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}},[R,g]),{legend:ne,margin:oe,legendPosition:ie}=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(or),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):At[i%At.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:Et,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:G,colorBy:p,colorScale:V,showLegend:B,legendPosition:T,userMargin:c,defaults:i.marginDefaults}),{customHoverBehavior:ae,customClickBehavior:se}=cr({selection:D,linkedHover:j,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:L,onClick:O,chartType:"ForceDirectedGraph",chartId:C}),ce=xr({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ce?u.createElement(yr,{componentName:"ForceDirectedGraph",message:ce,width:N,height:_}):Y||q||u.createElement(Rr,{componentName:"ForceDirectedGraph",width:N,height:_},u.createElement(Wt,Object.assign({ref:o,chartType:"force"},null!=a&&{nodes:G},null!=s&&{edges:X},{size:[N,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:oe,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:y,iterations:A,forceStrength:w,nodeStyle:ee,edgeStyle:te,colorBy:p,colorScheme:J,nodeSize:m,nodeSizeRange:v,nodeLabel:re,showLabels:R,enableHover:$,tooltipContent:!1===S?()=>null:qt(S)||void 0,customHoverBehavior:j||L||O?ae:void 0,customClickBehavior:L||O?se:void 0,legend:ne,legendPosition:ie},P&&"none"!==P&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories},{className:l,title:W,description:z,summary:H,accessibleTable:F},E)))});function qr(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 Xr(e){return"function"==typeof e?e:t=>t[e]||1}function Vr({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=Et(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=Et(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}}Yr.displayName="ForceDirectedGraph";const Kr=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=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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:p,colorScheme:f,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,onClick:C,chartId:D,selection:j,linkedHover:M,loading:I,emptyContent:P,legendInteraction:T}=t,N=i.width,_=i.height,$=i.enableHover,B=null===(n=i.showLabels)||void 0===n||n,R=i.title,W=i.description,z=i.summary,H=i.accessibleTable,F=Fr(I,N,_),Y=F?null:Hr(s,N,_,P),q=s||[],G=e.useMemo(()=>Gr(a,q,d,h),[a,q,d,h]),X=sr(G,p,f),V=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of G){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[G,p]),K=lr(T,p,V),U=ir(),Z=e.useMemo(()=>new Map,[]),Q=e.useMemo(()=>{if(Array.isArray(f))return f;if(U&&U.length>0)return U;const e=xt[f];return Array.isArray(e)?e:kt},[f,U]),J=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?Et(e.data||e,p,X):ar(0,U,f),t},[p,X,U,f,Z]),ee=e.useMemo(()=>Vr({edgeColorBy:m,colorBy:p,colorScale:X,nodeStyleFn:J,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[m,p,X,J,w]),te=e.useMemo(()=>{if(!B)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}},[B,A,g]),re=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:ne,customClickBehavior:oe}=cr({selection:j,linkedHover:M,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:O,onClick:C,chartType:"SankeyDiagram",chartId:D}),ie=xr({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ie?u.createElement(yr,{componentName:"SankeyDiagram",message:ie,width:N,height:_}):F||Y||u.createElement(Rr,{componentName:"SankeyDiagram",width:N,height:_},u.createElement(Wt,Object.assign({ref:o,chartType:"sankey"},G.length>0&&{nodes:G},null!=s&&{edges:q},{size:[N,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:J,edgeStyle:ee,colorBy:p,colorScheme:Q,edgeColorBy:m,edgeOpacity:w,edgeSort:S,nodeLabel:te,showLabels:B,enableHover:$,tooltipContent:!1===E?()=>null:qt(E)||void 0,customHoverBehavior:M||O||C?ne:void 0,customClickBehavior:O||C?oe:void 0},T&&"none"!==T&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories},{className:l,title:R,description:W,summary:z,accessibleTable:H},L)))});Kr.displayName="SankeyDiagram";const Ur=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=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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:p,colorScheme:f,edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:A=.5,tooltip:w,frameProps:S={},onObservation:E,onClick:L,chartId:O,selection:C,linkedHover:D,loading:j,emptyContent:M,legendInteraction:I}=t,P=i.width,T=i.height,N=i.enableHover,_=null===(n=i.showLabels)||void 0===n||n,$=i.title,B=i.description,R=i.summary,W=i.accessibleTable,z=Fr(j,P,T),H=z?null:Hr(s,P,T,M),F=s||[],Y=e.useMemo(()=>Gr(a,F,d,h),[a,F,d,h]),q=sr(Y,p,f),G=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Y){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[Y,p]),X=lr(I,p,G),V=ir(),K=e.useMemo(()=>new Map,[]),U=e.useMemo(()=>{if(Array.isArray(f))return f;if(V&&V.length>0)return V;const e=xt[f];return Array.isArray(e)?e:kt},[f,V]),Z=Y.length>0,Q=e.useMemo(()=>{if(Z)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(p)o.fill=Et(e.data||e,p,q);else{const i=Array.isArray(f)?f:xt[f]||kt,a=Array.isArray(i)?i:kt,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}},[Z,p,q,f]),J=e.useMemo(()=>{if(Z)return Vr({edgeColorBy:m,colorBy:p,colorScale:q,nodeStyleFn:Q||(e=>({fill:ar(0,V,f)})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[Z,m,p,q,Q,A,V,f,K]),ee=e.useMemo(()=>{if(!_)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}},[_,k,g]),te=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:re,customClickBehavior:ne}=cr({selection:C,linkedHover:D,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:E,onClick:L,chartType:"ChordDiagram",chartId:O}),oe=xr({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return oe?u.createElement(yr,{componentName:"ChordDiagram",message:oe,width:P,height:T}):z||H||u.createElement(Rr,{componentName:"ChordDiagram",width:P,height:T},u.createElement(Wt,Object.assign({ref:o,chartType:"chord"},Y.length>0&&{nodes:Y},null!=s&&{edges:F},{size:[P,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:Q,edgeStyle:J,colorBy:p,colorScheme:U,edgeColorBy:m,edgeOpacity:A,nodeLabel:ee,showLabels:_,enableHover:N,tooltipContent:!1===w?()=>null:qt(w)||void 0,customHoverBehavior:D||E||L?re:void 0,customClickBehavior:E||L?ne:void 0},I&&"none"!==I&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:l,title:$,description:B,summary:R,accessibleTable:W},S)))});function Zr(t){var r;const n=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{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,colorByDepth:p=!1,edgeStyle:f="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,onClick:A,chartId:w,selection:S,linkedHover:E,loading:L,legendInteraction:O}=t,C=n.width,D=n.height,j=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,I=n.title,P=n.description,T=n.summary,N=n.accessibleTable,_=Fr(L,C,D),$=e.useMemo(()=>qr(null!=o?o:null,l),[o,l]),B=sr($,p?void 0:y,g),R=e.useMemo(()=>{if(!y||p)return[];const e=new Set;for(const t of $){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[$,y,p]),W=lr(O,p?void 0:y,R),z=ir(),H=e.useMemo(()=>new Map,[]),F=e.useMemo(()=>{if(Array.isArray(g))return g;if(z&&z.length>0)return z;const e=xt[g];return Array.isArray(e)?e:kt},[g,z]),Y=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?wt[(e.depth||0)%wt.length]:y?Et(e.data||e,y,B):ar(0,z,g),t},[y,p,B,z,g,H]),q=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),G=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return Xr(d)},[s,d]),X=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:V,customClickBehavior:K}=cr({selection:S,linkedHover:E,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:k,onClick:A,chartType:"TreeDiagram",chartId:w}),U=br({componentName:"TreeDiagram",data:o});return U?u.createElement(yr,{componentName:"TreeDiagram",message:U,width:C,height:D}):_||u.createElement(Rr,{componentName:"TreeDiagram",width:C,height:D},u.createElement(Wt,Object.assign({chartType:s},null!=o&&{data:o},{size:[C,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:G,treeOrientation:c,edgeType:f,nodeStyle:Y,edgeStyle:q,colorBy:y,colorScheme:F,colorByDepth:p,nodeSize:v,nodeLabel:M?m||h:void 0,showLabels:M,enableHover:j,tooltipContent:!1===b?()=>null:qt(b)||void 0,customHoverBehavior:E||k||A?V:void 0,customClickBehavior:k||A?K:void 0},O&&"none"!==O&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:I,description:P,summary:T,accessibleTable:N},x)))}function Qr(t){var r;const n=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,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,colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:p,padding:f=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:A,onClick:w,chartId:S,loading:E,legendInteraction:L}=t,O=n.width,C=n.height,D=n.enableHover,j=null===(r=n.showLabels)||void 0===r||r,M=n.title,I=n.description,P=n.summary,T=n.accessibleTable,N=Fr(E,O,C),{activeSelectionHook:_,customHoverBehavior:$,customClickBehavior:B}=cr({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:A,onClick:w,chartType:"Treemap",chartId:S}),R=e.useCallback(e=>{if(!e)return $(null);const t=e.data||e;$({data:(null==t?void 0:t.data)||t})},[$]),W=e.useMemo(()=>qr(null!=o?o:null,s),[o,s]),z=sr(W,y?void 0:d,h),H=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of W){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[W,d,y]),F=lr(L,y?void 0:d,H),Y=ir(),q=e.useMemo(()=>new Map,[]),G=e.useMemo(()=>{if(Array.isArray(h))return h;if(Y&&Y.length>0)return Y;const e=xt[h];return Array.isArray(e)?e:kt},[h,Y]),X=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?wt[(e.depth||0)%wt.length]:d?Et(e.data||e,d,z):ar(0,Y,h),t},[d,y,z,Y,h,q]),V=e.useMemo(()=>_?e=>{var t;const r=Object.assign({},X(e));if(_.isActive)if(_.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}:X,[X,_,x]),K=e.useMemo(()=>Xr(c),[c]),U=void 0!==m?m:!j||"parent"!==g&&"all"!==g?void 0:18,Z=Object.assign(Object.assign({},n.marginDefaults),i),Q=br({componentName:"Treemap",data:o});return Q?u.createElement(yr,{componentName:"Treemap",message:Q,width:O,height:C}):N||u.createElement(Rr,{componentName:"Treemap",width:O,height:C},u.createElement(Wt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[O,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:K,padding:f,paddingTop:U,nodeStyle:V,colorBy:d,colorScheme:G,colorByDepth:y,nodeLabel:j?p||l:void 0,showLabels:j,labelMode:g,enableHover:D,tooltipContent:!1===v?()=>null:qt(v)||void 0},(k||A||w)&&{customHoverBehavior:R},(A||w)&&{customClickBehavior:B},L&&"none"!==L&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:a,title:M,description:I,summary:P,accessibleTable:T},b)))}function Jr(t){var r;const n=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h,colorByDepth:y=!1,nodeLabel:g,circleOpacity:p=.7,padding:f=4,tooltip:m,frameProps:v={},onObservation:b,onClick:x,chartId:k,selection:A,linkedHover:w,loading:S,legendInteraction:E}=t,L=n.width,O=n.height,C=n.enableHover,D=null===(r=n.showLabels)||void 0===r||r,j=n.title,M=n.description,I=n.summary,P=n.accessibleTable,T=Fr(S,L,O),N=e.useMemo(()=>qr(null!=o?o:null,s),[o,s]),_=sr(N,y?void 0:d,h),$=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of N){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[N,d,y]),B=lr(E,y?void 0:d,$),R=ir(),W=e.useMemo(()=>new Map,[]),z=e.useMemo(()=>{if(Array.isArray(h))return h;if(R&&R.length>0)return R;const e=xt[h];return Array.isArray(e)?e:kt},[h,R]),H=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:p};return t.fill=y?wt[(e.depth||0)%wt.length]:d?Et(e.data||e,d,_):ar(0,R,h),t},[d,y,_,p,R,h,W]),F=e.useMemo(()=>Xr(c),[c]),Y=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:q,customClickBehavior:G}=cr({selection:A,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),X=br({componentName:"CirclePack",data:o});return X?u.createElement(yr,{componentName:"CirclePack",message:X,width:L,height:O}):T||u.createElement(Rr,{componentName:"CirclePack",width:L,height:O},u.createElement(Wt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[L,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:F,padding:f,nodeStyle:H,colorBy:d,colorScheme:z,colorByDepth:y,nodeLabel:D?g||l:void 0,showLabels:D,enableHover:C,tooltipContent:!1===m?()=>null:qt(m)||void 0,customHoverBehavior:w||b||x?q:void 0,customClickBehavior:b||x?G:void 0},E&&"none"!==E&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:j,description:M,summary:I,accessibleTable:P},v)))}Ur.displayName="ChordDiagram",Zr.displayName="TreeDiagram",Qr.displayName="Treemap",Jr.displayName="CirclePack";const en=wt;function tn(t){const r=dr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:n,margin:o,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:l,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:y=2.95,speed:g=.25,revolution:p,revolutionStyle:f,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,onClick:O,chartId:C,selection:D,linkedHover:j,loading:M}=t,I=r.width,P=r.height,T=r.enableHover,N=r.title,_=r.description,$=r.summary,B=r.accessibleTable,R=Fr(M,I,P),W=sr(e.useMemo(()=>qr(n,a),[n,a]),d?void 0:c,l),z=ir(),H=e.useMemo(()=>new Map,[]),F=e.useMemo(()=>{if(Array.isArray(l))return l;if(z&&z.length>0)return z;const e=xt[l];return Array.isArray(e)?e:kt},[l,z]),Y=e.useMemo(()=>{if(Array.isArray(l))return l;const e=xt[l];return Array.isArray(e)?e:kt},[l]),q=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?Y[0]:en[(e.depth||0)%en.length]:c?Et(e.data||e,c,W):ar(0,z,l),r.opacity=n?1:.85,r},[c,d,W,Y,z,l,H]),G=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),X=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:V,customClickBehavior:K}=cr({selection:D,linkedHover:j,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:L,onClick:O,chartType:"OrbitDiagram",chartId:C}),U=e.useMemo(()=>{if(V)return e=>{V(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[V]),Z=e.useMemo(()=>{if(K)return e=>{K(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[K]),Q=br({componentName:"OrbitDiagram",data:n});return Q?u.createElement(yr,{componentName:"OrbitDiagram",message:Q,width:I,height:P}):R||u.createElement(Rr,{componentName:"OrbitDiagram",width:I,height:P},u.createElement(Wt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[I,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:q,edgeStyle:G,colorBy:c,colorScheme:F,colorByDepth:d,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&T,tooltipContent:k?void 0:!1===A?()=>null:qt(A)||void 0,customHoverBehavior:j||L||O?U:void 0,customClickBehavior:L||O?Z:void 0,foregroundGraphics:w,annotations:S,className:i,title:N,description:_,summary:$,orbitMode:h,orbitSize:y,orbitSpeed:g,orbitRevolution:p,orbitRevolutionStyle:f,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:B},E)))}tn.displayName="OrbitDiagram",exports.ChordDiagram=Ur,exports.CirclePack=Jr,exports.ForceDirectedGraph=Yr,exports.OrbitDiagram=tn,exports.SankeyDiagram=Kr,exports.StreamNetworkFrame=Wt,exports.TreeDiagram=Zr,exports.Treemap=Qr;