semiotic 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CLAUDE.md +227 -27
  2. package/README.md +43 -11
  3. package/ai/examples.md +358 -18
  4. package/ai/schema.json +64 -2
  5. package/ai/system-prompt.md +50 -12
  6. package/dist/components/Legend.d.ts +7 -1
  7. package/dist/components/charts/geo/ChoroplethMap.d.ts +53 -0
  8. package/dist/components/charts/geo/DistanceCartogram.d.ts +90 -0
  9. package/dist/components/charts/geo/FlowMap.d.ts +83 -0
  10. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +67 -0
  11. package/dist/components/charts/geo/index.d.ts +8 -0
  12. package/dist/components/charts/index.d.ts +2 -0
  13. package/dist/components/charts/network/ChordDiagram.d.ts +6 -5
  14. package/dist/components/charts/network/CirclePack.d.ts +2 -2
  15. package/dist/components/charts/network/ForceDirectedGraph.d.ts +9 -7
  16. package/dist/components/charts/network/OrbitDiagram.d.ts +21 -20
  17. package/dist/components/charts/network/SankeyDiagram.d.ts +6 -5
  18. package/dist/components/charts/network/TreeDiagram.d.ts +2 -2
  19. package/dist/components/charts/network/Treemap.d.ts +2 -2
  20. package/dist/components/charts/ordinal/BarChart.d.ts +7 -5
  21. package/dist/components/charts/ordinal/BoxPlot.d.ts +8 -6
  22. package/dist/components/charts/ordinal/DonutChart.d.ts +8 -6
  23. package/dist/components/charts/ordinal/DotPlot.d.ts +8 -6
  24. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +7 -5
  25. package/dist/components/charts/ordinal/Histogram.d.ts +8 -5
  26. package/dist/components/charts/ordinal/PieChart.d.ts +8 -6
  27. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +2 -0
  28. package/dist/components/charts/ordinal/StackedBarChart.d.ts +7 -5
  29. package/dist/components/charts/ordinal/SwarmPlot.d.ts +8 -6
  30. package/dist/components/charts/ordinal/ViolinPlot.d.ts +8 -5
  31. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +24 -6
  32. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +28 -7
  33. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +23 -5
  34. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +24 -6
  35. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +23 -5
  36. package/dist/components/charts/shared/colorUtils.d.ts +5 -0
  37. package/dist/components/charts/shared/hooks.d.ts +13 -1
  38. package/dist/components/charts/shared/legendUtils.d.ts +2 -3
  39. package/dist/components/charts/shared/statisticalOverlays.d.ts +1 -2
  40. package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +10 -0
  41. package/dist/components/charts/shared/tooltipUtils.d.ts +1 -1
  42. package/dist/components/charts/shared/types.d.ts +10 -4
  43. package/dist/components/charts/shared/useChartSetup.d.ts +112 -0
  44. package/dist/components/charts/shared/useStreamingLegend.d.ts +65 -0
  45. package/dist/components/charts/xy/AreaChart.d.ts +11 -6
  46. package/dist/components/charts/xy/BubbleChart.d.ts +11 -6
  47. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -6
  48. package/dist/components/charts/xy/Heatmap.d.ts +16 -5
  49. package/dist/components/charts/xy/LineChart.d.ts +21 -5
  50. package/dist/components/charts/xy/MinimapChart.d.ts +3 -0
  51. package/dist/components/charts/xy/QuadrantChart.d.ts +120 -0
  52. package/dist/components/charts/xy/Scatterplot.d.ts +9 -6
  53. package/dist/components/charts/xy/StackedAreaChart.d.ts +11 -6
  54. package/dist/components/geo/mergeData.d.ts +18 -0
  55. package/dist/components/geo/referenceGeography.d.ts +10 -0
  56. package/dist/components/geo/useReferenceAreas.d.ts +13 -0
  57. package/dist/components/realtime/RingBuffer.d.ts +1 -0
  58. package/dist/components/realtime/types.d.ts +17 -0
  59. package/dist/components/semiotic-data.d.ts +1 -0
  60. package/dist/components/semiotic-geo.d.ts +16 -0
  61. package/dist/components/semiotic-server.d.ts +1 -1
  62. package/dist/components/semiotic-xy.d.ts +1 -0
  63. package/dist/components/semiotic.d.ts +4 -4
  64. package/dist/components/server/renderToStaticSVG.d.ts +4 -2
  65. package/dist/components/stream/AccessibleDataTable.d.ts +50 -0
  66. package/dist/components/stream/CanvasHitTester.d.ts +8 -2
  67. package/dist/components/stream/DataSourceAdapter.d.ts +33 -4
  68. package/dist/components/stream/GeoCanvasHitTester.d.ts +19 -0
  69. package/dist/components/stream/GeoParticlePool.d.ts +46 -0
  70. package/dist/components/stream/GeoPipelineStore.d.ts +81 -0
  71. package/dist/components/stream/GeoTileRenderer.d.ts +31 -0
  72. package/dist/components/stream/NetworkPipelineStore.d.ts +16 -4
  73. package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -1
  74. package/dist/components/stream/OrdinalPipelineStore.d.ts +8 -4
  75. package/dist/components/stream/OrdinalSVGOverlay.d.ts +23 -1
  76. package/dist/components/stream/PipelineStore.d.ts +57 -5
  77. package/dist/components/stream/SVGOverlay.d.ts +28 -1
  78. package/dist/components/stream/SceneGraph.d.ts +7 -3
  79. package/dist/components/stream/SceneToSVG.d.ts +2 -0
  80. package/dist/components/stream/StreamGeoFrame.d.ts +4 -0
  81. package/dist/components/stream/accessorUtils.d.ts +1 -0
  82. package/dist/components/stream/canvasSetup.d.ts +26 -0
  83. package/dist/components/stream/geoTypes.d.ts +186 -0
  84. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +0 -7
  85. package/dist/components/stream/layouts/index.d.ts +2 -1
  86. package/dist/components/stream/layouts/orbitLayoutPlugin.d.ts +2 -0
  87. package/dist/components/stream/legendRenderer.d.ts +33 -0
  88. package/dist/components/stream/networkTypes.d.ts +49 -1
  89. package/dist/components/stream/ordinalTypes.d.ts +10 -0
  90. package/dist/components/stream/pipelineTransitionUtils.d.ts +42 -0
  91. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +9 -0
  92. package/dist/components/stream/renderers/heatmapCanvasRenderer.d.ts +2 -1
  93. package/dist/components/stream/renderers/lineCanvasRenderer.d.ts +1 -0
  94. package/dist/components/stream/renderers/renderPulse.d.ts +50 -0
  95. package/dist/components/stream/types.d.ts +77 -3
  96. package/dist/components/types/legendTypes.d.ts +27 -3
  97. package/dist/geo.min.js +1 -0
  98. package/dist/geo.module.min.js +1 -0
  99. package/dist/network.min.js +1 -1
  100. package/dist/network.module.min.js +1 -1
  101. package/dist/ordinal.min.js +1 -1
  102. package/dist/ordinal.module.min.js +1 -1
  103. package/dist/realtime.min.js +1 -1
  104. package/dist/realtime.module.min.js +1 -1
  105. package/dist/semiotic-ai.min.js +1 -1
  106. package/dist/semiotic-ai.module.min.js +1 -1
  107. package/dist/semiotic-data.d.ts +1 -0
  108. package/dist/semiotic-data.min.js +1 -1
  109. package/dist/semiotic-data.module.min.js +1 -1
  110. package/dist/semiotic-geo.d.ts +16 -0
  111. package/dist/semiotic-server.d.ts +1 -1
  112. package/dist/semiotic-xy.d.ts +1 -0
  113. package/dist/semiotic.d.ts +4 -4
  114. package/dist/semiotic.min.js +1 -1
  115. package/dist/semiotic.module.min.js +1 -1
  116. package/dist/server.min.js +1 -1
  117. package/dist/server.module.min.js +1 -1
  118. package/dist/test-utils/canvasMock.d.ts +3 -0
  119. package/dist/xy.min.js +1 -1
  120. package/dist/xy.module.min.js +1 -1
  121. package/package.json +29 -7
  122. package/dist/test/canvasMock.d.ts +0 -2
@@ -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"),l=require("d3-shape"),s=require("d3-hierarchy");function c(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=c(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const l=r[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=y(l.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function y(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const o=e.length,i=t*o,a=Math.min(Math.floor(i),o-1),l=i-a,[s,c,u,d]=e[a],h=g(s,c,u,d,l),f=d.x-s.x,y=d.y-s.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;h.x+=-y/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,o,i,a]=e.points,l=g(n,o,i,a,t),s=a.x-n.x,c=a.y-n.y,u=Math.sqrt(s*s+c*c);if(u>.001){const t=s/u;l.x+=-c/u*r*e.halfWidth*2,l.y+=t*r*e.halfWidth*2}return l}function g(e,t,r,n,o){const i=1-o,a=i*i,l=a*i,s=o*o,c=s*o;return{x:l*e.x+3*a*o*t.x+3*i*s*r.x+c*n.x,y:l*e.y+3*a*o*t.y+3*i*s*r.y+c*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],o=[],i=[],a={},l=[];function s(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&s(t)})}function c(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;l[e].length>t;t++)(n=l[e][t])===r?(u(r,o),d=!0):i[n]||(d=c(n));if(d)s(e);else for(t=0;l[e].length>t;t++){var h=a[n=l[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),l=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,o[s]=!1,i[s]=0,a[s]=-1,l[s]=[];var c,u=0,d=[],h=[];function f(t){var s=[t],c=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var g=f[y];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>a[g]||l[t].push(a[g])}i[t]=y}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var b=s[y];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=d.length,b===t){s.length=y;break}}d.push(p);var x=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)x[--m]=v[y][k];h.push(x)}c.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[s]=c}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var l=0;o[a].length>l;l++)i>o[a][l]&&(i=o[a][l],r=a);var s=o[r];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];i[+p]=!1,a[p]={}}c(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=L(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function E(e,t){var r=L(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function A(e,t){return t(e)}function D(e){return C(e.source)}function S(e){return C(e.target)}function C(e){return(e.y0+e.y1)/2}function P(e){return e.virtual?0:e.value}function M(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function O(e){return e.target.depth}function N(e,t){return e.sourceLinks.length?e.depth:t-1}function I(e,t){return e.y0-t.y0}function W(e,t){return t.y0-e.y0}function T(e,t){return e.y1-t.y1}function $(e,t){return t.y1-e.y1}function _(e,t){return R(e.source,t.source)||e.index-t.index}function B(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function j(e,t){return H(e)==H(t)?"bottom"==e.circularLinkType?W(e,t):I(e,t):H(t)-H(e)}function H(e){return e.target.column-e.source.column}function z(e,t){return F(e)==F(t)}function F(e){return e.y0-e.y1>0?"up":"down"}function Y(e,t,n,o,i){let a=e;var l=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,l))});var s=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),X(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),X(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,l=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?W:I);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?$:T),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),a}function X(e,t,r){e.sort(j);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var l=n[a];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&G(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+r;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function Z(e){return e.nodes}function K(e){return e.links}function Q(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?M(t,n)-M(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==M(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,o,i,a){var l=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,c=a;c>0;--c)u(s*=.99,n),d();function u(t,n){var o=l.length;l.forEach(function(i){var a=i.length,l=i[0].depth;i.forEach(function(i){var s;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&M(i,n)>0){var c=r.mean(i.sourceLinks,S),u=r.mean(i.targetLinks,D),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-C(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==l&&1==a)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(l==o-1&&1==a)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)s=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+s;else{var f=r.mean(i.sourceLinks,S),y=r.mean(i.targetLinks,D),g=((f&&y?(f+y)/2:f||y)-C(i))*t;i.y0+=g,i.y1+=g}})})}function d(){l.forEach(function(r){var n,a,l,s=e.y0,c=r.length;for(r.sort(t||R),l=0;c>l;++l)(a=s-(n=r[l]).y0)>0&&(n.y0+=a,n.y1+=a),s=n.y1+o;if((a=s-o-e.y1)>0)for(s=n.y0-=a,n.y1-=a,l=c-2;l>=0;--l)(a=(n=r[l]).y1+i-s)>0&&(n.y0-=a,n.y1-=a),s=n.y0})}}function U(e){e.nodes.forEach(function(e){e.sourceLinks.sort(B),e.targetLinks.sort(_)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,i=24,a=8,l=null,s=V,c=N,u=void 0,d=32,h=2,f=Z,y=K;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof o&&(o=e.target=p(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,l=i.target.index;n[a]||(n[a]=[]),n[l]||(n[l]=[]),-1===n[a].indexOf(l)&&n[a].push(l)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){A(e,t)!=A(o.source,t)&&A(e,t)!=A(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,P),r.sum(e.targetLinks,P)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,l=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==l?a:a+1,l=t(e)==l?l:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(f,u,c);var y=a;if(null!==l){var g=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(g,function(e){return e.length});m>1&&(y=Math.max(1,(o-t)*l/(m-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,y,i),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),Q(f,u,s),J(f,u,s,y,y,d),U(f),Y(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return A(r.source,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!z(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return A(r.target,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!z(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=E(t,e);return e.y0-r}if(t.source.column>e.source.column)return E(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),l=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(l-a);function c(t){return(t-a)/(l-a)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),Y(f,s,h,10,8)}(g),g}return g.update=function(e){return U(e),Y(e,s,h,10,8),e},g.nodeWidth=function(e){return arguments.length?(i=+e,g):i},g.nodePadding=function(e){return arguments.length?(a=+e,g):a},g.nodePaddingRatio=function(e){return arguments.length?(l=+e,g):l},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),g):f},g.links=function(e){return arguments.length?(y="function"==typeof e?e:q(e),g):y},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),g):s},g.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:q(e),g):c},g.nodeSort=function(e){return arguments.length?(u=e,g):u},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(h=+e,g):h},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],g):[[e,t],[n,o]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],g):[n-e,o-t]},g}const te=e=>{let r,n,o,i,a,l,s,c,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.y1,l=e.target.y0,s=t.interpolateNumber(a,l),c=s(.5),u=s(.5),`M${r},${a}C${r},${c} ${n},${u} ${n},${l}L${o},${l}C${o},${u} ${i},${c} ${i},${a}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),o=s(.5),i=s(.5),a=e.y0-e.sankeyWidth/2,l=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${a}C${o},${a} ${i},${l} ${n},${l}L${n},${c}C${i},${c} ${o},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+l},${n-r}L${t+l},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-s},${a-r}L${i-s},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${c},${a-h*r}L${c+n},${a-h*r+h*f}L${c+n},${d+h*n-h*f}L${c+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${l},${s-h*r}L${l},${s+h*r}L${u+n},${s+h*r}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${a+h*r}L${i},${a+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(O))-1:0},justify:N},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,l,s,c,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(o=r.nodeWidth)&&void 0!==o?o:15,y=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||N).nodeId(e=>e.id).nodeWidth(f).iterations(g);b.nodePaddingRatio&&b.nodePaddingRatio(y),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(s=null!==(l=n._circularWidth)&&void 0!==l?l:n.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",i=k.get(`${n}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(n),r=x.get(o);t&&(i.source=t),r&&(i.target=r)}}},buildScene(e,t,r,o){var i,a,l,s;const c="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,f=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,g=new Map;e.forEach((e,t)=>{g.set(e.id,y[t%y.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},o={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const o=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+i},${t.sourceY-r}L${t.sourceX+i},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:c,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?re(e):te(e),!i)continue;const c={fill:o.fill||n,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};v.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const i=t?t(r):r.id;if(!i)continue;let a,l,s;"down"===c?(a=r.x0+e/2,l=r.y1+14,s="middle"):(o[0]/2>r.x0+e/2?(a=r.x0-6,s="end"):(a=r.x1+6,s="start"),l=r.y0+n/2),m.push({x:a,y:l,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},ie={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const l=null!==(i=r.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(a=r.forceStrength)&&void 0!==a?a:.1,c=n[0]/2,u=n[1]/2;for(let t=0;e.length>t;t++){const r=e[t];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(t+.5),n=2.399963229728653*t;r.x=c+e*Math.cos(n),r.y=u+e*Math.sin(n)}}const d=ae(r.nodeSize,r.nodeSizeRange,e),h=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),f=n[1]/n[0],y=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*(e=>d(e))(e))).force("x",o.forceX(n[0]/2).strength(.1*f)).force("y",o.forceY(n[1]/2).strength(.1));if(y.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));y.force("link",h),y.force("link").links(e)}.1>y.alpha()&&y.alpha(1),y.stop();for(let e=0;l>e;++e)y.tick();const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var i,a,l;const s=r.nodeStyle,c=r.edgeStyle,u=ae(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],y=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=c?c(e):{},o={stroke:n.stroke||"#999",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=n.opacity)&&void 0!==l?l:.6};y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:o,datum:e})}if(!1!==r.showLabels){const t=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function ae(e,t,n){var o,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const l=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>l[0];const c=null!==(o=r.min(s))&&void 0!==o?o:0,u=null!==(a=r.max(s))&&void 0!==a?a:1;if(c===u)return()=>(l[0]+l[1])/2;const d=i.scaleLinear().domain([c,u]).range(l).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?l[0]:d(n)}}const le=n.schemeCategory10,se={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=r,c=Math.min(n[0],n[1])/2,u=c-i,d=n[0]/2,h=n[1]/2,f=(y=r.valueAccessor)?"function"==typeof y?y:e=>{var t;return null!==(t=e[y])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var y;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=g.get("string"==typeof e.source?e.source:e.source.id),n=g.get(t);if(void 0===r||void 0===n)continue;const o=f(e);v[r][n]=o}const m=a.chord().padAngle(o);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=l.arc().innerRadius(u).outerRadius(c);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const E=new Map;for(const e of t)E.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=E.get(`${r}\0${n}`)||E.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:l=20,edgeOpacity:s=.5}=r,c=Math.min(n[0],n[1])/2,u=c-l,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,y=r.edgeStyle,g=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:le,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=a.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const a=f?f(r):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:c,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:l,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=ce(r,d,h);let o="#999";if(y)o=y(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===g&&r?o=v.get(r.id)||o:t&&(o=v.get(t.id)||o)}const a=y?y(e):{},l={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:n,style:l,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=c+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:d+Math.cos(a)*n,y:h+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function ce(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const ue={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,l=(c=r.childrenAccessor)?"function"==typeof c?c:e=>e[c]:void 0;var c;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(i,l);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=s.tree();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=s.cluster();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=s.treemap().size([r,n]).tile(s.treemapBinary).padding(a);l>0&&c.paddingTop(l),c(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;s.pack().size([r,n]).padding(i)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var o;s.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,f)}const y=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;y.length>t;t++){const n=y[t],i={id:ge(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===a||"cluster"===a?de(i,n,r):"treemap"===a||"partition"===a?he(i,n):"circlepack"===a&&fe(i,n),i.__hierarchyNode=n,e.push(i),g.set(n,i)}if("tree"===a||"cluster"===a)for(const e of y)if(e.parent){const r=g.get(e.parent),n=g.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,l,s,c,u;const d=[],h=[],f=[],y=r.treeOrientation||"vertical",g="radial"===y,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;g&&(e+=p,n+=v);const i=o(t);let l=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(l=b[t.depth%b.length]);const s={fill:l,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(l=r.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,o=t.y,a=r.x,l=r.y;g&&(n+=p,o+=v,a+=p,l+=v);const u=ye(n,o,a,l,y),d=i(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=pe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,l=r.y;if(g&&(a+=p,l+=v),g){const e=a-p,t=l-v,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=l+t/r*10,i=0>e?"end":"start"):(n=a,o=l-12,i="middle")}else"horizontal"===y?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=a-m-6,i="end"):(n=a+m+6,i="start"),o=l):(n=a,o=l+m+14,i="middle");f.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const l=n(r);let c=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=s[r.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};a.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;if((null===(i=n.data)||void 0===i?void 0:i.children)&&n.data.children.length>0&&"partition"!==t.chartType)continue;const a=r?r(n):n.id;a&&(30>e||16>o||l.push({x:n.x0+e/2,y:n.y0+o/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,o)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:l}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,l,s;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const l=n(r);let s=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=pe(t.nodeLabel);for(const t of e){const e=null!==(l=t.__radius)&&void 0!==l?l:5,n=r?r(t):t.id;if(!n)continue;if(15>e)continue;const o=!((null===(s=t.data)||void 0===s?void 0:s.children)&&t.data.children.length>0);u.push({x:t.x,y:o?t.y:t.y-e+14,text:n+"",anchor:"middle",baseline:o?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:o?void 0:"#000",stroke:o?void 0:"#fff",strokeWidth:o?void 0:3,paintOrder:o?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function de(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function he(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function fe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ye(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}function ge(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function pe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}const ve={sankey:oe,force:ie,chord:se,tree:ue,cluster:ue,treemap:ue,circlepack:ue,partition:ue};function me(e){return ve[e]}class be{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},d),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new f(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof n?n:e=>e[n],s="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=l(t)+"";this.nodes.set(e,Object.assign(Object.assign({},xe(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=c(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},xe(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},xe(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,xe(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,xe(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,r),s=this.edges.get(l);return s?(s.value+=n,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=me(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values()),n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(r,n,this.config,e),t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear();for(const e of r)this.nodes.set(e.id,e);for(const e of n)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const o=new Set(this.nodes.keys()),i=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of o)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)o.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=o,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=me(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),r=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*r,e.x1=e._prevX1+(e._targetX1-e._prevX1)*r,e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*r,e.y1=e._prevY1+(e._targetY1-e._prevY1)*r,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*r);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=r.y1,a=n.y0,l=t.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:l(.5)},{x:e.y1,y:l(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=r.x1,a=n.x0,l=t.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:l(.5),y:e.y0},{x:l(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,i;const a=this.config.pulse;if(!a)return;const l=null!==(t=a.duration)&&void 0!==t?t:500,s=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=a.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;l>o&&(t._pulseIntensity=1-o/l,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const c=this.edgeTimestamps.get(`${n}\0${a}`);if(!c)continue;const u=e-c;l>u&&(t._pulseIntensity=1-u/l,t._pulseColor=s)}}applyDecay(){var e,t,r,n,o;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,l=this.nodeTimestamps.size;if(1>=l)return;const s=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;s.length>e;e++)c.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const d=l-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(l-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:l/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*l)>d?1:a;break;default:h=1}const f=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",a=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const l=this.nodes.get(r);if(!l)continue;const s=n.metric(l);let c=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function xe(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ke(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function we(e,t,r,n,o=30){let i=null,a=o,l=1/0;for(const t of e){const e=Ee(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;l>r&&(i=e,l=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Se(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Ee(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,r);case"rect":return function(e,t,r){const n=function(e,t,r){return r.x>e||e>r.x+r.w||r.y>t||t>r.y+r.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:r.x+r.w/2,cy:r.y+r.h/2}}(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=ke(Math.atan2(o,n)),l=ke(e.startAngle),s=ke(e.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let Le=null,Ae=null;function De(){return Ae||(Le=document.createElement("canvas"),Le.width=1,Le.height=1,Ae=Le.getContext("2d")),Ae}function Se(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=De();if(!a)return null;if(a.isPointInPath(i,t,r)){const i="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const l=e.x1+a*n,s=e.y1+a*o,c=Math.sqrt(Math.pow(t-l,2)+Math.pow(r-s,2));return c>5?null:{type:"edge",datum:e.datum,x:l,y:s,distance:c}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=De();if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0}}catch(e){}return null}(e,t,r);default:return null}}const Ce={fill:e=>u.createElement("rect",{style:e,width:20,height:20}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function Pe(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Ce[r])(n(e,t)),o}function Me(){return u.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function Oe(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Ne(e){const{legendGroups:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,title:a="Legend",width:l=100,height:s=20,orientation:c="vertical"}=e,d="vertical"===c?(({legendGroups:e,width:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i})=>{let a=30;const l=[];return e.forEach((e,s)=>{a+=5,l.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:a,x2:t,y2:a})),a+=10,e.label&&(a+=20,l.push(u.createElement("text",{key:"legend-text-"+s,y:a,className:"legend-group-label"},e.label)),a+=10),l.push(u.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${a})`},((e,t,r,n,o)=>{const{type:i="fill",styleFn:a,items:l}=e,s=[];let c=0;const d=!(!t&&!r);return l.forEach((e,l)=>{const h=Pe(e,l,i,a),f=Oe(e,n,o),y=o&&o.size>0&&o.has(e.label);s.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${c})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,style:{cursor:d?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},y&&u.createElement(Me,null),h,u.createElement("text",{y:15,x:30},e.label))),c+=25}),s})(e,r,n,o,i))),a+=25*e.items.length+10}),l})({legendGroups:t,width:l,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i}):(({legendGroups:e,title:t,height:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a})=>{let l=0;const s=[],c=!1===t?10:40;return e.forEach((t,d)=>{t.label&&(s.push(u.createElement("text",{key:"legend-text-"+d,transform:`translate(${l},${c}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),l+=20);const h=((e,t,r,n,o)=>{const{type:i="fill",styleFn:a,items:l}=e,s=[];let c=0;const d=!(!t&&!r);return l.forEach((e,l)=>{const h=Pe(e,l,i,a),f=Oe(e,n,o),y=o&&o.size>0&&o.has(e.label);s.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${c},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,style:{cursor:d?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},y&&u.createElement(Me,null),h,u.createElement("text",{y:15,x:25},e.label))),c+=35,c+=8*e.label.length}),{items:s,offset:c}})(t,n,o,i,a);s.push(u.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(${l},${c})`},h.items)),l+=h.offset+5,e[d+1]&&s.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:l,y1:c-10,x2:l,y2:r+c+10})),l+=15}),u.createElement("g",null,!1!==t&&u.createElement("line",{x1:0,x2:l+10,y1:c-10,y2:c-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:t,title:a,height:s,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i});return u.createElement("g",null,void 0!==a&&u.createElement("text",{className:"legend-title",y:20,x:"horizontal"===c?0:l/2,textAnchor:"horizontal"===c?"start":"middle"},a),d)}function Ie(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,foregroundGraphics:y,sceneNodes:g,annotations:p,svgAnnotationRules:v}=e;return u.createElement(u.Fragment,null,u.createElement("svg",{width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),p&&p.filter(e=>"widget"!==e.type).map((e,n)=>{if(v){const o=v(e,n,{width:t,height:r,sceneNodes:g});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),y),l&&"string"==typeof l?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?u.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},l):null,s&&u.createElement("g",{transform:`translate(${n-i.right+10},${i.top})`},"object"==typeof s&&!u.isValidElement(s)&&"legendGroups"in s?u.createElement(Ne,{legendGroups:s.legendGroups,title:"",width:100,customHoverBehavior:c,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f}):s)),null==p?void 0:p.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{var r,n,o,a,l,s,c,d,h;const f=g.find(t=>{var r,n,o,i,a;return t.id===e.nodeId||(null===(r=t.datum)||void 0===r?void 0:r.id)===e.nodeId||(null===(o=null===(n=t.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(a=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===e.nodeId});if(!f)return null;const y=i.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(n=f.x)&&void 0!==n?n:0),p=i.top+(null!==(o=f.cy)&&void 0!==o?o:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),v=null!==(l=e.dx)&&void 0!==l?l:0,m=null!==(s=e.dy)&&void 0!==s?s:-16,b=null!==(c=e.width)&&void 0!==c?c:32,x=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:u.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return u.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:y+v-b/2,top:p+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}Ie.displayName="NetworkSVGOverlay";const We="undefined"==typeof window||"undefined"==typeof document;function Te(e,t){var r,n,o,i,a,l;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,l=t.style.fill;o.addColorStop(0,1===a.from?l:"transparent"),o.addColorStop(1,1===a.to?l:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function $e(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function _e(e,t){var r,n,o,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function Be(e,t){var r,n;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}const Re={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},je=n.schemeCategory10,He=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function ze(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):je[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%je.length]}function Fe(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>e[t]))),o=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return i.scaleOrdinal().domain(n).range(r).unknown("#999");const a=Re[r]||Re.category10;if(o&&"function"==typeof a)return e=>a(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(a)?a:je;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}const Ye={top:20,right:80,bottom:20,left:80},Xe={top:40,right:40,bottom:40,left:40},Ge=new Set(["chord","force","circlepack"]),qe=[800,600],Ve={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ze({data:e}){var t,r,n,o,i,a;if("edge"===e.type){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:Ve},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const l=e.data,s=null==l?void 0:l.__hierarchyNode;if(s){const e=[];let i=s;for(;i;){const a=null!==(o=null!==(r=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==o?o:l.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:Ve},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=l.value&&l.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(i=l.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:Ve},u.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,d!==c&&` (weighted: ${d.toLocaleString()})`))}const Ke=e.forwardRef(function(t,r){var n,o,i;const{chartType:a,nodes:s,edges:c,data:f,initialEdges:y,nodeIDAccessor:g="id",sourceAccessor:p="source",targetAccessor:v="target",valueAccessor:m="value",childrenAccessor:b,hierarchySum:x,orientation:k="horizontal",nodeAlign:w="justify",nodePaddingRatio:E=.05,nodeWidth:L=15,iterations:A=300,forceStrength:D=.1,padAngle:S=.01,groupWidth:C=20,sortGroups:P,edgeSort:M,treeOrientation:O="vertical",edgeType:N="curve",padding:I,paddingTop:W,tensionConfig:T,showParticles:$=!1,particleStyle:_,nodeStyle:B,edgeStyle:R,colorBy:j,colorScheme:H="category10",edgeColorBy:z="source",edgeOpacity:F=.5,colorByDepth:Y=!1,nodeSize:X=8,nodeSizeRange:G=[5,20],nodeLabel:q,showLabels:V=!0,size:Z=qe,responsiveWidth:K,responsiveHeight:Q,margin:J,className:U,background:ee,enableHover:te=!0,tooltipContent:re,customHoverBehavior:ne,customClickBehavior:oe,onObservation:ie,chartId:ae,onTopologyChange:le,annotations:se,svgAnnotationRules:ce,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:fe,legendIsolatedCategories:ye,title:ge,foregroundGraphics:pe,backgroundGraphics:ve,decay:me,pulse:xe,staleness:ke,thresholds:Ee}=t,Le=Ge.has(a)?Xe:Ye,[Ae,De]=function(t,r,n){const o=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;a(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&i?i.w:t[0],n&&i?i.h:t[1]]]}(Z,K,Q),Se=Object.assign(Object.assign({},Le),J),Ce=De[0]-Se.left-Se.right,Pe=De[1]-Se.top-Se.bottom,Me=e.useMemo(()=>Object.assign(Object.assign({},d),T),[T]),Oe=e.useMemo(()=>Object.assign(Object.assign({},h),_),[_]),Ne=e.useMemo(()=>({chartType:a,nodeIDAccessor:g,sourceAccessor:p,targetAccessor:v,valueAccessor:m,childrenAccessor:b,hierarchySum:x,orientation:k,nodeAlign:w,nodePaddingRatio:E,nodeWidth:L,iterations:A,forceStrength:D,padAngle:S,groupWidth:C,sortGroups:P,edgeSort:M,treeOrientation:O,edgeType:N,padding:I,paddingTop:W,tensionConfig:Me,showParticles:$,particleStyle:Oe,nodeStyle:B,edgeStyle:R,nodeLabel:q,showLabels:V,colorBy:j,colorScheme:H,edgeColorBy:z,edgeOpacity:F,colorByDepth:Y,nodeSize:X,nodeSizeRange:G,decay:me,pulse:xe,staleness:ke,thresholds:Ee}),[a,g,p,v,m,b,x,k,w,E,L,A,D,S,C,P,M,O,N,I,W,Me,$,Oe,B,R,q,V,j,H,z,F,Y,X,G,me,xe,ke,Ee]),Re=e.useRef(null),He=e.useRef(0),ze=e.useRef(0),Fe=e.useRef(!0),Ve=e.useRef(()=>{}),Ke=e.useRef(null);Ke.current||(Ke.current=new be(Ne));const[Qe,Je]=e.useState(null),[Ue,et]=e.useState(0),[tt,rt]=e.useState(0),[nt,ot]=e.useState(!1),it=e.useRef(null),at=e.useRef(new Map),lt=e.useRef(0),st=e.useCallback(e=>{if("function"==typeof j)return j(e)+"";if("string"==typeof j&&e.data){const t=e.data[j];if(void 0!==t){if(!at.current.has(t+"")){const e=Array.isArray(H)?H:je;at.current.set(t+"",e[lt.current++%e.length])}return at.current.get(t+"")}}if(!at.current.has(e.id)){const t=Array.isArray(H)?H:je;at.current.set(e.id,t[lt.current++%t.length])}return at.current.get(e.id)},[j,H]),ct=e.useCallback(e=>{if("function"==typeof z)return z(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===z&&r?st(r):t?st(t):"#999"},[z,st]),ut=e.useCallback(e=>{if(!(null==_?void 0:_.colorBy))return ct(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Oe.colorBy&&r?st(r):t?st(t):"#999"},[null==_?void 0:_.colorBy,Oe.colorBy,st,ct]),dt="sankey"===a&&$||!!xe,ht=e.useCallback(()=>{He.current&&!dt||He.current||(He.current=requestAnimationFrame(()=>Ve.current()))},[dt]);e.useEffect(()=>{var e;null===(e=Ke.current)||void 0===e||e.updateConfig(Ne),Fe.current=!0,ht()},[Ne,ht]);const ft=e.useCallback(()=>{const e=Ke.current;if(!e)return;e.runLayout([Ce,Pe]),e.buildScene([Ce,Pe]),Fe.current=!0;const t=Array.isArray(H)?H:je,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];at.current.has(n.id)||at.current.set(n.id,t[e%t.length])}if(lt.current=r.length,et(e.layoutVersion),le){const{nodes:t,edges:r}=e.getLayoutData();le(t,r)}},[Ce,Pe,le,H]),yt=e.useCallback(e=>{const t=Ke.current;t&&(t.ingestEdge(e)&&ft(),ht())},[ft,ht]),gt=e.useCallback(e=>{const t=Ke.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&ft(),ht()},[ft,ht]),pt=e.useCallback(()=>{var e;null===(e=Ke.current)||void 0===e||e.clear(),at.current.clear(),lt.current=0,et(0),Je(null),it.current=null,Fe.current=!0,ht()},[ht]),vt=e.useCallback(()=>{const e=Ke.current;e&&(e.tension+=999,ft(),ht())},[ft,ht]);e.useImperativeHandle(r,()=>({push:yt,pushMany:gt,clear:pt,getTopology:()=>{var e,t;return null!==(t=null===(e=Ke.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ke.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:vt,getTension:()=>{var e,t;return null!==(t=null===(e=Ke.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[yt,gt,pt,vt]);const mt=["tree","cluster","treemap","circlepack","partition"].includes(a),bt=mt?f||(Array.isArray(c)?void 0:c):void 0;e.useEffect(()=>{const e=Ke.current;if(e)if(mt&&bt)e.ingestHierarchy(bt,[Ce,Pe]),e.buildScene([Ce,Pe]),Fe.current=!0,ht();else{const t=s||[],r=Array.isArray(c)?c:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[Ce,Pe]),e.buildScene([Ce,Pe]);const n=Array.isArray(H)?H:je,o=Array.from(e.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];at.current.has(t.id)||at.current.set(t.id,n[e%n.length])}lt.current=o.length,Fe.current=!0,ht()}},[s,c,f,bt,mt,Ce,Pe,Ne,ht,H]),e.useEffect(()=>{y&&y.length>0&&gt(y)},[]);const xt=e.useCallback(e=>{if(ne&&ne(e),ie){const t=Date.now();ie(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ae}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ae})}},[ne,ie,ae]),kt=e.useCallback(e=>{if(oe&&oe(e),ie){const t=Date.now();ie(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ae}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ae})}},[oe,ie,ae]),wt=e.useRef(()=>{}),Et=e.useRef(()=>{});wt.current=e=>{if(!te)return;const t=Re.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Se.left,o=e.clientY-r.top-Se.top;if(0>n||n>Ce||0>o||o>Pe)return void(it.current&&(it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),ht()));const i=Ke.current;if(!i)return;const a=we(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(it.current&&(it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),ht()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};it.current=l,Je(l),xt&&(xt(l),Fe.current=!0),ht()},Et.current=()=>{it.current&&(it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),ht())};const Lt=e.useRef(()=>{});Lt.current=e=>{if(!oe&&!ie)return;const t=Re.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Se.left,o=e.clientY-r.top-Se.top;if(0>n||n>Ce||0>o||o>Pe)return;const i=Ke.current;if(!i)return;const a=we(i.sceneNodes,i.sceneEdges,n,o);kt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},e.useCallback(e=>wt.current(e),[]);const At=e.useCallback(()=>Et.current(),[]),Dt=e.useCallback(e=>Lt.current(e),[]),St=e.useRef(-1),Ct=e.useCallback(e=>{const t=Ke.current;if(!t)return;const r=function(e){const t=[];for(const r of e)"circle"===r.type&&null!=r.cx?t.push({x:r.cx,y:r.cy,datum:r.datum}):"rect"===r.type&&null!=r.x?t.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum}):"arc"===r.type&&null!=r.cx&&t.push({x:r.cx,y:r.cy,datum:r.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return;const n=St.current,o=function(e,t,r){switch(e){case"ArrowRight":case"ArrowDown":return r-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return r-1;case"Escape":return-1;default:return null}}(e.key,0>n?-1:n,r.length);if(null===o)return;if(e.preventDefault(),0>o)return St.current=-1,it.current=null,Je(null),xt&&(xt(null),Fe.current=!0),void ht();const i=0>n?0:o;St.current=i;const a=r[i],l={type:"node",data:a.datum,x:a.x,y:a.y};it.current=l,Je(l),xt&&(xt(l),Fe.current=!0),ht()},[xt,ht]),Pt=e.useCallback(e=>{St.current=-1,wt.current(e)},[]);Ve.current=()=>{var e,t,r;He.current=0;const n=Re.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Ke.current;if(!i)return;const a=performance.now(),l=ze.current?Math.min((a-ze.current)/1e3,.1):.016;ze.current=a;const s=i.advanceTransition(a);(s||Fe.current)&&i.buildScene([Ce,Pe]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=De[0]*c,n.height=De[1]*c,n.style.width=De[0]+"px",n.style.height=De[1]+"px",o.scale(c,c),o.translate(Se.left,Se.top),o.clearRect(-Se.left,-Se.top,De[0],De[1]),ee&&(o.fillStyle=ee,o.fillRect(0,0,Ce,Pe)),me&&i.applyDecay(),xe&&i.applyPulse(a),Ee&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==ke?void 0:ke.threshold)&&void 0!==e?e:5e3,d=ke&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(o.globalAlpha=null!==(t=null==ke?void 0:ke.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Te(e,r);break;case"line":$e(e,r);break;case"ribbon":_e(e,r);break;case"curved":Be(e,r)}}(o,i.sceneEdges),function(e,t){var r,n,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(o,i.sceneNodes),function(e,t){var r,n,o,i;for(const a of t){if("circle"!==a.type)continue;const t=a;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const r=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,n=t.r+r*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,n,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(o,i.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(o,i.sceneNodes),$&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:h.spawnRate,l=null!==(i=n.maxPerEdge)&&void 0!==i?i:h.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=l)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<l;t++)e.spawn(n)}}(i.particlePool,e,l,Oe);const t=.5*(null!==(r=Oe.speedMultiplier)&&void 0!==r?r:1);let n;if(Oe.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(l,t,e,n),function(e,t,r,n,o){var i,a;const l=null!==(i=n.radius)&&void 0!==i?i:h.radius,s=null!==(a=n.opacity)&&void 0!==a?a:h.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const s=r[a.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(s);e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(o,i.particlePool,e,Oe,ut)}}d&&(o.globalAlpha=1);const f=Fe.current;Fe.current=!1,(f||s)&&rt(e=>e+1),(dt||s||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(He.current=requestAnimationFrame(()=>Ve.current()))},e.useEffect(()=>(ht(),()=>{He.current&&(cancelAnimationFrame(He.current),He.current=0)}),[ht]),e.useEffect(()=>{Fe.current=!0,ht()},[a,Ce,Pe,ee,ht]),function(t,r,n,o,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=r.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=s-l.lastIngestTime>c;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}(ke,Ke,Fe,ht,nt,ot);const Mt=te&&Qe?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Se.left+Qe.x,top:Se.top+Qe.y,transform:`translate(${Qe.x>.6*Ce?"calc(-100% - 12px)":"12px"}, ${.3*Pe>Qe.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},re?re(Qe):u.createElement(Ze,{data:Qe})):null;if(We){const e=Ke.current;if(e){const t=["tree","cluster","treemap","circlepack","partition"].includes(a),r=t?f||(Array.isArray(c)?void 0:c):void 0;if(t&&r)e.ingestHierarchy(r,[Ce,Pe]),e.buildScene([Ce,Pe]);else{const t=s||[],r=Array.isArray(c)?c:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[Ce,Pe]),e.buildScene([Ce,Pe]))}}const t=null!==(n=null==e?void 0:e.sceneNodes)&&void 0!==n?n:[],r=null!==(o=null==e?void 0:e.sceneEdges)&&void 0!==o?o:[],d=null!==(i=null==e?void 0:e.labels)&&void 0!==i?i:[];return u.createElement("div",{className:"stream-network-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof ge?ge:"Network chart",style:{position:"relative",width:De[0],height:De[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:De[0],height:De[1],style:{position:"absolute",left:0,top:0}},ve&&u.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ve),u.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ee&&u.createElement("rect",{x:0,y:0,width:Ce,height:Pe,fill:ee}),r.map((e,t)=>function(e,t){switch(e.type){case"line":return u.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":case"ribbon":return u.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return u.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":return u.createElement("circle",{key:"net-circle-"+t,cx:e.cx,cy:e.cy,r:e.r,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"rect":return u.createElement("rect",{key:"net-rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"arc":{const r=e,n=l.arc().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return u.createElement("path",{key:"net-arc-"+t,d:n,transform:`translate(${r.cx},${r.cy})`,fill:r.style.fill||"#4e79a7",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),d.map((e,t)=>function(e,t){return u.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),u.createElement(Ie,{width:Ce,height:Pe,totalWidth:De[0],totalHeight:De[1],margin:Se,labels:d,sceneNodes:t,title:ge,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:fe,legendIsolatedCategories:ye,foregroundGraphics:pe,annotations:se,svgAnnotationRules:ce,annotationFrame:0}))}const Ot=Ke.current;return u.createElement("div",{ref:Ae,className:"stream-network-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof ge?ge:"Network chart",tabIndex:0,style:{position:"relative",width:K?"100%":De[0],height:Q?"100%":De[1]},onMouseMove:te?Pt:void 0,onMouseLeave:te?At:void 0,onClick:oe||ie?Dt:void 0,onKeyDown:Ct},ve&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:De[0],height:De[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${Se.left},${Se.top})`},ve)),u.createElement("canvas",{ref:Re,style:{position:"absolute",top:0,left:0}}),u.createElement(Ie,{width:Ce,height:Pe,totalWidth:De[0],totalHeight:De[1],margin:Se,labels:(null==Ot?void 0:Ot.labels)||[],sceneNodes:null==Ot?void 0:Ot.sceneNodes,title:ge,legend:ue,legendHoverBehavior:de,legendClickBehavior:he,legendHighlightedCategory:fe,legendIsolatedCategories:ye,foregroundGraphics:pe,annotations:se,svgAnnotationRules:ce,annotationFrame:tt}),Mt,(null==ke?void 0:ke.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ke.badgePosition?{top:4,left:4}:"bottom-left"===ke.badgePosition?{bottom:4,left:4}:"bottom-right"===ke.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:nt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},nt?"STALE":"LIVE"))});Ke.displayName="StreamNetworkFrame";const Qe={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Je(e,t){return"function"==typeof t?t(e):e[t]}function Ue(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function et(e={}){const{fields:t,title:r,format:n,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(r){const t=Je(e,r);a=Ue(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,o,i;"string"==typeof t?(r=t,o=t,i=n):(r=t.label,o=t.accessor||t.key||"",i=t.format||n);const a=Je(e,o);l.push({label:r,value:Ue(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=Ue(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Ue(e[t[0]],n))}}const s=Object.assign(Object.assign({},Qe),o);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:s},a&&u.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}function tt(e){return!0===e?et():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?et(e):et())}const rt=e.createContext(null),nt="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function ot(t){const r=e.createContext(null),n=it(t);return[function({children:n}){const o=e.useMemo(()=>it(t),[]);return u.createElement(r.Provider,{value:o,children:n})},t=>{var o;const i=null!==(o=e.useContext(r))&&void 0!==o?o:n;return function(t,r){const[n,o]=e.useState(r);return nt(()=>t(()=>o(r)),[t]),n}(i.subscribe,()=>t(i.getState()))}]}function it(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function at(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function lt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[st,ct]=ot(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=lt(n,t),i=new Map(o.clauses);return i.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),i=new Map(n.clauses);return i.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=lt(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}})),[ut,dt]=ot(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function ht(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=ct(e=>e.selections.get(o)),a=ct(e=>e.setClause),l=ct(e=>e.clearClause),s=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(at(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:e.useCallback(()=>{l(o,n)},[l,o,n]),clientId:n}}const ft=e.createContext(!1),yt="#007bff";function gt(t,r,n="category10"){const o=e.useContext(rt);return e.useMemo(()=>{if(r&&"function"!=typeof r)return o&&Object.keys(o).length>0?e=>o[e]||Fe(t,r,n)(e):Fe(t,r,n)},[t,r,n,o])}function pt({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:l}){const s=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(r,n),c=ht({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:a,clear:l}=ht({name:r});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&a(t)},[n,a,l,r]),predicate:o,isActive:i}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),d=dt(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||d){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),d&&d(e)}}},[r,u,i,a,l,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},n),{type:"click",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,a,l])}}function vt(t,r,n){const[o,i]=e.useState(null),[a,l]=e.useState(new Set),s=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&l(t=>{const r=new Set(t);return r.has(e.label)?r.delete(e.label):r.add(e.label),r.size===n.length?new Set:r})},[t,n.length]),u=e.useMemo(()=>{if(!t||"none"===t||!r)return null;const e="string"==typeof r?r:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof r?r(t):null)===o}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const n=e?t[e]:"function"==typeof r?r(t):null;return a.has(n)}}:null},[t,r,o,a]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:s,onLegendClick:c,legendSelectionHook:u}}const mt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function bt(e,t,r){var n,o,i,a,l,s;const c=mt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?c.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?c.height:r.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function xt({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class kt extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var r,n;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:u.createElement(xt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function wt({componentName:e,width:t,height:r,children:n}){return u.createElement(kt,{fallback:n=>u.createElement(xt,{componentName:e,message:n.message,width:t,height:r})},n)}"undefined"!=typeof process&&process;const Et={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Lt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function At(e,t,r,n){return!1===n||e&&Array.isArray(e)&&e.length>0||e&&!Array.isArray(e)?null:u.createElement("div",{style:Object.assign(Object.assign({},Et),{width:t,height:r})},n||"No data available")}function Dt(e,t,r){if(!e)return null;const n=Math.min(5,Math.floor(r/40)),o=Math.max(8,Math.floor(r/(3*n))),i=Math.max(6,Math.floor(r/(2.5*n))),a=Math.floor((r-(n*(o+i)-i))/2);return u.createElement("div",{style:{width:t,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:n},(e,r)=>u.createElement("div",{key:r,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Lt),{position:"absolute",top:a+r*(o+i),left:Math.floor(.1*t),width:30+Math.round(50*Math.random())+"%",height:o,opacity:.5+r%2*.2})})))}function St(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function Ct(e,t){var r;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(r=function(e,t,r=3){let n,o=r+1;for(const r of t){const t=St(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}(e,t,3))&&void 0!==r?r:null)}function Pt({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Mt({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const r=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){const r=Ct(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}function Ot(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:l,nodeIDAccessor:s="id",sourceAccessor:c="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:y="category10",nodeSize:g=8,nodeSizeRange:p=[5,20],edgeWidth:v=1,edgeColor:m="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:k=.1,tooltip:w,frameProps:E={},onObservation:L,chartId:A,selection:D,linkedHover:S,loading:C,emptyContent:P,legendInteraction:M}=t,O=n.width,N=n.height,I=n.enableHover,W=n.showLegend,T=null!==(r=n.showLabels)&&void 0!==r&&r,$=n.title,_=Dt(C,O,N);if(_)return _;const B=At(i,O,N,P);if(B)return B;const R=o||[],j=i||[],H=gt(R,f,y),z=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of R){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[R,f]),F=vt(M,f,z),Y=e.useMemo(()=>e=>{const t={};return t.fill=f?ze(e.data||e,f,H):yt,"number"==typeof g&&(t.r=g),t},[f,H,g]),X=e.useMemo(()=>e=>({stroke:m,strokeWidth:"number"==typeof v?v:"function"==typeof v?v(e):e[v]||1,opacity:b}),[v,m,b]),G=e.useMemo(()=>{if(T&&h)return"function"==typeof h?h:e=>e[h]},[T,h]),{legend:q,margin:V}=function({data:t,colorBy:r,colorScale:n,showLegend:o,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(ft),s=void 0!==o?o:!l&&!!r,c=e.useMemo(()=>{if(s&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(o=>{const i=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),a=i?n(i,t,r):r?r(o):"#000000";return{label:o+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==o&&(t.stroke=o),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:ze})},[s,r,t,n]),u=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),i);return c&&120>e.right&&(e.right=120),e},[a,i,c]);return{legend:c,margin:u}}({data:R,colorBy:f,colorScale:H,showLegend:W,userMargin:a,defaults:n.marginDefaults}),{customHoverBehavior:Z}=pt({selection:D,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,chartType:"ForceDirectedGraph",chartId:A}),K=Mt({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:s}});return K?u.createElement(xt,{componentName:"ForceDirectedGraph",message:K,width:O,height:N}):u.createElement(wt,{componentName:"ForceDirectedGraph",width:O,height:N},u.createElement(Ke,Object.assign({chartType:"force",nodes:R,edges:j,size:[O,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:d,iterations:x,forceStrength:k,nodeStyle:Y,edgeStyle:X,colorBy:f,colorScheme:y,nodeSize:g,nodeSizeRange:p,nodeLabel:G,showLabels:T,enableHover:I,tooltipContent:w?e=>tt(w)(e.data):void 0,customHoverBehavior:S||L?Z:void 0,legend:q},M&&"none"!==M&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:l,title:$},E)))}function Nt(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function It(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],i="function"==typeof n?n(e):e[n];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function Wt(e){return"function"==typeof e?e:t=>t[e]||1}function Tt({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const l=Object.assign({fillOpacity:o},i);if("function"==typeof e)l.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?l.fill=ze(e.data||e,t,r):e&&(l.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?l.fill=ze(e.data||e,t,r):e&&(l.fill=n(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*o);return l}}function $t(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:o,edges:i,margin:a,className:l,sourceAccessor:s="source",targetAccessor:c="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",orientation:p="horizontal",nodeAlign:v="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:E,frameProps:L={},onObservation:A,chartId:D,selection:S,linkedHover:C,loading:P,emptyContent:M,legendInteraction:O}=t,N=n.width,I=n.height,W=n.enableHover,T=null===(r=n.showLabels)||void 0===r||r,$=n.title,_=Dt(P,N,I);if(_)return _;const B=At(i,N,I,M);if(B)return B;const R=i||[],j=e.useMemo(()=>It(o,R,s,c),[o,R,s,c]),H=gt(j,f,y),z=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of j){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[j,f]),F=vt(O,f,z),Y=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?ze(e.data||e,f,H):"#4d430c",t},[f,H]),X=e.useMemo(()=>Tt({edgeColorBy:g,colorBy:f,colorScale:H,nodeStyleFn:Y,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,H,Y,k]),G=e.useMemo(()=>{if(!T)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[T,x,h]),q=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:V,customClickBehavior:Z}=pt({selection:S,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:A,chartType:"SankeyDiagram",chartId:D}),K=Mt({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return K?u.createElement(xt,{componentName:"SankeyDiagram",message:K,width:N,height:I}):u.createElement(wt,{componentName:"SankeyDiagram",width:N,height:I},u.createElement(Ke,Object.assign({chartType:"sankey",nodes:j,edges:R,size:[N,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:c,valueAccessor:d,orientation:p,nodeAlign:v,nodePaddingRatio:m,nodeWidth:b,nodeStyle:Y,edgeStyle:X,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:k,edgeSort:w,nodeLabel:G,showLabels:T,enableHover:W,tooltipContent:E?e=>tt(E)(e.data):void 0,customHoverBehavior:C||A?V:void 0,customClickBehavior:A?Z:void 0},O&&"none"!==O&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:l,title:$},L)))}function _t(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:l,sourceAccessor:s="source",targetAccessor:c="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:f,colorScheme:y="category10",edgeColorBy:g="source",padAngle:p=.01,groupWidth:v=20,sortGroups:m,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:E,chartId:L,selection:A,linkedHover:D,loading:S,emptyContent:C,legendInteraction:P}=t,M=n.width,O=n.height,N=n.enableHover,I=null===(r=n.showLabels)||void 0===r||r,W=n.title,T=Dt(S,M,O);if(T)return T;const $=At(i,M,O,C);if($)return $;const _=i||[],B=e.useMemo(()=>It(o,_,s,c),[o,_,s,c]),R=gt(B,f,y),j=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of B){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[B,f]),H=vt(P,f,j),z=e.useMemo(()=>(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=ze(e.data||e,f,R);else{const i=Array.isArray(y)?y:Re[y]||je,a=Array.isArray(i)?i:je,l=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[l%a.length]}return o},[f,R,y]),F=e.useMemo(()=>Tt({edgeColorBy:g,colorBy:f,colorScale:R,nodeStyleFn:z,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,R,z,x]),Y=e.useMemo(()=>{if(!I)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[I,b,h]),X=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:G}=pt({selection:A,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ChordDiagram",chartId:L}),q=Mt({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return q?u.createElement(xt,{componentName:"ChordDiagram",message:q,width:M,height:O}):u.createElement(wt,{componentName:"ChordDiagram",width:M,height:O},u.createElement(Ke,Object.assign({chartType:"chord",nodes:B,edges:_,size:[M,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:c,valueAccessor:d,padAngle:p,groupWidth:v,sortGroups:m,nodeStyle:z,edgeStyle:F,colorBy:f,colorScheme:y,edgeColorBy:g,edgeOpacity:x,nodeLabel:Y,showLabels:I,enableHover:N,tooltipContent:k?e=>tt(k)(e.data):void 0,customHoverBehavior:D||E?G:void 0},P&&"none"!==P&&{legendHoverBehavior:H.onLegendHover,legendClickBehavior:H.onLegendClick,legendHighlightedCategory:H.highlightedCategory,legendIsolatedCategories:H.isolatedCategories},{className:l,title:W},w)))}function Bt(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:i,className:a,layout:l="tree",orientation:s="vertical",childrenAccessor:c="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:y="category10",colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:E,linkedHover:L,loading:A,legendInteraction:D}=t,S=n.width,C=n.height,P=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,O=n.title,N=Dt(A,S,C);if(N)return N;const I=e.useMemo(()=>Nt(o,c),[o,c]),W=gt(I,g?void 0:f,y),T=e.useMemo(()=>{if(!f||g)return[];const e=new Set;for(const t of I){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[I,f,g]),$=vt(D,g?void 0:f,T),_=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?He[(e.depth||0)%He.length]:f?ze(e.data||e,f,W):yt,t},[f,g,W]),B=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),R=e.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return Wt(d)},[l,d]),j=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:H}=pt({selection:E,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),z=Pt({componentName:"TreeDiagram",data:o});return z?u.createElement(xt,{componentName:"TreeDiagram",message:z,width:S,height:C}):u.createElement(wt,{componentName:"TreeDiagram",width:S,height:C},u.createElement(Ke,Object.assign({chartType:l,data:o,size:[S,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:j,nodeIDAccessor:h,childrenAccessor:c,hierarchySum:R,treeOrientation:s,edgeType:p,nodeStyle:_,edgeStyle:B,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:M?v||h:void 0,showLabels:M,enableHover:P,tooltipContent:b?e=>tt(b)(e.data):void 0,customHoverBehavior:L||k?H:void 0},D&&"none"!==D&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories},{className:a,title:O},x)))}function Rt(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:y="leaf",nodeLabel:g,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:E,loading:L,legendInteraction:A}=t,D=n.width,S=n.height,C=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,M=n.title,O=Dt(L,D,S);if(O)return O;const{activeSelectionHook:N,customHoverBehavior:I}=pt({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:E}),W=e.useCallback(e=>{if(!e)return I(null);const t=e.data||e;I({data:(null==t?void 0:t.data)||t})},[I]),T=e.useMemo(()=>Nt(o,l),[o,l]),$=gt(T,f?void 0:d,h),_=e.useMemo(()=>{if(!d||f)return[];const e=new Set;for(const t of T){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[T,d,f]),B=vt(A,f?void 0:d,_),R=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?He[(e.depth||0)%He.length]:d?ze(e.data||e,d,$):yt,t},[d,f,$]),j=e.useMemo(()=>N?e=>{var t;const r=Object.assign({},R(e));if(N.isActive)if(N.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(r,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(r,x.unselectedStyle)}return r}:R,[R,N,x]),H=e.useMemo(()=>Wt(s),[s]),z=void 0!==v?v:P&&"parent"===y?18:void 0,F=Object.assign(Object.assign({},n.marginDefaults),i),Y=Pt({componentName:"Treemap",data:o});return Y?u.createElement(xt,{componentName:"Treemap",message:Y,width:D,height:S}):u.createElement(wt,{componentName:"Treemap",width:D,height:S},u.createElement(Ke,Object.assign({chartType:"treemap",data:o,size:[D,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:H,padding:p,paddingTop:z,nodeStyle:j,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:P?g||c:void 0,showLabels:P,enableHover:C,tooltipContent:m?e=>tt(m)(e.data):void 0},(k||w)&&{customHoverBehavior:W},A&&"none"!==A&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:M},b)))}function jt(t){var r;const n=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:y,circleOpacity:g=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x,selection:k,linkedHover:w,loading:E,legendInteraction:L}=t,A=n.width,D=n.height,S=n.enableHover,C=null===(r=n.showLabels)||void 0===r||r,P=n.title,M=Dt(E,A,D);if(M)return M;const O=e.useMemo(()=>Nt(o,l),[o,l]),N=gt(O,f?void 0:d,h),I=e.useMemo(()=>{if(!d||f)return[];const e=new Set;for(const t of O){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[O,d,f]),W=vt(L,f?void 0:d,I),T=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?He[(e.depth||0)%He.length]:d?ze(e.data||e,d,N):yt,t},[d,f,N,g]),$=e.useMemo(()=>Wt(s),[s]),_=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:B}=pt({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),R=Pt({componentName:"CirclePack",data:o});return R?u.createElement(xt,{componentName:"CirclePack",message:R,width:A,height:D}):u.createElement(wt,{componentName:"CirclePack",width:A,height:D},u.createElement(Ke,Object.assign({chartType:"circlepack",data:o,size:[A,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:$,padding:p,nodeStyle:T,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:C?y||c:void 0,showLabels:C,enableHover:S,tooltipContent:v?e=>tt(v)(e.data):void 0,customHoverBehavior:w||b?B:void 0},L&&"none"!==L&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:P},m)))}Ot.displayName="ForceDirectedGraph",$t.displayName="SankeyDiagram",_t.displayName="ChordDiagram",Bt.displayName="TreeDiagram",Rt.displayName="Treemap",jt.displayName="CirclePack";const Ht=["#93c5fd","#fca5a5","#86efac","#fde68a","#c4b5fd","#f9a8d4","#a5f3fc"];function zt(t){const r=bt(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,title:t.title},{width:600,height:600}),{data:n,childrenAccessor:o="children",nodeIdAccessor:i="name",colorBy:a,colorScheme:s="category10",colorByDepth:c=!1,orbitMode:d="flat",orbitSize:h=2.95,speed:f=.25,revolution:y=e=>1/(e.depth+1),eccentricity:g=1,showRings:p=!0,nodeRadius:v=6,showLabels:m=!1,animated:b=!0,tooltip:x,foregroundGraphics:k,className:w,annotations:E,selection:L,linkedHover:A,onObservation:D,chartId:S,loading:C}=t,P=r.width,M=r.height,O=r.title,N=Dt(C,P,M);if(N)return N;const I=e.useMemo(()=>"function"==typeof o?o:e=>e[o],[o]),W=e.useMemo(()=>"function"==typeof i?i:e=>{var t;return(null!==(t=e[i])&&void 0!==t?t:"")+""},[i]),T=e.useMemo(()=>"function"==typeof v?v:()=>v,[v]),{customHoverBehavior:$}=pt({selection:L,linkedHover:A,fallbackFields:a?["string"==typeof a?a:""]:[],onObservation:D,chartType:"OrbitDiagram",chartId:S}),_=gt(e.useMemo(()=>{const e=[];return function t(r){e.push(r);const n=I(r);n&&n.forEach(t)}(n),e},[n,I]),c?void 0:a,s),{nodes:B,rings:R,eccentricityFn:j}=e.useMemo(()=>function(e,t,r,n,o,i,a){const s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o),c="number"==typeof i?()=>i:i,u="number"==typeof a?()=>a:a,d=[],h=[],f={datum:e,x:t[0]/2,y:t[1]/2,ring:Math.min(t[0],t[1])/2*.85,angle:0,depth:0,id:n(e)};return d.push(f),function e(t){const o=r(t.datum);if(!(null==o?void 0:o.length))return;t.children=[];const i=o.length;let a=0,f=0,y=0;for(;i>f;)f+=s[Math.min(y,s.length-1)],y++,a++;let g=0;for(let i=0;a>i;i++){const f=s[Math.min(i,s.length-1)],y=o.slice(g,g+f);if(!y.length)break;const p=(i+1)/a,v=t.parent?t.ring/c(t)*p:t.ring*p,m=l.pie().value(e=>{var t;return(null===(t=r(e))||void 0===t?void 0:t.length)?4:1}).sort(null)(y),b=u(t);h.push({source:t,x:t.x,y:t.y,r:v,ry:v*b});for(let r=0;y.length>r;r++){const o=(m[r].startAngle+m[r].endAngle)/2,i={datum:y[r],x:t.x+v*Math.sin(o),y:t.y+v*Math.cos(o)*b,ring:v,angle:o,depth:t.depth+1,parent:t,id:n(y[r])};t.children.push(i),d.push(i),e(i)}g+=f}}(f),{nodes:d,rings:h,eccentricityFn:u}}(n,[P,M],I,W,d,h,g),[n,P,M,I,W,d,h,g]),[,H]=e.useState(0),z=e.useRef(0),F=f*(Math.PI/360);e.useEffect(()=>{if(!b)return;let e;const t=()=>{z.current++,function(e,t,r,n,o,i){for(const t of e){if(!t.parent)continue;const e=t.angle+r*n*o(t),a=i(t);t.x=t.parent.x+t.ring*Math.sin(e),t.y=t.parent.y+t.ring*Math.cos(e)*a}for(const e of t)e.x=e.source.x,e.y=e.source.y}(B,R,z.current,F,y,j),H(e=>e+1),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[b,B,R,F,y,j]);const[Y,X]=e.useState(null),G=e.useCallback(e=>{X(e),$&&$(e?{data:e.datum,x:e.x,y:e.y}:null)},[$]),q=e.useCallback(e=>c?Ht[e.depth%Ht.length]:a?ze(e.datum,a,_):yt,[a,c,_]),V=Pt({componentName:"OrbitDiagram",data:n});return V?u.createElement(xt,{componentName:"OrbitDiagram",message:V,width:P,height:M}):u.createElement(wt,{componentName:"OrbitDiagram",width:P,height:M},u.createElement("div",{className:"semiotic-orbit-diagram"+(w?" "+w:""),role:"img","aria-label":"string"==typeof O?O:"Orbit diagram",tabIndex:0,style:{position:"relative",width:P,height:M}},u.createElement("svg",{width:P,height:M},p&&R.map((e,t)=>u.createElement("ellipse",{key:"ring-"+t,cx:e.x,cy:e.y,rx:e.r,ry:e.ry,fill:"none",stroke:"currentColor",strokeWidth:.5,opacity:.15})),B.map((e,t)=>e.parent?u.createElement("line",{key:"edge-"+t,x1:e.parent.x,y1:e.parent.y,x2:e.x,y2:e.y,stroke:"currentColor",strokeWidth:.5,opacity:.1}):null),B.map((e,t)=>{const r=T(e),n=q(e),o=Y===e;return u.createElement("g",{key:"node-"+t},u.createElement("circle",{cx:e.x,cy:e.y,r:o?1.5*r:r,fill:n,stroke:"white",strokeWidth:o?2:1,opacity:0===e.depth?1:.85,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>G(e),onMouseLeave:()=>G(null)}),m&&r>4&&u.createElement("text",{x:e.x,y:e.y+r+12,textAnchor:"middle",fontSize:10,fill:"currentColor",opacity:.7},W(e.datum)))}),null==E?void 0:E.map((e,t)=>{var r,n,o,i,a;if("widget"!==e.type)return null;const l=e.nodeId?B.find(t=>t.id===e.nodeId):null;if(!l)return null;const s=null!==(r=e.dx)&&void 0!==r?r:0,c=null!==(n=e.dy)&&void 0!==n?n:-16,d=null!==(o=e.width)&&void 0!==o?o:32,h=null!==(i=e.height)&&void 0!==i?i:32,f=null!==(a=e.content)&&void 0!==a?a:u.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return u.createElement("foreignObject",{key:"ann-"+t,x:l.x+s-d/2,y:l.y+c-h/2,width:d,height:h,style:{overflow:"visible",pointerEvents:"auto"}},u.createElement("div",{style:{width:d,height:h,display:"flex",alignItems:"center",justifyContent:"center"}},f))}),k),Y&&x&&u.createElement("div",{style:{position:"absolute",left:Y.x+12,top:Y.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},x(Y)),Y&&!x&&u.createElement("div",{style:{position:"absolute",left:Y.x+12,top:Y.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},u.createElement("strong",null,W(Y.datum)),Y.depth>0&&u.createElement("span",{style:{opacity:.7}}," (depth ",Y.depth,")")),O&&u.createElement("div",{style:{position:"absolute",top:8,left:0,width:"100%",textAlign:"center",fontSize:14,fontWeight:600,color:"currentColor",pointerEvents:"none"}},O)))}zt.displayName="OrbitDiagram",exports.ChordDiagram=_t,exports.CirclePack=jt,exports.ForceDirectedGraph=Ot,exports.OrbitDiagram=zt,exports.SankeyDiagram=$t,exports.StreamNetworkFrame=Ke,exports.TreeDiagram=Bt,exports.Treemap=Rt;
1
+ "use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),o=require("d3-force"),i=require("d3-scale"),a=require("d3-chord"),l=require("d3-shape"),s=require("d3-hierarchy");function c(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=c(e),d={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},h={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const l=r[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=g(l.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function 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),l=i-a,[s,c,u,d]=e[a],h=y(s,c,u,d,l),f=d.x-s.x,g=d.y-s.y,p=Math.sqrt(f*f+g*g);if(p>.001){const e=f/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,l=y(n,o,i,a,t),s=a.x-n.x,c=a.y-n.y,u=Math.sqrt(s*s+c*c);if(u>.001){const t=s/u;l.x+=-c/u*r*e.halfWidth*2,l.y+=t*r*e.halfWidth*2}return l}function y(e,t,r,n,o){const i=1-o,a=i*i,l=a*i,s=o*o,c=s*o;return{x:l*e.x+3*a*o*t.x+3*i*s*r.x+c*n.x,y:l*e.y+3*a*o*t.y+3*i*s*r.y+c*n.y}}function p(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],o=[],i=[],a={},l=[];function s(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&s(t)})}function c(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;l[e].length>t;t++)(n=l[e][t])===r?(u(r,o),d=!0):i[n]||(d=c(n));if(d)s(e);else for(t=0;l[e].length>t;t++){var h=a[n=l[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),l=Array(t),s=0;t>s;++s)r[s]=-1,n[s]=0,o[s]=!1,i[s]=0,a[s]=-1,l[s]=[];var c,u=0,d=[],h=[];function f(t){var s=[t],c=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>r[y]){r[y]=n[y]=u,o[y]=!0,u+=1,s.push(y),c.push(y);break}o[y]&&(n[t]=0|Math.min(n[t],n[y])),0>a[y]||l[t].push(a[y])}i[t]=g}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(g=s.length-1;g>=0;--g){var b=s[g];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=d.length,b===t){s.length=g;break}}d.push(p);var x=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)x[--m]=v[g][k];h.push(x)}c.pop()}}}for(s=0;t>s;++s)0>r[s]&&f(s);for(s=0;h.length>s;s++){var g=h[s];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[s]=c}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var l=0;o[a].length>l;l++)i>o[a][l]&&(i=o[a][l],r=a);var s=o[r];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,l=f.adjList){for(var g=0;l.length>g;g++)for(var y=0;l[g].length>y;y++){var p=l[g][y];i[+p]=!1,a[p]={}}c(r),r+=1}else r=h}return n}function m(e){return e.y0-e.y1>0?"up":"down"}function b(e,t){return t(e.source)==t(e.target)}function x(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function k(e){return e.target.x0-e.source.x1}function w(e,t){var r=L(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1-n:e.y1+n}function E(e,t){var r=L(e),n=k(t)/Math.tan(r);return"up"==m(e)?e.y1+n:e.y1-n}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function A(e,t){return t(e)}function S(e){return M(e.source)}function D(e){return M(e.target)}function M(e){return(e.y0+e.y1)/2}function P(e){return e.virtual?0:e.value}function C(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!b(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!b(e,t)?n+1:n}),r+n}function I(e){return e.target.depth}function N(e,t){return e.sourceLinks.length?e.depth:t-1}function O(e,t){return e.y0-t.y0}function T(e,t){return t.y0-e.y0}function W(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 j(e,t){return R(e.target,t.target)||e.index-t.index}function R(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function B(e,t){return H(e)==H(t)?"bottom"==e.circularLinkType?T(e,t):O(e,t):H(t)-H(e)}function H(e){return e.target.column-e.source.column}function z(e,t){return F(e)==F(t)}function F(e){return e.y0-e.y1>0?"up":"down"}function Y(e,t,n,o,i){let a=e;var l=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,l))});var s=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),X(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),X(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,b(e,t)&&x(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,l=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?T:O);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?_:W),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),a}function X(e,t,r){e.sort(B);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(b(e,t)&&x(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var l=n[a];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&G(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+r;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function G(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function q(e){return function(){return e}}function V(e){return e.index}function K(e){return e.nodes}function Z(e){return e.links}function Q(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var l=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+=M(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=M(e.target)*t,n+=t}}),n>0?o/n:NaN);l.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var r=l.get(e),n=l.get(t),o=r.bc,i=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?r.idx-n.idx:1:-1:o-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?C(t,n)-C(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==C(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function U(e,t,n,o,i,a){var l=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var s=1,c=a;c>0;--c)u(s*=.99,n),d();function u(t,n){var o=l.length;l.forEach(function(i){var a=i.length,l=i[0].depth;i.forEach(function(i){var s;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&C(i,n)>0){var c=r.mean(i.sourceLinks,D),u=r.mean(i.targetLinks,S),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-M(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==l&&1==a)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(l==o-1&&1==a)i.y0=e.y1/2-(s=i.y1-i.y0)/2,i.y1=e.y1/2+s/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)s=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+s;else{var f=r.mean(i.sourceLinks,D),g=r.mean(i.targetLinks,S),y=((f&&g?(f+g)/2:f||g)-M(i))*t;i.y0+=y,i.y1+=y}})})}function d(){l.forEach(function(r){var n,a,l,s=e.y0,c=r.length;for(r.sort(t||R),l=0;c>l;++l)(a=s-(n=r[l]).y0)>0&&(n.y0+=a,n.y1+=a),s=n.y1+o;if((a=s-o-e.y1)>0)for(s=n.y0-=a,n.y1-=a,l=c-2;l>=0;--l)(a=(n=r[l]).y1+i-s)>0&&(n.y0-=a,n.y1-=a),s=n.y0})}}function J(e){e.nodes.forEach(function(e){e.sourceLinks.sort(j),e.targetLinks.sort($)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function ee(){var e=0,t=0,n=1,o=1,i=24,a=8,l=null,s=V,c=N,u=void 0,d=32,h=2,f=K,g=Z;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=p(n,r)),"object"!=typeof o&&(o=e.target=p(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,l=i.target.index;n[a]||(n[a]=[]),n[l]||(n[l]=[]),-1===n[a].indexOf(l)&&n[a].push(l)}var s=v(n);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){A(e,t)!=A(o.source,t)&&A(e,t)!=A(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),b(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,P),r.sum(e.targetLinks,P)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,l=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==l?a:a+1,l=t(e)==l?l:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(f,u,c);var g=a;if(null!==l){var y=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=r.max(y,function(e){return e.length});m>1&&(g=Math.max(1,(o-t)*l/(m-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,g,i),Q(f,u,s),U(f,u,s,g,g,d),J(f),Y(f,s,h,10,8),Q(f,u,s),U(f,u,s,g,g,d),J(f),Y(f,s,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return A(r.source,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!z(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(f,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return A(r.target,t)==A(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!z(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=E(t,e);return e.y0-r}if(t.source.column>e.source.column)return E(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),l=r.max(t,function(e){return e.y1}),s=(e.y1-e.y0)/(l-a);function c(t){return(t-a)/(l-a)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),Y(f,s,h,10,8)}(y),y}return y.update=function(e){return J(e),Y(e,s,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(a=+e,y):a},y.nodePaddingRatio=function(e){return arguments.length?(l=+e,y):l},y.nodes=function(e){return arguments.length?(f="function"==typeof e?e:q(e),y):f},y.links=function(e){return arguments.length?(g="function"==typeof e?e:q(e),y):g},y.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:q(e),y):s},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:q(e),y):c},y.nodeSort=function(e){return arguments.length?(u=e,y):u},y.iterations=function(e){return arguments.length?(d=+e,y):d},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],y):[[e,t],[n,o]]},y.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],y):[n-e,o-t]},y}const te=e=>{let r,n,o,i,a,l,s,c,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.y1,l=e.target.y0,s=t.interpolateNumber(a,l),c=s(.5),u=s(.5),`M${r},${a}C${r},${c} ${n},${u} ${n},${l}L${o},${l}C${o},${u} ${i},${c} ${i},${a}Z`):(r=e.source.x1,n=e.target.x0,s=t.interpolateNumber(r,n),o=s(.5),i=s(.5),a=e.y0-e.sankeyWidth/2,l=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${a}C${o},${a} ${i},${l} ${n},${l}L${n},${c}C${i},${c} ${o},${u} ${r},${u}Z`)};function re(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+l},${n-r}L${t+l},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-s},${a-r}L${i-s},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${c},${a-h*r}L${c+n},${a-h*r+h*f}L${c+n},${d+h*n-h*f}L${c+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${s-h*r+h*f}L${u-n+f},${s-h*r}L${l},${s-h*r}L${l},${s+h*r}L${u+n},${s+h*r}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${a+h*r}L${i},${a+h*r}Z`}const ne={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(I))-1:0},justify:N},oe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,l,s,c,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ee().extent(m).links(v).nodes(p).nodeAlign(ne[h]||N).nodeId(e=>e.id).nodeWidth(f).iterations(y);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 v){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(s=null!==(l=n._circularWidth)&&void 0!==l?l:n.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",i=k.get(`${n}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(n),r=x.get(o);t&&(i.source=t),r&&(i.target=r)}}},buildScene(e,t,r,o){var i,a,l,s;const c="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,f=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],v=[],m=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(t):{},o={fill:n.fill||y.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const b=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of b){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";d?n=d(e).fill||n:"target"===f&&r?n=y.get(r.id)||n:t&&(n=y.get(t.id)||n);const o=d?d(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||n;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+i},${t.sourceY-r}L${t.sourceX+i},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:c,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-s},${t.targetY-r}L${t.targetX-s},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?re(e):te(e),!i)continue;const c={fill:o.fill||n,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};v.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const i=t?t(r):r.id;if(!i)continue;let a,l,s;"down"===c?(a=r.x0+e/2,l=r.y1+14,s="middle"):(o[0]/2>r.x0+e/2?(a=r.x0-6,s="end"):(a=r.x1+6,s="start"),l=r.y0+n/2),m.push({x:a,y:l,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}},ie={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const l=null!==(i=r.forceStrength)&&void 0!==i?i:.1,s=n[0]/2,c=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 f=d>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of h){const n=ae(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=le(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=le(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=s+n*Math.cos(r),e.y=c+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=s+e*Math.cos(o),n.y=c+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)))),y=f?40:g,p=se(r.nodeSize,r.nodeSizeRange,e),v=e=>p(e),m=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*l:l)).id(e=>e.id),b=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*v(e))).force("center",o.forceCenter(s,c).strength(.8)).force("x",o.forceX(s).strength(.15)).force("y",o.forceY(c).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",m),b.force("link").links(e)}f?b.alpha(.3):.1>b.alpha()&&b.alpha(1),b.stop();for(let e=0;y>e;++e)b.tick();for(const t of e){if(null==t.x||null==t.y)continue;const e=v(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,l;const s=r.nodeStyle,c=r.edgeStyle,u=se(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const f=[],g=[],y=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(t),r=s?s(t):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:2,opacity:r.opacity};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=c?c(e):{},o={stroke:n.stroke||"#999",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=n.opacity)&&void 0!==l?l:.6};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=(v=r.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(r);y.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:g,labels:y}}};function ae(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function le(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 se(e,t,n){var o,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const l=t||[5,20],s=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===s.length)return()=>l[0];const c=null!==(o=r.min(s))&&void 0!==o?o:0,u=null!==(a=r.max(s))&&void 0!==a?a:1;if(c===u)return()=>(l[0]+l[1])/2;const d=i.scaleLinear().domain([c,u]).range(l).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?l[0]:d(n)}}const ce=n.schemeCategory10,ue={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=r,c=Math.min(n[0],n[1])/2,u=c-i,d=n[0]/2,h=n[1]/2,f=(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 y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=y.get("string"==typeof e.source?e.source:e.source.id),n=y.get(t);if(void 0===r||void 0===n)continue;const o=f(e);v[r][n]=o}const m=a.chord().padAngle(o);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=l.arc().innerRadius(u).outerRadius(c);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const E=new Map;for(const e of t)E.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=E.get(`${r}\0${n}`)||E.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:l=20,edgeOpacity:s=.5}=r,c=Math.min(n[0],n[1])/2,u=c-l,d=n[0]/2,h=n[1]/2,f=r.nodeStyle,g=r.edgeStyle,y=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:ce,v=new Map;e.forEach((e,t)=>{v.set(e.id,p[t%p.length])});const m=a.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=f?f(r).fill||v.get(r.id)||p[t%p.length]:v.get(r.id)||p[t%p.length];const a=f?f(r):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:c,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:l,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=m(t);if(!r)continue;const n=de(r,d,h);let o="#999";if(g)o=g(e).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===y&&r?o=v.get(r.id)||o:t&&(o=v.get(t.id)||o)}const a=g?g(e):{},l={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:n,style:l,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,n=c+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:d+Math.cos(a)*n,y:h+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function de(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}function he(e){const[t,r,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}const fe={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,l=(c=r.childrenAccessor)?"function"==typeof c?c:e=>e[c]:void 0;var c;const u=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),d=s.hierarchy(i,l);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=s.tree();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=s.cluster();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=s.treemap().size([r,n]).tile(s.treemapBinary).padding(a);l>0&&c.paddingTop(l),c(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;s.pack().size([r,n]).padding(i)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var o;s.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,f)}const g=d.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;g.length>t;t++){const n=g[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?ge(i,n,r):"treemap"===a||"partition"===a?ye(i,n):"circlepack"===a&&pe(i,n),i.__hierarchyNode=n,e.push(i),y.set(n,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const r=y.get(e.parent),n=y.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,l,s,c,u;const d=[],h=[],f=[],g=r.treeOrientation||"vertical",y="radial"===g,p=n[0]/2,v=n[1]/2,m="number"==typeof(x=r.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,n=t.y;y&&(e+=p,n+=v);const i=o(t);let l=i.fill||"#4d430c";r.colorByDepth&&void 0!==t.depth&&(l=b[t.depth%b.length]);const s={fill:l,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:n,r:m,style:s,datum:t,id:t.id,label:t.id,depth:t.depth})}const k=null!==(l=r.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,o=t.y,a=r.x,l=r.y;y&&(n+=p,o+=v,a+=p,l+=v);const u=ve(n,o,a,l,g),d=i(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=be(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,l=r.y;if(y&&(a+=p,l+=v),y){const e=a-p,t=l-v,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=l+t/r*10,i=0>e?"end":"start"):(n=a,o=l-12,i="middle")}else"horizontal"===g?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=a-m-6,i="end"):(n=a+m+6,i="start"),o=l):(n=a,o=l+m+14,i="middle");f.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const l=n(r);let c=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=s[r.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};a.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=be(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,u=c.y1-c.y0;if(0>=e||0>=u)continue;const d=!((null===(i=c.data)||void 0===i?void 0:i.children)&&c.data.children.length>0);if(!a){if("leaf"===o&&!d)continue;if("parent"===o&&d)continue}const h=r?r(c):c.id;if(!h)continue;if((d?30:40)>e||(d?16:14)>u)continue;let f=n(c).fill||"#4d430c";t.colorByDepth&&void 0!==c.depth&&(f=s[c.depth%s.length]);const g=he(f);l.push(d?{x:c.x0+e/2,y:c.y0+u/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:g}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:g})}}return{sceneNodes:a,sceneEdges:[],labels:l}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,l,s;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const l=n(r);let s=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=d[r.depth%d.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=be(t.nodeLabel);for(const o of e){const e=null!==(l=o.__radius)&&void 0!==l?l:5,i=r?r(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=n(o).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(c=d[o.depth%d.length]),a){const t=he(c);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:c,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ge(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function ye(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function pe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function ve(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}function 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 be(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}function xe(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const ke={sankey:oe,force:ie,chord:ue,tree:fe,cluster:fe,treemap:fe,circlepack:fe,partition:fe,orbit:{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 s=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),c=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,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=xe(r);y.metaMap.clear(),n.length=0,o.length=0;const p=new Map;function v(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 m=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=v(c(e));n.push({id:k,x:m,y:b,x0:m,x1:m,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),y.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,p){const m=s(t);if(!(null==m?void 0:m.length))return;const b=m.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let E=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=m.slice(E,E+k);if(!w.length)break;const L=(b+1)/x,A={id:r,depth:h,data:t,parentId:r},S=p?d/f(A)*L:d*L,D=l.pie().value(e=>{var t;return(null===(t=s(e))||void 0===t?void 0:t.length)?4:1}).sort(null),M=D(w),P=g(A);for(let t=0;w.length>t;t++){const l=(M[t].startAngle+M[t].endAngle)/2,s=w[t],u=v(c(s)),d=i+S*Math.sin(l),f=a+S*Math.cos(l)*P;n.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:s}),y.metaMap.set(u,{ring:S,angle:l,depth:h,parentId:r,eccentricity:P}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(s,u,d,f,S,h+1,!0)}E+=k}}(e,k,m,b,x,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,l,s;const c=r.nodeStyle,u=r.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],g=[];if(!1!==r.orbitShowRings){const t=xe(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:r,ecc:n}]of o)for(let o=0;i>o;o++){const l=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:e+r*Math.sin(l),y1:t+r*Math.cos(l)*n,x2:e+r*Math.sin(s),y2:t+r*Math.cos(s)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(t),r=c?c(t):{},n={fill:r.fill||"#6366f1",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=r.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:y.get(e.source),r="object"==typeof e.target?e.target:y.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&f.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=d(r);if(4>=e)continue;const n="function"==typeof t?t(r):t&&null!==(s=null===(l=r.data)||void 0===l?void 0:l[t])&&void 0!==s?s:r.id;g.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:g}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=xe(t),i=null!==(r=t.orbitSpeed)&&void 0!==r?r:.25,a=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const r=null!==(t=e.depth)&&void 0!==t?t:0;return(r%2==0?1:-1)/(r+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),l=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=c.get(e.parentId);if(!r)continue;const n=e.angle+l*s*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)}};function we(e){return ke[e]}function Ee(e,t,r){return e+(t-e)*r}class Le{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 f(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 f(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,l="function"==typeof n?n:e=>e[n],s="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Ae(e)),{data:t}))}for(const e of t){const t=s(e)+"",r=c(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Ae(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Ae(r)),{data:e})),this.edges.set(`${t}\0${r}`,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Ae(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Ae(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,r),s=this.edges.get(l);return s?(s.value+=n,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,r,n,o,i,a;const l=we(this.config.chartType);if(!l)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!l.hierarchical)return;if(this.prepareForRelayout(),l.supportsStreaming&&!l.hierarchical){const e=new Map;for(const l of s)if(void 0!==l._prevX0){const s=(null!==(t=l._prevX1)&&void 0!==t?t:0)-(null!==(r=l._prevX0)&&void 0!==r?r:0),c=(null!==(n=l._prevY1)&&void 0!==n?n:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);e.set(l.id,{x:(null!==(i=l._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(a=l._prevY0)&&void 0!==a?a:0)+c/2})}else 0===l.x&&0===l.y||e.set(l.id,{x:l.x,y:l.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(l.computeLayout(s,c,this.config,e),delete this.config.__previousPositions,l.hierarchical&&s.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of s)this.nodes.set(e.id,e);for(const e of c)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),s.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=we(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a}get isAnimating(){const e=we(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=we(this.config.chartType);if(!(null==r?void 0:r.tick))return!1;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return r.tick(n,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),r=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Ee(e._prevX0,e._targetX0,r),e.x1=Ee(e._prevX1,e._targetX1,r),e.y0=Ee(e._prevY0,e._targetY0,r),e.y1=Ee(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=Ee(e._prevY0,e._targetY0,r),e.y1=Ee(e._prevY1,e._targetY1,r),e.sankeyWidth=Ee(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=r.y1,a=n.y0,l=t.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:l(.5)},{x:e.y1,y:l(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=r.x1,a=n.x0,l=t.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:l(.5),y:e.y0},{x:l(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,i;const a=this.config.pulse;if(!a)return;const l=null!==(t=a.duration)&&void 0!==t?t:500,s=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=a.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;l>o&&(t._pulseIntensity=1-o/l,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const c=this.edgeTimestamps.get(`${n}\0${a}`);if(!c)continue;const u=e-c;l>u&&(t._pulseIntensity=1-u/l,t._pulseColor=s)}}applyDecay(){var e,t,r,n,o;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,l=this.nodeTimestamps.size;if(1>=l)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const s=this._decaySortedNodes,c=new Map;for(let e=0;s.length>e;e++)c.set(s[e][0],e);for(const e of this.sceneNodes){const s=e.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const d=l-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(l-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:l/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*l)>d?1:a;break;default:h=1}const f=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:f*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",a=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const l=this.nodes.get(r);if(!l)continue;const s=n.metric(l);let c=null;void 0===n.critical||n.critical>s?void 0===n.warning||n.warning>s||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this._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 Ae(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 Se(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function De(e,t,r,n,o=30){let i=null,a=o,l=1/0;for(const t of e){const e=Me(t,r,n);if(e)if("rect"===t.type){const r=t.w*t.h;l>r&&(i=e,l=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Ne(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Me(e,t,r){switch(e.type){case"circle":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,r);case"rect":return function(e,t,r){const n=function(e,t,r){return r.x>e||e>r.x+r.w||r.y>t||t>r.y+r.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:r.x+r.w/2,cy:r.y+r.h/2}}(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Se(Math.atan2(o,n)),l=Se(e.startAngle),s=Se(e.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let Pe=null,Ce=null;function Ie(){return Ce||(Pe=document.createElement("canvas"),Pe.width=1,Pe.height=1,Ce=Pe.getContext("2d")),Ce}function Ne(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=Ie();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 l=a.lineWidth;a.lineWidth=10;const s=a.isPointInStroke(i,t,r);if(a.lineWidth=l,s)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 l=e.x1+a*n,s=e.y1+a*o,c=Math.sqrt(Math.pow(t-l,2)+Math.pow(r-s,2));return c>5?null:{type:"edge",datum:e.datum,x:l,y:s,distance:c}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=Ie();if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);default:return null}}const Oe={fill:e=>u.createElement("rect",{style:e,width:16,height:16}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Te(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Oe[r])(n(e,t)),o}function We(){return u.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function _e(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function $e({config:e,orientation:t="vertical",width:r=100}){const{colorFn:n,domain:o,label:i,format:a}=e,l=a||(e=>Math.round(100*e)/100+""),s="grad-legend-"+u.useId();if("horizontal"===t){const e=12,t=Math.min(r,200),a=Math.max(0,(r-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.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:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),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(#${s})`,rx:2}),u.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(o[0])),u.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(o[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.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:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),u.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),u.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(o[1])),u.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(o[0])))}function je(e){const{legendGroups:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:l="Legend",width:s=100,height:c=20,orientation:d="vertical"}=e,[h,f]=u.useState(0),[g,y]=u.useState(0),p=u.useCallback((e,t)=>{f(e),y(t)},[]),v="vertical"===d?(({legendGroups:e,width:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:s,legendInteraction:c})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:d,x2:t,y2:d})),d+=8,e.label&&(d+=16,h.push(u.createElement("text",{key:"legend-text-"+f,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-"+f,className:"legend-item",transform:`translate(0,${d})`},((e,t,r,n,o,i,a,l,s,c)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!t&&!r),v="isolate"===c||void 0===c&&null!=o;return f.forEach((e,c)=>{const m=Te(e,c,d,h),b=_e(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?l===i&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?x||!1:void 0,"aria-current":p&&!v&&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=(c+("ArrowDown"===r.key?1:-1)+f.length)%f.length;s(l,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=>{s(l,c),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"}),m,x&&u.createElement(We,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),g})(e,r,n,o,i,a,l,f,s,c))),d+=22*e.items.length+8}),h})({legendGroups:t||[],width:s,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:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let r=0;e.label&&(r+=16);const g=((e,t,r,n,o,i,a,l,s,c)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!t&&!r),v="isolate"===c||void 0===c&&null!=o;return f.forEach((e,c)=>{const m=Te(e,c,d,h),b=_e(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?l===i&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?x||!1:void 0,"aria-current":p&&!v&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:p?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowRight"===r.key||"ArrowLeft"===r.key){r.preventDefault();const e=(c+("ArrowRight"===r.key?1:-1)+f.length)%f.length;s(l,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=>{s(l,c),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"}),m,x&&u.createElement(We,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=26+7*e.label.length}),{items:g,offset:y}})(e,n,o,i,a,l,s,t,c,d);r+=g.offset+5,f.push(Object.assign(Object.assign({label:e.label},g),{offset:r})),h+=r+12});let g=Math.max(0,(r-h)/2);const y=[];return f.forEach((r,n)=>{const o=e[n];o.label&&(y.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),y.push(u.createElement("g",{key:"legend-group-"+n,className:"legend-item",transform:`translate(${g},0)`},r.items)),g+=r.offset+5,e[n+1]&&y.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+n,stroke:"gray",x1:g,y1:-8,x2:g,y2:t+0+8})),g+=12}),u.createElement("g",null,y)})({legendGroups:t||[],title:l,height:c,width:s,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:a}),m=!(!r&&!n);return u.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend"},void 0!==l&&""!==l&&"vertical"===d&&u.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),v)}function Re(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:g="right",foregroundGraphics:y,sceneNodes:p,annotations:v,svgAnnotationRules:m}=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 l?l:"Network Chart"),u.createElement("desc",null,"string"==typeof l?l+" — 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)),v&&v.filter(e=>"widget"!==e.type).map((e,n)=>{if(m){const o=m(e,n,{width:t,height:r,sceneNodes:p});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),y),l&&"string"==typeof l?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?u.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},l):null,function(e){const{legend:t,totalWidth:r,totalHeight:n,margin:o,legendPosition:i="right",title:a,legendHoverBehavior:l,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===i||"bottom"===i;let g,y;return"left"===i?(g=4,y=o.top):"top"===i?(g=0,y=a?32:8):"bottom"===i?(g=0,y=n-o.bottom+50):(g=r-o.right+10,y=o.top),u.createElement("g",{transform:`translate(${g}, ${y})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?u.createElement($e,{config:t.gradient,orientation:f?"horizontal":"vertical",width:f?r:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?u.createElement(je,{legendGroups:t.legendGroups,title:"",width:f?r:100,orientation:f?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:s,highlightedCategory:c,isolatedCategories:d,legendInteraction:h}):t)}({legend:s,totalWidth:n,totalHeight:o,margin:i,legendPosition:g,title:l,legendHoverBehavior:c,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})),null==v?void 0:v.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{var r,n,o,a,l,s,c,d,h;const f=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(!f)return null;const g=i.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(n=f.x)&&void 0!==n?n:0),y=i.top+(null!==(o=f.cy)&&void 0!==o?o:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),v=null!==(l=e.dx)&&void 0!==l?l:0,m=null!==(s=e.dy)&&void 0!==s?s:-16,b=null!==(c=e.width)&&void 0!==c?c:32,x=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:u.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return u.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:g+v-b/2,top:y+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}Re.displayName="NetworkSVGOverlay";const Be="undefined"==typeof window||"undefined"==typeof document,He={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ze(e,t,r){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?r+", empty":`${r}, ${n.join(", ")}`}function Fe({nodes:e,chartType:t}){var r,n,o,i,a;const l=[];for(const t of e){if(l.length>=50)break;l.push({values:{id:(null===(r=t.datum)||void 0===r?void 0:r.id)||t.id||"",x:Math.round(100*(null!==(o=null!==(n=t.cx)&&void 0!==n?n:t.x)&&void 0!==o?o:0))/100+"",y:Math.round(100*(null!==(a=null!==(i=t.cy)&&void 0!==i?i:t.y)&&void 0!==a?a:0))/100+""}})}if(0===l.length)return null;const s=new Set;for(const e of l)for(const t of Object.keys(e.values))s.add(t);const c=Array.from(s);return u.createElement("table",{style:He,role:"table","aria-label":"Data table for "+t},u.createElement("thead",null,u.createElement("tr",null,c.map(e=>u.createElement("th",{key:e},e)))),u.createElement("tbody",null,l.map((e,t)=>u.createElement("tr",{key:t},c.map(t=>{var r;return u.createElement("td",{key:t},null!==(r=e.values[t])&&void 0!==r?r:"")}))),e.length>50&&u.createElement("tr",null,u.createElement("td",{colSpan:c.length},"...and ",e.length-50," more items"))))}function Ye({hoverPoint:e}){let t="";if(e){const r=e.data||e;t="object"==typeof r?"Focused on data point: "+Object.entries(r).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+r}return u.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:He},t)}function Xe(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ge(e,t,r=.3){Xe(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function qe(e,t,r=.6){var n,o,i,a,l;if(!Xe(t))return;const s=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,c=t.r+s*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(l=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==l?l:0;e.beginPath(),e.arc(u,d,c,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 Ve(e,t){var r,n,o,i,a,l;if(!t.pathD)return;e.save();const s=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,l=t.style.fill;o.addColorStop(0,1===a.from?l:"transparent"),o.addColorStop(1,1===a.to?l:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function Ke(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 Ze(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 Qe(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 Ue={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},Je=n.schemeCategory10,et=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],tt=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 rt(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")||tt.has(t)}(n)?r(n):n}const n=e[t];return r?r(n):Je[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Je.length]}function nt(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=Ue[r]||Ue.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:Je;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function ot(t){const r=e.createContext(null),n=it(t);return[function({children:n}){const o=e.useMemo(()=>it(t),[]);return u.createElement(r.Provider,{value:o,children:n})},t=>{var o;const i=null!==(o=e.useContext(r))&&void 0!==o?o:n,a=e.useRef(t);a.current=t;const l=e.useCallback(()=>a.current(i.getState()),[i]),s=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,l,s)}]}function it(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const at={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}},lt={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}},[st,ct]=ot(e=>({theme:at,setTheme(t){e(e=>"light"===t?{theme:at}:"dark"===t?{theme:lt}:{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||{})})})}})),ut={top:20,right:80,bottom:20,left:80},dt={top:40,right:40,bottom:40,left:40},ht=new Set(["chord","force","circlepack","orbit"]),ft=[800,600],gt={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 yt({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:gt},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const l=e.data,s=null==l?void 0:l.__hierarchyNode;if(s){const e=[];let i=s;for(;i;){const a=null!==(o=null!==(r=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==o?o:l.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:gt},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=l.value&&l.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(i=l.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:gt},u.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,d!==c&&` (weighted: ${d.toLocaleString()})`))}const pt=e.forwardRef(function(t,r){var n,o,i,a,s,c,f,g,y,p,v;const{chartType:m,nodes:b,edges:x,data:k,initialEdges:w,nodeIDAccessor:E="id",sourceAccessor:L="source",targetAccessor:A="target",valueAccessor:S="value",childrenAccessor:D,hierarchySum:M,orientation:P="horizontal",nodeAlign:C="justify",nodePaddingRatio:I=.05,nodeWidth:N=15,iterations:O=300,forceStrength:T=.1,padAngle:W=.01,groupWidth:_=20,sortGroups:$,edgeSort:j,treeOrientation:R="vertical",edgeType:B="curve",padding:H,paddingTop:z,tensionConfig:F,showParticles:Y=!1,particleStyle:X,nodeStyle:G,edgeStyle:q,colorBy:V,colorScheme:K="category10",edgeColorBy:Z="source",edgeOpacity:Q=.5,colorByDepth:U=!1,nodeSize:J=8,nodeSizeRange:ee=[5,20],nodeLabel:te,showLabels:re=!0,labelMode:ne,size:oe=ft,responsiveWidth:ie,responsiveHeight:ae,margin:le,className:se,background:ce,enableHover:ue=!0,tooltipContent:de,customHoverBehavior:he,customClickBehavior:fe,onObservation:ge,chartId:ye,onTopologyChange:pe,annotations:ve,svgAnnotationRules:me,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ee,legendIsolatedCategories:Ae,title:Se,foregroundGraphics:Me,backgroundGraphics:Pe,decay:Ce,pulse:Ie,staleness:Ne,thresholds:Oe,accessibleTable:Te,orbitMode:We,orbitSize:_e,orbitSpeed:$e,orbitRevolution:je,orbitRevolutionStyle:He,orbitEccentricity:Xe,orbitShowRings:Ue,orbitAnimated:et}=t,tt=ht.has(m)?dt:ut,[rt,nt]=function(t,r,n){const o=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;a(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&i?i.w:t[0],n&&i?i.h:t[1]]]}(oe,ie,ae),ot=Object.assign(Object.assign({},tt),le),it=nt[0]-ot.left-ot.right,at=nt[1]-ot.top-ot.bottom,lt="function"==typeof Me?Me({size:nt,margin:ot}):Me,st=e.useMemo(()=>Object.assign(Object.assign({},d),F),[F]),gt=e.useMemo(()=>Object.assign(Object.assign({},h),X),[X]),pt=e.useMemo(()=>({chartType:m,nodeIDAccessor:E,sourceAccessor:L,targetAccessor:A,valueAccessor:S,childrenAccessor:D,hierarchySum:M,orientation:P,nodeAlign:C,nodePaddingRatio:I,nodeWidth:N,iterations:O,forceStrength:T,padAngle:W,groupWidth:_,sortGroups:$,edgeSort:j,treeOrientation:R,edgeType:B,padding:H,paddingTop:z,tensionConfig:st,showParticles:Y,particleStyle:gt,nodeStyle:G,edgeStyle:q,nodeLabel:te,showLabels:re,labelMode:ne,colorBy:V,colorScheme:K,edgeColorBy:Z,edgeOpacity:Q,colorByDepth:U,nodeSize:J,nodeSizeRange:ee,decay:Ce,pulse:Ie,staleness:Ne,thresholds:Oe,orbitMode:We,orbitSize:_e,orbitSpeed:$e,orbitRevolution:je,orbitRevolutionStyle:He,orbitEccentricity:Xe,orbitShowRings:Ue,orbitAnimated:et}),[m,E,L,A,S,D,M,P,C,I,N,O,T,W,_,$,j,R,B,H,z,st,Y,gt,G,q,te,re,ne,V,K,Z,Q,U,J,ee,Ce,Ie,Ne,Oe,We,_e,$e,je,He,Xe,Ue,et]),vt=e.useRef(null),mt=e.useRef(0),bt=e.useRef(0),xt=e.useRef(!0),kt=ct(e=>e.theme),wt=e.useRef(()=>{}),Et=e.useRef(null);Et.current||(Et.current=new Le(pt));const[Lt,At]=e.useState(null),[St,Dt]=e.useState(0),[Mt,Pt]=e.useState(0),[Ct,It]=e.useState(!1),Nt=e.useRef(null),Ot=e.useRef(new Map),Tt=e.useRef(0),Wt=e.useCallback(e=>{if("function"==typeof V)return V(e)+"";if("string"==typeof V&&e.data){const t=e.data[V];if(void 0!==t){if(!Ot.current.has(t+"")){const e=Array.isArray(K)?K:Je;Ot.current.set(t+"",e[Tt.current++%e.length])}return Ot.current.get(t+"")}}if(!Ot.current.has(e.id)){const t=Array.isArray(K)?K:Je;Ot.current.set(e.id,t[Tt.current++%t.length])}return Ot.current.get(e.id)},[V,K]),_t=e.useCallback(e=>{if("function"==typeof Z)return Z(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Z&&r?Wt(r):t?Wt(t):"#999"},[Z,Wt]),$t=e.useCallback(e=>{if(!(null==X?void 0:X.colorBy))return _t(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===gt.colorBy&&r?Wt(r):t?Wt(t):"#999"},[null==X?void 0:X.colorBy,gt.colorBy,Wt,_t]),jt="sankey"===m&&Y||!!Ie||null!==(o=null===(n=Et.current)||void 0===n?void 0:n.isAnimating)&&void 0!==o&&o,Rt=e.useCallback(()=>{mt.current&&!jt||mt.current||(mt.current=requestAnimationFrame(()=>wt.current()))},[jt]);e.useEffect(()=>{var e;null===(e=Et.current)||void 0===e||e.updateConfig(pt),xt.current=!0,Rt()},[pt,Rt]),e.useEffect(()=>{xt.current=!0,Rt()},[kt,Rt]);const Bt=e.useCallback(()=>{const e=Et.current;if(!e)return;e.runLayout([it,at]),e.buildScene([it,at]),xt.current=!0;const t=Array.isArray(K)?K:Je,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];Ot.current.has(n.id)||Ot.current.set(n.id,t[e%t.length])}if(Tt.current=r.length,Dt(e.layoutVersion),pe){const{nodes:t,edges:r}=e.getLayoutData();pe(t,r)}},[it,at,pe,K]),Ht=e.useCallback(e=>{const t=Et.current;t&&(t.ingestEdge(e)&&Bt(),Rt())},[Bt,Rt]),zt=e.useCallback(e=>{const t=Et.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&Bt(),Rt()},[Bt,Rt]),Ft=e.useCallback(()=>{var e;null===(e=Et.current)||void 0===e||e.clear(),Ot.current.clear(),Tt.current=0,Dt(0),At(null),Nt.current=null,xt.current=!0,Rt()},[Rt]),Yt=e.useCallback(()=>{const e=Et.current;e&&(e.tension+=999,Bt(),Rt())},[Bt,Rt]);e.useImperativeHandle(r,()=>({push:Ht,pushMany:zt,clear:Ft,getTopology:()=>{var e,t;return null!==(t=null===(e=Et.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Et.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Yt,getTension:()=>{var e,t;return null!==(t=null===(e=Et.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Ht,zt,Ft,Yt]);const Xt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(m),Gt=Xt?k||(Array.isArray(x)?void 0:x):void 0;e.useEffect(()=>{const e=Et.current;if(e)if(Xt&&Gt)e.ingestHierarchy(Gt,[it,at]),e.buildScene([it,at]),xt.current=!0,Rt();else{const t=b||[],r=Array.isArray(x)?x:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[it,at]),e.buildScene([it,at]);const n=Array.isArray(K)?K:Je,o=Array.from(e.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];Ot.current.has(t.id)||Ot.current.set(t.id,n[e%n.length])}Tt.current=o.length,xt.current=!0,Rt()}},[b,x,k,Gt,Xt,it,at,pt,Rt,K]),e.useEffect(()=>{w&&w.length>0&&zt(w)},[]);const qt=e.useCallback(e=>{if(he&&he(e),ge){const t=Date.now();ge(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ye}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ye})}},[he,ge,ye]),Vt=e.useCallback(e=>{if(fe&&fe(e),ge){const t=Date.now();ge(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ye}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ye})}},[fe,ge,ye]),Kt=e.useRef(()=>{}),Zt=e.useRef(()=>{});Kt.current=e=>{if(!ue)return;const t=vt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ot.left,o=e.clientY-r.top-ot.top;if(0>n||n>it||0>o||o>at)return void(Nt.current&&(Nt.current=null,At(null),qt&&(qt(null),xt.current=!0),Rt()));const i=Et.current;if(!i)return;const a=De(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(Nt.current&&(Nt.current=null,At(null),qt&&(qt(null),xt.current=!0),Rt()));const l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:a.type,data:l,x:a.x,y:a.y});Nt.current=s,At(s),qt&&(qt(s),xt.current=!0),Rt()},Zt.current=()=>{Nt.current&&(Nt.current=null,At(null),qt&&(qt(null),xt.current=!0),Rt())};const Qt=e.useRef(()=>{});Qt.current=e=>{if(!fe&&!ge)return;const t=vt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-ot.left,o=e.clientY-r.top-ot.top;if(0>n||n>it||0>o||o>at)return;const i=Et.current;if(!i)return;const a=De(i.sceneNodes,i.sceneEdges,n,o);if(a){const e=a.datum||{};Vt(Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{type:a.type,data:e,x:a.x,y:a.y}))}else Vt(null)},e.useCallback(e=>Kt.current(e),[]);const Ut=e.useCallback(()=>Zt.current(),[]),Jt=e.useCallback(e=>Qt.current(e),[]),er=e.useRef(-1),tr=e.useCallback(e=>{const t=Et.current;if(!t)return;const r=function(e){const t=[];for(const r of e)"circle"===r.type&&null!=r.cx?t.push({x:r.cx,y:r.cy,datum:r.datum}):"rect"===r.type&&null!=r.x?t.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum}):"arc"===r.type&&null!=r.cx&&t.push({x:r.cx,y:r.cy,datum:r.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return;const n=er.current,o=function(e,t,r){switch(e){case"ArrowRight":case"ArrowDown":return r-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return r-1;case"Escape":return-1;default:return null}}(e.key,0>n?-1:n,r.length);if(null===o)return;if(e.preventDefault(),0>o)return er.current=-1,Nt.current=null,At(null),qt&&(qt(null),xt.current=!0),void Rt();const i=0>n?0:o;er.current=i;const a=r[i],l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:"node",data:l,x:a.x,y:a.y});Nt.current=s,At(s),qt&&(qt(s),xt.current=!0),Rt()},[qt,Rt]),rr=e.useCallback(e=>{er.current=-1,Kt.current(e)},[]);wt.current=()=>{var e,t,r,n,o,i,a;mt.current=0;const l=vt.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=Et.current;if(!c)return;const u=performance.now(),d=bt.current?Math.min((u-bt.current)/1e3,.1):.016;bt.current=u;const f=c.advanceTransition(u),g=c.tickAnimation([it,at],d);(f||xt.current||g)&&c.buildScene([it,at]);const y="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,l=t[0]+"px",s=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==s&&(e.style.height=s),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}(l,nt,ot,y))return;s.clearRect(-ot.left,-ot.top,nt[0],nt[1]),ce&&(s.fillStyle=ce,s.fillRect(0,0,it,at)),Ce&&c.applyDecay(),Ie&&c.applyPulse(u),Oe&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(e=null==Ne?void 0:Ne.threshold)&&void 0!==e?e:5e3,v=Ne&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(s.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":Ve(e,r);break;case"line":Ke(e,r);break;case"ribbon":Ze(e,r);break;case"curved":Qe(e,r)}}(s,c.sceneEdges),function(e,t){var r,n,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),Ge(e,t),e.restore())}}(s,c.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()),qe(e,t),e.restore())}}(s,c.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()}}(s,c.sceneNodes),Y&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:h.spawnRate,l=null!==(i=n.maxPerEdge)&&void 0!==i?i:h.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=l)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<l;t++)e.spawn(n)}}(c.particlePool,e,d,gt);const t=.5*(null!==(r=gt.speedMultiplier)&&void 0!==r?r:1);let n;if(gt.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)}c.particlePool.step(d,t,e,n),function(e,t,r,n,o){var i,a;const l=null!==(i=n.radius)&&void 0!==i?i:h.radius,s=null!==(a=n.opacity)&&void 0!==a?a:h.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const s=r[a.edgeIndex];if(s){if("function"==typeof n.color){const t="object"==typeof s.source?s.source:null;e.fillStyle=t?n.color(s,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(s);e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(s,c.particlePool,e,gt,$t)}}v&&(s.globalAlpha=1);const m=xt.current;if(xt.current=!1,m||f||g){const e=vt.current;e&&e.setAttribute("aria-label",ze(null!==(o=null===(n=c.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(m||f||g)&&Pt(e=>e+1),(jt||f||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(mt.current=requestAnimationFrame(()=>wt.current()))},e.useEffect(()=>(Rt(),()=>{mt.current&&(cancelAnimationFrame(mt.current),mt.current=0)}),[Rt]),e.useEffect(()=>{xt.current=!0,Rt()},[m,it,at,ce,Rt]),function(t,r,n,o,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=r.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=s-l.lastIngestTime>c;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}(Ne,Et,xt,Rt,Ct,It);const nr=ue&&Lt?u.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ot.left+Lt.x,top:ot.top+Lt.y,transform:`translate(${Lt.x>.6*it?"calc(-100% - 12px)":"12px"}, ${.3*at>Lt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},de?de(Lt):u.createElement(yt,{data:Lt})):null;if(Be){const e=Et.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(m),r=t?k||(Array.isArray(x)?void 0:x):void 0;if(t&&r)e.ingestHierarchy(r,[it,at]),e.buildScene([it,at]);else{const t=b||[],r=Array.isArray(x)?x:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[it,at]),e.buildScene([it,at]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],r=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],n=null!==(s=null==e?void 0:e.labels)&&void 0!==s?s:[];return u.createElement("div",{className:"stream-network-frame"+(se?" "+se:""),role:"img","aria-label":"string"==typeof Se?Se:"Network chart",style:{position:"relative",width:nt[0],height:nt[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:nt[0],height:nt[1],style:{position:"absolute",left:0,top:0}},Pe&&u.createElement("g",{transform:`translate(${ot.left},${ot.top})`},Pe),u.createElement("g",{transform:`translate(${ot.left},${ot.top})`},ce&&u.createElement("rect",{x:0,y:0,width:it,height:at,fill:ce}),r.map((e,t)=>function(e,t){switch(e.type){case"line":return u.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":case"ribbon":return u.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return u.createElement("path",{key:"net-edge-"+t,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":return u.createElement("circle",{key:"net-circle-"+t,cx:e.cx,cy:e.cy,r:e.r,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"rect":return u.createElement("rect",{key:"net-rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"arc":{const r=e,n=l.arc().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return u.createElement("path",{key:"net-arc-"+t,d:n,transform:`translate(${r.cx},${r.cy})`,fill:r.style.fill||"#4e79a7",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),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(Re,{width:it,height:at,totalWidth:nt[0],totalHeight:nt[1],margin:ot,labels:n,sceneNodes:t,title:Se,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ee,legendIsolatedCategories:Ae,foregroundGraphics:lt,annotations:ve,svgAnnotationRules:me,annotationFrame:0}))}const or=Et.current;return u.createElement("div",{ref:rt,className:"stream-network-frame"+(se?" "+se:""),role:"img","aria-label":"string"==typeof Se?Se:"Network chart",tabIndex:0,style:{position:"relative",width:ie?"100%":nt[0],height:ae?"100%":nt[1],overflow:"visible"},onMouseMove:ue?rr:void 0,onMouseLeave:ue?Ut:void 0,onClick:fe||ge?Jt:void 0,onKeyDown:tr},Pe&&u.createElement("svg",{style:{position:"absolute",top:0,left:0,width:nt[0],height:nt[1],pointerEvents:"none"}},u.createElement("g",{transform:`translate(${ot.left},${ot.top})`},Pe)),u.createElement("canvas",{ref:vt,"aria-label":ze(null!==(f=null===(c=null==or?void 0:or.sceneNodes)||void 0===c?void 0:c.length)&&void 0!==f?f:0,null!==(y=null===(g=null==or?void 0:or.sceneEdges)||void 0===g?void 0:g.length)&&void 0!==y?y:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),u.createElement(Ye,{hoverPoint:Lt}),Te&&u.createElement(Fe,{nodes:null!==(p=null==or?void 0:or.sceneNodes)&&void 0!==p?p:[],edges:null!==(v=null==or?void 0:or.sceneEdges)&&void 0!==v?v:[],chartType:"Network chart"}),u.createElement(Re,{width:it,height:at,totalWidth:nt[0],totalHeight:nt[1],margin:ot,labels:(null==or?void 0:or.labels)||[],sceneNodes:null==or?void 0:or.sceneNodes,title:Se,legend:be,legendPosition:xe,legendHoverBehavior:ke,legendClickBehavior:we,legendHighlightedCategory:Ee,legendIsolatedCategories:Ae,foregroundGraphics:lt,annotations:ve,svgAnnotationRules:me,annotationFrame:Mt}),nr,(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:Ct?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ct?"STALE":"LIVE"))});pt.displayName="StreamNetworkFrame";const vt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function mt(e,t){return"function"==typeof t?t(e):e[t]}function bt(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 xt(e={}){const{fields:t,title:r,format:n,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(r){const t=mt(e,r);a=bt(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=mt(e,o);l.push({label:r,value:bt(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=bt(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=bt(e[t[0]],n))}}const s=Object.assign(Object.assign({},vt),o);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:s},a&&u.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}function kt(e){if(!0===e)return xt();if("function"==typeof e){const t=e;return e=>{const r=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==r?null:u.createElement("div",{className:"semiotic-tooltip",style:vt},r)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?xt(e):xt())}const wt=e.createContext(null);function Et(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function Lt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[At,St]=ot(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Lt(n,t),i=new Map(o.clauses);return i.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),i=new Map(n.clauses);return i.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=Lt(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}})),[Dt,Mt]=ot(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Pt(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=St(e=>e.selections.get(o)),a=St(e=>e.setClause),l=St(e=>e.clearClause),s=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(Et(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:s,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:e.useCallback(()=>{l(o,n)},[l,o,n]),clientId:n}}const Ct=e.createContext(!1),It="#007bff";function Nt(t,r,n="category10"){const o=e.useContext(wt);return e.useMemo(()=>{if(r){if(0===t.length)return o&&Object.keys(o).length>0?e=>o[e]||"#999":void 0;if("function"==typeof r){const e=Array.from(new Set(t.map(e=>r(e)+"")));return o&&Object.keys(o).length>0?e=>o[e]||"#999":nt(e.map(e=>({_cat:e})),"_cat",n)}if(o&&Object.keys(o).length>0){const e=nt(t,r,n);return t=>o[t]||e(t)}return nt(t,r,n)}},[t,r,n,o])}function Ot({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:l}){const s=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(r,n),c=Pt({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:a,clear:l}=Pt({name:r});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&a(t)},[n,a,l,r]),predicate:o,isActive:i}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),d=Mt(e=>e.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||d){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),d&&d(e)}}},[r,u,i,a,l,d]),customClickBehavior:e.useCallback(e=>{var t,r;if(i||d){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},n),{type:"click",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,a,l])}}function Tt(t,r,n){const[o,i]=e.useState(null),[a,l]=e.useState(new Set),s=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&l(t=>{const r=new Set(t);return r.has(e.label)?r.delete(e.label):r.add(e.label),r.size===n.length?new Set:r})},[t,n.length]),u=e.useMemo(()=>{if(!t||"none"===t||!r)return null;const e="string"==typeof r?r:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof r?r(t):null)===o}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const n=e?t[e]:"function"==typeof r?r(t):null;return a.has(n)}}:null},[t,r,o,a]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:s,onLegendClick:c,legendSelectionHook:u}}const Wt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function _t(e,t,r){var n,o,i,a,l,s;const c=Wt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?c.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?c.height:r.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function $t({componentName:e,message:t,width:r,height:n}){return u.createElement("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class jt 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($t,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Rt({componentName:e,width:t,height:r,children:n}){return u.createElement(jt,{fallback:n=>u.createElement($t,{componentName:e,message:n.message,width:t,height:r})},n)}"undefined"!=typeof process&&process;const Bt={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"},Ht={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function zt(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({},Bt),{width:t,height:r})},n||"No data available"):null}function Ft(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({},Ht),{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})})))}function Yt(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function Xt(e,t){var r;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(r=function(e,t,r=3){let n,o=r+1;for(const r of t){const t=Yt(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}(e,t,3))&&void 0!==r?r:null)}function Gt({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function qt({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const r=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){const r=Xt(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}const Vt=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:l,margin:s,className:c,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:f="target",nodeLabel:g,colorBy:y,colorScheme:p="category10",nodeSize:v=8,nodeSizeRange:m=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:w=300,forceStrength:E=.1,tooltip:L,frameProps:A={},onObservation:S,chartId:D,selection:M,linkedHover:P,loading:C,emptyContent:I,legendInteraction:N,legendPosition:O}=t,T=i.width,W=i.height,_=i.enableHover,$=i.showLegend,j=null!==(n=i.showLabels)&&void 0!==n&&n,R=i.title,B=Ft(C,T,W);if(B)return B;const H=zt(a,T,W,I);if(H)return H;const z=a||[],F=l||[],Y=Nt(z,y,p),X=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of z){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[z,y]),G=Tt(N,y,X),q=e.useMemo(()=>e=>{const t={};return t.fill=y?rt(e.data||e,y,Y):It,"number"==typeof v&&(t.r=v),t},[y,Y,v]),V=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),K=e.useMemo(()=>{if(j&&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}},[j,g]),{legend:Z,margin:Q,legendPosition:U}=function({data:t,colorBy:r,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:l={top:50,bottom:60,left:70,right:40}}){const s=e.useContext(Ct),c=void 0!==o?o:!s&&!!r,u=e.useMemo(()=>{if(c&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(o=>{const i=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),a=i?n(i,t,r):r?r(o):"#000000";return{label:o+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",r={fill:t,stroke:t};return void 0!==o&&(r.stroke=o),void 0!==i&&(r.strokeWidth=i),r},type:"fill",items:a,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:rt})},[c,r,t,n]),d=e.useMemo(()=>{const e=Object.assign(Object.assign({},l),a);return u&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[l,a,u,i]);return{legend:u,margin:d,legendPosition:i}}({data:z,colorBy:y,colorScale:Y,showLegend:$,legendPosition:O,userMargin:s,defaults:i.marginDefaults}),{customHoverBehavior:J}=Ot({selection:M,linkedHover:P,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:S,chartType:"ForceDirectedGraph",chartId:D}),ee=qt({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ee?u.createElement($t,{componentName:"ForceDirectedGraph",message:ee,width:T,height:W}):u.createElement(Rt,{componentName:"ForceDirectedGraph",width:T,height:W},u.createElement(pt,Object.assign({ref:o,chartType:"force"},null!=a&&{nodes:z},null!=l&&{edges:F},{size:[T,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:f,iterations:w,forceStrength:E,nodeStyle:q,edgeStyle:V,colorBy:y,colorScheme:p,nodeSize:v,nodeSizeRange:m,nodeLabel:K,showLabels:j,enableHover:_,tooltipContent:!1===L?()=>null:kt(L)||void 0,customHoverBehavior:P||S?J:void 0,legend:Z,legendPosition:U},N&&"none"!==N&&{legendHoverBehavior:G.onLegendHover,legendClickBehavior:G.onLegendClick,legendHighlightedCategory:G.highlightedCategory,legendIsolatedCategories:G.isolatedCategories},{className:c,title:R},A)))});function Kt(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 Zt(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 Qt(e){return"function"==typeof e?e:t=>t[e]||1}function Ut({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const l=Object.assign({fillOpacity:o},i);if("function"==typeof e)l.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?l.fill=rt(e.data||e,t,r):e&&(l.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?l.fill=rt(e.data||e,t,r):e&&(l.fill=n(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*o);return l}}Vt.displayName="ForceDirectedGraph";const Jt=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:a,edges:l,margin:s,className:c,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:f="value",nodeIdAccessor:g="id",colorBy:y,colorScheme:p="category10",edgeColorBy:v="source",orientation:m="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:E=.5,edgeSort:L,tooltip:A,frameProps:S={},onObservation:D,chartId:M,selection:P,linkedHover:C,loading:I,emptyContent:N,legendInteraction:O}=t,T=i.width,W=i.height,_=i.enableHover,$=null===(n=i.showLabels)||void 0===n||n,j=i.title,R=Ft(I,T,W);if(R)return R;const B=zt(l,T,W,N);if(B)return B;const H=l||[],z=e.useMemo(()=>Zt(a,H,d,h),[a,H,d,h]),F=Nt(z,y,p),Y=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of z){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[z,y]),X=Tt(O,y,Y),G=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?rt(e.data||e,y,F):"#4d430c",t},[y,F]),q=e.useMemo(()=>Ut({edgeColorBy:v,colorBy:y,colorScale:F,nodeStyleFn:G,edgeOpacity:E,baseStyle:{stroke:"none",strokeWidth:0}}),[v,y,F,G,E]),V=e.useMemo(()=>{if(!$)return;const e=w||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}},[$,w,g]),K=Object.assign(Object.assign({},i.marginDefaults),s),{customHoverBehavior:Z,customClickBehavior:Q}=Ot({selection:P,linkedHover:C,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:D,chartType:"SankeyDiagram",chartId:M}),U=qt({componentName:"SankeyDiagram",edges:l,edgesRequired:!0});return U?u.createElement($t,{componentName:"SankeyDiagram",message:U,width:T,height:W}):u.createElement(Rt,{componentName:"SankeyDiagram",width:T,height:W},u.createElement(pt,Object.assign({ref:o,chartType:"sankey"},z.length>0&&{nodes:z},null!=l&&{edges:H},{size:[T,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:f,orientation:m,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:G,edgeStyle:q,colorBy:y,colorScheme:p,edgeColorBy:v,edgeOpacity:E,edgeSort:L,nodeLabel:V,showLabels:$,enableHover:_,tooltipContent:!1===A?()=>null:kt(A)||void 0,customHoverBehavior:C||D?Z:void 0,customClickBehavior:D?Q:void 0},O&&"none"!==O&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:c,title:j},S)))});Jt.displayName="SankeyDiagram";const er=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:a,edges:l,margin:s,className:c,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:f="value",nodeIdAccessor:g="id",colorBy:y,colorScheme:p="category10",edgeColorBy:v="source",padAngle:m=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:E,frameProps:L={},onObservation:A,chartId:S,selection:D,linkedHover:M,loading:P,emptyContent:C,legendInteraction:I}=t,N=i.width,O=i.height,T=i.enableHover,W=null===(n=i.showLabels)||void 0===n||n,_=i.title,$=Ft(P,N,O);if($)return $;const j=zt(l,N,O,C);if(j)return j;const R=l||[],B=e.useMemo(()=>Zt(a,R,d,h),[a,R,d,h]),H=Nt(B,y,p),z=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of B){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[B,y]),F=Tt(I,y,z),Y=B.length>0,X=e.useMemo(()=>{if(Y)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(y)o.fill=rt(e.data||e,y,H);else{const i=Array.isArray(p)?p:Ue[p]||Je,a=Array.isArray(i)?i:Je,l=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[l%a.length]}return o}},[Y,y,H,p]),G=e.useMemo(()=>{if(Y)return Ut({edgeColorBy:v,colorBy:y,colorScale:H,nodeStyleFn:X||(e=>({fill:It})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[Y,v,y,H,X,w]),q=e.useMemo(()=>{if(!W)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}},[W,k,g]),V=Object.assign(Object.assign({},i.marginDefaults),s),{customHoverBehavior:K}=Ot({selection:D,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:A,chartType:"ChordDiagram",chartId:S}),Z=qt({componentName:"ChordDiagram",edges:l,edgesRequired:!0});return Z?u.createElement($t,{componentName:"ChordDiagram",message:Z,width:N,height:O}):u.createElement(Rt,{componentName:"ChordDiagram",width:N,height:O},u.createElement(pt,Object.assign({ref:o,chartType:"chord"},B.length>0&&{nodes:B},null!=l&&{edges:R},{size:[N,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:f,padAngle:m,groupWidth:b,sortGroups:x,nodeStyle:X,edgeStyle:G,colorBy:y,colorScheme:p,edgeColorBy:v,edgeOpacity:w,nodeLabel:q,showLabels:W,enableHover:T,tooltipContent:!1===E?()=>null:kt(E)||void 0,customHoverBehavior:M||A?K:void 0},I&&"none"!==I&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:c,title:_},L)))});function tr(t){var r;const n=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:i,className:a,layout:l="tree",orientation:s="vertical",childrenAccessor:c="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:f,colorScheme:g="category10",colorByDepth:y=!1,edgeStyle:p="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,chartId:w,selection:E,linkedHover:L,loading:A,legendInteraction:S}=t,D=n.width,M=n.height,P=n.enableHover,C=null===(r=n.showLabels)||void 0===r||r,I=n.title,N=Ft(A,D,M);if(N)return N;const O=e.useMemo(()=>Kt(null!=o?o:null,c),[o,c]),T=Nt(O,y?void 0:f,g),W=e.useMemo(()=>{if(!f||y)return[];const e=new Set;for(const t of O){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[O,f,y]),_=Tt(S,y?void 0:f,W),$=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?et[(e.depth||0)%et.length]:f?rt(e.data||e,f,T):It,t},[f,y,T]),j=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),R=e.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return Qt(d)},[l,d]),B=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:H}=Ot({selection:E,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),z=Gt({componentName:"TreeDiagram",data:o});return z?u.createElement($t,{componentName:"TreeDiagram",message:z,width:D,height:M}):u.createElement(Rt,{componentName:"TreeDiagram",width:D,height:M},u.createElement(pt,Object.assign({chartType:l},null!=o&&{data:o},{size:[D,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:h,childrenAccessor:c,hierarchySum:R,treeOrientation:s,edgeType:p,nodeStyle:$,edgeStyle:j,colorBy:f,colorScheme:g,colorByDepth:y,nodeSize:m,nodeLabel:C?v||h:void 0,showLabels:C,enableHover:P,tooltipContent:!1===b?()=>null:kt(b)||void 0,customHoverBehavior:L||k?H:void 0},S&&"none"!==S&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories},{className:a,title:I},x)))}function rr(t){var r;const n=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,labelMode:g="leaf",nodeLabel:y,padding:p=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,chartId:E,loading:L,legendInteraction:A}=t,S=n.width,D=n.height,M=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,C=n.title,I=Ft(L,S,D);if(I)return I;const{activeSelectionHook:N,customHoverBehavior:O}=Ot({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,chartType:"Treemap",chartId:E}),T=e.useCallback(e=>{if(!e)return O(null);const t=e.data||e;O({data:(null==t?void 0:t.data)||t})},[O]),W=e.useMemo(()=>Kt(null!=o?o:null,l),[o,l]),_=Nt(W,f?void 0:d,h),$=e.useMemo(()=>{if(!d||f)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,f]),j=Tt(A,f?void 0:d,$),R=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=f?et[(e.depth||0)%et.length]:d?rt(e.data||e,d,_):It,t},[d,f,_]),B=e.useMemo(()=>N?e=>{var t;const r=Object.assign({},R(e));if(N.isActive)if(N.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(r,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(r,x.unselectedStyle)}return r}:R,[R,N,x]),H=e.useMemo(()=>Qt(s),[s]),z=void 0!==v?v:P&&"parent"===g?18:void 0,F=Object.assign(Object.assign({},n.marginDefaults),i),Y=Gt({componentName:"Treemap",data:o});return Y?u.createElement($t,{componentName:"Treemap",message:Y,width:S,height:D}):u.createElement(Rt,{componentName:"Treemap",width:S,height:D},u.createElement(pt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[S,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:H,padding:p,paddingTop:z,nodeStyle:B,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:P?y||c:void 0,showLabels:P,labelMode:g,enableHover:M,tooltipContent:!1===m?()=>null:kt(m)||void 0},(k||w)&&{customHoverBehavior:T},A&&"none"!==A&&{legendHoverBehavior:j.onLegendHover,legendClickBehavior:j.onLegendClick,legendHighlightedCategory:j.highlightedCategory,legendIsolatedCategories:j.isolatedCategories},{className:a,title:C},b)))}function nr(t){var r;const n=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,nodeLabel:g,circleOpacity:y=.7,padding:p=4,tooltip:v,frameProps:m={},onObservation:b,chartId:x,selection:k,linkedHover:w,loading:E,legendInteraction:L}=t,A=n.width,S=n.height,D=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,P=n.title,C=Ft(E,A,S);if(C)return C;const I=e.useMemo(()=>Kt(null!=o?o:null,l),[o,l]),N=Nt(I,f?void 0:d,h),O=e.useMemo(()=>{if(!d||f)return[];const e=new Set;for(const t of I){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[I,d,f]),T=Tt(L,f?void 0:d,O),W=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=f?et[(e.depth||0)%et.length]:d?rt(e.data||e,d,N):It,t},[d,f,N,y]),_=e.useMemo(()=>Qt(s),[s]),$=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:j}=Ot({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),R=Gt({componentName:"CirclePack",data:o});return R?u.createElement($t,{componentName:"CirclePack",message:R,width:A,height:S}):u.createElement(Rt,{componentName:"CirclePack",width:A,height:S},u.createElement(pt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[A,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:_,padding:p,nodeStyle:W,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:M?g||c:void 0,showLabels:M,enableHover:D,tooltipContent:!1===v?()=>null:kt(v)||void 0,customHoverBehavior:w||b?j:void 0},L&&"none"!==L&&{legendHoverBehavior:T.onLegendHover,legendClickBehavior:T.onLegendClick,legendHighlightedCategory:T.highlightedCategory,legendIsolatedCategories:T.isolatedCategories},{className:a,title:P},m)))}er.displayName="ChordDiagram",tr.displayName="TreeDiagram",rr.displayName="Treemap",nr.displayName="CirclePack";const or=et;function ir(t){const r=_t(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:n,margin:o,className:i,childrenAccessor:a="children",nodeIdAccessor:l="name",colorBy:s,colorScheme:c="category10",colorByDepth:d=!1,orbitMode:h="flat",orbitSize:f=2.95,speed:g=.25,revolution:y,revolutionStyle:p,eccentricity:v=1,showRings:m=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:E,annotations:L,frameProps:A={},onObservation:S,chartId:D,selection:M,linkedHover:P,loading:C}=t,I=r.width,N=r.height,O=r.enableHover,T=r.title,W=Ft(C,I,N);if(W)return W;const _=Nt(e.useMemo(()=>Kt(n,a),[n,a]),d?void 0:s,c),$=e.useMemo(()=>{if(Array.isArray(c))return c;const e=Ue[c];return Array.isArray(e)?e:Je},[c]),j=e.useMemo(()=>e=>{var t;const r={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return r.fill=d?n?$[0]:or[(e.depth||0)%or.length]:s?rt(e.data||e,s,_):It,r.opacity=n?1:.85,r},[s,d,_,$]),R=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),B=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:H}=Ot({selection:M,linkedHover:P,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:S,chartType:"OrbitDiagram",chartId:D}),z=e.useMemo(()=>{if(H)return e=>{H(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[H]),F=Gt({componentName:"OrbitDiagram",data:n});return F?u.createElement($t,{componentName:"OrbitDiagram",message:F,width:I,height:N}):u.createElement(Rt,{componentName:"OrbitDiagram",width:I,height:N},u.createElement(pt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[I,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:j,edgeStyle:R,colorBy:s,colorScheme:c,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&O,tooltipContent:k?void 0:!1===w?()=>null:kt(w)||void 0,customHoverBehavior:P||S?z:void 0,foregroundGraphics:E,annotations:L,className:i,title:T,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k},A)))}ir.displayName="OrbitDiagram",exports.ChordDiagram=er,exports.CirclePack=nr,exports.ForceDirectedGraph=Vt,exports.OrbitDiagram=ir,exports.SankeyDiagram=Jt,exports.StreamNetworkFrame=pt,exports.TreeDiagram=tr,exports.Treemap=rr;