semiotic 3.6.0 → 3.7.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 (94) hide show
  1. package/CLAUDE.md +190 -227
  2. package/README.md +44 -14
  3. package/ai/cli.js +41 -0
  4. package/ai/componentMetadata.cjs +11 -2
  5. package/ai/dist/mcp-server.js +209 -6
  6. package/ai/examples.md +98 -0
  7. package/ai/schema.json +581 -1
  8. package/ai/system-prompt.md +5 -2
  9. package/dist/components/AccessibleNavTree.d.ts +25 -0
  10. package/dist/components/Annotation.d.ts +40 -14
  11. package/dist/components/ChartContainer.d.ts +32 -2
  12. package/dist/components/ai/annotationProvenance.d.ts +349 -0
  13. package/dist/components/ai/audienceProfile.d.ts +60 -3
  14. package/dist/components/ai/chartCapabilityTypes.d.ts +60 -2
  15. package/dist/components/ai/chartRoles.d.ts +27 -0
  16. package/dist/components/ai/conversationArc.d.ts +379 -0
  17. package/dist/components/ai/dataScaleProfile.d.ts +320 -0
  18. package/dist/components/ai/describeChart.d.ts +114 -0
  19. package/dist/components/ai/navigationTree.d.ts +45 -0
  20. package/dist/components/ai/readerGrounding.d.ts +70 -0
  21. package/dist/components/ai/suggestCharts.d.ts +34 -1
  22. package/dist/components/ai/useConversationArc.d.ts +89 -0
  23. package/dist/components/ai/useNavigationSync.d.ts +61 -0
  24. package/dist/components/ai/variantDiscovery.d.ts +168 -0
  25. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +3 -0
  26. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +3 -0
  27. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +3 -0
  28. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +3 -0
  29. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +3 -0
  30. package/dist/components/charts/shared/annotationHierarchy.d.ts +42 -0
  31. package/dist/components/charts/shared/annotationResolvers.d.ts +3 -2
  32. package/dist/components/charts/shared/annotationRules.d.ts +16 -0
  33. package/dist/components/charts/shared/annotationTypes.d.ts +14 -0
  34. package/dist/components/charts/shared/auditAccessibility.d.ts +90 -0
  35. package/dist/components/charts/shared/chartSpecs.d.ts +2 -3
  36. package/dist/components/charts/shared/diagnoseConfig.d.ts +4 -6
  37. package/dist/components/charts/shared/selectionUtils.d.ts +5 -2
  38. package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -0
  39. package/dist/components/charts/shared/types.d.ts +5 -1
  40. package/dist/components/charts/value/BigNumber.capability.d.ts +13 -0
  41. package/dist/components/charts/value/BigNumber.d.ts +14 -0
  42. package/dist/components/charts/value/formatting.d.ts +40 -0
  43. package/dist/components/charts/value/thresholdSparkline.d.ts +40 -0
  44. package/dist/components/charts/value/types.d.ts +292 -0
  45. package/dist/components/realtime/lifecycleBands.d.ts +44 -0
  46. package/dist/components/realtime/types.d.ts +23 -8
  47. package/dist/components/recipes/annotationDensity.d.ts +69 -0
  48. package/dist/components/recipes/annotationLayout.d.ts +93 -0
  49. package/dist/components/semiotic-ai.d.ts +38 -15
  50. package/dist/components/semiotic-realtime.d.ts +2 -0
  51. package/dist/components/semiotic-recipes.d.ts +4 -0
  52. package/dist/components/semiotic-utils.d.ts +8 -0
  53. package/dist/components/semiotic-value.d.ts +55 -0
  54. package/dist/components/semiotic.d.ts +7 -0
  55. package/dist/components/server/staticAnnotations.d.ts +2 -0
  56. package/dist/components/stream/AccessibleDataTable.d.ts +10 -1
  57. package/dist/components/stream/NetworkSVGOverlay.d.ts +11 -5
  58. package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -0
  59. package/dist/components/stream/SVGOverlay.d.ts +2 -0
  60. package/dist/components/stream/geoTypes.d.ts +3 -0
  61. package/dist/components/stream/networkTypes.d.ts +2 -0
  62. package/dist/components/stream/ordinalTypes.d.ts +2 -0
  63. package/dist/components/stream/types.d.ts +2 -0
  64. package/dist/geo.min.js +1 -1
  65. package/dist/geo.module.min.js +1 -1
  66. package/dist/network.min.js +1 -1
  67. package/dist/network.module.min.js +1 -1
  68. package/dist/ordinal.min.js +1 -1
  69. package/dist/ordinal.module.min.js +1 -1
  70. package/dist/realtime.min.js +1 -1
  71. package/dist/realtime.module.min.js +1 -1
  72. package/dist/semiotic-ai.d.ts +38 -15
  73. package/dist/semiotic-ai.min.js +1 -1
  74. package/dist/semiotic-ai.module.min.js +1 -1
  75. package/dist/semiotic-realtime.d.ts +2 -0
  76. package/dist/semiotic-recipes.d.ts +4 -0
  77. package/dist/semiotic-recipes.min.js +1 -1
  78. package/dist/semiotic-recipes.module.min.js +1 -1
  79. package/dist/semiotic-themes.min.js +1 -1
  80. package/dist/semiotic-themes.module.min.js +1 -1
  81. package/dist/semiotic-utils.d.ts +8 -0
  82. package/dist/semiotic-utils.min.js +1 -1
  83. package/dist/semiotic-utils.module.min.js +1 -1
  84. package/dist/semiotic-value.d.ts +55 -0
  85. package/dist/semiotic-value.min.js +2 -0
  86. package/dist/semiotic-value.module.min.js +2 -0
  87. package/dist/semiotic.d.ts +7 -0
  88. package/dist/semiotic.min.js +1 -1
  89. package/dist/semiotic.module.min.js +1 -1
  90. package/dist/server.min.js +1 -1
  91. package/dist/server.module.min.js +1 -1
  92. package/dist/xy.min.js +1 -1
  93. package/dist/xy.module.min.js +1 -1
  94. package/package.json +18 -4
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as r from"react";import{useRef as o,useMemo as i,useContext as a,useCallback as l,useSyncExternalStore as s,createContext as c,useState as d,useEffect as u,useLayoutEffect as h,forwardRef as f,useImperativeHandle as g,useId as y}from"react";import{interpolateNumber as p}from"d3-interpolate";import{min as v,groups as m,max as b,sum as x,mean as k,group as w}from"d3-array";import{forceLink as S,forceSimulation as A,forceManyBody as M,forceCenter as L,forceX as D,forceY as E}from"d3-force";import{scaleLinear as P,scaleOrdinal as T,scaleTime as O}from"d3-scale";import{ribbon as C,chord as N}from"d3-chord";import{arc as I,pie as _}from"d3-shape";import{hierarchy as W,partition as j,pack as B,treemap as $,treemapBinary as z,cluster as R,tree as H}from"d3-hierarchy";function F(e){return Array.isArray(e)?e[0]:e}function Y(e,t,n,r){return Object.assign({data:F(e),x:t,y:n,__semioticHoverData:!0},r)}const X={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},G={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function q(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function V(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function K(e){const t=e.map(q),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return V(e,n,r)}if(e>=1){const[e,r,o]=t[n];return V(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[a,l,s]=t[o],[c,d,u]=t[o+1];return V(Math.round(a+(c-a)*i),Math.round(l+(d-l)*i),Math.round(s+(u-s)*i))}}const Z=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],U=K(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Q=K(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=K(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=K(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),te=K(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]);K(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]);const ne=K(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),re=K(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]);K(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),K(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),K(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),K(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),K(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),K(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),K(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),K(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),K(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),K(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),K(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);class oe{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,r){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1,this._freeIndices.push(i);continue}const s=r&&null!==(o=r[a.edgeIndex])&&void 0!==o?o:1;a.t+=e*t*s*(l.bezier.circular?.3:1),1>a.t?ie(l.bezier,a.t,a.offset,a):(a.active=!1,this._freeIndices.push(i))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}}function ie(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,a=t*i,l=Math.min(Math.floor(a),i-1),s=a-l,[c,d,u,h]=e[l];ae(c,d,u,h,s,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;o.x+=-g/y*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,a,l]=e.points;ae(o,i,a,l,t,r);const s=l.x-o.x,c=l.y-o.y,d=Math.sqrt(s*s+c*c);if(d>.001){const t=s/d;r.x+=-c/d*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function ae(e,t,n,r,o,i){const a=1-o,l=a*a,s=l*a,c=o*o,d=c*o;i.x=s*e.x+3*l*o*t.x+3*a*c*n.x+d*r.x,i.y=s*e.y+3*l*o*t.y+3*a*c*n.y+d*r.y}function le(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function se(e,t){var n,r=[],o=[],i=[],a={},l=[];function s(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&s(t)})}function c(e){var t,r,u=!1;for(o.push(e),i[e]=!0,t=0;l[e].length>t;t++)(r=l[e][t])===n?(d(n,o),u=!0):i[r]||(u=c(r));if(u)s(e);else for(t=0;l[e].length>t;t++){var h=a[r=l[e][t]];h||(a[r]=h={}),h[r]=!0}return o.pop(),u}function d(e,t){var n=[].concat(t).concat(e);r.push(n)}function u(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),a=Array(t),l=Array(t),s=0;t>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,a[s]=-1,l[s]=[];var c,d=0,u=[],h=[];function f(t){var s=[t],c=[t];for(n[t]=r[t]=d,o[t]=!0,d+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=r[y]=d,o[y]=!0,d+=1,s.push(y),c.push(y);break}o[y]&&(r[t]=0|Math.min(r[t],r[y])),0>a[y]||l[t].push(a[y])}i[t]=g}else{if(r[t]===n[t]){var p=[],v=[],m=0;for(g=s.length-1;g>=0;--g){var b=s[g];if(o[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=u.length,b===t){s.length=g;break}}u.push(p);var x=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)x[--m]=v[g][k];h.push(x)}c.pop()}}}for(s=0;t>s;++s)0>n[s]&&f(s);for(s=0;h.length>s;s++){var g=h[s];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[s]=c}}return{components:u,adjacencyList:h}}(e),o=r.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],n=a);var s=o[n];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var f=u(n);if(n=f.leastVertex,l=f.adjList){for(var g=0;l.length>g;g++)for(var y=0;l[g].length>y;y++){var p=l[g][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return r}function ce(e){return e.y0-e.y1>0?"up":"down"}function de(e,t){return t(e.source)==t(e.target)}function ue(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function he(e){return e.target.x0-e.source.x1}function fe(e,t){var n=ye(e),r=he(t)/Math.tan(n);return"up"==ce(e)?e.y1-r:e.y1+r}function ge(e,t){var n=ye(e),r=he(t)/Math.tan(n);return"up"==ce(e)?e.y1+r:e.y1-r}function ye(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function pe(e,t){return t(e)}function ve(e){return be(e.source)}function me(e){return be(e.target)}function be(e){return(e.y0+e.y1)/2}function xe(e){return e.virtual?0:e.value}function ke(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!de(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!de(e,t)?r+1:r}),n+r}function we(e){return e.target.depth}function Se(e,t){return e.sourceLinks.length?e.depth:t-1}function Ae(e,t){return e.y0-t.y0}function Me(e,t){return t.y0-e.y0}function Le(e,t){return e.y1-t.y1}function De(e,t){return t.y1-e.y1}function Ee(e,t){return Te(e.source,t.source)||e.index-t.index}function Pe(e,t){return Te(e.target,t.target)||e.index-t.index}function Te(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Oe(e,t){return Ce(e)==Ce(t)?"bottom"==e.circularLinkType?Me(e,t):Ae(e,t):Ce(t)-Ce(e)}function Ce(e){return e.target.column-e.source.column}function Ne(e,t){return Ie(e)==Ie(t)}function Ie(e){return e.y0-e.y1>0?"up":"down"}function _e(e,t,n,r,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=v(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var s=i.links.filter(function(e){return e.circular});return s.sort(function(e,t){return t.value-e.value}),s.forEach(function(e,t){e._circularStub=t>=4}),We(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),We(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,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,de(e,t)&&ue(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+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,s=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?Me:Ae);var d=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+d,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+d),d+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?De:Le),d=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+d,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+d),d+=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,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function We(e,t,n){e.sort(Oe);var r=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(de(e,t)&&ue(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var l=r[a];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&je(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function je(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Be(e){return function(){return e}}function $e(e){return e.index}function ze(e){return e.nodes}function Re(e){return e.links}function He(e,t,n){var r=m(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.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 n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=be(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=be(e.target)*t,r+=t}}),r>0?o/r:NaN);l.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=l.get(e),r=l.get(t),o=n.bc,i=r.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)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?ke(t,n)-ke(e,n):"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==r.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==ke(t,n)?(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 Fe(e,t,n,r,o,i){var a=m(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,s=i;s>0;--s)c(l*=.99,n),d();function c(t,n){var r=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&&ke(o,n)>0){var s=k(o.sourceLinks,me),c=k(o.targetLinks,ve),d=s&&c?(s+c)/2:s||c;if(d){var u=(d-be(o))*t*.3;o.y0+=u,o.y1+=u}}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==r-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=k(o.sourceLinks,me),f=k(o.targetLinks,ve),g=((h&&f?(h+f)/2:h||f)-be(o))*t;o.y0+=g,o.y1+=g}})})}function d(){a.forEach(function(n){var i,a,l,s=e.y0,c=n.length;for(n.sort(t||Te),l=0;c>l;++l)(a=s-(i=n[l]).y0)>0&&(i.y0+=a,i.y1+=a),s=i.y1+r;if((a=s-r-e.y1)>0)for(s=i.y0-=a,i.y1-=a,l=c-2;l>=0;--l)(a=(i=n[l]).y1+o-s)>0&&(i.y0-=a,i.y1-=a),s=i.y0})}}function Ye(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Pe),e.targetLinks.sort(Ee)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=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=n+e.width/2,n+=e.width)})})}function Xe(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,l=$e,s=Se,c=void 0,d=32,u=2,h=ze,f=Re;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=r,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return w(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=le(n,r)),"object"!=typeof o&&(o=e.target=le(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(h,l),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,l=i.target.index;r[a]||(r[a]=[]),r[l]||(r[l]=[]),-1===r[a].indexOf(l)&&r[a].push(l)}var s=se(r);s.sort(function(e,t){return e.length-t.length});var c={};for(o=0;s.length>o;o++){var d=s[o].slice(-2);c[d[0]]||(c[d[0]]={}),c[d[0]][d[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,r=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:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){pe(e,t)!=pe(o.source,t)&&pe(e,t)!=pe(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),de(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(x(e.sourceLinks,xe),x(e.targetLinks,xe)),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,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-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(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.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?n(e,i):e.column})}(h,c,s);var f=i;if(null!==a){var g=m(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=b(g,function(e){return e.length});y>1&&(f=Math.max(1,(r-t)*a/(y-1)))}(function(e,t,n){var r=m(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=v(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/x(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=b(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,o),He(h,c,l),Fe(h,c,l,f,f,d),Ye(h),_e(h,l,u,10,8),He(h,c,l),Fe(h,c,l,f,f,d),Ye(h),_e(h,l,u,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return pe(n.source,t)==pe(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ne(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=fe(t,e);return e.y1-n}if(t.target.column>e.target.column)return fe(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;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y0=e.y1-a-t.width/2}})})}(h,l),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return pe(n.target,t)==pe(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ne(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=ge(t,e);return e.y0-n}if(t.source.column>e.source.column)return ge(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;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y1=e.y1-a-t.width/2}})})}(h,l),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){var i=v(t,function(e){return e.y0}),a=b(t,function(e){return e.y1}),l=(e.y1-e.y0)/(a-i);function s(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=s(e.y0),e.y1=s(e.y1)}),n.forEach(function(e){e.y0=s(e.y0),e.y1=s(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=s(e.y0)-e.y0;e.y0=s(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),_e(h,l,u,10,8)}(g),g}return g.update=function(e){return Ye(e),_e(e,l,u,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Be(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:Be(e),g):f},g.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Be(e),g):l},g.nodeAlign=function(e){return arguments.length?(s="function"==typeof e?e:Be(e),g):s},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(u=+e,g):u},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}function Ge(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:a,cp1X:l,cp2X:s}=e,c=(n+r)/2,d=(i+a)/2;return{pathD:[`M${t},${n}`,`C${l},${n} ${s},${i} ${o},${i}`,`L${o},${a}`,`C${s},${a} ${l},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:l,y:c},{x:s,y:d},{x:o,y:d}],halfWidth:(r-n)/2}}}const qe=e=>{let t,n,r,o,i,a,l,s,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,l=p(i,a),s=l(.5),c=l(.5),`M${t},${i}C${t},${s} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${o},${s} ${o},${i}Z`;const d=e.sankeyWidth/2,u=p(e.source.x1,e.target.x0),{pathD:h}=Ge({sx:e.source.x1,sTop:e.y0-d,sBot:e.y0+d,tx:e.target.x0,tTop:e.y1-d,tBot:e.y1+d,cp1X:u(.5),cp2X:u(.5)});return h};function Ve(e){var t;const n=e.sankeyWidth/2,r=(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,r=o.sourceY,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const l=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${r-n}L${t+l},${r-n}L${t+l},${r+n}L${t},${r+n}ZM${i},${a-n}L${i-s},${a-n}L${i-s},${a+n}L${i},${a+n}Z`}const i=o.sourceX,a=o.sourceY,l=o.targetX,s=o.targetY,c=o.rightFullExtent,d=o.leftFullExtent,u=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+r},${a-h*n+h*f}L${c+r},${u+h*r-h*f}L${c+r-f},${u+h*r}L${d-r+f},${u+h*r}L${d-r},${u+h*r-h*f}L${d-r},${s-h*n+h*f}L${d-r+f},${s-h*n}L${l},${s-h*n}L${l},${s+h*n}L${d+r},${s+h*n}L${d+r},${u-h*r}L${c-r},${u-h*r}L${c-r},${a+h*n}L${i},${a+h*n}Z`}const Ke=new Set,Ze=new WeakMap;function Ue(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Ze.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Ze.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Ke.has(e)||(Ke.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}const Qe={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(we))-1:0},justify:Se};function Je(e){return"string"==typeof e?e:e.id}const et={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i,a,l,s,c,d;if(0===e.length)return;const u="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.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"===u?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const b=Xe().extent(m).links(v).nodes(p).nodeAlign(Qe[h]||Se).nodeId(e=>e.id).nodeWidth(f).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of p)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of v){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,a=(null!==(s=null!==(l=r._circularWidth)&&void 0!==l?l:r.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-n,d=r[0],u=r[1];if(i>0&&a>0&&(0>e||0>n||t>d||o>u)){const t=Math.min(d/i,u/a),r=-e*t+(d-i*t)/2,o=-n*t+(u-a*t)/2;for(const e of p)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=Je(e.source),n=Je(e.target),r=k.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=null!==(d=e.width)&&void 0!==d?d:0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=u;const o=x.get(t),i=x.get(n);o&&(r.source=o),i&&(r.target=i)}}},buildScene(e,t,n,r){var o,i,a,l,s,c;const d="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Z,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const v=[],m=[],b=[],x=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=u?u(Ue(t,"nodeStyle")):{},o={fill:r.fill||p.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};x.set(t.id,("string"==typeof o.fill?o.fill:null)||p.get(t.id)||"#4d430c"),v.push("down"===d?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:o,datum:t,id:t.id,label:t.id})}const k=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of k){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 o=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";o="function"==typeof g?g(e)||o:"target"===g?x.get(r.id)||p.get(r.id)||o:x.get(t.id)||p.get(t.id)||o;const d=h?h(Ue(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),i=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=d.fill||o;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:a,fillOpacity:null!==(l=d.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:d.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-i},${t.targetY-n}L${t.targetX-i},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:a,fillOpacity:null!==(s=d.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:d.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-i,x1:t.targetX}});continue}let u;if(u=e.circular&&e.circularPathData?Ve(e):qe(e),!u)continue;const y={fill:d.fill||o,fillOpacity:null!==(c=d.fillOpacity)&&void 0!==c?c:f,stroke:d.stroke||"none",strokeWidth:d.strokeWidth,opacity:d.opacity};m.push({type:"bezier",pathD:u,bezierCache:e.bezier,style:y,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const i=t?t(n):n.id;if(!i)continue;let a,l,s;"down"===d?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,s="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+o/2),b.push({x:a,y:l,text:i+"",anchor:"down"===d?"middle":s,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:b}}},tt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i;if(0===e.length)return;const a=null!==(o=n.forceStrength)&&void 0!==o?o:.1,l=r[0]/2,s=r[1]/2,c=n.__previousPositions;let d=0;const u=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?d++:n?(t.x=n.x,t.y=n.y,d++):u.push(t)}const h=d>0&&.3>=(e.length>0?u.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of u){const r=nt(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=rt(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/r.length+a*Math.cos(i),e.y=n/r.length+a*Math.sin(i)}else{const t=rt(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=l+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=l+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=0===n.iterations?0:h?40:f,y=ot(n.nodeSize,n.nodeSizeRange,e),p=e=>y(e);if(g>0){const n=S().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*a:a)}).id(e=>e.id),r=A().force("charge",M().strength(e=>-25*p(e))).force("center",L(l,s).strength(.8)).force("x",D(l).strength(.15)).force("y",E(s).strength(.15));if(r.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}));n.links(e),r.force("link",n)}h?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let e=0;g>e;++e)r.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(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){var o,i,a,l,s,c,d;const u=n.nodeStyle,h=n.edgeStyle,f=ot(n.nodeSize,n.nodeSizeRange,e),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Z,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],v=[],m=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(Ue(t,"nodeSize")),r=u?u(Ue(t,"nodeStyle")):{},l={fill:r.fill||y.get(t.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:r.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:2,opacity:r.opacity};p.push({type:"circle",cx:t.x,cy:t.y,r:e,style:l,datum:t,id:t.id,label:t.id})}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:b.get(e.source),r="object"==typeof e.target?e.target:b.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=h?h(Ue(e,"edgeStyle")):{},i={stroke:o.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(d=o.opacity)&&void 0!==d?d:.6};v.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:i,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=f(Ue(n,"nodeSize"));m.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}};function nt(e,t,n){const r=[];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=n.get(a);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function rt(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function ot(e,t,n){var r,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=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===a.length)return()=>i[0];const l=null!==(r=v(a))&&void 0!==r?r:0,s=null!==(o=b(a))&&void 0!==o?o:1;if(l===s)return()=>(i[0]+i[1])/2;const c=P().domain([l,s]).range(i).clamp(!0);return t=>{var n;const r=null===(n=t.data)||void 0===n?void 0:n[e];return null==r||"number"!=typeof r?i[0]:c(r)}}const it=Z,at={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=n,l=Math.min(r[0],r[1])/2,s=l-i,c=r[0]/2,d=r[1]/2,u=(h=n.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,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=u(e);y[n][r]=o}const p=N().padAngle(o);a&&p.sortGroups(a);const v=p(y),m=v.groups,b=I().innerRadius(s).outerRadius(l);for(const t of m){const n=e[t.index],r=b.centroid({innerRadius:s,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+d,n.__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,n=x.get("string"==typeof e.source?e.source:e.source.id),r=x.get(t);n&&(e.source=n),r&&(e.target=r)}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 n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){var o,i,a,l;const{groupWidth:s=20,edgeOpacity:c=.5}=n,d=Math.min(r[0],r[1])/2,u=d-s,h=r[0]/2,f=r[1]/2,g=n.nodeStyle,y=n.edgeStyle,p=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:it,m=new Map;e.forEach((e,t)=>{m.set(e.id,v[t%v.length])});const b=C().radius(u),x=[],k=[],w=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let i;i=g?g(Ue(n,"nodeStyle")).fill||m.get(n.id)||v[t%v.length]:m.get(n.id)||v[t%v.length];const a=g?g(Ue(n,"nodeStyle")):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};x.push({type:"arc",cx:h,cy:f,innerR:u,outerR:d,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=b(t);if(!r)continue;const o=lt(r,h,f);let s=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";if(y)s=y(Ue(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===p&&n?s=m.get(n.id)||s:t&&(s=m.get(t.id)||s)}const d=y?y(Ue(e,"edgeStyle")):{},u={fill:s,fillOpacity:null!==(l=d.fillOpacity)&&void 0!==l?l:c,stroke:d.stroke||"none",strokeWidth:d.strokeWidth,opacity:d.opacity};k.push({type:"ribbon",pathD:o,style:u,datum:e})}if(!1!==n.showLabels){const t=(S=n.nodeLabel)?"function"==typeof S?S:e=>e[S]||e.id:null,r=d+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;w.push({x:h+Math.cos(a)*r,y:f+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:x,sceneEdges:k,labels:w}}};function lt(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}const st=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ct(e){const[t,n,r]=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*n+.114*r>150?"#222":"#fff"}function dt(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function ut(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function ht(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:st}function ft(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function gt(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}const yt={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,l=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,d=W(i,l);d.sum(c),d.sort((e,t)=>{var n,r;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(r=e.value)&&void 0!==r?r:0)});const[u,h]=r;switch(a){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=H();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(d,n,u,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=R();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(d,n,u,h);break;case"treemap":!function(e,t,n,r){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,s=$().size([n,r]).tile(z).padding(a);l>0&&s.paddingTop(l),s(e)}(d,n,u,h);break;case"circlepack":!function(e,t,n,r){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;B().size([n,r]).padding(i)(e)}(d,n,u,h);break;case"partition":!function(e,t,n,r){var o;j().size([n,r]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,n,u,h)}const f=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;f.length>t;t++){const r=f[t],i={id:dt(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?pt(i,r,n):"treemap"===a||"partition"===a?vt(i,r):"circlepack"===a&&mt(i,r),i.__hierarchyNode=r,e.push(i),g.set(r,i)}if("tree"===a||"cluster"===a)for(const e of f)if(e.parent){const n=g.get(e.parent),r=g.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){var a,l,s,c,d,u,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,b=r[0]/2,x=r[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const t of e){let e=t.x,r=t.y;m&&(e+=b,r+=x);const i=o(Ue(t,"nodeStyle"));let s=i.fill||ft(n);if(n.colorByDepth&&void 0!==t.depth){const e=ht(n);s=e[t.depth%e.length]}const c={fill:s,stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};g.push({type:"circle",cx:e,cy:r,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const S=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,s=r.y;m&&(o+=b,a+=x,l+=b,s+=x);const f=gt(o,a,l,s,v),g=i(Ue(e,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(d=n.themeSemantic)||void 0===d?void 0:d.secondary)||"#999",strokeWidth:null!==(u=g.strokeWidth)&&void 0!==u?u:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:S};y.push({type:"curved",pathD:f,style:p,datum:e})}if(!1!==n.showLabels){const t=ut(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,a=n.x,l=n.y;if(m&&(a+=b,l+=x),m){const e=a-b,t=l-x,n=Math.sqrt(e*e+t*t);n>0?(r=a+e/n*10,o=l+t/n*10,i=0>e?"end":"start"):(r=a,o=l-12,i="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(r=a-k-6,i="end"):(r=a+k+6,i="start"),o=l):(r=a,o=l+k+14,i="middle");p.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){var o,i,a,l,s;const c=[],d=[];for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;const l=r(Ue(n,"nodeStyle"));let s=l.fill||ft(t);if(t.colorByDepth&&void 0!==n.depth){const e=ht(t);s=e[n.depth%e.length]}const d={fill:s,stroke:l.stroke||(null===(o=t.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:e,h:a,style:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ut(t.nodeLabel),o=t.labelMode||"leaf",i="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,u=c.y1-c.y0;if(0>=e||0>=u)continue;const h=!((null===(a=c.data)||void 0===a?void 0:a.children)&&c.data.children.length>0);if(!i){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>e||(h?16:14)>u)continue;let g=r(Ue(c,"nodeStyle")).fill||ft(t);if(t.colorByDepth&&void 0!==c.depth){const e=ht(t);g=e[c.depth%e.length]}const y="string"==typeof g?ct(g):null!==(s=null===(l=t.themeSemantic)||void 0===l?void 0:l.text)&&void 0!==s?s:"#000";d.push(h?{x:c.x0+e/2,y:c.y0+u/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:d}}(e,n,0,o);case"circlepack":return function(e,t,n,r){var o,i,a,l,s,c,d,u,h,f;const g=[],y=[];for(const n of e){const e=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=e)continue;const s=r(Ue(n,"nodeStyle"));let c=s.fill||ft(t);if(t.colorByDepth&&void 0!==n.depth){const e=ht(t);c=e[n.depth%e.length]}const d={fill:c,stroke:s.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=s.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=s.opacity)&&void 0!==l?l:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:e,style:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ut(t.nodeLabel);for(const o of e){const e=null!==(s=o.__radius)&&void 0!==s?s:5,i=n?n(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=r(Ue(o,"nodeStyle")).fill||ft(t);if(t.colorByDepth&&void 0!==o.depth){const e=ht(t);l=e[o.depth%e.length]}if(a){const n="string"==typeof l?ct(l):null!==(u=null===(d=t.themeSemantic)||void 0===d?void 0:d.text)&&void 0!==u?u:"#000";y.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else y.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:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=t.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pt(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(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 vt(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 mt(e,t){var n;const r=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}function bt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const xt={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){var i,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,u=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,h="number"==typeof d?()=>d:d,f="number"==typeof u?()=>u:u,g=bt(n);g.metaMap.clear(),r.length=0,o.length=0;const y=new Map;function p(e){var t;const n=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,m=t[1]/2,b=Math.min(t[0],t[1])/2*.85,x=p(s(e));r.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,n,i,a,d,u,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+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let m=0;b>m;m++){const x=c[Math.min(m,c.length-1)],k=v.slice(w,w+x);if(!k.length)break;const S=(m+1)/b,A={id:n,depth:u,data:t,parentId:n},M=y?d/h(A)*S:d*S,L=_().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),D=L(k),E=f(A);for(let t=0;k.length>t;t++){const l=(D[t].startAngle+D[t].endAngle)/2,c=k[t],d=p(s(c)),h=i+M*Math.sin(l),f=a+M*Math.cos(l)*E;r.push({id:d,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:u,data:c}),g.metaMap.set(d,{ring:M,angle:l,depth:u,parentId:n,eccentricity:E}),o.push({source:n,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:d}}),e(c,d,h,f,M,u+1,!0)}w+=x}}(e,x,v,m,b,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){var o,i,a,l,s,c,d;const u=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const t=bt(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{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:n,ecc:r}]of o)for(let o=0;i>o;o++){const l=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;y.push({type:"line",x1:e+n*Math.sin(l),y1:t+n*Math.cos(l)*r,x2:e+n*Math.sin(s),y2:t+n*Math.cos(s)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(Ue(t,"nodeSize")),r=u?u(Ue(t,"nodeStyle")):{},c={fill:r.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:r.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=r.opacity)&&void 0!==l?l:0===(null!==(s=t.depth)&&void 0!==s?s:0)?1:.85};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:v.get(e.source),n="object"==typeof e.target?e.target:v.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&y.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=f(Ue(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t&&null!==(d=null===(c=n.data)||void 0===c?void 0:c[t])&&void 0!==d?d:n.id;p.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){var n,r;const o=bt(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,a=null!==(r=t.orbitRevolution)&&void 0!==r?r: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 n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),l=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const r=e.angle+l*s*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(r),t.y=n.y+e.ring*Math.cos(r)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},kt={sankey:et,force:tt,chord:at,tree:yt,cluster:yt,treemap:yt,circlepack:yt,partition:yt,orbit:xt};function wt(e){return kt[e]}const St={category10:Z,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:U,reds:Q,greens:J,oranges:ee,purples:te,viridis:ne,plasma:re},At=Z,Mt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Lt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Dt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Et(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Dt.has(t)}(r)?n(r):r}const r=(null==e?void 0:e[t])+"";return n?n(r):At[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%At.length]}function Pt(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return T().domain(r).range(n).unknown("#999");const i=St[n]||St.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:At;return T().domain(r).range(e).unknown("#999")}}function Tt(e){return 0===e.length?()=>"#4e79a7":t=>{var n;let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return null!==(n=e[Math.abs(r)%e.length])&&void 0!==n?n:"#4e79a7"}}function Ot(e,t,n){return e+(t-e)*n}function Ct(e,t,n){var r,o,i;if(1>=n)return 1;const a=null!==(r=e.minOpacity)&&void 0!==r?r:.1,l=n-1-t;switch(e.type){case"linear":return a+(1-l/(n-1))*(1-a);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:n/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>l?1:a;default:return 1}}class Nt{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=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({},X),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new oe(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},X),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new oe(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,n){const{nodeIDAccessor:r="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof r?r:e=>e[r],s="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});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({},It(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],r=s(n)+"",o=c(n)+"",i=d(n),a=null==i?NaN:Number(i),l=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},It(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},It(o)),{data:n}));const u=`${r}\0${o}\0${e}`,h={source:r,target:o,value:l,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:u};n&&"object"==typeof n&&_t(n.bezier)&&(h.bezier=n.bezier),this.edges.set(u,h)}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=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,It(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,It(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,n),s=this.edges.get(l);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,r,o,i,a,l,s;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=wt(this.config.chartType);if(!c)return;let d=Array.from(this.nodes.values());const u=Array.from(this.edges.values());if(0===d.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const l of d)if(void 0!==l._prevX0){const s=(null!==(t=l._prevX1)&&void 0!==t?t:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(r=l._prevY1)&&void 0!==r?r:0)-(null!==(o=l._prevY0)&&void 0!==o?o:0);e.set(l.id,{x:(null!==(i=l._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(a=l._prevY0)&&void 0!==a?a:0)+c/2})}else 0===l.x&&0===l.y||e.set(l.id,{x:l.x,y:l.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(d,u,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&d.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of d)this.nodes.set(e.id,e);for(let e=0;u.length>e;e++){const t=u[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,d=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=d.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=null!==(s=null===(l=this.config.transition)||void 0===l?void 0:l.duration)&&void 0!==s?s:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&d.length>0&&g>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.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=e,this.previousEdgeKeys=t}buildScene(e){var t,n,r,o,i,a;const l=Array.from(this.nodes.values()),s=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=function(e,t,n){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=St[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,Z),d={nodes:l,edges:s,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:null!==(t=this.config.themeSemantic)&&void 0!==t?t:{},categorical:[...c]},resolveColor:Tt(c),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{}};let u;try{u=this.config.customNetworkLayout(d)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],void(this.customLayoutOverlays=null)}return this.sceneNodes=null!==(r=u.sceneNodes)&&void 0!==r?r:[],this.sceneEdges=null!==(o=u.sceneEdges)&&void 0!==o?o:[],this.labels=null!==(i=u.labels)&&void 0!==i?i:[],void(this.customLayoutOverlays=null!==(a=u.overlays)&&void 0!==a?a:null)}this.customLayoutOverlays=null;const c=wt(this.config.chartType);if(!c)return;const{sceneNodes:d,sceneEdges:u,labels:h}=c.buildScene(l,s,this.config,e);this.sceneNodes=d,this.sceneEdges=u,this.labels=h}get isAnimating(){const e=wt(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=wt(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=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=Ot(e._prevX0,e._targetX0,n),e.x1=Ot(e._prevX1,e._targetX1,n),e.y0=Ot(e._prevY0,e._targetY0,n),e.y1=Ot(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Ot(e._prevY0,e._targetY0,n),e.y1=Ot(e._prevY1,e._targetY1,n),e.sankeyWidth=Ot(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=null==e?void 0:e.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}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),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.x1,i=n.x0,a=p(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:r}}const o=t.x1,i=n.x0,a=p(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:r}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,a=n.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},n])}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,n,r,o,i;const a=this.config.pulse;if(!a)return;const l=null!==(t=a.duration)&&void 0!==t?t:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=a.glowRadius)&&void 0!==r?r:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const o=e-r;l>o&&(t._pulseIntensity=1-o/l,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const r="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!a)continue;const c=this.edgeTimestamps.get(`${r}\0${a}`);if(!c)continue;const d=e-c;l>d&&(t._pulseIntensity=1-d/l,t._pulseColor=s)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const r=this.nodeTimestamps.size;if(1>=r)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const o=this._decaySortedNodes,i=new Map;for(let e=0;o.length>e;e++)i.set(o[e][0],e);for(const o of this.sceneNodes){const a=o.id;if(!a)continue;const l=i.get(a);if(void 0===l)continue;const s=Ct(n,l,r),c=null!==(t=null===(e=o.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;o.style=Object.assign(Object.assign({},o.style),{opacity:c*s})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,r),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,n;const r=this.config.thresholds;if(!r)return;const o=null!==(t=r.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==r.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=r.metric(l);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const r=this.nodes.get(e);if(!r)return null;const o=r.data?Object.assign({},r.data):{};return r.data=t(null!==(n=r.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(e,t,n){var r;const o=this.config.valueAccessor,i="function"==typeof o?o:o?e=>e[o]:e=>e.value,a=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){a.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(r=o.data)&&void 0!==r?r:{});const e=i(o.data);null!=e&&(o.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}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._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function It(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 _t(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Wt(e))return!1;return!0}return Wt(t.points)}function Wt(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}function jt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:r.createElement(r.Fragment,null,...t)}function Bt(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function $t(e,t,n,r,o=30){let i=null,a=o,l=1/0;for(const t of e){const e=zt(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(i=e,l=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){if(!1===e.interactive)continue;const t=Xt(e,n,r);t&&a>t.distance&&(i=t,a=t.distance)}return i}function zt(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i),l=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,r);return a>l?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"rect":return function(e,t,n){const r=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Bt(Math.atan2(o,r)),l=Bt(e.startAngle),s=Bt(e.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let Rt=null,Ht=null;function Ft(){return Ht||(Rt=document.createElement("canvas"),Rt.width=1,Rt.height=1,Ht=Rt.getContext("2d")),Ht}function Yt(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function Xt(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=Yt(e),o=Ft();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let a=((t-e.x1)*r+(n-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const l=e.x1+a*r,s=e.y1+a*o,c=Math.sqrt(Math.pow(t-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:e.datum,x:l,y:s,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=Yt(e),o=Ft();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Gt(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?qt(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?qt(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function qt(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function Vt(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}const Kt="var(--semiotic-focus, #005fcc)";function Zt({active:t,hoverPoint:n,margin:r,size:o,shape:i="circle",width:a,height:l}){if(!t||!n)return null;const s=n.x+r.left,c=n.y+r.top;let d;if("rect"===i&&null!=a&&null!=l){const t=Math.max(a,4),n=Math.max(l,4);d=e("rect",{x:s-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:Kt,strokeWidth:2,strokeDasharray:"4,2"})}else d=e("circle","wedge"===i?{cx:s,cy:c,r:12,fill:"none",stroke:Kt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:Kt,strokeWidth:2,strokeDasharray:"4,2"});return e("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:d})}const Ut={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Qt(e,t){return"function"==typeof t?t(e):e[t]}function Jt(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function en(n={}){const{fields:r,title:o,format:i,style:a={},className:l=""}=n;return n=>{if(!n||"object"!=typeof n)return null;let s;const c=[];if(o){const e=Qt(n,o);s=Jt(e,i)}if(r&&r.length>0)r.forEach(e=>{let t,r,o;"string"==typeof e?(t=e,r=e,o=i):(t=e.label,r=e.accessor||e.key||"",o=e.format||i);const a=Qt(n,r);c.push({label:t,value:Jt(a,o)})});else if(!o){const e=["value","y","name","id","label"];for(const t of e)if(void 0!==n[t]){s=Jt(n[t],i);break}if(!s){const e=Object.keys(n).filter(e=>!e.startsWith("_"));e.length>0&&(s=Jt(n[e[0]],i))}}const d=Object.assign(Object.assign({},Ut),a);return t("div",{className:("semiotic-tooltip "+l).trim(),style:d,children:[s&&e("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:s}),c.map((e,n)=>t("div",{style:{marginTop:0===n&&s?"4px":0},children:[e.label&&t("span",{children:[e.label,": "]}),e.value]},n))]})}}function tn(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var r;const o=F(!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(r=t.data)&&void 0!==r?r:{}:t),i=n(o);return null==i?null:e("div",{className:"semiotic-tooltip",style:Ut,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?en(t):en())}}function nn({x:t,y:n,containerWidth:o,containerHeight:i,margin:a,children:l,className:s="stream-frame-tooltip",zIndex:c=1}){const d=Number.isFinite(t)&&Number.isFinite(n),u=r.useRef(null),[h,f]=r.useState(null);r.useLayoutEffect(()=>{const e=u.current;if(!e)return;const t=e.getBoundingClientRect();f(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[l,s,o,i]);let g;g=h?`translate(${h.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${h.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const y=function(e){if(!r.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(l),p=y?null:Ut;return d?e("div",{ref:u,className:y?s:(s+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:a.left+t,top:a.top+n,transform:g,pointerEvents:"none",zIndex:c,width:"max-content"}),children:l}):null}function rn(t){let n=null;const r=()=>(n||(n=c(null)),n),d=on(t);return[function({children:n,initialState:a}){const l=o(a),s=i(()=>on(t,l.current),[]),c=r();return e(c.Provider,{value:s,children:n})},e=>{var t;const n=r(),i=null!==(t=a(n))&&void 0!==t?t:d,c=o(e);c.current=e;const u=l(()=>c.current(i.getState()),[i]),h=l(()=>c.current(i.getState()),[i]);return s(i.subscribe,u,h)}]}function on(e,t){const n=new EventTarget;let r=Object.assign(Object.assign({},e(function(e){r=Object.assign(Object.assign({},r),e(r)),n.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>r,subscribe:function(e){return n.addEventListener("update",e),()=>n.removeEventListener("update",e)}}}function an(e){if(!(null==e?void 0:e.colors))return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function ln(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:sn})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const sn=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],cn={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},dn={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},un={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:sn,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function hn(e,t){if("light"===t)return cn;if("dark"===t)return dn;if("high-contrast"===t)return un;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?dn:cn;return ln(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}return ln(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}const[fn,gn]=rn(e=>({theme:cn,setTheme(t){e(e=>({theme:hn(e.theme,t)}))}}));const yn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,pn=new WeakMap;let vn=0,mn=!1,bn=null,xn=null,kn=null;function wn(e,t){var n,r;if(!t)return t;const o=yn.exec(t);if(!o)return t;const i=e.canvas;if(!i)return(null===(n=o[2])||void 0===n?void 0:n.trim())||t;!function(){if(mn)return;if("undefined"==typeof window||"undefined"==typeof document)return;mn=!0;const e=()=>{vn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(bn=new MutationObserver(e),bn.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{xn=window.matchMedia("(prefers-color-scheme: dark)"),kn=e,"function"==typeof xn.addEventListener?xn.addEventListener("change",kn):"function"==typeof xn.addListener&&xn.addListener(kn)}catch(e){}}();let a=pn.get(i);a&&a.version===vn||(a={version:vn,map:new Map},pn.set(i,a));const l=a.map.get(t);if(void 0!==l)return l;const s=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(r=o[2])||void 0===r?void 0:r.trim())||t;return a.map.set(t,s),s}const Sn="undefined"==typeof window?u:h;function An(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Mn(e){const t=function(){const[e,t]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return u(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=o(t);n.current=t;const[a,s]=function(e,t,n){const r=o(null),[i,a]=d(null);return u(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),c=i(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),h=s[0]-c.left-c.right,f=s[1]-c.top-c.bottom,g=An(e.foregroundGraphics,s,c),y=An(e.backgroundGraphics,s,c),p=gn(e=>e.theme),{transition:v,introEnabled:m}=function(e,t){var n,r;if(!1===e)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(r=e.duration)&&void 0!==r?r:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(o||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),b="semiotic-table-"+r.useId(),x=o(0),k=o(()=>{}),w=l(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);u(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const S=o(()=>{}),A=o(()=>{}),M=o(null),L=o(0),D=l(()=>{L.current=0;const e=M.current;M.current=null,e&&S.current(e)},[]),E=l(e=>{M.current={clientX:e.clientX,clientY:e.clientY},0===L.current&&(L.current=requestAnimationFrame(D))},[D]),P=l(()=>{M.current=null,0!==L.current&&(cancelAnimationFrame(L.current),L.current=0),A.current()},[]);u(()=>()=>{M.current=null,0!==L.current&&(cancelAnimationFrame(L.current),L.current=0)},[]);const T=e.themeDirtyRef;return Sn(()=>{T&&(vn++,T.current=!0,w())},[p,w,T]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:a,size:s,margin:c,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:y,currentTheme:p,transition:v,introEnabled:m,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:S,hoverLeaveRef:A,onPointerMove:E,onPointerLeave:P}}const Ln={fill:(t,n)=>e("rect",{style:t,width:n,height:n}),line:(t,n)=>e("line",{style:t,x1:0,y1:0,x2:n,y2:n})};function Dn(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Ln[n])(r(e,t),o),i}function En({swatchSize:t}){return e("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Pn(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const Tn=(n,r,o,i,a,l,s,c,d,u,h)=>{const{type:f="fill",styleFn:g,items:y}=n,p=[];let v=0;const m=!(!r&&!o),b="isolate"===u||void 0===u&&null!=a,{swatchSize:x,labelGap:k,rowHeight:w}=h;return y.forEach((n,u)=>{const h=Dn(n,u,f,g,x),S=Pn(n,i,a),A=a&&a.size>0&&a.has(n.label);p.push(t("g",{transform:`translate(0,${v})`,onClick:r?()=>r(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?c===l&&u===s?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?A||!1:void 0,"aria-current":m&&!b&&null!=i&&n.label===i||void 0,"aria-label":n.label,onKeyDown:m?e=>{var t;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(n)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const n=(u+("ArrowDown"===e.key?1:-1)+y.length)%y.length;d(c,n);const r=null===(t=e.currentTarget.parentElement)||void 0===t?void 0:t.children[n];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:m?e=>{d(c,u),o&&o(n);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+k+2+7*n.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),h,A&&e(En,{swatchSize:x}),e("text",{y:x/2,x:x+k,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+u)),v+=w}),p};function On({config:n,orientation:o="vertical",width:i=100}){const{colorFn:a,domain:l,label:s,format:c}=n,d=c||(e=>Math.round(100*e)/100+""),u="grad-legend-"+r.useId();if("horizontal"===o){const n=12,r=Math.min(i,200),o=Math.max(0,(i-r)/2),c=[];for(let t=0;64>=t;t++){const n=t/64;c.push(e("stop",{offset:100*n+"%",stopColor:a(l[0]+n*(l[1]-l[0]))},t))}return t("g",{"aria-label":s||"Gradient legend",children:[e("defs",{children:e("linearGradient",{id:u,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),s&&e("text",{x:o+r/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e("rect",{x:o,y:0,width:r,height:n,fill:`url(#${u})`,rx:2}),e("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[0])}),e("text",{x:o+r,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[1])})]})}const h=[];for(let t=0;64>=t;t++){const n=t/64;h.push(e("stop",{offset:100*n+"%",stopColor:a(l[1]-n*(l[1]-l[0]))},t))}return t("g",{"aria-label":s||"Gradient legend",children:[s&&e("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e("defs",{children:e("linearGradient",{id:u,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),e("rect",{x:0,y:0,width:14,height:100,fill:`url(#${u})`,rx:2}),e("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[1])}),e("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[0])})]})}function Cn(n){const{legendGroups:o,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,legendInteraction:c,title:d="Legend",width:u=100,height:h=20,orientation:f="vertical",legendLayout:g}=n,y=function(e){var t,n,r,o,i;const a=Math.max(1,null!==(t=null==e?void 0:e.swatchSize)&&void 0!==t?t:16),l=Math.max(a,null!==(n=null==e?void 0:e.rowHeight)&&void 0!==n?n:22);return{swatchSize:a,labelGap:Math.max(0,null!==(r=null==e?void 0:e.labelGap)&&void 0!==r?r:6),itemGap:Math.max(0,null!==(o=null==e?void 0:e.itemGap)&&void 0!==o?o:10),rowHeight:l,align:"left"===(null==e?void 0:e.align)?"start":"right"===(null==e?void 0:e.align)?"end":null!==(i=null==e?void 0:e.align)&&void 0!==i?i:"start",maxWidth:null==e?void 0:e.maxWidth}}(g),[p,v]=r.useState(0),[m,b]=r.useState(0),x=r.useCallback((e,t)=>{v(e),b(t)},[]),k="vertical"===f?(({legendGroups:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:d,metrics:u})=>{let h=24;const f=[];return t.forEach((t,g)=>{h+=5,f.push(e("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,t.label&&(h+=16,f.push(e("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),h+=8),f.push(e("g",{className:"legend-item",transform:`translate(0,${h})`,children:Tn(t,r,o,i,a,l,s,g,c,d,u)},"legend-group-"+g)),h+=t.items.length*u.rowHeight+8}),f})({legendGroups:o||[],width:u,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:p,focusedItemIndex:m,onFocusedIndexChange:x,legendInteraction:c,metrics:y}):(({legendGroups:n,height:r,width:o,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:c,focusedItemIndex:d,onFocusedIndexChange:u,legendInteraction:h,metrics:f})=>{var g;let y=0;const p=[];n.forEach((n,r)=>{var g;let v=0;n.label&&(v+=16);const m=((n,r,o,i,a,l,s,c,d,u,h,f)=>{const{type:g="fill",styleFn:y,items:p}=n,v=[],{swatchSize:m,labelGap:b,itemGap:x,rowHeight:k,align:w}=h,S=!(!r&&!o),A="isolate"===u||void 0===u&&null!=a,M=p.map(e=>m+b+7*e.label.length),L=[];let D=0,E=0;M.forEach((e,t)=>{const n=0===E?e:E+x+e;f&&f>0&&E>0&&n>f?(L.push({start:D,end:t,width:E}),D=t,E=e):E=n}),p.length>0&&L.push({start:D,end:p.length,width:E}),L.forEach((n,u)=>{let h="center"===w?Math.max(0,((null!=f?f:n.width)-n.width)/2):"end"===w?Math.max(0,(null!=f?f:n.width)-n.width):0;for(let f=n.start;n.end>f;f++){const n=p[f],w=Dn(n,f,g,y,m),L=Pn(n,i,a),D=a&&a.size>0&&a.has(n.label);v.push(t("g",{transform:`translate(${h},${u*k})`,onClick:r?()=>r(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:S?c===l&&f===s?0:-1:void 0,role:S?"option":void 0,"aria-selected":S&&A?D||!1:void 0,"aria-current":S&&!A&&null!=i&&n.label===i||void 0,"aria-label":n.label,onKeyDown:S?e=>{var t;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(n)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const n=(f+("ArrowRight"===e.key?1:-1)+p.length)%p.length;d(c,n);const r=null===(t=e.currentTarget.parentElement)||void 0===t?void 0:t.children[n];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:S?e=>{d(c,f),o&&o(n);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","visible")}:void 0,onBlur:S?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:S?"pointer":"default",opacity:L,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[S&&e("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+b+2+7*n.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),w,D&&e(En,{swatchSize:m}),e("text",{y:m/2,x:m+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+f)),h+=M[f]+x}});const P=Math.max(0,...L.map(e=>e.width)),T=L.length;return{items:v,offset:P,totalRows:T,totalHeight:T*k}})(n,i,a,l,s,c,d,r,u,h,f,null!==(g=f.maxWidth)&&void 0!==g?g:o);v+=m.offset+5,p.push(Object.assign(Object.assign({label:n.label},m),{offset:v,totalRows:m.totalRows,totalHeight:m.totalHeight})),y+=v+12});const v=null!==(g=f.maxWidth)&&void 0!==g?g:o;let m=y>v?0:"center"===f.align?Math.max(0,(v-y)/2):"end"===f.align?Math.max(0,v-y):0;const b=[];return p.forEach((t,o)=>{const i=n[o];i.label&&(b.push(e("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+o)),m+=16),b.push(e("g",{className:"legend-item",transform:`translate(${m},0)`,children:t.items},"legend-group-"+o)),m+=t.offset+5,n[o+1]&&b.push(e("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(t.totalHeight||r)+0+8},"legend-top-line legend-symbol-"+o)),m+=12}),e("g",{children:b})})({legendGroups:o||[],title:d,height:h,width:u,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:p,focusedItemIndex:m,onFocusedIndexChange:x,legendInteraction:c,metrics:y}),w=!(!i&&!a);return t("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"isolate"!==c&&(void 0!==c||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==d&&""!==d&&"vertical"===f&&e("text",{className:"legend-title",y:16,x:u/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:d}),k]})}function Nn(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function In(e){return"object"==typeof e&&null!==e&&"gradient"in e}function _n(t){var n;const{legend:r,totalWidth:o,totalHeight:i,margin:a,legendPosition:l="right",legendLayout:s,title:c,legendHoverBehavior:d,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=t;if(!r)return null;const y="top"===l||"bottom"===l,p=!!c,v=Math.max(1,y?null!==(n=null==s?void 0:s.maxWidth)&&void 0!==n?n:Math.max(0,o-a.left-a.right):100);let m,b;return"left"===l?(m=Math.max(4,a.left-v-10),b=a.top):"top"===l?(m=a.left,b=p?32:8):"bottom"===l?(m=a.left,b=i-a.bottom+38):(m=o-a.right+10,b=a.top),e("g",{transform:`translate(${m}, ${b})`,children:In(r)?e(On,{config:r.gradient,orientation:y?"horizontal":"vertical",width:v}):Nn(r)?e(Cn,{legendGroups:r.legendGroups,title:"",width:v,orientation:y?"horizontal":"vertical",legendLayout:s,customHoverBehavior:d,customClickBehavior:u,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):r})}function Wn(o){const{width:i,height:a,totalWidth:l,totalHeight:s,margin:c,labels:d,title:u,legend:h,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p,legendPosition:v="right",legendLayout:m,foregroundGraphics:b,sceneNodes:x,annotations:k,svgAnnotationRules:w}=o;return t(n,{children:[t("svg",{role:"img",width:l,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e("title",{children:"string"==typeof u?u:"Network Chart"}),e("desc",{children:"string"==typeof u?u+" — network data visualization":"Network data visualization"}),t("g",{transform:`translate(${c.left},${c.top})`,children:[d.map((t,n)=>e("text",{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"},children:t.text},"label-"+n)),k&&k.filter(e=>"widget"!==e.type).map((t,n)=>{if(w){const o=w(t,n,{width:i,height:a,sceneNodes:x});if(o)return e(r.Fragment,{children:o},"annotation-"+n)}return null}),b]}),u&&"string"==typeof u?e("text",{x:l/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:u}):u?e("foreignObject",{x:0,y:0,width:l,height:c.top,children:u}):null,_n({legend:h,totalWidth:l,totalHeight:s,margin:c,legendPosition:v,title:u,legendLayout:m,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p})]}),null==k?void 0:k.filter(e=>"widget"===e.type&&e.nodeId&&x).map((t,n)=>{var r,o,i,a,l,s,d,u,h;const f=x.find(e=>{var n,r,o,i,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(o=null===(r=e.datum)||void 0===r?void 0:r.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=c.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=c.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),p=null!==(l=t.dx)&&void 0!==l?l:0,v=null!==(s=t.dy)&&void 0!==s?s:-16,m=null!==(d=t.width)&&void 0!==d?d:32,b=null!==(u=t.height)&&void 0!==u?u:32,k=null!==(h=t.content)&&void 0!==h?h:e("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e("div",{style:{position:"absolute",left:g+p-m/2,top:y+v-b/2,width:m,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}Wn.displayName="NetworkSVGOverlay";const jn={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Bn(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const $n="undefined"==typeof window||"undefined"==typeof document,zn="undefined"!=typeof window?h:u,Rn=()=>()=>{},Hn=()=>!1,Fn=()=>!0;function Yn(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function Xn(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Gn(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}const qn=r.createContext(null),Vn={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Kn(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const Zn=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Un="semiotic-accessible-data-table",Qn=Un+" semiotic-accessible-data-table-hidden",Jn=Un+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",er={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},tr={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},nr={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},rr={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},or={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},ir={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},ar={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #999))",marginBottom:4,fontStyle:"italic"};function lr({nodes:n,edges:o,chartType:i,tableId:a,chartTitle:l}){var s,c,d,u,h,f,g,y,p,v,m,b,x,k;const[w,S]=r.useState(!1),A=r.useContext(qn),M=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,L=w||M,D=l?"Data summary for "+l:a?`Data summary for ${i} ${a}`:"Data summary for "+i,E=r.useRef(null),P=r.useCallback(()=>{w||M||S(!0)},[w,M]),T=r.useCallback(e=>{var t;M||(null===(t=E.current)||void 0===t?void 0:t.contains(e.relatedTarget))||S(!1)},[M]);if(!n||0===n.length)return a?e("span",{id:a,tabIndex:-1,style:Vn}):null;if(!L)return e("div",{id:a,className:Qn,tabIndex:-1,onFocus:P,style:Vn,role:"region","aria-label":D,children:t("button",{type:"button",onClick:()=>S(!0),children:["View data summary (",n.length," nodes, ",o.length," edges)"]})});const O=Array.isArray(n)?n:[],C=Array.isArray(o)?o:[],N=new Map,I=new Map,_=new Map,W=new Map;for(const e of C){if(!e||"object"!=typeof e)continue;const t=null!==(c=e.datum)&&void 0!==c?c:e,n="object"==typeof t.source?null===(d=t.source)||void 0===d?void 0:d.id:t.source,r="object"==typeof t.target?null===(u=t.target)||void 0===u?void 0:u.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";I.set(e,(null!==(h=I.get(e))&&void 0!==h?h:0)+1),W.set(e,(null!==(f=W.get(e))&&void 0!==f?f:0)+o)}if(null!=r&&""!==r){const e=r+"";N.set(e,(null!==(g=N.get(e))&&void 0!==g?g:0)+1),_.set(e,(null!==(y=_.get(e))&&void 0!==y?y:0)+o)}}const j=[];for(let e=0;O.length>e;e++){const t=O[e];if(!t||"object"!=typeof t)continue;const n=null!==(v=null===(p=t.datum)||void 0===p?void 0:p.id)&&void 0!==v?v:t.id,r=null!=n?n+"":"node-"+e,o=null!==(m=N.get(r))&&void 0!==m?m:0,i=null!==(b=I.get(r))&&void 0!==b?b:0,a=null!==(x=_.get(r))&&void 0!==x?x:0,l=null!==(k=W.get(r))&&void 0!==k?k:0;j.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+l,wInDeg:a,wOutDeg:l})}j.sort((e,t)=>t.degree-e.degree);let B=0,$=0;if(j.length>0){let e=0;for(const t of j)e+=t.degree,t.degree>$&&($=t.degree);B=e/j.length}const z=C.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),R=[`${j.length} nodes, ${C.length} edges.`];j.length>0&&R.push(`Mean degree: ${Zn(B)}, max degree: ${$}.`);const H=j.slice(0,5);return t("div",{ref:E,id:a,className:Jn,tabIndex:-1,onBlur:T,style:er,role:"region","aria-label":D,children:[e("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{M&&A&&A.setVisible(!1),S(!1)},"aria-label":"Close data summary",style:nr,children:"×"}),e("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:tr,children:R.join(" ")}),t("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+i,style:rr,children:[t("caption",{className:"semiotic-accessible-data-table-caption",style:ar,children:["Top ",H.length," of ",j.length," nodes by degree"]}),e("thead",{children:t("tr",{children:[e("th",{style:or,children:"id"}),e("th",{style:or,children:"degree"}),e("th",{style:or,children:"in"}),e("th",{style:or,children:"out"}),z&&e("th",{style:or,children:"w. degree"}),z&&e("th",{style:or,children:"w. in"}),z&&e("th",{style:or,children:"w. out"})]})}),e("tbody",{children:H.map((n,r)=>t("tr",{children:[e("td",{style:ir,children:n.id}),e("td",{style:ir,children:n.degree}),e("td",{style:ir,children:n.inDeg}),e("td",{style:ir,children:n.outDeg}),z&&e("td",{style:ir,children:Zn(n.wDegree)}),z&&e("td",{style:ir,children:Zn(n.wInDeg)}),z&&e("td",{style:ir,children:Zn(n.wOutDeg)})]},r))})]})]})}function sr({summary:t}){return t?e("div",{role:"note",style:Vn,children:t}):null}function cr({tableId:t}){return e("a",{href:"#"+t,style:Vn,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Vn)},children:"Skip to data table"})}function dr({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="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("div",{"aria-live":"polite","aria-atomic":"true",style:Vn,children:n})}const ur=Object.freeze([]);function hr(e){if(!e)return ur;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function fr(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function gr(e,t,n=.3){fr(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function yr(e,t,n=.6){var r,o,i,a,l;if(!fr(t))return;const s=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,c=t.r+s*t._pulseIntensity,d=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,u=null!==(l=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==l?l:0;e.beginPath(),e.arc(d,u,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function pr(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function vr(e,t){var n,r,o,i,a,l;if(!t.pathD)return;e.save();const s=pr(t);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!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,l="string"==typeof t.style.fill?t.style.fill:"#999",s=wn(e,l)||l;o.addColorStop(0,1===a.from?s:"transparent"),o.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function mr(e,t){var n,r;e.save();const o=t.style.stroke||"#999";e.strokeStyle=wn(e,o)||o,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n: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!==(r=t.style.strokeWidth)&&void 0!==r?r: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 br(e,t){var n,r,o,i;if(!t.pathD)return;e.save();const a=pr(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(r=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==r?r:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||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 xr(e,t){var n,r;if(!t.pathD)return;e.save();const o=pr(t),i=t.style.stroke||"#999";e.strokeStyle=wn(e,i)||i,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.1,e.fill(o)),e.restore()}const kr={top:20,right:80,bottom:20,left:80},wr={top:40,right:40,bottom:40,left:40},Sr=new Set(["chord","force","circlepack","orbit"]),Ar=[800,600],Mr={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 Lr({data:n}){var r,o,i,a,l,s;if("edge"===n.nodeOrEdge){const e=n.data;return e?t("div",{className:"semiotic-tooltip",style:Mr,children:[t("div",{style:{fontWeight:600},children:["object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target]}),null!=e.value&&t("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]})]}):null}const c=n.data;if(!c)return null;const d=c.__hierarchyNode;if(d){const n=[];let l=d;for(;l;){const e=null!==(a=null!==(o=null===(r=l.data)||void 0===r?void 0:r.name)&&void 0!==o?o:null===(i=l.data)||void 0===i?void 0:i.id)&&void 0!==a?a:c.id;null!=e&&n.unshift(e+""),l=l.parent}n.length>1&&n.shift();const s=n.length-1;return t("div",{className:"semiotic-tooltip",style:Mr,children:[e("div",{children:n.map((n,r)=>t("span",{children:[r>0&&e("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),r===s?e("strong",{children:n}):e("span",{style:{opacity:.7},children:n})]},r))}),null!=c.value&&c.value>0&&e("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const u=((null===(l=c.sourceLinks)||void 0===l?void 0:l.length)||0)+((null===(s=c.targetLinks)||void 0===s?void 0:s.length)||0),h=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return t("div",{className:"semiotic-tooltip",style:Mr,children:[e("div",{style:{fontWeight:600},children:c.id}),null!=c.value&&c.value>0&&t("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),u>0&&t("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,h!==u&&` (weighted: ${h.toLocaleString()})`]})]})}Lr.ownsChrome=!0;const Dr=f(function(n,r){var a,c,h,f,y,p,v,m,b,x,k,w,S,A,M,L,D,E;const{chartType:P,nodes:T,edges:O,data:C,initialEdges:N,nodeIDAccessor:_="id",sourceAccessor:W="source",targetAccessor:j="target",valueAccessor:B="value",edgeIdAccessor:$,childrenAccessor:z,hierarchySum:R,orientation:H="horizontal",nodeAlign:F="justify",nodePaddingRatio:q=.05,nodeWidth:V=15,iterations:K=300,forceStrength:Z=.1,padAngle:U=.01,groupWidth:Q=20,sortGroups:J,edgeSort:ee,treeOrientation:te="vertical",edgeType:ne="curve",padding:re,paddingTop:oe,tensionConfig:ie,showParticles:ae=!1,particleStyle:le,nodeStyle:se,edgeStyle:ce,colorBy:de,colorScheme:ue="category10",edgeColorBy:he="source",edgeOpacity:fe=.5,colorByDepth:ge=!1,nodeSize:ye=8,nodeSizeRange:pe=[5,20],nodeLabel:ve,showLabels:me=!0,labelMode:be,size:xe=Ar,responsiveWidth:ke,responsiveHeight:we,margin:Se,className:Ae,background:Me,enableHover:Le=!0,tooltipContent:De,customHoverBehavior:Ee,customClickBehavior:Pe,onObservation:Te,chartId:Oe,onTopologyChange:Ce,annotations:Ne,svgAnnotationRules:Ie,legend:_e,legendPosition:We,legendLayout:je,legendHoverBehavior:Be,legendClickBehavior:$e,legendHighlightedCategory:ze,legendIsolatedCategories:Re,title:He,foregroundGraphics:Fe,backgroundGraphics:Ye,decay:Xe,pulse:Ge,transition:qe,animate:Ve,staleness:Ke,thresholds:Ze,accessibleTable:Ue=!0,description:Qe,summary:Je,orbitMode:et,orbitSize:tt,orbitSpeed:nt,orbitRevolution:rt,orbitRevolutionStyle:ot,orbitEccentricity:it,orbitShowRings:at,orbitAnimated:lt,customNetworkLayout:st,layoutConfig:ct}=n,dt=Sr.has(P)?wr:kr,ut=o(!0),ht=Mn({sizeProp:xe,responsiveWidth:ke,responsiveHeight:we,userMargin:Se,marginDefault:dt,foregroundGraphics:Fe,backgroundGraphics:Ye,animate:Ve,transitionProp:qe,themeDirtyRef:ut}),{reducedMotionRef:ft,responsiveRef:gt,size:yt,margin:pt,adjustedWidth:vt,adjustedHeight:mt,resolvedForeground:bt,resolvedBackground:xt,transition:kt,introEnabled:wt,tableId:St,rafRef:Mt,renderFnRef:Lt,scheduleRender:Dt,currentTheme:Et}=ht,Pt=function(){const[e,t]=d(!1);return zn(()=>{t(!0)},[]),e}(),Tt=function(){const e=s(Rn,Hn,Fn);return o(e).current}(),Ot=i(()=>hr(T),[T]),Ct=i(()=>Array.isArray(O)?hr(O):O,[O]),It=i(()=>Object.assign(Object.assign({},X),ie),[ie]),_t=i(()=>Object.assign(Object.assign({},G),le),[le]),Wt=i(()=>{var e;return{chartType:P,nodeIDAccessor:_,sourceAccessor:W,targetAccessor:j,valueAccessor:B,edgeIdAccessor:$,childrenAccessor:z,hierarchySum:R,orientation:H,nodeAlign:F,nodePaddingRatio:q,nodeWidth:V,iterations:K,forceStrength:Z,padAngle:U,groupWidth:Q,sortGroups:J,edgeSort:ee,treeOrientation:te,edgeType:ne,padding:re,paddingTop:oe,tensionConfig:It,showParticles:ae,particleStyle:_t,nodeStyle:se,edgeStyle:ce,nodeLabel:ve,showLabels:me,labelMode:be,colorBy:de,colorScheme:ue,themeCategorical:null===(e=null==Et?void 0:Et.colors)||void 0===e?void 0:e.categorical,themeSemantic:an(Et),edgeColorBy:he,edgeOpacity:fe,colorByDepth:ge,nodeSize:ye,nodeSizeRange:pe,decay:Xe,pulse:Ge,transition:kt,introAnimation:wt,staleness:Ke,thresholds:Ze,orbitMode:et,orbitSize:tt,orbitSpeed:nt,orbitRevolution:rt,orbitRevolutionStyle:ot,orbitEccentricity:it,orbitShowRings:at,orbitAnimated:lt,customNetworkLayout:st,layoutConfig:ct}},[P,_,W,j,B,z,R,H,F,q,V,K,Z,U,Q,J,ee,te,ne,re,oe,It,ae,_t,se,ce,ve,me,be,de,ue,he,fe,ge,ye,pe,Xe,Ge,null==kt?void 0:kt.duration,null==kt?void 0:kt.easing,wt,Ke,Ze,et,tt,nt,rt,ot,it,at,lt,Et,st,ct]),Bt=function(e){const t=o(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Xn(e,t);if(!Gn(e)||!Gn(t))return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!Xn(n,o))return!1}else{if(!Gn(n)||!Gn(o))return!1;if(!Yn(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}(Wt),zt=o(null),Rt=o(0),Ht=o(0),Ft=o(!1),Yt=o(null);Yt.current||(Yt.current=new Nt(Bt));const[Xt,qt]=d(null),[Kt,Ut]=d(0),[Qt,Jt]=d(0),[en,tn]=d(!1),[rn,on]=d(null),ln=o(null),sn=o(new Map),cn=o(0),dn=l(e=>{if("function"==typeof de)return de(e)+"";if("string"==typeof de&&e.data){const t=e.data[de];if(void 0!==t){if(!sn.current.has(t+"")){const e=Array.isArray(ue)?ue:At;sn.current.set(t+"",e[cn.current++%e.length])}return sn.current.get(t+"")}}if(sn.current.has(e.id))return sn.current.get(e.id);const t=Array.isArray(ue)?ue:At,n=de?t[cn.current++%t.length]:t[0];return sn.current.set(e.id,n),n},[de,ue]),un=(null===(a=null==Et?void 0:Et.colors)||void 0===a?void 0:a.border)||(null===(c=null==Et?void 0:Et.colors)||void 0===c?void 0:c.secondary)||(null===(h=null==Et?void 0:Et.colors)||void 0===h?void 0:h.primary)||"#999",hn=l(e=>{var t,n;return e?"object"==typeof e?e:null!==(n=null===(t=Yt.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==n?n:null:null},[]),fn=l(e=>{if("function"==typeof he)return he(e);const t=hn(e.source),n=hn(e.target);return"target"===he&&n?dn(n):t?dn(t):un},[he,dn,un,hn]),gn=l(e=>{if("function"==typeof _t.color){const t=hn(e.source);return t?_t.color(e,t):un}if(!(null==le?void 0:le.colorBy))return fn(e);const t=_t.colorBy,n=hn(e.source),r=hn(e.target);return"target"===t&&r?dn(r):n?dn(n):un},[null==le?void 0:le.colorBy,_t.color,_t.colorBy,dn,fn,un,hn]),yn=("sankey"===P||!!st)&&ae||!!Ge||null!==(y=null===(f=Yt.current)||void 0===f?void 0:f.isAnimating)&&void 0!==y&&y;u(()=>{var e;null===(e=Yt.current)||void 0===e||e.updateConfig(Bt),ut.current=!0,Dt()},[Bt,Dt]);const pn=l(()=>{var e,t;on(null!==(t=null===(e=Yt.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);u(()=>{var e;const t=Yt.current;if(t){t.buildScene([vt,mt]),pn();for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&sn.current.set(n.id,n.style.fill);ut.current=!0,Dt()}},[Et,vt,mt,Dt,pn]);const vn=l(()=>{var e;const t=Yt.current;if(!t)return;t.runLayout([vt,mt]),t.buildScene([vt,mt]),pn(),ut.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&sn.current.set(n.id,n.style.fill);const n=Array.isArray(ue)?ue:At,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];sn.current.has(t.id)||sn.current.set(t.id,n[e%n.length])}if(cn.current=r.length,Ut(t.layoutVersion),Ce){const{nodes:e,edges:n}=t.getLayoutData();Ce(e,n)}},[vt,mt,Ce,ue,pn]),mn=l(e=>{if(null==e||"object"!=typeof e)return;const t=Yt.current;t&&(t.ingestEdge(e)&&vn(),Dt())},[vn,Dt]),bn=l(e=>{const t=Yt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&vn(),Dt()},[vn,Dt]),xn=l(()=>{var e;null===(e=Yt.current)||void 0===e||e.clear(),sn.current.clear(),cn.current=0,Ut(0),qt(null),ln.current=null,ut.current=!0,Dt()},[Dt]),kn=l(()=>{const e=Yt.current;e&&(e.tension+=999,vn(),Dt())},[vn,Dt]);g(r,()=>({push:mn,pushMany:bn,removeNode:e=>{var t,n,r;const o=null!==(n=null===(t=Yt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(o){const t=(null===(r=ln.current)||void 0===r?void 0:r.data)?"function"==typeof _?_(ln.current.data):ln.current.data[_]:void 0;ln.current&&"node"===ln.current.nodeOrEdge&&t===e&&(ln.current=null,qt(null)),sn.current.delete(e),vn(),ut.current=!0,Dt()}return o},removeEdge:(e,t)=>{var n,r;const o=null!==(r=null===(n=Yt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==r&&r;if(o){if(ln.current&&"edge"===ln.current.nodeOrEdge){const n=ln.current.data;let r;r=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!$||!n||("function"==typeof $?$:e=>null==e?void 0:e[$])(n)===e,r&&(ln.current=null,qt(null))}vn(),ut.current=!0,Dt()}return o},updateNode:(e,t)=>{var n,r;const o=null!==(r=null===(n=Yt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==r?r:null;return o&&(ut.current=!0,Dt()),o},updateEdge:(e,t,n)=>{var r,o;const i=null!==(o=null===(r=Yt.current)||void 0===r?void 0:r.updateEdge(e,t,n))&&void 0!==o?o:[];return i.length>0&&(vn(),ut.current=!0,Dt()),i},clear:xn,getTopology:()=>{var e,t;return null!==(t=null===(e=Yt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Yt.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:kn,getTension:()=>{var e,t;return null!==(t=null===(e=Yt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[mn,bn,xn,kn,vn,Dt]);const Sn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),An=Sn?C||(Array.isArray(O)?void 0:O):void 0;u(()=>{var e;const t=Yt.current;if(t)if(Sn&&An)t.ingestHierarchy(An,[vt,mt]),t.buildScene([vt,mt]),pn(),ut.current=!0,Dt();else{const n=Ot,r=Array.isArray(Ct)?Ct:[];if(0===n.length&&0===r.length)return;t.ingestBounded(n,r,[vt,mt]),t.buildScene([vt,mt]),pn();for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&sn.current.set(n.id,n.style.fill+"");const o=Array.isArray(ue)?ue:At,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];sn.current.has(t.id)||sn.current.set(t.id,o[e%o.length])}cn.current=i.length,ut.current=!0,Dt()}},[Ot,Ct,C,An,Sn,vt,mt,Bt,Dt,ue,pn]),u(()=>{N&&N.length>0&&bn(N)},[]);const Ln=l(e=>{if(Ee&&Ee(e),Te){const t=Date.now();Te(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Oe}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Oe})}},[Ee,Te,Oe]),Dn=l(e=>{if(Pe&&Pe(e),Te){const t=Date.now();Te(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Oe}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Oe})}},[Pe,Te,Oe]),{hoverHandlerRef:En,hoverLeaveRef:Pn,onPointerMove:Tn,onPointerLeave:On}=ht;En.current=e=>{if(!Le)return;const t=zt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-pt.left,o=e.clientY-n.top-pt.top;if(0>r||r>vt||0>o||o>mt)return void(ln.current&&(ln.current=null,qt(null),Ln&&(Ln(null),ut.current=!0),Dt()));const i=Yt.current;if(!i)return;const a=$t(i.sceneNodes,i.sceneEdges,r,o);if(!a)return void(ln.current&&(ln.current=null,qt(null),Ln&&(Ln(null),ut.current=!0),Dt()));const l=Y(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});ln.current=l,qt(l),Ln&&(Ln(l),ut.current=!0),Dt()},Pn.current=()=>{ln.current&&(ln.current=null,qt(null),Ln&&(Ln(null),ut.current=!0),Dt())};const Cn=o(()=>{});Cn.current=e=>{if(!Pe&&!Te)return;const t=zt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-pt.left,o=e.clientY-n.top-pt.top;if(0>r||r>vt||0>o||o>mt)return;const i=Yt.current;if(!i)return;const a=$t(i.sceneNodes,i.sceneEdges,r,o);Dn(a?Y(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)};const Nn=l(e=>Cn.current(e),[]),In=o(-1),_n=o(null),qn=o(-1),Vn=l(e=>{var t;const n=Yt.current;if(!n)return;const r=function(e){var t,n,r,o,i,a;const l=[];for(const s of e)if("circle"===s.type&&null!=s.cx){if(0>=s.r)continue;l.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(t=s.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"})}else if("rect"===s.type&&null!=s.x){if(0>=s.w||0>=s.h)continue;l.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"})}else"arc"===s.type&&null!=s.cx&&l.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(a=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return l.sort((e,t)=>e.x-t.x||e.y-t.y),l}(n.sceneNodes);if(0===r.length)return;const o=function(e){var t,n;const r=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let o=r.get(e);o||(o=[],r.set(e,o)),o.push(n)}for(const e of r.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(r.keys()).sort((e,t)=>{const n=r.get(e),o=r.get(t);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(r.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:o,byGroup:r,idToIdx:a}}(r),i=In.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),In.current=0,qn.current=-1;const t=o.flat[0];_n.current={shape:t.shape,w:t.w,h:t.h};const n=Y(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return ln.current=n,qt(n),Ln&&(Ln(n),ut.current=!0),void Dt()}const a=function(e,t){var n,r;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=i._groupIndex)&&void 0!==r?r:0}}(o,i),l=function(e,t,n,r,o){var i,a,l;const s=n.flat[t.flatIndex];if(!s)return Gt(e,t,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(a=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const l=a.x-t.x,s=a.y-t.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(l)}if(!c)continue;const d=l*l+s*s;o>d&&(o=d,r=i)}return r}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n;const r=e+"",o=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,i=Vt(t.source),a=Vt(t.target),l=null!=i,s=null!=a;l&&i+""===r&&s?o.push(a+""):s&&a+""===r&&l&&o.push(i+"")}return o}(c,r);if(0===e.length)return t.flatIndex;const i=null!==(l=n.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==l?l:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Gt(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,a,o,null!==(t=n.sceneEdges)&&void 0!==t?t:[],qn);if(null===l)return;if(e.preventDefault(),0>l)return In.current=-1,_n.current=null,qn.current=-1,ln.current=null,qt(null),Ln&&(Ln(null),ut.current=!0),void Dt();In.current=l;const s=o.flat[l];_n.current={shape:s.shape,w:s.w,h:s.h};const c={data:s.datum||{},x:s.x,y:s.y,__semioticHoverData:!0,nodeOrEdge:"node"};ln.current=c,qt(c),Ln&&(Ln(c),ut.current=!0),Dt()},[Ln,Dt]),Zn=l(e=>{In.current=-1,_n.current=null,Tn(e)},[Tn]);Lt.current=()=>{var e,t,n,r,o,i,a;Mt.current=0;const l=zt.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=Yt.current;if(!c)return;const d=performance.now(),u=Rt.current?Math.min((d-Rt.current)/1e3,.1):.016;Rt.current=d;const h=c.advanceTransition(ft.current?d+1e6:d),f=!ft.current&&h,g=!ft.current&&c.tickAnimation([vt,mt],u);(h||ut.current||g)&&c.buildScene([vt,mt]);const y="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=t[0]*r,a=t[1]*r,l=t[0]+"px",s=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==s&&(e.style.height=s),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(r,0,0,r,0,0),o.translate(n.left,n.top),o}(l,yt,pt,y))return;if(s.clearRect(-pt.left,-pt.top,yt[0],yt[1]),Me){const e=wn(s,Me);e&&(s.fillStyle=e,s.fillRect(0,0,vt,mt))}Xe&&c.applyDecay(),Ge&&c.applyPulse(d),Ze&&c.applyThresholds(d),c.applyTopologyDiff(d);const p=null!==(e=null==Ke?void 0:Ke.threshold)&&void 0!==e?e:5e3,v=Ke&&c.lastIngestTime>0&&d-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(t=null==Ke?void 0:Ke.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":vr(e,n);break;case"line":mr(e,n);break;case"ribbon":br(e,n);break;case"curved":xr(e,n)}}(s,c.sceneEdges),function(e,t){var n,r,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="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),gr(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,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="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),yr(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,r,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="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(s,c.sceneNodes),ae&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,r){var o,i;const a=null!==(o=r.spawnRate)&&void 0!==o?o:G.spawnRate,l=null!==(i=r.maxPerEdge)&&void 0!==i?i:G.maxPerEdge;for(let r=0;t.length>r;r++){const o=t[r];if(!o.bezier)continue;if(e.countForEdge(r)>=l)continue;const i=o.value*a*n*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let d=s;Math.random()<c&&d++;for(let t=0;d>t&&e.countForEdge(r)<l;t++)e.spawn(r)}}(c.particlePool,e,u,_t);const t=.5*(null!==(n=_t.speedMultiplier)&&void 0!==n?n:1);let r;if(_t.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(u,t,e,r),function(e,t,n,r,o){var i,a;const l=null!==(i=r.radius)&&void 0!==i?i:G.radius,s=null!==(a=r.opacity)&&void 0!==a?a:G.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(s),e.fillStyle=wn(e,c)||c,e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}e.globalAlpha=1}(s,c.particlePool,e,_t,gn)}}v&&(s.globalAlpha=1);const m=ut.current;if(ut.current=!1,m||f||g){const e=zt.current;e&&e.setAttribute("aria-label",Kn(null!==(o=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==o?o:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}const b=m||f||g||Ft.current;b&&d-Ht.current>=33?(Jt(e=>e+1),Ht.current=d,Ft.current=!1):Ft.current=!!b,(yn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Ft.current)&&(Mt.current=requestAnimationFrame(()=>Lt.current()))},function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:i,renderFnRef:a,cleanup:l}=e;zn(()=>{var e,o;t&&n&&(null===(o=null===(e=r.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===o||o.call(e)),i.current=!0,a.current()},[t,n]);const s=o(l);s.current=l,u(()=>()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.call(s)},[])}({hydrated:Pt,wasHydratingFromSSR:Tt,storeRef:Yt,dirtyRef:ut,renderFnRef:Lt}),u(()=>{ut.current=!0,Dt()},[P,vt,mt,Me,Dt]),function(e,t,n,r,o,i){u(()=>{if(!e)return;const a=setInterval(()=>{var a;const l=t.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(a=e.threshold)&&void 0!==a?a:5e3,d=s-l.lastIngestTime>c;d!==o&&(i(d),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r])}(Ke,Yt,ut,Dt,en,tn);const Un=Le&&Xt?e(nn,{x:Xt.x,y:Xt.y,containerWidth:vt,containerHeight:mt,margin:pt,className:"stream-network-tooltip",zIndex:2,children:De?De(Xt):e(Lr,{data:Xt})}):null;if($n||!Pt&&Tt){const n=Yt.current;if(n){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),t=e?C||(Array.isArray(O)?void 0:O):void 0;if(e&&t)n.ingestHierarchy(t,[vt,mt]),n.buildScene([vt,mt]);else{const e=Ot,t=Array.isArray(Ct)?Ct:[];(e.length>0||t.length>0)&&(n.ingestBounded(e,t,[vt,mt]),n.buildScene([vt,mt]))}}const r=null!==(p=null==n?void 0:n.sceneNodes)&&void 0!==p?p:[],o=null!==(v=null==n?void 0:n.sceneEdges)&&void 0!==v?v:[],i=null!==(m=null==n?void 0:n.labels)&&void 0!==m?m:[];return t("div",{ref:gt,className:"stream-network-frame"+(Ae?" "+Ae:""),role:"img","aria-label":Qe||("string"==typeof He?He:"Network chart"),style:{position:"relative",width:ke?"100%":yt[0],height:we?"100%":yt[1]},children:[e(sr,{summary:Je}),t("svg",{xmlns:"http://www.w3.org/2000/svg",width:yt[0],height:yt[1],style:{position:"absolute",left:0,top:0},children:[xt&&e("g",{transform:`translate(${pt.left},${pt.top})`,children:xt}),t("g",{transform:`translate(${pt.left},${pt.top})`,children:[Me&&e("rect",{x:0,y:0,width:vt,height:mt,fill:Me}),o.map((t,n)=>function(t,n){switch(t.type){case"line":return e("line",{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},"net-edge-"+n);case"bezier":{const r=t;return e("path",{d:r.pathD,fill:Bn(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},"net-edge-"+n)}case"ribbon":{const r=t;return e("path",{d:r.pathD,fill:Bn(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},"net-edge-"+n)}case"curved":{const r=t;return e("path",{d:r.pathD,fill:Bn(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity},"net-edge-"+n)}default:return null}}(t,n)).filter(Boolean),r.map((t,n)=>function(t,n){switch(t.type){case"circle":{const r=t;return e("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:Bn(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},"net-circle-"+n)}case"rect":{const r=t;return e("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:Bn(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},"net-rect-"+n)}case"arc":{const r=t,o=I().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2)(jn)||"";return e("path",{d:o,transform:`translate(${r.cx},${r.cy})`,fill:Bn(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},"net-arc-"+n)}default:return null}}(t,n)).filter(Boolean),i.map((t,n)=>function(t,n){return e("text",{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,children:t.text},"net-label-"+n)}(t,n)).filter(Boolean)]})]}),e(Wn,{width:vt,height:mt,totalWidth:yt[0],totalHeight:yt[1],margin:pt,labels:i,sceneNodes:r,title:He,legend:_e,legendPosition:We,legendLayout:je,legendHoverBehavior:Be,legendClickBehavior:$e,legendHighlightedCategory:ze,legendIsolatedCategories:Re,foregroundGraphics:jt(bt,null===(b=Yt.current)||void 0===b?void 0:b.customLayoutOverlays),annotations:Ne,svgAnnotationRules:Ie,annotationFrame:0})]})}const Qn=Yt.current;return t("div",{ref:gt,className:"stream-network-frame"+(Ae?" "+Ae:""),role:"group","aria-label":Qe||("string"==typeof He?He:"Network chart"),tabIndex:0,style:{position:"relative",width:ke?"100%":yt[0],height:we?"100%":yt[1],overflow:"visible"},onKeyDown:Vn,children:[Ue&&e(cr,{tableId:St}),Ue&&e(lr,{nodes:null!==(x=null==Qn?void 0:Qn.sceneNodes)&&void 0!==x?x:[],edges:null!==(k=null==Qn?void 0:Qn.sceneEdges)&&void 0!==k?k:[],chartType:"Network chart",tableId:St,chartTitle:"string"==typeof He?He:void 0}),e(sr,{summary:Je}),t("div",{role:"img","aria-label":Qe||("string"==typeof He?He:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Le?Zn:void 0,onMouseLeave:Le?On:void 0,onClick:Pe||Te?Nn:void 0,children:[xt&&e("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:yt[0],height:yt[1],pointerEvents:"none",overflow:"visible"},children:e("g",{transform:`translate(${pt.left},${pt.top})`,children:xt})}),e("canvas",{ref:zt,"aria-label":Kn(null!==(S=null===(w=null==Qn?void 0:Qn.sceneNodes)||void 0===w?void 0:w.length)&&void 0!==S?S:0,null!==(M=null===(A=null==Qn?void 0:Qn.sceneEdges)||void 0===A?void 0:A.length)&&void 0!==M?M:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e(dr,{hoverPoint:Xt}),e(Wn,{width:vt,height:mt,totalWidth:yt[0],totalHeight:yt[1],margin:pt,labels:(null==Qn?void 0:Qn.labels)||[],sceneNodes:null==Qn?void 0:Qn.sceneNodes,title:He,legend:_e,legendPosition:We,legendLayout:je,legendHoverBehavior:Be,legendClickBehavior:$e,legendHighlightedCategory:ze,legendIsolatedCategories:Re,foregroundGraphics:jt(bt,rn),annotations:Ne,svgAnnotationRules:Ie,annotationFrame:Qt}),e(Zt,{active:In.current>=0,hoverPoint:Xt,margin:pt,size:yt,shape:null===(L=_n.current)||void 0===L?void 0:L.shape,width:null===(D=_n.current)||void 0===D?void 0:D.w,height:null===(E=_n.current)||void 0===E?void 0:E.h}),Un,(null==Ke?void 0:Ke.showBadge)&&e("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ke.badgePosition?{top:4,left:4}:"bottom-left"===Ke.badgePosition?{bottom:4,left:4}:"bottom-right"===Ke.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:en?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:en?"STALE":"LIVE"})]})]})});function Er(e,t){const{variant:n,frameRef:r,overrides:o,deps:i}=t;g(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,r;return null!==(r=null===(n=e.current)||void 0===n?void 0:n.remove(t))&&void 0!==r?r:[]},update:(t,n)=>{var r,o;return null!==(o=null===(r=e.current)||void 0===r?void 0:r.update(t,n))&&void 0!==o?o:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==n?n:null}}}if("network"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,r,o,i,a;const l=Array.isArray(t)?t:[t],s=null!==(o=null===(r=null===(n=e.current)||void 0===n?void 0:n.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==o?o:[],c=[];for(const t of l){const n=s.find(e=>e.id===t);n&&c.push(Object.assign(Object.assign({},null!==(i=n.data)&&void 0!==i?i:{}),{id:t})),null===(a=e.current)||void 0===a||a.removeNode(t)}return c},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var r;const o=null===(r=e.current)||void 0===r?void 0:r.updateNode(t,n);return o?[Object.assign(Object.assign({},o),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n,r,o;return null!==(o=null===(r=null===(n=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==o?o:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,r;return null!==(r=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==r?r:[]},update:(t,n)=>{var r,o,i;const a=null!==(o=null===(r=e.current)||void 0===r?void 0:r.removePoint(t))&&void 0!==o?o:[];for(const t of a)null===(i=e.current)||void 0===i||i.push(n(t));return a},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]}}}const n=t;return{push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,r;return null!==(r=null===(t=n.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==r?r:[]},update:(e,t)=>{var r,o,i;const a=null!==(o=null===(r=n.current)||void 0===r?void 0:r.removeLine(e))&&void 0!==o?o:[];for(const e of a)null===(i=n.current)||void 0===i||i.pushLine(t(e));return a},clear:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getLines())&&void 0!==t?t:[]}}}(n,r);return Object.assign(Object.assign({},e),o)},null!=i?i:[])}Dr.displayName="StreamNetworkFrame";const Pr=c(null);function Tr(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Or(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Cr,Nr]=rn(e=>({selections:new Map,setClause(t,n){e(e=>{const r=new Map(e.selections),o=Or(r,t),i=new Map(o.clauses);return i.set(n.clientId,n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r)return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},setResolution(t,n){e(e=>{const r=new Map(e.selections),o=Or(r,t);return r.set(t,Object.assign(Object.assign({},o),{resolution:n})),{selections:r}})},clearSelection(t){e(e=>{const n=new Map(e.selections),r=n.get(t);return r&&n.set(t,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[Ir,_r]=rn(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let Wr={positions:new Map};const jr=new Set;function Br(){for(const e of jr)e()}function $r(e,t){const n=Wr.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Wr.positions);r.delete(e),Wr={positions:r},Br()}function zr(e){const t=y(),n=e.clientId||t,{name:r}=e,o=Nr(e=>e.selections.get(r)),a=Nr(e=>e.setClause),s=Nr(e=>e.clearClause),c=i(()=>!!o&&o.clauses.size>0,[o]);return{predicate:i(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Tr(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:l(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)};a(r,{clientId:n,type:"point",fields:t})},[n,r,a]),selectInterval:l(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r};a(r,{clientId:n,type:"interval",fields:t})},[n,r,a]),clear:l(()=>{s(r,n)},[s,r,n]),clientId:n}}const Rr=c(!1),Hr=c(null),Fr="undefined"==typeof window?u:h;function Yr(e,t,n){var r;const o=null!==(r=e.xValue)&&void 0!==r?r:null==t?void 0:t[n];if(null==o)return null;const i=Number(o);return Number.isFinite(i)?i:null}function Xr(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?Object.assign(Object.assign({},t),{xValue:e.xValue}):t||{}}function Gr(){var e;const t=gn(e=>e.theme),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function qr(e,t,n,r,o){let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=St[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function Vr({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:l="right",userMargin:s,defaults:c={top:50,bottom:60,left:70,right:40},categories:d}){const u=a(Rr),h=null!==a(Hr),f=void 0!==r?r:!u&&!!t,g=!!t&&(f||h),p=i(()=>{if(!g)return[];if(void 0!==d)return d;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[d,t,e,g]);!function(e){const t=a(Hr),n=y(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),i=o([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i.current,r)||(i.current=r);const l=i.current;Fr(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),Fr(()=>{t&&t.registerCategories(n,l)},[t,n,l])}(h&&t?p:[]);const v=i(()=>{if(!f||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){const l=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),l=a?r(a,t,n):n?n(o):Mt[i%Mt.length];return{label:o+"",color:l}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:l,label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Et,categories:p}),o=r.legendGroups.reduce((e,t)=>e+t.items.length,0);return 0!==o?r:void 0},[f,t,e,n,p]),m=i(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=t=>{const n=e[t];return"number"==typeof n?n:c[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];return v&&("right"===l&&!r("right")&&110>n.right?n.right=110:"left"===l&&!r("left")&&110>n.left?n.left=110:"top"===l&&!r("top")&&50>n.top?n.top=50:"bottom"===l&&!r("bottom")&&80>n.bottom&&(n.bottom=80)),n},[c,s,v,l]);return{legend:v,margin:m,legendPosition:l}}r.createContext(void 0);const Kr={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 Zr(e,t,n){var r,o,i,a,l,s,c;const d=Kr[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(r=t.width)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.width)?d.width:n.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.height)?d.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:d.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:d.showGrid,enableHover:null!==(l=t.enableHover)&&void 0!==l?l:!!t.linkedHover||d.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:d.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:d.showLabels,title:u?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:Ur(d.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:u}}function Ur(e,t,n){if(!1!==t)return e;const r=Object.assign({},e);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Qr(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function Jr(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function eo(e){return"function"==typeof e?e:t=>t[e]||1}function to({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,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=Et(e.data||e,t,n):e&&(l.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?l.fill=Et(e.data||e,t,n):e&&(l.fill=r(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*o);return l}}function no({componentName:n,message:r,diagnosticHint:o,width:i,height:a}){return e("div",{role:"alert",style:{width:i,height:Math.max(a,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"},children:t("div",{style:{textAlign:"center",maxWidth:400},children:[e("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:n}),e("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:r}),o&&e("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class ro extends r.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,r;null===(r=(n=this.props).onError)||void 0===r||r.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e(no,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function oo({componentName:t,width:n,height:r,children:o}){return e(ro,{fallback:o=>e(no,{componentName:t,message:o.message,width:n,height:r}),children:o})}"undefined"!=typeof process&&process;const io={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"},ao={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function lo(t){const{nodes:n,edges:r,inferNodes:o=!0,sourceAccessor:s="source",targetAccessor:c="target",colorBy:h,colorScheme:f,showLegend:g,legendPosition:p,legendInteraction:v,selection:m,linkedHover:b,onObservation:x,onClick:k,chartType:w,chartId:S,marginDefaults:A,userMargin:M,width:L,height:D,loading:E,loadingContent:P,emptyContent:T,emptyDataKey:O="edges"}=t,C=i(()=>hr(r),[r]),N=i(()=>hr(n),[n]),I=function(t,n,r,o){if(!t)return null;if(!1===o)return null;if(null!=o)return e("div",{style:{width:n,height:r,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const i=Math.min(5,Math.floor(r/40)),a=Math.max(8,Math.floor(r/(3*i))),l=Math.max(6,Math.floor(r/(2.5*i))),s=Math.floor((r-(i*(a+l)-l))/2);return e("div",{style:{width:n,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,r)=>e("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ao),{position:"absolute",top:s+r*(a+l),left:Math.floor(.1*n),width:30+(37*r+13)%50+"%",height:a,opacity:.5+r%2*.2})},r))})}(E,L,D,P),_=I?null:function(t,n,r,o){return!1===o||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e("div",{style:Object.assign(Object.assign({},io),{width:n,height:r}),children:o||"No data available"}):null}("nodes"===O?void 0===n?void 0:N:void 0===r?void 0:C,L,D,T),W=i(()=>o?Jr(N,C,s,c):N,[o,N,C,s,c]),j=function(e,t,n){const r=a(Pr),o=Gr();return i(()=>{var i;if(!t)return;const a=null!==(i=null!=n?n:o&&o.length>0?o:void 0)&&void 0!==i?i:"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(r&&Object.keys(r).length>0){const e=Pt(n.map(e=>({_cat:e})),"_cat",a);return t=>r[t]||e(t)}return Pt(n.map(e=>({_cat:e})),"_cat",a)}if(r&&Object.keys(r).length>0){const n=Pt(e,t,a);return e=>r[e]||n(e)}return Pt(e,t,a)}if(r&&Object.keys(r).length>0){const e=Pt([{_:"a"}],"_",a);return t=>r[t]||e(t)}},[e,t,n,r,o])}(W,h,f),B=Gr(),$=i(()=>{if(Array.isArray(f))return f;if(B&&B.length>0)return B;if("string"==typeof f){const e=St[f];if(Array.isArray(e)&&e.length>0)return e}return At},[f,B]),z=i(()=>{if(!h)return[];const e=new Set;for(const t of W){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[W,h]),R=function(e,t,n){const[r,o]=d(null),[a,s]=d(new Set),c=l(t=>{"highlight"===e&&o(t?t.label:null)},[e]),u=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 n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return a.has(r)}}:null},[e,t,r,a]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:c,onLegendClick:u,legendSelectionHook:h}}(v,h,z),{legend:H,margin:F,legendPosition:Y}=Vr({data:W,colorBy:h,colorScale:j,showLegend:g,legendPosition:p,userMargin:M,defaults:A,categories:z}),X=function({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:r=!1,onObservation:o,chartType:a,chartId:s,onClick:c,hoverHighlight:h,colorByField:f}){const g=y(),p=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(t,n),v=zr({name:(null==e?void 0:e.name)||"__unused__"}),m=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:a}=zr({name:t});return{onHover:l(e=>{if(!e)return void a();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&i(t)},[n,i,a,t]),predicate:r,isActive:o}}({name:(null==p?void 0:p.name)||"hover",fields:(null==p?void 0:p.fields)||n||[]}),b=_r(e=>e.pushObservation),x=e?{isActive:v.isActive,predicate:v.predicate}:null,[k,w]=d(null),S=f||n[0],A=i(()=>{if(!h||null==k||!S)return null;const e=k,t=S;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[t]?n[t]:(null!==(r=n[t])&&void 0!==r?r:"")+"")===e}}},[h,k,S]),M=l(e=>{var n,r;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const n=Yr(e,t,p.xField);null!=n&&function(e,t,n){const r=Wr.positions.get(e);(null==r?void 0:r.locked)||r&&r.xValue===t&&r.sourceId===n||(Wr={positions:new Map(Wr.positions).set(e,{xValue:t,sourceId:n})},Br())}(p.name||"hover",n,g)}"x-position"!==(null==p?void 0:p.mode)&&m.onHover(t)}else"x-position"===(null==p?void 0:p.mode)&&$r(p.name||"hover",g),"x-position"!==(null==p?void 0:p.mode)&&m.onHover(null);if(h&&S)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[S];w(null!=n?n+"":null)}else w(null);if(o||b){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const i=Xr(e),a=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(r=e.y)&&void 0!==r?r:0});o&&o(a),b&&b(a)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});o&&o(e),b&&b(e)}}},[t,m,p,g,o,a,s,b,h,S]),L=l(e=>{var t,n,r,i;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=Yr(e,t,p.xField);null!=n&&function(e,t,n){const r=Wr.positions.get(e);if(null==r?void 0:r.locked){const t=new Map(Wr.positions);return t.delete(e),Wr={positions:t},Br(),!1}Wr={positions:new Map(Wr.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Br()}(p.name||"hover",n,g)}if(e&&c){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]),c(r,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(o||b){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const n=Xr(e),a=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(i=e.y)&&void 0!==i?i:0});o&&o(a),b&&b(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});o&&o(e),b&&b(e)}}},[c,o,b,a,s,p,g]);return u(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const e=p.name||"hover";return()=>{!function(e,t){const n=Wr.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const r=new Map(Wr.positions);r.delete(e),Wr={positions:r},Br()}(e,g),$r(e,g)}},[null==p?void 0:p.mode,null==p?void 0:p.name,g]),{activeSelectionHook:x,hoverSelectionHook:A,customHoverBehavior:M,customClickBehavior:L,crosshairSourceId:g}}({selection:m,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:x,onClick:k,chartType:w,chartId:S}),{customHoverBehavior:G,customClickBehavior:q,activeSelectionHook:V,hoverSelectionHook:K,crosshairSourceId:Z}=X;return{safeNodes:W,safeEdges:C,colorScale:j,effectivePalette:$,themeCategorical:B,allCategories:z,legendState:R,legend:H,margin:F,legendPosition:Y,customHoverBehavior:G,customClickBehavior:q,activeSelectionHook:V,hoverSelectionHook:K,crosshairSourceId:Z,loadingEl:I,emptyEl:_}}function so(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const r=e(...t)||{};return Object.assign(Object.assign({},r),n)}:(...e)=>Object.assign({},n)}function co(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let a=1;r>=a;a++){const r=o[a];o[a]=e[i-1]===t[a-1]?n:1+Math.min(n,o[a],o[a-1]),n=r}}return o[r]}function uo(e,t){var n;if(0===t.length)return null;const r=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(r)||r.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let r,o=n+1;for(const n of t){const t=co(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3))&&void 0!==n?n:null)}function ho({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} 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 fo({componentName:e,nodes:t,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==n)return null;if(o&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!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 n=(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(n){const t=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=uo(o,t),i=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}const go=f(function(t,n){var r;const a=o(null);Er(n,{variant:"network",frameRef:a});const l=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:s,edges:c,margin:d,className:u,nodeIdAccessor:h,nodeIDAccessor:f,sourceAccessor:g="source",targetAccessor:y="target",nodeLabel:p,colorBy:v,colorScheme:m,nodeSize:b=8,nodeSizeRange:x=[5,20],edgeWidth:k=1,edgeColor:w="#999",edgeOpacity:S=.6,iterations:A=300,forceStrength:M=.1,tooltip:L,frameProps:D={},onObservation:E,onClick:P,chartId:T,selection:O,linkedHover:C,loading:N,loadingContent:I,emptyContent:_,legendInteraction:W,legendPosition:j,stroke:B,strokeWidth:$,opacity:z}=t,R=null!==(r=null!=h?h:f)&&void 0!==r?r:"id",{width:H,height:F,enableHover:Y,showLegend:X,showLabels:G=!1,title:q,description:V,summary:K,accessibleTable:Z}=l,U=lo({nodes:s,edges:c,inferNodes:!1,sourceAccessor:g,targetAccessor:y,colorBy:v,colorScheme:m,showLegend:X,legendPosition:j,legendInteraction:W,selection:O,linkedHover:C,onObservation:E,onClick:P,chartType:"ForceDirectedGraph",chartId:T,marginDefaults:l.marginDefaults,userMargin:d,width:H,height:F,loading:N,loadingContent:I,emptyContent:_,emptyDataKey:"nodes"}),Q=i(()=>new Map,[]),J=i(()=>e=>{const t={};return t.fill=v?Et(e.data||e,v,U.colorScale):qr(0,U.themeCategorical,m),"number"==typeof b&&(t.r=b),t},[v,U.colorScale,b,U.themeCategorical,m,Q]),ee=i(()=>so(J,{stroke:B,strokeWidth:$,opacity:z}),[J,B,$,z]),te=i(()=>e=>({stroke:w,strokeWidth:"number"==typeof k?k:"function"==typeof k?k(e):e[k]||1,opacity:S}),[k,w,S]),ne=i(()=>so(te,{stroke:B,strokeWidth:$,opacity:z}),[te,B,$,z]),re=i(()=>{if(G&&p)return"function"==typeof p?p:e=>{var t,n,r;return null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t[p])&&void 0!==n?n:e[p])&&void 0!==r?r:e.id}},[G,p]),oe=fo({componentName:"ForceDirectedGraph",nodes:s,edges:c,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:R}});return oe?e(no,{componentName:"ForceDirectedGraph",message:oe,width:H,height:F}):U.loadingEl?U.loadingEl:U.emptyEl?U.emptyEl:e(oo,{componentName:"ForceDirectedGraph",width:H,height:F,children:e(Dr,Object.assign({ref:a,chartType:"force"},null!=s&&{nodes:U.safeNodes},null!=c&&{edges:U.safeEdges},{size:[H,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,nodeIDAccessor:R,sourceAccessor:g,targetAccessor:y,iterations:A,forceStrength:M,nodeStyle:ee,edgeStyle:ne,colorBy:v,colorScheme:U.effectivePalette,nodeSize:b,nodeSizeRange:x,nodeLabel:re,showLabels:G,enableHover:Y,tooltipContent:!1===L?()=>null:tn(L)||void 0,customHoverBehavior:C||E||P?U.customHoverBehavior:void 0,customClickBehavior:E||P?U.customClickBehavior:void 0,legend:U.legend,legendPosition:U.legendPosition},W&&"none"!==W&&{legendHoverBehavior:U.legendState.onLegendHover,legendClickBehavior:U.legendState.onLegendClick,legendHighlightedCategory:U.legendState.highlightedCategory,legendIsolatedCategories:U.legendState.isolatedCategories},{className:u,title:q,description:V,summary:K,accessibleTable:Z},null!=t.animate&&{animate:t.animate},D))})});go.displayName="ForceDirectedGraph";const yo=f(function(t,n){const r=o(null);Er(n,{variant:"network",frameRef:r,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const a=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:800,height:600}),{nodes:l,edges:s,margin:c,className:d,sourceAccessor:u="source",targetAccessor:h="target",valueAccessor:f="value",nodeIdAccessor:g="id",colorBy:y,colorScheme:p,edgeColorBy:v="source",orientation:m="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:S=.5,edgeSort:A,tooltip:M,frameProps:L={},onObservation:D,onClick:E,chartId:P,selection:T,linkedHover:O,loading:C,loadingContent:N,emptyContent:I,showLegend:_,legendPosition:W,legendInteraction:j,stroke:B,strokeWidth:$,opacity:z}=t,{width:R,height:H,enableHover:F,showLabels:Y=!0,title:X,description:G,summary:q,accessibleTable:V}=a,K=lo({nodes:l,edges:s,inferNodes:!0,sourceAccessor:u,targetAccessor:h,colorBy:y,colorScheme:p,showLegend:_,legendPosition:W,legendInteraction:j,selection:T,linkedHover:O,onObservation:D,onClick:E,chartType:"SankeyDiagram",chartId:P,marginDefaults:a.marginDefaults,userMargin:c,width:R,height:H,loading:C,loadingContent:N,emptyContent:I}),Z=i(()=>new Map,[]),U=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?Et(e.data||e,y,K.colorScale):qr(0,K.themeCategorical,p),t},[y,K.colorScale,K.themeCategorical,p,Z]),Q=i(()=>so(U,{stroke:B,strokeWidth:$,opacity:z}),[U,B,$,z]),J=i(()=>to({edgeColorBy:v,colorBy:y,colorScale:K.colorScale,nodeStyleFn:Q,edgeOpacity:S,baseStyle:{stroke:"none",strokeWidth:0}}),[v,y,K.colorScale,Q,S]),ee=i(()=>so(J,{stroke:B,strokeWidth:$,opacity:z}),[J,B,$,z]),te=i(()=>{if(!Y)return;const e=w||g;return"function"==typeof e?e:t=>{var n,r,o;return null!==(o=null!==(r=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==r?r:t[e])&&void 0!==o?o:t.id}},[Y,w,g]),ne=fo({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ne?e(no,{componentName:"SankeyDiagram",message:ne,width:R,height:H}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e(oo,{componentName:"SankeyDiagram",width:R,height:H,children:e(Dr,Object.assign({ref:r,chartType:"sankey"},K.safeNodes.length>0&&{nodes:K.safeNodes},null!=s&&{edges:K.safeEdges},{size:[R,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:h,valueAccessor:f,orientation:m,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:Q,edgeStyle:ee,colorBy:y,colorScheme:K.effectivePalette,edgeColorBy:v,edgeOpacity:S,edgeSort:A,nodeLabel:te,showLabels:Y,enableHover:F,tooltipContent:!1===M?()=>null:tn(M)||void 0,customHoverBehavior:O||D||E?K.customHoverBehavior:void 0,customClickBehavior:D||E?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},j&&"none"!==j&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:d,title:X,description:G,summary:q,accessibleTable:V},null!=t.animate&&{animate:t.animate},L))})});yo.displayName="SankeyDiagram";const po=f(function(t,n){const r=o(null);Er(n,{variant:"network",frameRef:r,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const a=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:l,edges:s,margin:c,className:d,sourceAccessor:u="source",targetAccessor:h="target",valueAccessor:f="value",nodeIdAccessor:g="id",colorBy:y,colorScheme:p,edgeColorBy:v="source",padAngle:m=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:S,frameProps:A={},onObservation:M,onClick:L,chartId:D,selection:E,linkedHover:P,loading:T,loadingContent:O,emptyContent:C,legendInteraction:N,stroke:I,strokeWidth:_,opacity:W}=t,{width:j,height:B,enableHover:$,showLabels:z=!0,title:R,description:H,summary:F,accessibleTable:Y}=a,X=lo({nodes:l,edges:s,inferNodes:!0,sourceAccessor:u,targetAccessor:h,colorBy:y,colorScheme:p,showLegend:!1,legendInteraction:N,selection:E,linkedHover:P,onObservation:M,onClick:L,chartType:"ChordDiagram",chartId:D,marginDefaults:a.marginDefaults,userMargin:c,width:j,height:B,loading:T,loadingContent:O,emptyContent:C}),G=i(()=>new Map,[]),q=X.safeNodes.length>0,V=i(()=>{if(q)return(e,t)=>{var n,r;const o={stroke:"black",strokeWidth:1};if(y)o.fill=Et(e.data||e,y,X.colorScale);else{const i=Array.isArray(p)?p:St[p]||At,a=Array.isArray(i)?i:At,l=null!==(r=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==r?r:0;o.fill=a[l%a.length]}return o}},[q,y,X.colorScale,p]),K=i(()=>V?so(V,{stroke:I,strokeWidth:_,opacity:W}):void 0,[V,I,_,W]),Z=i(()=>{if(q)return to({edgeColorBy:v,colorBy:y,colorScale:X.colorScale,nodeStyleFn:K||(e=>({fill:qr(0,X.themeCategorical,p)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[q,v,y,X.colorScale,K,w,X.themeCategorical,p,G]),U=i(()=>Z?so(Z,{stroke:I,strokeWidth:_,opacity:W}):void 0,[Z,I,_,W]),Q=i(()=>{if(!z)return;const e=k||g;return"function"==typeof e?e:t=>{var n,r,o;return null!==(o=null!==(r=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==r?r:t[e])&&void 0!==o?o:t.id}},[z,k,g]),J=fo({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return J?e(no,{componentName:"ChordDiagram",message:J,width:j,height:B}):X.loadingEl?X.loadingEl:X.emptyEl?X.emptyEl:e(oo,{componentName:"ChordDiagram",width:j,height:B,children:e(Dr,Object.assign({ref:r,chartType:"chord"},X.safeNodes.length>0&&{nodes:X.safeNodes},null!=s&&{edges:X.safeEdges},{size:[j,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:h,valueAccessor:f,padAngle:m,groupWidth:b,sortGroups:x,nodeStyle:K,edgeStyle:U,colorBy:y,colorScheme:X.effectivePalette,edgeColorBy:v,edgeOpacity:w,nodeLabel:Q,showLabels:z,enableHover:$,tooltipContent:!1===S?()=>null:tn(S)||void 0,customHoverBehavior:P||M||L?X.customHoverBehavior:void 0,customClickBehavior:M||L?X.customClickBehavior:void 0},N&&"none"!==N&&{legendHoverBehavior:X.legendState.onLegendHover,legendClickBehavior:X.legendState.onLegendClick,legendHighlightedCategory:X.legendState.highlightedCategory,legendIsolatedCategories:X.legendState.isolatedCategories},{className:d,title:R,description:H,summary:F,accessibleTable:Y},null!=t.animate&&{animate:t.animate},A))})});function vo(t){const n=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:o,className:a,layout:l="tree",orientation:s="vertical",childrenAccessor:c="children",valueAccessor:d="value",nodeIdAccessor:u="name",colorBy:h,colorScheme:f,colorByDepth:g=!1,edgeStyle:y="curve",nodeLabel:p,nodeSize:v=5,tooltip:m,frameProps:b={},onObservation:x,onClick:k,chartId:w,selection:S,linkedHover:A,loading:M,loadingContent:L,legendInteraction:D,stroke:E,strokeWidth:P,opacity:T}=t,{width:O,height:C,enableHover:N,showLabels:I=!0,title:_,description:W,summary:j,accessibleTable:B}=n,$=lo({nodes:i(()=>Qr(null!=r?r:null,c),[r,c]),edges:void 0,inferNodes:!1,colorBy:g?void 0:h,colorScheme:f,showLegend:!1,legendInteraction:D,selection:S,linkedHover:A,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:n.marginDefaults,userMargin:o,width:O,height:C,loading:M,loadingContent:L}),z=i(()=>new Map,[]),R=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Lt[(e.depth||0)%Lt.length]:h?Et(e.data||e,h,$.colorScale):qr(0,$.themeCategorical,f),t},[h,g,$.colorScale,$.themeCategorical,f,z]),H=i(()=>so(R,{stroke:E,strokeWidth:P,opacity:T}),[R,E,P,T]),F=i(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),Y=i(()=>so(F,{stroke:E,strokeWidth:P,opacity:T}),[F,E,P,T]),X=i(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return eo(d)},[l,d]),G=ho({componentName:"TreeDiagram",data:r});return G?e(no,{componentName:"TreeDiagram",message:G,width:O,height:C}):$.loadingEl?$.loadingEl:e(oo,{componentName:"TreeDiagram",width:O,height:C,children:e(Dr,Object.assign({chartType:l},null!=r&&{data:r},{size:[O,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$.margin,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:X,treeOrientation:s,edgeType:y,nodeStyle:H,edgeStyle:Y,colorBy:h,colorScheme:$.effectivePalette,colorByDepth:g,nodeSize:v,nodeLabel:I?p||u:void 0,showLabels:I,enableHover:N,tooltipContent:!1===m?()=>null:tn(m)||void 0,customHoverBehavior:A||x||k?$.customHoverBehavior:void 0,customClickBehavior:x||k?$.customClickBehavior:void 0},D&&"none"!==D&&{legendHoverBehavior:$.legendState.onLegendHover,legendClickBehavior:$.legendState.onLegendClick,legendHighlightedCategory:$.legendState.highlightedCategory,legendIsolatedCategories:$.legendState.isolatedCategories},{className:a,title:_,description:W,summary:j,accessibleTable:B},null!=t.animate&&{animate:t.animate},b))})}function mo(t){const n=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover},{width:600,height:600}),{data:r,margin:o,className:a,childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:d="name",colorBy:u,colorScheme:h,colorByDepth:f=!1,labelMode:g="leaf",nodeLabel:y,padding:p=4,paddingTop:v,nodeStyle:m,tooltip:b,frameProps:x={},selection:k,linkedHover:w,onObservation:S,onClick:A,chartId:M,loading:L,loadingContent:D,legendInteraction:E,stroke:P,strokeWidth:T,opacity:O}=t,{nodeStyle:C}=x,N=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);r.length>o;o++)0>t.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(x,["nodeStyle"]),{width:I,height:_,enableHover:W,showLabels:j=!0,title:B,description:$,summary:z,accessibleTable:R}=n,H=lo({nodes:i(()=>Qr(null!=r?r:null,s),[r,s]),edges:void 0,inferNodes:!1,colorBy:f?void 0:u,colorScheme:h,showLegend:!1,legendInteraction:E,selection:k,linkedHover:w,onObservation:S,onClick:A,chartType:"Treemap",chartId:M,marginDefaults:n.marginDefaults,userMargin:o,width:I,height:_,loading:L,loadingContent:D}),F=function(e){const t=gn(e=>e.theme.colors.selectionOpacity);return i(()=>{var n,r;if(void 0!==e||void 0!==t)return Object.assign(Object.assign({name:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:""},e),{unselectedOpacity:null!==(r=null==e?void 0:e.unselectedOpacity)&&void 0!==r?r:t})},[e,t])}(k),Y=H.customHoverBehavior,X=l(e=>{if(!e)return Y(null);const t=e.data||e;Y({data:(null==t?void 0:t.data)||t})},[Y]),G=i(()=>new Map,[]),q=i(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=f?Lt[(e.depth||0)%Lt.length]:u?Et(e.data||e,u,H.colorScale):qr(0,H.themeCategorical,h),t},[u,f,H.colorScale,H.themeCategorical,h,G]),V=i(()=>m||C?e=>{var t,n;return Object.assign(Object.assign(Object.assign({},q(e)),C&&null!==(t=C(e))&&void 0!==t?t:{}),m&&null!==(n=m(e))&&void 0!==n?n:{})}:q,[q,m,C]),K=i(()=>so(V,{stroke:P,strokeWidth:T,opacity:O}),[V,P,T,O]),Z=i(()=>H.activeSelectionHook?e=>{var t;const n=Object.assign({},K(e));if(H.activeSelectionHook.isActive)if(H.activeSelectionHook.predicate(e.data||e))(null==F?void 0:F.selectedStyle)&&Object.assign(n,F.selectedStyle);else{const e=null!==(t=null==F?void 0:F.unselectedOpacity)&&void 0!==t?t:.5;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==F?void 0:F.unselectedStyle)&&Object.assign(n,F.unselectedStyle)}return n}:K,[K,H.activeSelectionHook,F]),U=i(()=>eo(c),[c]),Q=void 0!==v?v:!j||"parent"!==g&&"all"!==g?void 0:18,J=ho({componentName:"Treemap",data:r});return J?e(no,{componentName:"Treemap",message:J,width:I,height:_}):H.loadingEl?H.loadingEl:e(oo,{componentName:"Treemap",width:I,height:_,children:e(Dr,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[I,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H.margin,nodeIDAccessor:d,childrenAccessor:s,hierarchySum:U,padding:p,paddingTop:Q,nodeStyle:Z,colorBy:u,colorScheme:H.effectivePalette,colorByDepth:f,nodeLabel:j?y||d:void 0,showLabels:j,labelMode:g,enableHover:W,tooltipContent:!1===b?()=>null:tn(b)||void 0},(w||S||A)&&{customHoverBehavior:X},(S||A)&&{customClickBehavior:H.customClickBehavior},E&&"none"!==E&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:a,title:B,description:$,summary:z,accessibleTable:R},null!=t.animate&&{animate:t.animate},N))})}function bo(t){const n=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:o,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:u,colorByDepth:h=!1,nodeLabel:f,circleOpacity:g=.7,padding:y=4,tooltip:p,frameProps:v={},onObservation:m,onClick:b,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:A,legendInteraction:M,stroke:L,strokeWidth:D,opacity:E}=t,{width:P,height:T,enableHover:O,showLabels:C=!0,title:N,description:I,summary:_,accessibleTable:W}=n,j=lo({nodes:i(()=>Qr(null!=r?r:null,l),[r,l]),edges:void 0,inferNodes:!1,colorBy:h?void 0:d,colorScheme:u,showLegend:!1,legendInteraction:M,selection:k,linkedHover:w,onObservation:m,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:n.marginDefaults,userMargin:o,width:P,height:T,loading:S,loadingContent:A}),B=i(()=>new Map,[]),$=i(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?Lt[(e.depth||0)%Lt.length]:d?Et(e.data||e,d,j.colorScale):qr(0,j.themeCategorical,u),t},[d,h,j.colorScale,g,j.themeCategorical,u,B]),z=i(()=>so($,{stroke:L,strokeWidth:D,opacity:E}),[$,L,D,E]),R=i(()=>eo(s),[s]),H=ho({componentName:"CirclePack",data:r});return H?e(no,{componentName:"CirclePack",message:H,width:P,height:T}):j.loadingEl?j.loadingEl:e(oo,{componentName:"CirclePack",width:P,height:T,children:e(Dr,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[P,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:j.margin,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:R,padding:y,nodeStyle:z,colorBy:d,colorScheme:j.effectivePalette,colorByDepth:h,nodeLabel:C?f||c:void 0,showLabels:C,enableHover:O,tooltipContent:!1===p?()=>null:tn(p)||void 0,customHoverBehavior:w||m||b?j.customHoverBehavior:void 0,customClickBehavior:m||b?j.customClickBehavior:void 0},M&&"none"!==M&&{legendHoverBehavior:j.legendState.onLegendHover,legendClickBehavior:j.legendState.onLegendClick,legendHighlightedCategory:j.legendState.highlightedCategory,legendIsolatedCategories:j.legendState.isolatedCategories},{className:a,title:N,description:I,summary:_,accessibleTable:W},null!=t.animate&&{animate:t.animate},v))})}po.displayName="ChordDiagram",vo.displayName="TreeDiagram","function"==typeof SuppressedError&&SuppressedError,mo.displayName="Treemap",bo.displayName="CirclePack";const xo=Lt;function ko(t){const n=Zr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:o,className:a,childrenAccessor:l="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:d,colorByDepth:u=!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:S,annotations:A,frameProps:M={},onObservation:L,onClick:D,chartId:E,selection:P,linkedHover:T,loading:O,loadingContent:C,stroke:N,strokeWidth:I,opacity:_}=t,{width:W,height:j,enableHover:B,title:$,description:z,summary:R,accessibleTable:H}=n,F=lo({nodes:i(()=>Qr(r,l),[r,l]),edges:void 0,inferNodes:!1,colorBy:u?void 0:c,colorScheme:d,showLegend:!1,legendInteraction:void 0,selection:P,linkedHover:T,onObservation:L,onClick:D,chartType:"OrbitDiagram",chartId:E,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:o,width:W,height:j,loading:O,loadingContent:C}),Y=i(()=>new Map,[]),X=i(()=>{if(Array.isArray(d))return d;const e=St[d];return Array.isArray(e)?e:At},[d]),G=i(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},r=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=u?r?X[0]:xo[(e.depth||0)%xo.length]:c?Et(e.data||e,c,F.colorScale):qr(0,F.themeCategorical,d),n.opacity=r?1:.85,n},[c,u,F.colorScale,X,F.themeCategorical,d,Y]),q=i(()=>so(G,{stroke:N,strokeWidth:I,opacity:_}),[G,N,I,_]),V=i(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),K=i(()=>{if(F.customHoverBehavior)return e=>{F.customHoverBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[F.customHoverBehavior]),Z=i(()=>{if(F.customClickBehavior)return e=>{F.customClickBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[F.customClickBehavior]),U=ho({componentName:"OrbitDiagram",data:r});return U?e(no,{componentName:"OrbitDiagram",message:U,width:W,height:j}):F.loadingEl?F.loadingEl:e(oo,{componentName:"OrbitDiagram",width:W,height:j,children:e(Dr,Object.assign({chartType:"orbit"},null!=r&&{data:r},{size:[W,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F.margin,nodeIDAccessor:s,childrenAccessor:l,nodeStyle:q,edgeStyle:V,colorBy:c,colorScheme:F.effectivePalette,colorByDepth:u,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&B,tooltipContent:k?void 0:!1===w?()=>null:tn(w)||void 0,customHoverBehavior:T||L||D?K:void 0,customClickBehavior:L||D?Z:void 0,foregroundGraphics:S,annotations:A,className:a,title:$,description:z,summary:R,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k,accessibleTable:H},null!=t.animate&&{animate:t.animate},M))})}function wo(e,t,n){const r=[],o=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,a=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&a&&a&&n[1]>=n[0]||r.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)o.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),o.has(e.target)||r.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||r.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||r.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}function So(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function Ao(e,t,n){const r=t.incoming[e.id],o=t.outgoing[e.id],i=[];for(const e of r)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of o)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const a={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{i.sort((e,t)=>{var n,r;return e.time-t.time||(null!==(n=a[e.kind])&&void 0!==n?n:99)-(null!==(r=a[t.kind])&&void 0!==r?r:99)})},s=i.length?Math.min(...i.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,d=null!=c?c-1:null!=s&&Number.isFinite(s)?s-1:null,u=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;u.length>e;e++)h.set(u[e],u[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=d?d:e};l();const g=[];let y=0,p=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:p);if(n>0){const t="top"===e.side?"bot":"top",r=Math.min(n,"top"===t?y:p);if(r>0){const o=f(e.time);g.push({time:o,delta:-r,kind:"transfer-out",side:t}),g.push({time:o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?y-=r:p-=r,"top"===e.side?y+=r:p+=r,n-=r}n>0&&null!==d&&(g.push({time:d,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:p+=n)}"top"===e.side?y-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:p+=t}i.push(...g),l();let v=0,m=0,b=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:v,botMass:m}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:m;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?v+=e.delta:m+=e.delta,v+m>b&&(b=v+m),v>x&&(x=v),m>k&&(k=m),w.push({t:e.time,topMass:v,botMass:m})}const A=[];let M=0;for(;w.length>M;){let e=M;for(;w.length>e+1&&w[e+1].t===w[M].t;)e++;A.push(w[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||A.push(w[t])}M=e+1}const L=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let D=null;for(const e of o)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===D||D>e.systemInTime)&&(D=e.systemInTime);let E=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===E||e.systemOutTime>E)&&(E=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=L?L:-1/0,null!=E?E:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],r=Math.min(null!=c?c:1/0,null!=D?D:1/0);Number.isFinite(r)&&n.t>r&&n.topMass+n.botMass>0&&A.unshift({t:r,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:x,botPeak:k,localAttachments:S}}function Mo(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Lo(e,t){return e.map(e=>({t:Mo(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Do(e,t,n){const r=e.value*n;if("out"===e.kind){const o=e.sideMassBefore*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}const o=e.sideMassAfter*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}function Eo(e,t){let n=0;for(let r=0;t.length>r;r++)for(let o=r+1;t.length>o;o++){const i=t[r],a=t[o];i.source!==a.source&&i.target!==a.target&&i.source!==a.target&&i.target!==a.source&&(Math.min(i.endTime,a.endTime)>Math.max(i.startTime,a.startTime)&&e[a.source]>e[i.source]!=e[a.target]>e[i.target]&&n++)}return n}function Po(e,t){let n=0;for(const r of t)n+=Math.abs(e[r.source]-e[r.target])*(r.value||1);return n}function To(e,t){return 1e3*Eo(e,t)+Po(e,t)}function Oo(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function Co(e,t,n){e.length>8||n.length>40?(function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=Oo(e,t),a=To(t,n);for(let l=0;r>l;l++){const r=Array(o).fill(0),l=Array(o).fill(0);for(const e of n){const n=t[e.source],o=t[e.target];r[n]+=o*(e.value||1),l[n]+=e.value||1,r[o]+=n*(e.value||1),l[o]+=e.value||1}const s=Array.from({length:o},(e,t)=>t).sort((e,t)=>(l[e]>0?r[e]/l[e]:e)-(l[t]>0?r[t]/l[t]:t)),c=s.map(t=>e[t]),d=new Map;s.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t);const u=To(t,n);if(a>u)a=u,i=Oo(e,t);else if(u===a)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=To(t,n);for(let a=0;r>a;a++){let r=!1;for(let a=0;o-1>a;a++){const o=e[a];e[a]=e[a+1],e[a+1]=o;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const l=To(t,n);if(i>l)i=l,r=!0;else{const n=e[a];e[a]=e[a+1],e[a+1]=n;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a)}}if(!r)break}}(e,t,n,6)):function(e,t,n){const r=e.length;if(1>=r)return;const o=Object.assign({},t),i=Object.keys(o),a=Array.from({length:r},(e,t)=>t),l=a.slice(),s=Object.assign({},o);let c=a.slice(),d=1/0;const u=()=>{for(const e of i)s[e]=l[o[e]];const e=To(s,n);d>e&&(d=e,c=a.slice())},h=(e,t)=>{const n=a[e],r=a[t];a[e]=r,a[t]=n,l[n]=t,l[r]=e};u();const f=Array(r).fill(0);let g=0;for(;r>g;)g>f[g]?(h(g%2==0?0:f[g],g),u(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function No(e,t,n,r,o){var i,a,l,s,c,d,u,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:v,lifetimeMode:m="full"}=o,b={},x={};for(const t of e)b[t.id]=n[t.id].topPeak||0,x[t.id]=n[t.id].botPeak||0;const k="half"===m,w={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=k?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=k?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}w[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(i)?i:null}}const S={},A=[];if("reuse"===p){const n=new Map;for(const t of e)n.set(t.id,0);const o=new Map;for(const t of e)o.set(t.id,0);for(const e of t)o.set(e.target,(null!==(i=o.get(e.target))&&void 0!==i?i:0)+1);const u=[];for(const t of e)0===(null!==(a=o.get(t.id))&&void 0!==a?a:0)&&u.push(t.id);for(;u.length;){const e=u.shift();for(const t of null!==(l=r.outgoing[e])&&void 0!==l?l:[]){const r=(null!==(s=n.get(e))&&void 0!==s?s:0)+1;r>(null!==(c=n.get(t.target))&&void 0!==c?c:0)&&n.set(t.target,r),o.set(t.target,o.get(t.target)-1),0===o.get(t.target)&&u.push(t.target)}}const h=[...e].filter(e=>null!==w[e.id].start).sort((e,t)=>{var r,o;const i=null!==(r=n.get(e.id))&&void 0!==r?r:0,a=null!==(o=n.get(t.id))&&void 0!==o?o:0;return i!==a?i-a:w[e.id].start-w[t.id].start}),f=e.filter(e=>null===w[e.id].start);for(const e of[...h,...f]){const t=w[e.id];let n=-1;for(let e=0;A.length>e;e++){const r=A[e].occupants[A[e].occupants.length-1];if(null===t.start||void 0===r||t.start>=r.end){n=e;break}}-1===n&&(A.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=A.length-1),A[n].occupants.push({id:e.id,end:null!==(d=null==t?void 0:t.end)&&void 0!==d?d:-1/0}),A[n].peak.topPeak=Math.max(A[n].peak.topPeak,b[e.id]),A[n].peak.botPeak=Math.max(A[n].peak.botPeak,x[e.id]),S[e.id]=n}}else e.forEach((e,t)=>{var n,r;A.push({occupants:[{id:e.id,end:null!==(r=null===(n=w[e.id])||void 0===n?void 0:n.end)&&void 0!==r?r:-1/0}],peak:{topPeak:b[e.id],botPeak:x[e.id]}}),S[e.id]=t});let M=null,L=null,D=null,E=null;const P=()=>{M=Eo(S,t),D=Po(S,t)},T=()=>{L=Eo(S,t),E=Po(S,t)};"crossing-min"===v?(P(),Co(A,S,t),T()):"inside-out"===v?(P(),function(e,t){const n=e.length;if(1>=n)return;const r=e=>e.peak.topPeak+e.peak.botPeak,o=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>r(t.slot)-r(e.slot)),i=Array(n),a=Math.floor((n-1)/2);i[a]=o[0].idx;let l=a-1,s=a+1;for(let e=1;o.length>e;e++)e%2==1&&n>s||0>l?i[s++]=o[e].idx:i[l--]=o[e].idx;const c=i.map(t=>e[t]),d=new Map;i.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t)}(A,S),T()):"crossing-min+inside-out"===v&&(P(),Co(A,S,t),function(e,t,n){const r=e.length;if(1>=r)return;const o=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((r-1)/2);let a=To(t,n);for(const{slot:l}of o){const o=e.indexOf(l);if(0>o)continue;const s=i;if(o===s)continue;const c=e[o];e.splice(o,1),e.splice(s,0,c);const d=new Map;for(let e=0;r>e;e++)d.set(e,e);if(s>o){for(let e=o+1;s>=e;e++)d.set(e,e-1);d.set(o,s)}else{for(let e=s;o>e;e++)d.set(e,e+1);d.set(o,s)}for(const e of Object.keys(t))t[e]=d.get(t[e]);const u=To(t,n);if(u>a){const n=e[s];e.splice(s,1),e.splice(o,0,n);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(o>s){for(let e=s+1;o>=e;e++)i.set(e,e-1);i.set(s,o)}else{for(let e=o;s>e;e++)i.set(e,e+1);i.set(s,o)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=u}}(A,S,t),T());const O=A.map(e=>{const t=new Map;for(const r of e.occupants){const e=n[r.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),C=(e,t)=>{let n={top:0,bot:0};for(const[r,o]of e){if(r>t)break;n=o}return n},N=[];for(let e=0;A.length-1>e;e++){const t=O[e],n=O[e+1],r=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let o=0;for(const e of r){const r=C(t,e),i=C(n,e);r.bot+i.top>o&&(o=r.bot+i.top)}N.push(o)}const I=[];let _=g+(null!==(h=null===(u=A[0])||void 0===u?void 0:u.peak.topPeak)&&void 0!==h?h:0)*y;A.length>0&&I.push(_);for(let e=1;A.length>e;e++)_+=N[e-1]*y+g,I.push(_);if(A.length>0&&(_+=A[A.length-1].peak.botPeak*y+g),_>f){const e=f/_;for(let t=0;I.length>t;t++)I[t]*=e}const W=0===A.length?0:A[0].peak.topPeak+N.reduce((e,t)=>e+t,0)+A[A.length-1].peak.botPeak,j={};for(const t of e)j[t.id]=I[S[t.id]];return{effectiveSlotsHeight:W,centerlines:j,laneLifetime:w,slots:A,slotByNode:S,slotCenter:I,crossingsBefore:M,crossingsAfter:L,lengthBefore:D,lengthAfter:E}}ko.displayName="OrbitDiagram";const Io=e=>{var t,n;const{bands:r=[],ribbons:o=[],showLabels:i=!0}=e.config,a=[];for(const e of o)a.push(Object.assign(Object.assign({type:"bezier",pathD:e.pathD},e.bezier&&{bezierCache:e.bezier}),{style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}}));for(const e of r)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];a.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of r)a.push({type:"bezier",pathD:e.pathD,style:Object.assign(Object.assign({},e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86}),{stroke:null!==(t=e.stroke)&&void 0!==t?t:e.fill,strokeWidth:null!==(n=e.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const l=i?r.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:r.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:l}};function _o(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function Wo(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function jo(e,t){return"function"==typeof e?e(t):t[e]}const Bo=f(function(r,a){const{nodes:s,edges:c,domain:u,axisTicks:h=[],nodeIdAccessor:f="id",sourceAccessor:g="source",targetAccessor:y="target",valueAccessor:p="value",startTimeAccessor:v="startTime",endTimeAccessor:m="endTime",systemInTimeAccessor:b,systemOutTimeAccessor:x,xExtentAccessor:k="xExtent",edgeIdAccessor:w="id",colorBy:S,colorScheme:A,showLegend:M,legendPosition:L="right",pairing:D="temporal",packing:E="reuse",laneOrder:P="crossing-min",ribbonLane:T="both",lifetimeMode:C="half",showLaneRails:N=!1,showQualityReadout:I=!1,showLabels:_=!0,width:W=600,height:j=400,margin:B,title:$,description:z,summary:R,accessibleTable:H,responsiveWidth:F,responsiveHeight:Y,loading:X,loadingContent:G,emptyContent:q,edgeOpacity:V=.35,timeFormat:K,valueFormat:Z,tooltip:U,enableHover:Q=!0,onObservation:J,onClick:ee,showParticles:te=!1,particleStyle:ne,chartId:re,frameProps:oe={}}=r,[ie,ae]=d([]),[le,se]=d([]),ce=o(ie),de=o(le);ce.current=ie,de.current=le;const ue=l(e=>{ce.current=e,ae(e)},[]),he=l(e=>{de.current=e,se(e)},[]),fe=void 0!==c,ge=hr(fe?c:ie),ye=i(()=>{const e=hr(null!=s?s:[]),t=le;if(0===e.length&&0===t.length)return Jr([],ge,g,y);const n=new Set,r=[];for(const t of e){const e=jo(f,t)+"";n.has(e)||(n.add(e),r.push(t))}for(const e of t){const t=jo(f,e)+"";n.has(t)||(n.add(t),r.push(e))}const o=Jr([],ge,g,y);for(const e of o)n.has(e.id)||(n.add(e.id),r.push(e));return r},[s,le,ge,f,g,y]),pe=o(null),ve=l((e,t)=>{const n=jo(w,e);return null!=n?n+"":`${jo(g,e)}-${jo(y,e)}-${t}`},[w,g,y]),me=l(e=>{if(null==e)return!1;const t=e;return null!=jo(g,t)&&null!=jo(y,t)},[g,y]);Er(a,{variant:"network",frameRef:pe,overrides:{push(e){if(me(e)){if(fe)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ue([...ce.current,e])}else he([...de.current,e])},pushMany(e){const t=[],n=[];for(const r of e)me(r)?t.push(r):n.push(r);t.length>0&&(fe?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ue([...ce.current,...t])),n.length>0&&he([...de.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!fe){const e=ce.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(ve(i,o))?n.push(i):r.push(i)}r.length!==e.length&&ue(r)}const r=de.current,o=[];for(const e of r){const r=jo(f,e)+"";t.has(r)?n.push(e):o.push(e)}return o.length!==r.length&&he(o),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!fe){let e=!1;const o=ce.current.map((o,i)=>n.has(ve(o,i))?(r.push(o),e=!0,t(o)):o);e&&ue(o)}let o=!1;const i=de.current.map(e=>{const i=jo(f,e)+"";return n.has(i)?(r.push(e),o=!0,t(e)):e});return o&&he(i),r},clear(){var e;fe||ue([]),he([]),null===(e=pe.current)||void 0===e||e.clear()},getData:()=>null!=ge?ge:[],getScales:()=>null},deps:[fe,me,ve,f,ge,ue,he]});const be=ve,xe=l(e=>jo(f,e)+"",[f]),{nodes:ke,edges:we,domain:Se,rawNodeById:Ae,rawEdgeById:Me}=i(()=>{const e=(null!=ye?ye:[]).map(e=>{const t={id:xe(e),__raw:e},n=k?jo(k,e):null;if(Array.isArray(n)&&2===n.length){const e=Wo(n[0]),r=Wo(n[1]);Number.isFinite(e)&&Number.isFinite(r)&&(t.xExtent=[e,r])}return t}),t=(null!=ge?ge:[]).map((e,t)=>{const n={id:be(e,t),source:jo(g,e)+"",target:jo(y,e)+"",value:Number(jo(p,e)),startTime:Wo(jo(v,e)),endTime:Wo(jo(m,e)),__raw:e};if(b){const t=Wo(jo(b,e));Number.isFinite(t)&&(n.systemInTime=t)}if(x){const t=Wo(jo(x,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Wo(u[0]),Wo(u[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const o=new Map;for(const e of t)null!=e.__raw&&o.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:r,rawEdgeById:o}},[ye,ge,u,xe,be,k,g,y,p,v,m,b,x]),Le=lo({nodes:ye,edges:ge,inferNodes:!1,sourceAccessor:g,targetAccessor:y,colorBy:S,colorScheme:A,showLegend:!1,legendPosition:L,selection:void 0,linkedHover:void 0,onObservation:J,onClick:ee,chartType:"ProcessSankey",chartId:re,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:B,width:W,height:j,loading:X,loadingContent:G,emptyContent:q}),De=(null!=M?M:!!S)&&!!S,Ee=l(e=>null!=B&&("number"==typeof B||null!=B[e]),[B]),Pe=i(()=>{const e=Object.assign({},Le.margin);return De&&("right"===L&&!Ee("right")&&140>e.right?e.right=140:"bottom"===L&&!Ee("bottom")&&80>e.bottom&&(e.bottom=80)),e},[Le.margin,De,L,Ee]),Te=W-Pe.left-Pe.right,Oe=j-Pe.top-Pe.bottom,Ce=i(()=>wo(ke,we,Se),[ke,we,Se]),Ne=i(()=>Ce.length>0?null:function(e,t,n){var r;const{plotH:o,pairing:i="temporal",packing:a="reuse",laneOrder:l="crossing-min",lifetimeMode:s="half"}=n,c=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),d=function(e,t,n,r="value"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===r?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,a=new Map;for(const e of t)a.set(e.id,{});const l=(e,t)=>{const n=new Map;for(const r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const a=[...n.values()];a.sort("temporal"===r?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:o);return a};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.length)l(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)l(r,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=l(r,"source"),n=l(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,c,i);let u={};for(const t of e)u[t.id]=Ao(t,c,d);const h=No(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:a,laneOrder:l,lifetimeMode:s}),f=new Set;for(const e of t){const t=h.slotByNode[e.source],n=h.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=d.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(f.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],r=new Set(e.map(e=>d.get(e.id).sourceSide)),o=new Set(n.map(e=>d.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)h.slotByNode[t.source]===h.slotByNode[t.target]&&(d.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)h.slotByNode[n.source]===h.slotByNode[n.target]&&(d.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const r=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===d.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===d.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},o=(e,t)=>{const o=r(),i="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,a="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=i||0>=a)return!1;const l=Math.min(i,a),s=n.filter(t=>!f.has(t.id)&&d.get(t.id).sourceSide===e&&l>=t.value).sort((e,t)=>t.value-e.value);return 0!==s.length&&(d.get(s[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(o("top","bot")||o("bot","top")););}u={};for(const t of e)u[t.id]=Ao(t,c,d);const g=No(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:a,laneOrder:l,lifetimeMode:s}),y=null!==(r=g.effectiveSlotsHeight)&&void 0!==r?r:g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),p=Math.min(12,.35*o/Math.max(g.slots.length+1,1)),v=y>0?Math.max(0,(o-p*(g.slots.length+1))/y):1,m=No(e,t,u,c,{plotH:o,padding:p,valueScale:v,packing:a,laneOrder:l,lifetimeMode:s});return{nodeData:u,sides:d,valueScale:v,padding:p,compressedPadding:12>p,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(ke,we,{plotH:Oe,pairing:D,packing:E,laneOrder:P,lifetimeMode:C}),[Ce,ke,we,Oe,D,E,P,C]),Ie=i(()=>O().domain(Se).range([0,Te]),[Se,Te]),_e=l((e,t)=>{if(S&&ye){const t=Ae.get(e);if(t)return Et(t,S,Le.colorScale)}return Le.effectivePalette[t%Le.effectivePalette.length]||"#475569"},[S,ye,Ae,Le.colorScale,Le.effectivePalette]),We=i(()=>{const e=new Map;return ke.forEach((t,n)=>e.set(t.id,n)),e},[ke]),je=i(()=>{if(!Ne)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Ne,r=[],o=[];return ke.forEach((o,i)=>{var a;const l=t[o.id];if(!l||0===l.samples.length)return;const s=function(e,t,n,r,o){if(0===e.length)return null;const i=Lo(e,o),a=e=>t-i[e].topMass*n,l=e=>t+i[e].botMass*n;let s=`M${r(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)s+=` L${r(i[e].t)},${a(e)}`;s+=` L${r(i[i.length-1].t)},${l(i.length-1)}`;for(let e=i.length-2;e>=0;e--)s+=` L${r(i[e].t)},${l(e)}`;return s+" Z"}(l.samples,e[o.id],n,Ie,Se);if(!s)return;const c=Lo(l.samples,Se),d=c.find(e=>e.topMass+e.botMass>0)||c[0],u=e[o.id]+(d.botMass-d.topMass)*n/2,h=_e(o.id,i),f=null!==(a=Ae.get(o.id))&&void 0!==a?a:o,g=function(e,t,n,r,o){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const a=n.valueScale,l=n.centerlines[e],s=Lo(i.samples,o),c=s.find(e=>e.topMass+e.botMass>0)||s[0],d=[...s].reverse().find(e=>e.topMass+e.botMass>0)||s[s.length-1],u=r(c.t),h=r(d.t),f=e=>r(Mo(e,o)),g=[],y=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),r=f(n.startTime),o=t-20,i=Math.max(u,o);if(r>i){const[n,s]=Do(e,l,a);g.push({pathD:y(i,n,r,s),x0:o,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),r=f(n.endTime),o=t+20,i=Math.min(h,o);if(i>r){const[n,s]=Do(e,l,a);g.push({pathD:y(r,n,i,s),x0:t,x1:o,from:1,to:0})}}}}return g}(o.id,we,Ne,Ie,Se);r.push(Object.assign(Object.assign({id:o.id,pathD:s,fill:h,stroke:h,strokeWidth:.5},g.length>0&&{gradientStubs:g}),{rawDatum:f,labelX:Ie(d.t)-4,labelY:u,labelText:o.id}))}),we.forEach(r=>{var i,a,l,s;const c=null===(i=t[r.source])||void 0===i?void 0:i.localAttachments.get(r.id),d=null===(a=t[r.target])||void 0===a?void 0:a.localAttachments.get(r.id);if(!c||!d)return;const u=null!==(l=We.get(r.source))&&void 0!==l?l:0,h=_e(r.source,u),f=function(e,t,n,r,o,i,a,l){const s=o,c=e=>l?Math.max(l[0],Math.min(l[1],e)):e,d=i(c(e.time)),u=i(c(n.time)),h=e.value*s,f=n.value*s,g=e.sideMassBefore*s,y=n.sideMassAfter*s;let p,v,m,b;"top"===e.side?(p=t-g,v=p+h):(v=t+g,p=v-h),"top"===n.side?(m=r-y,b=m+f):(b=r+y,m=b-f);const x="source"===a?d+.85*(u-d):"target"===a?d+.15*(u-d):(d+u)/2;return{sx:d,sTop:p,sBot:v,tx:u,tTop:m,tBot:b,cp1X:x,cp2X:x}}(c,e[r.source],d,e[r.target],n,Ie,T,Se),{pathD:g,bezier:y}=Ge(f),p=null!==(s=Me.get(r.id))&&void 0!==s?s:r;o.push({id:r.id,pathD:g,fill:h,opacity:V,rawDatum:p,bezier:y})}),{bands:r,ribbons:o}},[Ne,ke,we,Ie,Se,_e,Ae,Me,T,V,We]),Be=i(()=>({bands:je.bands,ribbons:je.ribbons,showLabels:_}),[je,_]),$e=i(()=>{if(!De||!S)return;const e=new Map;(null!=ye?ye:[]).forEach((t,n)=>{const r=jo(S,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:_e(xe(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[De,S,ye,_e,xe]),ze=i(()=>!1!==U&&Q?void 0===U||!0===U?null:tn(U)||null:null,[U,Q]),Re=l(e=>K?K(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[K]),He=l(e=>Z?Z(e):e+"",[Z]),Fe=l(r=>{if(!r||!r.data)return null;const o=r.data;if(!_o(o))return null;const i=o.data;if(ze)return ze(i);if("band"===o.__kind){const n=o.id,r=Ne?function(e){if(!e)return[];const t=new Set,n=[];for(const r of e.samples){const e=r.topMass+r.botMass,o=`${r.t}:${e}`;t.has(o)||(t.add(o),n.push({t:r.t,total:e}))}return n}(Ne.nodeData[n]):[],i=5,a=r.length>i?r.length:null,l=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),r=n.length-1,o=[Object.assign(Object.assign({},n[0]),{mark:"min"}),Object.assign(Object.assign({},n[Math.floor(.25*r)]),{mark:"q25"}),Object.assign(Object.assign({},n[Math.floor(.5*r)]),{mark:"median"}),Object.assign(Object.assign({},n[Math.floor(.75*r)]),{mark:"q75"}),Object.assign(Object.assign({},n[r]),{mark:"max"})],i=new Set,a=[];for(const e of o)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(r,i);return t("div",{style:{minWidth:160},children:[e("div",{style:{fontWeight:600,marginBottom:4},children:n}),l.length>0&&t("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[e("thead",{children:t("tr",{style:{opacity:.6},children:[e("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),e("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=a&&e("th",{})]})}),e("tbody",{children:l.map((n,r)=>t("tr",{children:[e("td",{style:{paddingRight:8},children:Re(n.t)}),e("td",{style:{textAlign:"right"},children:He(n.total)}),null!=a&&e("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:n.mark})]},r))})]}),null!=a&&t("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",l.length," of ",a," samples"]})]})}const a=i,l=jo(g,a),s=jo(y,a),c=jo(p,a),d=jo(v,a),u=jo(m,a);return t("div",{style:{minWidth:160},children:[t("div",{style:{fontWeight:600,marginBottom:4},children:[l+""," → ",s+""]}),t("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=c&&t(n,{children:[e("span",{style:{opacity:.6},children:"value"}),e("span",{style:{textAlign:"right"},children:He(Number(c))})]}),null!=d&&t(n,{children:[e("span",{style:{opacity:.6},children:"start"}),e("span",{style:{textAlign:"right"},children:Re(Wo(d))})]}),null!=u&&t(n,{children:[e("span",{style:{opacity:.6},children:"end"}),e("span",{style:{textAlign:"right"},children:Re(Wo(u))})]})]})]})},[Ne,ze,Re,He,g,y,p,v,m]),Ye=i(()=>{if(!Ne)return null;const{centerlines:n,laneLifetime:r,nodeData:o,valueScale:i,compressedPadding:a,crossingsBefore:l,crossingsAfter:s,lengthBefore:c,lengthAfter:d}=Ne;let u=null,f=null;for(const e of ke){const t=r[e.id];if(!t||null===t.start||null===t.end)continue;const n=Ie(t.start),o=Ie(t.end);(null===u||u>n)&&(u=n),(null===f||o>f)&&(f=o)}const g=e=>Math.max(0,Math.min(Te,e)),y=g(null!=u?u:0),p=Math.max(y,g(null!=f?f:Te));return t("g",{children:[I&&null!==(null!=s?s:null)&&t("text",{x:Te,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",l," → ",s," ","edge length: ",Math.round(c)," → ",Math.round(d)]}),a&&e("text",{x:Te,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),h.map((t,n)=>{const r=Ie(Wo(t.date));return y-.5>r||r>p+.5?null:e("line",{x1:r,y1:0,x2:r,y2:Oe,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+n)}),N&&ke.map((a,l)=>{const s=r[a.id];if(!s||null===s.start)return null;const c=o[a.id],d=c?{topPeak:c.topPeak,botPeak:c.botPeak}:{topPeak:0,botPeak:0},u=n[a.id]+(d.botPeak-d.topPeak)*i/2,h=Ie(s.start),f=Ie(s.end),g=_e(a.id,l);return t("g",{children:[e("line",{x1:h,y1:u,x2:f,y2:u,stroke:g,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e("line",{x1:h,y1:u-4,x2:h,y2:u+4,stroke:g,strokeOpacity:.5}),e("line",{x1:f,y1:u-4,x2:f,y2:u+4,stroke:g,strokeOpacity:.5})]},"lane-"+a.id)}),e("line",{x1:y,y1:Oe+4,x2:p,y2:Oe+4,stroke:"#94a3b8"}),h.map((n,r)=>{const o=Wo(n.date),i=Ie(o);if(y-.5>i||i>p+.5)return null;const a=null!=n.label?n.label:K?K(new Date(o)):"";return t("g",{transform:`translate(${i},${Oe+4})`,children:[e("line",{y2:6,stroke:"#94a3b8"}),e("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:a})]},r)})]})},[Ne,h,Ie,Te,Oe,N,ke,_e,I,K]),Xe=i(()=>(null!=ye?ye:[]).map(e=>({id:xe(e),data:e})),[ye,xe]),qe=i(()=>{const e=new Map;for(const t of je.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[je]),Ve=i(()=>(null!=ge?ge:[]).map((e,t)=>{const n=be(e,t),r=Number(jo(p,e));return{id:n,source:jo(g,e)+"",target:jo(y,e)+"",value:Number.isFinite(r)?r:0,bezier:qe.get(n),data:e}}),[ge,be,g,y,p,qe]),Ke=Le.loadingEl,Ze=Le.emptyEl;return Ce.length>0?t("svg",{width:W,height:j,role:"img","aria-label":null!=$?$:"Process Sankey validation failed",children:[e("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ce.map((t,n)=>e("text",{x:20,y:56+18*n,fontSize:12,fill:"#64748b",children:"• "+So(t)},n))]}):Ke||Ze||e(Dr,Object.assign({ref:pe,chartType:"force",nodes:Xe,edges:Ve,customNetworkLayout:Io,layoutConfig:Be,size:[W,j],responsiveWidth:F,responsiveHeight:Y,margin:Pe,title:$,description:null!=z?z:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:R,accessibleTable:H,enableHover:Q,tooltipContent:!1===U?()=>null:Fe,backgroundGraphics:Ye,showParticles:te,particleStyle:ne,legend:$e,legendPosition:L,onObservation:J,customClickBehavior:ee?e=>{if(!e||!e.data)return;const t=e.data;_o(t)&&ee(t.data,{x:e.x,y:e.y})}:void 0,chartId:re,colorScheme:Array.isArray(A)?A:void 0},oe))});Bo.displayName="ProcessSankey";const $o=f(function(t,n){const{nodes:r,edges:a,layout:l,layoutConfig:s,nodeIDAccessor:c="id",sourceAccessor:d="source",targetAccessor:u="target",margin:h,className:f,colorScheme:g,frameProps:y={}}=t,{frameRef:p,resolved:v,normalizedMargin:m}=function(e){const t=o(null);return Er(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:Zr(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel}),normalizedMargin:i(()=>function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:n,imperativeVariant:"network",margin:h,width:t.width,height:t.height,enableHover:t.enableHover,title:t.title,mode:t.mode}),b=i(()=>hr(null!=r?r:[]),[r]),x=i(()=>hr(null!=a?a:[]),[a]),{width:k,height:w,enableHover:S,title:A,description:M,summary:L,accessibleTable:D}=v,E=Object.assign(Object.assign(Object.assign(Object.assign({chartType:"force"},null!=r&&{nodes:b}),null!=a&&{edges:x}),{customNetworkLayout:l,layoutConfig:s,nodeIDAccessor:c,sourceAccessor:d,targetAccessor:u,colorScheme:g,size:[k,w],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:m,className:f,title:A,description:M,summary:L,accessibleTable:D,enableHover:S}),y);return e(oo,{componentName:"NetworkCustomChart",width:k,height:w,children:e(Dr,Object.assign({ref:p},E))})});$o.displayName="NetworkCustomChart";export{po as ChordDiagram,bo as CirclePack,go as ForceDirectedGraph,$o as NetworkCustomChart,ko as OrbitDiagram,Bo as ProcessSankey,yo as SankeyDiagram,Dr as StreamNetworkFrame,vo as TreeDiagram,mo as Treemap,So as formatProcessSankeyIssue,wo as validateProcessSankey};
2
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{useRef as r,useMemo as i,useContext as a,useCallback as l,useSyncExternalStore as s,createContext as c,useState as d,useEffect as u,useLayoutEffect as h,forwardRef as f,useImperativeHandle as g,useId as y}from"react";import{interpolateNumber as p}from"d3-interpolate";import{min as v,groups as m,max as b,sum as x,mean as k,group as w}from"d3-array";import{forceLink as S,forceSimulation as A,forceManyBody as M,forceCenter as L,forceX as D,forceY as O}from"d3-force";import{scaleLinear as P,scaleOrdinal as E,scaleTime as T}from"d3-scale";import{ribbon as N,chord as I}from"d3-chord";import{arc as C,pie as _}from"d3-shape";import{hierarchy as j,partition as W,pack as $,treemap as B,treemapBinary as z,cluster as R,tree as H}from"d3-hierarchy";function F(e){return Array.isArray(e)?e[0]:e}function Y(e,t,n,o){return Object.assign({data:F(e),x:t,y:n,__semioticHoverData:!0},o)}const X={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},G={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function q(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function V(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function K(e){const t=e.map(q),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return V(e,n,o)}if(e>=1){const[e,o,r]=t[n];return V(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[a,l,s]=t[r],[c,d,u]=t[r+1];return V(Math.round(a+(c-a)*i),Math.round(l+(d-l)*i),Math.round(s+(u-s)*i))}}const Z=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],U=K(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Q=K(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=K(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=K(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),te=K(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]);K(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]);const ne=K(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oe=K(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]);K(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),K(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),K(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),K(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),K(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),K(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),K(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),K(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),K(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),K(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),K(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);class re{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1,this._freeIndices.push(i);continue}const s=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;a.t+=e*t*s*(l.bezier.circular?.3:1),1>a.t?ie(l.bezier,a.t,a.offset,a):(a.active=!1,this._freeIndices.push(i))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}}function ie(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const i=e.length,a=t*i,l=Math.min(Math.floor(a),i-1),s=a-l,[c,d,u,h]=e[l];ae(c,d,u,h,s,r);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;r.x+=-g/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,i,a,l]=e.points;ae(r,i,a,l,t,o);const s=l.x-r.x,c=l.y-r.y,d=Math.sqrt(s*s+c*c);if(d>.001){const t=s/d;o.x+=-c/d*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function ae(e,t,n,o,r,i){const a=1-r,l=a*a,s=l*a,c=r*r,d=c*r;i.x=s*e.x+3*l*r*t.x+3*a*c*n.x+d*o.x,i.y=s*e.y+3*l*r*t.y+3*a*c*n.y+d*o.y}function le(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function se(e,t){var n,o=[],r=[],i=[],a={},l=[];function s(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&s(t)})}function c(e){var t,o,u=!1;for(r.push(e),i[e]=!0,t=0;l[e].length>t;t++)(o=l[e][t])===n?(d(n,r),u=!0):i[o]||(u=c(o));if(u)s(e);else for(t=0;l[e].length>t;t++){var h=a[o=l[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),u}function d(e,t){var n=[].concat(t).concat(e);o.push(n)}function u(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),l=Array(t),s=0;t>s;++s)n[s]=-1,o[s]=0,r[s]=!1,i[s]=0,a[s]=-1,l[s]=[];var c,d=0,u=[],h=[];function f(t){var s=[t],c=[t];for(n[t]=o[t]=d,r[t]=!0,d+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=o[y]=d,r[y]=!0,d+=1,s.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||l[t].push(a[y])}i[t]=g}else{if(o[t]===n[t]){var p=[],v=[],m=0;for(g=s.length-1;g>=0;--g){var b=s[g];if(r[b]=!1,p.push(b),v.push(l[b]),m+=l[b].length,a[b]=u.length,b===t){s.length=g;break}}u.push(p);var x=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)x[--m]=v[g][k];h.push(x)}c.pop()}}}for(s=0;t>s;++s)0>n[s]&&f(s);for(s=0;h.length>s;s++){var g=h[s];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[s]=c}}return{components:u,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var l=0;r[a].length>l;l++)i>r[a][l]&&(i=r[a][l],n=a);var s=r[n];if(!s)return!1;var c=e.map(function(e,t){return-1===s.indexOf(t)?[]:e.filter(function(e){return-1!==s.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var f=u(n);if(n=f.leastVertex,l=f.adjList){for(var g=0;l.length>g;g++)for(var y=0;l[g].length>y;y++){var p=l[g][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return o}function ce(e){return e.y0-e.y1>0?"up":"down"}function de(e,t){return t(e.source)==t(e.target)}function ue(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function he(e){return e.target.x0-e.source.x1}function fe(e,t){var n=ye(e),o=he(t)/Math.tan(n);return"up"==ce(e)?e.y1-o:e.y1+o}function ge(e,t){var n=ye(e),o=he(t)/Math.tan(n);return"up"==ce(e)?e.y1+o:e.y1-o}function ye(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function pe(e,t){return t(e)}function ve(e){return be(e.source)}function me(e){return be(e.target)}function be(e){return(e.y0+e.y1)/2}function xe(e){return e.virtual?0:e.value}function ke(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!de(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!de(e,t)?o+1:o}),n+o}function we(e){return e.target.depth}function Se(e,t){return e.sourceLinks.length?e.depth:t-1}function Ae(e,t){return e.y0-t.y0}function Me(e,t){return t.y0-e.y0}function Le(e,t){return e.y1-t.y1}function De(e,t){return t.y1-e.y1}function Oe(e,t){return Ee(e.source,t.source)||e.index-t.index}function Pe(e,t){return Ee(e.target,t.target)||e.index-t.index}function Ee(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Te(e,t){return Ne(e)==Ne(t)?"bottom"==e.circularLinkType?Me(e,t):Ae(e,t):Ne(t)-Ne(e)}function Ne(e){return e.target.column-e.source.column}function Ie(e,t){return Ce(e)==Ce(t)}function Ce(e){return e.y0-e.y1>0?"up":"down"}function _e(e,t,n,o,r){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=v(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var s=i.links.filter(function(e){return e.circular});return s.sort(function(e,t){return t.value-e.value}),s.forEach(function(e,t){e._circularStub=t>=4}),je(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),je(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,de(e,t)&&ue(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+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-r-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,s=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?Me:Ae);var d=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+d,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+d),d+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?De:Le),d=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+d,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+d),d+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+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-r-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,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function je(e,t,n){e.sort(Te);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(de(e,t)&&ue(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var l=o[a];if(l!==e&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&We(e,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;i=s>i?s:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function We(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function $e(e){return function(){return e}}function Be(e){return e.index}function ze(e){return e.nodes}function Re(e){return e.links}function He(e,t,n){var o=m(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var l=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=be(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=be(e.target)*t,o+=t}}),o>0?r/o:NaN);l.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=l.get(e),o=l.get(t),r=n.bc,i=o.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(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?ke(t,n)-ke(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==ke(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function Fe(e,t,n,o,r,i){var a=m(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,s=i;s>0;--s)c(l*=.99,n),d();function c(t,n){var o=a.length;a.forEach(function(r){var i=r.length,a=r[0].depth;r.forEach(function(r){var l;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&ke(r,n)>0){var s=k(r.sourceLinks,me),c=k(r.targetLinks,ve),d=s&&c?(s+c)/2:s||c;if(d){var u=(d-be(r))*t*.3;r.y0+=u,r.y1+=u}}else if(0==a&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(a==o-1&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)l=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+l;else{var h=k(r.sourceLinks,me),f=k(r.targetLinks,ve),g=((h&&f?(h+f)/2:h||f)-be(r))*t;r.y0+=g,r.y1+=g}})})}function d(){a.forEach(function(n){var i,a,l,s=e.y0,c=n.length;for(n.sort(t||Ee),l=0;c>l;++l)(a=s-(i=n[l]).y0)>0&&(i.y0+=a,i.y1+=a),s=i.y1+o;if((a=s-o-e.y1)>0)for(s=i.y0-=a,i.y1-=a,l=c-2;l>=0;--l)(a=(i=n[l]).y1+r-s)>0&&(i.y0-=a,i.y1-=a),s=i.y0})}}function Ye(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Pe),e.targetLinks.sort(Oe)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Xe(){var e=0,t=0,n=1,o=1,r=24,i=8,a=null,l=Be,s=Se,c=void 0,d=32,u=2,h=ze,f=Re;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=o,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return w(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=le(n,o)),"object"!=typeof r&&(r=e.target=le(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,l=i.target.index;o[a]||(o[a]=[]),o[l]||(o[l]=[]),-1===o[a].indexOf(l)&&o[a].push(l)}var s=se(o);s.sort(function(e,t){return e.length-t.length});var c={};for(r=0;s.length>r;r++){var d=s[r].slice(-2);c[d[0]]||(c[d[0]]={}),c[d[0]][d[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){pe(e,t)!=pe(r.source,t)&&pe(e,t)!=pe(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),de(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(x(e.sourceLinks,xe),x(e.targetLinks,xe)),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,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-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(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,c,s);var f=i;if(null!==a){var g=m(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=b(g,function(e){return e.length});y>1&&(f=Math.max(1,(o-t)*a/(y-1)))}(function(e,t,n){var o=m(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 r=v(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/x(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=b(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,r),He(h,c,l),Fe(h,c,l,f,f,d),Ye(h),_e(h,l,u,10,8),He(h,c,l),Fe(h,c,l,f,f,d),Ye(h),_e(h,l,u,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return pe(n.source,t)==pe(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ie(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=fe(t,e);return e.y1-n}if(t.target.column>e.target.column)return fe(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;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(h,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return pe(n.target,t)==pe(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ie(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=ge(t,e);return e.y0-n}if(t.source.column>e.source.column)return ge(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;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(h,l),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){var i=v(t,function(e){return e.y0}),a=b(t,function(e){return e.y1}),l=(e.y1-e.y0)/(a-i);function s(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=s(e.y0),e.y1=s(e.y1)}),n.forEach(function(e){e.y0=s(e.y0),e.y1=s(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=s(e.y0)-e.y0;e.y0=s(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),_e(h,l,u,10,8)}(g),g}return g.update=function(e){return Ye(e),_e(e,l,u,10,8),e},g.nodeWidth=function(e){return arguments.length?(r=+e,g):r},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:$e(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:$e(e),g):f},g.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:$e(e),g):l},g.nodeAlign=function(e){return arguments.length?(s="function"==typeof e?e:$e(e),g):s},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(d=+e,g):d},g.circularLinkGap=function(e){return arguments.length?(u=+e,g):u},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],g):[[e,t],[n,o]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],g):[n-e,o-t]},g}function Ge(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:a,cp1X:l,cp2X:s}=e,c=(n+o)/2,d=(i+a)/2;return{pathD:[`M${t},${n}`,`C${l},${n} ${s},${i} ${r},${i}`,`L${r},${a}`,`C${s},${a} ${l},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:l,y:c},{x:s,y:d},{x:r,y:d}],halfWidth:(o-n)/2}}}const qe=e=>{let t,n,o,r,i,a,l,s,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,l=p(i,a),s=l(.5),c=l(.5),`M${t},${i}C${t},${s} ${n},${c} ${n},${a}L${o},${a}C${o},${c} ${r},${s} ${r},${i}Z`;const d=e.sankeyWidth/2,u=p(e.source.x1,e.target.x0),{pathD:h}=Ge({sx:e.source.x1,sTop:e.y0-d,sBot:e.y0+d,tx:e.target.x0,tTop:e.y1-d,tBot:e.y1+d,cp1X:u(.5),cp2X:u(.5)});return h};function Ve(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.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*(r.rightFullExtent-t))),s=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+l},${o-n}L${t+l},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-s},${a-n}L${i-s},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,l=r.targetX,s=r.targetY,c=r.rightFullExtent,d=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*f}L${c+o},${u+h*o-h*f}L${c+o-f},${u+h*o}L${d-o+f},${u+h*o}L${d-o},${u+h*o-h*f}L${d-o},${s-h*n+h*f}L${d-o+f},${s-h*n}L${l},${s-h*n}L${l},${s+h*n}L${d+o},${s+h*n}L${d+o},${u-h*o}L${c-o},${u-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const Ke=new Set,Ze=new WeakMap;function Ue(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Ze.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Ze.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Ke.has(e)||(Ke.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}const Qe={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(we))-1:0},justify:Se};function Je(e){return"string"==typeof e?e:e.id}const et={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,l,s,c,d;if(0===e.length)return;const u="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(r=n.nodeWidth)&&void 0!==r?r:15,g=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.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"===u?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=Xe().extent(m).links(v).nodes(p).nodeAlign(Qe[h]||Se).nodeId(e=>e.id).nodeWidth(f).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of p)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of v){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(s=null!==(l=o._circularWidth)&&void 0!==l?l:o.width)&&void 0!==s?s:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,d=o[0],u=o[1];if(i>0&&a>0&&(0>e||0>n||t>d||r>u)){const t=Math.min(d/i,u/a),o=-e*t+(d-i*t)/2,r=-n*t+(u-a*t)/2;for(const e of p)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of v)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=Je(e.source),n=Je(e.target),o=k.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(d=e.width)&&void 0!==d?d:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=u;const r=x.get(t),i=x.get(n);r&&(o.source=r),i&&(o.target=i)}}},buildScene(e,t,n,o){var r,i,a,l,s,c;const d="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,f=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Z,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const v=[],m=[],b=[],x=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=u?u(Ue(t,"nodeStyle")):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};x.set(t.id,("string"==typeof r.fill?r.fill:null)||p.get(t.id)||"#4d430c"),v.push("down"===d?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:r,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const k=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of k){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";r="function"==typeof g?g(e)||r:"target"===g?x.get(o.id)||p.get(o.id)||r:x.get(t.id)||p.get(t.id)||r;const d=h?h(Ue(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),i=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=d.fill||r;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:a,fillOpacity:null!==(l=d.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:d.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-i},${t.targetY-n}L${t.targetX-i},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:a,fillOpacity:null!==(s=d.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:d.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-i,x1:t.targetX}});continue}let u;if(u=e.circular&&e.circularPathData?Ve(e):qe(e),!u)continue;const y={fill:d.fill||r,fillOpacity:null!==(c=d.fillOpacity)&&void 0!==c?c:f,stroke:d.stroke||"none",strokeWidth:d.strokeWidth,opacity:d.opacity};m.push({type:"bezier",pathD:u,bezierCache:e.bezier,style:y,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,l,s;"down"===d?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,s="start"):(o[0]/2>n.x0+e/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+r/2),b.push({x:a,y:l,text:i+"",anchor:"down"===d?"middle":s,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:m,labels:b}}},tt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,l=o[0]/2,s=o[1]/2,c=n.__previousPositions;let d=0;const u=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?d++:n?(t.x=n.x,t.y=n.y,d++):u.push(t)}const h=d>0&&.3>=(e.length>0?u.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of u){const o=nt(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=ot(e.id),i=r%360*(Math.PI/180),a=10+r%20;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=ot(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=l+o*Math.cos(n),e.y=s+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=l+e*Math.cos(r),o.y=s+e*Math.sin(r)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=0===n.iterations?0:h?40:f,y=rt(n.nodeSize,n.nodeSizeRange,e),p=e=>y(e);if(g>0){const n=S().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*a:a)}).id(e=>e.id),o=A().force("charge",M().strength(e=>-25*p(e))).force("center",L(l,s).strength(.8)).force("x",D(l).strength(.15)).force("y",O(s).strength(.15));if(o.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}));n.links(e),o.force("link",n)}h?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let e=0;g>e;++e)o.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(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a,l,s,c,d;const u=n.nodeStyle,h=n.edgeStyle,f=rt(n.nodeSize,n.nodeSizeRange,e),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Z,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],v=[],m=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(Ue(t,"nodeSize")),o=u?u(Ue(t,"nodeStyle")):{},l={fill:o.fill||y.get(t.id)||(null===(r=n.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:2,opacity:o.opacity};p.push({type:"circle",cx:t.x,cy:t.y,r:e,style:l,datum:t,id:t.id,label:t.id})}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:b.get(e.source),o="object"==typeof e.target?e.target:b.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=h?h(Ue(e,"edgeStyle")):{},i={stroke:r.stroke||(null===(l=n.themeSemantic)||void 0===l?void 0:l.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999",strokeWidth:null!==(c=r.strokeWidth)&&void 0!==c?c:1,opacity:null!==(d=r.opacity)&&void 0!==d?d:.6};v.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:i,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=f(Ue(n,"nodeSize"));m.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:v,labels:m}}};function nt(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function ot(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function rt(e,t,n){var o,r;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=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===a.length)return()=>i[0];const l=null!==(o=v(a))&&void 0!==o?o:0,s=null!==(r=b(a))&&void 0!==r?r:1;if(l===s)return()=>(i[0]+i[1])/2;const c=P().domain([l,s]).range(i).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?i[0]:c(o)}}const it=Z,at={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,l=Math.min(o[0],o[1])/2,s=l-i,c=o[0]/2,d=o[1]/2,u=(h=n.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,n=f.get("string"==typeof e.source?e.source:e.source.id),o=f.get(t);if(void 0===n||void 0===o)continue;const r=u(e);y[n][o]=r}const p=I().padAngle(r);a&&p.sortGroups(a);const v=p(y),m=v.groups,b=C().innerRadius(s).outerRadius(l);for(const t of m){const n=e[t.index],o=b.centroid({innerRadius:s,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+c,n.y=o[1]+d,n.__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,n=x.get("string"==typeof e.source?e.source:e.source.id),o=x.get(t);n&&(e.source=n),o&&(e.target=o)}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 n=e[t.source.index].id,o=e[t.target.index].id,r=k.get(`${n}\0${o}`)||k.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){var r,i,a,l;const{groupWidth:s=20,edgeOpacity:c=.5}=n,d=Math.min(o[0],o[1])/2,u=d-s,h=o[0]/2,f=o[1]/2,g=n.nodeStyle,y=n.edgeStyle,p=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:it,m=new Map;e.forEach((e,t)=>{m.set(e.id,v[t%v.length])});const b=N().radius(u),x=[],k=[],w=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let i;i=g?g(Ue(n,"nodeStyle")).fill||m.get(n.id)||v[t%v.length]:m.get(n.id)||v[t%v.length];const a=g?g(Ue(n,"nodeStyle")):{},l={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};x.push({type:"arc",cx:h,cy:f,innerR:u,outerR:d,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:l,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=b(t);if(!o)continue;const r=lt(o,h,f);let s=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";if(y)s=y(Ue(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===p&&n?s=m.get(n.id)||s:t&&(s=m.get(t.id)||s)}const d=y?y(Ue(e,"edgeStyle")):{},u={fill:s,fillOpacity:null!==(l=d.fillOpacity)&&void 0!==l?l:c,stroke:d.stroke||"none",strokeWidth:d.strokeWidth,opacity:d.opacity};k.push({type:"ribbon",pathD:r,style:u,datum:e})}if(!1!==n.showLabels){const t=(S=n.nodeLabel)?"function"==typeof S?S:e=>e[S]||e.id:null,o=d+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;w.push({x:h+Math.cos(a)*o,y:f+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:x,sceneEdges:k,labels:w}}};function lt(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const st=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ct(e){const[t,n,o]=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*n+.114*o>150?"#222":"#fff"}function dt(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function ut(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function ht(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:st}function ft(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function gt(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}const yt={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,l=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,d=j(i,l);d.sum(c),d.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[u,h]=o;switch(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=H();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,u,h);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=R();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,u,h);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,s=B().size([n,o]).tile(z).padding(a);l>0&&s.paddingTop(l),s(e)}(d,n,u,h);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;$().size([n,o]).padding(i)(e)}(d,n,u,h);break;case"partition":!function(e,t,n,o){var r;W().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(d,n,u,h)}const f=d.descendants();e.length=0,t.length=0;const g=new Map;for(let t=0;f.length>t;t++){const o=f[t],i={id:dt(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===a||"cluster"===a?pt(i,o,n):"treemap"===a||"partition"===a?vt(i,o):"circlepack"===a&&mt(i,o),i.__hierarchyNode=o,e.push(i),g.set(o,i)}if("tree"===a||"cluster"===a)for(const e of f)if(e.parent){const n=g.get(e.parent),o=g.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,l,s,c,d,u,h,f;const g=[],y=[],p=[],v=n.treeOrientation||"vertical",m="radial"===v,b=o[0]/2,x=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const t of e){let e=t.x,o=t.y;m&&(e+=b,o+=x);const i=r(Ue(t,"nodeStyle"));let s=i.fill||ft(n);if(n.colorByDepth&&void 0!==t.depth){const e=ht(n);s=e[t.depth%e.length]}const c={fill:s,stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.surface)||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};g.push({type:"circle",cx:e,cy:o,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const S=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,a=t.y,l=o.x,s=o.y;m&&(r+=b,a+=x,l+=b,s+=x);const f=gt(r,a,l,s,v),g=i(Ue(e,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(d=n.themeSemantic)||void 0===d?void 0:d.secondary)||"#999",strokeWidth:null!==(u=g.strokeWidth)&&void 0!==u?u:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:S};y.push({type:"curved",pathD:f,style:p,datum:e})}if(!1!==n.showLabels){const t=ut(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,l=n.y;if(m&&(a+=b,l+=x),m){const e=a-b,t=l-x,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=l+t/n*10,i=0>e?"end":"start"):(o=a,r=l-12,i="middle")}else"horizontal"===v?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=a-k-6,i="end"):(o=a+k+6,i="start"),r=l):(o=a,r=l+k+14,i="middle");p.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i,a,l,s;const c=[],d=[];for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;const l=o(Ue(n,"nodeStyle"));let s=l.fill||ft(t);if(t.colorByDepth&&void 0!==n.depth){const e=ht(t);s=e[n.depth%e.length]}const d={fill:s,stroke:l.stroke||(null===(r=t.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(i=l.strokeWidth)&&void 0!==i?i:1,opacity:l.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:e,h:a,style:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ut(t.nodeLabel),r=t.labelMode||"leaf",i="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,u=c.y1-c.y0;if(0>=e||0>=u)continue;const h=!((null===(a=c.data)||void 0===a?void 0:a.children)&&c.data.children.length>0);if(!i){if("leaf"===r&&!h)continue;if("parent"===r&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>e||(h?16:14)>u)continue;let g=o(Ue(c,"nodeStyle")).fill||ft(t);if(t.colorByDepth&&void 0!==c.depth){const e=ht(t);g=e[c.depth%e.length]}const y="string"==typeof g?ct(g):null!==(s=null===(l=t.themeSemantic)||void 0===l?void 0:l.text)&&void 0!==s?s:"#000";d.push(h?{x:c.x0+e/2,y:c.y0+u/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:d}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,l,s,c,d,u,h,f;const g=[],y=[];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(Ue(n,"nodeStyle"));let c=s.fill||ft(t);if(t.colorByDepth&&void 0!==n.depth){const e=ht(t);c=e[n.depth%e.length]}const d={fill:c,stroke:s.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=s.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=s.opacity)&&void 0!==l?l:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:e,style:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ut(t.nodeLabel);for(const r of e){const e=null!==(s=r.__radius)&&void 0!==s?s:5,i=n?n(r):r.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let l=o(Ue(r,"nodeStyle")).fill||ft(t);if(t.colorByDepth&&void 0!==r.depth){const e=ht(t);l=e[r.depth%e.length]}if(a){const n="string"==typeof l?ct(l):null!==(u=null===(d=t.themeSemantic)||void 0===d?void 0:d.text)&&void 0!==u?u:"#000";y.push({x:r.x,y:r.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else y.push({x:r.x,y:r.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=t.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pt(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(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 vt(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 mt(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function bt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const xt={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){var i,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,u=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,h="number"==typeof d?()=>d:d,f="number"==typeof u?()=>u:u,g=bt(n);g.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function p(e){var t;const n=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,m=t[1]/2,b=Math.min(t[0],t[1])/2*.85,x=p(s(e));o.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,n,i,a,d,u,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+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let m=0;b>m;m++){const x=c[Math.min(m,c.length-1)],k=v.slice(w,w+x);if(!k.length)break;const S=(m+1)/b,A={id:n,depth:u,data:t,parentId:n},M=y?d/h(A)*S:d*S,L=_().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),D=L(k),O=f(A);for(let t=0;k.length>t;t++){const l=(D[t].startAngle+D[t].endAngle)/2,c=k[t],d=p(s(c)),h=i+M*Math.sin(l),f=a+M*Math.cos(l)*O;o.push({id:d,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:u,data:c}),g.metaMap.set(d,{ring:M,angle:l,depth:u,parentId:n,eccentricity:O}),r.push({source:n,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:d}}),e(c,d,h,f,M,u+1,!0)}w+=x}}(e,x,v,m,b,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){var r,i,a,l,s,c,d;const u=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const t=bt(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{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:n,ecc:o}]of r)for(let r=0;i>r;r++){const l=r/i*Math.PI*2,s=(r+1)/i*Math.PI*2;y.push({type:"line",x1:e+n*Math.sin(l),y1:t+n*Math.cos(l)*o,x2:e+n*Math.sin(s),y2:t+n*Math.cos(s)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(Ue(t,"nodeSize")),o=u?u(Ue(t,"nodeStyle")):{},c={fill:o.fill||(null===(r=n.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=o.opacity)&&void 0!==l?l:0===(null!==(s=t.depth)&&void 0!==s?s:0)?1:.85};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:v.get(e.source),n="object"==typeof e.target?e.target:v.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&y.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=f(Ue(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t&&null!==(d=null===(c=n.data)||void 0===c?void 0:c[t])&&void 0!==d?d:n.id;p.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const r=bt(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,a=null!==(o=t.orbitRevolution)&&void 0!==o?o: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 n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+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())-r.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const o=e.angle+l*s*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},kt={sankey:et,force:tt,chord:at,tree:yt,cluster:yt,treemap:yt,circlepack:yt,partition:yt,orbit:xt};function wt(e){return kt[e]}const St={category10:Z,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:U,reds:Q,greens:J,oranges:ee,purples:te,viridis:ne,plasma:oe},At=Z,Mt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Lt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Dt=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 Ot(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Dt.has(t)}(o)?n(o):o}const o=(null==e?void 0:e[t])+"";return n?n(o):At[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%At.length]}function Pt(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return E().domain(o).range(n).unknown("#999");const i=St[n]||St.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:At;return E().domain(o).range(e).unknown("#999")}}function Et(e){return 0===e.length?()=>"#4e79a7":t=>{var n;let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return null!==(n=e[Math.abs(o)%e.length])&&void 0!==n?n:"#4e79a7"}}function Tt(e,t,n){return e+(t-e)*n}function Nt(e,t,n){var o,r,i;if(1>=n)return 1;const a=null!==(o=e.minOpacity)&&void 0!==o?o:.1,l=n-1-t;switch(e.type){case"linear":return a+(1-l/(n-1))*(1-a);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>l?1:a;default:return 1}}class It{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=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({},X),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new re(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},X),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new re(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof o?o:e=>e[o],s="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});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(let e=0;t.length>e;e++){const n=t[e],o=s(n)+"",r=c(n)+"",i=d(n),a=null==i?NaN:Number(i),l=Number.isFinite(a)?a:1;this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Ct(o)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Ct(r)),{data:n}));const u=`${o}\0${r}\0${e}`,h={source:o,target:r,value:l,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:u};n&&"object"==typeof n&&_t(n.bezier)&&(h.bezier=n.bezier),this.edges.set(u,h)}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=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(n)||(this.nodes.set(n,Ct(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const l=this.edgeKey(t,n),s=this.edges.get(l);let c=!1;return s?(s.value+=o,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(l,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,o,r,i,a,l,s;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=wt(this.config.chartType);if(!c)return;let d=Array.from(this.nodes.values());const u=Array.from(this.edges.values());if(0===d.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const l of d)if(void 0!==l._prevX0){const s=(null!==(t=l._prevX1)&&void 0!==t?t:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(o=l._prevY1)&&void 0!==o?o:0)-(null!==(r=l._prevY0)&&void 0!==r?r:0);e.set(l.id,{x:(null!==(i=l._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(a=l._prevY0)&&void 0!==a?a:0)+c/2})}else 0===l.x&&0===l.y||e.set(l.id,{x:l.x,y:l.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(d,u,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&d.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of d)this.nodes.set(e.id,e);for(let e=0;u.length>e;e++){const t=u[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,d=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=d.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=null!==(s=null===(l=this.config.transition)||void 0===l?void 0:l.duration)&&void 0!==s?s:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&d.length>0&&g>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.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=e,this.previousEdgeKeys=t}buildScene(e){var t,n,o,r,i,a;const l=Array.from(this.nodes.values()),s=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=function(e,t,n){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=St[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,Z),d={nodes:l,edges:s,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:null!==(t=this.config.themeSemantic)&&void 0!==t?t:{},categorical:[...c]},resolveColor:Et(c),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{}};let u;try{u=this.config.customNetworkLayout(d)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],void(this.customLayoutOverlays=null)}return this.sceneNodes=null!==(o=u.sceneNodes)&&void 0!==o?o:[],this.sceneEdges=null!==(r=u.sceneEdges)&&void 0!==r?r:[],this.labels=null!==(i=u.labels)&&void 0!==i?i:[],void(this.customLayoutOverlays=null!==(a=u.overlays)&&void 0!==a?a:null)}this.customLayoutOverlays=null;const c=wt(this.config.chartType);if(!c)return;const{sceneNodes:d,sceneEdges:u,labels:h}=c.buildScene(l,s,this.config,e);this.sceneNodes=d,this.sceneEdges=u,this.labels=h}get isAnimating(){const e=wt(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=wt(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=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=Tt(e._prevX0,e._targetX0,n),e.x1=Tt(e._prevX1,e._targetX1,n),e.y0=Tt(e._prevY0,e._targetY0,n),e.y1=Tt(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Tt(e._prevY0,e._targetY0,n),e.y1=Tt(e._prevY1,e._targetY1,n),e.sankeyWidth=Tt(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=null==e?void 0:e.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}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),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.x1,i=n.x0,a=p(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,a=p(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,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,n,o,r,i;const a=this.config.pulse;if(!a)return;const l=null!==(t=a.duration)&&void 0!==t?t:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;l>r&&(t._pulseIntensity=1-r/l,t._pulseColor=s,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const d=e-c;l>d&&(t._pulseIntensity=1-d/l,t._pulseColor=s)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const o=this.nodeTimestamps.size;if(1>=o)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const r=this._decaySortedNodes,i=new Map;for(let e=0;r.length>e;e++)i.set(r[e][0],e);for(const r of this.sceneNodes){const a=r.id;if(!a)continue;const l=i.get(a);if(void 0===l)continue;const s=Nt(n,l,o),c=null!==(t=null===(e=r.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;r.style=Object.assign(Object.assign({},r.style),{opacity:c*s})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),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,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=o.metric(l);let c=null;void 0===o.critical||o.critical>s?void 0===o.warning||o.warning>s||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const o=this.nodes.get(e);if(!o)return null;const r=o.data?Object.assign({},o.data):{};return o.data=t(null!==(n=o.data)&&void 0!==n?n:{}),this.layoutVersion++,r}updateEdge(e,t,n){var o;const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,a=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){a.push(r.data?Object.assign({},r.data):{}),r.data=n(null!==(o=r.data)&&void 0!==o?o:{});const e=i(r.data);null!=e&&(r.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}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._hasRenderedOnce=!1,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 _t(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!jt(e))return!1;return!0}return jt(t.points)}function jt(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}function Wt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:o.createElement(o.Fragment,null,...t)}function $t(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Bt(e,t,n,o,r=30){let i=null,a=r,l=1/0;for(const t of e){const e=zt(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(i=e,l=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){if(!1===e.interactive)continue;const t=Xt(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function zt(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,a=Math.sqrt(r*r+i*i),l=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,o);return a>l?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,o);case"rect":return function(e,t,n){const o=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const a=$t(Math.atan2(r,o)),l=$t(e.startAngle),s=$t(e.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let Rt=null,Ht=null;function Ft(){return Ht||(Rt=document.createElement("canvas"),Rt.width=1,Rt.height=1,Ht=Rt.getContext("2d")),Ht}function Yt(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function Xt(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Yt(e),r=Ft();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const l=e.x1+a*o,s=e.y1+a*r,c=Math.sqrt(Math.pow(t-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:e.datum,x:l,y:s,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Yt(e),r=Ft();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Gt(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?qt(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?qt(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function qt(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function Vt(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}const Kt="var(--semiotic-focus, #005fcc)";function Zt({active:t,hoverPoint:n,margin:o,size:r,shape:i="circle",width:a,height:l}){if(!t||!n)return null;const s=n.x+o.left,c=n.y+o.top;let d;if("rect"===i&&null!=a&&null!=l){const t=Math.max(a,4),n=Math.max(l,4);d=e("rect",{x:s-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:Kt,strokeWidth:2,strokeDasharray:"4,2"})}else d=e("circle","wedge"===i?{cx:s,cy:c,r:12,fill:"none",stroke:Kt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:Kt,strokeWidth:2,strokeDasharray:"4,2"});return e("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:d})}const Ut={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Qt(e,t){return"function"==typeof t?t(e):e[t]}function Jt(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function en(n={}){const{fields:o,title:r,format:i,style:a={},className:l=""}=n;return n=>{if(!n||"object"!=typeof n)return null;let s;const c=[];if(r){const e=Qt(n,r);s=Jt(e,i)}if(o&&o.length>0)o.forEach(e=>{let t,o,r;"string"==typeof e?(t=e,o=e,r=i):(t=e.label,o=e.accessor||e.key||"",r=e.format||i);const a=Qt(n,o);c.push({label:t,value:Jt(a,r)})});else if(!r){const e=["value","y","name","id","label"];for(const t of e)if(void 0!==n[t]){s=Jt(n[t],i);break}if(!s){const e=Object.keys(n).filter(e=>!e.startsWith("_"));e.length>0&&(s=Jt(n[e[0]],i))}}const d=Object.assign(Object.assign({},Ut),a);return t("div",{className:("semiotic-tooltip "+l).trim(),style:d,children:[s&&e("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:s}),c.map((e,n)=>t("div",{style:{marginTop:0===n&&s?"4px":0},children:[e.label&&t("span",{children:[e.label,": "]}),e.value]},n))]})}}function tn(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var o;const r=F(!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(o=t.data)&&void 0!==o?o:{}:t),i=n(r);return null==i?null:e("div",{className:"semiotic-tooltip",style:Ut,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?en(t):en())}}function nn({x:t,y:n,containerWidth:r,containerHeight:i,margin:a,children:l,className:s="stream-frame-tooltip",zIndex:c=1}){const d=Number.isFinite(t)&&Number.isFinite(n),u=o.useRef(null),[h,f]=o.useState(null);o.useLayoutEffect(()=>{const e=u.current;if(!e)return;const t=e.getBoundingClientRect();f(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[l,s,r,i]);let g;g=h?`translate(${h.width+12>r-t?"calc(-100% - 12px)":"12px"}, ${h.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const y=function(e){if(!o.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor)return!0}return!1}(l),p=y?null:Ut;return d?e("div",{ref:u,className:y?s:(s+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:a.left+t,top:a.top+n,transform:g,pointerEvents:"none",zIndex:c,width:"max-content"}),children:l}):null}function on(t){let n=null;const o=()=>(n||(n=c(null)),n),d=rn(t);return[function({children:n,initialState:a}){const l=r(a),s=i(()=>rn(t,l.current),[]),c=o();return e(c.Provider,{value:s,children:n})},e=>{var t;const n=o(),i=null!==(t=a(n))&&void 0!==t?t:d,c=r(e);c.current=e;const u=l(()=>c.current(i.getState()),[i]),h=l(()=>c.current(i.getState()),[i]);return s(i.subscribe,u,h)}]}function rn(e,t){const n=new EventTarget;let o=Object.assign(Object.assign({},e(function(e){o=Object.assign(Object.assign({},o),e(o)),n.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>o,subscribe:function(e){return n.addEventListener("update",e),()=>n.removeEventListener("update",e)}}}function an(e){if(!(null==e?void 0:e.colors))return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function ln(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:sn})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const sn=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],cn={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},dn={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},un={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:sn,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function hn(e,t){if("light"===t)return cn;if("dark"===t)return dn;if("high-contrast"===t)return un;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?dn:cn;return ln(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}return ln(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}const[fn,gn]=on(e=>({theme:cn,setTheme(t){e(e=>({theme:hn(e.theme,t)}))}}));const yn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,pn=new WeakMap;let vn=0,mn=!1,bn=null,xn=null,kn=null;function wn(e,t){var n,o;if(!t)return t;const r=yn.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;!function(){if(mn)return;if("undefined"==typeof window||"undefined"==typeof document)return;mn=!0;const e=()=>{vn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(bn=new MutationObserver(e),bn.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{xn=window.matchMedia("(prefers-color-scheme: dark)"),kn=e,"function"==typeof xn.addEventListener?xn.addEventListener("change",kn):"function"==typeof xn.addListener&&xn.addListener(kn)}catch(e){}}();let a=pn.get(i);a&&a.version===vn||(a={version:vn,map:new Map},pn.set(i,a));const l=a.map.get(t);if(void 0!==l)return l;const s=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return a.map.set(t,s),s}const Sn="undefined"==typeof window?u:h;function An(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Mn(e){const t=function(){const[e,t]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return u(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=r(t);n.current=t;const[a,s]=function(e,t,n){const o=r(null),[i,a]=d(null);return u(()=>{if(!t&&!n)return;const e=o.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[o,[t&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),c=i(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),h=s[0]-c.left-c.right,f=s[1]-c.top-c.bottom,g=An(e.foregroundGraphics,s,c),y=An(e.backgroundGraphics,s,c),p=gn(e=>e.theme),{transition:v,introEnabled:m}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const r="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(r||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),b="semiotic-table-"+o.useId(),x=r(0),k=r(()=>{}),w=l(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);u(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const S=r(()=>{}),A=r(()=>{}),M=r(null),L=r(0),D=l(()=>{L.current=0;const e=M.current;M.current=null,e&&S.current(e)},[]),O=l(e=>{M.current={clientX:e.clientX,clientY:e.clientY},0===L.current&&(L.current=requestAnimationFrame(D))},[D]),P=l(()=>{M.current=null,0!==L.current&&(cancelAnimationFrame(L.current),L.current=0),A.current()},[]);u(()=>()=>{M.current=null,0!==L.current&&(cancelAnimationFrame(L.current),L.current=0)},[]);const E=e.themeDirtyRef;return Sn(()=>{E&&(vn++,E.current=!0,w())},[p,w,E]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:a,size:s,margin:c,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:y,currentTheme:p,transition:v,introEnabled:m,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:S,hoverLeaveRef:A,onPointerMove:O,onPointerLeave:P}}const Ln={fill:(t,n)=>e("rect",{style:t,width:n,height:n}),line:(t,n)=>e("line",{style:t,x1:0,y1:0,x2:n,y2:n})};function Dn(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,Ln[n])(o(e,t),r),i}function On({swatchSize:t}){return e("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Pn(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const En=(n,o,r,i,a,l,s,c,d,u,h)=>{const{type:f="fill",styleFn:g,items:y}=n,p=[];let v=0;const m=!(!o&&!r),b="isolate"===u||void 0===u&&null!=a,{swatchSize:x,labelGap:k,rowHeight:w}=h;return y.forEach((n,u)=>{const h=Dn(n,u,f,g,x),S=Pn(n,i,a),A=a&&a.size>0&&a.has(n.label);p.push(t("g",{transform:`translate(0,${v})`,onClick:o?()=>o(n):void 0,onMouseEnter:r?()=>r(n):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:m?c===l&&u===s?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?A||!1:void 0,"aria-current":m&&!b&&null!=i&&n.label===i||void 0,"aria-label":n.label,onKeyDown:m?e=>{var t;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(n)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const n=(u+("ArrowDown"===e.key?1:-1)+y.length)%y.length;d(c,n);const o=null===(t=e.currentTarget.parentElement)||void 0===t?void 0:t.children[n];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:m?e=>{d(c,u),r&&r(n);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+k+2+7*n.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),h,A&&e(On,{swatchSize:x}),e("text",{y:x/2,x:x+k,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+u)),v+=w}),p};function Tn({config:n,orientation:r="vertical",width:i=100}){const{colorFn:a,domain:l,label:s,format:c}=n,d=c||(e=>Math.round(100*e)/100+""),u="grad-legend-"+o.useId();if("horizontal"===r){const n=12,o=Math.min(i,200),r=Math.max(0,(i-o)/2),c=[];for(let t=0;64>=t;t++){const n=t/64;c.push(e("stop",{offset:100*n+"%",stopColor:a(l[0]+n*(l[1]-l[0]))},t))}return t("g",{"aria-label":s||"Gradient legend",children:[e("defs",{children:e("linearGradient",{id:u,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),s&&e("text",{x:r+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e("rect",{x:r,y:0,width:o,height:n,fill:`url(#${u})`,rx:2}),e("text",{x:r,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[0])}),e("text",{x:r+o,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[1])})]})}const h=[];for(let t=0;64>=t;t++){const n=t/64;h.push(e("stop",{offset:100*n+"%",stopColor:a(l[1]-n*(l[1]-l[0]))},t))}return t("g",{"aria-label":s||"Gradient legend",children:[s&&e("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e("defs",{children:e("linearGradient",{id:u,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),e("rect",{x:0,y:0,width:14,height:100,fill:`url(#${u})`,rx:2}),e("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[1])}),e("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:d(l[0])})]})}function Nn(n){const{legendGroups:r,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,legendInteraction:c,title:d="Legend",width:u=100,height:h=20,orientation:f="vertical",legendLayout:g}=n,y=function(e){var t,n,o,r,i;const a=Math.max(1,null!==(t=null==e?void 0:e.swatchSize)&&void 0!==t?t:16),l=Math.max(a,null!==(n=null==e?void 0:e.rowHeight)&&void 0!==n?n:22);return{swatchSize:a,labelGap:Math.max(0,null!==(o=null==e?void 0:e.labelGap)&&void 0!==o?o:6),itemGap:Math.max(0,null!==(r=null==e?void 0:e.itemGap)&&void 0!==r?r:10),rowHeight:l,align:"left"===(null==e?void 0:e.align)?"start":"right"===(null==e?void 0:e.align)?"end":null!==(i=null==e?void 0:e.align)&&void 0!==i?i:"start",maxWidth:null==e?void 0:e.maxWidth}}(g),[p,v]=o.useState(0),[m,b]=o.useState(0),x=o.useCallback((e,t)=>{v(e),b(t)},[]),k="vertical"===f?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:d,metrics:u})=>{let h=24;const f=[];return t.forEach((t,g)=>{h+=5,f.push(e("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,t.label&&(h+=16,f.push(e("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),h+=8),f.push(e("g",{className:"legend-item",transform:`translate(0,${h})`,children:En(t,o,r,i,a,l,s,g,c,d,u)},"legend-group-"+g)),h+=t.items.length*u.rowHeight+8}),f})({legendGroups:r||[],width:u,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:p,focusedItemIndex:m,onFocusedIndexChange:x,legendInteraction:c,metrics:y}):(({legendGroups:n,height:o,width:r,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:c,focusedItemIndex:d,onFocusedIndexChange:u,legendInteraction:h,metrics:f})=>{var g;let y=0;const p=[];n.forEach((n,o)=>{var g;let v=0;n.label&&(v+=16);const m=((n,o,r,i,a,l,s,c,d,u,h,f)=>{const{type:g="fill",styleFn:y,items:p}=n,v=[],{swatchSize:m,labelGap:b,itemGap:x,rowHeight:k,align:w}=h,S=!(!o&&!r),A="isolate"===u||void 0===u&&null!=a,M=p.map(e=>m+b+7*e.label.length),L=[];let D=0,O=0;M.forEach((e,t)=>{const n=0===O?e:O+x+e;f&&f>0&&O>0&&n>f?(L.push({start:D,end:t,width:O}),D=t,O=e):O=n}),p.length>0&&L.push({start:D,end:p.length,width:O}),L.forEach((n,u)=>{let h="center"===w?Math.max(0,((null!=f?f:n.width)-n.width)/2):"end"===w?Math.max(0,(null!=f?f:n.width)-n.width):0;for(let f=n.start;n.end>f;f++){const n=p[f],w=Dn(n,f,g,y,m),L=Pn(n,i,a),D=a&&a.size>0&&a.has(n.label);v.push(t("g",{transform:`translate(${h},${u*k})`,onClick:o?()=>o(n):void 0,onMouseEnter:r?()=>r(n):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:S?c===l&&f===s?0:-1:void 0,role:S?"option":void 0,"aria-selected":S&&A?D||!1:void 0,"aria-current":S&&!A&&null!=i&&n.label===i||void 0,"aria-label":n.label,onKeyDown:S?e=>{var t;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(n)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const n=(f+("ArrowRight"===e.key?1:-1)+p.length)%p.length;d(c,n);const o=null===(t=e.currentTarget.parentElement)||void 0===t?void 0:t.children[n];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:S?e=>{d(c,f),r&&r(n);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","visible")}:void 0,onBlur:S?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:S?"pointer":"default",opacity:L,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[S&&e("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+b+2+7*n.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),w,D&&e(On,{swatchSize:m}),e("text",{y:m/2,x:m+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+f)),h+=M[f]+x}});const P=Math.max(0,...L.map(e=>e.width)),E=L.length;return{items:v,offset:P,totalRows:E,totalHeight:E*k}})(n,i,a,l,s,c,d,o,u,h,f,null!==(g=f.maxWidth)&&void 0!==g?g:r);v+=m.offset+5,p.push(Object.assign(Object.assign({label:n.label},m),{offset:v,totalRows:m.totalRows,totalHeight:m.totalHeight})),y+=v+12});const v=null!==(g=f.maxWidth)&&void 0!==g?g:r;let m=y>v?0:"center"===f.align?Math.max(0,(v-y)/2):"end"===f.align?Math.max(0,v-y):0;const b=[];return p.forEach((t,r)=>{const i=n[r];i.label&&(b.push(e("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+r)),m+=16),b.push(e("g",{className:"legend-item",transform:`translate(${m},0)`,children:t.items},"legend-group-"+r)),m+=t.offset+5,n[r+1]&&b.push(e("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(t.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+r)),m+=12}),e("g",{children:b})})({legendGroups:r||[],title:d,height:h,width:u,customClickBehavior:i,customHoverBehavior:a,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:p,focusedItemIndex:m,onFocusedIndexChange:x,legendInteraction:c,metrics:y}),w=!(!i&&!a);return t("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"isolate"!==c&&(void 0!==c||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==d&&""!==d&&"vertical"===f&&e("text",{className:"legend-title",y:16,x:u/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:d}),k]})}function In(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function Cn(e){return"object"==typeof e&&null!==e&&"gradient"in e}function _n(t){var n;const{legend:o,totalWidth:r,totalHeight:i,margin:a,legendPosition:l="right",legendLayout:s,title:c,legendHoverBehavior:d,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=t;if(!o)return null;const y="top"===l||"bottom"===l,p=!!c,v=Math.max(1,y?null!==(n=null==s?void 0:s.maxWidth)&&void 0!==n?n:Math.max(0,r-a.left-a.right):100);let m,b;return"left"===l?(m=Math.max(4,a.left-v-10),b=a.top):"top"===l?(m=a.left,b=p?32:8):"bottom"===l?(m=a.left,b=i-a.bottom+38):(m=r-a.right+10,b=a.top),e("g",{transform:`translate(${m}, ${b})`,children:Cn(o)?e(Tn,{config:o.gradient,orientation:y?"horizontal":"vertical",width:v}):In(o)?e(Nn,{legendGroups:o.legendGroups,title:"",width:v,orientation:y?"horizontal":"vertical",legendLayout:s,customHoverBehavior:d,customClickBehavior:u,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}const jn={secondary:0,primary:3},Wn=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function $n(e){return!0===(null==e?void 0:e._annotationDeferred)}function Bn(e){return"blended"===(null==e?void 0:e.cohesion)||"layer"===(null==e?void 0:e.cohesion)?e.cohesion:null}function zn(e){var t;const n=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function Rn(e){return Math.max(.72,.95-.06*e)}function Hn(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Fn(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Yn(e){return null==e?null:e+""}function Xn(e,t,n){var o;return null===(o=t.stickyPositionCache)||void 0===o||o.set(e,n),n}const Gn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function qn(e){return!!e&&"object"==typeof e&&Gn.has(function(e){return"string"==typeof(null==e?void 0:e.type)?e.type:""}(e))}function Vn(e){return"primary"===(null==e?void 0:e.emphasis)||!0===(null==e?void 0:e.defensive)}function Kn(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Zn(e){var t,n;let o;const r=null==e?void 0:e.emphasis;o="primary"===r?100:"secondary"===r?10:50;const i=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(o+=15*function(e){return Math.max(0,Math.min(1,e))}(i)),null===(n=null==e?void 0:e.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}new Set(["label","callout","callout-circle","callout-rect"]);const Un=32,Qn=6,Jn=4,eo=8,to=72;const no={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function oo(e){return qn(e)}function ro(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function io(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function ao(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function lo(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function so(e,t,n,o,r,i,a,l){const s=ao(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(s,r,i,l);for(const e of n)c+=12*lo(s,e);for(const e of o)c+=4*lo(s,e);return c}function co(e,t,n){var o,r;if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const i=null!==(o=e.pointId)&&void 0!==o?o:e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const a=e.coordinates,l=null===(r=n.scales)||void 0===r?void 0:r.geoProjection;if(Array.isArray(a)&&a.length>=2&&l){const e=a[0],t=a[1];if("number"==typeof e&&"number"==typeof t){const n=l([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?function(e,t,n){var o,r;const i=e.anchor||(null===(o=e.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return Xn(t,n,{x:r.x,y:r.y})}const o=function(e){var t,n,o,r,i,a;const l=e.data;if(!l||0===l.length)return null;const s=l[l.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,d=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!d)return null;const u=s[e.xAccessor||"x"],h=s[e.yAccessor||"y"];return null==u||null==h?null:{x:c(u),y:d(h)}}(n);return o?Xn(t,n,o):null}if("semantic"===i){const o=function(e,t,n){var o,r;const i=function(e){var t,n;return Yn(null!==(n=null===(t=e.provenance)||void 0===t?void 0:t.stableId)&&void 0!==n?n:e.stableId)}(e);if(!i)return null;const a=null===(o=n.pointNodes)||void 0===o?void 0:o.find(e=>Yn(e.pointId)===i);if(a)return Xn(t,n,{x:a.x,y:a.y});const l=null===(r=n.data)||void 0===r?void 0:r.find(e=>function(e){var t,n,o;return Yn(null!==(n=null!==(t=e.stableId)&&void 0!==t?t:e.id)&&void 0!==n?n:null===(o=e.provenance)||void 0===o?void 0:o.stableId)}(e)===i);if(!l)return null;const s=Hn(l,n),c=Fn(l,n);return null==s||null==c?null:Xn(t,n,{x:s,y:c})}(e,t,n);if(o)return o}let a=null,l=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(a=t.x,l=t.y)}if(null!=a&&null!=l||(a=Hn(e,n),l=Fn(e,n)),null!=a&&null!=l)return Xn(t,n,{x:a,y:l});if("sticky"===i){const e=null===(r=n.stickyPositionCache)||void 0===r?void 0:r.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function uo(e){var t;const{annotations:n,context:o,defaultOffset:r=Un,notePadding:i=Qn,markPadding:a=Jn,edgePadding:l=eo,preserveManualOffsets:s=!0,routeLongConnectors:c=!0,connectorThreshold:d=to,density:u,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:y,audience:p}=e,v=o.width||0,m=o.height||0;if(0===n.length||0>=v||0>=m)return n.slice();const b=[],x=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(o,a);let k=!1;const w=n.map((e,t)=>{if(!oo(e))return e;const n=co(e,t,o);if(!n)return e;const a=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...ro("string"==typeof e.title?e.title:void 0,t),...ro("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(s&&("number"==typeof(u=e).dx||"number"==typeof u.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return b.push(ao(io(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,a),i)),e}var u;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=so(io(n.x,n.y,e.dx,e.dy,a),e,b,x,v,m,i,l);f>t&&(h=e,f=t)}if(!h)return e;const g=ao(io(n.x,n.y,h.dx,h.dy,a),i);b.push(g);const y=Math.hypot(h.dx,h.dy),p=c&&y>=d&&"text"!==e.type&&"widget"!==e.type?Object.assign(Object.assign({},e.connector||{end:"arrow"}),{type:"curve"}):e.connector;return k=!0,Object.assign(Object.assign(Object.assign({},e),{dx:h.dx,dy:h.dy}),p?{connector:p}:{})}),S=k?w:n.slice();let A=S;if(f){let e=!1;const t=S.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:Object.assign(Object.assign({},e),{_redundantConnector:!0})}(t);return n!==t&&(e=!0),n});A=e?t:S}{let e=!1;const t=A.map(t=>{if(!0!==(null==t?void 0:t.defensive))return t;const n=function(e){var t;const n=null==e?void 0:e.provenance;if(!n||"object"!=typeof n)return e;const o="string"==typeof n.source?null!==(t=no[n.source])&&void 0!==t?t:n.source:null,r="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const i=[o,r].filter(Boolean).join(" · "),a="string"==typeof e.label?e.label:"";return a.includes(`(${i})`)?e:Object.assign(Object.assign({},e),{label:a?`${a} (${i})`:`(${i})`})}(t);return n!==t&&(e=!0),n});A=e?t:A}const M=new Set;if(u){const e="object"==typeof u?u:{},n=function(e){if(!e)return 1;const t=function(e){const t=null==e?void 0:e.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(p),o=1===n?e:Object.assign(Object.assign({},e),{maxAnnotations:Math.max(0,Math.round((null!==(t=e.maxAnnotations)&&void 0!==t?t:Kn(v,m,e))*n))}),{deferred:r}=function(e){var t;const{annotations:n,width:o,height:r}=e,i=Math.max(0,null!==(t=e.minVisible)&&void 0!==t?t:1),a=Kn(o,r,e),l=n.map((e,t)=>{return{annotation:e,index:t,note:(n=e,qn(n))};var n}),s=l.filter(e=>e.note);if(0===s.length||a>=s.length)return{visible:n.slice(),deferred:[],budget:a};const c=s.filter(e=>Vn(e.annotation)),d=s.filter(e=>!Vn(e.annotation)).sort((e,t)=>Zn(t.annotation)-Zn(e.annotation)||e.index-t.index),u=Math.min(d.length,Math.max(Math.max(0,a-c.length),Math.max(0,i-c.length))),h=new Set([...c.map(e=>e.index),...d.slice(0,u).map(e=>e.index)]),f=[],g=[];for(const{annotation:e,index:t,note:n}of l)!n||h.has(t)?f.push(e):g.push(e);return{visible:f,deferred:g,budget:a}}(Object.assign({annotations:A,width:v,height:m},o));for(const e of r)M.add(e)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=v)for(const e of A)oo(e)&&"secondary"===e.emphasis&&M.add(e);if(M.size>0)for(const e of A)!0===(null==e?void 0:e.defensive)&&M.delete(e);let L;return L=0===M.size?A:h?A.map(e=>M.has(e)?Object.assign(Object.assign({},e),{_annotationDeferred:!0}):e):A.filter(e=>!M.has(e)),y?function(e,t){let n=!1;const o=e.map(e=>oo(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,Object.assign(Object.assign({},e),{cohesion:t})):e);return n?o:e}(L,y):L}function ho(r){const{width:i,height:a,totalWidth:l,totalHeight:s,margin:c,labels:d,title:u,legend:h,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p,legendPosition:v="right",legendLayout:m,foregroundGraphics:b,sceneNodes:x,annotations:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=r,A=o.useMemo(()=>{const e=(x||[]).flatMap(e=>{const t=function(e){var t,n,o,r;const i=null!==(t=e.cx)&&void 0!==t?t:null!=e.x&&null!=e.w?e.x+e.w/2:e.x,a=null!==(n=e.cy)&&void 0!==n?n:null!=e.y&&null!=e.h?e.y+e.h/2:e.y;return"number"!=typeof i||"number"!=typeof a?null:{x:i,y:a,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):Math.max(1,null!==(o=e.w)&&void 0!==o?o:0,null!==(r=e.h)&&void 0!==r?r:0)/2}}(e),n=function(e){var t,n,o,r,i,a,l,s;const c=null!==(a=null!==(o=null!==(t=e.id)&&void 0!==t?t:null===(n=e.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:null===(i=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===i?void 0:i.id)&&void 0!==a?a:null===(s=null===(l=e.datum)||void 0===l?void 0:l.data)||void 0===s?void 0:s.name;return null==c?void 0:c+""}(e);return t?[Object.assign({pointId:n},t)]:[]});return{scales:null,width:i,height:a,frameType:"network",pointNodes:e,sceneNodes:x}},[a,x,i]),M=o.useMemo(()=>k&&w?uo(Object.assign({annotations:k,context:A},"object"==typeof w?w:{})):k,[k,w,A]),L=M?function(t){const n=t.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:zn(e.annotation),readingOrder:null,rank:1};var n}),o=n.some(e=>null!=e.emphasis||null!=e.confidence),r=t.some(e=>$n(e.annotation)),i=t.some(e=>null!=Bn(e.annotation)),a=t.some(e=>"layer"===Bn(e.annotation));if(!o&&!r&&!i)return t.map(e=>e.node);const l=n.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>{var n,o;return(null!==(n=t.confidence)&&void 0!==n?n:0)-(null!==(o=e.confidence)&&void 0!==o?o:0)||e.i-t.i});l.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,l.length)});for(const e of n)e.emphasis&&(e.rank=jn[e.emphasis]);const s=n.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(t=>{const{p:n,i:o,emphasis:r,readingOrder:i}=t,a=$n(n.annotation);let l=n.node;if("primary"===r||"secondary"===r||null!=i){const t=null==r&&null!=i;l=e("g",Object.assign({className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r},"secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},t?{opacity:Rn(i),"data-annotation-reading-order":i}:{},{children:n.node}),"annotation-emphasis-"+o)}const s=Bn(n.annotation);return s&&(l=e("g",{className:"annotation-cohesion--"+s,children:l},"annotation-cohesion-"+o)),a&&(l=e("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:l},"annotation-deferred-"+o)),l});return r&&s.unshift(e("style",{children:Wn},"annotation-disclosure-style")),a&&s.unshift(e("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(M.reduce((t,n,r)=>{if("widget"===n.type||!S)return t;const i=S(n,r,A);return i&&t.push({node:e(o.Fragment,{children:i},"annotation-"+r),annotation:n}),t},[])):null,D=!0===(null==M?void 0:M.some(e=>"widget"===e.type&&!0===e._annotationDeferred));return t(n,{children:[D&&e("style",{children:Wn},"annotation-widget-disclosure-style"),t("svg",{role:"img",width:l,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e("title",{children:"string"==typeof u?u:"Network Chart"}),e("desc",{children:"string"==typeof u?u+" — network data visualization":"Network data visualization"}),t("g",{transform:`translate(${c.left},${c.top})`,children:[d.map((t,n)=>e("text",{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"},children:t.text},"label-"+n)),L,b]}),u&&"string"==typeof u?e("text",{x:l/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:u}):u?e("foreignObject",{x:0,y:0,width:l,height:c.top,children:u}):null,_n({legend:h,totalWidth:l,totalHeight:s,margin:c,legendPosition:v,title:u,legendLayout:m,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:y,legendIsolatedCategories:p})]}),null==M?void 0:M.filter(e=>"widget"===e.type&&e.nodeId&&x).map((t,n)=>{var o,r,i,a,l,s,d,u,h;const f=!0===t._annotationDeferred,g=x.find(e=>{var n,o,r,i,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(r=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.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(!g)return null;const y=c.left+(null!==(o=g.cx)&&void 0!==o?o:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(r=g.x)&&void 0!==r?r:0),p=c.top+(null!==(i=g.cy)&&void 0!==i?i:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(a=g.y)&&void 0!==a?a:0),v=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(s=t.dy)&&void 0!==s?s:-16,b=null!==(d=t.width)&&void 0!==d?d:32,k=null!==(u=t.height)&&void 0!==u?u:32,w=null!==(h=t.content)&&void 0!==h?h:e("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e("div",{className:f?"annotation-deferred":void 0,"data-annotation-disclosure":f?"deferred":void 0,style:{position:"absolute",left:y+v-b/2,top:p+m-k/2,width:b,height:k,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:w},"widget-"+n)})]})}ho.displayName="NetworkSVGOverlay";const fo={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function go(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const yo="undefined"==typeof window||"undefined"==typeof document,po="undefined"!=typeof window?h:u,vo=()=>()=>{},mo=()=>!1,bo=()=>!0;function xo(e){const t=r(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return wo(e,t);if(!So(e)||!So(t))return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!wo(n,r))return!1}else{if(!So(n)||!So(r))return!1;if(!ko(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function ko(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function wo(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function So(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}const Ao=o.createContext(null),Mo={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Lo(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}const Do=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Oo="semiotic-accessible-data-table",Po=Oo+" semiotic-accessible-data-table-hidden",Eo=Oo+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",To={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},No={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Io={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Co={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},_o={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},jo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Wo={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #999))",marginBottom:4,fontStyle:"italic"},$o={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Bo({nodes:n,edges:r,chartType:i,tableId:a,chartTitle:l}){var s,c,d,u,h,f,g,y,p,v,m,b,x,k;const[w,S]=o.useState(!1),[A,M]=o.useState(5),L=o.useContext(Ao),D=null!==(s=null==L?void 0:L.visible)&&void 0!==s&&s,O=w||D,P=l?"Data summary for "+l:a?`Data summary for ${i} ${a}`:"Data summary for "+i,E=o.useRef(null);o.useEffect(()=>{O||M(5)},[O]);const T=o.useCallback(e=>{e.target===e.currentTarget&&(w||D||S(!0))},[w,D]),N=o.useCallback(e=>{var t;D||(null===(t=E.current)||void 0===t?void 0:t.contains(e.relatedTarget))||S(!1)},[D]);if(!n||0===n.length)return a?e("span",{id:a,tabIndex:-1,style:Mo}):null;if(!O)return e("div",{id:a,className:Po,tabIndex:-1,onFocus:T,style:Mo,role:"region","aria-label":P,children:t("button",{type:"button",onClick:()=>S(!0),children:["View data summary (",n.length," nodes, ",r.length," edges)"]})});const I=Array.isArray(n)?n:[],C=Array.isArray(r)?r:[],_=new Map,j=new Map,W=new Map,$=new Map;for(const e of C){if(!e||"object"!=typeof e)continue;const t=null!==(c=e.datum)&&void 0!==c?c:e,n="object"==typeof t.source?null===(d=t.source)||void 0===d?void 0:d.id:t.source,o="object"==typeof t.target?null===(u=t.target)||void 0===u?void 0:u.id:t.target,r="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";j.set(e,(null!==(h=j.get(e))&&void 0!==h?h:0)+1),$.set(e,(null!==(f=$.get(e))&&void 0!==f?f:0)+r)}if(null!=o&&""!==o){const e=o+"";_.set(e,(null!==(g=_.get(e))&&void 0!==g?g:0)+1),W.set(e,(null!==(y=W.get(e))&&void 0!==y?y:0)+r)}}const B=[];for(let e=0;I.length>e;e++){const t=I[e];if(!t||"object"!=typeof t)continue;const n=null!==(v=null===(p=t.datum)||void 0===p?void 0:p.id)&&void 0!==v?v:t.id,o=null!=n?n+"":"node-"+e,r=null!==(m=_.get(o))&&void 0!==m?m:0,i=null!==(b=j.get(o))&&void 0!==b?b:0,a=null!==(x=W.get(o))&&void 0!==x?x:0,l=null!==(k=$.get(o))&&void 0!==k?k:0;B.push({id:o,degree:r+i,inDeg:r,outDeg:i,wDegree:a+l,wInDeg:a,wOutDeg:l})}B.sort((e,t)=>t.degree-e.degree);let z=0,R=0;if(B.length>0){let e=0;for(const t of B)e+=t.degree,t.degree>R&&(R=t.degree);z=e/B.length}const H=C.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),F=[`${B.length} nodes, ${C.length} edges.`];B.length>0&&F.push(`Mean degree: ${Do(z)}, max degree: ${R}.`);const Y=Math.min(A,B.length),X=B.slice(0,Y),G=B.length-Y;return t("div",{ref:E,id:a,className:Eo,tabIndex:-1,onBlur:N,style:To,role:"region","aria-label":P,children:[e("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{D&&L&&L.setVisible(!1),S(!1)},"aria-label":"Close data summary",style:Io,children:"×"}),e("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:No,children:F.join(" ")}),t("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+i,style:Co,children:[e("caption",{className:"semiotic-accessible-data-table-caption",style:Wo,children:G>0?`Top ${Y} of ${B.length} nodes by degree`:`All ${B.length} nodes by degree`}),e("thead",{children:t("tr",{children:[e("th",{style:_o,children:"id"}),e("th",{style:_o,children:"degree"}),e("th",{style:_o,children:"in"}),e("th",{style:_o,children:"out"}),H&&e("th",{style:_o,children:"w. degree"}),H&&e("th",{style:_o,children:"w. in"}),H&&e("th",{style:_o,children:"w. out"})]})}),e("tbody",{children:X.map((n,o)=>t("tr",{children:[e("td",{style:jo,children:n.id}),e("td",{style:jo,children:n.degree}),e("td",{style:jo,children:n.inDeg}),e("td",{style:jo,children:n.outDeg}),H&&e("td",{style:jo,children:Do(n.wDegree)}),H&&e("td",{style:jo,children:Do(n.wInDeg)}),H&&e("td",{style:jo,children:Do(n.wOutDeg)})]},o))})]}),G>0&&t("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>M(e=>e+25),style:$o,children:["Show ",Math.min(25,G)," more"," ",1===G?"node":"nodes"," (",G," remaining)"]})]})}function zo({summary:t}){return t?e("div",{role:"note",style:Mo,children:t}):null}function Ro({tableId:t}){return e("a",{href:"#"+t,style:Mo,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Mo)},children:"Skip to data table"})}function Ho({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+e}return e("div",{"aria-live":"polite","aria-atomic":"true",style:Mo,children:n})}const Fo=Object.freeze([]);function Yo(e){if(!e)return Fo;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function Xo(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Go(e,t,n=.3){Xo(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function qo(e,t,n=.6){var o,r,i,a,l;if(!Xo(t))return;const s=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+s*t._pulseIntensity,d=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,u=null!==(l=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==l?l:0;e.beginPath(),e.arc(d,u,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Vo(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Ko(e,t){var n,o,r,i,a,l;if(!t.pathD)return;e.save();const s=Vo(t);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,l="string"==typeof t.style.fill?t.style.fill:"#999",s=wn(e,l)||l;r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(s)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(l=t.style.opacity)&&void 0!==l?l:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(s)),e.restore()}function Zo(e,t){var n,o;e.save();const r=t.style.stroke||"#999";e.strokeStyle=wn(e,r)||r,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n: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!==(o=t.style.strokeWidth)&&void 0!==o?o: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 Uo(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=Vo(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.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 Qo(e,t){var n,o;if(!t.pathD)return;e.save();const r=Vo(t),i=t.style.stroke||"#999";e.strokeStyle=wn(e,i)||i,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}const Jo={top:20,right:80,bottom:20,left:80},er={top:40,right:40,bottom:40,left:40},tr=new Set(["chord","force","circlepack","orbit"]),nr=[800,600],or={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 rr({data:n}){var o,r,i,a,l,s;if("edge"===n.nodeOrEdge){const e=n.data;return e?t("div",{className:"semiotic-tooltip",style:or,children:[t("div",{style:{fontWeight:600},children:["object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target]}),null!=e.value&&t("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]})]}):null}const c=n.data;if(!c)return null;const d=c.__hierarchyNode;if(d){const n=[];let l=d;for(;l;){const e=null!==(a=null!==(r=null===(o=l.data)||void 0===o?void 0:o.name)&&void 0!==r?r:null===(i=l.data)||void 0===i?void 0:i.id)&&void 0!==a?a:c.id;null!=e&&n.unshift(e+""),l=l.parent}n.length>1&&n.shift();const s=n.length-1;return t("div",{className:"semiotic-tooltip",style:or,children:[e("div",{children:n.map((n,o)=>t("span",{children:[o>0&&e("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),o===s?e("strong",{children:n}):e("span",{style:{opacity:.7},children:n})]},o))}),null!=c.value&&c.value>0&&e("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const u=((null===(l=c.sourceLinks)||void 0===l?void 0:l.length)||0)+((null===(s=c.targetLinks)||void 0===s?void 0:s.length)||0),h=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return t("div",{className:"semiotic-tooltip",style:or,children:[e("div",{style:{fontWeight:600},children:c.id}),null!=c.value&&c.value>0&&t("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),u>0&&t("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,h!==u&&` (weighted: ${h.toLocaleString()})`]})]})}rr.ownsChrome=!0;const ir=f(function(n,o){var a,c,h,f,y,p,v,m,b,x,k,w,S,A,M,L,D,O;const{chartType:P,nodes:E,edges:T,data:N,initialEdges:I,nodeIDAccessor:_="id",sourceAccessor:j="source",targetAccessor:W="target",valueAccessor:$="value",edgeIdAccessor:B,childrenAccessor:z,hierarchySum:R,orientation:H="horizontal",nodeAlign:F="justify",nodePaddingRatio:q=.05,nodeWidth:V=15,iterations:K=300,forceStrength:Z=.1,padAngle:U=.01,groupWidth:Q=20,sortGroups:J,edgeSort:ee,treeOrientation:te="vertical",edgeType:ne="curve",padding:oe,paddingTop:re,tensionConfig:ie,showParticles:ae=!1,particleStyle:le,nodeStyle:se,edgeStyle:ce,colorBy:de,colorScheme:ue="category10",edgeColorBy:he="source",edgeOpacity:fe=.5,colorByDepth:ge=!1,nodeSize:ye=8,nodeSizeRange:pe=[5,20],nodeLabel:ve,showLabels:me=!0,labelMode:be,size:xe=nr,responsiveWidth:ke,responsiveHeight:we,margin:Se,className:Ae,background:Me,enableHover:Le=!0,tooltipContent:De,customHoverBehavior:Oe,customClickBehavior:Pe,onObservation:Ee,chartId:Te,onTopologyChange:Ne,annotations:Ie,autoPlaceAnnotations:Ce,svgAnnotationRules:_e,legend:je,legendPosition:We,legendLayout:$e,legendHoverBehavior:Be,legendClickBehavior:ze,legendHighlightedCategory:Re,legendIsolatedCategories:He,title:Fe,foregroundGraphics:Ye,backgroundGraphics:Xe,decay:Ge,pulse:qe,transition:Ve,animate:Ke,staleness:Ze,thresholds:Ue,accessibleTable:Qe=!0,description:Je,summary:et,orbitMode:tt,orbitSize:nt,orbitSpeed:ot,orbitRevolution:rt,orbitRevolutionStyle:it,orbitEccentricity:at,orbitShowRings:lt,orbitAnimated:st,customNetworkLayout:ct,layoutConfig:dt}=n,ut=tr.has(P)?er:Jo,ht=r(!0),ft=Mn({sizeProp:xe,responsiveWidth:ke,responsiveHeight:we,userMargin:Se,marginDefault:ut,foregroundGraphics:Ye,backgroundGraphics:Xe,animate:Ke,transitionProp:Ve,themeDirtyRef:ht}),{reducedMotionRef:gt,responsiveRef:yt,size:pt,margin:vt,adjustedWidth:mt,adjustedHeight:bt,resolvedForeground:xt,resolvedBackground:kt,transition:wt,introEnabled:St,tableId:Mt,rafRef:Lt,renderFnRef:Dt,scheduleRender:Ot,currentTheme:Pt}=ft,Et=function(){const[e,t]=d(!1);return po(()=>{t(!0)},[]),e}(),Tt=function(){const e=s(vo,mo,bo);return r(e).current}(),Nt=i(()=>Yo(E),[E]),Ct=i(()=>Array.isArray(T)?Yo(T):T,[T]),_t=i(()=>Object.assign(Object.assign({},X),ie),[ie]),jt=i(()=>Object.assign(Object.assign({},G),le),[le]),$t=i(()=>{var e;return{chartType:P,nodeIDAccessor:_,sourceAccessor:j,targetAccessor:W,valueAccessor:$,edgeIdAccessor:B,childrenAccessor:z,hierarchySum:R,orientation:H,nodeAlign:F,nodePaddingRatio:q,nodeWidth:V,iterations:K,forceStrength:Z,padAngle:U,groupWidth:Q,sortGroups:J,edgeSort:ee,treeOrientation:te,edgeType:ne,padding:oe,paddingTop:re,tensionConfig:_t,showParticles:ae,particleStyle:jt,nodeStyle:se,edgeStyle:ce,nodeLabel:ve,showLabels:me,labelMode:be,colorBy:de,colorScheme:ue,themeCategorical:null===(e=null==Pt?void 0:Pt.colors)||void 0===e?void 0:e.categorical,themeSemantic:an(Pt),edgeColorBy:he,edgeOpacity:fe,colorByDepth:ge,nodeSize:ye,nodeSizeRange:pe,decay:Ge,pulse:qe,transition:wt,introAnimation:St,staleness:Ze,thresholds:Ue,orbitMode:tt,orbitSize:nt,orbitSpeed:ot,orbitRevolution:rt,orbitRevolutionStyle:it,orbitEccentricity:at,orbitShowRings:lt,orbitAnimated:st,customNetworkLayout:ct,layoutConfig:dt}},[P,_,j,W,$,z,R,H,F,q,V,K,Z,U,Q,J,ee,te,ne,oe,re,_t,ae,jt,se,ce,ve,me,be,de,ue,he,fe,ge,ye,pe,Ge,qe,null==wt?void 0:wt.duration,null==wt?void 0:wt.easing,St,Ze,Ue,tt,nt,ot,rt,it,at,lt,st,Pt,ct,dt]),zt=xo($t),Rt=xo({chartType:P,nodeIDAccessor:_,sourceAccessor:j,targetAccessor:W,valueAccessor:$,childrenAccessor:z,hierarchySum:R,orientation:H,nodeAlign:F,nodePaddingRatio:q,nodeWidth:V,iterations:K,forceStrength:Z,padAngle:U,groupWidth:Q,sortGroups:J,edgeSort:ee,treeOrientation:te,edgeType:ne,padding:oe,paddingTop:re,tensionConfig:_t,orbitMode:tt,orbitSize:nt,orbitEccentricity:at,customNetworkLayout:ct,layoutConfig:dt}),Ht=r(null),Ft=r(0),Yt=r(0),Xt=r(!1),qt=r(null);qt.current||(qt.current=new It(zt));const[Kt,Ut]=d(null),[Qt,Jt]=d(0),[en,tn]=d(0),[on,rn]=d(!1),[ln,sn]=d(null),cn=r(null),dn=r(new Map),un=r(0),hn=l(e=>{if("function"==typeof de)return de(e)+"";if("string"==typeof de&&e.data){const t=e.data[de];if(void 0!==t){if(!dn.current.has(t+"")){const e=Array.isArray(ue)?ue:At;dn.current.set(t+"",e[un.current++%e.length])}return dn.current.get(t+"")}}if(dn.current.has(e.id))return dn.current.get(e.id);const t=Array.isArray(ue)?ue:At,n=de?t[un.current++%t.length]:t[0];return dn.current.set(e.id,n),n},[de,ue]),fn=(null===(a=null==Pt?void 0:Pt.colors)||void 0===a?void 0:a.border)||(null===(c=null==Pt?void 0:Pt.colors)||void 0===c?void 0:c.secondary)||(null===(h=null==Pt?void 0:Pt.colors)||void 0===h?void 0:h.primary)||"#999",gn=l(e=>{var t,n;return e?"object"==typeof e?e:null!==(n=null===(t=qt.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==n?n:null:null},[]),yn=l(e=>{if("function"==typeof he)return he(e);const t=gn(e.source),n=gn(e.target);return"target"===he&&n?hn(n):t?hn(t):fn},[he,hn,fn,gn]),pn=l(e=>{if("function"==typeof jt.color){const t=gn(e.source);return t?jt.color(e,t):fn}if(!(null==le?void 0:le.colorBy))return yn(e);const t=jt.colorBy,n=gn(e.source),o=gn(e.target);return"target"===t&&o?hn(o):n?hn(n):fn},[null==le?void 0:le.colorBy,jt.color,jt.colorBy,hn,yn,fn,gn]),vn=("sankey"===P||!!ct)&&ae||!!qe||null!==(y=null===(f=qt.current)||void 0===f?void 0:f.isAnimating)&&void 0!==y&&y;u(()=>{var e;null===(e=qt.current)||void 0===e||e.updateConfig(zt),ht.current=!0,Ot()},[zt,Ot]);const mn=l(()=>{var e,t;sn(null!==(t=null===(e=qt.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);u(()=>{var e;const t=qt.current;if(t){t.buildScene([mt,bt]),mn();for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&dn.current.set(n.id,n.style.fill);ht.current=!0,Ot()}},[Pt,mt,bt,Ot,mn]);const bn=l(()=>{var e;const t=qt.current;if(!t)return;t.runLayout([mt,bt]),t.buildScene([mt,bt]),mn(),ht.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&dn.current.set(n.id,n.style.fill);const n=Array.isArray(ue)?ue:At,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];dn.current.has(t.id)||dn.current.set(t.id,n[e%n.length])}if(un.current=o.length,Jt(t.layoutVersion),Ne){const{nodes:e,edges:n}=t.getLayoutData();Ne(e,n)}},[mt,bt,Ne,ue,mn]),xn=l(e=>{if(null==e||"object"!=typeof e)return;const t=qt.current;t&&(t.ingestEdge(e)&&bn(),Ot())},[bn,Ot]),kn=l(e=>{const t=qt.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&bn(),Ot()},[bn,Ot]),Sn=l(()=>{var e;null===(e=qt.current)||void 0===e||e.clear(),dn.current.clear(),un.current=0,Jt(0),Ut(null),cn.current=null,ht.current=!0,Ot()},[Ot]),An=l(()=>{const e=qt.current;e&&(e.tension+=999,bn(),Ot())},[bn,Ot]);g(o,()=>({push:xn,pushMany:kn,removeNode:e=>{var t,n,o;const r=null!==(n=null===(t=qt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(r){const t=(null===(o=cn.current)||void 0===o?void 0:o.data)?"function"==typeof _?_(cn.current.data):cn.current.data[_]:void 0;cn.current&&"node"===cn.current.nodeOrEdge&&t===e&&(cn.current=null,Ut(null)),dn.current.delete(e),bn(),ht.current=!0,Ot()}return r},removeEdge:(e,t)=>{var n,o;const r=null!==(o=null===(n=qt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==o&&o;if(r){if(cn.current&&"edge"===cn.current.nodeOrEdge){const n=cn.current.data;let o;o=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!B||!n||("function"==typeof B?B:e=>null==e?void 0:e[B])(n)===e,o&&(cn.current=null,Ut(null))}bn(),ht.current=!0,Ot()}return r},updateNode:(e,t)=>{var n,o;const r=null!==(o=null===(n=qt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==o?o:null;return r&&(ht.current=!0,Ot()),r},updateEdge:(e,t,n)=>{var o,r;const i=null!==(r=null===(o=qt.current)||void 0===o?void 0:o.updateEdge(e,t,n))&&void 0!==r?r:[];return i.length>0&&(bn(),ht.current=!0,Ot()),i},clear:Sn,getTopology:()=>{var e,t;return null!==(t=null===(e=qt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=qt.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:An,getTension:()=>{var e,t;return null!==(t=null===(e=qt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[xn,kn,Sn,An,bn,Ot]);const Ln=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),Dn=Ln?N||(Array.isArray(T)?void 0:T):void 0;u(()=>{var e;const t=qt.current;if(t)if(Ln&&Dn)t.ingestHierarchy(Dn,[mt,bt]),t.buildScene([mt,bt]),mn(),ht.current=!0,Ot();else{const n=Nt,o=Array.isArray(Ct)?Ct:[];if(0===n.length&&0===o.length)return;t.ingestBounded(n,o,[mt,bt]),t.buildScene([mt,bt]),mn();for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&dn.current.set(n.id,n.style.fill+"");const r=Array.isArray(ue)?ue:At,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];dn.current.has(t.id)||dn.current.set(t.id,r[e%r.length])}un.current=i.length,ht.current=!0,Ot()}},[Nt,Ct,N,Dn,Ln,mt,bt,Rt,Ot,ue,mn]),u(()=>{I&&I.length>0&&kn(I)},[]);const On=l(e=>{if(Oe&&Oe(e),Ee){const t=Date.now();Ee(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Te}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Te})}},[Oe,Ee,Te]),Pn=l(e=>{if(Pe&&Pe(e),Ee){const t=Date.now();Ee(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Te}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Te})}},[Pe,Ee,Te]),{hoverHandlerRef:En,hoverLeaveRef:Tn,onPointerMove:Nn,onPointerLeave:In}=ft;En.current=e=>{if(!Le)return;const t=Ht.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-vt.left,r=e.clientY-n.top-vt.top;if(0>o||o>mt||0>r||r>bt)return void(cn.current&&(cn.current=null,Ut(null),On&&(On(null),ht.current=!0),Ot()));const i=qt.current;if(!i)return;const a=Bt(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(cn.current&&(cn.current=null,Ut(null),On&&(On(null),ht.current=!0),Ot()));const l=Y(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});cn.current=l,Ut(l),On&&(On(l),ht.current=!0),Ot()},Tn.current=()=>{cn.current&&(cn.current=null,Ut(null),On&&(On(null),ht.current=!0),Ot())};const Cn=r(()=>{});Cn.current=e=>{if(!Pe&&!Ee)return;const t=Ht.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-vt.left,r=e.clientY-n.top-vt.top;if(0>o||o>mt||0>r||r>bt)return;const i=qt.current;if(!i)return;const a=Bt(i.sceneNodes,i.sceneEdges,o,r);Pn(a?Y(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)};const _n=l(e=>Cn.current(e),[]),jn=r(-1),Wn=r(null),$n=r(-1),Bn=l(e=>{var t;const n=qt.current;if(!n)return;const o=function(e){var t,n,o,r,i,a;const l=[];for(const s of e)if("circle"===s.type&&null!=s.cx){if(0>=s.r)continue;l.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(t=s.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"})}else if("rect"===s.type&&null!=s.x){if(0>=s.w||0>=s.h)continue;l.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(r=null===(o=s.datum)||void 0===o?void 0:o.id)&&void 0!==r?r:"_default"})}else"arc"===s.type&&null!=s.cx&&l.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(a=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return l.sort((e,t)=>e.x-t.x||e.y-t.y),l}(n.sceneNodes);if(0===o.length)return;const r=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:a}}(o),i=jn.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),jn.current=0,$n.current=-1;const t=r.flat[0];Wn.current={shape:t.shape,w:t.w,h:t.h};const n=Y(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return cn.current=n,Ut(n),On&&(On(n),ht.current=!0),void Ot()}const a=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}(r,i),l=function(e,t,n,o,r){var i,a,l;const s=n.flat[t.flatIndex];if(!s)return Gt(e,t,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=null!==(a=function(e,t,n){let o=null,r=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const l=a.x-t.x,s=a.y-t.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(l)}if(!c)continue;const d=l*l+s*s;r>d&&(r=d,o=i)}return o}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n;const o=e+"",r=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,i=Vt(t.source),a=Vt(t.target),l=null!=i,s=null!=a;l&&i+""===o&&s?r.push(a+""):s&&a+""===o&&l&&r.push(i+"")}return r}(c,o);if(0===e.length)return t.flatIndex;const i=null!==(l=n.idToIdx.get(e[(r.current+1)%e.length]))&&void 0!==l?l:-1;return 0>i?t.flatIndex:(r.current=-1,i)}default:{const o=Gt(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,a,r,null!==(t=n.sceneEdges)&&void 0!==t?t:[],$n);if(null===l)return;if(e.preventDefault(),0>l)return jn.current=-1,Wn.current=null,$n.current=-1,cn.current=null,Ut(null),On&&(On(null),ht.current=!0),void Ot();jn.current=l;const s=r.flat[l];Wn.current={shape:s.shape,w:s.w,h:s.h};const c={data:s.datum||{},x:s.x,y:s.y,__semioticHoverData:!0,nodeOrEdge:"node"};cn.current=c,Ut(c),On&&(On(c),ht.current=!0),Ot()},[On,Ot]),zn=l(e=>{jn.current=-1,Wn.current=null,Nn(e)},[Nn]);Dt.current=()=>{var e,t,n,o,r,i,a;Lt.current=0;const l=Ht.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=qt.current;if(!c)return;const d=performance.now(),u=Ft.current?Math.min((d-Ft.current)/1e3,.1):.016;Ft.current=d;const h=c.advanceTransition(gt.current?d+1e6:d),f=!gt.current&&h,g=!gt.current&&c.tickAnimation([mt,bt],u);(h||ht.current||g)&&c.buildScene([mt,bt]);const y="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,l=t[0]+"px",s=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==s&&(e.style.height=s),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}(l,pt,vt,y))return;if(s.clearRect(-vt.left,-vt.top,pt[0],pt[1]),Me){const e=wn(s,Me);e&&(s.fillStyle=e,s.fillRect(0,0,mt,bt))}Ge&&c.applyDecay(),qe&&c.applyPulse(d),Ue&&c.applyThresholds(d),c.applyTopologyDiff(d);const p=null!==(e=null==Ze?void 0:Ze.threshold)&&void 0!==e?e:5e3,v=Ze&&c.lastIngestTime>0&&d-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(t=null==Ze?void 0:Ze.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Ko(e,n);break;case"line":Zo(e,n);break;case"ribbon":Uo(e,n);break;case"curved":Qo(e,n)}}(s,c.sceneEdges),function(e,t){var n,o,r;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="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),Go(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,o,r;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="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),qo(e,t),e.restore())}}(s,c.sceneNodes),function(e,t){var n,o,r;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="string"==typeof t.style.fill&&wn(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=wn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(s,c.sceneNodes),ae&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:G.spawnRate,l=null!==(i=o.maxPerEdge)&&void 0!==i?i:G.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=l)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let d=s;Math.random()<c&&d++;for(let t=0;d>t&&e.countForEdge(o)<l;t++)e.spawn(o)}}(c.particlePool,e,u,jt);const t=.5*(null!==(n=jt.speedMultiplier)&&void 0!==n?n:1);let o;if(jt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(u,t,e,o),function(e,t,n,o,r){var i,a;const l=null!==(i=o.radius)&&void 0!==i?i:G.radius,s=null!==(a=o.opacity)&&void 0!==a?a:G.opacity;e.globalAlpha=s;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.color:r(s),e.fillStyle=wn(e,c)||c,e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fill()}e.globalAlpha=1}(s,c.particlePool,e,jt,pn)}}v&&(s.globalAlpha=1);const m=ht.current;if(ht.current=!1,m||f||g){const e=Ht.current;e&&e.setAttribute("aria-label",Lo(null!==(r=null===(o=c.sceneNodes)||void 0===o?void 0:o.length)&&void 0!==r?r:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}const b=m||f||g||Xt.current;b&&d-Yt.current>=33?(tn(e=>e+1),Yt.current=d,Xt.current=!1):Xt.current=!!b,(vn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Xt.current)&&(Lt.current=requestAnimationFrame(()=>Dt.current()))},function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:o,dirtyRef:i,renderFnRef:a,cleanup:l}=e;po(()=>{var e,r;t&&n&&(null===(r=null===(e=o.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===r||r.call(e)),i.current=!0,a.current()},[t,n]);const s=r(l);s.current=l,u(()=>()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.call(s)},[])}({hydrated:Et,wasHydratingFromSSR:Tt,storeRef:qt,dirtyRef:ht,renderFnRef:Dt}),u(()=>{ht.current=!0,Ot()},[P,mt,bt,Me,Ot]),function(e,t,n,o,r,i){u(()=>{if(!e)return;const a=setInterval(()=>{var a;const l=t.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(a=e.threshold)&&void 0!==a?a:5e3,d=s-l.lastIngestTime>c;d!==r&&(i(d),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o])}(Ze,qt,ht,Ot,on,rn);const Rn=Le&&Kt?e(nn,{x:Kt.x,y:Kt.y,containerWidth:mt,containerHeight:bt,margin:vt,className:"stream-network-tooltip",zIndex:2,children:De?De(Kt):e(rr,{data:Kt})}):null;if(yo||!Et&&Tt){const n=qt.current;if(n){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(P),t=e?N||(Array.isArray(T)?void 0:T):void 0;if(e&&t)n.ingestHierarchy(t,[mt,bt]),n.buildScene([mt,bt]);else{const e=Nt,t=Array.isArray(Ct)?Ct:[];(e.length>0||t.length>0)&&(n.ingestBounded(e,t,[mt,bt]),n.buildScene([mt,bt]))}}const o=null!==(p=null==n?void 0:n.sceneNodes)&&void 0!==p?p:[],r=null!==(v=null==n?void 0:n.sceneEdges)&&void 0!==v?v:[],i=null!==(m=null==n?void 0:n.labels)&&void 0!==m?m:[];return t("div",{ref:yt,className:"stream-network-frame"+(Ae?" "+Ae:""),role:"img","aria-label":Je||("string"==typeof Fe?Fe:"Network chart"),style:{position:"relative",width:ke?"100%":pt[0],height:we?"100%":pt[1]},children:[e(zo,{summary:et}),t("svg",{xmlns:"http://www.w3.org/2000/svg",width:pt[0],height:pt[1],style:{position:"absolute",left:0,top:0},children:[kt&&e("g",{transform:`translate(${vt.left},${vt.top})`,children:kt}),t("g",{transform:`translate(${vt.left},${vt.top})`,children:[Me&&e("rect",{x:0,y:0,width:mt,height:bt,fill:Me}),r.map((t,n)=>function(t,n){switch(t.type){case"line":return e("line",{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},"net-edge-"+n);case"bezier":{const o=t;return e("path",{d:o.pathD,fill:go(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=t;return e("path",{d:o.pathD,fill:go(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=t;return e("path",{d:o.pathD,fill:go(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(t,n)).filter(Boolean),o.map((t,n)=>function(t,n){switch(t.type){case"circle":{const o=t;return e("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:go(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=t;return e("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:go(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=t,r=C().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(fo)||"";return e("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:go(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}default:return null}}(t,n)).filter(Boolean),i.map((t,n)=>function(t,n){return e("text",{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,children:t.text},"net-label-"+n)}(t,n)).filter(Boolean)]})]}),e(ho,{width:mt,height:bt,totalWidth:pt[0],totalHeight:pt[1],margin:vt,labels:i,sceneNodes:o,title:Fe,legend:je,legendPosition:We,legendLayout:$e,legendHoverBehavior:Be,legendClickBehavior:ze,legendHighlightedCategory:Re,legendIsolatedCategories:He,foregroundGraphics:Wt(xt,null===(b=qt.current)||void 0===b?void 0:b.customLayoutOverlays),annotations:Ie,autoPlaceAnnotations:Ce,svgAnnotationRules:_e,annotationFrame:0})]})}const Hn=qt.current;return t("div",{ref:yt,className:"stream-network-frame"+(Ae?" "+Ae:""),role:"group","aria-label":Je||("string"==typeof Fe?Fe:"Network chart"),tabIndex:0,style:{position:"relative",width:ke?"100%":pt[0],height:we?"100%":pt[1],overflow:"visible"},onKeyDown:Bn,children:[Qe&&e(Ro,{tableId:Mt}),Qe&&e(Bo,{nodes:null!==(x=null==Hn?void 0:Hn.sceneNodes)&&void 0!==x?x:[],edges:null!==(k=null==Hn?void 0:Hn.sceneEdges)&&void 0!==k?k:[],chartType:"Network chart",tableId:Mt,chartTitle:"string"==typeof Fe?Fe:void 0}),e(zo,{summary:et}),e(Ho,{hoverPoint:Kt}),t("div",{role:"img","aria-label":Je||("string"==typeof Fe?Fe:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Le?zn:void 0,onMouseLeave:Le?In:void 0,onClick:Pe||Ee?_n:void 0,children:[kt&&e("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:pt[0],height:pt[1],pointerEvents:"none",overflow:"visible"},children:e("g",{transform:`translate(${vt.left},${vt.top})`,children:kt})}),e("canvas",{ref:Ht,"aria-label":Lo(null!==(S=null===(w=null==Hn?void 0:Hn.sceneNodes)||void 0===w?void 0:w.length)&&void 0!==S?S:0,null!==(M=null===(A=null==Hn?void 0:Hn.sceneEdges)||void 0===A?void 0:A.length)&&void 0!==M?M:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e(ho,{width:mt,height:bt,totalWidth:pt[0],totalHeight:pt[1],margin:vt,labels:(null==Hn?void 0:Hn.labels)||[],sceneNodes:null==Hn?void 0:Hn.sceneNodes,title:Fe,legend:je,legendPosition:We,legendLayout:$e,legendHoverBehavior:Be,legendClickBehavior:ze,legendHighlightedCategory:Re,legendIsolatedCategories:He,foregroundGraphics:Wt(xt,ln),annotations:Ie,autoPlaceAnnotations:Ce,svgAnnotationRules:_e,annotationFrame:en}),e(Zt,{active:jn.current>=0,hoverPoint:Kt,margin:vt,size:pt,shape:null===(L=Wn.current)||void 0===L?void 0:L.shape,width:null===(D=Wn.current)||void 0===D?void 0:D.w,height:null===(O=Wn.current)||void 0===O?void 0:O.h}),Rn,(null==Ze?void 0:Ze.showBadge)&&e("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ze.badgePosition?{top:4,left:4}:"bottom-left"===Ze.badgePosition?{bottom:4,left:4}:"bottom-right"===Ze.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:on?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:on?"STALE":"LIVE"})]})]})});function ar(e,t){const{variant:n,frameRef:o,overrides:r,deps:i}=t;g(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,r;return null!==(r=null===(o=e.current)||void 0===o?void 0:o.update(t,n))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==n?n:null}}}if("network"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o,r,i,a;const l=Array.isArray(t)?t:[t],s=null!==(r=null===(o=null===(n=e.current)||void 0===n?void 0:n.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==r?r:[],c=[];for(const t of l){const n=s.find(e=>e.id===t);n&&c.push(Object.assign(Object.assign({},null!==(i=n.data)&&void 0!==i?i:{}),{id:t})),null===(a=e.current)||void 0===a||a.removeNode(t)}return c},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var o;const r=null===(o=e.current)||void 0===o?void 0:o.updateNode(t,n);return r?[Object.assign(Object.assign({},r),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n,o,r;return null!==(r=null===(o=null===(n=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==r?r:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,r,i;const a=null!==(r=null===(o=e.current)||void 0===o?void 0:o.removePoint(t))&&void 0!==r?r:[];for(const t of a)null===(i=e.current)||void 0===i||i.push(n(t));return a},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]}}}const n=t;return{push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,r,i;const a=null!==(r=null===(o=n.current)||void 0===o?void 0:o.removeLine(e))&&void 0!==r?r:[];for(const e of a)null===(i=n.current)||void 0===i||i.pushLine(t(e));return a},clear:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getLines())&&void 0!==t?t:[]}}}(n,o);return Object.assign(Object.assign({},e),r)},null!=i?i:[])}ir.displayName="StreamNetworkFrame";const lr=c(null);function sr(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function cr(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[dr,ur]=on(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=cr(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=cr(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[hr,fr]=on(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let gr={positions:new Map};const yr=new Set;function pr(){for(const e of yr)e()}function vr(e,t){const n=gr.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(gr.positions);o.delete(e),gr={positions:o},pr()}function mr(e){const t=y(),n=e.clientId||t,{name:o}=e,r=ur(e=>e.selections.get(o)),a=ur(e=>e.setClause),s=ur(e=>e.clearClause),c=i(()=>!!r&&r.clauses.size>0,[r]);return{predicate:i(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(sr(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:c,selectPoints:l(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:l(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:l(()=>{s(o,n)},[s,o,n]),clientId:n}}const br=c(!1),xr=c(null),kr="undefined"==typeof window?u:h;function wr(e,t,n){var o;const r=null!==(o=e.xValue)&&void 0!==o?o:null==t?void 0:t[n];if(null==r)return null;const i=Number(r);return Number.isFinite(i)?i:null}function Sr(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?Object.assign(Object.assign({},t),{xValue:e.xValue}):t||{}}function Ar(){var e;const t=gn(e=>e.theme),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function Mr(e,t,n,o,r){let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=St[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function Lr({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:l="right",userMargin:s,defaults:c={top:50,bottom:60,left:70,right:40},categories:d}){const u=a(br),h=null!==a(xr),f=void 0!==o?o:!u&&!!t,g=!!t&&(f||h),p=i(()=>{if(!g)return[];if(void 0!==d)return d;const n=new Set;for(const o of e){const e="function"==typeof t?t(o):o[t];null!=e&&n.add(e+"")}return Array.from(n)},[d,t,e,g]);!function(e){const t=a(xr),n=y(),o=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),i=r([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i.current,o)||(i.current=o);const l=i.current;kr(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),kr(()=>{t&&t.registerCategories(n,l)},[t,n,l])}(h&&t?p:[]);const v=i(()=>{if(!f||!t)return;const o=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:a}){const l=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),l=a?o(a,t,n):n?n(r):Mt[i%Mt.length];return{label:r+"",color:l}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:l,label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Ot,categories:p}),r=o.legendGroups.reduce((e,t)=>e+t.items.length,0);return 0!==r?o:void 0},[f,t,e,n,p]),m=i(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=t=>{const n=e[t];return"number"==typeof n?n:c[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];return v&&("right"===l&&!o("right")&&110>n.right?n.right=110:"left"===l&&!o("left")&&110>n.left?n.left=110:"top"===l&&!o("top")&&50>n.top?n.top=50:"bottom"===l&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[c,s,v,l]);return{legend:v,margin:m,legendPosition:l}}o.createContext(void 0);const Dr={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 Or(e,t,n){var o,r,i,a,l,s,c;const d=Dr[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?d.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?d.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:d.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:d.showGrid,enableHover:null!==(l=t.enableHover)&&void 0!==l?l:!!t.linkedHover||d.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:d.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:d.showLabels,title:u?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:Pr(d.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:u}}function Pr(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Er(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function Tr(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function Nr(e){return"function"==typeof e?e:t=>t[e]||1}function Ir({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const l=Object.assign({fillOpacity:r},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=Ot(e.data||e,t,n):e&&(l.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?l.fill=Ot(e.data||e,t,n):e&&(l.fill=o(e,e.index).fill)}else"gradient"===e&&(l.fill="#999",l.fillOpacity=.7*r);return l}}function Cr({componentName:n,message:o,diagnosticHint:r,width:i,height:a}){return e("div",{role:"alert",style:{width:i,height:Math.max(a,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"},children:t("div",{style:{textAlign:"center",maxWidth:400},children:[e("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:n}),e("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:o}),r&&e("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:r})]})})}class _r extends o.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e(Cr,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function jr({componentName:t,width:n,height:o,children:r}){return e(_r,{fallback:r=>e(Cr,{componentName:t,message:r.message,width:n,height:o}),children:r})}"undefined"!=typeof process&&process;const Wr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},$r={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Br(t){const{nodes:n,edges:o,inferNodes:r=!0,sourceAccessor:s="source",targetAccessor:c="target",colorBy:h,colorScheme:f,showLegend:g,legendPosition:p,legendInteraction:v,selection:m,linkedHover:b,onObservation:x,onClick:k,chartType:w,chartId:S,marginDefaults:A,userMargin:M,width:L,height:D,loading:O,loadingContent:P,emptyContent:E,emptyDataKey:T="edges"}=t,N=i(()=>Yo(o),[o]),I=i(()=>Yo(n),[n]),C=function(t,n,o,r){if(!t)return null;if(!1===r)return null;if(null!=r)return e("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const i=Math.min(5,Math.floor(o/40)),a=Math.max(8,Math.floor(o/(3*i))),l=Math.max(6,Math.floor(o/(2.5*i))),s=Math.floor((o-(i*(a+l)-l))/2);return e("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,o)=>e("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},$r),{position:"absolute",top:s+o*(a+l),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:a,opacity:.5+o%2*.2})},o))})}(O,L,D,P),_=C?null:function(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e("div",{style:Object.assign(Object.assign({},Wr),{width:n,height:o}),children:r||"No data available"}):null}("nodes"===T?void 0===n?void 0:I:void 0===o?void 0:N,L,D,E),j=i(()=>r?Tr(I,N,s,c):I,[r,I,N,s,c]),W=function(e,t,n){const o=a(lr),r=Ar();return i(()=>{var i;if(!t)return;const a=null!==(i=null!=n?n:r&&r.length>0?r:void 0)&&void 0!==i?i:"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(o&&Object.keys(o).length>0){const e=Pt(n.map(e=>({_cat:e})),"_cat",a);return t=>o[t]||e(t)}return Pt(n.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const n=Pt(e,t,a);return e=>o[e]||n(e)}return Pt(e,t,a)}if(o&&Object.keys(o).length>0){const e=Pt([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[e,t,n,o,r])}(j,h,f),$=Ar(),B=i(()=>{if(Array.isArray(f))return f;if($&&$.length>0)return $;if("string"==typeof f){const e=St[f];if(Array.isArray(e)&&e.length>0)return e}return At},[f,$]),z=i(()=>{if(!h)return[];const e=new Set;for(const t of j){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[j,h]),R=function(e,t,n){const[o,r]=d(null),[a,s]=d(new Set),c=l(t=>{"highlight"===e&&r(t?t.label:null)},[e]),u=l(t=>{"isolate"===e&&s(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),h=i(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return a.has(o)}}:null},[e,t,o,a]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:c,onLegendClick:u,legendSelectionHook:h}}(v,h,z),{legend:H,margin:F,legendPosition:Y}=Lr({data:j,colorBy:h,colorScale:W,showLegend:g,legendPosition:p,userMargin:M,defaults:A,categories:z}),X=function({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:r,chartType:a,chartId:s,onClick:c,hoverHighlight:h,colorByField:f}){const g=y(),p=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),v="series"===(null==p?void 0:p.mode)?[p.seriesField||f||n[0]].filter(e=>!!e):(null==p?void 0:p.fields)||n||[],m=mr({name:(null==e?void 0:e.name)||"__unused__"}),b=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:a}=mr({name:t});return{onHover:l(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&i(t)},[n,i,a,t]),predicate:o,isActive:r}}({name:(null==p?void 0:p.name)||"hover",fields:v}),x=fr(e=>e.pushObservation),k=e?{isActive:m.isActive,predicate:m.predicate}:null,[w,S]=d(null),A=f||n[0],M=i(()=>{if(!h||null==w||!A)return null;const e=w,t=A;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[h,w,A]),L=l(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const n=wr(e,t,p.xField);null!=n&&function(e,t,n){const o=gr.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(gr={positions:new Map(gr.positions).set(e,{xValue:t,sourceId:n})},pr())}(p.name||"hover",n,g)}"x-position"!==(null==p?void 0:p.mode)&&b.onHover(t)}else"x-position"===(null==p?void 0:p.mode)&&vr(p.name||"hover",g),"x-position"!==(null==p?void 0:p.mode)&&b.onHover(null);if(h&&A)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[A];S(null!=n?n+"":null)}else S(null);if(r||x){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const i=Sr(e),a=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(a),x&&x(a)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});r&&r(e),x&&x(e)}}},[t,b,p,g,r,a,s,x,h,A]),D=l(e=>{var t,n,o,i;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=wr(e,t,p.xField);null!=n&&function(e,t,n){const o=gr.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(gr.positions);return t.delete(e),gr={positions:t},pr(),!1}gr={positions:new Map(gr.positions).set(e,{xValue:t,sourceId:n,locked:!0})},pr()}(p.name||"hover",n,g)}if(e&&c){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),c(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(r||x){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const n=Sr(e),a=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(a),x&&x(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),x&&x(e)}}},[c,r,x,a,s,p,g]);return u(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const e=p.name||"hover";return()=>{!function(e,t){const n=gr.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(gr.positions);o.delete(e),gr={positions:o},pr()}(e,g),vr(e,g)}},[null==p?void 0:p.mode,null==p?void 0:p.name,g]),{activeSelectionHook:k,hoverSelectionHook:M,customHoverBehavior:L,customClickBehavior:D,crosshairSourceId:g}}({selection:m,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:x,onClick:k,chartType:w,chartId:S}),{customHoverBehavior:G,customClickBehavior:q,activeSelectionHook:V,hoverSelectionHook:K,crosshairSourceId:Z}=X;return{safeNodes:j,safeEdges:N,colorScale:W,effectivePalette:B,themeCategorical:$,allCategories:z,legendState:R,legend:H,margin:F,legendPosition:Y,customHoverBehavior:G,customClickBehavior:q,activeSelectionHook:V,hoverSelectionHook:K,crosshairSourceId:Z,loadingEl:C,emptyEl:_}}function zr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}function Rr(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function Hr(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let o,r=n+1;for(const n of t){const t=Rr(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function Fr({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} 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 Yr({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!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 n=(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(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Hr(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}const Xr=f(function(t,n){var o;const a=r(null);ar(n,{variant:"network",frameRef:a});const l=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:s,edges:c,margin:d,className:u,nodeIdAccessor:h,nodeIDAccessor:f,sourceAccessor:g="source",targetAccessor:y="target",nodeLabel:p,colorBy:v,colorScheme:m,nodeSize:b=8,nodeSizeRange:x=[5,20],edgeWidth:k=1,edgeColor:w="#999",edgeOpacity:S=.6,iterations:A=300,forceStrength:M=.1,tooltip:L,frameProps:D={},onObservation:O,onClick:P,chartId:E,selection:T,linkedHover:N,loading:I,loadingContent:C,emptyContent:_,legendInteraction:j,legendPosition:W,stroke:$,strokeWidth:B,opacity:z}=t,R=null!==(o=null!=h?h:f)&&void 0!==o?o:"id",{width:H,height:F,enableHover:Y,showLegend:X,showLabels:G=!1,title:q,description:V,summary:K,accessibleTable:Z}=l,U=Br({nodes:s,edges:c,inferNodes:!1,sourceAccessor:g,targetAccessor:y,colorBy:v,colorScheme:m,showLegend:X,legendPosition:W,legendInteraction:j,selection:T,linkedHover:N,onObservation:O,onClick:P,chartType:"ForceDirectedGraph",chartId:E,marginDefaults:l.marginDefaults,userMargin:d,width:H,height:F,loading:I,loadingContent:C,emptyContent:_,emptyDataKey:"nodes"}),Q=i(()=>new Map,[]),J=i(()=>e=>{const t={};return t.fill=v?Ot(e.data||e,v,U.colorScale):Mr(0,U.themeCategorical,m),"number"==typeof b&&(t.r=b),t},[v,U.colorScale,b,U.themeCategorical,m,Q]),ee=i(()=>zr(J,{stroke:$,strokeWidth:B,opacity:z}),[J,$,B,z]),te=i(()=>e=>({stroke:w,strokeWidth:"number"==typeof k?k:"function"==typeof k?k(e):e[k]||1,opacity:S}),[k,w,S]),ne=i(()=>zr(te,{stroke:$,strokeWidth:B,opacity:z}),[te,$,B,z]),oe=i(()=>{if(G&&p)return"function"==typeof p?p:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[p])&&void 0!==n?n:e[p])&&void 0!==o?o:e.id}},[G,p]),re=Yr({componentName:"ForceDirectedGraph",nodes:s,edges:c,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:R}});return re?e(Cr,{componentName:"ForceDirectedGraph",message:re,width:H,height:F}):U.loadingEl?U.loadingEl:U.emptyEl?U.emptyEl:e(jr,{componentName:"ForceDirectedGraph",width:H,height:F,children:e(ir,Object.assign({ref:a,chartType:"force"},null!=s&&{nodes:U.safeNodes},null!=c&&{edges:U.safeEdges},{size:[H,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,nodeIDAccessor:R,sourceAccessor:g,targetAccessor:y,iterations:A,forceStrength:M,nodeStyle:ee,edgeStyle:ne,colorBy:v,colorScheme:U.effectivePalette,nodeSize:b,nodeSizeRange:x,nodeLabel:oe,showLabels:G,enableHover:Y,tooltipContent:!1===L?()=>null:tn(L)||void 0,customHoverBehavior:N||O||P?U.customHoverBehavior:void 0,customClickBehavior:O||P?U.customClickBehavior:void 0,legend:U.legend,legendPosition:U.legendPosition},j&&"none"!==j&&{legendHoverBehavior:U.legendState.onLegendHover,legendClickBehavior:U.legendState.onLegendClick,legendHighlightedCategory:U.legendState.highlightedCategory,legendIsolatedCategories:U.legendState.isolatedCategories},{className:u,title:q,description:V,summary:K,accessibleTable:Z},null!=t.animate&&{animate:t.animate},D))})});Xr.displayName="ForceDirectedGraph";const Gr=f(function(t,n){const o=r(null);ar(n,{variant:"network",frameRef:o,overrides:{getData:()=>{var e,t,n,r;return null!==(r=null===(n=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==r?r:[]}}});const a=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:800,height:600}),{nodes:l,edges:s,margin:c,className:d,sourceAccessor:u="source",targetAccessor:h="target",valueAccessor:f="value",nodeIdAccessor:g="id",colorBy:y,colorScheme:p,edgeColorBy:v="source",orientation:m="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:S=.5,edgeSort:A,tooltip:M,frameProps:L={},onObservation:D,onClick:O,chartId:P,selection:E,linkedHover:T,loading:N,loadingContent:I,emptyContent:C,showLegend:_,legendPosition:j,legendInteraction:W,stroke:$,strokeWidth:B,opacity:z}=t,{width:R,height:H,enableHover:F,showLabels:Y=!0,title:X,description:G,summary:q,accessibleTable:V}=a,K=Br({nodes:l,edges:s,inferNodes:!0,sourceAccessor:u,targetAccessor:h,colorBy:y,colorScheme:p,showLegend:_,legendPosition:j,legendInteraction:W,selection:E,linkedHover:T,onObservation:D,onClick:O,chartType:"SankeyDiagram",chartId:P,marginDefaults:a.marginDefaults,userMargin:c,width:R,height:H,loading:N,loadingContent:I,emptyContent:C}),Z=i(()=>new Map,[]),U=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?Ot(e.data||e,y,K.colorScale):Mr(0,K.themeCategorical,p),t},[y,K.colorScale,K.themeCategorical,p,Z]),Q=i(()=>zr(U,{stroke:$,strokeWidth:B,opacity:z}),[U,$,B,z]),J=i(()=>Ir({edgeColorBy:v,colorBy:y,colorScale:K.colorScale,nodeStyleFn:Q,edgeOpacity:S,baseStyle:{stroke:"none",strokeWidth:0}}),[v,y,K.colorScale,Q,S]),ee=i(()=>zr(J,{stroke:$,strokeWidth:B,opacity:z}),[J,$,B,z]),te=i(()=>{if(!Y)return;const e=w||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[Y,w,g]),ne=Yr({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ne?e(Cr,{componentName:"SankeyDiagram",message:ne,width:R,height:H}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e(jr,{componentName:"SankeyDiagram",width:R,height:H,children:e(ir,Object.assign({ref:o,chartType:"sankey"},K.safeNodes.length>0&&{nodes:K.safeNodes},null!=s&&{edges:K.safeEdges},{size:[R,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:h,valueAccessor:f,orientation:m,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:Q,edgeStyle:ee,colorBy:y,colorScheme:K.effectivePalette,edgeColorBy:v,edgeOpacity:S,edgeSort:A,nodeLabel:te,showLabels:Y,enableHover:F,tooltipContent:!1===M?()=>null:tn(M)||void 0,customHoverBehavior:T||D||O?K.customHoverBehavior:void 0,customClickBehavior:D||O?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},W&&"none"!==W&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:d,title:X,description:G,summary:q,accessibleTable:V},null!=t.animate&&{animate:t.animate},L))})});Gr.displayName="SankeyDiagram";const qr=f(function(t,n){const o=r(null);ar(n,{variant:"network",frameRef:o,overrides:{getData:()=>{var e,t,n,r;return null!==(r=null===(n=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==r?r:[]}}});const a=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:l,edges:s,margin:c,className:d,sourceAccessor:u="source",targetAccessor:h="target",valueAccessor:f="value",nodeIdAccessor:g="id",colorBy:y,colorScheme:p,edgeColorBy:v="source",padAngle:m=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:S,frameProps:A={},onObservation:M,onClick:L,chartId:D,selection:O,linkedHover:P,loading:E,loadingContent:T,emptyContent:N,legendInteraction:I,stroke:C,strokeWidth:_,opacity:j}=t,{width:W,height:$,enableHover:B,showLabels:z=!0,title:R,description:H,summary:F,accessibleTable:Y}=a,X=Br({nodes:l,edges:s,inferNodes:!0,sourceAccessor:u,targetAccessor:h,colorBy:y,colorScheme:p,showLegend:!1,legendInteraction:I,selection:O,linkedHover:P,onObservation:M,onClick:L,chartType:"ChordDiagram",chartId:D,marginDefaults:a.marginDefaults,userMargin:c,width:W,height:$,loading:E,loadingContent:T,emptyContent:N}),G=i(()=>new Map,[]),q=X.safeNodes.length>0,V=i(()=>{if(q)return(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(y)r.fill=Ot(e.data||e,y,X.colorScale);else{const i=Array.isArray(p)?p:St[p]||At,a=Array.isArray(i)?i:At,l=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[l%a.length]}return r}},[q,y,X.colorScale,p]),K=i(()=>V?zr(V,{stroke:C,strokeWidth:_,opacity:j}):void 0,[V,C,_,j]),Z=i(()=>{if(q)return Ir({edgeColorBy:v,colorBy:y,colorScale:X.colorScale,nodeStyleFn:K||(e=>({fill:Mr(0,X.themeCategorical,p)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[q,v,y,X.colorScale,K,w,X.themeCategorical,p,G]),U=i(()=>Z?zr(Z,{stroke:C,strokeWidth:_,opacity:j}):void 0,[Z,C,_,j]),Q=i(()=>{if(!z)return;const e=k||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[z,k,g]),J=Yr({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return J?e(Cr,{componentName:"ChordDiagram",message:J,width:W,height:$}):X.loadingEl?X.loadingEl:X.emptyEl?X.emptyEl:e(jr,{componentName:"ChordDiagram",width:W,height:$,children:e(ir,Object.assign({ref:o,chartType:"chord"},X.safeNodes.length>0&&{nodes:X.safeNodes},null!=s&&{edges:X.safeEdges},{size:[W,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:h,valueAccessor:f,padAngle:m,groupWidth:b,sortGroups:x,nodeStyle:K,edgeStyle:U,colorBy:y,colorScheme:X.effectivePalette,edgeColorBy:v,edgeOpacity:w,nodeLabel:Q,showLabels:z,enableHover:B,tooltipContent:!1===S?()=>null:tn(S)||void 0,customHoverBehavior:P||M||L?X.customHoverBehavior:void 0,customClickBehavior:M||L?X.customClickBehavior:void 0},I&&"none"!==I&&{legendHoverBehavior:X.legendState.onLegendHover,legendClickBehavior:X.legendState.onLegendClick,legendHighlightedCategory:X.legendState.highlightedCategory,legendIsolatedCategories:X.legendState.isolatedCategories},{className:d,title:R,description:H,summary:F,accessibleTable:Y},null!=t.animate&&{animate:t.animate},A))})});function Vr(t){const n=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:r,className:a,layout:l="tree",orientation:s="vertical",childrenAccessor:c="children",valueAccessor:d="value",nodeIdAccessor:u="name",colorBy:h,colorScheme:f,colorByDepth:g=!1,edgeStyle:y="curve",nodeLabel:p,nodeSize:v=5,tooltip:m,frameProps:b={},onObservation:x,onClick:k,chartId:w,selection:S,linkedHover:A,loading:M,loadingContent:L,legendInteraction:D,stroke:O,strokeWidth:P,opacity:E}=t,{width:T,height:N,enableHover:I,showLabels:C=!0,title:_,description:j,summary:W,accessibleTable:$}=n,B=Br({nodes:i(()=>Er(null!=o?o:null,c),[o,c]),edges:void 0,inferNodes:!1,colorBy:g?void 0:h,colorScheme:f,showLegend:!1,legendInteraction:D,selection:S,linkedHover:A,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:n.marginDefaults,userMargin:r,width:T,height:N,loading:M,loadingContent:L}),z=i(()=>new Map,[]),R=i(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Lt[(e.depth||0)%Lt.length]:h?Ot(e.data||e,h,B.colorScale):Mr(0,B.themeCategorical,f),t},[h,g,B.colorScale,B.themeCategorical,f,z]),H=i(()=>zr(R,{stroke:O,strokeWidth:P,opacity:E}),[R,O,P,E]),F=i(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),Y=i(()=>zr(F,{stroke:O,strokeWidth:P,opacity:E}),[F,O,P,E]),X=i(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return Nr(d)},[l,d]),G=Fr({componentName:"TreeDiagram",data:o});return G?e(Cr,{componentName:"TreeDiagram",message:G,width:T,height:N}):B.loadingEl?B.loadingEl:e(jr,{componentName:"TreeDiagram",width:T,height:N,children:e(ir,Object.assign({chartType:l},null!=o&&{data:o},{size:[T,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B.margin,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:X,treeOrientation:s,edgeType:y,nodeStyle:H,edgeStyle:Y,colorBy:h,colorScheme:B.effectivePalette,colorByDepth:g,nodeSize:v,nodeLabel:C?p||u:void 0,showLabels:C,enableHover:I,tooltipContent:!1===m?()=>null:tn(m)||void 0,customHoverBehavior:A||x||k?B.customHoverBehavior:void 0,customClickBehavior:x||k?B.customClickBehavior:void 0},D&&"none"!==D&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},{className:a,title:_,description:j,summary:W,accessibleTable:$},null!=t.animate&&{animate:t.animate},b))})}function Kr(t){const n=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:r,className:a,childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:d="name",colorBy:u,colorScheme:h,colorByDepth:f=!1,labelMode:g="leaf",nodeLabel:y,padding:p=4,paddingTop:v,nodeStyle:m,tooltip:b,frameProps:x={},selection:k,linkedHover:w,onObservation:S,onClick:A,chartId:M,loading:L,loadingContent:D,legendInteraction:O,stroke:P,strokeWidth:E,opacity:T}=t,{nodeStyle:N}=x,I=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(x,["nodeStyle"]),{width:C,height:_,enableHover:j,showLabels:W=!0,title:$,description:B,summary:z,accessibleTable:R}=n,H=Br({nodes:i(()=>Er(null!=o?o:null,s),[o,s]),edges:void 0,inferNodes:!1,colorBy:f?void 0:u,colorScheme:h,showLegend:!1,legendInteraction:O,selection:k,linkedHover:w,onObservation:S,onClick:A,chartType:"Treemap",chartId:M,marginDefaults:n.marginDefaults,userMargin:r,width:C,height:_,loading:L,loadingContent:D}),F=function(e){const t=gn(e=>e.theme.colors.selectionOpacity);return i(()=>{var n,o;if(void 0!==e||void 0!==t)return Object.assign(Object.assign({name:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:""},e),{unselectedOpacity:null!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:t})},[e,t])}(k),Y=H.customHoverBehavior,X=l(e=>{if(!e)return Y(null);const t=e.data||e;Y({data:(null==t?void 0:t.data)||t})},[Y]),G=i(()=>new Map,[]),q=i(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=f?Lt[(e.depth||0)%Lt.length]:u?Ot(e.data||e,u,H.colorScale):Mr(0,H.themeCategorical,h),t},[u,f,H.colorScale,H.themeCategorical,h,G]),V=i(()=>m||N?e=>{var t,n;return Object.assign(Object.assign(Object.assign({},q(e)),N&&null!==(t=N(e))&&void 0!==t?t:{}),m&&null!==(n=m(e))&&void 0!==n?n:{})}:q,[q,m,N]),K=i(()=>zr(V,{stroke:P,strokeWidth:E,opacity:T}),[V,P,E,T]),Z=i(()=>H.activeSelectionHook?e=>{var t;const n=Object.assign({},K(e));if(H.activeSelectionHook.isActive)if(H.activeSelectionHook.predicate(e.data||e))(null==F?void 0:F.selectedStyle)&&Object.assign(n,F.selectedStyle);else{const e=null!==(t=null==F?void 0:F.unselectedOpacity)&&void 0!==t?t:.5;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==F?void 0:F.unselectedStyle)&&Object.assign(n,F.unselectedStyle)}return n}:K,[K,H.activeSelectionHook,F]),U=i(()=>Nr(c),[c]),Q=void 0!==v?v:!W||"parent"!==g&&"all"!==g?void 0:18,J=Fr({componentName:"Treemap",data:o});return J?e(Cr,{componentName:"Treemap",message:J,width:C,height:_}):H.loadingEl?H.loadingEl:e(jr,{componentName:"Treemap",width:C,height:_,children:e(ir,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[C,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H.margin,nodeIDAccessor:d,childrenAccessor:s,hierarchySum:U,padding:p,paddingTop:Q,nodeStyle:Z,colorBy:u,colorScheme:H.effectivePalette,colorByDepth:f,nodeLabel:W?y||d:void 0,showLabels:W,labelMode:g,enableHover:j,tooltipContent:!1===b?()=>null:tn(b)||void 0},(w||S||A)&&{customHoverBehavior:X},(S||A)&&{customClickBehavior:H.customClickBehavior},O&&"none"!==O&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:a,title:$,description:B,summary:z,accessibleTable:R},null!=t.animate&&{animate:t.animate},I))})}function Zr(t){const n=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:r,className:a,childrenAccessor:l="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:u,colorByDepth:h=!1,nodeLabel:f,circleOpacity:g=.7,padding:y=4,tooltip:p,frameProps:v={},onObservation:m,onClick:b,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:A,legendInteraction:M,stroke:L,strokeWidth:D,opacity:O}=t,{width:P,height:E,enableHover:T,showLabels:N=!0,title:I,description:C,summary:_,accessibleTable:j}=n,W=Br({nodes:i(()=>Er(null!=o?o:null,l),[o,l]),edges:void 0,inferNodes:!1,colorBy:h?void 0:d,colorScheme:u,showLegend:!1,legendInteraction:M,selection:k,linkedHover:w,onObservation:m,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:n.marginDefaults,userMargin:r,width:P,height:E,loading:S,loadingContent:A}),$=i(()=>new Map,[]),B=i(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?Lt[(e.depth||0)%Lt.length]:d?Ot(e.data||e,d,W.colorScale):Mr(0,W.themeCategorical,u),t},[d,h,W.colorScale,g,W.themeCategorical,u,$]),z=i(()=>zr(B,{stroke:L,strokeWidth:D,opacity:O}),[B,L,D,O]),R=i(()=>Nr(s),[s]),H=Fr({componentName:"CirclePack",data:o});return H?e(Cr,{componentName:"CirclePack",message:H,width:P,height:E}):W.loadingEl?W.loadingEl:e(jr,{componentName:"CirclePack",width:P,height:E,children:e(ir,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[P,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W.margin,nodeIDAccessor:c,childrenAccessor:l,hierarchySum:R,padding:y,nodeStyle:z,colorBy:d,colorScheme:W.effectivePalette,colorByDepth:h,nodeLabel:N?f||c:void 0,showLabels:N,enableHover:T,tooltipContent:!1===p?()=>null:tn(p)||void 0,customHoverBehavior:w||m||b?W.customHoverBehavior:void 0,customClickBehavior:m||b?W.customClickBehavior:void 0},M&&"none"!==M&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},{className:a,title:I,description:C,summary:_,accessibleTable:j},null!=t.animate&&{animate:t.animate},v))})}qr.displayName="ChordDiagram",Vr.displayName="TreeDiagram","function"==typeof SuppressedError&&SuppressedError,Kr.displayName="Treemap",Zr.displayName="CirclePack";const Ur=Lt;function Qr(t){const n=Or(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:r,className:a,childrenAccessor:l="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:d,colorByDepth:u=!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:S,annotations:A,frameProps:M={},onObservation:L,onClick:D,chartId:O,selection:P,linkedHover:E,loading:T,loadingContent:N,stroke:I,strokeWidth:C,opacity:_}=t,{width:j,height:W,enableHover:$,title:B,description:z,summary:R,accessibleTable:H}=n,F=Br({nodes:i(()=>Er(o,l),[o,l]),edges:void 0,inferNodes:!1,colorBy:u?void 0:c,colorScheme:d,showLegend:!1,legendInteraction:void 0,selection:P,linkedHover:E,onObservation:L,onClick:D,chartType:"OrbitDiagram",chartId:O,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:j,height:W,loading:T,loadingContent:N}),Y=i(()=>new Map,[]),{colorScale:X,customClickBehavior:G,customHoverBehavior:q,themeCategorical:V}=F,K=i(()=>{if(Array.isArray(d))return d;const e=St[d];return Array.isArray(e)?e:At},[d]),Z=i(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=u?o?K[0]:Ur[(e.depth||0)%Ur.length]:c?Ot(e.data||e,c,X):Mr(0,V,d),n.opacity=o?1:.85,n},[c,u,X,K,V,d,Y]),U=i(()=>zr(Z,{stroke:I,strokeWidth:C,opacity:_}),[Z,I,C,_]),Q=i(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),J=i(()=>{if(q)return e=>{q(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[q]),ee=i(()=>{if(G)return e=>{G(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[G]),te=Fr({componentName:"OrbitDiagram",data:o});return te?e(Cr,{componentName:"OrbitDiagram",message:te,width:j,height:W}):F.loadingEl?F.loadingEl:e(jr,{componentName:"OrbitDiagram",width:j,height:W,children:e(ir,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[j,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F.margin,nodeIDAccessor:s,childrenAccessor:l,nodeStyle:U,edgeStyle:Q,colorBy:c,colorScheme:F.effectivePalette,colorByDepth:u,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&$,tooltipContent:k?void 0:!1===w?()=>null:tn(w)||void 0,customHoverBehavior:E||L||D?J:void 0,customClickBehavior:L||D?ee:void 0,foregroundGraphics:S,annotations:A,className:a,title:B,description:z,summary:R,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k,accessibleTable:H},null!=t.animate&&{animate:t.animate},M))})}function Jr(e,t,n){const o=[],r=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,a=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&a&&a&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||o.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}function ei(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function ti(e,t,n){const o=t.incoming[e.id],r=t.outgoing[e.id],i=[];for(const e of o)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const a={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{i.sort((e,t)=>{var n,o;return e.time-t.time||(null!==(n=a[e.kind])&&void 0!==n?n:99)-(null!==(o=a[t.kind])&&void 0!==o?o:99)})},s=i.length?Math.min(...i.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,d=null!=c?c-1:null!=s&&Number.isFinite(s)?s-1:null,u=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;u.length>e;e++)h.set(u[e],u[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=d?d:e};l();const g=[];let y=0,p=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:p);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?y:p);if(o>0){const r=f(e.time);g.push({time:r,delta:-o,kind:"transfer-out",side:t}),g.push({time:r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:p-=o,"top"===e.side?y+=o:p+=o,n-=o}n>0&&null!==d&&(g.push({time:d,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:p+=n)}"top"===e.side?y-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:p+=t}i.push(...g),l();let v=0,m=0,b=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:v,botMass:m}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:m;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?v+=e.delta:m+=e.delta,v+m>b&&(b=v+m),v>x&&(x=v),m>k&&(k=m),w.push({t:e.time,topMass:v,botMass:m})}const A=[];let M=0;for(;w.length>M;){let e=M;for(;w.length>e+1&&w[e+1].t===w[M].t;)e++;A.push(w[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||A.push(w[t])}M=e+1}const L=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let D=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===D||D>e.systemInTime)&&(D=e.systemInTime);let O=null;for(const e of o)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===O||e.systemOutTime>O)&&(O=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=L?L:-1/0,null!=O?O:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],o=Math.min(null!=c?c:1/0,null!=D?D:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&A.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:x,botPeak:k,localAttachments:S}}function ni(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function oi(e,t){return e.map(e=>({t:ni(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function ri(e,t,n){const o=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}function ii(e,t){let n=0;for(let o=0;t.length>o;o++)for(let r=o+1;t.length>r;r++){const i=t[o],a=t[r];i.source!==a.source&&i.target!==a.target&&i.source!==a.target&&i.target!==a.source&&(Math.min(i.endTime,a.endTime)>Math.max(i.startTime,a.startTime)&&e[a.source]>e[i.source]!=e[a.target]>e[i.target]&&n++)}return n}function ai(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function li(e,t){return 1e3*ii(e,t)+ai(e,t)}function si(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function ci(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=si(e,t),a=li(t,n);for(let l=0;o>l;l++){const o=Array(r).fill(0),l=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];o[n]+=r*(e.value||1),l[n]+=e.value||1,o[r]+=n*(e.value||1),l[r]+=e.value||1}const s=Array.from({length:r},(e,t)=>t).sort((e,t)=>(l[e]>0?o[e]/l[e]:e)-(l[t]>0?o[t]/l[t]:t)),c=s.map(t=>e[t]),d=new Map;s.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t);const u=li(t,n);if(a>u)a=u,i=si(e,t);else if(u===a)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=li(t,n);for(let a=0;o>a;a++){let o=!1;for(let a=0;r-1>a;a++){const r=e[a];e[a]=e[a+1],e[a+1]=r;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const l=li(t,n);if(i>l)i=l,o=!0;else{const n=e[a];e[a]=e[a+1],e[a+1]=n;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const r=Object.assign({},t),i=Object.keys(r),a=Array.from({length:o},(e,t)=>t),l=a.slice(),s=Object.assign({},r);let c=a.slice(),d=1/0;const u=()=>{for(const e of i)s[e]=l[r[e]];const e=li(s,n);d>e&&(d=e,c=a.slice())},h=(e,t)=>{const n=a[e],o=a[t];a[e]=o,a[t]=n,l[n]=t,l[o]=e};u();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),u(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function di(e,t,n,o,r){var i,a,l,s,c,d,u,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:v,lifetimeMode:m="full"}=r,b={},x={};for(const t of e)b[t.id]=n[t.id].topPeak||0,x[t.id]=n[t.id].botPeak||0;const k="half"===m,w={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=k?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=k?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}w[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}const S={},A=[];if("reuse"===p){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(null!==(i=r.get(e.target))&&void 0!==i?i:0)+1);const u=[];for(const t of e)0===(null!==(a=r.get(t.id))&&void 0!==a?a:0)&&u.push(t.id);for(;u.length;){const e=u.shift();for(const t of null!==(l=o.outgoing[e])&&void 0!==l?l:[]){const o=(null!==(s=n.get(e))&&void 0!==s?s:0)+1;o>(null!==(c=n.get(t.target))&&void 0!==c?c:0)&&n.set(t.target,o),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&u.push(t.target)}}const h=[...e].filter(e=>null!==w[e.id].start).sort((e,t)=>{var o,r;const i=null!==(o=n.get(e.id))&&void 0!==o?o:0,a=null!==(r=n.get(t.id))&&void 0!==r?r:0;return i!==a?i-a:w[e.id].start-w[t.id].start}),f=e.filter(e=>null===w[e.id].start);for(const e of[...h,...f]){const t=w[e.id];let n=-1;for(let e=0;A.length>e;e++){const o=A[e].occupants[A[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(A.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=A.length-1),A[n].occupants.push({id:e.id,end:null!==(d=null==t?void 0:t.end)&&void 0!==d?d:-1/0}),A[n].peak.topPeak=Math.max(A[n].peak.topPeak,b[e.id]),A[n].peak.botPeak=Math.max(A[n].peak.botPeak,x[e.id]),S[e.id]=n}}else e.forEach((e,t)=>{var n,o;A.push({occupants:[{id:e.id,end:null!==(o=null===(n=w[e.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:b[e.id],botPeak:x[e.id]}}),S[e.id]=t});let M=null,L=null,D=null,O=null;const P=()=>{M=ii(S,t),D=ai(S,t)},E=()=>{L=ii(S,t),O=ai(S,t)};"crossing-min"===v?(P(),ci(A,S,t),E()):"inside-out"===v?(P(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),i=Array(n),a=Math.floor((n-1)/2);i[a]=r[0].idx;let l=a-1,s=a+1;for(let e=1;r.length>e;e++)e%2==1&&n>s||0>l?i[s++]=r[e].idx:i[l--]=r[e].idx;const c=i.map(t=>e[t]),d=new Map;i.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t)}(A,S),E()):"crossing-min+inside-out"===v&&(P(),ci(A,S,t),function(e,t,n){const o=e.length;if(1>=o)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((o-1)/2);let a=li(t,n);for(const{slot:l}of r){const r=e.indexOf(l);if(0>r)continue;const s=i;if(r===s)continue;const c=e[r];e.splice(r,1),e.splice(s,0,c);const d=new Map;for(let e=0;o>e;e++)d.set(e,e);if(s>r){for(let e=r+1;s>=e;e++)d.set(e,e-1);d.set(r,s)}else{for(let e=s;r>e;e++)d.set(e,e+1);d.set(r,s)}for(const e of Object.keys(t))t[e]=d.get(t[e]);const u=li(t,n);if(u>a){const n=e[s];e.splice(s,1),e.splice(r,0,n);const i=new Map;for(let e=0;o>e;e++)i.set(e,e);if(r>s){for(let e=s+1;r>=e;e++)i.set(e,e-1);i.set(s,r)}else{for(let e=r;s>e;e++)i.set(e,e+1);i.set(s,r)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=u}}(A,S,t),E());const T=A.map(e=>{const t=new Map;for(const o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),N=(e,t)=>{let n={top:0,bot:0};for(const[o,r]of e){if(o>t)break;n=r}return n},I=[];for(let e=0;A.length-1>e;e++){const t=T[e],n=T[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of o){const o=N(t,e),i=N(n,e);o.bot+i.top>r&&(r=o.bot+i.top)}I.push(r)}const C=[];let _=g+(null!==(h=null===(u=A[0])||void 0===u?void 0:u.peak.topPeak)&&void 0!==h?h:0)*y;A.length>0&&C.push(_);for(let e=1;A.length>e;e++)_+=I[e-1]*y+g,C.push(_);if(A.length>0&&(_+=A[A.length-1].peak.botPeak*y+g),_>f){const e=f/_;for(let t=0;C.length>t;t++)C[t]*=e}const j=0===A.length?0:A[0].peak.topPeak+I.reduce((e,t)=>e+t,0)+A[A.length-1].peak.botPeak,W={};for(const t of e)W[t.id]=C[S[t.id]];return{effectiveSlotsHeight:j,centerlines:W,laneLifetime:w,slots:A,slotByNode:S,slotCenter:C,crossingsBefore:M,crossingsAfter:L,lengthBefore:D,lengthAfter:O}}Qr.displayName="OrbitDiagram";const ui=e=>{var t,n;const{bands:o=[],ribbons:r=[],showLabels:i=!0}=e.config,a=[];for(const e of r)a.push(Object.assign(Object.assign({type:"bezier",pathD:e.pathD},e.bezier&&{bezierCache:e.bezier}),{style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}}));for(const e of o)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];a.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of o)a.push({type:"bezier",pathD:e.pathD,style:Object.assign(Object.assign({},e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86}),{stroke:null!==(t=e.stroke)&&void 0!==t?t:e.fill,strokeWidth:null!==(n=e.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const l=i?o.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:l}};function hi(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function fi(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function gi(e,t){return"function"==typeof e?e(t):t[e]}const yi=f(function(o,a){const{nodes:s,edges:c,domain:u,axisTicks:h=[],nodeIdAccessor:f="id",sourceAccessor:g="source",targetAccessor:y="target",valueAccessor:p="value",startTimeAccessor:v="startTime",endTimeAccessor:m="endTime",systemInTimeAccessor:b,systemOutTimeAccessor:x,xExtentAccessor:k="xExtent",edgeIdAccessor:w="id",colorBy:S,colorScheme:A,showLegend:M,legendPosition:L="right",pairing:D="temporal",packing:O="reuse",laneOrder:P="crossing-min",ribbonLane:E="both",lifetimeMode:N="half",showLaneRails:I=!1,showQualityReadout:C=!1,showLabels:_=!0,width:j=600,height:W=400,margin:$,title:B,description:z,summary:R,accessibleTable:H,responsiveWidth:F,responsiveHeight:Y,loading:X,loadingContent:G,emptyContent:q,edgeOpacity:V=.35,timeFormat:K,valueFormat:Z,tooltip:U,enableHover:Q=!0,onObservation:J,onClick:ee,showParticles:te=!1,particleStyle:ne,chartId:oe,frameProps:re={}}=o,[ie,ae]=d([]),[le,se]=d([]),ce=r(ie),de=r(le);ce.current=ie,de.current=le;const ue=l(e=>{ce.current=e,ae(e)},[]),he=l(e=>{de.current=e,se(e)},[]),fe=void 0!==c,ge=Yo(fe?c:ie),ye=i(()=>{const e=Yo(null!=s?s:[]),t=le;if(0===e.length&&0===t.length)return Tr([],ge,g,y);const n=new Set,o=[];for(const t of e){const e=gi(f,t)+"";n.has(e)||(n.add(e),o.push(t))}for(const e of t){const t=gi(f,e)+"";n.has(t)||(n.add(t),o.push(e))}const r=Tr([],ge,g,y);for(const e of r)n.has(e.id)||(n.add(e.id),o.push(e));return o},[s,le,ge,f,g,y]),pe=r(null),ve=l((e,t)=>{const n=gi(w,e);return null!=n?n+"":`${gi(g,e)}-${gi(y,e)}-${t}`},[w,g,y]),me=l(e=>{if(null==e)return!1;const t=e;return null!=gi(g,t)&&null!=gi(y,t)},[g,y]);ar(a,{variant:"network",frameRef:pe,overrides:{push(e){if(me(e)){if(fe)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ue([...ce.current,e])}else he([...de.current,e])},pushMany(e){const t=[],n=[];for(const o of e)me(o)?t.push(o):n.push(o);t.length>0&&(fe?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ue([...ce.current,...t])),n.length>0&&he([...de.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!fe){const e=ce.current,o=[];for(let r=0;e.length>r;r++){const i=e[r];t.has(ve(i,r))?n.push(i):o.push(i)}o.length!==e.length&&ue(o)}const o=de.current,r=[];for(const e of o){const o=gi(f,e)+"";t.has(o)?n.push(e):r.push(e)}return r.length!==o.length&&he(r),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!fe){let e=!1;const r=ce.current.map((r,i)=>n.has(ve(r,i))?(o.push(r),e=!0,t(r)):r);e&&ue(r)}let r=!1;const i=de.current.map(e=>{const i=gi(f,e)+"";return n.has(i)?(o.push(e),r=!0,t(e)):e});return r&&he(i),o},clear(){var e;fe||ue([]),he([]),null===(e=pe.current)||void 0===e||e.clear()},getData:()=>null!=ge?ge:[],getScales:()=>null},deps:[fe,me,ve,f,ge,ue,he]});const be=ve,xe=l(e=>gi(f,e)+"",[f]),{nodes:ke,edges:we,domain:Se,rawNodeById:Ae,rawEdgeById:Me}=i(()=>{const e=(null!=ye?ye:[]).map(e=>{const t={id:xe(e),__raw:e},n=k?gi(k,e):null;if(Array.isArray(n)&&2===n.length){const e=fi(n[0]),o=fi(n[1]);Number.isFinite(e)&&Number.isFinite(o)&&(t.xExtent=[e,o])}return t}),t=(null!=ge?ge:[]).map((e,t)=>{const n={id:be(e,t),source:gi(g,e)+"",target:gi(y,e)+"",value:Number(gi(p,e)),startTime:fi(gi(v,e)),endTime:fi(gi(m,e)),__raw:e};if(b){const t=fi(gi(b,e));Number.isFinite(t)&&(n.systemInTime=t)}if(x){const t=fi(gi(x,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[fi(u[0]),fi(u[1])],o=new Map;for(const t of e)null!=t.__raw&&o.set(t.id,t.__raw);const r=new Map;for(const e of t)null!=e.__raw&&r.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:o,rawEdgeById:r}},[ye,ge,u,xe,be,k,g,y,p,v,m,b,x]),Le=Br({nodes:ye,edges:ge,inferNodes:!1,sourceAccessor:g,targetAccessor:y,colorBy:S,colorScheme:A,showLegend:!1,legendPosition:L,selection:void 0,linkedHover:void 0,onObservation:J,onClick:ee,chartType:"ProcessSankey",chartId:oe,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:$,width:j,height:W,loading:X,loadingContent:G,emptyContent:q}),De=(null!=M?M:!!S)&&!!S,Oe=l(e=>null!=$&&("number"==typeof $||null!=$[e]),[$]),Pe=i(()=>{const e=Object.assign({},Le.margin);return De&&("right"===L&&!Oe("right")&&140>e.right?e.right=140:"bottom"===L&&!Oe("bottom")&&80>e.bottom&&(e.bottom=80)),e},[Le.margin,De,L,Oe]),Ee=j-Pe.left-Pe.right,Te=W-Pe.top-Pe.bottom,Ne=i(()=>Jr(ke,we,Se),[ke,we,Se]),Ie=i(()=>Ne.length>0?null:function(e,t,n){var o;const{plotH:r,pairing:i="temporal",packing:a="reuse",laneOrder:l="crossing-min",lifetimeMode:s="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),d=function(e,t,n,o="value"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===o?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,a=new Map;for(const e of t)a.set(e.id,{});const l=(e,t)=>{const n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const a=[...n.values()];a.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:r);return a};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)l(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)l(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=l(o,"source"),n=l(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=o}}}return a}(e,t,c,i);let u={};for(const t of e)u[t.id]=ti(t,c,d);const h=di(e,t,u,c,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:l,lifetimeMode:s}),f=new Set;for(const e of t){const t=h.slotByNode[e.source],n=h.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=d.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>d.get(e.id).sourceSide)),r=new Set(n.map(e=>d.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)h.slotByNode[t.source]===h.slotByNode[t.target]&&(d.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)h.slotByNode[n.source]===h.slotByNode[n.target]&&(d.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const o=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===d.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===d.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=o(),i="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,a="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=i||0>=a)return!1;const l=Math.min(i,a),s=n.filter(t=>!f.has(t.id)&&d.get(t.id).sourceSide===e&&l>=t.value).sort((e,t)=>t.value-e.value);return 0!==s.length&&(d.get(s[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=ti(t,c,d);const g=di(e,t,u,c,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:l,lifetimeMode:s}),y=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),p=Math.min(12,.35*r/Math.max(g.slots.length+1,1)),v=y>0?Math.max(0,(r-p*(g.slots.length+1))/y):1,m=di(e,t,u,c,{plotH:r,padding:p,valueScale:v,packing:a,laneOrder:l,lifetimeMode:s});return{nodeData:u,sides:d,valueScale:v,padding:p,compressedPadding:12>p,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(ke,we,{plotH:Te,pairing:D,packing:O,laneOrder:P,lifetimeMode:N}),[Ne,ke,we,Te,D,O,P,N]),Ce=i(()=>T().domain(Se).range([0,Ee]),[Se,Ee]),_e=l((e,t)=>{if(S&&ye){const t=Ae.get(e);if(t)return Ot(t,S,Le.colorScale)}return Le.effectivePalette[t%Le.effectivePalette.length]||"#475569"},[S,ye,Ae,Le.colorScale,Le.effectivePalette]),je=i(()=>{const e=new Map;return ke.forEach((t,n)=>e.set(t.id,n)),e},[ke]),We=i(()=>{if(!Ie)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Ie,o=[],r=[];return ke.forEach((r,i)=>{var a;const l=t[r.id];if(!l||0===l.samples.length)return;const s=function(e,t,n,o,r){if(0===e.length)return null;const i=oi(e,r),a=e=>t-i[e].topMass*n,l=e=>t+i[e].botMass*n;let s=`M${o(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)s+=` L${o(i[e].t)},${a(e)}`;s+=` L${o(i[i.length-1].t)},${l(i.length-1)}`;for(let e=i.length-2;e>=0;e--)s+=` L${o(i[e].t)},${l(e)}`;return s+" Z"}(l.samples,e[r.id],n,Ce,Se);if(!s)return;const c=oi(l.samples,Se),d=c.find(e=>e.topMass+e.botMass>0)||c[0],u=e[r.id]+(d.botMass-d.topMass)*n/2,h=_e(r.id,i),f=null!==(a=Ae.get(r.id))&&void 0!==a?a:r,g=function(e,t,n,o,r){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const a=n.valueScale,l=n.centerlines[e],s=oi(i.samples,r),c=s.find(e=>e.topMass+e.botMass>0)||s[0],d=[...s].reverse().find(e=>e.topMass+e.botMass>0)||s[s.length-1],u=o(c.t),h=o(d.t),f=e=>o(ni(e,r)),g=[],y=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),o=f(n.startTime),r=t-20,i=Math.max(u,r);if(o>i){const[n,s]=ri(e,l,a);g.push({pathD:y(i,n,o,s),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),o=f(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,s]=ri(e,l,a);g.push({pathD:y(o,n,i,s),x0:t,x1:r,from:1,to:0})}}}}return g}(r.id,we,Ie,Ce,Se);o.push(Object.assign(Object.assign({id:r.id,pathD:s,fill:h,stroke:h,strokeWidth:.5},g.length>0&&{gradientStubs:g}),{rawDatum:f,labelX:Ce(d.t)-4,labelY:u,labelText:r.id}))}),we.forEach(o=>{var i,a,l,s;const c=null===(i=t[o.source])||void 0===i?void 0:i.localAttachments.get(o.id),d=null===(a=t[o.target])||void 0===a?void 0:a.localAttachments.get(o.id);if(!c||!d)return;const u=null!==(l=je.get(o.source))&&void 0!==l?l:0,h=_e(o.source,u),f=function(e,t,n,o,r,i,a,l){const s=r,c=e=>l?Math.max(l[0],Math.min(l[1],e)):e,d=i(c(e.time)),u=i(c(n.time)),h=e.value*s,f=n.value*s,g=e.sideMassBefore*s,y=n.sideMassAfter*s;let p,v,m,b;"top"===e.side?(p=t-g,v=p+h):(v=t+g,p=v-h),"top"===n.side?(m=o-y,b=m+f):(b=o+y,m=b-f);const x="source"===a?d+.85*(u-d):"target"===a?d+.15*(u-d):(d+u)/2;return{sx:d,sTop:p,sBot:v,tx:u,tTop:m,tBot:b,cp1X:x,cp2X:x}}(c,e[o.source],d,e[o.target],n,Ce,E,Se),{pathD:g,bezier:y}=Ge(f),p=null!==(s=Me.get(o.id))&&void 0!==s?s:o;r.push({id:o.id,pathD:g,fill:h,opacity:V,rawDatum:p,bezier:y})}),{bands:o,ribbons:r}},[Ie,ke,we,Ce,Se,_e,Ae,Me,E,V,je]),$e=i(()=>({bands:We.bands,ribbons:We.ribbons,showLabels:_}),[We,_]),Be=i(()=>{if(!De||!S)return;const e=new Map;(null!=ye?ye:[]).forEach((t,n)=>{const o=gi(S,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:_e(xe(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[De,S,ye,_e,xe]),ze=i(()=>!1!==U&&Q?void 0===U||!0===U?null:tn(U)||null:null,[U,Q]),Re=l(e=>K?K(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[K]),He=l(e=>Z?Z(e):e+"",[Z]),Fe=l(o=>{if(!o||!o.data)return null;const r=o.data;if(!hi(r))return null;const i=r.data;if(ze)return ze(i);if("band"===r.__kind){const n=r.id,o=Ie?function(e){if(!e)return[];const t=new Set,n=[];for(const o of e.samples){const e=o.topMass+o.botMass,r=`${o.t}:${e}`;t.has(r)||(t.add(r),n.push({t:o.t,total:e}))}return n}(Ie.nodeData[n]):[],i=5,a=o.length>i?o.length:null,l=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),o=n.length-1,r=[Object.assign(Object.assign({},n[0]),{mark:"min"}),Object.assign(Object.assign({},n[Math.floor(.25*o)]),{mark:"q25"}),Object.assign(Object.assign({},n[Math.floor(.5*o)]),{mark:"median"}),Object.assign(Object.assign({},n[Math.floor(.75*o)]),{mark:"q75"}),Object.assign(Object.assign({},n[o]),{mark:"max"})],i=new Set,a=[];for(const e of r)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(o,i);return t("div",{style:{minWidth:160},children:[e("div",{style:{fontWeight:600,marginBottom:4},children:n}),l.length>0&&t("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[e("thead",{children:t("tr",{style:{opacity:.6},children:[e("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),e("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=a&&e("th",{})]})}),e("tbody",{children:l.map((n,o)=>t("tr",{children:[e("td",{style:{paddingRight:8},children:Re(n.t)}),e("td",{style:{textAlign:"right"},children:He(n.total)}),null!=a&&e("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:n.mark})]},o))})]}),null!=a&&t("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",l.length," of ",a," samples"]})]})}const a=i,l=gi(g,a),s=gi(y,a),c=gi(p,a),d=gi(v,a),u=gi(m,a);return t("div",{style:{minWidth:160},children:[t("div",{style:{fontWeight:600,marginBottom:4},children:[l+""," → ",s+""]}),t("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=c&&t(n,{children:[e("span",{style:{opacity:.6},children:"value"}),e("span",{style:{textAlign:"right"},children:He(Number(c))})]}),null!=d&&t(n,{children:[e("span",{style:{opacity:.6},children:"start"}),e("span",{style:{textAlign:"right"},children:Re(fi(d))})]}),null!=u&&t(n,{children:[e("span",{style:{opacity:.6},children:"end"}),e("span",{style:{textAlign:"right"},children:Re(fi(u))})]})]})]})},[Ie,ze,Re,He,g,y,p,v,m]),Ye=i(()=>{if(!Ie)return null;const{centerlines:n,laneLifetime:o,nodeData:r,valueScale:i,compressedPadding:a,crossingsBefore:l,crossingsAfter:s,lengthBefore:c,lengthAfter:d}=Ie;let u=null,f=null;for(const e of ke){const t=o[e.id];if(!t||null===t.start||null===t.end)continue;const n=Ce(t.start),r=Ce(t.end);(null===u||u>n)&&(u=n),(null===f||r>f)&&(f=r)}const g=e=>Math.max(0,Math.min(Ee,e)),y=g(null!=u?u:0),p=Math.max(y,g(null!=f?f:Ee));return t("g",{children:[C&&null!==(null!=s?s:null)&&t("text",{x:Ee,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",l," → ",s," ","edge length: ",Math.round(c)," → ",Math.round(d)]}),a&&e("text",{x:Ee,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),h.map((t,n)=>{const o=Ce(fi(t.date));return y-.5>o||o>p+.5?null:e("line",{x1:o,y1:0,x2:o,y2:Te,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+n)}),I&&ke.map((a,l)=>{const s=o[a.id];if(!s||null===s.start)return null;const c=r[a.id],d=c?{topPeak:c.topPeak,botPeak:c.botPeak}:{topPeak:0,botPeak:0},u=n[a.id]+(d.botPeak-d.topPeak)*i/2,h=Ce(s.start),f=Ce(s.end),g=_e(a.id,l);return t("g",{children:[e("line",{x1:h,y1:u,x2:f,y2:u,stroke:g,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e("line",{x1:h,y1:u-4,x2:h,y2:u+4,stroke:g,strokeOpacity:.5}),e("line",{x1:f,y1:u-4,x2:f,y2:u+4,stroke:g,strokeOpacity:.5})]},"lane-"+a.id)}),e("line",{x1:y,y1:Te+4,x2:p,y2:Te+4,stroke:"#94a3b8"}),h.map((n,o)=>{const r=fi(n.date),i=Ce(r);if(y-.5>i||i>p+.5)return null;const a=null!=n.label?n.label:K?K(new Date(r)):"";return t("g",{transform:`translate(${i},${Te+4})`,children:[e("line",{y2:6,stroke:"#94a3b8"}),e("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:a})]},o)})]})},[Ie,h,Ce,Ee,Te,I,ke,_e,C,K]),Xe=i(()=>(null!=ye?ye:[]).map(e=>({id:xe(e),data:e})),[ye,xe]),qe=i(()=>{const e=new Map;for(const t of We.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[We]),Ve=i(()=>(null!=ge?ge:[]).map((e,t)=>{const n=be(e,t),o=Number(gi(p,e));return{id:n,source:gi(g,e)+"",target:gi(y,e)+"",value:Number.isFinite(o)?o:0,bezier:qe.get(n),data:e}}),[ge,be,g,y,p,qe]),Ke=Le.loadingEl,Ze=Le.emptyEl;return Ne.length>0?t("svg",{width:j,height:W,role:"img","aria-label":null!=B?B:"Process Sankey validation failed",children:[e("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ne.map((t,n)=>e("text",{x:20,y:56+18*n,fontSize:12,fill:"#64748b",children:"• "+ei(t)},n))]}):Ke||Ze||e(ir,Object.assign({ref:pe,chartType:"force",nodes:Xe,edges:Ve,customNetworkLayout:ui,layoutConfig:$e,size:[j,W],responsiveWidth:F,responsiveHeight:Y,margin:Pe,title:B,description:null!=z?z:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:R,accessibleTable:H,enableHover:Q,tooltipContent:!1===U?()=>null:Fe,backgroundGraphics:Ye,showParticles:te,particleStyle:ne,legend:Be,legendPosition:L,onObservation:J,customClickBehavior:ee?e=>{if(!e||!e.data)return;const t=e.data;hi(t)&&ee(t.data,{x:e.x,y:e.y})}:void 0,chartId:oe,colorScheme:Array.isArray(A)?A:void 0},re))});yi.displayName="ProcessSankey";const pi=f(function(t,n){const{nodes:o,edges:a,layout:l,layoutConfig:s,nodeIDAccessor:c="id",sourceAccessor:d="source",targetAccessor:u="target",margin:h,className:f,colorScheme:g,frameProps:y={}}=t,{frameRef:p,resolved:v,normalizedMargin:m}=function(e){const t=r(null);return ar(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:Or(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel}),normalizedMargin:i(()=>function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:n,imperativeVariant:"network",margin:h,width:t.width,height:t.height,enableHover:t.enableHover,title:t.title,mode:t.mode}),b=i(()=>Yo(null!=o?o:[]),[o]),x=i(()=>Yo(null!=a?a:[]),[a]),{width:k,height:w,enableHover:S,title:A,description:M,summary:L,accessibleTable:D}=v,O=Object.assign(Object.assign(Object.assign(Object.assign({chartType:"force"},null!=o&&{nodes:b}),null!=a&&{edges:x}),{customNetworkLayout:l,layoutConfig:s,nodeIDAccessor:c,sourceAccessor:d,targetAccessor:u,colorScheme:g,size:[k,w],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:m,className:f,title:A,description:M,summary:L,accessibleTable:D,enableHover:S}),y);return e(jr,{componentName:"NetworkCustomChart",width:k,height:w,children:e(ir,Object.assign({ref:p},O))})});pi.displayName="NetworkCustomChart";export{qr as ChordDiagram,Zr as CirclePack,Xr as ForceDirectedGraph,pi as NetworkCustomChart,Qr as OrbitDiagram,yi as ProcessSankey,Gr as SankeyDiagram,ir as StreamNetworkFrame,Vr as TreeDiagram,Kr as Treemap,ei as formatProcessSankeyIssue,Jr as validateProcessSankey};