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
- import*as e from"react";import{useRef as t,useState as r,useEffect as n,forwardRef as o,useMemo as i,useCallback as a,useImperativeHandle as l,useContext as c,createContext as s,useLayoutEffect as u,useId as d}from"react";import{interpolateNumber as h}from"d3-interpolate";import{min as f,groups as y,max as g,sum as p,mean as v,group as m}from"d3-array";import{schemeCategory10 as b,interpolatePlasma as x,interpolateViridis as k,interpolatePurples as w,interpolateOranges as E,interpolateGreens as L,interpolateReds as A,interpolateBlues as D,schemeSet3 as S,schemeTableau10 as P}from"d3-scale-chromatic";import{forceLink as C,forceSimulation as O,forceManyBody as N,forceX as W,forceY as I}from"d3-force";import{scaleLinear as T,scaleOrdinal as M}from"d3-scale";import{ribbon as $,chord as _}from"d3-chord";import{arc as B,pie as j}from"d3-shape";import{hierarchy as H,partition as R,pack as z,treemap as F,treemapBinary as Y,cluster as X,tree as G}from"d3-hierarchy";const q={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},V={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Z{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 c=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*c*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const s=K(l.bezier,a.t,a.offset);a.x=s.x,a.y=s.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 K(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,[c,s,u,d]=e[a],h=Q(c,s,u,d,l),f=d.x-c.x,y=d.y-c.y,g=Math.sqrt(f*f+y*y);if(g>.001){const e=f/g;h.x+=-y/g*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=Q(n,o,i,a,t),c=a.x-n.x,s=a.y-n.y,u=Math.sqrt(c*c+s*s);if(u>.001){const t=c/u;l.x+=-s/u*r*e.halfWidth*2,l.y+=t*r*e.halfWidth*2}return l}function Q(e,t,r,n,o){const i=1-o,a=i*i,l=a*i,c=o*o,s=c*o;return{x:l*e.x+3*a*o*t.x+3*i*c*r.x+s*n.x,y:l*e.y+3*a*o*t.y+3*i*c*r.y+s*n.y}}function J(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function U(e,t){var r,n=[],o=[],i=[],a={},l=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function s(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=s(n));if(d)c(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),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,l[c]=[];var s,u=0,d=[],h=[];function f(t){var c=[t],s=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;s.length>0;){var f=e[t=s[s.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,c.push(g),s.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=c.length-1;y>=0;--y){var b=c[y];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=d.length,b===t){c.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)}s.pop()}}}for(c=0;t>c;++c)0>r[c]&&f(c);for(c=0;h.length>c;c++){var y=h[c];if(0!==y.length){y.sort(function(e,t){return e-t}),s=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&s.push(y[g]);h[c]=s}}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 c=o[r];if(!c)return!1;var s=e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})});return{leastVertex:i,adjList:s}}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]={}}s(r),r+=1}else r=h}return n}function ee(e){return e.y0-e.y1>0?"up":"down"}function te(e,t){return t(e.source)==t(e.target)}function re(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 ne(e){return e.target.x0-e.source.x1}function oe(e,t){var r=ae(e),n=ne(t)/Math.tan(r);return"up"==ee(e)?e.y1-n:e.y1+n}function ie(e,t){var r=ae(e),n=ne(t)/Math.tan(r);return"up"==ee(e)?e.y1+n:e.y1-n}function ae(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function le(e,t){return t(e)}function ce(e){return ue(e.source)}function se(e){return ue(e.target)}function ue(e){return(e.y0+e.y1)/2}function de(e){return e.virtual?0:e.value}function he(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!te(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!te(e,t)?n+1:n}),r+n}function fe(e){return e.target.depth}function ye(e,t){return e.sourceLinks.length?e.depth:t-1}function ge(e,t){return e.y0-t.y0}function pe(e,t){return t.y0-e.y0}function ve(e,t){return e.y1-t.y1}function me(e,t){return t.y1-e.y1}function be(e,t){return ke(e.source,t.source)||e.index-t.index}function xe(e,t){return ke(e.target,t.target)||e.index-t.index}function ke(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function we(e,t){return Ee(e)==Ee(t)?"bottom"==e.circularLinkType?pe(e,t):ge(e,t):Ee(t)-Ee(e)}function Ee(e){return e.target.column-e.source.column}function Le(e,t){return Ae(e)==Ae(t)}function Ae(e){return e.y0-e.y1>0?"up":"down"}function De(e,t,r,n,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var l=f(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.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}),Se(i.links.filter(function(e){return"top"==e.circularLinkType}),t,r),Se(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,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,te(e,t)&&re(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+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-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,c=e.circularLinkType,s=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});s.sort("bottom"==e.circularLinkType?pe:ge);var u=0;s.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),a=e.target.column,(s=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?me:ve),u=0,s.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-o-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)}),i}function Se(e,t,r){e.sort(we);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(te(e,t)&&re(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&&Pe(e,l)){var c=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Pe(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Ce(e){return function(){return e}}function Oe(e){return e.index}function Ne(e){return e.nodes}function We(e){return e.links}function Ie(e,t,r){var n=y(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(o){var i=o.length;o.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?he(t,r)-he(e,r):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),o.forEach(function(t,o){t.depth==n.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==he(t,r)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+o,t.y1=t.y0+t.value*e.ky)})})}function Te(e,t,r,n,o,i){var a=y(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var l=1,c=i;c>0;--c)s(l*=.99,r),u();function s(t,r){var n=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var l;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&he(o,r)>0){var c=v(o.sourceLinks,se),s=v(o.targetLinks,ce),u=c&&s?(c+s)/2:c||s;if(u){var d=(u-ue(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(l=o.y1-o.y0)/2,o.y1=e.y1/2+l/2;else if(a==n-1&&1==i)o.y0=e.y1/2-(l=o.y1-o.y0)/2,o.y1=e.y1/2+l/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)l=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+l;else{var h=v(o.sourceLinks,se),f=v(o.targetLinks,ce),y=((h&&f?(h+f)/2:h||f)-ue(o))*t;o.y0+=y,o.y1+=y}})})}function u(){a.forEach(function(r){var i,a,l,c=e.y0,s=r.length;for(r.sort(t||ke),l=0;s>l;++l)(a=c-(i=r[l]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+n;if((a=c-n-e.y1)>0)for(c=i.y0-=a,i.y1-=a,l=s-2;l>=0;--l)(a=(i=r[l]).y1+o-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function Me(e){e.nodes.forEach(function(e){e.sourceLinks.sort(xe),e.targetLinks.sort(be)}),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 $e(){var e=0,t=0,r=1,n=1,o=24,i=8,a=null,l=Oe,c=ye,s=void 0,u=32,d=2,h=Ne,v=We;function b(){var b={nodes:h.apply(null,arguments),links:v.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=r,h.y1=n,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return m(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=J(r,n)),"object"!=typeof o&&(o=e.target=J(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(h,l),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 c=U(n);c.sort(function(e,t){return e.length-t.length});var s={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);s[u[0]]||(s[u[0]]={}),s[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||s[n]&&s[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++)})}(h,s),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){le(e,t)!=le(o.source,t)&&le(e,t)!=le(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),te(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(p(e.sourceLinks,de),p(e.targetLinks,de)),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)})})}(h),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})}(h,s,c);var v=i;if(null!==a){var b=y(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),x=g(b,function(e){return e.length});x>1&&(v=Math.max(1,(n-t)*a/(x-1)))}(function(e,t,r){var n=y(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 o=f(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/p(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=g(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/i),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(h,v,o),Ie(h,s,l),Te(h,s,l,v,v,u),Me(h),De(h,l,d,10,8),Ie(h,s,l),Te(h,s,l,v,v,u),Me(h),De(h,l,d,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 le(r.source,t)==le(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(!Le(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=oe(t,e);return e.y1-r}if(t.target.column>e.target.column)return oe(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}})})}(h,l),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return le(r.target,t)==le(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(!Le(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=ie(t,e);return e.y0-r}if(t.source.column>e.source.column)return ie(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}})})}(h,l),function(e){var t=e.nodes,r=e.links,n=!1,o=!1;if(r.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){var i=f(t,function(e){return e.y0}),a=g(t,function(e){return e.y1}),l=(e.y1-e.y0)/(a-i);function c(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),r.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):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})})}}(h),De(h,l,d,10,8)}(b),b}return b.update=function(e){return Me(e),De(e,l,d,10,8),e},b.nodeWidth=function(e){return arguments.length?(o=+e,b):o},b.nodePadding=function(e){return arguments.length?(i=+e,b):i},b.nodePaddingRatio=function(e){return arguments.length?(a=+e,b):a},b.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Ce(e),b):h},b.links=function(e){return arguments.length?(v="function"==typeof e?e:Ce(e),b):v},b.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Ce(e),b):l},b.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Ce(e),b):c},b.nodeSort=function(e){return arguments.length?(s=e,b):s},b.iterations=function(e){return arguments.length?(u=+e,b):u},b.circularLinkGap=function(e){return arguments.length?(d=+e,b):d},b.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],r=+o[1][0],n=+o[1][1],b):[[e,t],[r,n]]},b.size=function(o){return arguments.length?(e=t=0,r=+o[0],n=+o[1],b):[r-e,n-t]},b}const _e=e=>{let t,r,n,o,i,a,l,c,s;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.y1,a=e.target.y0,l=h(i,a),c=l(.5),s=l(.5),`M${t},${i}C${t},${c} ${r},${s} ${r},${a}L${n},${a}C${n},${s} ${o},${c} ${o},${i}Z`):(t=e.source.x1,r=e.target.x0,l=h(t,r),n=l(.5),o=l(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,s=e.y0+e.sankeyWidth/2,`M${t},${i}C${n},${i} ${o},${a} ${r},${a}L${r},${c}C${o},${c} ${n},${s} ${t},${s}Z`)};function Be(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))),c=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-c},${a-r}L${i-c},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,c=o.targetY,s=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${s},${a-h*r}L${s+n},${a-h*r+h*f}L${s+n},${d+h*n-h*f}L${s+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${c-h*r+h*f}L${u-n+f},${c-h*r}L${l},${c-h*r}L${l},${c+h*r}L${u+n},${c+h*r}L${u+n},${d-h*n}L${s-n},${d-h*n}L${s-n},${a+h*r}L${i},${a+h*r}Z`}const je={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(fe))-1:0},justify:ye},He={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,l,c,s,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=$e().extent(m).links(v).nodes(p).nodeAlign(je[h]||ye).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!==(c=null!==(l=n._circularWidth)&&void 0!==l?l:n.width)&&void 0!==c?c:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(s=e.width)&&void 0!==s?s: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,n){var o,i,a,l;const c="vertical"===r.orientation?"down":"right",s=r.nodeStyle,u=r.edgeStyle,d=null!==(o=r.edgeOpacity)&&void 0!==o?o:.5,h=r.edgeColorBy||"source",f=Array.isArray(r.colorScheme)?r.colorScheme:b,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const g=[],p=[],v=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=s?s(t):{},o={fill:n.fill||y.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};g.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const m=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of m){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";u?n=u(e).fill||n:"target"===h&&r?n=y.get(r.id)||n:t&&(n=y.get(t.id)||n);const o=u?u(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,l=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),c=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),s=o.fill||n;p.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+l},${t.sourceY-r}L${t.sourceX+l},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:s,fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:d,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+l}}),p.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-c},${t.targetY-r}L${t.targetX-c},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:s,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-c,x1:t.targetX}});continue}let c;if(c=e.circular&&e.circularPathData?Be(e):_e(e),!c)continue;const s={fill:o.fill||n,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:d,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:s,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,o=r.y1-r.y0;if(0>=e||0>=o)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"):(n[0]/2>r.x0+e/2?(a=r.x0-6,s="end"):(a=r.x1+6,s="start"),l=r.y0+o/2),v.push({x:a,y:l,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:g,sceneEdges:p,labels:v}}},Re={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){var o,i;if(0===e.length)return;const a=null!==(o=r.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),l=null!==(i=r.forceStrength)&&void 0!==i?i:.1,c=n[0]/2,s=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=s+e*Math.sin(n)}}const u=ze(r.nodeSize,r.nodeSizeRange,e),d=C().strength(e=>Math.min(2.5,e.weight?e.weight*l:l)).id(e=>e.id),h=n[1]/n[0],f=O().force("charge",N().strength(e=>-25*(e=>u(e))(e))).force("x",W(n[0]/2).strength(.1*h)).force("y",I(n[1]/2).strength(.1));if(f.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}));f.force("link",d),f.force("link").links(e)}.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;a>e;++e)f.tick();const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){var o,i,a;const l=r.nodeStyle,c=r.edgeStyle,s=ze(r.nodeSize,r.nodeSizeRange,e),u=Array.isArray(r.colorScheme)?r.colorScheme:b,d=new Map;e.forEach((e,t)=>{d.set(e.id,u[t%u.length])});const h=[],f=[],y=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(t),r=l?l(t):{},n={fill:r.fill||d.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:2,opacity:r.opacity};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:g.get(e.source),r="object"==typeof e.target?e.target:g.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!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:.6};f.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=(p=r.nodeLabel)?"function"==typeof p?p:e=>e[p]||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=s(r);y.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:h,sceneEdges:f,labels:y}}};function ze(e,t,r){var n,o;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const i=t||[5,20],a=r.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===a.length)return()=>i[0];const l=null!==(n=f(a))&&void 0!==n?n:0,c=null!==(o=g(a))&&void 0!==o?o:1;if(l===c)return()=>(i[0]+i[1])/2;const s=T().domain([l,c]).range(i).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?i[0]:s(n)}}const Fe=b,Ye={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=r,l=Math.min(n[0],n[1])/2,c=l-i,s=n[0]/2,u=n[1]/2,d=(h=r.valueAccessor)?"function"==typeof h?h:e=>{var t;return null!==(t=e[h])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=f.get("string"==typeof e.source?e.source:e.source.id),n=f.get(t);if(void 0===r||void 0===n)continue;const o=d(e);g[r][n]=o}const p=_().padAngle(o);a&&p.sortGroups(a);const v=p(g),m=v.groups,b=B().innerRadius(c).outerRadius(l);for(const t of m){const r=e[t.index],n=b.centroid(t);r.x=n[0]+s,r.y=n[1]+u,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=x.get("string"==typeof e.source?e.source:e.source.id),n=x.get(t);r&&(e.source=r),n&&(e.target=n)}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 t of v){const r=e[t.source.index].id,n=e[t.target.index].id,o=k.get(`${r}\0${n}`)||k.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:a=20,edgeOpacity:l=.5}=r,c=Math.min(n[0],n[1])/2,s=c-a,u=n[0]/2,d=n[1]/2,h=r.nodeStyle,f=r.edgeStyle,y=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:Fe,p=new Map;e.forEach((e,t)=>{p.set(e.id,g[t%g.length])});const v=$().radius(s),m=[],b=[],x=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=h?h(r).fill||p.get(r.id)||g[t%g.length]:p.get(r.id)||g[t%g.length];const a=h?h(r):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};m.push({type:"arc",cx:u,cy:d,innerR:s,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=v(t);if(!r)continue;const n=Xe(r,u,d);let o="#999";if(f)o=f(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=p.get(r.id)||o:t&&(o=p.get(t.id)||o)}const a=f?f(e):{},c={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:n,style:c,datum:e})}if(!1!==r.showLabels){const t=(k=r.nodeLabel)?"function"==typeof k?k:e=>e[k]||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;x.push({x:u+Math.cos(a)*n,y:d+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:b,labels:x}}};function Xe(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 Ge={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 s=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=H(i,l);u.sum(s),u.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[d,h]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=G();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(u,r,d,h);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=X();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(u,r,d,h);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=F().size([r,n]).tile(Y).padding(a);l>0&&c.paddingTop(l),c(e)}(u,r,d,h);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;z().size([r,n]).padding(i)(e)}(u,r,d,h);break;case"partition":!function(e,t,r,n){var o;R().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(u,r,d,h)}const f=u.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;f.length>t;t++){const n=f[t],i={id:Qe(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?qe(i,n,r):"treemap"===a||"partition"===a?Ve(i,n):"circlepack"===a&&Ze(i,n),i.__hierarchyNode=n,e.push(i),y.set(n,i)}if("tree"===a||"cluster"===a)for(const e of f)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,c,s,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 c={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:c,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=Ke(n,o,a,l,y),d=i(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(c=d.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(s=d.opacity)&&void 0!==s?s:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=Je(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=[],c=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const l=n(r);let s=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=c[r.depth%c.length]);const u={fill:s,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=Je(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,c;const s=[],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 c=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=d[r.depth%d.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};s.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=Je(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===(c=t.data)||void 0===c?void 0:c.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:s,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function qe(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 Ve(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 Ze(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 Ke(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 Qe(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 Je(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 Ue={sankey:He,force:Re,chord:Ye,tree:Ge,cluster:Ge,treemap:Ge,circlepack:Ge,partition:Ge};function et(e){return Ue[e]}class tt{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({},q),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new Z(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},q),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new Z(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],c="function"==typeof o?o:e=>e[o],s="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({},rt(e)),{data:t}))}for(const e of t){const t=c(e)+"",r=s(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},rt(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},rt(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,rt(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,rt(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,r),c=this.edges.get(l);return c?(c.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=et(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=et(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,t,r){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.y1,i=r.y0,a=h(o,i);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:n}}const o=t.x1,i=r.x0,a=h(o,i);return{circular:!1,points:[{x:o,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:n}}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,c=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",s=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=c,t._pulseGlowRadius=s)}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 s=this.edgeTimestamps.get(`${n}\0${a}`);if(!s)continue;const u=e-s;l>u&&(t._pulseIntensity=1-u/l,t._pulseColor=c)}}applyDecay(){var e,t,r,n,o;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,l=this.nodeTimestamps.size;if(1>=l)return;const c=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),s=new Map;for(let e=0;c.length>e;e++)s.set(c[e][0],e);for(const e of this.sceneNodes){const c=e.id;if(!c)continue;const u=s.get(c);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 c=n.metric(l);let s=null;void 0===n.critical||n.critical>c?void 0===n.warning||n.warning>c||(s=o):s=i,s&&(t.style=Object.assign(Object.assign({},t.style),{fill:s}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=s,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 rt(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 nt(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function ot(e,t,r,n,o=30){let i=null,a=o,l=1/0;for(const t of e){const e=it(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=st(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function it(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=nt(Math.atan2(o,n)),l=nt(e.startAngle),c=nt(e.endAngle);if(l>c?a>=l||c>=a:a>=l&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let at=null,lt=null;function ct(){return lt||(at=document.createElement("canvas"),at.width=1,at.height=1,lt=at.getContext("2d")),lt}function st(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=ct();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,c=e.y1+a*o,s=Math.sqrt(Math.pow(t-l,2)+Math.pow(r-c,2));return s>5?null:{type:"edge",datum:e.datum,x:l,y:c,distance:s}}(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=ct();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 ut={fill:t=>e.createElement("rect",{style:t,width:20,height:20}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function dt(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,ut[r])(n(e,t)),o}function ht(){return e.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function ft(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function yt(t){const{legendGroups:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,title:l="Legend",width:c=100,height:s=20,orientation:u="vertical"}=t,d="vertical"===u?(({legendGroups:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a})=>{let l=30;const c=[];return t.forEach((t,s)=>{l+=5,c.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:l,x2:r,y2:l})),l+=10,t.label&&(l+=20,c.push(e.createElement("text",{key:"legend-text-"+s,y:l,className:"legend-group-label"},t.label)),l+=10),c.push(e.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${l})`},((t,r,n,o,i)=>{const{type:a="fill",styleFn:l,items:c}=t,s=[];let u=0;const d=!(!r&&!n);return c.forEach((t,c)=>{const h=dt(t,c,a,l),f=ft(t,o,i),y=i&&i.size>0&&i.has(t.label);s.push(e.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${u})`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:d?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},y&&e.createElement(ht,null),h,e.createElement("text",{y:15,x:30},t.label))),u+=25}),s})(t,n,o,i,a))),l+=25*t.items.length+10}),c})({legendGroups:r,width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a}):(({legendGroups:t,title:r,height:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:l})=>{let c=0;const s=[],u=!1===r?10:40;return t.forEach((r,d)=>{r.label&&(s.push(e.createElement("text",{key:"legend-text-"+d,transform:`translate(${c},${u}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},r.label)),c+=20);const h=((t,r,n,o,i)=>{const{type:a="fill",styleFn:l,items:c}=t,s=[];let u=0;const d=!(!r&&!n);return c.forEach((t,c)=>{const h=dt(t,c,a,l),f=ft(t,o,i),y=i&&i.size>0&&i.has(t.label);s.push(e.createElement("g",{key:"legend-item-"+c,transform:`translate(${u},0)`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:d?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},y&&e.createElement(ht,null),h,e.createElement("text",{y:15,x:25},t.label))),u+=35,u+=8*t.label.length}),{items:s,offset:u}})(r,o,i,a,l);s.push(e.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(${c},${u})`},h.items)),c+=h.offset+5,t[d+1]&&s.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:c,y1:u-10,x2:c,y2:n+u+10})),c+=15}),e.createElement("g",null,!1!==r&&e.createElement("line",{x1:0,x2:c+10,y1:u-10,y2:u-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:r,title:l,height:s,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a});return e.createElement("g",null,void 0!==l&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===u?0:c/2,textAnchor:"horizontal"===u?"start":"middle"},l),d)}function gt(t){const{width:r,height:n,totalWidth:o,totalHeight:i,margin:a,labels:l,title:c,legend:s,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,foregroundGraphics:y,sceneNodes:g,annotations:p,svgAnnotationRules:v}=t;return e.createElement(e.Fragment,null,e.createElement("svg",{width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${a.left},${a.top})`},l.map((t,r)=>e.createElement("text",{key:"label-"+r,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),p&&p.filter(e=>"widget"!==e.type).map((t,o)=>{if(v){const i=v(t,o,{width:r,height:n,sceneNodes:g});if(i)return e.createElement(e.Fragment,{key:"annotation-"+o},i)}return null}),y),c&&"string"==typeof c?e.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},c):c?e.createElement("foreignObject",{x:0,y:0,width:o,height:a.top},c):null,s&&e.createElement("g",{transform:`translate(${o-a.right+10},${a.top})`},"object"==typeof s&&!e.isValidElement(s)&&"legendGroups"in s?e.createElement(yt,{legendGroups:s.legendGroups,title:"",width:100,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f}):s)),null==p?void 0:p.filter(e=>"widget"===e.type&&e.nodeId&&g).map((t,r)=>{var n,o,i,l,c,s,u,d,h;const f=g.find(e=>{var r,n,o,i,a;return e.id===t.nodeId||(null===(r=e.datum)||void 0===r?void 0:r.id)===t.nodeId||(null===(o=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===t.nodeId||(null===(a=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===t.nodeId});if(!f)return null;const y=a.left+(null!==(n=f.cx)&&void 0!==n?n:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),p=a.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),v=null!==(c=t.dx)&&void 0!==c?c:0,m=null!==(s=t.dy)&&void 0!==s?s:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return e.createElement("div",{key:"widget-"+r,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)}))}gt.displayName="NetworkSVGOverlay";const pt="undefined"==typeof window||"undefined"==typeof document;function vt(e,t){var r,n,o,i,a,l;if(!t.pathD)return;e.save();const c=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,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(c)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(c)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(c)),e.restore()}function mt(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function bt(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 xt(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 kt={category10:b,tableau10:P,set3:S,blues:D,reds:A,greens:L,oranges:E,purples:w,viridis:k,plasma:x},wt=b,Et=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function Lt(e,t,r){if("function"==typeof t)return t(e);const n=e[t];return r?r(n):wt[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+""))%wt.length]}function At(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 M().domain(n).range(r).unknown("#999");const i=kt[r]||kt.category10;if(o&&"function"==typeof i)return e=>i(Number(e)/Math.max(...n.map(Number)));{const e=Array.isArray(i)?i:wt;return M().domain(n).range(e).unknown("#999")}}const Dt={top:20,right:80,bottom:20,left:80},St={top:40,right:40,bottom:40,left:40},Pt=new Set(["chord","force","circlepack"]),Ct=[800,600],Ot={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 Nt({data:t}){var r,n,o,i,a,l;if("edge"===t.type){const r=t.data;return e.createElement("div",{className:"semiotic-tooltip",style:Ot},e.createElement("div",{style:{fontWeight:600}},"object"==typeof r.source?r.source.id:r.source," → ","object"==typeof r.target?r.target.id:r.target),null!=r.value&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof r.value?r.value.toLocaleString():r.value+""))}const c=t.data,s=null==c?void 0:c.__hierarchyNode;if(s){const t=[];let a=s;for(;a;){const e=null!==(i=null!==(n=null===(r=a.data)||void 0===r?void 0:r.name)&&void 0!==n?n:null===(o=a.data)||void 0===o?void 0:o.id)&&void 0!==i?i:c.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const l=t.length-1;return e.createElement("div",{className:"semiotic-tooltip",style:Ot},e.createElement("div",null,t.map((t,r)=>e.createElement("span",{key:r},r>0&&e.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),r===l?e.createElement("strong",null,t):e.createElement("span",{style:{opacity:.7}},t)))),null!=c.value&&c.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof c.value?c.value.toLocaleString():c.value+""))}const u=((null===(a=c.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(l=c.targetLinks)||void 0===l?void 0:l.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.createElement("div",{className:"semiotic-tooltip",style:Ot},e.createElement("div",{style:{fontWeight:600}},c.id),null!=c.value&&c.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""),u>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`))}const Wt=o(function(o,c){var s,u,d;const{chartType:h,nodes:f,edges:y,data:g,initialEdges:p,nodeIDAccessor:v="id",sourceAccessor:m="source",targetAccessor:b="target",valueAccessor:x="value",childrenAccessor:k,hierarchySum:w,orientation:E="horizontal",nodeAlign:L="justify",nodePaddingRatio:A=.05,nodeWidth:D=15,iterations:S=300,forceStrength:P=.1,padAngle:C=.01,groupWidth:O=20,sortGroups:N,edgeSort:W,treeOrientation:I="vertical",edgeType:T="curve",padding:M,paddingTop:$,tensionConfig:_,showParticles:j=!1,particleStyle:H,nodeStyle:R,edgeStyle:z,colorBy:F,colorScheme:Y="category10",edgeColorBy:X="source",edgeOpacity:G=.5,colorByDepth:Z=!1,nodeSize:K=8,nodeSizeRange:Q=[5,20],nodeLabel:J,showLabels:U=!0,size:ee=Ct,responsiveWidth:te,responsiveHeight:re,margin:ne,className:oe,background:ie,enableHover:ae=!0,tooltipContent:le,customHoverBehavior:ce,customClickBehavior:se,onObservation:ue,chartId:de,onTopologyChange:he,annotations:fe,svgAnnotationRules:ye,legend:ge,legendHoverBehavior:pe,legendClickBehavior:ve,legendHighlightedCategory:me,legendIsolatedCategories:be,title:xe,foregroundGraphics:ke,backgroundGraphics:we,decay:Ee,pulse:Le,staleness:Ae,thresholds:De}=o,Se=Pt.has(h)?St:Dt,[Pe,Ce]=function(e,o,i){const a=t(null),[l,c]=r(null);return n(()=>{if(!o&&!i)return;const e=a.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;c(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[o,i]),[a,[o&&l?l.w:e[0],i&&l?l.h:e[1]]]}(ee,te,re),Oe=Object.assign(Object.assign({},Se),ne),Ne=Ce[0]-Oe.left-Oe.right,We=Ce[1]-Oe.top-Oe.bottom,Ie=i(()=>Object.assign(Object.assign({},q),_),[_]),Te=i(()=>Object.assign(Object.assign({},V),H),[H]),Me=i(()=>({chartType:h,nodeIDAccessor:v,sourceAccessor:m,targetAccessor:b,valueAccessor:x,childrenAccessor:k,hierarchySum:w,orientation:E,nodeAlign:L,nodePaddingRatio:A,nodeWidth:D,iterations:S,forceStrength:P,padAngle:C,groupWidth:O,sortGroups:N,edgeSort:W,treeOrientation:I,edgeType:T,padding:M,paddingTop:$,tensionConfig:Ie,showParticles:j,particleStyle:Te,nodeStyle:R,edgeStyle:z,nodeLabel:J,showLabels:U,colorBy:F,colorScheme:Y,edgeColorBy:X,edgeOpacity:G,colorByDepth:Z,nodeSize:K,nodeSizeRange:Q,decay:Ee,pulse:Le,staleness:Ae,thresholds:De}),[h,v,m,b,x,k,w,E,L,A,D,S,P,C,O,N,W,I,T,M,$,Ie,j,Te,R,z,J,U,F,Y,X,G,Z,K,Q,Ee,Le,Ae,De]),$e=t(null),_e=t(0),Be=t(0),je=t(!0),He=t(()=>{}),Re=t(null);Re.current||(Re.current=new tt(Me));const[ze,Fe]=r(null),[Ye,Xe]=r(0),[Ge,qe]=r(0),[Ve,Ze]=r(!1),Ke=t(null),Qe=t(new Map),Je=t(0),Ue=a(e=>{if("function"==typeof F)return F(e)+"";if("string"==typeof F&&e.data){const t=e.data[F];if(void 0!==t){if(!Qe.current.has(t+"")){const e=Array.isArray(Y)?Y:wt;Qe.current.set(t+"",e[Je.current++%e.length])}return Qe.current.get(t+"")}}if(!Qe.current.has(e.id)){const t=Array.isArray(Y)?Y:wt;Qe.current.set(e.id,t[Je.current++%t.length])}return Qe.current.get(e.id)},[F,Y]),et=a(e=>{if("function"==typeof X)return X(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===X&&r?Ue(r):t?Ue(t):"#999"},[X,Ue]),rt=a(e=>{if(!(null==H?void 0:H.colorBy))return et(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Te.colorBy&&r?Ue(r):t?Ue(t):"#999"},[null==H?void 0:H.colorBy,Te.colorBy,Ue,et]),nt="sankey"===h&&j||!!Le,it=a(()=>{_e.current&&!nt||_e.current||(_e.current=requestAnimationFrame(()=>He.current()))},[nt]);n(()=>{var e;null===(e=Re.current)||void 0===e||e.updateConfig(Me),je.current=!0,it()},[Me,it]);const at=a(()=>{const e=Re.current;if(!e)return;e.runLayout([Ne,We]),e.buildScene([Ne,We]),je.current=!0;const t=Array.isArray(Y)?Y:wt,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];Qe.current.has(n.id)||Qe.current.set(n.id,t[e%t.length])}if(Je.current=r.length,Xe(e.layoutVersion),he){const{nodes:t,edges:r}=e.getLayoutData();he(t,r)}},[Ne,We,he,Y]),lt=a(e=>{const t=Re.current;t&&(t.ingestEdge(e)&&at(),it())},[at,it]),ct=a(e=>{const t=Re.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&at(),it()},[at,it]),st=a(()=>{var e;null===(e=Re.current)||void 0===e||e.clear(),Qe.current.clear(),Je.current=0,Xe(0),Fe(null),Ke.current=null,je.current=!0,it()},[it]),ut=a(()=>{const e=Re.current;e&&(e.tension+=999,at(),it())},[at,it]);l(c,()=>({push:lt,pushMany:ct,clear:st,getTopology:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Re.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:ut,getTension:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[lt,ct,st,ut]);const dt=["tree","cluster","treemap","circlepack","partition"].includes(h),ht=dt?g||(Array.isArray(y)?void 0:y):void 0;n(()=>{const e=Re.current;if(e)if(dt&&ht)e.ingestHierarchy(ht,[Ne,We]),e.buildScene([Ne,We]),je.current=!0,it();else{const t=f||[],r=Array.isArray(y)?y:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[Ne,We]),e.buildScene([Ne,We]);const n=Array.isArray(Y)?Y:wt,o=Array.from(e.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];Qe.current.has(t.id)||Qe.current.set(t.id,n[e%n.length])}Je.current=o.length,je.current=!0,it()}},[f,y,g,ht,dt,Ne,We,Me,it,Y]),n(()=>{p&&p.length>0&&ct(p)},[]);const ft=a(e=>{if(ce&&ce(e),ue){const t=Date.now();ue(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:de}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:de})}},[ce,ue,de]),yt=a(e=>{if(se&&se(e),ue){const t=Date.now();ue(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:de}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:de})}},[se,ue,de]),kt=t(()=>{}),Et=t(()=>{});kt.current=e=>{if(!ae)return;const t=$e.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Oe.left,o=e.clientY-r.top-Oe.top;if(0>n||n>Ne||0>o||o>We)return void(Ke.current&&(Ke.current=null,Fe(null),ft&&(ft(null),je.current=!0),it()));const i=Re.current;if(!i)return;const a=ot(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(Ke.current&&(Ke.current=null,Fe(null),ft&&(ft(null),je.current=!0),it()));const l={type:a.type,data:a.datum,x:a.x,y:a.y};Ke.current=l,Fe(l),ft&&(ft(l),je.current=!0),it()},Et.current=()=>{Ke.current&&(Ke.current=null,Fe(null),ft&&(ft(null),je.current=!0),it())};const Lt=t(()=>{});Lt.current=e=>{if(!se&&!ue)return;const t=$e.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Oe.left,o=e.clientY-r.top-Oe.top;if(0>n||n>Ne||0>o||o>We)return;const i=Re.current;if(!i)return;const a=ot(i.sceneNodes,i.sceneEdges,n,o);yt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},a(e=>kt.current(e),[]);const At=a(()=>Et.current(),[]),Ot=a(e=>Lt.current(e),[]),Wt=t(-1),It=a(e=>{const t=Re.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=Wt.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 Wt.current=-1,Ke.current=null,Fe(null),ft&&(ft(null),je.current=!0),void it();const i=0>n?0:o;Wt.current=i;const a=r[i],l={type:"node",data:a.datum,x:a.x,y:a.y};Ke.current=l,Fe(l),ft&&(ft(l),je.current=!0),it()},[ft,it]),Tt=a(e=>{Wt.current=-1,kt.current(e)},[]);He.current=()=>{var e,t,r;_e.current=0;const n=$e.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Re.current;if(!i)return;const a=performance.now(),l=Be.current?Math.min((a-Be.current)/1e3,.1):.016;Be.current=a;const c=i.advanceTransition(a);(c||je.current)&&i.buildScene([Ne,We]);const s="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ce[0]*s,n.height=Ce[1]*s,n.style.width=Ce[0]+"px",n.style.height=Ce[1]+"px",o.scale(s,s),o.translate(Oe.left,Oe.top),o.clearRect(-Oe.left,-Oe.top,Ce[0],Ce[1]),ie&&(o.fillStyle=ie,o.fillRect(0,0,Ne,We)),Ee&&i.applyDecay(),Le&&i.applyPulse(a),De&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==Ae?void 0:Ae.threshold)&&void 0!==e?e:5e3,d=Ae&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(o.globalAlpha=null!==(t=null==Ae?void 0:Ae.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":vt(e,r);break;case"line":mt(e,r);break;case"ribbon":bt(e,r);break;case"curved":xt(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),j&&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:V.spawnRate,l=null!==(i=n.maxPerEdge)&&void 0!==i?i:V.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),c=Math.floor(i),s=i-c;let u=c;Math.random()<s&&u++;for(let t=0;u>t&&e.countForEdge(n)<l;t++)e.spawn(n)}}(i.particlePool,e,l,Te);const t=.5*(null!==(r=Te.speedMultiplier)&&void 0!==r?r:1);let n;if(Te.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:V.radius,c=null!==(a=n.opacity)&&void 0!==a?a:V.opacity;e.globalAlpha=c;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const c=r[a.edgeIndex];if(c){if("function"==typeof n.color){const t="object"==typeof c.source?c.source:null;e.fillStyle=t?n.color(c,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(c);e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(o,i.particlePool,e,Te,rt)}}d&&(o.globalAlpha=1);const h=je.current;je.current=!1,(h||c)&&qe(e=>e+1),(nt||c||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(_e.current=requestAnimationFrame(()=>He.current()))},n(()=>(it(),()=>{_e.current&&(cancelAnimationFrame(_e.current),_e.current=0)}),[it]),n(()=>{je.current=!0,it()},[h,Ne,We,ie,it]),function(e,t,r,o,i,a){n(()=>{if(!e)return;const n=setInterval(()=>{var n;const l=t.current;if(!l||0===l.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=e.threshold)&&void 0!==n?n:5e3,u=c-l.lastIngestTime>s;u!==i&&(a(u),r.current=!0,o())},1e3);return()=>clearInterval(n)},[e,i,o])}(Ae,Re,je,it,Ve,Ze);const Mt=ae&&ze?e.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Oe.left+ze.x,top:Oe.top+ze.y,transform:`translate(${ze.x>.6*Ne?"calc(-100% - 12px)":"12px"}, ${.3*We>ze.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},le?le(ze):e.createElement(Nt,{data:ze})):null;if(pt){const t=Re.current;if(t){const e=["tree","cluster","treemap","circlepack","partition"].includes(h),r=e?g||(Array.isArray(y)?void 0:y):void 0;if(e&&r)t.ingestHierarchy(r,[Ne,We]),t.buildScene([Ne,We]);else{const e=f||[],r=Array.isArray(y)?y:[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[Ne,We]),t.buildScene([Ne,We]))}}const r=null!==(s=null==t?void 0:t.sceneNodes)&&void 0!==s?s:[],n=null!==(u=null==t?void 0:t.sceneEdges)&&void 0!==u?u:[],o=null!==(d=null==t?void 0:t.labels)&&void 0!==d?d:[];return e.createElement("div",{className:"stream-network-frame"+(oe?" "+oe:""),role:"img","aria-label":"string"==typeof xe?xe:"Network chart",style:{position:"relative",width:Ce[0],height:Ce[1]}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ce[0],height:Ce[1],style:{position:"absolute",left:0,top:0}},we&&e.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},we),e.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},ie&&e.createElement("rect",{x:0,y:0,width:Ne,height:We,fill:ie}),n.map((t,r)=>function(t,r){switch(t.type){case"line":return e.createElement("line",{key:"net-edge-"+r,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":case"ribbon":return e.createElement("path",{key:"net-edge-"+r,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return e.createElement("path",{key:"net-edge-"+r,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,r)).filter(Boolean),r.map((t,r)=>function(t,r){switch(t.type){case"circle":return e.createElement("circle",{key:"net-circle-"+r,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return e.createElement("rect",{key:"net-rect-"+r,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const n=t,o=B().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return e.createElement("path",{key:"net-arc-"+r,d:o,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,r)).filter(Boolean),o.map((t,r)=>function(t,r){return e.createElement("text",{key:"net-label-"+r,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,r)).filter(Boolean))),e.createElement(gt,{width:Ne,height:We,totalWidth:Ce[0],totalHeight:Ce[1],margin:Oe,labels:o,sceneNodes:r,title:xe,legend:ge,legendHoverBehavior:pe,legendClickBehavior:ve,legendHighlightedCategory:me,legendIsolatedCategories:be,foregroundGraphics:ke,annotations:fe,svgAnnotationRules:ye,annotationFrame:0}))}const $t=Re.current;return e.createElement("div",{ref:Pe,className:"stream-network-frame"+(oe?" "+oe:""),role:"img","aria-label":"string"==typeof xe?xe:"Network chart",tabIndex:0,style:{position:"relative",width:te?"100%":Ce[0],height:re?"100%":Ce[1]},onMouseMove:ae?Tt:void 0,onMouseLeave:ae?At:void 0,onClick:se||ue?Ot:void 0,onKeyDown:It},we&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ce[0],height:Ce[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${Oe.left},${Oe.top})`},we)),e.createElement("canvas",{ref:$e,style:{position:"absolute",top:0,left:0}}),e.createElement(gt,{width:Ne,height:We,totalWidth:Ce[0],totalHeight:Ce[1],margin:Oe,labels:(null==$t?void 0:$t.labels)||[],sceneNodes:null==$t?void 0:$t.sceneNodes,title:xe,legend:ge,legendHoverBehavior:pe,legendClickBehavior:ve,legendHighlightedCategory:me,legendIsolatedCategories:be,foregroundGraphics:ke,annotations:fe,svgAnnotationRules:ye,annotationFrame:Ge}),Mt,(null==Ae?void 0:Ae.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ae.badgePosition?{top:4,left:4}:"bottom-left"===Ae.badgePosition?{bottom:4,left:4}:"bottom-right"===Ae.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Ve?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ve?"STALE":"LIVE"))});Wt.displayName="StreamNetworkFrame";const It={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 Tt(e,t){return"function"==typeof t?t(e):e[t]}function Mt(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 $t(t={}){const{fields:r,title:n,format:o,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let l;const c=[];if(n){const e=Tt(t,n);l=Mt(e,o)}if(r&&r.length>0)r.forEach(e=>{let r,n,i;"string"==typeof e?(r=e,n=e,i=o):(r=e.label,n=e.accessor||e.key||"",i=e.format||o);const a=Tt(t,n);c.push({label:r,value:Mt(a,i)})});else if(!n){const e=["value","y","name","id","label"];for(const r of e)if(void 0!==t[r]){l=Mt(t[r],o);break}if(!l){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(l=Mt(t[e[0]],o))}}const s=Object.assign(Object.assign({},It),i);return e.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:s},l&&e.createElement("div",{style:{fontWeight:c.length>0?"bold":"normal"}},l),c.map((t,r)=>e.createElement("div",{key:r,style:{marginTop:0===r&&l?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function _t(e){return!0===e?$t():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?$t(e):$t())}const Bt=s(null),jt="undefined"!=typeof window?u:n;function Ht(t){const n=s(null),o=Rt(t);return[function({children:r}){const o=i(()=>Rt(t),[]);return e.createElement(n.Provider,{value:o,children:r})},e=>{var t;const i=null!==(t=c(n))&&void 0!==t?t:o;return function(e,t){const[n,o]=r(t);return jt(()=>e(()=>o(t)),[e]),n}(i.subscribe,()=>e(i.getState()))}]}function Rt(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 zt(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 Ft(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Yt,Xt]=Ht(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Ft(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=Ft(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}})}})),[Gt,qt]=Ht(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 Vt(e){const t=d(),r=e.clientId||t,{name:n}=e,o=Xt(e=>e.selections.get(n)),l=Xt(e=>e.setClause),c=Xt(e=>e.clearClause),s=i(()=>!!o&&o.clauses.size>0,[o]);return{predicate:i(()=>o&&0!==o.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(zt(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(o,r):()=>!0,[o,r]),isActive:s,selectPoints:a(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};l(n,{clientId:r,type:"point",fields:t})},[r,n,l]),selectInterval:a(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};l(n,{clientId:r,type:"interval",fields:t})},[r,n,l]),clear:a(()=>{c(n,r)},[c,n,r]),clientId:r}}const Zt=s(!1),Kt="#007bff";function Qt(e,t,r="category10"){const n=c(Bt);return i(()=>{if(t&&"function"!=typeof t)return n&&Object.keys(n).length>0?o=>n[o]||At(e,t,r)(o):At(e,t,r)},[e,t,r,n])}function Jt({selection:e,linkedHover:t,fallbackFields:r=[],unwrapData:n=!1,onObservation:o,chartType:i,chartId:l}){const c=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,r),s=Vt({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const t=e.name||"hover",{fields:r}=e,{predicate:n,isActive:o,selectPoints:i,clear:l}=Vt({name:t});return{onHover:a(e=>{if(!e)return void l();const t={};for(const n of r){const r=e[n];void 0!==r&&(t[n]=[r])}Object.keys(t).length>0&&i(t)},[r,i,l,t]),predicate:n,isActive:o}}({name:(null==c?void 0:c.name)||"hover",fields:(null==c?void 0:c.fields)||r||[]}),d=qt(e=>e.pushObservation);return{activeSelectionHook:e?{isActive:s.isActive,predicate:s.predicate}:null,customHoverBehavior:a(e=>{var r,n;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(o||d){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:l};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(n=e.y)&&void 0!==n?n:0});o&&o(a),d&&d(a)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});o&&o(e),d&&d(e)}}},[t,u,o,i,l,d]),customClickBehavior:a(e=>{var t,r;if(o||d){const n={timestamp:Date.now(),chartType:i||"unknown",chartId:l};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},n),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});o&&o(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});o&&o(e),d&&d(e)}}},[o,d,i,l])}}function Ut(e,t,n){const[o,l]=r(null),[c,s]=r(new Set),u=a(t=>{"highlight"===e&&l(t?t.label:null)},[e]),d=a(t=>{"isolate"===e&&s(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),h=i(()=>{if(!e||"none"===e||!t)return null;const r="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(r?e[r]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&c.size>0?{isActive:!0,predicate:e=>{const n=r?e[r]:"function"==typeof t?t(e):null;return c.has(n)}}:null},[e,t,o,c]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?c:new Set,onLegendHover:u,onLegendClick:d,legendSelectionHook:h}}const er={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 tr(e,t,r){var n,o,i,a,l,c;const s=er[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)?s.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?s.height:r.height,showAxes:s.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:s.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||s.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:s.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:s.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:s.marginDefaults}}function rr({componentName:t,message:r,width:n,height:o}){return e.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},r)))}class nr extends e.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:t}=this.props,r=this.state.error;return"function"==typeof t?t(r):void 0!==t?t:e.createElement(rr,{componentName:"ChartErrorBoundary",message:r.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function or({componentName:t,width:r,height:n,children:o}){return e.createElement(nr,{fallback:o=>e.createElement(rr,{componentName:t,message:o.message,width:r,height:n})},o)}"undefined"!=typeof process&&process;const ir={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"},ar={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function lr(t,r,n,o){return!1===o||t&&Array.isArray(t)&&t.length>0||t&&!Array.isArray(t)?null:e.createElement("div",{style:Object.assign(Object.assign({},ir),{width:r,height:n})},o||"No data available")}function cr(t,r,n){if(!t)return null;const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),l=Math.floor((n-(o*(i+a)-a))/2);return e.createElement("div",{style:{width:r,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(t,n)=>e.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ar),{position:"absolute",top:l+n*(i+a),left:Math.floor(.1*r),width:30+Math.round(50*Math.random())+"%",height:i,opacity:.5+n%2*.2})})))}function sr(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 ur(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=sr(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 dr({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 hr({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=ur(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 fr(t){var r;const n=tr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:a,margin:l,className:s,nodeIDAccessor:u="id",sourceAccessor:d="source",targetAccessor:h="target",nodeLabel:f,colorBy:y,colorScheme:g="category10",nodeSize:p=8,nodeSizeRange:v=[5,20],edgeWidth:m=1,edgeColor:b="#999",edgeOpacity:x=.6,iterations:k=300,forceStrength:w=.1,tooltip:E,frameProps:L={},onObservation:A,chartId:D,selection:S,linkedHover:P,loading:C,emptyContent:O,legendInteraction:N}=t,W=n.width,I=n.height,T=n.enableHover,M=n.showLegend,$=null!==(r=n.showLabels)&&void 0!==r&&r,_=n.title,B=cr(C,W,I);if(B)return B;const j=lr(a,W,I,O);if(j)return j;const H=o||[],R=a||[],z=Qt(H,y,g),F=i(()=>{if(!y)return[];const e=new Set;for(const t of H){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[H,y]),Y=Ut(N,y,F),X=i(()=>e=>{const t={};return t.fill=y?Lt(e.data||e,y,z):Kt,"number"==typeof p&&(t.r=p),t},[y,z,p]),G=i(()=>e=>({stroke:b,strokeWidth:"number"==typeof m?m:"function"==typeof m?m(e):e[m]||1,opacity:x}),[m,b,x]),q=i(()=>{if($&&f)return"function"==typeof f?f:e=>e[f]},[$,f]),{legend:V,margin:Z}=function({data:e,colorBy:t,colorScale:r,showLegend:n,userMargin:o,defaults:a={top:50,bottom:60,left:70,right:40}}){const l=c(Zt),s=void 0!==n?n:!l&&!!t,u=i(()=>{if(s&&t)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:e,colorBy:t,colorScale:r,getColor:Lt})},[s,t,e,r]),d=i(()=>{const e=Object.assign(Object.assign({},a),o);return u&&120>e.right&&(e.right=120),e},[a,o,u]);return{legend:u,margin:d}}({data:H,colorBy:y,colorScale:z,showLegend:M,userMargin:l,defaults:n.marginDefaults}),{customHoverBehavior:K}=Jt({selection:S,linkedHover:P,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:A,chartType:"ForceDirectedGraph",chartId:D}),Q=hr({componentName:"ForceDirectedGraph",nodes:o,edges:a,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:u}});return Q?e.createElement(rr,{componentName:"ForceDirectedGraph",message:Q,width:W,height:I}):e.createElement(or,{componentName:"ForceDirectedGraph",width:W,height:I},e.createElement(Wt,Object.assign({chartType:"force",nodes:H,edges:R,size:[W,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,nodeIDAccessor:u,sourceAccessor:d,targetAccessor:h,iterations:k,forceStrength:w,nodeStyle:X,edgeStyle:G,colorBy:y,colorScheme:g,nodeSize:p,nodeSizeRange:v,nodeLabel:q,showLabels:$,enableHover:T,tooltipContent:E?e=>_t(E)(e.data):void 0,customHoverBehavior:P||A?K:void 0,legend:V},N&&"none"!==N&&{legendHoverBehavior:Y.onLegendHover,legendClickBehavior:Y.onLegendClick,legendHighlightedCategory:Y.highlightedCategory,legendIsolatedCategories:Y.isolatedCategories},{className:s,title:_},L)))}function yr(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function gr(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],i="function"==typeof n?n(e):e[n];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function pr(e){return"function"==typeof e?e:t=>t[e]||1}function vr({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const 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=Lt(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=Lt(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 mr(t){var r;const n=tr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:o,edges:a,margin:l,className:c,sourceAccessor:s="source",targetAccessor:u="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:P,loading:C,emptyContent:O,legendInteraction:N}=t,W=n.width,I=n.height,T=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,$=n.title,_=cr(C,W,I);if(_)return _;const B=lr(a,W,I,O);if(B)return B;const j=a||[],H=i(()=>gr(o,j,s,u),[o,j,s,u]),R=Qt(H,f,y),z=i(()=>{if(!f)return[];const e=new Set;for(const t of H){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[H,f]),F=Ut(N,f,z),Y=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?Lt(e.data||e,f,R):"#4d430c",t},[f,R]),X=i(()=>vr({edgeColorBy:g,colorBy:f,colorScale:R,nodeStyleFn:Y,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[g,f,R,Y,k]),G=i(()=>{if(!M)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[M,x,h]),q=Object.assign(Object.assign({},n.marginDefaults),l),{customHoverBehavior:V,customClickBehavior:Z}=Jt({selection:S,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:A,chartType:"SankeyDiagram",chartId:D}),K=hr({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return K?e.createElement(rr,{componentName:"SankeyDiagram",message:K,width:W,height:I}):e.createElement(or,{componentName:"SankeyDiagram",width:W,height:I},e.createElement(Wt,Object.assign({chartType:"sankey",nodes:H,edges:j,size:[W,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:u,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:M,enableHover:T,tooltipContent:E?e=>_t(E)(e.data):void 0,customHoverBehavior:P||A?V:void 0,customClickBehavior:A?Z:void 0},N&&"none"!==N&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:c,title:$},L)))}function br(t){var r;const n=tr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:o,edges:a,margin:l,className:c,sourceAccessor:s="source",targetAccessor:u="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:P,legendInteraction:C}=t,O=n.width,N=n.height,W=n.enableHover,I=null===(r=n.showLabels)||void 0===r||r,T=n.title,M=cr(S,O,N);if(M)return M;const $=lr(a,O,N,P);if($)return $;const _=a||[],B=i(()=>gr(o,_,s,u),[o,_,s,u]),j=Qt(B,f,y),H=i(()=>{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]),R=Ut(C,f,H),z=i(()=>(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=Lt(e.data||e,f,j);else{const i=Array.isArray(y)?y:kt[y]||wt,a=Array.isArray(i)?i:wt,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,j,y]),F=i(()=>vr({edgeColorBy:g,colorBy:f,colorScale:j,nodeStyleFn:z,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[g,f,j,z,x]),Y=i(()=>{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),l),{customHoverBehavior:G}=Jt({selection:A,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,chartType:"ChordDiagram",chartId:L}),q=hr({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return q?e.createElement(rr,{componentName:"ChordDiagram",message:q,width:O,height:N}):e.createElement(or,{componentName:"ChordDiagram",width:O,height:N},e.createElement(Wt,Object.assign({chartType:"chord",nodes:B,edges:_,size:[O,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:h,sourceAccessor:s,targetAccessor:u,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:W,tooltipContent:k?e=>_t(k)(e.data):void 0,customHoverBehavior:D||E?G:void 0},C&&"none"!==C&&{legendHoverBehavior:R.onLegendHover,legendClickBehavior:R.onLegendClick,legendHighlightedCategory:R.highlightedCategory,legendIsolatedCategories:R.isolatedCategories},{className:c,title:T},w)))}function xr(t){var r;const n=tr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:l,layout:c="tree",orientation:s="vertical",childrenAccessor:u="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,P=n.height,C=n.enableHover,O=null===(r=n.showLabels)||void 0===r||r,N=n.title,W=cr(A,S,P);if(W)return W;const I=i(()=>yr(o,u),[o,u]),T=Qt(I,g?void 0:f,y),M=i(()=>{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]),$=Ut(D,g?void 0:f,M),_=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Et[(e.depth||0)%Et.length]:f?Lt(e.data||e,f,T):Kt,t},[f,g,T]),B=i(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),j=i(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return pr(d)},[c,d]),H=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:R}=Jt({selection:E,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),z=dr({componentName:"TreeDiagram",data:o});return z?e.createElement(rr,{componentName:"TreeDiagram",message:z,width:S,height:P}):e.createElement(or,{componentName:"TreeDiagram",width:S,height:P},e.createElement(Wt,Object.assign({chartType:c,data:o,size:[S,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:j,treeOrientation:s,edgeType:p,nodeStyle:_,edgeStyle:B,colorBy:f,colorScheme:y,colorByDepth:g,nodeSize:m,nodeLabel:O?v||h:void 0,showLabels:O,enableHover:C,tooltipContent:b?e=>_t(b)(e.data):void 0,customHoverBehavior:L||k?R:void 0},D&&"none"!==D&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories},{className:l,title:N},x)))}function kr(t){var r;const n=tr(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:l,className:c,childrenAccessor:s="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:f="category10",colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:p,padding:v=4,paddingTop:m,tooltip:b,frameProps:x={},selection:k,linkedHover:w,onObservation:E,chartId:L,loading:A,legendInteraction:D}=t,S=n.width,P=n.height,C=n.enableHover,O=null===(r=n.showLabels)||void 0===r||r,N=n.title,W=cr(A,S,P);if(W)return W;const{activeSelectionHook:I,customHoverBehavior:T}=Jt({selection:k,linkedHover:w,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:E,chartType:"Treemap",chartId:L}),M=a(e=>{if(!e)return T(null);const t=e.data||e;T({data:(null==t?void 0:t.data)||t})},[T]),$=i(()=>yr(o,s),[o,s]),_=Qt($,y?void 0:h,f),B=i(()=>{if(!h||y)return[];const e=new Set;for(const t of $){const r="function"==typeof h?h(t):t[h];null!=r&&e.add(r+"")}return Array.from(e)},[$,h,y]),j=Ut(D,y?void 0:h,B),H=i(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?Et[(e.depth||0)%Et.length]:h?Lt(e.data||e,h,_):Kt,t},[h,y,_]),R=i(()=>I?e=>{var t;const r=Object.assign({},H(e));if(I.isActive)if(I.predicate(e.data||e))(null==k?void 0:k.selectedStyle)&&Object.assign(r,k.selectedStyle);else{const e=null!==(t=null==k?void 0:k.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==k?void 0:k.unselectedStyle)&&Object.assign(r,k.unselectedStyle)}return r}:H,[H,I,k]),z=i(()=>pr(u),[u]),F=void 0!==m?m:O&&"parent"===g?18:void 0,Y=Object.assign(Object.assign({},n.marginDefaults),l),X=dr({componentName:"Treemap",data:o});return X?e.createElement(rr,{componentName:"Treemap",message:X,width:S,height:P}):e.createElement(or,{componentName:"Treemap",width:S,height:P},e.createElement(Wt,Object.assign({chartType:"treemap",data:o,size:[S,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,nodeIDAccessor:d,childrenAccessor:s,hierarchySum:z,padding:v,paddingTop:F,nodeStyle:R,colorBy:h,colorScheme:f,colorByDepth:y,nodeLabel:O?p||d:void 0,showLabels:O,enableHover:C,tooltipContent:b?e=>_t(b)(e.data):void 0},(w||E)&&{customHoverBehavior:M},D&&"none"!==D&&{legendHoverBehavior:j.onLegendHover,legendClickBehavior:j.onLegendClick,legendHighlightedCategory:j.highlightedCategory,legendIsolatedCategories:j.isolatedCategories},{className:c,title:N},x)))}function wr(t){var r;const n=tr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:l,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:u="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,P=null===(r=n.showLabels)||void 0===r||r,C=n.title,O=cr(E,A,D);if(O)return O;const N=i(()=>yr(o,c),[o,c]),W=Qt(N,f?void 0:d,h),I=i(()=>{if(!d||f)return[];const e=new Set;for(const t of N){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[N,d,f]),T=Ut(L,f?void 0:d,I),M=i(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=f?Et[(e.depth||0)%Et.length]:d?Lt(e.data||e,d,W):Kt,t},[d,f,W,g]),$=i(()=>pr(s),[s]),_=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:B}=Jt({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),j=dr({componentName:"CirclePack",data:o});return j?e.createElement(rr,{componentName:"CirclePack",message:j,width:A,height:D}):e.createElement(or,{componentName:"CirclePack",width:A,height:D},e.createElement(Wt,Object.assign({chartType:"circlepack",data:o,size:[A,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:$,padding:p,nodeStyle:M,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:P?y||u:void 0,showLabels:P,enableHover:S,tooltipContent:v?e=>_t(v)(e.data):void 0,customHoverBehavior:w||b?B:void 0},L&&"none"!==L&&{legendHoverBehavior:T.onLegendHover,legendClickBehavior:T.onLegendClick,legendHighlightedCategory:T.highlightedCategory,legendIsolatedCategories:T.isolatedCategories},{className:l,title:C},m)))}fr.displayName="ForceDirectedGraph",mr.displayName="SankeyDiagram",br.displayName="ChordDiagram",xr.displayName="TreeDiagram",kr.displayName="Treemap",wr.displayName="CirclePack";const Er=["#93c5fd","#fca5a5","#86efac","#fde68a","#c4b5fd","#f9a8d4","#a5f3fc"];function Lr(o){const l=tr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,title:o.title},{width:600,height:600}),{data:c,childrenAccessor:s="children",nodeIdAccessor:u="name",colorBy:d,colorScheme:h="category10",colorByDepth:f=!1,orbitMode:y="flat",orbitSize:g=2.95,speed:p=.25,revolution:v=e=>1/(e.depth+1),eccentricity:m=1,showRings:b=!0,nodeRadius:x=6,showLabels:k=!1,animated:w=!0,tooltip:E,foregroundGraphics:L,className:A,annotations:D,selection:S,linkedHover:P,onObservation:C,chartId:O,loading:N}=o,W=l.width,I=l.height,T=l.title,M=cr(N,W,I);if(M)return M;const $=i(()=>"function"==typeof s?s:e=>e[s],[s]),_=i(()=>"function"==typeof u?u:e=>{var t;return(null!==(t=e[u])&&void 0!==t?t:"")+""},[u]),B=i(()=>"function"==typeof x?x:()=>x,[x]),{customHoverBehavior:H}=Jt({selection:S,linkedHover:P,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:C,chartType:"OrbitDiagram",chartId:O}),R=Qt(i(()=>{const e=[];return function t(r){e.push(r);const n=$(r);n&&n.forEach(t)}(c),e},[c,$]),f?void 0:d,h),{nodes:z,rings:F,eccentricityFn:Y}=i(()=>function(e,t,r,n,o,i,a){const l=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,s="number"==typeof a?()=>a:a,u=[],d=[],h={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 u.push(h),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,h=0,f=0;for(;i>h;)h+=l[Math.min(f,l.length-1)],f++,a++;let y=0;for(let i=0;a>i;i++){const h=l[Math.min(i,l.length-1)],f=o.slice(y,y+h);if(!f.length)break;const g=(i+1)/a,p=t.parent?t.ring/c(t)*g:t.ring*g,v=j().value(e=>{var t;return(null===(t=r(e))||void 0===t?void 0:t.length)?4:1}).sort(null)(f),m=s(t);d.push({source:t,x:t.x,y:t.y,r:p,ry:p*m});for(let r=0;f.length>r;r++){const o=(v[r].startAngle+v[r].endAngle)/2,i={datum:f[r],x:t.x+p*Math.sin(o),y:t.y+p*Math.cos(o)*m,ring:p,angle:o,depth:t.depth+1,parent:t,id:n(f[r])};t.children.push(i),u.push(i),e(i)}y+=h}}(h),{nodes:u,rings:d,eccentricityFn:s}}(c,[W,I],$,_,y,g,m),[c,W,I,$,_,y,g,m]),[,X]=r(0),G=t(0),q=p*(Math.PI/360);n(()=>{if(!w)return;let e;const t=()=>{G.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}(z,F,G.current,q,v,Y),X(e=>e+1),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[w,z,F,q,v,Y]);const[V,Z]=r(null),K=a(e=>{Z(e),H&&H(e?{data:e.datum,x:e.x,y:e.y}:null)},[H]),Q=a(e=>f?Er[e.depth%Er.length]:d?Lt(e.datum,d,R):Kt,[d,f,R]),J=dr({componentName:"OrbitDiagram",data:c});return J?e.createElement(rr,{componentName:"OrbitDiagram",message:J,width:W,height:I}):e.createElement(or,{componentName:"OrbitDiagram",width:W,height:I},e.createElement("div",{className:"semiotic-orbit-diagram"+(A?" "+A:""),role:"img","aria-label":"string"==typeof T?T:"Orbit diagram",tabIndex:0,style:{position:"relative",width:W,height:I}},e.createElement("svg",{width:W,height:I},b&&F.map((t,r)=>e.createElement("ellipse",{key:"ring-"+r,cx:t.x,cy:t.y,rx:t.r,ry:t.ry,fill:"none",stroke:"currentColor",strokeWidth:.5,opacity:.15})),z.map((t,r)=>t.parent?e.createElement("line",{key:"edge-"+r,x1:t.parent.x,y1:t.parent.y,x2:t.x,y2:t.y,stroke:"currentColor",strokeWidth:.5,opacity:.1}):null),z.map((t,r)=>{const n=B(t),o=Q(t),i=V===t;return e.createElement("g",{key:"node-"+r},e.createElement("circle",{cx:t.x,cy:t.y,r:i?1.5*n:n,fill:o,stroke:"white",strokeWidth:i?2:1,opacity:0===t.depth?1:.85,style:{cursor:"pointer",transition:"r 0.15s"},onMouseEnter:()=>K(t),onMouseLeave:()=>K(null)}),k&&n>4&&e.createElement("text",{x:t.x,y:t.y+n+12,textAnchor:"middle",fontSize:10,fill:"currentColor",opacity:.7},_(t.datum)))}),null==D?void 0:D.map((t,r)=>{var n,o,i,a,l;if("widget"!==t.type)return null;const c=t.nodeId?z.find(e=>e.id===t.nodeId):null;if(!c)return null;const s=null!==(n=t.dx)&&void 0!==n?n:0,u=null!==(o=t.dy)&&void 0!==o?o:-16,d=null!==(i=t.width)&&void 0!==i?i:32,h=null!==(a=t.height)&&void 0!==a?a:32,f=null!==(l=t.content)&&void 0!==l?l:e.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return e.createElement("foreignObject",{key:"ann-"+r,x:c.x+s-d/2,y:c.y+u-h/2,width:d,height:h,style:{overflow:"visible",pointerEvents:"auto"}},e.createElement("div",{style:{width:d,height:h,display:"flex",alignItems:"center",justifyContent:"center"}},f))}),L),V&&E&&e.createElement("div",{style:{position:"absolute",left:V.x+12,top:V.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},E(V)),V&&!E&&e.createElement("div",{style:{position:"absolute",left:V.x+12,top:V.y-12,background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"}},e.createElement("strong",null,_(V.datum)),V.depth>0&&e.createElement("span",{style:{opacity:.7}}," (depth ",V.depth,")")),T&&e.createElement("div",{style:{position:"absolute",top:8,left:0,width:"100%",textAlign:"center",fontSize:14,fontWeight:600,color:"currentColor",pointerEvents:"none"}},T)))}Lr.displayName="OrbitDiagram";export{br as ChordDiagram,wr as CirclePack,fr as ForceDirectedGraph,Lr as OrbitDiagram,mr as SankeyDiagram,Wt as StreamNetworkFrame,xr as TreeDiagram,kr as Treemap};
1
+ import*as e from"react";import{useRef as t,useState as r,useEffect as n,createContext as o,useMemo as i,useContext as a,useCallback as l,useSyncExternalStore as c,forwardRef as s,useImperativeHandle as u,useId as d}from"react";import{interpolateNumber as h}from"d3-interpolate";import{min as f,groups as g,max as y,sum as p,mean as v,group as m}from"d3-array";import{schemeCategory10 as b,interpolatePlasma as x,interpolateViridis as k,interpolatePurples as w,interpolateOranges as E,interpolateGreens as A,interpolateReds as L,interpolateBlues as S,schemeSet3 as D,schemeTableau10 as P}from"d3-scale-chromatic";import{forceLink as M,forceSimulation as I,forceManyBody as C,forceCenter as N,forceX as O,forceY as T}from"d3-force";import{scaleLinear as W,scaleOrdinal as _}from"d3-scale";import{ribbon as $,chord as j}from"d3-chord";import{arc as B,pie as z}from"d3-shape";import{hierarchy as R,partition as H,pack as F,treemap as Y,treemapBinary as X,cluster as G,tree as q}from"d3-hierarchy";const V={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},K={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Z{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 c=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*c*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const s=Q(l.bezier,a.t,a.offset);a.x=s.x,a.y=s.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 Q(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,[c,s,u,d]=e[a],h=U(c,s,u,d,l),f=d.x-c.x,g=d.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;h.x+=-g/y*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=U(n,o,i,a,t),c=a.x-n.x,s=a.y-n.y,u=Math.sqrt(c*c+s*s);if(u>.001){const t=c/u;l.x+=-s/u*r*e.halfWidth*2,l.y+=t*r*e.halfWidth*2}return l}function U(e,t,r,n,o){const i=1-o,a=i*i,l=a*i,c=o*o,s=c*o;return{x:l*e.x+3*a*o*t.x+3*i*c*r.x+s*n.x,y:l*e.y+3*a*o*t.y+3*i*c*r.y+s*n.y}}function J(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function ee(e,t){var r,n=[],o=[],i=[],a={},l=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function s(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=s(n));if(d)c(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),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,l[c]=[];var s,u=0,d=[],h=[];function f(t){var c=[t],s=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;s.length>0;){var f=e[t=s[s.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,c.push(y),s.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=c.length-1;g>=0;--g){var b=c[g];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=d.length,b===t){c.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)}s.pop()}}}for(c=0;t>c;++c)0>r[c]&&f(c);for(c=0;h.length>c;c++){var g=h[c];if(0!==g.length){g.sort(function(e,t){return e-t}),s=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&s.push(g[y]);h[c]=s}}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 c=o[r];if(!c)return!1;var s=e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})});return{leastVertex:i,adjList:s}}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]={}}s(r),r+=1}else r=h}return n}function te(e){return e.y0-e.y1>0?"up":"down"}function re(e,t){return t(e.source)==t(e.target)}function ne(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 oe(e){return e.target.x0-e.source.x1}function ie(e,t){var r=le(e),n=oe(t)/Math.tan(r);return"up"==te(e)?e.y1-n:e.y1+n}function ae(e,t){var r=le(e),n=oe(t)/Math.tan(r);return"up"==te(e)?e.y1+n:e.y1-n}function le(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function ce(e,t){return t(e)}function se(e){return de(e.source)}function ue(e){return de(e.target)}function de(e){return(e.y0+e.y1)/2}function he(e){return e.virtual?0:e.value}function fe(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!re(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!re(e,t)?n+1:n}),r+n}function ge(e){return e.target.depth}function ye(e,t){return e.sourceLinks.length?e.depth:t-1}function pe(e,t){return e.y0-t.y0}function ve(e,t){return t.y0-e.y0}function me(e,t){return e.y1-t.y1}function be(e,t){return t.y1-e.y1}function xe(e,t){return we(e.source,t.source)||e.index-t.index}function ke(e,t){return we(e.target,t.target)||e.index-t.index}function we(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Ee(e,t){return Ae(e)==Ae(t)?"bottom"==e.circularLinkType?ve(e,t):pe(e,t):Ae(t)-Ae(e)}function Ae(e){return e.target.column-e.source.column}function Le(e,t){return Se(e)==Se(t)}function Se(e){return e.y0-e.y1>0?"up":"down"}function De(e,t,r,n,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var l=f(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.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}),Pe(i.links.filter(function(e){return"top"==e.circularLinkType}),t,r),Pe(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,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,re(e,t)&&ne(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+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-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,c=e.circularLinkType,s=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});s.sort("bottom"==e.circularLinkType?ve:pe);var u=0;s.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),a=e.target.column,(s=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?be:me),u=0,s.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-o-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)}),i}function Pe(e,t,r){e.sort(Ee);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(re(e,t)&&ne(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&&Me(e,l)){var c=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Me(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Ie(e){return function(){return e}}function Ce(e){return e.index}function Ne(e){return e.nodes}function Oe(e){return e.links}function Te(e,t,r){var n=g(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var l=new Map;o.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+=de(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=de(e.target)*t,n+=t}}),n>0?o/n:NaN);l.set(e,{bc:i,idx:t})}),o.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 o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?fe(t,r)-fe(e,r):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==n.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==fe(t,r)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function We(e,t,r,n,o,i){var a=g(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var l=1,c=i;c>0;--c)s(l*=.99,r),u();function s(t,r){var n=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var l;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&fe(o,r)>0){var c=v(o.sourceLinks,ue),s=v(o.targetLinks,se),u=c&&s?(c+s)/2:c||s;if(u){var d=(u-de(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(l=o.y1-o.y0)/2,o.y1=e.y1/2+l/2;else if(a==n-1&&1==i)o.y0=e.y1/2-(l=o.y1-o.y0)/2,o.y1=e.y1/2+l/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)l=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+l;else{var h=v(o.sourceLinks,ue),f=v(o.targetLinks,se),g=((h&&f?(h+f)/2:h||f)-de(o))*t;o.y0+=g,o.y1+=g}})})}function u(){a.forEach(function(r){var i,a,l,c=e.y0,s=r.length;for(r.sort(t||we),l=0;s>l;++l)(a=c-(i=r[l]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+n;if((a=c-n-e.y1)>0)for(c=i.y0-=a,i.y1-=a,l=s-2;l>=0;--l)(a=(i=r[l]).y1+o-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function _e(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ke),e.targetLinks.sort(xe)}),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 $e(){var e=0,t=0,r=1,n=1,o=24,i=8,a=null,l=Ce,c=ye,s=void 0,u=32,d=2,h=Ne,v=Oe;function b(){var b={nodes:h.apply(null,arguments),links:v.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=r,h.y1=n,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return m(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=J(r,n)),"object"!=typeof o&&(o=e.target=J(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(h,l),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 c=ee(n);c.sort(function(e,t){return e.length-t.length});var s={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);s[u[0]]||(s[u[0]]={}),s[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||s[n]&&s[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++)})}(h,s),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){ce(e,t)!=ce(o.source,t)&&ce(e,t)!=ce(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),re(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(p(e.sourceLinks,he),p(e.targetLinks,he)),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)})})}(h),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})}(h,s,c);var v=i;if(null!==a){var b=g(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),x=y(b,function(e){return e.length});x>1&&(v=Math.max(1,(n-t)*a/(x-1)))}(function(e,t,r){var n=g(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 o=f(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/p(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=y(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/i),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(h,v,o),Te(h,s,l),We(h,s,l,v,v,u),_e(h),De(h,l,d,10,8),Te(h,s,l),We(h,s,l,v,v,u),_e(h),De(h,l,d,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 ce(r.source,t)==ce(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(!Le(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=ie(t,e);return e.y1-r}if(t.target.column>e.target.column)return ie(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}})})}(h,l),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return ce(r.target,t)==ce(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(!Le(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=ae(t,e);return e.y0-r}if(t.source.column>e.source.column)return ae(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}})})}(h,l),function(e){var t=e.nodes,r=e.links,n=!1,o=!1;if(r.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){var i=f(t,function(e){return e.y0}),a=y(t,function(e){return e.y1}),l=(e.y1-e.y0)/(a-i);function c(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),r.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):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})})}}(h),De(h,l,d,10,8)}(b),b}return b.update=function(e){return _e(e),De(e,l,d,10,8),e},b.nodeWidth=function(e){return arguments.length?(o=+e,b):o},b.nodePadding=function(e){return arguments.length?(i=+e,b):i},b.nodePaddingRatio=function(e){return arguments.length?(a=+e,b):a},b.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Ie(e),b):h},b.links=function(e){return arguments.length?(v="function"==typeof e?e:Ie(e),b):v},b.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Ie(e),b):l},b.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Ie(e),b):c},b.nodeSort=function(e){return arguments.length?(s=e,b):s},b.iterations=function(e){return arguments.length?(u=+e,b):u},b.circularLinkGap=function(e){return arguments.length?(d=+e,b):d},b.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],r=+o[1][0],n=+o[1][1],b):[[e,t],[r,n]]},b.size=function(o){return arguments.length?(e=t=0,r=+o[0],n=+o[1],b):[r-e,n-t]},b}const je=e=>{let t,r,n,o,i,a,l,c,s;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.y1,a=e.target.y0,l=h(i,a),c=l(.5),s=l(.5),`M${t},${i}C${t},${c} ${r},${s} ${r},${a}L${n},${a}C${n},${s} ${o},${c} ${o},${i}Z`):(t=e.source.x1,r=e.target.x0,l=h(t,r),n=l(.5),o=l(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,s=e.y0+e.sankeyWidth/2,`M${t},${i}C${n},${i} ${o},${a} ${r},${a}L${r},${c}C${o},${c} ${n},${s} ${t},${s}Z`)};function Be(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))),c=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-c},${a-r}L${i-c},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,c=o.targetY,s=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${s},${a-h*r}L${s+n},${a-h*r+h*f}L${s+n},${d+h*n-h*f}L${s+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${c-h*r+h*f}L${u-n+f},${c-h*r}L${l},${c-h*r}L${l},${c+h*r}L${u+n},${c+h*r}L${u+n},${d-h*n}L${s-n},${d-h*n}L${s-n},${a+h*r}L${i},${a+h*r}Z`}const ze={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(ge))-1:0},justify:ye},Re={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,l,c,s,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=$e().extent(m).links(v).nodes(p).nodeAlign(ze[h]||ye).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!==(c=null!==(l=n._circularWidth)&&void 0!==l?l:n.width)&&void 0!==c?c:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(s=e.width)&&void 0!==s?s: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,n){var o,i,a,l;const c="vertical"===r.orientation?"down":"right",s=r.nodeStyle,u=r.edgeStyle,d=null!==(o=r.edgeOpacity)&&void 0!==o?o:.5,h=r.edgeColorBy||"source",f=Array.isArray(r.colorScheme)?r.colorScheme:b,g=new Map;e.forEach((e,t)=>{g.set(e.id,f[t%f.length])});const y=[],p=[],v=[];for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=s?s(t):{},o={fill:n.fill||g.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};y.push({type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const m=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of m){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";u?n=u(e).fill||n:"target"===h&&r?n=g.get(r.id)||n:t&&(n=g.get(t.id)||n);const o=u?u(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,l=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),c=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),s=o.fill||n;p.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+l},${t.sourceY-r}L${t.sourceX+l},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:s,fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:d,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+l}}),p.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-c},${t.targetY-r}L${t.targetX-c},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:s,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-c,x1:t.targetX}});continue}let c;if(c=e.circular&&e.circularPathData?Be(e):je(e),!c)continue;const s={fill:o.fill||n,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:d,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:s,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,o=r.y1-r.y0;if(0>=e||0>=o)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"):(n[0]/2>r.x0+e/2?(a=r.x0-6,s="end"):(a=r.x1+6,s="start"),l=r.y0+o/2),v.push({x:a,y:l,text:i+"",anchor:s,baseline:"middle",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:p,labels:v}}},He={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i;if(0===e.length)return;const a=null!==(o=r.forceStrength)&&void 0!==o?o:.1,l=n[0]/2,c=n[1]/2,s=r.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=null==s?void 0:s.get(t.id);e?u++:r?(t.x=r.x,t.y=r.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of d){const n=Fe(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=Ye(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=Ye(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=l+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=l+e*Math.cos(o),n.y=c+e*Math.sin(o)}}}const f=null!==(i=r.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=h?40:f,y=Xe(r.nodeSize,r.nodeSizeRange,e),p=e=>y(e),v=M().strength(e=>Math.min(2.5,e.weight?e.weight*a:a)).id(e=>e.id),m=I().force("charge",C().strength(e=>-25*p(e))).force("center",N(l,c).strength(.8)).force("x",O(l).strength(.15)).force("y",T(c).strength(.15));if(m.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}));m.force("link",v),m.force("link").links(e)}h?m.alpha(.3):.1>m.alpha()&&m.alpha(1),m.stop();for(let e=0;g>e;++e)m.tick();for(const t of e){if(null==t.x||null==t.y)continue;const e=p(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 b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=b.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=b.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){var o,i,a;const l=r.nodeStyle,c=r.edgeStyle,s=Xe(r.nodeSize,r.nodeSizeRange,e),u=Array.isArray(r.colorScheme)?r.colorScheme:b,d=new Map;e.forEach((e,t)=>{d.set(e.id,u[t%u.length])});const h=[],f=[],g=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(t),r=l?l(t):{},n={fill:r.fill||d.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:2,opacity:r.opacity};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}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);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!==(i=n.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:.6};f.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=(p=r.nodeLabel)?"function"==typeof p?p:e=>e[p]||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=s(r);g.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:h,sceneEdges:f,labels:g}}};function Fe(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 Ye(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 Xe(e,t,r){var n,o;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const i=t||[5,20],a=r.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===a.length)return()=>i[0];const l=null!==(n=f(a))&&void 0!==n?n:0,c=null!==(o=y(a))&&void 0!==o?o:1;if(l===c)return()=>(i[0]+i[1])/2;const s=W().domain([l,c]).range(i).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?i[0]:s(n)}}const Ge=b,qe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=r,l=Math.min(n[0],n[1])/2,c=l-i,s=n[0]/2,u=n[1]/2,d=(h=r.valueAccessor)?"function"==typeof h?h:e=>{var t;return null!==(t=e[h])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=f.get("string"==typeof e.source?e.source:e.source.id),n=f.get(t);if(void 0===r||void 0===n)continue;const o=d(e);y[r][n]=o}const p=j().padAngle(o);a&&p.sortGroups(a);const v=p(y),m=v.groups,b=B().innerRadius(c).outerRadius(l);for(const t of m){const r=e[t.index],n=b.centroid(t);r.x=n[0]+s,r.y=n[1]+u,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=x.get("string"==typeof e.source?e.source:e.source.id),n=x.get(t);r&&(e.source=r),n&&(e.target=n)}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 t of v){const r=e[t.source.index].id,n=e[t.target.index].id,o=k.get(`${r}\0${n}`)||k.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:a=20,edgeOpacity:l=.5}=r,c=Math.min(n[0],n[1])/2,s=c-a,u=n[0]/2,d=n[1]/2,h=r.nodeStyle,f=r.edgeStyle,g=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:Ge,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const v=$().radius(s),m=[],b=[],x=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=h?h(r).fill||p.get(r.id)||y[t%y.length]:p.get(r.id)||y[t%y.length];const a=h?h(r):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};m.push({type:"arc",cx:u,cy:d,innerR:s,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=v(t);if(!r)continue;const n=Ve(r,u,d);let o="#999";if(f)o=f(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=p.get(r.id)||o:t&&(o=p.get(t.id)||o)}const a=f?f(e):{},c={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:n,style:c,datum:e})}if(!1!==r.showLabels){const t=(k=r.nodeLabel)?"function"==typeof k?k:e=>e[k]||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;x.push({x:u+Math.cos(a)*n,y:d+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:b,labels:x}}};function Ve(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 Ke(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 Ze={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 s=r.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=R(i,l);u.sum(s),u.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[d,h]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=q();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(u,r,d,h);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=G();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(u,r,d,h);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=Y().size([r,n]).tile(X).padding(a);l>0&&c.paddingTop(l),c(e)}(u,r,d,h);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;F().size([r,n]).padding(i)(e)}(u,r,d,h);break;case"partition":!function(e,t,r,n){var o;H().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(u,r,d,h)}const f=u.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;f.length>t;t++){const n=f[t],i={id:tt(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?Qe(i,n,r):"treemap"===a||"partition"===a?Ue(i,n):"circlepack"===a&&Je(i,n),i.__hierarchyNode=n,e.push(i),g.set(n,i)}if("tree"===a||"cluster"===a)for(const e of f)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,c,s,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 c={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:c,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=et(n,o,a,l,g),d=i(e),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(c=d.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(s=d.opacity)&&void 0!==s?s:k};h.push({type:"curved",pathD:u,style:f,datum:e})}if(!1!==r.showLabels){const t=rt(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=[],c=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const l=n(r);let s=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(s=c[r.depth%c.length]);const u={fill:s,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=rt(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,u=s.y1-s.y0;if(0>=e||0>=u)continue;const d=!((null===(i=s.data)||void 0===i?void 0:i.children)&&s.data.children.length>0);if(!a){if("leaf"===o&&!d)continue;if("parent"===o&&d)continue}const h=r?r(s):s.id;if(!h)continue;if((d?30:40)>e||(d?16:14)>u)continue;let f=n(s).fill||"#4d430c";t.colorByDepth&&void 0!==s.depth&&(f=c[s.depth%c.length]);const g=Ke(f);l.push(d?{x:s.x0+e/2,y:s.y0+u/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:g}:{x:s.x0+4,y:s.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,c;const s=[],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 c=l.fill||"#4d430c";t.colorByDepth&&void 0!==r.depth&&(c=d[r.depth%d.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};s.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=rt(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===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let s=n(o).fill||"#4d430c";if(t.colorByDepth&&void 0!==o.depth&&(s=d[o.depth%d.length]),a){const t=Ke(s);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:s,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Qe(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 Ue(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 Je(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 et(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 tt(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 rt(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 nt(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const ot={sankey:Re,force:He,chord:qe,tree:Ze,cluster:Ze,treemap:Ze,circlepack:Ze,partition:Ze,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 l=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),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),u=null!==(i=r.orbitSize)&&void 0!==i?i:2.95,d=null!==(a=r.orbitEccentricity)&&void 0!==a?a:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=nt(r);g.metaMap.clear(),n.length=0,o.length=0;const y=new Map;function p(e){var t;const r=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,r+1),0===r?e:`${e}__${r}`}const v=t[0]/2,m=t[1]/2,b=Math.min(t[0],t[1])/2*.85,x=p(c(e));n.push({id:x,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:e}),g.metaMap.set(x,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,u,d,y){const v=l(t);if(!(null==v?void 0:v.length))return;const m=v.length;let b=0,x=0,k=0;for(;m>x;)x+=s[Math.min(k,s.length-1)],k++,b++;let w=0;for(let m=0;b>m;m++){const x=s[Math.min(m,s.length-1)],k=v.slice(w,w+x);if(!k.length)break;const E=(m+1)/b,A={id:r,depth:d,data:t,parentId:r},L=y?u/h(A)*E:u*E,S=z().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),D=S(k),P=f(A);for(let t=0;k.length>t;t++){const l=(D[t].startAngle+D[t].endAngle)/2,s=k[t],u=p(c(s)),h=i+L*Math.sin(l),f=a+L*Math.cos(l)*P;n.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:s}),g.metaMap.set(u,{ring:L,angle:l,depth:d,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,h,f,L,d+1,!0)}w+=x}}(e,x,v,m,b,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,l,c;const s=r.nodeStyle,u=r.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],g=[];if(!1!==r.orbitShowRings){const t=nt(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,c=(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(c),y2:t+r*Math.cos(c)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(t),r=s?s(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!==(c=null===(l=r.data)||void 0===l?void 0:l[t])&&void 0!==c?c:r.id;g.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:g}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=nt(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,c=i*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=s.get(e.parentId);if(!r)continue;const n=e.angle+l*c*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(n),t.y=r.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)}};function it(e){return ot[e]}function at(e,t,r){return e+(t-e)*r}class lt{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({},V),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new Z(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({},V),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new Z(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],c="function"==typeof o?o:e=>e[o],s="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({},ct(e)),{data:t}))}for(const e of t){const t=c(e)+"",r=s(e)+"",n=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},ct(t)),{data:e})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},ct(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,ct(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,ct(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,r),c=this.edges.get(l);return c?(c.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=it(this.config.chartType);if(!l)return;let c=Array.from(this.nodes.values()),s=Array.from(this.edges.values());if(0===c.length&&!l.hierarchical)return;if(this.prepareForRelayout(),l.supportsStreaming&&!l.hierarchical){const e=new Map;for(const l of c)if(void 0!==l._prevX0){const c=(null!==(t=l._prevX1)&&void 0!==t?t:0)-(null!==(r=l._prevX0)&&void 0!==r?r:0),s=(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)+c/2,y:(null!==(a=l._prevY0)&&void 0!==a?a:0)+s/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(c,s,this.config,e),delete this.config.__previousPositions,l.hierarchical&&c.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of c)this.nodes.set(e.id,e);for(const e of s)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),c.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=it(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=it(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=it(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=at(e._prevX0,e._targetX0,r),e.x1=at(e._prevX1,e._targetX1,r),e.y0=at(e._prevY0,e._targetY0,r),e.y1=at(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=at(e._prevY0,e._targetY0,r),e.y1=at(e._prevY1,e._targetY1,r),e.sankeyWidth=at(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,t,r){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.y1,i=r.y0,a=h(o,i);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:n}}const o=t.x1,i=r.x0,a=h(o,i);return{circular:!1,points:[{x:o,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:n}}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,c=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",s=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=c,t._pulseGlowRadius=s)}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 s=this.edgeTimestamps.get(`${n}\0${a}`);if(!s)continue;const u=e-s;l>u&&(t._pulseIntensity=1-u/l,t._pulseColor=c)}}applyDecay(){var e,t,r,n,o;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,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 c=this._decaySortedNodes,s=new Map;for(let e=0;c.length>e;e++)s.set(c[e][0],e);for(const e of this.sceneNodes){const c=e.id;if(!c)continue;const u=s.get(c);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 c=n.metric(l);let s=null;void 0===n.critical||n.critical>c?void 0===n.warning||n.warning>c||(s=o):s=i,s&&(t.style=Object.assign(Object.assign({},t.style),{fill:s}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=s,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 ct(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 st(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function ut(e,t,r,n,o=30){let i=null,a=o,l=1/0;for(const t of e){const e=dt(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=yt(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function dt(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=st(Math.atan2(o,n)),l=st(e.startAngle),c=st(e.endAngle);if(l>c?a>=l||c>=a:a>=l&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let ht=null,ft=null;function gt(){return ft||(ht=document.createElement("canvas"),ht.width=1,ht.height=1,ft=ht.getContext("2d")),ft}function yt(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=gt();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 c=a.isPointInStroke(i,t,r);if(a.lineWidth=l,c)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const l=e.x1+a*n,c=e.y1+a*o,s=Math.sqrt(Math.pow(t-l,2)+Math.pow(r-c,2));return s>5?null:{type:"edge",datum:e.datum,x:l,y:c,distance:s}}(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=gt();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 pt={fill:t=>e.createElement("rect",{style:t,width:16,height:16}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function vt(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,pt[r])(n(e,t)),o}function mt(){return e.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function bt(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function xt({config:t,orientation:r="vertical",width:n=100}){const{colorFn:o,domain:i,label:a,format:l}=t,c=l||(e=>Math.round(100*e)/100+""),s="grad-legend-"+e.useId();if("horizontal"===r){const t=12,r=Math.min(n,200),l=Math.max(0,(n-r)/2),u=[];for(let t=0;64>=t;t++){const r=t/64;u.push(e.createElement("stop",{key:t,offset:100*r+"%",stopColor:o(i[0]+r*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":a||"Gradient legend"},e.createElement("defs",null,e.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),a&&e.createElement("text",{x:l+r/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),e.createElement("rect",{x:l,y:0,width:r,height:t,fill:`url(#${s})`,rx:2}),e.createElement("text",{x:l,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},c(i[0])),e.createElement("text",{x:l+r,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},c(i[1])))}const u=[];for(let t=0;64>=t;t++){const r=t/64;u.push(e.createElement("stop",{key:t,offset:100*r+"%",stopColor:o(i[1]-r*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":a||"Gradient legend"},a&&e.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),e.createElement("defs",null,e.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),e.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),e.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},c(i[1])),e.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},c(i[0])))}function kt(t){const{legendGroups:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,legendInteraction:l,title:c="Legend",width:s=100,height:u=20,orientation:d="vertical"}=t,[h,f]=e.useState(0),[g,y]=e.useState(0),p=e.useCallback((e,t)=>{f(e),y(t)},[]),v="vertical"===d?(({legendGroups:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:s,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,f)=>{d+=5,h.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:d,x2:r,y2:d})),d+=8,t.label&&(d+=16,h.push(e.createElement("text",{key:"legend-text-"+f,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),d+=8),h.push(e.createElement("g",{key:"legend-group-"+f,className:"legend-item",transform:`translate(0,${d})`},((t,r,n,o,i,a,l,c,s,u)=>{const{type:d="fill",styleFn:h,items:f}=t,g=[];let y=0;const p=!(!r&&!n),v="isolate"===u||void 0===u&&null!=i;return f.forEach((t,u)=>{const m=vt(t,u,d,h),b=bt(t,o,i),x=i&&i.size>0&&i.has(t.label);g.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${y})`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?c===a&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?x||!1:void 0,"aria-current":p&&!v&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:p?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+f.length)%f.length;s(c,t);const r=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:p?e=>{s(c,u),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(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&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,x&&e.createElement(mt,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),g})(t,n,o,i,a,l,c,f,s,u))),d+=22*t.items.length+8}),h})({legendGroups:r||[],width:s,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:l}):(({legendGroups:t,height:r,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:c,focusedItemIndex:s,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];t.forEach((t,r)=>{let n=0;t.label&&(n+=16);const g=((t,r,n,o,i,a,l,c,s,u)=>{const{type:d="fill",styleFn:h,items:f}=t,g=[];let y=0;const p=!(!r&&!n),v="isolate"===u||void 0===u&&null!=i;return f.forEach((t,u)=>{const m=vt(t,u,d,h),b=bt(t,o,i),x=i&&i.size>0&&i.has(t.label);g.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(${y},0)`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?c===a&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?x||!1:void 0,"aria-current":p&&!v&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:p?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+f.length)%f.length;s(c,t);const r=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:p?e=>{s(c,u),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(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&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,x&&e.createElement(mt,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=26+7*t.label.length}),{items:g,offset:y}})(t,o,i,a,l,c,s,r,u,d);n+=g.offset+5,f.push(Object.assign(Object.assign({label:t.label},g),{offset:n})),h+=n+12});let g=Math.max(0,(n-h)/2);const y=[];return f.forEach((n,o)=>{const i=t[o];i.label&&(y.push(e.createElement("text",{key:"legend-text-"+o,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),g+=16),y.push(e.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${g},0)`},n.items)),g+=n.offset+5,t[o+1]&&y.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:g,y1:-8,x2:g,y2:r+0+8})),g+=12}),e.createElement("g",null,y)})({legendGroups:r||[],title:c,height:u,width:s,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:p,legendInteraction:l}),m=!(!n&&!o);return e.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==l&&(void 0!==l||null==a))||void 0,"aria-label":"Chart legend"},void 0!==c&&""!==c&&"vertical"===d&&e.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},c),v)}function wt(t){const{width:r,height:n,totalWidth:o,totalHeight:i,margin:a,labels:l,title:c,legend:s,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:g="right",foregroundGraphics:y,sceneNodes:p,annotations:v,svgAnnotationRules:m}=t;return e.createElement(e.Fragment,null,e.createElement("svg",{role:"img",width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("title",null,"string"==typeof c?c:"Network Chart"),e.createElement("desc",null,"string"==typeof c?c+" — network data visualization":"Network data visualization"),e.createElement("g",{transform:`translate(${a.left},${a.top})`},l.map((t,r)=>e.createElement("text",{key:"label-"+r,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),v&&v.filter(e=>"widget"!==e.type).map((t,o)=>{if(m){const i=m(t,o,{width:r,height:n,sceneNodes:p});if(i)return e.createElement(e.Fragment,{key:"annotation-"+o},i)}return null}),y),c&&"string"==typeof c?e.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},c):c?e.createElement("foreignObject",{x:0,y:0,width:o,height:a.top},c):null,function(t){const{legend:r,totalWidth:n,totalHeight:o,margin:i,legendPosition:a="right",title:l,legendHoverBehavior:c,legendClickBehavior:s,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!r)return null;const f="top"===a||"bottom"===a;let g,y;return"left"===a?(g=4,y=i.top):"top"===a?(g=0,y=l?32:8):"bottom"===a?(g=0,y=o-i.bottom+50):(g=n-i.right+10,y=i.top),e.createElement("g",{transform:`translate(${g}, ${y})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(r)?e.createElement(xt,{config:r.gradient,orientation:f?"horizontal":"vertical",width:f?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(r)?e.createElement(kt,{legendGroups:r.legendGroups,title:"",width:f?n:100,orientation:f?"horizontal":"vertical",customHoverBehavior:c,customClickBehavior:s,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):r)}({legend:s,totalWidth:o,totalHeight:i,margin:a,legendPosition:g,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})),null==v?void 0:v.filter(e=>"widget"===e.type&&e.nodeId&&p).map((t,r)=>{var n,o,i,l,c,s,u,d,h;const f=p.find(e=>{var r,n,o,i,a;return e.id===t.nodeId||(null===(r=e.datum)||void 0===r?void 0:r.id)===t.nodeId||(null===(o=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===t.nodeId||(null===(a=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===t.nodeId});if(!f)return null;const g=a.left+(null!==(n=f.cx)&&void 0!==n?n:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=a.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l:0),v=null!==(c=t.dx)&&void 0!==c?c:0,m=null!==(s=t.dy)&&void 0!==s?s:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return e.createElement("div",{key:"widget-"+r,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)}))}wt.displayName="NetworkSVGOverlay";const Et="undefined"==typeof window||"undefined"==typeof document,At={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Lt(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 St({nodes:t,chartType:r}){var n,o,i,a,l;const c=[];for(const e of t){if(c.length>=50)break;c.push({values:{id:(null===(n=e.datum)||void 0===n?void 0:n.id)||e.id||"",x:Math.round(100*(null!==(i=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==i?i:0))/100+"",y:Math.round(100*(null!==(l=null!==(a=e.cy)&&void 0!==a?a:e.y)&&void 0!==l?l:0))/100+""}})}if(0===c.length)return null;const s=new Set;for(const e of c)for(const t of Object.keys(e.values))s.add(t);const u=Array.from(s);return e.createElement("table",{style:At,role:"table","aria-label":"Data table for "+r},e.createElement("thead",null,e.createElement("tr",null,u.map(t=>e.createElement("th",{key:t},t)))),e.createElement("tbody",null,c.map((t,r)=>e.createElement("tr",{key:r},u.map(r=>{var n;return e.createElement("td",{key:r},null!==(n=t.values[r])&&void 0!==n?n:"")}))),t.length>50&&e.createElement("tr",null,e.createElement("td",{colSpan:u.length},"...and ",t.length-50," more items"))))}function Dt({hoverPoint:t}){let r="";if(t){const e=t.data||t;r="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:At},r)}function Pt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Mt(e,t,r=.3){Pt(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 It(e,t,r=.6){var n,o,i,a,l;if(!Pt(t))return;const c=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,s=t.r+c*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(l=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==l?l:0;e.beginPath(),e.arc(u,d,s,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 Ct(e,t){var r,n,o,i,a,l;if(!t.pathD)return;e.save();const c=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,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(c)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(c)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(c)),e.restore()}function Nt(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 Ot(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 Tt(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 Wt={category10:b,tableau10:P,set3:D,blues:S,reds:L,greens:A,oranges:E,purples:w,viridis:k,plasma:x},_t=b,$t=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],jt=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 Bt(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")||jt.has(t)}(n)?r(n):n}const n=e[t];return r?r(n):_t[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+""))%_t.length]}function zt(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 _().domain(n).range(r).unknown("#999");const i=Wt[r]||Wt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of n){const r=Number(t);r>e&&(e=r)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:_t;return _().domain(n).range(e).unknown("#999")}}function Rt(r){const n=o(null),s=Ht(r);return[function({children:t}){const o=i(()=>Ht(r),[]);return e.createElement(n.Provider,{value:o,children:t})},e=>{var r;const o=null!==(r=a(n))&&void 0!==r?r:s,i=t(e);i.current=e;const u=l(()=>i.current(o.getState()),[o]),d=l(()=>i.current(o.getState()),[o]);return c(o.subscribe,u,d)}]}function Ht(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 Ft={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}},Yt={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}},[Xt,Gt]=Rt(e=>({theme:Ft,setTheme(t){e(e=>"light"===t?{theme:Ft}:"dark"===t?{theme:Yt}:{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||{})})})}})),qt={top:20,right:80,bottom:20,left:80},Vt={top:40,right:40,bottom:40,left:40},Kt=new Set(["chord","force","circlepack","orbit"]),Zt=[800,600],Qt={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 Ut({data:t}){var r,n,o,i,a,l;if("edge"===t.type){const r=t.data;return e.createElement("div",{className:"semiotic-tooltip",style:Qt},e.createElement("div",{style:{fontWeight:600}},"object"==typeof r.source?r.source.id:r.source," → ","object"==typeof r.target?r.target.id:r.target),null!=r.value&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof r.value?r.value.toLocaleString():r.value+""))}const c=t.data,s=null==c?void 0:c.__hierarchyNode;if(s){const t=[];let a=s;for(;a;){const e=null!==(i=null!==(n=null===(r=a.data)||void 0===r?void 0:r.name)&&void 0!==n?n:null===(o=a.data)||void 0===o?void 0:o.id)&&void 0!==i?i:c.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const l=t.length-1;return e.createElement("div",{className:"semiotic-tooltip",style:Qt},e.createElement("div",null,t.map((t,r)=>e.createElement("span",{key:r},r>0&&e.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),r===l?e.createElement("strong",null,t):e.createElement("span",{style:{opacity:.7}},t)))),null!=c.value&&c.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof c.value?c.value.toLocaleString():c.value+""))}const u=((null===(a=c.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(l=c.targetLinks)||void 0===l?void 0:l.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.createElement("div",{className:"semiotic-tooltip",style:Qt},e.createElement("div",{style:{fontWeight:600}},c.id),null!=c.value&&c.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""),u>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`))}const Jt=s(function(o,a){var c,s,d,h,f,g,y,p,v,m,b;const{chartType:x,nodes:k,edges:w,data:E,initialEdges:A,nodeIDAccessor:L="id",sourceAccessor:S="source",targetAccessor:D="target",valueAccessor:P="value",childrenAccessor:M,hierarchySum:I,orientation:C="horizontal",nodeAlign:N="justify",nodePaddingRatio:O=.05,nodeWidth:T=15,iterations:W=300,forceStrength:_=.1,padAngle:$=.01,groupWidth:j=20,sortGroups:z,edgeSort:R,treeOrientation:H="vertical",edgeType:F="curve",padding:Y,paddingTop:X,tensionConfig:G,showParticles:q=!1,particleStyle:Z,nodeStyle:Q,edgeStyle:U,colorBy:J,colorScheme:ee="category10",edgeColorBy:te="source",edgeOpacity:re=.5,colorByDepth:ne=!1,nodeSize:oe=8,nodeSizeRange:ie=[5,20],nodeLabel:ae,showLabels:le=!0,labelMode:ce,size:se=Zt,responsiveWidth:ue,responsiveHeight:de,margin:he,className:fe,background:ge,enableHover:ye=!0,tooltipContent:pe,customHoverBehavior:ve,customClickBehavior:me,onObservation:be,chartId:xe,onTopologyChange:ke,annotations:we,svgAnnotationRules:Ee,legend:Ae,legendPosition:Le,legendHoverBehavior:Se,legendClickBehavior:De,legendHighlightedCategory:Pe,legendIsolatedCategories:Me,title:Ie,foregroundGraphics:Ce,backgroundGraphics:Ne,decay:Oe,pulse:Te,staleness:We,thresholds:_e,accessibleTable:$e,orbitMode:je,orbitSize:Be,orbitSpeed:ze,orbitRevolution:Re,orbitRevolutionStyle:He,orbitEccentricity:Fe,orbitShowRings:Ye,orbitAnimated:Xe}=o,Ge=Kt.has(x)?Vt:qt,[qe,Ve]=function(e,o,i){const a=t(null),[l,c]=r(null);return n(()=>{if(!o&&!i)return;const e=a.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;c(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[o,i]),[a,[o&&l?l.w:e[0],i&&l?l.h:e[1]]]}(se,ue,de),Ke=Object.assign(Object.assign({},Ge),he),Ze=Ve[0]-Ke.left-Ke.right,Qe=Ve[1]-Ke.top-Ke.bottom,Ue="function"==typeof Ce?Ce({size:Ve,margin:Ke}):Ce,Je=i(()=>Object.assign(Object.assign({},V),G),[G]),et=i(()=>Object.assign(Object.assign({},K),Z),[Z]),tt=i(()=>({chartType:x,nodeIDAccessor:L,sourceAccessor:S,targetAccessor:D,valueAccessor:P,childrenAccessor:M,hierarchySum:I,orientation:C,nodeAlign:N,nodePaddingRatio:O,nodeWidth:T,iterations:W,forceStrength:_,padAngle:$,groupWidth:j,sortGroups:z,edgeSort:R,treeOrientation:H,edgeType:F,padding:Y,paddingTop:X,tensionConfig:Je,showParticles:q,particleStyle:et,nodeStyle:Q,edgeStyle:U,nodeLabel:ae,showLabels:le,labelMode:ce,colorBy:J,colorScheme:ee,edgeColorBy:te,edgeOpacity:re,colorByDepth:ne,nodeSize:oe,nodeSizeRange:ie,decay:Oe,pulse:Te,staleness:We,thresholds:_e,orbitMode:je,orbitSize:Be,orbitSpeed:ze,orbitRevolution:Re,orbitRevolutionStyle:He,orbitEccentricity:Fe,orbitShowRings:Ye,orbitAnimated:Xe}),[x,L,S,D,P,M,I,C,N,O,T,W,_,$,j,z,R,H,F,Y,X,Je,q,et,Q,U,ae,le,ce,J,ee,te,re,ne,oe,ie,Oe,Te,We,_e,je,Be,ze,Re,He,Fe,Ye,Xe]),rt=t(null),nt=t(0),ot=t(0),it=t(!0),at=Gt(e=>e.theme),ct=t(()=>{}),st=t(null);st.current||(st.current=new lt(tt));const[dt,ht]=r(null),[ft,gt]=r(0),[yt,pt]=r(0),[vt,mt]=r(!1),bt=t(null),xt=t(new Map),kt=t(0),At=l(e=>{if("function"==typeof J)return J(e)+"";if("string"==typeof J&&e.data){const t=e.data[J];if(void 0!==t){if(!xt.current.has(t+"")){const e=Array.isArray(ee)?ee:_t;xt.current.set(t+"",e[kt.current++%e.length])}return xt.current.get(t+"")}}if(!xt.current.has(e.id)){const t=Array.isArray(ee)?ee:_t;xt.current.set(e.id,t[kt.current++%t.length])}return xt.current.get(e.id)},[J,ee]),Pt=l(e=>{if("function"==typeof te)return te(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===te&&r?At(r):t?At(t):"#999"},[te,At]),Wt=l(e=>{if(!(null==Z?void 0:Z.colorBy))return Pt(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===et.colorBy&&r?At(r):t?At(t):"#999"},[null==Z?void 0:Z.colorBy,et.colorBy,At,Pt]),$t="sankey"===x&&q||!!Te||null!==(s=null===(c=st.current)||void 0===c?void 0:c.isAnimating)&&void 0!==s&&s,jt=l(()=>{nt.current&&!$t||nt.current||(nt.current=requestAnimationFrame(()=>ct.current()))},[$t]);n(()=>{var e;null===(e=st.current)||void 0===e||e.updateConfig(tt),it.current=!0,jt()},[tt,jt]),n(()=>{it.current=!0,jt()},[at,jt]);const Bt=l(()=>{const e=st.current;if(!e)return;e.runLayout([Ze,Qe]),e.buildScene([Ze,Qe]),it.current=!0;const t=Array.isArray(ee)?ee:_t,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const n=r[e];xt.current.has(n.id)||xt.current.set(n.id,t[e%t.length])}if(kt.current=r.length,gt(e.layoutVersion),ke){const{nodes:t,edges:r}=e.getLayoutData();ke(t,r)}},[Ze,Qe,ke,ee]),zt=l(e=>{const t=st.current;t&&(t.ingestEdge(e)&&Bt(),jt())},[Bt,jt]),Rt=l(e=>{const t=st.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&Bt(),jt()},[Bt,jt]),Ht=l(()=>{var e;null===(e=st.current)||void 0===e||e.clear(),xt.current.clear(),kt.current=0,gt(0),ht(null),bt.current=null,it.current=!0,jt()},[jt]),Ft=l(()=>{const e=st.current;e&&(e.tension+=999,Bt(),jt())},[Bt,jt]);u(a,()=>({push:zt,pushMany:Rt,clear:Ht,getTopology:()=>{var e,t;return null!==(t=null===(e=st.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=st.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Ft,getTension:()=>{var e,t;return null!==(t=null===(e=st.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[zt,Rt,Ht,Ft]);const Yt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),Xt=Yt?E||(Array.isArray(w)?void 0:w):void 0;n(()=>{const e=st.current;if(e)if(Yt&&Xt)e.ingestHierarchy(Xt,[Ze,Qe]),e.buildScene([Ze,Qe]),it.current=!0,jt();else{const t=k||[],r=Array.isArray(w)?w:[];if(0===t.length&&0===r.length)return;e.ingestBounded(t,r,[Ze,Qe]),e.buildScene([Ze,Qe]);const n=Array.isArray(ee)?ee:_t,o=Array.from(e.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];xt.current.has(t.id)||xt.current.set(t.id,n[e%n.length])}kt.current=o.length,it.current=!0,jt()}},[k,w,E,Xt,Yt,Ze,Qe,tt,jt,ee]),n(()=>{A&&A.length>0&&Rt(A)},[]);const Qt=l(e=>{if(ve&&ve(e),be){const t=Date.now();be(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:xe}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:xe})}},[ve,be,xe]),Jt=l(e=>{if(me&&me(e),be){const t=Date.now();be(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:xe}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:xe})}},[me,be,xe]),er=t(()=>{}),tr=t(()=>{});er.current=e=>{if(!ye)return;const t=rt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Ke.left,o=e.clientY-r.top-Ke.top;if(0>n||n>Ze||0>o||o>Qe)return void(bt.current&&(bt.current=null,ht(null),Qt&&(Qt(null),it.current=!0),jt()));const i=st.current;if(!i)return;const a=ut(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(bt.current&&(bt.current=null,ht(null),Qt&&(Qt(null),it.current=!0),jt()));const l=a.datum||{},c=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:a.type,data:l,x:a.x,y:a.y});bt.current=c,ht(c),Qt&&(Qt(c),it.current=!0),jt()},tr.current=()=>{bt.current&&(bt.current=null,ht(null),Qt&&(Qt(null),it.current=!0),jt())};const rr=t(()=>{});rr.current=e=>{if(!me&&!be)return;const t=rt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Ke.left,o=e.clientY-r.top-Ke.top;if(0>n||n>Ze||0>o||o>Qe)return;const i=st.current;if(!i)return;const a=ut(i.sceneNodes,i.sceneEdges,n,o);if(a){const e=a.datum||{};Jt(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 Jt(null)},l(e=>er.current(e),[]);const nr=l(()=>tr.current(),[]),or=l(e=>rr.current(e),[]),ir=t(-1),ar=l(e=>{const t=st.current;if(!t)return;const r=function(e){const t=[];for(const r of e)"circle"===r.type&&null!=r.cx?t.push({x:r.cx,y:r.cy,datum:r.datum}):"rect"===r.type&&null!=r.x?t.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum}):"arc"===r.type&&null!=r.cx&&t.push({x:r.cx,y:r.cy,datum:r.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return;const n=ir.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 ir.current=-1,bt.current=null,ht(null),Qt&&(Qt(null),it.current=!0),void jt();const i=0>n?0:o;ir.current=i;const a=r[i],l=a.datum||{},c=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:"node",data:l,x:a.x,y:a.y});bt.current=c,ht(c),Qt&&(Qt(c),it.current=!0),jt()},[Qt,jt]),lr=l(e=>{ir.current=-1,er.current(e)},[]);ct.current=()=>{var e,t,r,n,o,i,a;nt.current=0;const l=rt.current;if(!l)return;const c=l.getContext("2d");if(!c)return;const s=st.current;if(!s)return;const u=performance.now(),d=ot.current?Math.min((u-ot.current)/1e3,.1):.016;ot.current=u;const h=s.advanceTransition(u),f=s.tickAnimation([Ze,Qe],d);(h||it.current||f)&&s.buildScene([Ze,Qe]);const g="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",c=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==c&&(e.style.height=c),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(n,0,0,n,0,0),o.translate(r.left,r.top),o}(l,Ve,Ke,g))return;c.clearRect(-Ke.left,-Ke.top,Ve[0],Ve[1]),ge&&(c.fillStyle=ge,c.fillRect(0,0,Ze,Qe)),Oe&&s.applyDecay(),Te&&s.applyPulse(u),_e&&s.applyThresholds(u),s.applyTopologyDiff(u);const y=null!==(e=null==We?void 0:We.threshold)&&void 0!==e?e:5e3,p=We&&s.lastIngestTime>0&&u-s.lastIngestTime>y;if(p&&(c.globalAlpha=null!==(t=null==We?void 0:We.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Ct(e,r);break;case"line":Nt(e,r);break;case"ribbon":Ot(e,r);break;case"curved":Tt(e,r)}}(c,s.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)),Mt(e,t),e.restore())}}(c,s.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()),It(e,t),e.restore())}}(c,s.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(c,s.sceneNodes),q&&s.particlePool&&!p){const e=Array.from(s.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:K.spawnRate,l=null!==(i=n.maxPerEdge)&&void 0!==i?i:K.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),c=Math.floor(i),s=i-c;let u=c;Math.random()<s&&u++;for(let t=0;u>t&&e.countForEdge(n)<l;t++)e.spawn(n)}}(s.particlePool,e,d,et);const t=.5*(null!==(r=et.speedMultiplier)&&void 0!==r?r:1);let n;if(et.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)}s.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:K.radius,c=null!==(a=n.opacity)&&void 0!==a?a:K.opacity;e.globalAlpha=c;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const c=r[a.edgeIndex];if(c){if("function"==typeof n.color){const t="object"==typeof c.source?c.source:null;e.fillStyle=t?n.color(c,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(c);e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(c,s.particlePool,e,et,Wt)}}p&&(c.globalAlpha=1);const v=it.current;if(it.current=!1,v||h||f){const e=rt.current;e&&e.setAttribute("aria-label",Lt(null!==(o=null===(n=s.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=s.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(v||h||f)&&pt(e=>e+1),($t||h||f||s.hasActivePulses||s.hasActiveThresholds||s.hasActiveTopologyDiff)&&(nt.current=requestAnimationFrame(()=>ct.current()))},n(()=>(jt(),()=>{nt.current&&(cancelAnimationFrame(nt.current),nt.current=0)}),[jt]),n(()=>{it.current=!0,jt()},[x,Ze,Qe,ge,jt]),function(e,t,r,o,i,a){n(()=>{if(!e)return;const n=setInterval(()=>{var n;const l=t.current;if(!l||0===l.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=e.threshold)&&void 0!==n?n:5e3,u=c-l.lastIngestTime>s;u!==i&&(a(u),r.current=!0,o())},1e3);return()=>clearInterval(n)},[e,i,o])}(We,st,it,jt,vt,mt);const cr=ye&&dt?e.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Ke.left+dt.x,top:Ke.top+dt.y,transform:`translate(${dt.x>.6*Ze?"calc(-100% - 12px)":"12px"}, ${.3*Qe>dt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},pe?pe(dt):e.createElement(Ut,{data:dt})):null;if(Et){const t=st.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(x),r=e?E||(Array.isArray(w)?void 0:w):void 0;if(e&&r)t.ingestHierarchy(r,[Ze,Qe]),t.buildScene([Ze,Qe]);else{const e=k||[],r=Array.isArray(w)?w:[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[Ze,Qe]),t.buildScene([Ze,Qe]))}}const r=null!==(d=null==t?void 0:t.sceneNodes)&&void 0!==d?d:[],n=null!==(h=null==t?void 0:t.sceneEdges)&&void 0!==h?h:[],o=null!==(f=null==t?void 0:t.labels)&&void 0!==f?f:[];return e.createElement("div",{className:"stream-network-frame"+(fe?" "+fe:""),role:"img","aria-label":"string"==typeof Ie?Ie:"Network chart",style:{position:"relative",width:Ve[0],height:Ve[1]}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ve[0],height:Ve[1],style:{position:"absolute",left:0,top:0}},Ne&&e.createElement("g",{transform:`translate(${Ke.left},${Ke.top})`},Ne),e.createElement("g",{transform:`translate(${Ke.left},${Ke.top})`},ge&&e.createElement("rect",{x:0,y:0,width:Ze,height:Qe,fill:ge}),n.map((t,r)=>function(t,r){switch(t.type){case"line":return e.createElement("line",{key:"net-edge-"+r,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":case"ribbon":return e.createElement("path",{key:"net-edge-"+r,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return e.createElement("path",{key:"net-edge-"+r,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,r)).filter(Boolean),r.map((t,r)=>function(t,r){switch(t.type){case"circle":return e.createElement("circle",{key:"net-circle-"+r,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return e.createElement("rect",{key:"net-rect-"+r,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const n=t,o=B().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return e.createElement("path",{key:"net-arc-"+r,d:o,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,r)).filter(Boolean),o.map((t,r)=>function(t,r){return e.createElement("text",{key:"net-label-"+r,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,r)).filter(Boolean))),e.createElement(wt,{width:Ze,height:Qe,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ke,labels:o,sceneNodes:r,title:Ie,legend:Ae,legendPosition:Le,legendHoverBehavior:Se,legendClickBehavior:De,legendHighlightedCategory:Pe,legendIsolatedCategories:Me,foregroundGraphics:Ue,annotations:we,svgAnnotationRules:Ee,annotationFrame:0}))}const sr=st.current;return e.createElement("div",{ref:qe,className:"stream-network-frame"+(fe?" "+fe:""),role:"img","aria-label":"string"==typeof Ie?Ie:"Network chart",tabIndex:0,style:{position:"relative",width:ue?"100%":Ve[0],height:de?"100%":Ve[1],overflow:"visible"},onMouseMove:ye?lr:void 0,onMouseLeave:ye?nr:void 0,onClick:me||be?or:void 0,onKeyDown:ar},Ne&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ve[0],height:Ve[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${Ke.left},${Ke.top})`},Ne)),e.createElement("canvas",{ref:rt,"aria-label":Lt(null!==(y=null===(g=null==sr?void 0:sr.sceneNodes)||void 0===g?void 0:g.length)&&void 0!==y?y:0,null!==(v=null===(p=null==sr?void 0:sr.sceneEdges)||void 0===p?void 0:p.length)&&void 0!==v?v:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.createElement(Dt,{hoverPoint:dt}),$e&&e.createElement(St,{nodes:null!==(m=null==sr?void 0:sr.sceneNodes)&&void 0!==m?m:[],edges:null!==(b=null==sr?void 0:sr.sceneEdges)&&void 0!==b?b:[],chartType:"Network chart"}),e.createElement(wt,{width:Ze,height:Qe,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ke,labels:(null==sr?void 0:sr.labels)||[],sceneNodes:null==sr?void 0:sr.sceneNodes,title:Ie,legend:Ae,legendPosition:Le,legendHoverBehavior:Se,legendClickBehavior:De,legendHighlightedCategory:Pe,legendIsolatedCategories:Me,foregroundGraphics:Ue,annotations:we,svgAnnotationRules:Ee,annotationFrame:yt}),cr,(null==We?void 0:We.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===We.badgePosition?{top:4,left:4}:"bottom-left"===We.badgePosition?{bottom:4,left:4}:"bottom-right"===We.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:vt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},vt?"STALE":"LIVE"))});Jt.displayName="StreamNetworkFrame";const er={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 tr(e,t){return"function"==typeof t?t(e):e[t]}function rr(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 nr(t={}){const{fields:r,title:n,format:o,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let l;const c=[];if(n){const e=tr(t,n);l=rr(e,o)}if(r&&r.length>0)r.forEach(e=>{let r,n,i;"string"==typeof e?(r=e,n=e,i=o):(r=e.label,n=e.accessor||e.key||"",i=e.format||o);const a=tr(t,n);c.push({label:r,value:rr(a,i)})});else if(!n){const e=["value","y","name","id","label"];for(const r of e)if(void 0!==t[r]){l=rr(t[r],o);break}if(!l){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(l=rr(t[e[0]],o))}}const s=Object.assign(Object.assign({},er),i);return e.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:s},l&&e.createElement("div",{style:{fontWeight:c.length>0?"bold":"normal"}},l),c.map((t,r)=>e.createElement("div",{key:r,style:{marginTop:0===r&&l?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function or(t){if(!0===t)return nr();if("function"==typeof t){const r=t;return t=>{const n=r(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==n?null:e.createElement("div",{className:"semiotic-tooltip",style:er},n)}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?nr(t):nr())}const ir=o(null);function ar(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 lr(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[cr,sr]=Rt(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=lr(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=lr(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}})}})),[ur,dr]=Rt(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 hr(e){const t=d(),r=e.clientId||t,{name:n}=e,o=sr(e=>e.selections.get(n)),a=sr(e=>e.setClause),c=sr(e=>e.clearClause),s=i(()=>!!o&&o.clauses.size>0,[o]);return{predicate:i(()=>o&&0!==o.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(ar(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(o,r):()=>!0,[o,r]),isActive:s,selectPoints:l(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(n,{clientId:r,type:"point",fields:t})},[r,n,a]),selectInterval:l(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(n,{clientId:r,type:"interval",fields:t})},[r,n,a]),clear:l(()=>{c(n,r)},[c,n,r]),clientId:r}}const fr=o(!1),gr="#007bff";function yr(e,t,r="category10"){const n=a(ir);return i(()=>{if(t){if(0===e.length)return n&&Object.keys(n).length>0?e=>n[e]||"#999":void 0;if("function"==typeof t){const o=Array.from(new Set(e.map(e=>t(e)+"")));return n&&Object.keys(n).length>0?e=>n[e]||"#999":zt(o.map(e=>({_cat:e})),"_cat",r)}if(n&&Object.keys(n).length>0){const o=zt(e,t,r);return e=>n[e]||o(e)}return zt(e,t,r)}},[e,t,r,n])}function pr({selection:e,linkedHover:t,fallbackFields:r=[],unwrapData:n=!1,onObservation:o,chartType:i,chartId:a}){const c=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,r),s=hr({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const t=e.name||"hover",{fields:r}=e,{predicate:n,isActive:o,selectPoints:i,clear:a}=hr({name:t});return{onHover:l(e=>{if(!e)return void a();const t={};for(const n of r){const r=e[n];void 0!==r&&(t[n]=[r])}Object.keys(t).length>0&&i(t)},[r,i,a,t]),predicate:n,isActive:o}}({name:(null==c?void 0:c.name)||"hover",fields:(null==c?void 0:c.fields)||r||[]}),d=dr(e=>e.pushObservation);return{activeSelectionHook:e?{isActive:s.isActive,predicate:s.predicate}:null,customHoverBehavior:l(e=>{var r,n;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(o||d){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:a};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(n=e.y)&&void 0!==n?n:0});o&&o(a),d&&d(a)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});o&&o(e),d&&d(e)}}},[t,u,o,i,a,d]),customClickBehavior:l(e=>{var t,r;if(o||d){const n={timestamp:Date.now(),chartType:i||"unknown",chartId:a};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},n),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});o&&o(a),d&&d(a)}else{const e=Object.assign(Object.assign({},n),{type:"click-end"});o&&o(e),d&&d(e)}}},[o,d,i,a])}}function vr(e,t,n){const[o,a]=r(null),[c,s]=r(new Set),u=l(t=>{"highlight"===e&&a(t?t.label:null)},[e]),d=l(t=>{"isolate"===e&&s(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),h=i(()=>{if(!e||"none"===e||!t)return null;const r="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(r?e[r]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&c.size>0?{isActive:!0,predicate:e=>{const n=r?e[r]:"function"==typeof t?t(e):null;return c.has(n)}}:null},[e,t,o,c]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?c:new Set,onLegendHover:u,onLegendClick:d,legendSelectionHook:h}}const mr={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 br(e,t,r){var n,o,i,a,l,c;const s=mr[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)?s.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?s.height:r.height,showAxes:s.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:s.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||s.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:s.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:s.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:s.marginDefaults}}function xr({componentName:t,message:r,width:n,height:o}){return e.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},r)))}class kr extends e.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:t}=this.props,r=this.state.error;return"function"==typeof t?t(r):void 0!==t?t:e.createElement(xr,{componentName:"ChartErrorBoundary",message:r.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function wr({componentName:t,width:r,height:n,children:o}){return e.createElement(kr,{fallback:o=>e.createElement(xr,{componentName:t,message:o.message,width:r,height:n})},o)}"undefined"!=typeof process&&process;const Er={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"},Ar={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Lr(t,r,n,o){return!1===o||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.createElement("div",{style:Object.assign(Object.assign({},Er),{width:r,height:n})},o||"No data available"):null}function Sr(t,r,n){if(!t)return null;const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),l=Math.floor((n-(o*(i+a)-a))/2);return e.createElement("div",{style:{width:r,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(t,n)=>e.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ar),{position:"absolute",top:l+n*(i+a),left:Math.floor(.1*r),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2})})))}function Dr(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function Pr(e,t){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=Dr(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 Mr({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 Ir({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=Pr(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 Cr=s(function(r,n){var o;const l=t(null);u(n,()=>({push:e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=l.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 c=br(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLegend:r.showLegend,showLabels:r.showLabels,title:r.title},{width:600,height:600}),{nodes:s,edges:d,margin:h,className:f,nodeIDAccessor:g="id",sourceAccessor:y="source",targetAccessor:p="target",nodeLabel:v,colorBy:m,colorScheme:b="category10",nodeSize:x=8,nodeSizeRange:k=[5,20],edgeWidth:w=1,edgeColor:E="#999",edgeOpacity:A=.6,iterations:L=300,forceStrength:S=.1,tooltip:D,frameProps:P={},onObservation:M,chartId:I,selection:C,linkedHover:N,loading:O,emptyContent:T,legendInteraction:W,legendPosition:_}=r,$=c.width,j=c.height,B=c.enableHover,z=c.showLegend,R=null!==(o=c.showLabels)&&void 0!==o&&o,H=c.title,F=Sr(O,$,j);if(F)return F;const Y=Lr(s,$,j,T);if(Y)return Y;const X=s||[],G=d||[],q=yr(X,m,b),V=i(()=>{if(!m)return[];const e=new Set;for(const t of X){const r="function"==typeof m?m(t):t[m];null!=r&&e.add(r+"")}return Array.from(e)},[X,m]),K=vr(W,m,V),Z=i(()=>e=>{const t={};return t.fill=m?Bt(e.data||e,m,q):gr,"number"==typeof x&&(t.r=x),t},[m,q,x]),Q=i(()=>e=>({stroke:E,strokeWidth:"number"==typeof w?w:"function"==typeof w?w(e):e[w]||1,opacity:A}),[w,E,A]),U=i(()=>{if(R&&v)return"function"==typeof v?v:e=>{var t,r,n;return null!==(n=null!==(r=null===(t=e.data)||void 0===t?void 0:t[v])&&void 0!==r?r:e[v])&&void 0!==n?n:e.id}},[R,v]),{legend:J,margin:ee,legendPosition:te}=function({data:e,colorBy:t,colorScale:r,showLegend:n,legendPosition:o="right",userMargin:l,defaults:c={top:50,bottom:60,left:70,right:40}}){const s=a(fr),u=void 0!==n?n:!s&&!!t,d=i(()=>{if(u&&t)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:e,colorBy:t,colorScale:r,getColor:Bt})},[u,t,e,r]),h=i(()=>{const e=Object.assign(Object.assign({},c),l);return d&&("right"===o&&110>e.right?e.right=110:"left"===o&&110>e.left?e.left=110:"top"===o&&50>e.top?e.top=50:"bottom"===o&&80>e.bottom&&(e.bottom=80)),e},[c,l,d,o]);return{legend:d,margin:h,legendPosition:o}}({data:X,colorBy:m,colorScale:q,showLegend:z,legendPosition:_,userMargin:h,defaults:c.marginDefaults}),{customHoverBehavior:re}=pr({selection:C,linkedHover:N,fallbackFields:m?["string"==typeof m?m:""]:[],unwrapData:!0,onObservation:M,chartType:"ForceDirectedGraph",chartId:I}),ne=Ir({componentName:"ForceDirectedGraph",nodes:s,edges:d,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:g}});return ne?e.createElement(xr,{componentName:"ForceDirectedGraph",message:ne,width:$,height:j}):e.createElement(wr,{componentName:"ForceDirectedGraph",width:$,height:j},e.createElement(Jt,Object.assign({ref:l,chartType:"force"},null!=s&&{nodes:X},null!=d&&{edges:G},{size:[$,j],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:ee,nodeIDAccessor:g,sourceAccessor:y,targetAccessor:p,iterations:L,forceStrength:S,nodeStyle:Z,edgeStyle:Q,colorBy:m,colorScheme:b,nodeSize:x,nodeSizeRange:k,nodeLabel:U,showLabels:R,enableHover:B,tooltipContent:!1===D?()=>null:or(D)||void 0,customHoverBehavior:N||M?re:void 0,legend:J,legendPosition:te},W&&"none"!==W&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories},{className:f,title:H},P)))});function Nr(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 Or(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 Tr(e){return"function"==typeof e?e:t=>t[e]||1}function Wr({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=Bt(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=Bt(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}}Cr.displayName="ForceDirectedGraph";const _r=s(function(r,n){var o;const a=t(null);u(n,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=a.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 l=br(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title},{width:800,height:600}),{nodes:c,edges:s,margin:d,className:h,sourceAccessor:f="source",targetAccessor:g="target",valueAccessor:y="value",nodeIdAccessor:p="id",colorBy:v,colorScheme:m="category10",edgeColorBy:b="source",orientation:x="horizontal",nodeAlign:k="justify",nodePaddingRatio:w=.05,nodeWidth:E=15,nodeLabel:A,edgeOpacity:L=.5,edgeSort:S,tooltip:D,frameProps:P={},onObservation:M,chartId:I,selection:C,linkedHover:N,loading:O,emptyContent:T,legendInteraction:W}=r,_=l.width,$=l.height,j=l.enableHover,B=null===(o=l.showLabels)||void 0===o||o,z=l.title,R=Sr(O,_,$);if(R)return R;const H=Lr(s,_,$,T);if(H)return H;const F=s||[],Y=i(()=>Or(c,F,f,g),[c,F,f,g]),X=yr(Y,v,m),G=i(()=>{if(!v)return[];const e=new Set;for(const t of Y){const r="function"==typeof v?v(t):t[v];null!=r&&e.add(r+"")}return Array.from(e)},[Y,v]),q=vr(W,v,G),V=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=v?Bt(e.data||e,v,X):"#4d430c",t},[v,X]),K=i(()=>Wr({edgeColorBy:b,colorBy:v,colorScale:X,nodeStyleFn:V,edgeOpacity:L,baseStyle:{stroke:"none",strokeWidth:0}}),[b,v,X,V,L]),Z=i(()=>{if(!B)return;const e=A||p;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[B,A,p]),Q=Object.assign(Object.assign({},l.marginDefaults),d),{customHoverBehavior:U,customClickBehavior:J}=pr({selection:C,linkedHover:N,fallbackFields:v?["string"==typeof v?v:""]:[],unwrapData:!0,onObservation:M,chartType:"SankeyDiagram",chartId:I}),ee=Ir({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ee?e.createElement(xr,{componentName:"SankeyDiagram",message:ee,width:_,height:$}):e.createElement(wr,{componentName:"SankeyDiagram",width:_,height:$},e.createElement(Jt,Object.assign({ref:a,chartType:"sankey"},Y.length>0&&{nodes:Y},null!=s&&{edges:F},{size:[_,$],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:Q,nodeIDAccessor:p,sourceAccessor:f,targetAccessor:g,valueAccessor:y,orientation:x,nodeAlign:k,nodePaddingRatio:w,nodeWidth:E,nodeStyle:V,edgeStyle:K,colorBy:v,colorScheme:m,edgeColorBy:b,edgeOpacity:L,edgeSort:S,nodeLabel:Z,showLabels:B,enableHover:j,tooltipContent:!1===D?()=>null:or(D)||void 0,customHoverBehavior:N||M?U:void 0,customClickBehavior:M?J:void 0},W&&"none"!==W&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories},{className:h,title:z},P)))});_r.displayName="SankeyDiagram";const $r=s(function(r,n){var o;const a=t(null);u(n,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=a.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 l=br(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title},{width:600,height:600}),{nodes:c,edges:s,margin:d,className:h,sourceAccessor:f="source",targetAccessor:g="target",valueAccessor:y="value",nodeIdAccessor:p="id",colorBy:v,colorScheme:m="category10",edgeColorBy:b="source",padAngle:x=.01,groupWidth:k=20,sortGroups:w,nodeLabel:E,edgeOpacity:A=.5,tooltip:L,frameProps:S={},onObservation:D,chartId:P,selection:M,linkedHover:I,loading:C,emptyContent:N,legendInteraction:O}=r,T=l.width,W=l.height,_=l.enableHover,$=null===(o=l.showLabels)||void 0===o||o,j=l.title,B=Sr(C,T,W);if(B)return B;const z=Lr(s,T,W,N);if(z)return z;const R=s||[],H=i(()=>Or(c,R,f,g),[c,R,f,g]),F=yr(H,v,m),Y=i(()=>{if(!v)return[];const e=new Set;for(const t of H){const r="function"==typeof v?v(t):t[v];null!=r&&e.add(r+"")}return Array.from(e)},[H,v]),X=vr(O,v,Y),G=H.length>0,q=i(()=>{if(G)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(v)o.fill=Bt(e.data||e,v,F);else{const i=Array.isArray(m)?m:Wt[m]||_t,a=Array.isArray(i)?i:_t,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}},[G,v,F,m]),V=i(()=>{if(G)return Wr({edgeColorBy:b,colorBy:v,colorScale:F,nodeStyleFn:q||(e=>({fill:gr})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[G,b,v,F,q,A]),K=i(()=>{if(!$)return;const e=E||p;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}},[$,E,p]),Z=Object.assign(Object.assign({},l.marginDefaults),d),{customHoverBehavior:Q}=pr({selection:M,linkedHover:I,fallbackFields:v?["string"==typeof v?v:""]:[],unwrapData:!0,onObservation:D,chartType:"ChordDiagram",chartId:P}),U=Ir({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return U?e.createElement(xr,{componentName:"ChordDiagram",message:U,width:T,height:W}):e.createElement(wr,{componentName:"ChordDiagram",width:T,height:W},e.createElement(Jt,Object.assign({ref:a,chartType:"chord"},H.length>0&&{nodes:H},null!=s&&{edges:R},{size:[T,W],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:Z,nodeIDAccessor:p,sourceAccessor:f,targetAccessor:g,valueAccessor:y,padAngle:x,groupWidth:k,sortGroups:w,nodeStyle:q,edgeStyle:V,colorBy:v,colorScheme:m,edgeColorBy:b,edgeOpacity:A,nodeLabel:K,showLabels:$,enableHover:_,tooltipContent:!1===L?()=>null:or(L)||void 0,customHoverBehavior:I||D?Q:void 0},O&&"none"!==O&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:h,title:j},S)))});function jr(t){var r;const n=br(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:l,layout:c="tree",orientation:s="vertical",childrenAccessor:u="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:A,loading:L,legendInteraction:S}=t,D=n.width,P=n.height,M=n.enableHover,I=null===(r=n.showLabels)||void 0===r||r,C=n.title,N=Sr(L,D,P);if(N)return N;const O=i(()=>Nr(null!=o?o:null,u),[o,u]),T=yr(O,y?void 0:f,g),W=i(()=>{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]),_=vr(S,y?void 0:f,W),$=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?$t[(e.depth||0)%$t.length]:f?Bt(e.data||e,f,T):gr,t},[f,y,T]),j=i(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),B=i(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return Tr(d)},[c,d]),z=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:R}=pr({selection:E,linkedHover:A,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:k,chartType:"TreeDiagram",chartId:w}),H=Mr({componentName:"TreeDiagram",data:o});return H?e.createElement(xr,{componentName:"TreeDiagram",message:H,width:D,height:P}):e.createElement(wr,{componentName:"TreeDiagram",width:D,height:P},e.createElement(Jt,Object.assign({chartType:c},null!=o&&{data:o},{size:[D,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:B,treeOrientation:s,edgeType:p,nodeStyle:$,edgeStyle:j,colorBy:f,colorScheme:g,colorByDepth:y,nodeSize:m,nodeLabel:I?v||h:void 0,showLabels:I,enableHover:M,tooltipContent:!1===b?()=>null:or(b)||void 0,customHoverBehavior:A||k?R:void 0},S&&"none"!==S&&{legendHoverBehavior:_.onLegendHover,legendClickBehavior:_.onLegendClick,legendHighlightedCategory:_.highlightedCategory,legendIsolatedCategories:_.isolatedCategories},{className:l,title:C},x)))}function Br(t){var r;const n=br(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:a,className:c,childrenAccessor:s="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:f="category10",colorByDepth:g=!1,labelMode:y="leaf",nodeLabel:p,padding:v=4,paddingTop:m,tooltip:b,frameProps:x={},selection:k,linkedHover:w,onObservation:E,chartId:A,loading:L,legendInteraction:S}=t,D=n.width,P=n.height,M=n.enableHover,I=null===(r=n.showLabels)||void 0===r||r,C=n.title,N=Sr(L,D,P);if(N)return N;const{activeSelectionHook:O,customHoverBehavior:T}=pr({selection:k,linkedHover:w,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:E,chartType:"Treemap",chartId:A}),W=l(e=>{if(!e)return T(null);const t=e.data||e;T({data:(null==t?void 0:t.data)||t})},[T]),_=i(()=>Nr(null!=o?o:null,s),[o,s]),$=yr(_,g?void 0:h,f),j=i(()=>{if(!h||g)return[];const e=new Set;for(const t of _){const r="function"==typeof h?h(t):t[h];null!=r&&e.add(r+"")}return Array.from(e)},[_,h,g]),B=vr(S,g?void 0:h,j),z=i(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=g?$t[(e.depth||0)%$t.length]:h?Bt(e.data||e,h,$):gr,t},[h,g,$]),R=i(()=>O?e=>{var t;const r=Object.assign({},z(e));if(O.isActive)if(O.predicate(e.data||e))(null==k?void 0:k.selectedStyle)&&Object.assign(r,k.selectedStyle);else{const e=null!==(t=null==k?void 0:k.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==k?void 0:k.unselectedStyle)&&Object.assign(r,k.unselectedStyle)}return r}:z,[z,O,k]),H=i(()=>Tr(u),[u]),F=void 0!==m?m:I&&"parent"===y?18:void 0,Y=Object.assign(Object.assign({},n.marginDefaults),a),X=Mr({componentName:"Treemap",data:o});return X?e.createElement(xr,{componentName:"Treemap",message:X,width:D,height:P}):e.createElement(wr,{componentName:"Treemap",width:D,height:P},e.createElement(Jt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[D,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,nodeIDAccessor:d,childrenAccessor:s,hierarchySum:H,padding:v,paddingTop:F,nodeStyle:R,colorBy:h,colorScheme:f,colorByDepth:g,nodeLabel:I?p||d:void 0,showLabels:I,labelMode:y,enableHover:M,tooltipContent:!1===b?()=>null:or(b)||void 0},(w||E)&&{customHoverBehavior:W},S&&"none"!==S&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:c,title:C},x)))}function zr(t){var r;const n=br(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:o,margin:a,className:l,childrenAccessor:c="children",valueAccessor:s="value",nodeIdAccessor:u="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:A}=t,L=n.width,S=n.height,D=n.enableHover,P=null===(r=n.showLabels)||void 0===r||r,M=n.title,I=Sr(E,L,S);if(I)return I;const C=i(()=>Nr(null!=o?o:null,c),[o,c]),N=yr(C,f?void 0:d,h),O=i(()=>{if(!d||f)return[];const e=new Set;for(const t of C){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[C,d,f]),T=vr(A,f?void 0:d,O),W=i(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=f?$t[(e.depth||0)%$t.length]:d?Bt(e.data||e,d,N):gr,t},[d,f,N,y]),_=i(()=>Tr(s),[s]),$=Object.assign(Object.assign({},n.marginDefaults),a),{customHoverBehavior:j}=pr({selection:k,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),B=Mr({componentName:"CirclePack",data:o});return B?e.createElement(xr,{componentName:"CirclePack",message:B,width:L,height:S}):e.createElement(wr,{componentName:"CirclePack",width:L,height:S},e.createElement(Jt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[L,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:_,padding:p,nodeStyle:W,colorBy:d,colorScheme:h,colorByDepth:f,nodeLabel:P?g||u:void 0,showLabels:P,enableHover:D,tooltipContent:!1===v?()=>null:or(v)||void 0,customHoverBehavior:w||b?j:void 0},A&&"none"!==A&&{legendHoverBehavior:T.onLegendHover,legendClickBehavior:T.onLegendClick,legendHighlightedCategory:T.highlightedCategory,legendIsolatedCategories:T.isolatedCategories},{className:l,title:M},m)))}$r.displayName="ChordDiagram",jr.displayName="TreeDiagram",Br.displayName="Treemap",zr.displayName="CirclePack";const Rr=$t;function Hr(t){const r=br(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:a,childrenAccessor:l="children",nodeIdAccessor:c="name",colorBy:s,colorScheme:u="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:A,frameProps:L={},onObservation:S,chartId:D,selection:P,linkedHover:M,loading:I}=t,C=r.width,N=r.height,O=r.enableHover,T=r.title,W=Sr(I,C,N);if(W)return W;const _=yr(i(()=>Nr(n,l),[n,l]),d?void 0:s,u),$=i(()=>{if(Array.isArray(u))return u;const e=Wt[u];return Array.isArray(e)?e:_t},[u]),j=i(()=>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]:Rr[(e.depth||0)%Rr.length]:s?Bt(e.data||e,s,_):gr,r.opacity=n?1:.85,r},[s,d,_,$]),B=i(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),z=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:R}=pr({selection:P,linkedHover:M,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:S,chartType:"OrbitDiagram",chartId:D}),H=i(()=>{if(R)return e=>{R(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[R]),F=Mr({componentName:"OrbitDiagram",data:n});return F?e.createElement(xr,{componentName:"OrbitDiagram",message:F,width:C,height:N}):e.createElement(wr,{componentName:"OrbitDiagram",width:C,height:N},e.createElement(Jt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[C,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,nodeIDAccessor:c,childrenAccessor:l,nodeStyle:j,edgeStyle:B,colorBy:s,colorScheme:u,colorByDepth:d,nodeSize:b,nodeLabel:x?c:void 0,showLabels:x,enableHover:!k&&O,tooltipContent:k?void 0:!1===w?()=>null:or(w)||void 0,customHoverBehavior:M||S?H:void 0,foregroundGraphics:E,annotations:A,className:a,title:T,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k},L)))}Hr.displayName="OrbitDiagram";export{$r as ChordDiagram,zr as CirclePack,Cr as ForceDirectedGraph,Hr as OrbitDiagram,_r as SankeyDiagram,Jt as StreamNetworkFrame,jr as TreeDiagram,Br as Treemap};