semiotic 3.5.0 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +21 -19
- package/README.md +22 -16
- package/ai/chartSuggestions.cjs +191 -3
- package/ai/componentMetadata.cjs +3 -3
- package/ai/dist/mcp-server.js +266 -48
- package/ai/examples.md +68 -0
- package/ai/schema.json +900 -1
- package/ai/system-prompt.md +4 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +16 -1
- package/dist/components/charts/geo/FlowMap.d.ts +13 -4
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/network/OrbitDiagram.d.ts +5 -5
- package/dist/components/charts/network/ProcessSankey.d.ts +141 -0
- package/dist/components/charts/network/processSankey/algorithm.d.ts +136 -0
- package/dist/components/charts/network/processSankey/buildScenes.d.ts +45 -0
- package/dist/components/charts/network/processSankey/ribbonInputs.d.ts +32 -0
- package/dist/components/charts/network/processSankey/streamingLayout.d.ts +58 -0
- package/dist/components/charts/network/processSankey/tooltipUtils.d.ts +41 -0
- package/dist/components/charts/ordinal/BarChart.d.ts +14 -0
- package/dist/components/charts/ordinal/BoxPlot.d.ts +2 -0
- package/dist/components/charts/ordinal/DotPlot.d.ts +11 -0
- package/dist/components/charts/ordinal/GaugeChart.d.ts +20 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +2 -0
- package/dist/components/charts/ordinal/LikertChart.d.ts +2 -0
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +2 -0
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +2 -0
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +7 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +14 -11
- package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +43 -0
- package/dist/components/charts/shared/axisExtent.d.ts +59 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +75 -0
- package/dist/components/charts/shared/colorUtils.d.ts +8 -2
- package/dist/components/charts/shared/networkUtils.d.ts +3 -5
- package/dist/components/charts/shared/radialGeometry.d.ts +99 -0
- package/dist/components/charts/shared/regressionUtils.d.ts +59 -0
- package/dist/components/charts/shared/selectionUtils.d.ts +8 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +5 -0
- package/dist/components/charts/shared/types.d.ts +13 -0
- package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +75 -0
- package/dist/components/charts/shared/useEncodingDomain.d.ts +48 -0
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -1
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +148 -0
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +87 -0
- package/dist/components/charts/shared/useSeriesFeatures.d.ts +57 -0
- package/dist/components/charts/shared/useStreamStatus.d.ts +33 -0
- package/dist/components/charts/shared/useXYLineStyle.d.ts +69 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +87 -0
- package/dist/components/charts/xy/AreaChart.d.ts +38 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +13 -0
- package/dist/components/charts/xy/CandlestickChart.d.ts +4 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +20 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +172 -0
- package/dist/components/charts/xy/Heatmap.d.ts +4 -0
- package/dist/components/charts/xy/LineChart.d.ts +12 -0
- package/dist/components/charts/xy/MinimapChart.d.ts +7 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +38 -0
- package/dist/components/charts/xy/StackedAreaChart.d.ts +12 -0
- package/dist/components/geometry/ribbonGeometry.d.ts +76 -0
- package/dist/components/semiotic-ai.d.ts +2 -0
- package/dist/components/semiotic-network.d.ts +4 -0
- package/dist/components/semiotic-realtime.d.ts +2 -0
- package/dist/components/semiotic-utils.d.ts +4 -0
- package/dist/components/semiotic-xy.d.ts +2 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/serverChartConfigs.d.ts +2 -0
- package/dist/components/stream/GeoPipelineStore.d.ts +21 -0
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +8 -0
- package/dist/components/stream/PipelineStore.d.ts +5 -0
- package/dist/components/stream/SVGOverlay.d.ts +18 -0
- package/dist/components/stream/annotationAccessorResolver.d.ts +39 -0
- package/dist/components/stream/geoTypes.d.ts +12 -0
- package/dist/components/stream/ordinalTypes.d.ts +12 -0
- package/dist/components/stream/renderers/cornerRadii.d.ts +33 -0
- package/dist/components/stream/types.d.ts +23 -0
- package/dist/components/types/legendTypes.d.ts +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +2 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +4 -0
- package/dist/semiotic-realtime.d.ts +2 -0
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-utils.d.ts +4 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +2 -0
- package/dist/semiotic.d.ts +3 -3
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +10 -5
package/dist/network.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const e=require("react/jsx-runtime"),t=require("react"),r=require("d3-interpolate"),n=require("d3-array"),o=require("d3-force"),i=require("d3-scale"),a=require("d3-chord"),s=require("d3-shape"),l=require("d3-hierarchy");function c(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=c(t);function d(e,t,r,n){return Object.assign({data:e,x:t,y:r,__semioticHoverData:!0},n)}const h={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},f={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function g(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function y(e,t,r){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(r)}`}function p(e){const t=e.map(g),r=t.length-1;return e=>{if(0>=e){const[e,r,n]=t[0];return y(e,r,n)}if(e>=1){const[e,n,o]=t[r];return y(e,n,o)}const n=e*r,o=Math.floor(n),i=n-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return y(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}const v=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=p(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),b=p(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),x=p(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),k=p(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=p(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]);p(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]);const S=p(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=p(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]);p(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),p(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),p(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),p(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),p(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),p(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),p(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),p(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),p(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),p(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),p(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);class j{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 r=this.particles[t];return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,r,n){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=r[a.edgeIndex];if(!s||!s.bezier){a.active=!1,this._freeIndices.push(i);continue}const l=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;a.t+=e*t*l*(s.bezier.circular?.3:1),1>a.t?L(s.bezier,a.t,a.offset,a):(a.active=!1,this._freeIndices.push(i))}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;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 r=0;e>r;r++)t.length>r?this.particles[r]=t[r]:(this.particles[r]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(r));this.capacity=e}}function L(e,t,r,n){if(e.circular&&e.segments)return void function(e,t,r,n,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];M(c,u,d,h,l,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*r*n*2,o.y+=e*r*n*2}}(e.segments,t,r,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[o,i,a,s]=e.points;M(o,i,a,s,t,n);const l=s.x-o.x,c=s.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;n.x+=-c/u*r*e.halfWidth*2,n.y+=t*r*e.halfWidth*2}}function M(e,t,r,n,o,i){const a=1-o,s=a*a,l=s*a,c=o*o,u=c*o;i.x=l*e.x+3*s*o*t.x+3*a*c*r.x+u*n.x,i.y=l*e.y+3*s*o*t.y+3*a*c*r.y+u*n.y}function D(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function C(e,t){var r,n=[],o=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=c(n));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)r[l]=-1,n[l]=0,o[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>r[y]){r[y]=n[y]=u,o[y]=!0,u+=1,l.push(y),c.push(y);break}o[y]&&(n[t]=0|Math.min(n[t],n[y])),0>a[y]||s[t].push(a[y])}i[t]=g}else{if(n[t]===r[t]){var p=[],v=[],m=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(o[b]=!1,p.push(b),v.push(s[b]),m+=s[b].length,a[b]=d.length,b===t){l.length=g;break}}d.push(p);var x=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)x[--m]=v[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>r[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];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[l]=c}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],r=a);var l=o[r];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}r=0;for(var h=e.length;h>r;){var f=d(r);if(r=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];i[+p]=!1,a[p]={}}c(r),r+=1}else r=h}return n}function E(e){return e.y0-e.y1>0?"up":"down"}function _(e,t){return t(e.source)==t(e.target)}function P(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function I(e){return e.target.x0-e.source.x1}function O(e,t){var r=T(e),n=I(t)/Math.tan(r);return"up"==E(e)?e.y1-n:e.y1+n}function N(e,t){var r=T(e),n=I(t)/Math.tan(r);return"up"==E(e)?e.y1+n:e.y1-n}function T(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function W(e,t){return t(e)}function R(e){return B(e.source)}function $(e){return B(e.target)}function B(e){return(e.y0+e.y1)/2}function z(e){return e.virtual?0:e.value}function H(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!_(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!_(e,t)?n+1:n}),r+n}function F(e){return e.target.depth}function Y(e,t){return e.sourceLinks.length?e.depth:t-1}function X(e,t){return e.y0-t.y0}function G(e,t){return t.y0-e.y0}function q(e,t){return e.y1-t.y1}function V(e,t){return t.y1-e.y1}function K(e,t){return U(e.source,t.source)||e.index-t.index}function Z(e,t){return U(e.target,t.target)||e.index-t.index}function U(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Q(e,t){return J(e)==J(t)?"bottom"==e.circularLinkType?G(e,t):X(e,t):J(t)-J(e)}function J(e){return e.target.column-e.source.column}function ee(e,t){return te(e)==te(t)}function te(e){return e.y0-e.y1>0?"up":"down"}function re(e,t,r,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=n.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),ne(a.links.filter(function(e){return"top"==e.circularLinkType}),t,r),ne(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,_(e,t)&&P(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var n=e.source.column,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==n&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?G:X);var u=0;c.forEach(function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+n*r+u),u+=t._circularWidth||t.width}),n=e.target.column,(c=a.links.filter(function(e){return e.target.column==n&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?V:q),u=0,c.forEach(function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+n*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),a}function ne(e,t,r){e.sort(Q);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(_(e,t)&&P(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&oe(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function oe(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function ie(e){return function(){return e}}function ae(e){return e.index}function se(e){return e.nodes}function le(e){return e.links}function ce(e,t,r){var o=n.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(n,i){var a=n.length;if(t)n.sort(t);else if(i>0){var s=new Map;n.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=B(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=B(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),n.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?r.idx-n.idx:1:-1:o-i})}else n.sort(function(e,t){return e.circularLinkType==t.circularLinkType?H(t,r)-H(e,r):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});n.forEach(function(t,n){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==H(t,r)?(t.y0=e.y1/2+n,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+n,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-n,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*n,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+n,t.y1=t.y0+t.value*e.ky)})})}function ue(e,t,r,o,i,a){var s=n.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=a;c>0;--c)u(l*=.99,r),d();function u(t,r){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&H(i,r)>0){var c=n.mean(i.sourceLinks,$),u=n.mean(i.targetLinks,R),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-B(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var f=n.mean(i.sourceLinks,$),g=n.mean(i.targetLinks,R),y=((f&&g?(f+g)/2:f||g)-B(i))*t;i.y0+=y,i.y1+=y}})})}function d(){s.forEach(function(r){var n,a,s,l=e.y0,c=r.length;for(r.sort(t||U),s=0;c>s;++s)(a=l-(n=r[s]).y0)>0&&(n.y0+=a,n.y1+=a),l=n.y1+o;if((a=l-o-e.y1)>0)for(l=n.y0-=a,n.y1-=a,s=c-2;s>=0;--s)(a=(n=r[s]).y1+i-l)>0&&(n.y0-=a,n.y1-=a),l=n.y0})}}function de(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Z),e.targetLinks.sort(K)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function he(){var e=0,t=0,r=1,o=1,i=24,a=8,s=null,l=ae,c=Y,u=void 0,d=32,h=2,f=se,g=le;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=r,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return n.group(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=D(r,n)),"object"!=typeof o&&(o=e.target=D(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(f,l),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var l=C(n);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(f,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){W(e,t)!=W(o.source,t)&&W(e,t)!=W(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),_(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(n.sum(e.sourceLinks,z),n.sum(e.targetLinks,z)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?r(e,i):e.column})}(f,u,c);var g=a;if(null!==s){var y=n.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=n.max(y,function(e){return e.length});p>1&&(g=Math.max(1,(o-t)*s/(p-1)))}(function(e,t,r){var o=n.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=n.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/n.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=n.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/a),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(f,g,i),ce(f,u,l),ue(f,u,l,g,g,d),de(f),re(f,l,h,10,8),ce(f,u,l),ue(f,u,l,g,g,d),de(f),re(f,l,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return W(r.source,t)==W(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!ee(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=O(t,e);return e.y1-r}if(t.target.column>e.target.column)return O(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(f,l),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return W(r.target,t)==W(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!ee(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=N(t,e);return e.y0-r}if(t.source.column>e.source.column)return N(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(f,l),function(e){var t=e.nodes,r=e.links,o=!1,i=!1;if(r.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=n.min(t,function(e){return e.y0}),s=n.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-a);function c(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),r.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,r=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(f),re(f,l,h,10,8)}(y),y}return y.update=function(e){return de(e),re(e,l,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(a=+e,y):a},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(f="function"==typeof e?e:ie(e),y):f},y.links=function(e){return arguments.length?(g="function"==typeof e?e:ie(e),y):g},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:ie(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:ie(e),y):c},y.nodeSort=function(e){return arguments.length?(u=e,y):u},y.iterations=function(e){return arguments.length?(d=+e,y):d},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(n){return arguments.length?(e=+n[0][0],t=+n[0][1],r=+n[1][0],o=+n[1][1],y):[[e,t],[r,o]]},y.size=function(n){return arguments.length?(e=t=0,r=+n[0],o=+n[1],y):[r-e,o-t]},y}const fe=e=>{let t,n,o,i,a,s,l,c,u;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.x1,s=e.target.x0,l=r.interpolateNumber(a,s),c=l(.5),u=l(.5),`M${t},${a}C${t},${c} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${c} ${i},${a}Z`):(t=e.source.x1,n=e.target.x0,l=r.interpolateNumber(t,n),o=l(.5),i=l(.5),a=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,c=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${a}C${o},${a} ${i},${s} ${n},${s}L${n},${c}C${i},${c} ${o},${u} ${t},${u}Z`)};function ge(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+s},${n-r}L${t+s},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-l},${a-r}L${i-l},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,s=o.targetX,l=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${c},${a-h*r}L${c+n},${a-h*r+h*f}L${c+n},${d+h*n-h*f}L${c+n-f},${d+h*n}L${u-n+f},${d+h*n}L${u-n},${d+h*n-h*f}L${u-n},${l-h*r+h*f}L${u-n+f},${l-h*r}L${s},${l-h*r}L${s},${l+h*r}L${u+n},${l+h*r}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${a+h*r}L${i},${a+h*r}Z`}const ye=new Set,pe=new WeakMap;function ve(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=pe.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,pe.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;ye.has(e)||(ye.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}const me={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(F))-1:0},justify:Y};function be(e){return"string"==typeof e?e:e.id}const xe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",f=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=he().extent(m).links(v).nodes(p).nodeAlign(me[h]||Y).nodeId(e=>e.id).nodeWidth(f).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(l=null!==(s=n._circularWidth)&&void 0!==s?s:n.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of v)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(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=be(e.source),r=be(e.target),n=k.get(e._edgeKey?e._edgeKey:`${t}\0${r}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=d;const o=x.get(t),i=x.get(r);o&&(n.source=o),i&&(n.target=i)}}},buildScene(e,t,r,n){var o,i,a,s,l,c;const u="vertical"===r.orientation?"down":"right",d=r.nodeStyle,h=r.edgeStyle,f=null!==(o=r.edgeOpacity)&&void 0!==o?o:.5,g=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:v,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const m=[],b=[],x=[],k=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=d?d(ve(t,"nodeStyle")):{},o={fill:n.fill||p.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};k.set(t.id,("string"==typeof o.fill?o.fill:null)||p.get(t.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:t.y0,y:t.x0,w:r,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const w=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of w){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=(null===(i=r.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=r.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";o="function"==typeof g?g(e)||o:"target"===g?k.get(n.id)||p.get(n.id)||o:k.get(t.id)||p.get(t.id)||o;const u=h?h(ve(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),i=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=u.fill||o;b.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+n},${t.sourceY-r}L${t.sourceX+n},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:a,fillOpacity:null!==(s=u.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),b.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-i},${t.targetY-r}L${t.targetX-i},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:a,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-i,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?ge(e):fe(e),!d)continue;const y={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};b.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:y,datum:e})}if(!1!==r.showLabels){const t=(S=r.nodeLabel)?"function"==typeof S?S:e=>e[S]||e.id:null;for(const r of e){const e=r.x1-r.x0,o=r.y1-r.y0;if(0>=e||0>=o)continue;const i=t?t(r):r.id;if(!i)continue;let a,s,l;"down"===u?(a=r.y0+(r.y1-r.y0)/2,s=r.x1+14,l="start"):(n[0]/2>r.x0+e/2?(a=r.x0-6,l="end"):(a=r.x1+6,l="start"),s=r.y0+o/2),x.push({x:a,y:s,text:i+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var S;return{sceneNodes:m,sceneEdges:b,labels:x}}},ke={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,l=n[0]/2,c=n[1]/2,u=r.__previousPositions;let d=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=null==u?void 0:u.get(t.id);e?d++:r?(t.x=r.x,t.y=r.y,d++):h.push(t)}const f=d>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of h){const n=we(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=Se(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=Se(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=l+n*Math.cos(r),e.y=c+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=l+e*Math.cos(o),n.y=c+e*Math.sin(o)}}}const g=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),y=0===r.iterations?0:f?40:g,p=Ae(r.nodeSize,r.nodeSizeRange,e),v=e=>p(e);if(y>0){const r=o.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),n=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*v(e))).force("center",o.forceCenter(l,c).strength(.8)).force("x",o.forceX(l).strength(.15)).force("y",o.forceY(c).strength(.15));if(n.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.force("link",r),n.force("link").links(e)}f?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;y>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=v(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){var o,i,a,s,l,c,u;const d=r.nodeStyle,h=r.edgeStyle,f=Ae(r.nodeSize,r.nodeSizeRange,e),g=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:v,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],m=[],b=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(ve(t,"nodeSize")),n=d?d(ve(t,"nodeStyle")):{},s={fill:n.fill||y.get(t.id)||(null===(o=r.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:n.stroke||(null===(i=r.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:2,opacity:n.opacity};p.push({type:"circle",cx:t.x,cy:t.y,r:e,style:s,datum:t,id:t.id,label:t.id})}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:x.get(e.source),n="object"==typeof e.target?e.target:x.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=h?h(ve(e,"edgeStyle")):{},i={stroke:o.stroke||(null===(s=r.themeSemantic)||void 0===s?void 0:s.border)||(null===(l=r.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:i,datum:e})}if(!1!==r.showLabels){const t=(k=r.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=f(ve(r,"nodeSize"));b.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:b}}};function we(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function Se(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function Ae(e,t,r){var o,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=r.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(o=n.min(l))&&void 0!==o?o:0,u=null!==(a=n.max(l))&&void 0!==a?a:1;if(c===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const je=v,Le={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=r,c=Math.min(n[0],n[1])/2,u=c-i,d=n[0]/2,h=n[1]/2,f=(g=r.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=y.get("string"==typeof e.source?e.source:e.source.id),n=y.get(t);if(void 0===r||void 0===n)continue;const o=f(e);v[r][n]=o}const m=a.chord().padAngle(o);l&&m.sortGroups(l);const b=m(v),x=b.groups,k=s.arc().innerRadius(u).outerRadius(c);for(const t of x){const r=e[t.index],n=k.centroid({innerRadius:u,outerRadius:c,startAngle:t.startAngle,endAngle:t.endAngle});r.x=n[0]+d,r.y=n[1]+h,r.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);r&&(e.source=r),n&&(e.target=n)}const S=new Map;for(const e of t)S.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=S.get(`${r}\0${n}`)||S.get(`${n}\0${r}`);o&&(o.__chordData=t)}},buildScene(e,t,r,n){var o,i,s,l;const{groupWidth:c=20,edgeOpacity:u=.5}=r,d=Math.min(n[0],n[1])/2,h=d-c,f=n[0]/2,g=n[1]/2,y=r.nodeStyle,p=r.edgeStyle,v=r.edgeColorBy||"source",m=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:je,b=new Map;e.forEach((e,t)=>{b.set(e.id,m[t%m.length])});const x=a.ribbon().radius(h),k=[],w=[],S=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.__arcData;if(!n)continue;let i;i=y?y(ve(r,"nodeStyle")).fill||b.get(r.id)||m[t%m.length]:b.get(r.id)||m[t%m.length];const a=y?y(ve(r,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:d,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:s,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=x(t);if(!n)continue;const o=Me(n,f,g);let a=(null===(i=r.themeSemantic)||void 0===i?void 0:i.border)||(null===(s=r.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)a=p(ve(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===v&&r?a=b.get(r.id)||a:t&&(a=b.get(t.id)||a)}const c=p?p(ve(e,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(l=c.fillOpacity)&&void 0!==l?l:u,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity};w.push({type:"ribbon",pathD:o,style:d,datum:e})}if(!1!==r.showLabels){const t=(A=r.nodeLabel)?"function"==typeof A?A:e=>e[A]||e.id:null,n=d+12;for(const r of e){const e=r.__arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;S.push({x:f+Math.cos(a)*n,y:g+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:k,sceneEdges:w,labels:S}}};function Me(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const De=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ce(e){const[t,r,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*r+.114*n>150?"#222":"#fff"}function Ee(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function _e(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}function Pe(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:De}function Ie(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 Oe(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}const Ne={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),c=r.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>Number(e[c])||0:e=>Number(e.value)||0,d=l.hierarchy(i,s);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,f]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=l.tree();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=l.cluster();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,f);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=l.treemap().size([r,n]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(e)}(d,r,h,f);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;l.pack().size([r,n]).padding(i)(e)}(d,r,h,f);break;case"partition":!function(e,t,r,n){var o;l.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,f)}const g=d.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;g.length>t;t++){const n=g[t],i={id:Ee(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===a||"cluster"===a?Te(i,n,r):"treemap"===a||"partition"===a?We(i,n):"circlepack"===a&&Re(i,n),i.__hierarchyNode=n,e.push(i),y.set(n,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const r=y.get(e.parent),n=y.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,s,l,c,u,d,h,f;const g=[],y=[],p=[],v=r.treeOrientation||"vertical",m="radial"===v,b=n[0]/2,x=n[1]/2,k="number"==typeof(w=r.nodeSize)?w:5;var w;for(const t of e){let e=t.x,n=t.y;m&&(e+=b,n+=x);const i=o(ve(t,"nodeStyle"));let l=i.fill||Ie(r);if(r.colorByDepth&&void 0!==t.depth){const e=Pe(r);l=e[t.depth%e.length]}const c={fill:l,stroke:i.stroke||(null===(a=r.themeSemantic)||void 0===a?void 0:a.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:i.opacity};g.push({type:"circle",cx:e,cy:n,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const S=null!==(l=r.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,a=t.y,s=n.x,l=n.y;m&&(o+=b,a+=x,s+=b,l+=x);const f=Oe(o,a,s,l,v),g=i(ve(e,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=r.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=r.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:S};y.push({type:"curved",pathD:f,style:p,datum:e})}if(!1!==r.showLabels){const t=_e(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(m&&(a+=b,s+=x),m){const e=a-b,t=s-x,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===v?((null===(f=r.data)||void 0===f?void 0:f.children)&&0!==r.data.children.length?(n=a-k-6,i="end"):(n=a+k+6,i="start"),o=s):(n=a,o=s+k+14,i="middle");p.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i,a,s,l;const c=[],u=[];for(const r of e){const e=r.x1-r.x0,a=r.y1-r.y0;if(0>=e||0>=a)continue;const s=n(ve(r,"nodeStyle"));let l=s.fill||Ie(t);if(t.colorByDepth&&void 0!==r.depth){const e=Pe(t);l=e[r.depth%e.length]}const u={fill:l,stroke:s.stroke||(null===(o=t.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};c.push({type:"rect",x:r.x0,y:r.y0,w:e,h:a,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=_e(t.nodeLabel),o=t.labelMode||"leaf",i="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,d=c.y1-c.y0;if(0>=e||0>=d)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=r?r(c):c.id;if(!f)continue;if((h?30:40)>e||(h?16:14)>d)continue;let g=n(ve(c,"nodeStyle")).fill||Ie(t);if(t.colorByDepth&&void 0!==c.depth){const e=Pe(t);g=e[c.depth%e.length]}const y="string"==typeof g?Ce(g):null!==(l=null===(s=t.themeSemantic)||void 0===s?void 0:s.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+e/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/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:u}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,s,l,c,u,d,h,f;const g=[],y=[];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const l=n(ve(r,"nodeStyle"));let c=l.fill||Ie(t);if(t.colorByDepth&&void 0!==r.depth){const e=Pe(t);c=e[r.depth%e.length]}const u={fill:c,stroke:l.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=l.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=l.opacity)&&void 0!==s?s:.7};g.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=_e(t.nodeLabel);for(const o of e){const e=null!==(l=o.__radius)&&void 0!==l?l:5,i=r?r(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let s=n(ve(o,"nodeStyle")).fill||Ie(t);if(t.colorByDepth&&void 0!==o.depth){const e=Pe(t);s=e[o.depth%e.length]}if(a){const r="string"==typeof s?Ce(s):null!==(d=null===(u=t.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#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:r})}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,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Te(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function We(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 Re(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function $e(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const Be={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){var i,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var r;return(null!==(r=e[t])&&void 0!==r?r:"")+""}}(r.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),d=null!==(i=r.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=r.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=$e(r);y.metaMap.clear(),n.length=0,o.length=0;const p=new Map;function v(e){var t;const r=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,r+1),0===r?e:`${e}__${r}`}const m=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=v(c(e));n.push({id:k,x:m,y:b,x0:m,x1:m,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),y.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,p){const m=l(t);if(!(null==m?void 0:m.length))return;const b=m.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let S=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=m.slice(S,S+k);if(!w.length)break;const A=(b+1)/x,j={id:r,depth:h,data:t,parentId:r},L=p?d/f(j)*A:d*A,M=s.pie().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),D=M(w),C=g(j);for(let t=0;w.length>t;t++){const s=(D[t].startAngle+D[t].endAngle)/2,l=w[t],u=v(c(l)),d=i+L*Math.sin(s),f=a+L*Math.cos(s)*C;n.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:l}),y.metaMap.set(u,{ring:L,angle:s,depth:h,parentId:r,eccentricity:C}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(l,u,d,f,L,h+1,!0)}S+=k}}(e,k,m,b,x,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,s,l,c,u;const d=r.nodeStyle,h=r.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==r.orbitShowRings){const t=$e(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;y.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(l),y2:t+r*Math.cos(l)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(ve(t,"nodeSize")),n=d?d(ve(t,"nodeStyle")):{},c={fill:n.fill||(null===(o=r.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:n.stroke||(null===(i=r.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=n.opacity)&&void 0!==s?s:0===(null!==(l=t.depth)&&void 0!==l?l: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),r="object"==typeof e.target?e.target:v.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=f(ve(r,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(r):t&&null!==(u=null===(c=r.data)||void 0===c?void 0:c[t])&&void 0!==u?u:r.id;p.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=$e(t),i=null!==(r=t.orbitSpeed)&&void 0!==r?r:.25,a=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const r=null!==(t=e.depth)&&void 0!==t?t:0;return(r%2==0?1:-1)/(r+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,l=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=c.get(e.parentId);if(!r)continue;const n=e.angle+s*l*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(n),t.y=r.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)},ze={sankey:xe,force:ke,chord:Le,tree:Ne,cluster:Ne,treemap:Ne,circlepack:Ne,partition:Ne,orbit:Be};function He(e){return ze[e]}const Fe={category10:v,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:m,reds:b,greens:x,oranges:k,purples:w,viridis:S,plasma:A},Ye=v,Xe=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Ge=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],qe=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 Ve(e,t,r){if("function"==typeof t){const n=t(e);return r&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||qe.has(t)}(n)?r(n):n}const n=(null==e?void 0:e[t])+"";return r?r(n):Ye[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n))%Ye.length]}function Ke(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),o=n.every(e=>!isNaN(Number(e)));if(Array.isArray(r))return i.scaleOrdinal().domain(n).range(r).unknown("#999");const a=Fe[r]||Fe.category10;if(o&&"function"==typeof a){let e=-1/0;for(const t of n){const r=Number(t);r>e&&(e=r)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:Ye;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function Ze(e){return 0===e.length?()=>"#4e79a7":t=>{var r;let n=0;for(let e=0;t.length>e;e++)n=31*n+t.charCodeAt(e)|0;return null!==(r=e[Math.abs(n)%e.length])&&void 0!==r?r:"#4e79a7"}}function Ue(e,t,r){return e+(t-e)*r}function Qe(e,t,r){var n,o,i;if(1>=r)return 1;const a=null!==(n=e.minOpacity)&&void 0!==n?n:.1,s=r-1-t;switch(e.type){case"linear":return a+(1-s/(r-1))*(1-a);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:r/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*r)>s?1:a;default:return 1}}class Je{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({},h),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new j(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({},h),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new j(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,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof n?n:e=>e[n],l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this._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=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},et(e)),{data:t}))}for(let e=0;t.length>e;e++){const r=t[e],n=l(r)+"",o=c(r)+"",i=Number(u(r))||1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},et(n)),{data:r})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},et(o)),{data:r}));const a=`${n}\0${o}\0${e}`;this.edges.set(a,{source:n,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:a})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,et(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,et(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),l=this.edges.get(s);let c=!1;return l?(l.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,r,n,o,i,a,s,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=He(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const s of u)if(void 0!==s._prevX0){const l=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(r=s._prevX0)&&void 0!==r?r:0),c=(null!==(n=s._prevY1)&&void 0!==n?n:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+l/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+c/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],r=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=r,this.edges.set(r,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const r=e.get(t.id);r&&(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=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=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=null!==(l=null===(s=this.config.transition)||void 0===s?void 0:s.duration)&&void 0!==l?l:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const t=e[0]/2,r=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=r,e._prevY1=r;for(const e of this.edges.values())e._prevY0=r,e._prevY1=r,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,r,n,o,i,a;const s=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=function(e,t,r){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Fe[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:r}(this.config.colorScheme,this.config.themeCategorical,v),u={nodes:s,edges:l,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:Ze(c),config:null!==(r=this.config.layoutConfig)&&void 0!==r?r:{}};let d;try{d=this.config.customNetworkLayout(u)}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!==(n=d.sceneNodes)&&void 0!==n?n:[],this.sceneEdges=null!==(o=d.sceneEdges)&&void 0!==o?o:[],this.labels=null!==(i=d.labels)&&void 0!==i?i:[],void(this.customLayoutOverlays=null!==(a=d.overlays)&&void 0!==a?a:null)}this.customLayoutOverlays=null;const c=He(this.config.chartType);if(!c)return;const{sceneNodes:u,sceneEdges:d,labels:h}=c.buildScene(s,l,this.config,e);this.sceneNodes=u,this.sceneEdges=d,this.labels=h}get isAnimating(){const e=He(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=He(this.config.chartType);if(!(null==r?void 0:r.tick))return!1;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return r.tick(n,o,this.config,e,t)}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),r=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Ue(e._prevX0,e._targetX0,r),e.x1=Ue(e._prevX1,e._targetX1,r),e.y0=Ue(e._prevY0,e._targetY0,r),e.y1=Ue(e._prevY1,e._targetY1,r));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Ue(e._prevY0,e._targetY0,r),e.y1=Ue(e._prevY1,e._targetY1,r),e.sankeyWidth=Ue(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const r=null==e?void 0:e.get(t.id);r&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.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 r=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(r){e._prevY0=r.y0,e._prevY1=r.y1,e._prevSankeyWidth=r.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,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=r.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=n.x0,s=r.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(!r)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=a.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const c=this.edgeTimestamps.get(`${n}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t;const r=this.config.decay;if(!r)return;const n=this.nodeTimestamps.size;if(1>=n)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 s=i.get(a);if(void 0===s)continue;const l=Qe(r,s,n),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*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",a=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const s=this.nodes.get(r);if(!s)continue;const l=n.metric(s);let c=null;void 0===n.critical||n.critical>l?void 0===n.warning||n.warning>l||(c=o):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var r;const n=this.nodes.get(e);if(!n)return null;const o=n.data?Object.assign({},n.data):{};return n.data=t(null!==(r=n.data)&&void 0!==r?r:{}),this.layoutVersion++,o}updateEdge(e,t,r){var n;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=r(null!==(n=o.data)&&void 0!==n?n:{});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,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)!==e&&("string"==typeof r.target?r.target:r.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const r=[];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 n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,o]of this.edges)o.data&&n(o.data)===e&&r.push(t)}else for(const[n,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&r.push(n);for(const e of r)this.edges.delete(e),this.edgeTimestamps.delete(e);return r.length>0&&this.layoutVersion++,r.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 et(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 tt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:u.createElement(u.Fragment,null,...t)}function rt(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function nt(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=ot(t,r,n,o);if(e)if("rect"===t.type){const r=t.w*t.h;s>r&&(i=e,s=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=ct(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function ot(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i),s=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,n);return a>s?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=function(e,t,r){return r.x>e||e>r.x+r.w||r.y>t||t>r.y+r.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:r.x+r.w/2,cy:r.y+r.h/2}}(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=rt(Math.atan2(o,n)),s=rt(e.startAngle),l=rt(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let it=null,at=null;function st(){return at||(it=document.createElement("canvas"),it.width=1,it.height=1,at=it.getContext("2d")),at}function lt(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 ct(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;const i=lt(e),a=st();if(!i||!a)return null;try{if(a.isPointInPath(i,t,r)){const i="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}const s=a.lineWidth;a.lineWidth=10;const l=a.isPointInStroke(i,t,r);if(a.lineWidth=s,l)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*n,l=e.y1+a*o,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(r-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;const n=lt(e),o=st();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);default:return null}}function ut(e,t,r){const{group:n,indexInGroup:o}=t,i=r.byGroup.get(n);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=r.groups.indexOf(n);return r.groups.length-1>e?dt(r,r.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=r.groups.indexOf(n);return e>0?dt(r,r.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*r.flat.length)),r.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*r.flat.length)),0);case"Home":return 0;case"End":return r.flat.length-1;case"Escape":return-1;default:return null}}function dt(e,t,r){const n=e.byGroup.get(t);let o=0,i=Math.abs(n[0].x-r.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-r.x);i>t&&(i=t,o=e)}return n[o]._flatIndex}function ht(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}const ft="var(--semiotic-focus, #005fcc)";function gt({active:t,hoverPoint:r,margin:n,size:o,shape:i="circle",width:a,height:s}){if(!t||!r)return null;const l=r.x+n.left,c=r.y+n.top;let u;if("rect"===i&&null!=a&&null!=s){const t=Math.max(a,4),r=Math.max(s,4);u=e.jsx("rect",{x:l-t/2-3,y:c-r/2-3,width:t+6,height:r+6,rx:3,fill:"none",stroke:ft,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:ft,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ft,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function yt({x:t,y:r,containerWidth:n,containerHeight:o,margin:i,children:a,className:s="stream-frame-tooltip",zIndex:l=1}){const c=u.useRef(null),[d,h]=u.useState(null);u.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();h(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[a,s,n,o]);let f;return f=d?`translate(${d.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${d.height+12>o-r?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>r?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:c,className:s,style:{position:"absolute",left:i.left+t,top:i.top+r,transform:f,pointerEvents:"none",zIndex:l,width:"max-content"},children:a})}function pt(r){let n=null;const o=()=>(n||(n=t.createContext(null)),n),i=vt(r);return[function({children:n,initialState:i}){const a=t.useRef(i),s=t.useMemo(()=>vt(r,a.current),[]),l=o();return e.jsx(l.Provider,{value:s,children:n})},e=>{var r;const n=o(),a=null!==(r=t.useContext(n))&&void 0!==r?r:i,s=t.useRef(e);s.current=e;const l=t.useCallback(()=>s.current(a.getState()),[a]),c=t.useCallback(()=>s.current(a.getState()),[a]);return t.useSyncExternalStore(a.subscribe,l,c)}]}function vt(e,t){const r=new EventTarget;let n=Object.assign(Object.assign({},e(function(e){n=Object.assign(Object.assign({},n),e(n)),r.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>n,subscribe:function(e){return r.addEventListener("update",e),()=>r.removeEventListener("update",e)}}}function mt(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 bt(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:xt})})),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 xt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],kt={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}},wt={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}},St={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:xt,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 At(e,t){if("light"===t)return kt;if("dark"===t)return wt;if("high-contrast"===t)return St;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?wt:kt;return bt(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 bt(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[jt,Lt]=pt(e=>({theme:kt,setTheme(t){e(e=>({theme:At(e.theme,t)}))}}));const Mt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Dt=new WeakMap;let Ct=0,Et=!1,_t=null,Pt=null,It=null;function Ot(e,t){var r,n;if(!t)return t;const o=Mt.exec(t);if(!o)return t;const i=e.canvas;if(!i)return(null===(r=o[2])||void 0===r?void 0:r.trim())||t;!function(){if(Et)return;if("undefined"==typeof window||"undefined"==typeof document)return;Et=!0;const e=()=>{Ct++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(_t=new MutationObserver(e),_t.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Pt=window.matchMedia("(prefers-color-scheme: dark)"),It=e,"function"==typeof Pt.addEventListener?Pt.addEventListener("change",It):"function"==typeof Pt.addListener&&Pt.addListener(It)}catch(e){}}();let a=Dt.get(i);a&&a.version===Ct||(a={version:Ct,map:new Map},Dt.set(i,a));const s=a.map.get(t);if(void 0!==s)return s;const l=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(n=o[2])||void 0===n?void 0:n.trim())||t;return a.map.set(t,l),l}const Nt="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function Tt(e,t,r){return"function"==typeof e?e({size:t,margin:r}):e}function Wt(e){const r=function(){const[e,r]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return r(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>r(e.matches))},[]),e}(),n=t.useRef(r);n.current=r;const[o,i]=function(e,r,n){const o=t.useRef(null),[i,a]=t.useState(null);return t.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;a(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),a=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),s=i[0]-a.left-a.right,l=i[1]-a.top-a.bottom,c=Tt(e.foregroundGraphics,i,a),d=Tt(e.backgroundGraphics,i,a),h=Lt(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){var r,n;if(!1===e)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(n=e.duration)&&void 0!==n?n:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(o||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+u.useId(),p=t.useRef(0),v=t.useRef(()=>{}),m=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);t.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),k=t.useRef(null),w=t.useRef(0),S=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),A=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(S))},[S]),j=t.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),x.current()},[]);t.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const L=e.themeDirtyRef;return Nt(()=>{L&&(Ct++,L.current=!0,m())},[h,m,L]),{reducedMotion:r,reducedMotionRef:n,responsiveRef:o,size:i,margin:a,adjustedWidth:s,adjustedHeight:l,resolvedForeground:c,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:y,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:A,onPointerLeave:j}}const Rt={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function $t(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Rt[r])(n(e,t)),o}function Bt(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function zt(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const Ht=(t,r,n,o,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=t,g=[];let y=0;const p=!(!r&&!n),v="isolate"===u||void 0===u&&null!=i;return f.forEach((t,u)=>{const m=$t(t,u,d,h),b=zt(t,o,i),x=i&&i.size>0&&i.has(t.label);g.push(e.jsxs("g",{transform:`translate(0,${y})`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===a&&u===s?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?x||!1:void 0,"aria-current":p&&!v&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:p?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+f.length)%f.length;c(l,t);const r=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:p?e=>{c(l,u),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,x&&e.jsx(Bt,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=22}),g};function Ft({config:t,orientation:r="vertical",width:n=100}){const{colorFn:o,domain:i,label:a,format:s}=t,l=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+u.useId();if("horizontal"===r){const t=12,r=Math.min(n,200),s=Math.max(0,(n-r)/2),u=[];for(let t=0;64>=t;t++){const r=t/64;u.push(e.jsx("stop",{offset:100*r+"%",stopColor:o(i[0]+r*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":a||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),a&&e.jsx("text",{x:s+r/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),e.jsx("rect",{x:s,y:0,width:r,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])}),e.jsx("text",{x:s+r,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])})]})}const d=[];for(let t=0;64>=t;t++){const r=t/64;d.push(e.jsx("stop",{offset:100*r+"%",stopColor:o(i[1]-r*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":a||"Gradient legend",children:[a&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])})]})}function Yt(t){const{legendGroups:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,legendInteraction:s,title:l="Legend",width:c=100,height:d=20,orientation:h="vertical"}=t,[f,g]=u.useState(0),[y,p]=u.useState(0),v=u.useCallback((e,t)=>{g(e),p(t)},[]),m="vertical"===h?(({legendGroups:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,f)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:r,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:Ht(t,n,o,i,a,s,l,f,c,u)},"legend-group-"+f)),d+=22*t.items.length+8}),h})({legendGroups:r||[],width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:v,legendInteraction:s}):(({legendGroups:t,height:r,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];t.forEach((t,r)=>{let g=0;t.label&&(g+=16);const y=((t,r,n,o,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=t,y=[];let p=0,v=0;const m=!(!r&&!n),b="isolate"===u||void 0===u&&null!=i;g.forEach((t,u)=>{const x=$t(t,u,h,f),k=zt(t,o,i),w=i&&i.size>0&&i.has(t.label),S=26+7*t.label.length;d&&d>0&&p>0&&p+S>d&&(v++,p=0),y.push(e.jsxs("g",{transform:`translate(${p},${22*v})`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?l===a&&u===s?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?w||!1:void 0,"aria-current":m&&!b&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:m?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+g.length)%g.length;c(l,t);const r=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:m?e=>{c(l,u),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.jsx(Bt,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),p+=S});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=v+1;return{items:y,offset:x,totalRows:w,totalHeight:22*w}})(t,o,i,a,s,l,c,r,u,d,n);g+=y.offset+5,f.push(Object.assign(Object.assign({label:t.label},y),{offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight})),h+=g+12});let g=h>n?0:Math.max(0,(n-h)/2);const y=[];return f.forEach((n,o)=>{const i=t[o];i.label&&(y.push(e.jsx("text",{transform:`translate(${g},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)),g+=16),y.push(e.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:n.items},"legend-group-"+o)),g+=n.offset+5,t[o+1]&&y.push(e.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(n.totalHeight||r)+0+8},"legend-top-line legend-symbol-"+o)),g+=12}),e.jsx("g",{children:y})})({legendGroups:r||[],title:l,height:d,width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:v,legendInteraction:s}),b=!(!n&&!o);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===h&&e.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),m]})}function Xt(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function Gt(e){return"object"==typeof e&&null!==e&&"gradient"in e}function qt(t){const{legend:r,totalWidth:n,totalHeight:o,margin:i,legendPosition:a="right",title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!r)return null;const f="top"===a||"bottom"===a;let g,y;return"left"===a?(g=4,y=i.top):"top"===a?(g=0,y=s?32:8):"bottom"===a?(g=0,y=o-i.bottom+50):(g=n-i.right+10,y=i.top),e.jsx("g",{transform:`translate(${g}, ${y})`,children:Gt(r)?e.jsx(Ft,{config:r.gradient,orientation:f?"horizontal":"vertical",width:f?n:100}):Xt(r)?e.jsx(Yt,{legendGroups:r.legendGroups,title:"",width:f?n:100,orientation:f?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):r})}function Vt(t){const{width:r,height:n,totalWidth:o,totalHeight:i,margin:a,labels:s,title:l,legend:c,legendHoverBehavior:d,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g,legendPosition:y="right",foregroundGraphics:p,sceneNodes:v,annotations:m,svgAnnotationRules:b}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof l?l:"Network Chart"}),e.jsx("desc",{children:"string"==typeof l?l+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[s.map((t,r)=>e.jsx("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-"+r)),m&&m.filter(e=>"widget"!==e.type).map((t,o)=>{if(b){const i=b(t,o,{width:r,height:n,sceneNodes:v});if(i)return e.jsx(u.Fragment,{children:i},"annotation-"+o)}return null}),p]}),l&&"string"==typeof l?e.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:o,height:a.top,children:l}):null,qt({legend:c,totalWidth:o,totalHeight:i,margin:a,legendPosition:y,title:l,legendHoverBehavior:d,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g})]}),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,r)=>{var n,o,i,s,l,c,u,d,h;const f=v.find(e=>{var r,n,o,i,a;return e.id===t.nodeId||(null===(r=e.datum)||void 0===r?void 0:r.id)===t.nodeId||(null===(o=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===t.nodeId||(null===(a=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===t.nodeId});if(!f)return null;const g=a.left+(null!==(n=f.cx)&&void 0!==n?n:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),y=a.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(s=f.y)&&void 0!==s?s:0),p=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(c=t.dy)&&void 0!==c?c:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:g+p-b/2,top:y+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+r)})]})}Vt.displayName="NetworkSVGOverlay";const Kt={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Zt(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Ut="undefined"==typeof window||"undefined"==typeof document,Qt="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,Jt=()=>()=>{},er=()=>!1,tr=()=>!0;function rr(e,t){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const n of r){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!Object.is(e[n],t[n]))return!1}return!0}function nr(e,t){if(e.length!==t.length)return!1;for(let r=0;e.length>r;r++)if(!Object.is(e[r],t[r]))return!1;return!0}function or(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 ir=u.createContext(null),ar={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function sr(e,t,r){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?r+", empty":`${r}, ${n.join(", ")}`}const lr=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},cr={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},ur={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},dr={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},hr={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},fr={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},gr={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},yr={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function pr({nodes:t,edges:r,chartType:n,tableId:o,chartTitle:i}){var a,s,l,c,d,h,f,g,y,p,v,m,b,x;const[k,w]=u.useState(!1),S=u.useContext(ir),A=null!==(a=null==S?void 0:S.visible)&&void 0!==a&&a,j=k||A,L=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n,M=u.useRef(null),D=u.useCallback(()=>{k||A||w(!0)},[k,A]),C=u.useCallback(e=>{var t;A||(null===(t=M.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[A]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:ar}):null;if(!j)return e.jsx("div",{id:o,tabIndex:-1,onFocus:D,style:ar,role:"region","aria-label":L,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",r.length," edges)"]})});const E=Array.isArray(t)?t:[],_=Array.isArray(r)?r:[],P=new Map,I=new Map,O=new Map,N=new Map;for(const e of _){if(!e||"object"!=typeof e)continue;const t=null!==(s=e.datum)&&void 0!==s?s:e,r="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=r&&""!==r){const e=r+"";I.set(e,(null!==(d=I.get(e))&&void 0!==d?d:0)+1),N.set(e,(null!==(h=N.get(e))&&void 0!==h?h:0)+o)}if(null!=n&&""!==n){const e=n+"";P.set(e,(null!==(f=P.get(e))&&void 0!==f?f:0)+1),O.set(e,(null!==(g=O.get(e))&&void 0!==g?g:0)+o)}}const T=[];for(let e=0;E.length>e;e++){const t=E[e];if(!t||"object"!=typeof t)continue;const r=null!==(p=null===(y=t.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:t.id,n=null!=r?r+"":"node-"+e,o=null!==(v=P.get(n))&&void 0!==v?v:0,i=null!==(m=I.get(n))&&void 0!==m?m:0,a=null!==(b=O.get(n))&&void 0!==b?b:0,s=null!==(x=N.get(n))&&void 0!==x?x:0;T.push({id:n,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}T.sort((e,t)=>t.degree-e.degree);let W=0,R=0;if(T.length>0){let e=0;for(const t of T)e+=t.degree,t.degree>R&&(R=t.degree);W=e/T.length}const $=_.some(e=>{var t;const r=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==r?void 0:r.value)&&Number.isFinite(r.value)}),B=[`${T.length} nodes, ${_.length} edges.`];T.length>0&&B.push(`Mean degree: ${lr(W)}, max degree: ${R}.`);const z=T.slice(0,5);return e.jsxs("div",{ref:M,id:o,tabIndex:-1,onBlur:C,style:cr,role:"region","aria-label":L,children:[e.jsx("button",{type:"button",onClick:()=>{A&&S&&S.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:dr,children:"×"}),e.jsx("div",{role:"note",style:ur,children:B.join(" ")}),e.jsxs("table",{role:"table","aria-label":"Node degree summary for "+n,style:hr,children:[e.jsxs("caption",{style:yr,children:["Top ",z.length," of ",T.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:fr,children:"id"}),e.jsx("th",{style:fr,children:"degree"}),e.jsx("th",{style:fr,children:"in"}),e.jsx("th",{style:fr,children:"out"}),$&&e.jsx("th",{style:fr,children:"w. degree"}),$&&e.jsx("th",{style:fr,children:"w. in"}),$&&e.jsx("th",{style:fr,children:"w. out"})]})}),e.jsx("tbody",{children:z.map((t,r)=>e.jsxs("tr",{children:[e.jsx("td",{style:gr,children:t.id}),e.jsx("td",{style:gr,children:t.degree}),e.jsx("td",{style:gr,children:t.inDeg}),e.jsx("td",{style:gr,children:t.outDeg}),$&&e.jsx("td",{style:gr,children:lr(t.wDegree)}),$&&e.jsx("td",{style:gr,children:lr(t.wInDeg)}),$&&e.jsx("td",{style:gr,children:lr(t.wOutDeg)})]},r))})]})]})}function vr({summary:t}){return t?e.jsx("div",{role:"note",style:ar,children:t}):null}function mr({tableId:t}){return e.jsx("a",{href:"#"+t,style:ar,onClick:e=>{e.preventDefault();const r=document.getElementById(t);r&&requestAnimationFrame(()=>r.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,ar)},children:"Skip to data table"})}function br({hoverPoint:t}){let r="";if(t){const e=t.data||t;r="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:ar,children:r})}const xr=Object.freeze([]);function kr(e){if(!e)return xr;let t=!1;for(let r=0;e.length>r;r++){const n=e[r];if(null==n||"object"!=typeof n){t=!0;break}}if(!t)return e;const r=[];for(const t of e)null!=t&&"object"==typeof t&&r.push(t);return r}function wr(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Sr(e,t,r=.3){wr(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Ar(e,t,r=.6){var n,o,i,a,s;if(!wr(t))return;const l=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*r,e.stroke()}function jr(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Lr(e,t){var r,n,o,i,a,s;if(!t.pathD)return;e.save();const l=jr(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!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,s="string"==typeof t.style.fill?t.style.fill:"#999",l=Ot(e,s)||s;o.addColorStop(0,1===a.from?l:"transparent"),o.addColorStop(1,1===a.to?l:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&Ot(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(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ot(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Mr(e,t){var r,n;e.save();const o=t.style.stroke||"#999";e.strokeStyle=Ot(e,o)||o,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Dr(e,t){var r,n,o,i;if(!t.pathD)return;e.save();const a=jr(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Ot(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ot(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 Cr(e,t){var r,n;if(!t.pathD)return;e.save();const o=jr(t),i=t.style.stroke||"#999";e.strokeStyle=Ot(e,i)||i,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Ot(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}const Er={top:20,right:80,bottom:20,left:80},_r={top:40,right:40,bottom:40,left:40},Pr=new Set(["chord","force","circlepack","orbit"]),Ir=[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 Nr({data:t}){var r,n,o,i,a,s;if("edge"===t.nodeOrEdge){const r=t.data;return r?e.jsxs("div",{className:"semiotic-tooltip",style:Or,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof r.source?r.source.id:r.source," → ","object"==typeof r.target?r.target.id:r.target]}),null!=r.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof r.value?r.value.toLocaleString():r.value+""]})]}):null}const l=t.data;if(!l)return null;const c=l.__hierarchyNode;if(c){const t=[];let a=c;for(;a;){const e=null!==(i=null!==(n=null===(r=a.data)||void 0===r?void 0:r.name)&&void 0!==n?n:null===(o=a.data)||void 0===o?void 0:o.id)&&void 0!==i?i:l.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const s=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:Or,children:[e.jsx("div",{children:t.map((t,r)=>e.jsxs("span",{children:[r>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),r===s?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},r))}),null!=l.value&&l.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof l.value?l.value.toLocaleString():l.value+""})]})}const u=((null===(a=l.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(s=l.targetLinks)||void 0===s?void 0:s.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:Or,children:[e.jsx("div",{style:{fontWeight:600},children:l.id}),null!=l.value&&l.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const Tr=t.forwardRef(function(r,n){var o,i,a,l,c,u,g,y,p,v,m,b,x,k,w,S,A,j;const{chartType:L,nodes:M,edges:D,data:C,initialEdges:E,nodeIDAccessor:_="id",sourceAccessor:P="source",targetAccessor:I="target",valueAccessor:O="value",edgeIdAccessor:N,childrenAccessor:T,hierarchySum:W,orientation:R="horizontal",nodeAlign:$="justify",nodePaddingRatio:B=.05,nodeWidth:z=15,iterations:H=300,forceStrength:F=.1,padAngle:Y=.01,groupWidth:X=20,sortGroups:G,edgeSort:q,treeOrientation:V="vertical",edgeType:K="curve",padding:Z,paddingTop:U,tensionConfig:Q,showParticles:J=!1,particleStyle:ee,nodeStyle:te,edgeStyle:re,colorBy:ne,colorScheme:oe="category10",edgeColorBy:ie="source",edgeOpacity:ae=.5,colorByDepth:se=!1,nodeSize:le=8,nodeSizeRange:ce=[5,20],nodeLabel:ue,showLabels:de=!0,labelMode:he,size:fe=Ir,responsiveWidth:ge,responsiveHeight:ye,margin:pe,className:ve,background:me,enableHover:be=!0,tooltipContent:xe,customHoverBehavior:ke,customClickBehavior:we,onObservation:Se,chartId:Ae,onTopologyChange:je,annotations:Le,svgAnnotationRules:Me,legend:De,legendPosition:Ce,legendHoverBehavior:Ee,legendClickBehavior:_e,legendHighlightedCategory:Pe,legendIsolatedCategories:Ie,title:Oe,foregroundGraphics:Ne,backgroundGraphics:Te,decay:We,pulse:Re,transition:$e,animate:Be,staleness:ze,thresholds:He,accessibleTable:Fe=!0,description:Xe,summary:Ge,orbitMode:qe,orbitSize:Ve,orbitSpeed:Ke,orbitRevolution:Ze,orbitRevolutionStyle:Ue,orbitEccentricity:Qe,orbitShowRings:et,orbitAnimated:rt,customNetworkLayout:ot,layoutConfig:it}=r,at=Pr.has(L)?_r:Er,st=t.useRef(!0),lt=Wt({sizeProp:fe,responsiveWidth:ge,responsiveHeight:ye,userMargin:pe,marginDefault:at,foregroundGraphics:Ne,backgroundGraphics:Te,animate:Be,transitionProp:$e,themeDirtyRef:st}),{reducedMotionRef:ct,responsiveRef:dt,size:ft,margin:pt,adjustedWidth:vt,adjustedHeight:bt,resolvedForeground:xt,resolvedBackground:kt,transition:wt,introEnabled:St,tableId:At,rafRef:jt,renderFnRef:Lt,scheduleRender:Mt,currentTheme:Dt}=lt,Ct=function(){const[e,r]=t.useState(!1);return Qt(()=>{r(!0)},[]),e}(),Et=function(){const e=t.useSyncExternalStore(Jt,er,tr);return t.useRef(e).current}(),_t=t.useMemo(()=>kr(M),[M]),Pt=t.useMemo(()=>Array.isArray(D)?kr(D):D,[D]),It=t.useMemo(()=>Object.assign(Object.assign({},h),Q),[Q]),Nt=t.useMemo(()=>Object.assign(Object.assign({},f),ee),[ee]),Tt=t.useMemo(()=>{var e;return{chartType:L,nodeIDAccessor:_,sourceAccessor:P,targetAccessor:I,valueAccessor:O,edgeIdAccessor:N,childrenAccessor:T,hierarchySum:W,orientation:R,nodeAlign:$,nodePaddingRatio:B,nodeWidth:z,iterations:H,forceStrength:F,padAngle:Y,groupWidth:X,sortGroups:G,edgeSort:q,treeOrientation:V,edgeType:K,padding:Z,paddingTop:U,tensionConfig:It,showParticles:J,particleStyle:Nt,nodeStyle:te,edgeStyle:re,nodeLabel:ue,showLabels:de,labelMode:he,colorBy:ne,colorScheme:oe,themeCategorical:null===(e=null==Dt?void 0:Dt.colors)||void 0===e?void 0:e.categorical,themeSemantic:mt(Dt),edgeColorBy:ie,edgeOpacity:ae,colorByDepth:se,nodeSize:le,nodeSizeRange:ce,decay:We,pulse:Re,transition:wt,introAnimation:St,staleness:ze,thresholds:He,orbitMode:qe,orbitSize:Ve,orbitSpeed:Ke,orbitRevolution:Ze,orbitRevolutionStyle:Ue,orbitEccentricity:Qe,orbitShowRings:et,orbitAnimated:rt,customNetworkLayout:ot,layoutConfig:it}},[L,_,P,I,O,T,W,R,$,B,z,H,F,Y,X,G,q,V,K,Z,U,It,J,Nt,te,re,ue,de,he,ne,oe,ie,ae,se,le,ce,We,Re,null==wt?void 0:wt.duration,null==wt?void 0:wt.easing,St,ze,He,qe,Ve,Ke,Ze,Ue,Qe,et,rt,Dt,ot,it]),Rt=function(e){const r=t.useRef(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return nr(e,t);if(!or(e)||!or(t))return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const n of r){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;const r=e[n],o=t[n];if(!Object.is(r,o))if(Array.isArray(r)&&Array.isArray(o)){if(!nr(r,o))return!1}else{if(!or(r)||!or(o))return!1;if(!rr(r,o))return!1}}return!0}(r.current,e)||(r.current=e),r.current}(Tt),$t=t.useRef(null),Bt=t.useRef(0),zt=t.useRef(0),Ht=t.useRef(!1),Ft=t.useRef(null);Ft.current||(Ft.current=new Je(Rt));const[Yt,Xt]=t.useState(null),[Gt,qt]=t.useState(0),[ir,ar]=t.useState(0),[lr,cr]=t.useState(!1),[ur,dr]=t.useState(null),hr=t.useRef(null),fr=t.useRef(new Map),gr=t.useRef(0),yr=t.useCallback(e=>{if("function"==typeof ne)return ne(e)+"";if("string"==typeof ne&&e.data){const t=e.data[ne];if(void 0!==t){if(!fr.current.has(t+"")){const e=Array.isArray(oe)?oe:Ye;fr.current.set(t+"",e[gr.current++%e.length])}return fr.current.get(t+"")}}if(fr.current.has(e.id))return fr.current.get(e.id);const t=Array.isArray(oe)?oe:Ye,r=ne?t[gr.current++%t.length]:t[0];return fr.current.set(e.id,r),r},[ne,oe]),xr=(null===(o=null==Dt?void 0:Dt.colors)||void 0===o?void 0:o.border)||(null===(i=null==Dt?void 0:Dt.colors)||void 0===i?void 0:i.secondary)||(null===(a=null==Dt?void 0:Dt.colors)||void 0===a?void 0:a.primary)||"#999",wr=t.useCallback(e=>{if("function"==typeof ie)return ie(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===ie&&r?yr(r):t?yr(t):xr},[ie,yr,xr]),jr=t.useCallback(e=>{if(!(null==ee?void 0:ee.colorBy))return wr(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Nt.colorBy&&r?yr(r):t?yr(t):xr},[null==ee?void 0:ee.colorBy,Nt.colorBy,yr,wr,xr]),Or="sankey"===L&&J||!!Re||null!==(c=null===(l=Ft.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=Ft.current)||void 0===e||e.updateConfig(Rt),st.current=!0,Mt()},[Rt,Mt]);const Tr=t.useCallback(()=>{var e,t;dr(null!==(t=null===(e=Ft.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);t.useEffect(()=>{var e;const t=Ft.current;if(t){t.buildScene([vt,bt]),Tr();for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&fr.current.set(r.id,r.style.fill);st.current=!0,Mt()}},[Dt,vt,bt,Mt,Tr]);const Wr=t.useCallback(()=>{var e;const t=Ft.current;if(!t)return;t.runLayout([vt,bt]),t.buildScene([vt,bt]),Tr(),st.current=!0;for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&fr.current.set(r.id,r.style.fill);const r=Array.isArray(oe)?oe:Ye,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];fr.current.has(t.id)||fr.current.set(t.id,r[e%r.length])}if(gr.current=n.length,qt(t.layoutVersion),je){const{nodes:e,edges:r}=t.getLayoutData();je(e,r)}},[vt,bt,je,oe,Tr]),Rr=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=Ft.current;t&&(t.ingestEdge(e)&&Wr(),Mt())},[Wr,Mt]),$r=t.useCallback(e=>{const t=Ft.current;if(!t)return;let r=!1;for(const n of e)null!=n&&"object"==typeof n&&t.ingestEdge(n)&&(r=!0);r&&Wr(),Mt()},[Wr,Mt]),Br=t.useCallback(()=>{var e;null===(e=Ft.current)||void 0===e||e.clear(),fr.current.clear(),gr.current=0,qt(0),Xt(null),hr.current=null,st.current=!0,Mt()},[Mt]),zr=t.useCallback(()=>{const e=Ft.current;e&&(e.tension+=999,Wr(),Mt())},[Wr,Mt]);t.useImperativeHandle(n,()=>({push:Rr,pushMany:$r,removeNode:e=>{var t,r,n;const o=null!==(r=null===(t=Ft.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==r&&r;if(o){const t=(null===(n=hr.current)||void 0===n?void 0:n.data)?"function"==typeof _?_(hr.current.data):hr.current.data[_]:void 0;hr.current&&"node"===hr.current.nodeOrEdge&&t===e&&(hr.current=null,Xt(null)),fr.current.delete(e),Wr(),st.current=!0,Mt()}return o},removeEdge:(e,t)=>{var r,n;const o=null!==(n=null===(r=Ft.current)||void 0===r?void 0:r.removeEdge(e,t))&&void 0!==n&&n;if(o){if(hr.current&&"edge"===hr.current.nodeOrEdge){const r=hr.current.data;let n;n=void 0!==t?("object"==typeof(null==r?void 0:r.source)?r.source.id:null==r?void 0:r.source)===e&&("object"==typeof(null==r?void 0:r.target)?r.target.id:null==r?void 0:r.target)===t:!N||!r||("function"==typeof N?N:e=>null==e?void 0:e[N])(r)===e,n&&(hr.current=null,Xt(null))}Wr(),st.current=!0,Mt()}return o},updateNode:(e,t)=>{var r,n;const o=null!==(n=null===(r=Ft.current)||void 0===r?void 0:r.updateNode(e,t))&&void 0!==n?n:null;return o&&(st.current=!0,Mt()),o},updateEdge:(e,t,r)=>{var n,o;const i=null!==(o=null===(n=Ft.current)||void 0===n?void 0:n.updateEdge(e,t,r))&&void 0!==o?o:[];return i.length>0&&(Wr(),st.current=!0,Mt()),i},clear:Br,getTopology:()=>{var e,t;return null!==(t=null===(e=Ft.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ft.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:zr,getTension:()=>{var e,t;return null!==(t=null===(e=Ft.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Rr,$r,Br,zr,Wr,Mt]);const Hr=["tree","cluster","treemap","circlepack","partition","orbit"].includes(L),Fr=Hr?C||(Array.isArray(D)?void 0:D):void 0;t.useEffect(()=>{var e;const t=Ft.current;if(t)if(Hr&&Fr)t.ingestHierarchy(Fr,[vt,bt]),t.buildScene([vt,bt]),Tr(),st.current=!0,Mt();else{const r=_t,n=Array.isArray(Pt)?Pt:[];if(0===r.length&&0===n.length)return;t.ingestBounded(r,n,[vt,bt]),t.buildScene([vt,bt]),Tr();for(const r of t.sceneNodes)r.id&&(null===(e=r.style)||void 0===e?void 0:e.fill)&&fr.current.set(r.id,r.style.fill+"");const o=Array.isArray(oe)?oe:Ye,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];fr.current.has(t.id)||fr.current.set(t.id,o[e%o.length])}gr.current=i.length,st.current=!0,Mt()}},[_t,Pt,C,Fr,Hr,vt,bt,Rt,Mt,oe,Tr]),t.useEffect(()=>{E&&E.length>0&&$r(E)},[]);const Yr=t.useCallback(e=>{if(ke&&ke(e),Se){const t=Date.now();Se(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae})}},[ke,Se,Ae]),Xr=t.useCallback(e=>{if(we&&we(e),Se){const t=Date.now();Se(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae})}},[we,Se,Ae]),{hoverHandlerRef:Gr,hoverLeaveRef:qr,onPointerMove:Vr,onPointerLeave:Kr}=lt;Gr.current=e=>{if(!be)return;const t=$t.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-pt.left,o=e.clientY-r.top-pt.top;if(0>n||n>vt||0>o||o>bt)return void(hr.current&&(hr.current=null,Xt(null),Yr&&(Yr(null),st.current=!0),Mt()));const i=Ft.current;if(!i)return;const a=nt(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(hr.current&&(hr.current=null,Xt(null),Yr&&(Yr(null),st.current=!0),Mt()));const s=d(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});hr.current=s,Xt(s),Yr&&(Yr(s),st.current=!0),Mt()},qr.current=()=>{hr.current&&(hr.current=null,Xt(null),Yr&&(Yr(null),st.current=!0),Mt())};const Zr=t.useRef(()=>{});Zr.current=e=>{if(!we&&!Se)return;const t=$t.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-pt.left,o=e.clientY-r.top-pt.top;if(0>n||n>vt||0>o||o>bt)return;const i=Ft.current;if(!i)return;const a=nt(i.sceneNodes,i.sceneEdges,n,o);Xr(a?d(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)};const Ur=t.useCallback(e=>Zr.current(e),[]),Qr=t.useRef(-1),Jr=t.useRef(null),en=t.useRef(-1),tn=t.useCallback(e=>{var t;const r=Ft.current;if(!r)return;const n=function(e){var t,r,n,o,i,a;const s=[];for(const l of e)"circle"===l.type&&null!=l.cx?s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(r=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==r?r:"_default"}):"rect"===l.type&&null!=l.x?s.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=null===(n=l.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:"_default"}):"arc"===l.type&&null!=l.cx&&s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(a=null===(i=l.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(r.sceneNodes);if(0===n.length)return;const o=function(e){var t,r;const n=new Map;for(const r of e){const e=null!==(t=r.group)&&void 0!==t?t:"_default";let o=n.get(e);o||(o=[],n.set(e,o)),o.push(r)}for(const e of n.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(n.keys()).sort((e,t)=>{const r=n.get(e),o=n.get(t);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(n.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(r=i[e].datum)||void 0===r?void 0:r.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:o,byGroup:n,idToIdx:a}}(n),i=Qr.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(),Qr.current=0,en.current=-1;const t=o.flat[0];Jr.current={shape:t.shape,w:t.w,h:t.h};const r=d(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return hr.current=r,Xt(r),Yr&&(Yr(r),st.current=!0),void Mt()}const a=function(e,t){var r,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(r=i.group)&&void 0!==r?r:"_default",indexInGroup:null!==(n=i._groupIndex)&&void 0!==n?n:0}}(o,i),s=function(e,t,r,n,o){var i,a,s;const l=r.flat[t.flatIndex];if(!l)return ut(e,t,r);const c=null===(i=l.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(a=function(e,t,r){let n=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(r){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;o>u&&(o=u,n=i)}return n}(r,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return n!==t.flatIndex&&(o.current=-1),n}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var r;const n=e+"",o=[];for(const e of t){const t=null!==(r=e.datum)&&void 0!==r?r:e,i=ht(t.source),a=ht(t.target),s=null!=i,l=null!=a;s&&i+""===n&&l?o.push(a+""):l&&a+""===n&&s&&o.push(i+"")}return o}(c,n);if(0===e.length)return t.flatIndex;const i=null!==(s=r.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const n=ut(e,t,r);return null!==n&&n!==t.flatIndex&&(o.current=-1),n}}}(e.key,a,o,null!==(t=r.sceneEdges)&&void 0!==t?t:[],en);if(null===s)return;if(e.preventDefault(),0>s)return Qr.current=-1,Jr.current=null,en.current=-1,hr.current=null,Xt(null),Yr&&(Yr(null),st.current=!0),void Mt();Qr.current=s;const l=o.flat[s];Jr.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};hr.current=c,Xt(c),Yr&&(Yr(c),st.current=!0),Mt()},[Yr,Mt]),rn=t.useCallback(e=>{Qr.current=-1,Jr.current=null,Vr(e)},[Vr]);Lt.current=()=>{var e,t,r,n,o,i,a;jt.current=0;const s=$t.current;if(!s)return;const l=s.getContext("2d");if(!l)return;const c=Ft.current;if(!c)return;const u=performance.now(),d=Bt.current?Math.min((u-Bt.current)/1e3,.1):.016;Bt.current=u;const h=c.advanceTransition(ct.current?u+1e6:u),g=!ct.current&&h,y=!ct.current&&c.tickAnimation([vt,bt],d);(h||st.current||y)&&c.buildScene([vt,bt]);const p="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,r,n){const o=e.getContext("2d");if(!o)return null;const i=t[0]*n,a=t[1]*n,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(n,0,0,n,0,0),o.translate(r.left,r.top),o}(s,ft,pt,p))return;if(l.clearRect(-pt.left,-pt.top,ft[0],ft[1]),me){const e=Ot(l,me);e&&(l.fillStyle=e,l.fillRect(0,0,vt,bt))}We&&c.applyDecay(),Re&&c.applyPulse(u),He&&c.applyThresholds(u),c.applyTopologyDiff(u);const v=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,m=ze&&c.lastIngestTime>0&&u-c.lastIngestTime>v;if(m&&(l.globalAlpha=null!==(t=null==ze?void 0:ze.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Lr(e,r);break;case"line":Mr(e,r);break;case"ribbon":Dr(e,r);break;case"curved":Cr(e,r)}}(l,c.sceneEdges),function(e,t){var r,n,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Ot(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ot(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),Sr(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Ot(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ot(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),Ar(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Ot(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ot(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(l,c.sceneNodes),J&&c.particlePool&&!m){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:f.spawnRate,s=null!==(i=n.maxPerEdge)&&void 0!==i?i:f.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=s)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<s;t++)e.spawn(n)}}(c.particlePool,e,d,Nt);const t=.5*(null!==(r=Nt.speedMultiplier)&&void 0!==r?r:1);let n;if(Nt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,n),function(e,t,r,n,o){var i,a;const s=null!==(i=n.radius)&&void 0!==i?i:f.radius,l=null!==(a=n.opacity)&&void 0!==a?a:f.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=r[a.edgeIndex];if(l){if("function"==typeof n.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?n.color(l,t):Ot(e,"var(--semiotic-secondary, #666)")}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(l,c.particlePool,e,Nt,jr)}}m&&(l.globalAlpha=1);const b=st.current;if(st.current=!1,b||g||y){const e=$t.current;e&&e.setAttribute("aria-label",sr(null!==(o=null===(n=c.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}const x=b||g||y||Ht.current;x&&u-zt.current>=33?(ar(e=>e+1),zt.current=u,Ht.current=!1):Ht.current=!!x,(Or||g||null!=c.transition||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Ht.current)&&(jt.current=requestAnimationFrame(()=>Lt.current()))},function(e){const{hydrated:r,wasHydratingFromSSR:n,storeRef:o,dirtyRef:i,renderFnRef:a,cleanup:s}=e;Qt(()=>{var e,t;r&&n&&(null===(t=null===(e=o.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),i.current=!0,a.current()},[r,n]);const l=t.useRef(s);l.current=s,t.useEffect(()=>()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)},[])}({hydrated:Ct,wasHydratingFromSSR:Et,storeRef:Ft,dirtyRef:st,renderFnRef:Lt}),t.useEffect(()=>{st.current=!0,Mt()},[L,vt,bt,me,Mt]),function(e,r,n,o,i,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const s=r.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(t)},[e,i,o])}(ze,Ft,st,Mt,lr,cr);const nn=be&&Yt?e.jsx(yt,{x:Yt.x,y:Yt.y,containerWidth:vt,containerHeight:bt,margin:pt,className:"stream-network-tooltip",zIndex:2,children:xe?xe(Yt):e.jsx(Nr,{data:Yt})}):null;if(Ut||!Ct&&Et){const t=Ft.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(L),r=e?C||(Array.isArray(D)?void 0:D):void 0;if(e&&r)t.ingestHierarchy(r,[vt,bt]),t.buildScene([vt,bt]);else{const e=_t,r=Array.isArray(Pt)?Pt:[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[vt,bt]),t.buildScene([vt,bt]))}}const r=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],n=null!==(g=null==t?void 0:t.sceneEdges)&&void 0!==g?g:[],o=null!==(y=null==t?void 0:t.labels)&&void 0!==y?y:[];return e.jsxs("div",{ref:dt,className:"stream-network-frame"+(ve?" "+ve:""),role:"img","aria-label":Xe||("string"==typeof Oe?Oe:"Network chart"),style:{position:"relative",width:ge?"100%":ft[0],height:ye?"100%":ft[1]},children:[e.jsx(vr,{summary:Ge}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ft[0],height:ft[1],style:{position:"absolute",left:0,top:0},children:[kt&&e.jsx("g",{transform:`translate(${pt.left},${pt.top})`,children:kt}),e.jsxs("g",{transform:`translate(${pt.left},${pt.top})`,children:[me&&e.jsx("rect",{x:0,y:0,width:vt,height:bt,fill:me}),n.map((t,r)=>function(t,r){switch(t.type){case"line":return e.jsx("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-"+r);case"bezier":{const n=t;return e.jsx("path",{d:n.pathD,fill:Zt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+r)}case"ribbon":{const n=t;return e.jsx("path",{d:n.pathD,fill:Zt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+r)}case"curved":{const n=t;return e.jsx("path",{d:n.pathD,fill:Zt(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+r)}default:return null}}(t,r)).filter(Boolean),r.map((t,r)=>function(t,r){switch(t.type){case"circle":{const n=t;return e.jsx("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:Zt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+r)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Zt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+r)}case"arc":{const n=t,o=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Kt)||"";return e.jsx("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:Zt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+r)}default:return null}}(t,r)).filter(Boolean),o.map((t,r)=>function(t,r){return e.jsx("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-"+r)}(t,r)).filter(Boolean)]})]}),e.jsx(Vt,{width:vt,height:bt,totalWidth:ft[0],totalHeight:ft[1],margin:pt,labels:o,sceneNodes:r,title:Oe,legend:De,legendPosition:Ce,legendHoverBehavior:Ee,legendClickBehavior:_e,legendHighlightedCategory:Pe,legendIsolatedCategories:Ie,foregroundGraphics:tt(xt,null===(p=Ft.current)||void 0===p?void 0:p.customLayoutOverlays),annotations:Le,svgAnnotationRules:Me,annotationFrame:0})]})}const on=Ft.current;return e.jsxs("div",{ref:dt,className:"stream-network-frame"+(ve?" "+ve:""),role:"group","aria-label":Xe||("string"==typeof Oe?Oe:"Network chart"),tabIndex:0,style:{position:"relative",width:ge?"100%":ft[0],height:ye?"100%":ft[1],overflow:"visible"},onKeyDown:tn,children:[Fe&&e.jsx(mr,{tableId:At}),Fe&&e.jsx(pr,{nodes:null!==(v=null==on?void 0:on.sceneNodes)&&void 0!==v?v:[],edges:null!==(m=null==on?void 0:on.sceneEdges)&&void 0!==m?m:[],chartType:"Network chart",tableId:At,chartTitle:"string"==typeof Oe?Oe:void 0}),e.jsx(vr,{summary:Ge}),e.jsxs("div",{role:"img","aria-label":Xe||("string"==typeof Oe?Oe:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:be?rn:void 0,onMouseLeave:be?Kr:void 0,onClick:we||Se?Ur:void 0,children:[kt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ft[0],height:ft[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${pt.left},${pt.top})`,children:kt})}),e.jsx("canvas",{ref:$t,"aria-label":sr(null!==(x=null===(b=null==on?void 0:on.sceneNodes)||void 0===b?void 0:b.length)&&void 0!==x?x:0,null!==(w=null===(k=null==on?void 0:on.sceneEdges)||void 0===k?void 0:k.length)&&void 0!==w?w:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(br,{hoverPoint:Yt}),e.jsx(Vt,{width:vt,height:bt,totalWidth:ft[0],totalHeight:ft[1],margin:pt,labels:(null==on?void 0:on.labels)||[],sceneNodes:null==on?void 0:on.sceneNodes,title:Oe,legend:De,legendPosition:Ce,legendHoverBehavior:Ee,legendClickBehavior:_e,legendHighlightedCategory:Pe,legendIsolatedCategories:Ie,foregroundGraphics:tt(xt,ur),annotations:Le,svgAnnotationRules:Me,annotationFrame:ir}),e.jsx(gt,{active:Qr.current>=0,hoverPoint:Yt,margin:pt,size:ft,shape:null===(S=Jr.current)||void 0===S?void 0:S.shape,width:null===(A=Jr.current)||void 0===A?void 0:A.w,height:null===(j=Jr.current)||void 0===j?void 0:j.h}),nn,(null==ze?void 0:ze.showBadge)&&e.jsx("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:lr?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:lr?"STALE":"LIVE"})]})]})});function Wr(e,r){const{variant:n,frameRef:o,overrides:i,deps:a}=r;t.useImperativeHandle(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var r;return null===(r=e.current)||void 0===r?void 0:r.push(t)},pushMany:t=>{var r;return null===(r=e.current)||void 0===r?void 0:r.pushMany(t)},remove:t=>{var r,n;return null!==(n=null===(r=e.current)||void 0===r?void 0:r.remove(t))&&void 0!==n?n:[]},update:(t,r)=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.update(t,r))&&void 0!==o?o:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,r;return null!==(r=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==r?r:[]},getScales:()=>{var t,r;return null!==(r=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==r?r:null}}}if("network"===e){const e=t;return{push:t=>{var r;return null===(r=e.current)||void 0===r?void 0:r.push(t)},pushMany:t=>{var r;return null===(r=e.current)||void 0===r?void 0:r.pushMany(t)},remove:t=>{var r,n,o,i,a;const s=Array.isArray(t)?t:[t],l=null!==(o=null===(n=null===(r=e.current)||void 0===r?void 0:r.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const t of s){const r=l.find(e=>e.id===t);r&&c.push(Object.assign(Object.assign({},null!==(i=r.data)&&void 0!==i?i:{}),{id:t})),null===(a=e.current)||void 0===a||a.removeNode(t)}return c},update:(t,r)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var n;const o=null===(n=e.current)||void 0===n?void 0:n.updateNode(t,r);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,r,n,o;return null!==(o=null===(n=null===(r=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}}const r=t;return{push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o,i;const a=null!==(o=null===(n=r.current)||void 0===n?void 0:n.removePoint(e))&&void 0!==o?o:[];for(const e of a)null===(i=r.current)||void 0===i||i.push(t(e));return a},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}}(n,o);return Object.assign(Object.assign({},e),i)},null!=a?a:[])}Tr.displayName="StreamNetworkFrame";const Rr={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 $r(e,t){return"function"==typeof t?t(e):e[t]}function Br(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 zr(t={}){const{fields:r,title:n,format:o,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(n){const e=$r(t,n);s=Br(e,o)}if(r&&r.length>0)r.forEach(e=>{let r,n,i;"string"==typeof e?(r=e,n=e,i=o):(r=e.label,n=e.accessor||e.key||"",i=e.format||o);const a=$r(t,n);l.push({label:r,value:Br(a,i)})});else if(!n){const e=["value","y","name","id","label"];for(const r of e)if(void 0!==t[r]){s=Br(t[r],o);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Br(t[e[0]],o))}}const c=Object.assign(Object.assign({},Rr),i);return e.jsxs("div",{className:("semiotic-tooltip "+a).trim(),style:c,children:[s&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:s}),l.map((t,r)=>e.jsxs("div",{style:{marginTop:0===r&&s?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},r))]})}}function Hr(t){if(!0!==t){if("function"==typeof t){const r=t;return t=>{var n;const o=!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!==(n=t.data)&&void 0!==n?n:{}:t,i=r(o);return null==i?null:e.jsx("div",{className:"semiotic-tooltip",style:Rr,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?zr(t):zr())}}const Fr=t.createContext(null);function Yr(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function Xr(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Gr,qr]=pt(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Xr(n,t),i=new Map(o.clauses);return i.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),i=new Map(n.clauses);return i.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=Xr(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}})),[Vr,Kr]=pt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let Zr={positions:new Map};const Ur=new Set;function Qr(){for(const e of Ur)e()}function Jr(e,t){const r=Zr.positions.get(e);if(null==r?void 0:r.locked)return;if(!r||r.sourceId!==t)return;const n=new Map(Zr.positions);n.delete(e),Zr={positions:n},Qr()}function en(e){const r=t.useId(),n=e.clientId||r,{name:o}=e,i=qr(e=>e.selections.get(o)),a=qr(e=>e.setClause),s=qr(e=>e.clearClause),l=t.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:t.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(Yr(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:t.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:t.useCallback(()=>{s(o,n)},[s,o,n]),clientId:n}}const tn=t.createContext(!1),rn=t.createContext(null),nn="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function on(e,t,r){var n;const o=null!==(n=e.xValue)&&void 0!==n?n:null==t?void 0:t[r];if(null==o)return null;const i=Number(o);return Number.isFinite(i)?i:null}function an(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 sn(){var e;const t=Lt(e=>e.theme),r=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return r&&r.length>0?r:void 0}function ln(e,t,r,n,o){let i;if(Array.isArray(r))i=r;else if(t&&t.length>0)i=t;else if("string"==typeof r){const e=Fe[r];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function cn(e,r,n){const o=t.useContext(Fr),i=sn();return t.useMemo(()=>{var t;if(!r)return;const a=null!==(t=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof r){const t=Array.from(new Set(e.map(e=>r(e)+"")));if(o&&Object.keys(o).length>0){const e=Ke(t.map(e=>({_cat:e})),"_cat",a);return t=>o[t]||e(t)}return Ke(t.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const t=Ke(e,r,a);return e=>o[e]||t(e)}return Ke(e,r,a)}if(o&&Object.keys(o).length>0){const e=Ke([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[e,r,n,o,i])}function un({selection:e,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(r,n),f=en({name:(null==e?void 0:e.name)||"__unused__"}),g=function(e){const r=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:a,clear:s}=en({name:r});return{onHover:t.useCallback(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&a(t)},[n,a,s,r]),predicate:o,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),y=Kr(e=>e.pushObservation),p=e?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=t.useState(null),b=u||n[0],x=t.useMemo(()=>{if(!c||null==v||!b)return null;const e=v,t=b;return{isActive:!0,predicate:r=>{var n;return("string"==typeof r[t]?r[t]:(null!==(n=r[t])&&void 0!==n?n:"")+"")===e}}},[c,v,b]),k=t.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const r=on(e,t,h.xField);null!=r&&function(e,t,r){const n=Zr.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===r||(Zr={positions:new Map(Zr.positions).set(e,{xValue:t,sourceId:r})},Qr())}(h.name||"hover",r,d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Jr(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[b];m(null!=r?r+"":null)}else m(null);if(i||y){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const o=an(e),a=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),y&&y(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),y&&y(e)}}},[r,g,h,d,i,a,s,y,c,b]),w=t.useCallback(e=>{var t,r,n,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=on(e,t,h.xField);null!=r&&function(e,t,r){const n=Zr.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(Zr.positions);return t.delete(e),Zr={positions:t},Qr(),!1}Zr={positions:new Map(Zr.positions).set(e,{xValue:t,sourceId:r,locked:!0})},Qr()}(h.name||"hover",r,d)}if(e&&l){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),l(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0})}if(i||y){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const r=an(e),a=Object.assign(Object.assign({},t),{type:"click",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),y&&y(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),y&&y(e)}}},[l,i,y,a,s,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{!function(e,t){const r=Zr.positions.get(e);if(!(null==r?void 0:r.locked))return;if(t&&r.sourceId!==t)return;const n=new Map(Zr.positions);n.delete(e),Zr={positions:n},Qr()}(e,d),Jr(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function dn({data:e,colorBy:r,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(tn),u=null!==t.useContext(rn),d=void 0!==o?o:!c&&!!r,h=!!r&&(d||u),f=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const n of e){const e="function"==typeof r?r(n):n[r];null!=e&&t.add(e+"")}return Array.from(t)},[l,r,e,h]);!function(e){const r=t.useContext(rn),n=t.useId(),o=function(e){const t=new Set,r=[];for(const n of e)t.has(n)||(t.add(n),r.push(n));return r}(e),i=t.useRef([]);(function(e,t){if(e.length!==t.length)return!1;for(let r=0;e.length>r;r++)if(e[r]!==t[r])return!1;return!0})(i.current,o)||(i.current=o);const a=i.current;nn(()=>{if(r)return()=>r.unregisterCategories(n)},[r,n]),nn(()=>{r&&r.registerCategories(n,a)},[r,n,a])}(u&&r?f:[]);const g=t.useMemo(()=>{if(!d||!r)return;const t=function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i,categories:a}){const s=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?n(a,t,r):r?r(o):Xe[i%Xe.length];return{label:o+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",r={fill:t,stroke:t};return void 0!==o&&(r.stroke=o),void 0!==i&&(r.strokeWidth=i),r},type:"fill",items:s,label:""}]}}({data:e,colorBy:r,colorScale:n,getColor:Ve,categories:f});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,r,e,n,f]),y=t.useMemo(()=>{const e="number"==typeof a?{top:a,bottom:a,left:a,right:a}:null!=a?a:{},t=Object.assign(Object.assign({},s),e);return g&&("right"===i&&110>t.right?t.right=110:"left"===i&&110>t.left?t.left=110:"top"===i&&50>t.top?t.top=50:"bottom"===i&&80>t.bottom&&(t.bottom=80)),t},[s,a,g,i]);return{legend:g,margin:y,legendPosition:i}}function hn(e,r,n){const[o,i]=t.useState(null),[a,s]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&i(t?t.label:null)},[e]),c=t.useCallback(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]),u=t.useMemo(()=>{if(!e||"none"===e||!r)return null;const t="string"==typeof r?r:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof r?r(e):null)===o}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const n=t?e[t]:"function"==typeof r?r(e):null;return a.has(n)}}:null},[e,r,o,a]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}u.createContext(void 0);const fn={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 gn(e,t,r){var n,o,i,a,s,l,c;const u=fn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?u.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?u.height:r.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:yn(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function yn(e,t,r){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===r?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function pn(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const r={};return void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),e?(...t)=>{const n=e(...t)||{};return Object.assign(Object.assign({},n),r)}:(...e)=>Object.assign({},r)}function vn({componentName:t,message:r,diagnosticHint:n,width:o,height:i}){return e.jsx("div",{role:"alert",style:{width:o,height:Math.max(i,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:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:r}),n&&e.jsx("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:n})]})})}class mn extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var r,n;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,r=this.state.error;return"function"==typeof t?t(r):void 0!==t?t:e.jsx(vn,{componentName:"ChartErrorBoundary",message:r.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function bn({componentName:t,width:r,height:n,children:o}){return e.jsx(mn,{fallback:o=>e.jsx(vn,{componentName:t,message:o.message,width:r,height:n}),children:o})}"undefined"!=typeof process&&process;const xn={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"},kn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function wn(t,r,n,o){return!1===o||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},xn),{width:r,height:n}),children:o||"No data available"}):null}function Sn(t,r,n){if(!t)return null;const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(i+a)-a))/2);return e.jsx("div",{style:{width:r,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(t,n)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},kn),{position:"absolute",top:s+n*(i+a),left:Math.floor(.1*r),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2})},n))})}function An(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function jn(e,t){var r;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(r=function(e,t,r=3){let n,o=r+1;for(const r of t){const t=An(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}(e,t,3))&&void 0!==r?r:null)}function Ln({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Mn({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const r=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){const r=jn(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}const Dn=t.forwardRef(function(r,n){var o;const i=t.useRef(null);Wr(n,{variant:"network",frameRef:i});const a=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLegend:r.showLegend,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{nodes:s,edges:l,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:h,sourceAccessor:f="source",targetAccessor:g="target",nodeLabel:y,colorBy:p,colorScheme:v,nodeSize:m=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:k="#999",edgeOpacity:w=.6,iterations:S=300,forceStrength:A=.1,tooltip:j,frameProps:L={},onObservation:M,onClick:D,chartId:C,selection:E,linkedHover:_,loading:P,emptyContent:I,legendInteraction:O,legendPosition:N,stroke:T,strokeWidth:W,opacity:R}=r,$=null!==(o=null!=d?d:h)&&void 0!==o?o:"id",{width:B,height:z,enableHover:H,showLegend:F,showLabels:Y=!1,title:X,description:G,summary:q,accessibleTable:V}=a,K=t.useMemo(()=>kr(s),[s]),Z=t.useMemo(()=>kr(l),[l]),U=Sn(P,B,z),Q=U?null:wn(void 0===s?void 0:K,B,z,I),J=cn(K,p,v),ee=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of K){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[K,p]),te=hn(O,p,ee),re=sn(),ne=t.useMemo(()=>new Map,[]),oe=t.useMemo(()=>{if(Array.isArray(v))return v;if(re&&re.length>0)return re;const e=Fe[v];return Array.isArray(e)?e:Ye},[v,re]),ie=t.useMemo(()=>e=>{const t={};return t.fill=p?Ve(e.data||e,p,J):ln(0,re,v),"number"==typeof m&&(t.r=m),t},[p,J,m,re,v,ne]),ae=t.useMemo(()=>pn(ie,{stroke:T,strokeWidth:W,opacity:R}),[ie,T,W,R]),se=t.useMemo(()=>e=>({stroke:k,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:w}),[x,k,w]),le=t.useMemo(()=>pn(se,{stroke:T,strokeWidth:W,opacity:R}),[se,T,W,R]),ce=t.useMemo(()=>{if(Y&&y)return"function"==typeof y?y:e=>{var t,r,n;return null!==(n=null!==(r=null===(t=e.data)||void 0===t?void 0:t[y])&&void 0!==r?r:e[y])&&void 0!==n?n:e.id}},[Y,y]),{legend:ue,margin:de,legendPosition:he}=dn({data:K,colorBy:p,colorScale:J,showLegend:F,legendPosition:N,userMargin:c,defaults:a.marginDefaults}),{customHoverBehavior:fe,customClickBehavior:ge}=un({selection:E,linkedHover:_,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:M,onClick:D,chartType:"ForceDirectedGraph",chartId:C}),ye=Mn({componentName:"ForceDirectedGraph",nodes:s,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:$}});return ye?e.jsx(vn,{componentName:"ForceDirectedGraph",message:ye,width:B,height:z}):U||Q||e.jsx(bn,{componentName:"ForceDirectedGraph",width:B,height:z,children:e.jsx(Tr,Object.assign({ref:i,chartType:"force"},null!=s&&{nodes:K},null!=l&&{edges:Z},{size:[B,z],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:de,nodeIDAccessor:$,sourceAccessor:f,targetAccessor:g,iterations:S,forceStrength:A,nodeStyle:ae,edgeStyle:le,colorBy:p,colorScheme:oe,nodeSize:m,nodeSizeRange:b,nodeLabel:ce,showLabels:Y,enableHover:H,tooltipContent:!1===j?()=>null:Hr(j)||void 0,customHoverBehavior:_||M||D?fe:void 0,customClickBehavior:M||D?ge:void 0,legend:ue,legendPosition:he},O&&"none"!==O&&{legendHoverBehavior:te.onLegendHover,legendClickBehavior:te.onLegendClick,legendHighlightedCategory:te.highlightedCategory,legendIsolatedCategories:te.isolatedCategories},{className:u,title:X,description:G,summary:q,accessibleTable:V},null!=r.animate&&{animate:r.animate},L))})});function Cn(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function En(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],i="function"==typeof n?n(e):e[n];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function _n(e){return"function"==typeof e?e:t=>t[e]||1}function Pn({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:o},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=Ve(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ve(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}Dn.displayName="ForceDirectedGraph";const In=t.forwardRef(function(r,n){const o=t.useRef(null);Wr(n,{variant:"network",frameRef:o,overrides:{getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}});const i=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:800,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",orientation:v="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,edgeOpacity:w=.5,edgeSort:S,tooltip:A,frameProps:j={},onObservation:L,onClick:M,chartId:D,selection:C,linkedHover:E,loading:_,emptyContent:P,legendInteraction:I,stroke:O,strokeWidth:N,opacity:T}=r,{width:W,height:R,enableHover:$,showLabels:B=!0,title:z,description:H,summary:F,accessibleTable:Y}=i,X=t.useMemo(()=>kr(s),[s]),G=t.useMemo(()=>kr(a),[a]),q=Sn(_,W,R),V=q?null:wn(void 0===s?void 0:X,W,R,P),K=t.useMemo(()=>En(G,X,u,d),[G,X,u,d]),Z=cn(K,g,y),U=t.useMemo(()=>{if(!g)return[];const e=new Set;for(const t of K){const r="function"==typeof g?g(t):t[g];null!=r&&e.add(r+"")}return Array.from(e)},[K,g]),Q=hn(I,g,U),J=sn(),ee=t.useMemo(()=>new Map,[]),te=t.useMemo(()=>{if(Array.isArray(y))return y;if(J&&J.length>0)return J;const e=Fe[y];return Array.isArray(e)?e:Ye},[y,J]),re=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Ve(e.data||e,g,Z):ln(0,J,y),t},[g,Z,J,y,ee]),ne=t.useMemo(()=>pn(re,{stroke:O,strokeWidth:N,opacity:T}),[re,O,N,T]),oe=t.useMemo(()=>Pn({edgeColorBy:p,colorBy:g,colorScale:Z,nodeStyleFn:ne,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[p,g,Z,ne,w]),ie=t.useMemo(()=>pn(oe,{stroke:O,strokeWidth:N,opacity:T}),[oe,O,N,T]),ae=t.useMemo(()=>{if(!B)return;const e=k||f;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[B,k,f]),se=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof l?{top:l,bottom:l,left:l,right:l}:l),{customHoverBehavior:le,customClickBehavior:ce}=un({selection:C,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:L,onClick:M,chartType:"SankeyDiagram",chartId:D}),ue=Mn({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ue?e.jsx(vn,{componentName:"SankeyDiagram",message:ue,width:W,height:R}):q||V||e.jsx(bn,{componentName:"SankeyDiagram",width:W,height:R,children:e.jsx(Tr,Object.assign({ref:o,chartType:"sankey"},K.length>0&&{nodes:K},null!=s&&{edges:X},{size:[W,R],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:se,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:v,nodeAlign:m,nodePaddingRatio:b,nodeWidth:x,nodeStyle:ne,edgeStyle:ie,colorBy:g,colorScheme:te,edgeColorBy:p,edgeOpacity:w,edgeSort:S,nodeLabel:ae,showLabels:B,enableHover:$,tooltipContent:!1===A?()=>null:Hr(A)||void 0,customHoverBehavior:E||L||M?le:void 0,customClickBehavior:L||M?ce:void 0},I&&"none"!==I&&{legendHoverBehavior:Q.onLegendHover,legendClickBehavior:Q.onLegendClick,legendHighlightedCategory:Q.highlightedCategory,legendIsolatedCategories:Q.isolatedCategories},{className:c,title:z,description:H,summary:F,accessibleTable:Y},null!=r.animate&&{animate:r.animate},j))})});In.displayName="SankeyDiagram";const On=t.forwardRef(function(r,n){const o=t.useRef(null);Wr(n,{variant:"network",frameRef:o,overrides:{getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}});const i=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",padAngle:v=.01,groupWidth:m=20,sortGroups:b,nodeLabel:x,edgeOpacity:k=.5,tooltip:w,frameProps:S={},onObservation:A,onClick:j,chartId:L,selection:M,linkedHover:D,loading:C,emptyContent:E,legendInteraction:_,stroke:P,strokeWidth:I,opacity:O}=r,{width:N,height:T,enableHover:W,showLabels:R=!0,title:$,description:B,summary:z,accessibleTable:H}=i,F=t.useMemo(()=>kr(s),[s]),Y=t.useMemo(()=>kr(a),[a]),X=Sn(C,N,T),G=X?null:wn(void 0===s?void 0:F,N,T,E),q=t.useMemo(()=>En(Y,F,u,d),[Y,F,u,d]),V=cn(q,g,y),K=t.useMemo(()=>{if(!g)return[];const e=new Set;for(const t of q){const r="function"==typeof g?g(t):t[g];null!=r&&e.add(r+"")}return Array.from(e)},[q,g]),Z=hn(_,g,K),U=sn(),Q=t.useMemo(()=>new Map,[]),J=t.useMemo(()=>{if(Array.isArray(y))return y;if(U&&U.length>0)return U;const e=Fe[y];return Array.isArray(e)?e:Ye},[y,U]),ee=q.length>0,te=t.useMemo(()=>{if(ee)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(g)o.fill=Ve(e.data||e,g,V);else{const i=Array.isArray(y)?y:Fe[y]||Ye,a=Array.isArray(i)?i:Ye,s=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[s%a.length]}return o}},[ee,g,V,y]),re=t.useMemo(()=>te?pn(te,{stroke:P,strokeWidth:I,opacity:O}):void 0,[te,P,I,O]),ne=t.useMemo(()=>{if(ee)return Pn({edgeColorBy:p,colorBy:g,colorScale:V,nodeStyleFn:re||(e=>({fill:ln(0,U,y)})),edgeOpacity:k,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:k}})},[ee,p,g,V,re,k,U,y,Q]),oe=t.useMemo(()=>ne?pn(ne,{stroke:P,strokeWidth:I,opacity:O}):void 0,[ne,P,I,O]),ie=t.useMemo(()=>{if(!R)return;const e=x||f;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[R,x,f]),ae=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof l?{top:l,bottom:l,left:l,right:l}:l),{customHoverBehavior:se,customClickBehavior:le}=un({selection:M,linkedHover:D,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:A,onClick:j,chartType:"ChordDiagram",chartId:L}),ce=Mn({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return ce?e.jsx(vn,{componentName:"ChordDiagram",message:ce,width:N,height:T}):X||G||e.jsx(bn,{componentName:"ChordDiagram",width:N,height:T,children:e.jsx(Tr,Object.assign({ref:o,chartType:"chord"},q.length>0&&{nodes:q},null!=s&&{edges:F},{size:[N,T],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:ae,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:v,groupWidth:m,sortGroups:b,nodeStyle:re,edgeStyle:oe,colorBy:g,colorScheme:J,edgeColorBy:p,edgeOpacity:k,nodeLabel:ie,showLabels:R,enableHover:W,tooltipContent:!1===w?()=>null:Hr(w)||void 0,customHoverBehavior:D||A||j?se:void 0,customClickBehavior:A||j?le:void 0},_&&"none"!==_&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories},{className:c,title:$,description:B,summary:z,accessibleTable:H},null!=r.animate&&{animate:r.animate},S))})});function Nn(r){const n=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{data:o,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="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:j,legendInteraction:L,stroke:M,strokeWidth:D,opacity:C}=r,{width:E,height:_,enableHover:P,showLabels:I=!0,title:O,description:N,summary:T,accessibleTable:W}=n,R=Sn(j,E,_),$=t.useMemo(()=>Cn(null!=o?o:null,c),[o,c]),B=cn($,g?void 0:h,f),z=t.useMemo(()=>{if(!h||g)return[];const e=new Set;for(const t of $){const r="function"==typeof h?h(t):t[h];null!=r&&e.add(r+"")}return Array.from(e)},[$,h,g]),H=hn(L,g?void 0:h,z),F=sn(),Y=t.useMemo(()=>new Map,[]),X=t.useMemo(()=>{if(Array.isArray(f))return f;if(F&&F.length>0)return F;const e=Fe[f];return Array.isArray(e)?e:Ye},[f,F]),G=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Ge[(e.depth||0)%Ge.length]:h?Ve(e.data||e,h,B):ln(0,F,f),t},[h,g,B,F,f,Y]),q=t.useMemo(()=>pn(G,{stroke:M,strokeWidth:D,opacity:C}),[G,M,D,C]),V=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),K=t.useMemo(()=>pn(V,{stroke:M,strokeWidth:D,opacity:C}),[V,M,D,C]),Z=t.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return _n(u)},[s,u]),U=Object.assign(Object.assign({},n.marginDefaults),"number"==typeof i?{top:i,bottom:i,left:i,right:i}:i),{customHoverBehavior:Q,customClickBehavior:J}=un({selection:S,linkedHover:A,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w}),ee=Ln({componentName:"TreeDiagram",data:o});return ee?e.jsx(vn,{componentName:"TreeDiagram",message:ee,width:E,height:_}):R||e.jsx(bn,{componentName:"TreeDiagram",width:E,height:_,children:e.jsx(Tr,Object.assign({chartType:s},null!=o&&{data:o},{size:[E,_],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:U,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:Z,treeOrientation:l,edgeType:y,nodeStyle:q,edgeStyle:K,colorBy:h,colorScheme:X,colorByDepth:g,nodeSize:v,nodeLabel:I?p||d:void 0,showLabels:I,enableHover:P,tooltipContent:!1===m?()=>null:Hr(m)||void 0,customHoverBehavior:A||x||k?Q:void 0,customClickBehavior:x||k?J:void 0},L&&"none"!==L&&{legendHoverBehavior:H.onLegendHover,legendClickBehavior:H.onLegendClick,legendHighlightedCategory:H.highlightedCategory,legendIsolatedCategories:H.isolatedCategories},{className:a,title:O,description:N,summary:T,accessibleTable:W},null!=r.animate&&{animate:r.animate},b))})}function Tn(r){const n=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary,linkedHover:r.linkedHover},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:f="leaf",nodeLabel:g,padding:y=4,paddingTop:p,tooltip:v,frameProps:m={},selection:b,linkedHover:x,onObservation:k,onClick:w,chartId:S,loading:A,legendInteraction:j,stroke:L,strokeWidth:M,opacity:D}=r,{width:C,height:E,enableHover:_,showLabels:P=!0,title:I,description:O,summary:N,accessibleTable:T}=n,W=Sn(A,C,E),{activeSelectionHook:R,customHoverBehavior:$,customClickBehavior:B}=un({selection:b,linkedHover:x,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:k,onClick:w,chartType:"Treemap",chartId:S}),z=function(e){const r=Lt(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,n;if(void 0!==e||void 0!==r)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(n=null==e?void 0:e.unselectedOpacity)&&void 0!==n?n:r})},[e,r])}(b),H=t.useCallback(e=>{if(!e)return $(null);const t=e.data||e;$({data:(null==t?void 0:t.data)||t})},[$]),F=t.useMemo(()=>Cn(null!=o?o:null,s),[o,s]),Y=cn(F,h?void 0:u,d),X=t.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of F){const r="function"==typeof u?u(t):t[u];null!=r&&e.add(r+"")}return Array.from(e)},[F,u,h]),G=hn(j,h?void 0:u,X),q=sn(),V=t.useMemo(()=>new Map,[]),K=t.useMemo(()=>{if(Array.isArray(d))return d;if(q&&q.length>0)return q;const e=Fe[d];return Array.isArray(e)?e:Ye},[d,q]),Z=t.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?Ge[(e.depth||0)%Ge.length]:u?Ve(e.data||e,u,Y):ln(0,q,d),t},[u,h,Y,q,d,V]),U=t.useMemo(()=>pn(Z,{stroke:L,strokeWidth:M,opacity:D}),[Z,L,M,D]),Q=t.useMemo(()=>R?e=>{var t;const r=Object.assign({},U(e));if(R.isActive)if(R.predicate(e.data||e))(null==z?void 0:z.selectedStyle)&&Object.assign(r,z.selectedStyle);else{const e=null!==(t=null==z?void 0:z.unselectedOpacity)&&void 0!==t?t:.5;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==z?void 0:z.unselectedStyle)&&Object.assign(r,z.unselectedStyle)}return r}:U,[U,R,z]),J=t.useMemo(()=>_n(l),[l]),ee=void 0!==p?p:!P||"parent"!==f&&"all"!==f?void 0:18,te=Object.assign(Object.assign({},n.marginDefaults),"number"==typeof i?{top:i,bottom:i,left:i,right:i}:i),re=Ln({componentName:"Treemap",data:o});return re?e.jsx(vn,{componentName:"Treemap",message:re,width:C,height:E}):W||e.jsx(bn,{componentName:"Treemap",width:C,height:E,children:e.jsx(Tr,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[C,E],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:te,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:J,padding:y,paddingTop:ee,nodeStyle:Q,colorBy:u,colorScheme:K,colorByDepth:h,nodeLabel:P?g||c:void 0,showLabels:P,labelMode:f,enableHover:_,tooltipContent:!1===v?()=>null:Hr(v)||void 0},(x||k||w)&&{customHoverBehavior:H},(k||w)&&{customClickBehavior:B},j&&"none"!==j&&{legendHoverBehavior:G.onLegendHover,legendClickBehavior:G.onLegendClick,legendHighlightedCategory:G.highlightedCategory,legendIsolatedCategories:G.isolatedCategories},{className:a,title:I,description:O,summary:N,accessibleTable:T},null!=r.animate&&{animate:r.animate},m))})}function Wn(r){const n=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,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,legendInteraction:A,stroke:j,strokeWidth:L,opacity:M}=r,{width:D,height:C,enableHover:E,showLabels:_=!0,title:P,description:I,summary:O,accessibleTable:N}=n,T=Sn(S,D,C),W=t.useMemo(()=>Cn(null!=o?o:null,s),[o,s]),R=cn(W,h?void 0:u,d),$=t.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of W){const r="function"==typeof u?u(t):t[u];null!=r&&e.add(r+"")}return Array.from(e)},[W,u,h]),B=hn(A,h?void 0:u,$),z=sn(),H=t.useMemo(()=>new Map,[]),F=t.useMemo(()=>{if(Array.isArray(d))return d;if(z&&z.length>0)return z;const e=Fe[d];return Array.isArray(e)?e:Ye},[d,z]),Y=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?Ge[(e.depth||0)%Ge.length]:u?Ve(e.data||e,u,R):ln(0,z,d),t},[u,h,R,g,z,d,H]),X=t.useMemo(()=>pn(Y,{stroke:j,strokeWidth:L,opacity:M}),[Y,j,L,M]),G=t.useMemo(()=>_n(l),[l]),q=Object.assign(Object.assign({},n.marginDefaults),"number"==typeof i?{top:i,bottom:i,left:i,right:i}:i),{customHoverBehavior:V,customClickBehavior:K}=un({selection:k,linkedHover:w,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:m,onClick:b,chartType:"CirclePack",chartId:x}),Z=Ln({componentName:"CirclePack",data:o});return Z?e.jsx(vn,{componentName:"CirclePack",message:Z,width:D,height:C}):T||e.jsx(bn,{componentName:"CirclePack",width:D,height:C,children:e.jsx(Tr,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[D,C],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:q,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:G,padding:y,nodeStyle:X,colorBy:u,colorScheme:F,colorByDepth:h,nodeLabel:_?f||c:void 0,showLabels:_,enableHover:E,tooltipContent:!1===p?()=>null:Hr(p)||void 0,customHoverBehavior:w||m||b?V:void 0,customClickBehavior:m||b?K:void 0},A&&"none"!==A&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:P,description:I,summary:O,accessibleTable:N},null!=r.animate&&{animate:r.animate},v))})}On.displayName="ChordDiagram",Nn.displayName="TreeDiagram",Tn.displayName="Treemap",Wn.displayName="CirclePack";const Rn=Ge;function $n(r){const n=gn(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:f=2.95,speed:g=.25,revolution:y,revolutionStyle:p,eccentricity:v=1,showRings:m=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:S,annotations:A,frameProps:j={},onObservation:L,onClick:M,chartId:D,selection:C,linkedHover:E,loading:_,stroke:P,strokeWidth:I,opacity:O}=r,{width:N,height:T,enableHover:W,title:R,description:$,summary:B,accessibleTable:z}=n,H=Sn(_,N,T),F=cn(t.useMemo(()=>Cn(o,s),[o,s]),d?void 0:c,u),Y=sn(),X=t.useMemo(()=>new Map,[]),G=t.useMemo(()=>{if(Array.isArray(u))return u;if(Y&&Y.length>0)return Y;const e=Fe[u];return Array.isArray(e)?e:Ye},[u,Y]),q=t.useMemo(()=>{if(Array.isArray(u))return u;const e=Fe[u];return Array.isArray(e)?e:Ye},[u]),V=t.useMemo(()=>e=>{var t;const r={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return r.fill=d?n?q[0]:Rn[(e.depth||0)%Rn.length]:c?Ve(e.data||e,c,F):ln(0,Y,u),r.opacity=n?1:.85,r},[c,d,F,q,Y,u,X]),K=t.useMemo(()=>pn(V,{stroke:P,strokeWidth:I,opacity:O}),[V,P,I,O]),Z=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),U=Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof i?{top:i,bottom:i,left:i,right:i}:i),{customHoverBehavior:Q,customClickBehavior:J}=un({selection:C,linkedHover:E,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:L,onClick:M,chartType:"OrbitDiagram",chartId:D}),ee=t.useMemo(()=>{if(Q)return e=>{Q(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Q]),te=t.useMemo(()=>{if(J)return e=>{J(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[J]),re=Ln({componentName:"OrbitDiagram",data:o});return re?e.jsx(vn,{componentName:"OrbitDiagram",message:re,width:N,height:T}):H||e.jsx(bn,{componentName:"OrbitDiagram",width:N,height:T,children:e.jsx(Tr,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[N,T],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:U,nodeIDAccessor:l,childrenAccessor:s,nodeStyle:K,edgeStyle:Z,colorBy:c,colorScheme:G,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&W,tooltipContent:k?void 0:!1===w?()=>null:Hr(w)||void 0,customHoverBehavior:E||L||M?ee:void 0,customClickBehavior:L||M?te:void 0,foregroundGraphics:S,annotations:A,className:a,title:R,description:$,summary:B,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k,accessibleTable:z},null!=r.animate&&{animate:r.animate},j))})}$n.displayName="OrbitDiagram";const Bn=t.forwardRef(function(r,n){const{nodes:o,edges:i,layout:a,layoutConfig:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",margin:d,className:h,colorScheme:f,frameProps:g={}}=r,{frameRef:y,resolved:p,normalizedMargin:v}=function(e){const r=t.useRef(null);return Wr(e.imperativeRef,{variant:e.imperativeVariant,frameRef:r}),{frameRef:r,resolved:gn(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:t.useMemo(()=>function(e){if(null!=e)return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:e}(e.margin),[e.margin])}}({imperativeRef:n,imperativeVariant:"network",margin:d,width:r.width,height:r.height,enableHover:r.enableHover,title:r.title,mode:r.mode}),m=t.useMemo(()=>kr(null!=o?o:[]),[o]),b=t.useMemo(()=>kr(null!=i?i:[]),[i]),{width:x,height:k,enableHover:w,title:S,description:A,summary:j,accessibleTable:L}=p,M=Object.assign(Object.assign(Object.assign(Object.assign({chartType:"force"},null!=o&&{nodes:m}),null!=i&&{edges:b}),{customNetworkLayout:a,layoutConfig:s,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,colorScheme:f,size:[x,k],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:v,className:h,title:S,description:A,summary:j,accessibleTable:L,enableHover:w}),g);return e.jsx(bn,{componentName:"NetworkCustomChart",width:x,height:k,children:e.jsx(Tr,Object.assign({ref:y},M))})});Bn.displayName="NetworkCustomChart",exports.ChordDiagram=On,exports.CirclePack=Wn,exports.ForceDirectedGraph=Dn,exports.NetworkCustomChart=Bn,exports.OrbitDiagram=$n,exports.SankeyDiagram=In,exports.StreamNetworkFrame=Tr,exports.TreeDiagram=Nn,exports.Treemap=Tn;
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react"),n=require("d3-interpolate"),r=require("d3-array"),o=require("d3-force"),i=require("d3-scale"),a=require("d3-chord"),s=require("d3-shape"),l=require("d3-hierarchy");function c(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const u=c(t);function d(e,t,n,r){return Object.assign({data:e,x:t,y:n,__semioticHoverData:!0},r)}const h={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},f={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function g(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function y(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function p(e){const t=e.map(g),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return y(e,n,r)}if(e>=1){const[e,r,o]=t[n];return y(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return y(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}const v=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=p(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),b=p(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),x=p(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),k=p(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=p(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]);p(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]);const S=p(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=p(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]);p(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),p(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),p(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),p(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),p(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),p(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),p(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),p(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),p(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),p(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),p(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);class M{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 s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1,this._freeIndices.push(i);continue}const l=r&&null!==(o=r[a.edgeIndex])&&void 0!==o?o:1;a.t+=e*t*l*(s.bezier.circular?.3:1),1>a.t?j(s.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 j(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];L(c,u,d,h,l,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,s]=e.points;L(o,i,a,s,t,r);const l=s.x-o.x,c=s.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function L(e,t,n,r,o,i){const a=1-o,s=a*a,l=s*a,c=o*o,u=c*o;i.x=l*e.x+3*s*o*t.x+3*a*c*n.x+u*r.x,i.y=l*e.y+3*s*o*t.y+3*a*c*n.y+u*r.y}function E(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function D(e,t){var n,r=[],o=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(r=s[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[r=s[e][t]];h||(a[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,t){var n=[].concat(t).concat(e);r.push(n)}function d(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),s=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=r[y]=u,o[y]=!0,u+=1,l.push(y),c.push(y);break}o[y]&&(r[t]=0|Math.min(r[t],r[y])),0>a[y]||s[t].push(a[y])}i[t]=g}else{if(r[t]===n[t]){var p=[],v=[],m=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(o[b]=!1,p.push(b),v.push(s[b]),m+=s[b].length,a[b]=d.length,b===t){l.length=g;break}}d.push(p);var x=Array(m);for(g=0;v.length>g;g++)for(var k=0;v[g].length>k;k++)x[--m]=v[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];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[l]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],n=a);var l=o[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return r}function C(e){return e.y0-e.y1>0?"up":"down"}function P(e,t){return t(e.source)==t(e.target)}function O(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 _(e){return e.target.x0-e.source.x1}function N(e,t){var n=T(e),r=_(t)/Math.tan(n);return"up"==C(e)?e.y1-r:e.y1+r}function I(e,t){var n=T(e),r=_(t)/Math.tan(n);return"up"==C(e)?e.y1+r:e.y1-r}function T(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function W(e,t){return t(e)}function B(e){return $(e.source)}function R(e){return $(e.target)}function $(e){return(e.y0+e.y1)/2}function z(e){return e.virtual?0:e.value}function H(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!P(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!P(e,t)?r+1:r}),n+r}function F(e){return e.target.depth}function Y(e,t){return e.sourceLinks.length?e.depth:t-1}function X(e,t){return e.y0-t.y0}function G(e,t){return t.y0-e.y0}function q(e,t){return e.y1-t.y1}function V(e,t){return t.y1-e.y1}function K(e,t){return U(e.source,t.source)||e.index-t.index}function Z(e,t){return U(e.target,t.target)||e.index-t.index}function U(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Q(e,t){return J(e)==J(t)?"bottom"==e.circularLinkType?G(e,t):X(e,t):J(t)-J(e)}function J(e){return e.target.column-e.source.column}function ee(e,t){return te(e)==te(t)}function te(e){return e.y0-e.y1>0?"up":"down"}function ne(e,t,n,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=a.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),re(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),re(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,P(e,t)&&O(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?G:X);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(c=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?V:q),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,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)}),a}function re(e,t,n){e.sort(Q);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(P(e,t)&&O(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&oe(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function oe(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function ie(e){return function(){return e}}function ae(e){return e.index}function se(e){return e.nodes}function le(e){return e.links}function ce(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=$(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=$(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=s.get(e),r=s.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 r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?H(t,n)-H(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==H(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 ue(e,t,n,o,i,a){var s=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=a;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&H(i,n)>0){var c=r.mean(i.sourceLinks,R),u=r.mean(i.targetLinks,B),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-$(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var f=r.mean(i.sourceLinks,R),g=r.mean(i.targetLinks,B),y=((f&&g?(f+g)/2:f||g)-$(i))*t;i.y0+=y,i.y1+=y}})})}function d(){s.forEach(function(n){var r,a,s,l=e.y0,c=n.length;for(n.sort(t||U),s=0;c>s;++s)(a=l-(r=n[s]).y0)>0&&(r.y0+=a,r.y1+=a),l=r.y1+o;if((a=l-o-e.y1)>0)for(l=r.y0-=a,r.y1-=a,s=c-2;s>=0;--s)(a=(r=n[s]).y1+i-l)>0&&(r.y0-=a,r.y1-=a),l=r.y0})}}function de(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Z),e.targetLinks.sort(K)}),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 he(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,l=ae,c=Y,u=void 0,d=32,h=2,f=se,g=le;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=E(n,r)),"object"!=typeof o&&(o=e.target=E(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(f,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,s=i.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=D(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,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++)})}(f,u),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){W(e,t)!=W(o.source,t)&&W(e,t)!=W(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),P(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,z),r.sum(e.targetLinks,z)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(f),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(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})}(f,u,c);var g=a;if(null!==s){var y=r.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=r.max(y,function(e){return e.length});p>1&&(g=Math.max(1,(o-t)*s/(p-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,g,i),ce(f,u,l),ue(f,u,l,g,g,d),de(f),ne(f,l,h,10,8),ce(f,u,l),ue(f,u,l,g,g,d),de(f),ne(f,l,h,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 W(n.source,t)==W(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(!ee(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=N(t,e);return e.y1-n}if(t.target.column>e.target.column)return N(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}})})}(f,l),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return W(n.target,t)==W(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(!ee(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=I(t,e);return e.y0-n}if(t.source.column>e.source.column)return I(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}})})}(f,l),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),s=r.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-a);function c(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(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})})}}(f),ne(f,l,h,10,8)}(y),y}return y.update=function(e){return de(e),ne(e,l,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(a=+e,y):a},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(f="function"==typeof e?e:ie(e),y):f},y.links=function(e){return arguments.length?(g="function"==typeof e?e:ie(e),y):g},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:ie(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:ie(e),y):c},y.nodeSort=function(e){return arguments.length?(u=e,y):u},y.iterations=function(e){return arguments.length?(d=+e,y):d},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],y):[[e,t],[n,o]]},y.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],y):[n-e,o-t]},y}function fe(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(n+r)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${l},${i} ${o},${i}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}const ge=e=>{let t,r,o,i,a,s,l,c,u;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.x1,s=e.target.x0,l=n.interpolateNumber(a,s),c=l(.5),u=l(.5),`M${t},${a}C${t},${c} ${r},${u} ${r},${s}L${o},${s}C${o},${u} ${i},${c} ${i},${a}Z`;const d=e.sankeyWidth/2,h=n.interpolateNumber(e.source.x1,e.target.x0),{pathD:f}=fe({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:h(.5),cp2X:h(.5)});return f};function ye(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 s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${r-n}L${t+s},${r-n}L${t+s},${r+n}L${t},${r+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=o.sourceX,a=o.sourceY,s=o.targetX,l=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=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},${d+h*r-h*f}L${c+r-f},${d+h*r}L${u-r+f},${d+h*r}L${u-r},${d+h*r-h*f}L${u-r},${l-h*n+h*f}L${u-r+f},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+r},${l+h*n}L${u+r},${d-h*r}L${c-r},${d-h*r}L${c-r},${a+h*n}L${i},${a+h*n}Z`}const pe=new Set,ve=new WeakMap;function me(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=ve.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,ve.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}`;pe.has(e)||(pe.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 be={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(F))-1:0},justify:Y};function xe(e){return"string"==typeof e?e:e.id}const ke={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var o,i,a,s,l,c,u;if(0===e.length)return;const d="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"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const b=he().extent(m).links(v).nodes(p).nodeAlign(be[h]||Y).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!==(l=null!==(s=r._circularWidth)&&void 0!==s?s:r.width)&&void 0!==l?l: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,u=r[0],d=r[1];if(i>0&&a>0&&(0>e||0>n||t>u||o>d)){const t=Math.min(u/i,d/a),r=-e*t+(u-i*t)/2,o=-n*t+(d-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=xe(e.source),n=xe(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!==(u=e.width)&&void 0!==u?u: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=d;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,s,l,c;const u="vertical"===n.orientation?"down":"right",d=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:v,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const m=[],b=[],x=[],k=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=d?d(me(t,"nodeStyle")):{},o={fill:r.fill||p.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};k.set(t.id,("string"==typeof o.fill?o.fill:null)||p.get(t.id)||"#4d430c"),m.push("down"===u?{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 w=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of w){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?k.get(r.id)||p.get(r.id)||o:k.get(t.id)||p.get(t.id)||o;const u=h?h(me(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=u.fill||o;b.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!==(s=u.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),b.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!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-i,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?ye(e):ge(e),!d)continue;const y={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};b.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:y,datum:e})}if(!1!==n.showLabels){const t=(S=n.nodeLabel)?"function"==typeof S?S:e=>e[S]||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,s,l;"down"===u?(a=n.y0+(n.y1-n.y0)/2,s=n.x1+14,l="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),s=n.y0+o/2),x.push({x:a,y:s,text:i+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var S;return{sceneNodes:m,sceneEdges:b,labels:x}}},we={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){var i,a;if(0===e.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,l=r[0]/2,c=r[1]/2,u=n.__previousPositions;let d=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==u?void 0:u.get(t.id);e?d++:n?(t.x=n.x,t.y=n.y,d++):h.push(t)}const f=d>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const r=Se(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=Ae(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=Ae(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=l+r*Math.cos(n),e.y=c+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=c+e*Math.sin(o)}}}const g=null!==(a=n.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),y=0===n.iterations?0:f?40:g,p=Me(n.nodeSize,n.nodeSizeRange,e),v=e=>p(e);if(y>0){const n=o.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),r=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*v(e))).force("center",o.forceCenter(l,c).strength(.8)).force("x",o.forceX(l).strength(.15)).force("y",o.forceY(c).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}));r.force("link",n),r.force("link").links(e)}f?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let e=0;y>e;++e)r.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=v(t);t.x=Math.max(e,Math.min(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 m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){var o,i,a,s,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Me(n.nodeSize,n.nodeSizeRange,e),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:v,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],m=[],b=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(me(t,"nodeSize")),r=d?d(me(t,"nodeStyle")):{},s={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:s,datum:t,id:t.id,label:t.id})}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:x.get(e.source),r="object"==typeof e.target?e.target:x.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(me(e,"edgeStyle")):{},i={stroke:o.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};m.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=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||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(me(n,"nodeSize"));b.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:b}}};function Se(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 Ae(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 Me(e,t,n){var o,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=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===l.length)return()=>s[0];const c=null!==(o=r.min(l))&&void 0!==o?o:0,u=null!==(a=r.max(l))&&void 0!==a?a:1;if(c===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([c,u]).range(s).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?s[0]:d(r)}}const je=v,Le={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=n,c=Math.min(r[0],r[1])/2,u=c-i,d=r[0]/2,h=r[1]/2,f=(g=n.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const p=e.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=y.get("string"==typeof e.source?e.source:e.source.id),r=y.get(t);if(void 0===n||void 0===r)continue;const o=f(e);v[n][r]=o}const m=a.chord().padAngle(o);l&&m.sortGroups(l);const b=m(v),x=b.groups,k=s.arc().innerRadius(u).outerRadius(c);for(const t of x){const n=e[t.index],r=k.centroid({innerRadius:u,outerRadius:c,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+d,n.y=r[1]+h,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),r=w.get(t);n&&(e.source=n),r&&(e.target=r)}const S=new Map;for(const e of t)S.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const n=e[t.source.index].id,r=e[t.target.index].id,o=S.get(`${n}\0${r}`)||S.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){var o,i,s,l;const{groupWidth:c=20,edgeOpacity:u=.5}=n,d=Math.min(r[0],r[1])/2,h=d-c,f=r[0]/2,g=r[1]/2,y=n.nodeStyle,p=n.edgeStyle,v=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:je,b=new Map;e.forEach((e,t)=>{b.set(e.id,m[t%m.length])});const x=a.ribbon().radius(h),k=[],w=[],S=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let i;i=y?y(me(n,"nodeStyle")).fill||b.get(n.id)||m[t%m.length]:b.get(n.id)||m[t%m.length];const a=y?y(me(n,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:d,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=x(t);if(!r)continue;const o=Ee(r,f,g);let a=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)a=p(me(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===v&&n?a=b.get(n.id)||a:t&&(a=b.get(t.id)||a)}const c=p?p(me(e,"edgeStyle")):{},d={fill:a,fillOpacity:null!==(l=c.fillOpacity)&&void 0!==l?l:u,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity};w.push({type:"ribbon",pathD:o,style:d,datum:e})}if(!1!==n.showLabels){const t=(A=n.nodeLabel)?"function"==typeof A?A:e=>e[A]||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;S.push({x:f+Math.cos(a)*r,y:g+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:k,sceneEdges:w,labels:S}}};function Ee(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 De=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ce(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 Pe(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 Oe(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 _e(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:De}function Ne(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 Ie(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 Te={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>Number(e[c])||0:e=>Number(e.value)||0,d=l.hierarchy(i,s);d.sum(u),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[h,f]=r;switch(a){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=l.tree();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(d,n,h,f);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=l.cluster();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(d,n,h,f);break;case"treemap":!function(e,t,n,r){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=l.treemap().size([n,r]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(e)}(d,n,h,f);break;case"circlepack":!function(e,t,n,r){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;l.pack().size([n,r]).padding(i)(e)}(d,n,h,f);break;case"partition":!function(e,t,n,r){var o;l.partition().size([n,r]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,n,h,f)}const g=d.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;g.length>t;t++){const r=g[t],i={id:Pe(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?We(i,r,n):"treemap"===a||"partition"===a?Be(i,r):"circlepack"===a&&Re(i,r),i.__hierarchyNode=r,e.push(i),y.set(r,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const n=y.get(e.parent),r=y.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,s,l,c,u,d,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(me(t,"nodeStyle"));let l=i.fill||Ne(n);if(n.colorByDepth&&void 0!==t.depth){const e=_e(n);l=e[t.depth%e.length]}const c={fill:l,stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s: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!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,s=r.x,l=r.y;m&&(o+=b,a+=x,s+=b,l+=x);const f=Ie(o,a,s,l,v),g=i(me(e,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d: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=Oe(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,a=n.x,s=n.y;if(m&&(a+=b,s+=x),m){const e=a-b,t=s-x,n=Math.sqrt(e*e+t*t);n>0?(r=a+e/n*10,o=s+t/n*10,i=0>e?"end":"start"):(r=a,o=s-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=s):(r=a,o=s+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,s,l;const c=[],u=[];for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;const s=r(me(n,"nodeStyle"));let l=s.fill||Ne(t);if(t.colorByDepth&&void 0!==n.depth){const e=_e(t);l=e[n.depth%e.length]}const u={fill:l,stroke:s.stroke||(null===(o=t.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:e,h:a,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Oe(t.nodeLabel),o=t.labelMode||"leaf",i="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,d=c.y1-c.y0;if(0>=e||0>=d)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)>d)continue;let g=r(me(c,"nodeStyle")).fill||Ne(t);if(t.colorByDepth&&void 0!==c.depth){const e=_e(t);g=e[c.depth%e.length]}const y="string"==typeof g?Ce(g):null!==(l=null===(s=t.themeSemantic)||void 0===s?void 0:s.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+e/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/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:u}}(e,n,0,o);case"circlepack":return function(e,t,n,r){var o,i,a,s,l,c,u,d,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 l=r(me(n,"nodeStyle"));let c=l.fill||Ne(t);if(t.colorByDepth&&void 0!==n.depth){const e=_e(t);c=e[n.depth%e.length]}const u={fill:c,stroke:l.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=l.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=l.opacity)&&void 0!==s?s:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Oe(t.nodeLabel);for(const o of e){const e=null!==(l=o.__radius)&&void 0!==l?l: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 s=r(me(o,"nodeStyle")).fill||Ne(t);if(t.colorByDepth&&void 0!==o.depth){const e=_e(t);s=e[o.depth%e.length]}if(a){const n="string"==typeof s?Ce(s):null!==(d=null===(u=t.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#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 We(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 Be(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 Re(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 $e(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const ze={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),c=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),u=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,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=$e(n);y.metaMap.clear(),r.length=0,o.length=0;const p=new Map;function v(e){var t;const n=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,n+1),0===n?e:`${e}__${n}`}const m=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=v(c(e));r.push({id:k,x:m,y:b,x0:m,x1:m,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),y.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,a,d,h,p){const m=l(t);if(!(null==m?void 0:m.length))return;const b=m.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let S=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=m.slice(S,S+k);if(!w.length)break;const A=(b+1)/x,M={id:n,depth:h,data:t,parentId:n},j=p?d/f(M)*A:d*A,L=s.pie().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),E=L(w),D=g(M);for(let t=0;w.length>t;t++){const s=(E[t].startAngle+E[t].endAngle)/2,l=w[t],u=v(c(l)),d=i+j*Math.sin(s),f=a+j*Math.cos(s)*D;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:l}),y.metaMap.set(u,{ring:j,angle:s,depth:h,parentId:n,eccentricity:D}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(l,u,d,f,j,h+1,!0)}S+=k}}(e,k,m,b,x,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){var o,i,a,s,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const t=$e(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 s=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;y.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*r,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(me(t,"nodeSize")),r=d?d(me(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!==(s=r.opacity)&&void 0!==s?s:0===(null!==(l=t.depth)&&void 0!==l?l: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(me(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[t])&&void 0!==u?u: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=$e(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),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,l=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+s*l*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)},He={sankey:ke,force:we,chord:Le,tree:Te,cluster:Te,treemap:Te,circlepack:Te,partition:Te,orbit:ze};function Fe(e){return He[e]}const Ye={category10:v,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:m,reds:b,greens:x,oranges:k,purples:w,viridis:S,plasma:A},Xe=v,Ge=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],qe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Ve=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 Ke(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")||Ve.has(t)}(r)?n(r):r}const r=(null==e?void 0:e[t])+"";return n?n(r):Xe[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))%Xe.length]}function Ze(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 i.scaleOrdinal().domain(r).range(n).unknown("#999");const a=Ye[n]||Ye.category10;if(o&&"function"==typeof a){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:Xe;return i.scaleOrdinal().domain(r).range(e).unknown("#999")}}function Ue(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 Qe(e,t,n){return e+(t-e)*n}function Je(e,t,n){var r,o,i;if(1>=n)return 1;const a=null!==(r=e.minOpacity)&&void 0!==r?r:.1,s=n-1-t;switch(e.type){case"linear":return a+(1-s/(n-1))*(1-a);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:n/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>s?1:a;default:return 1}}class et{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({},h),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new M(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({},h),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new M(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,s="function"==typeof r?r:e=>e[r],l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this._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=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},tt(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],r=l(n)+"",o=c(n)+"",i=u(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},tt(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},tt(o)),{data:n}));const d=`${r}\0${o}\0${e}`,h={source:r,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:d};n&&"object"==typeof n&&nt(n.bezier)&&(h.bezier=n.bezier),this.edges.set(d,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,tt(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,tt(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;return l?(l.value+=r,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,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,s,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=Fe(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const s of u)if(void 0!==s._prevX0){const l=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(r=s._prevY1)&&void 0!==r?r:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+l/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+c/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.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(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[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,u=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=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=null!==(l=null===(s=this.config.transition)||void 0===s?void 0:s.duration)&&void 0!==l?l:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.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 s=Array.from(this.nodes.values()),l=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=Ye[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,v),u={nodes:s,edges:l,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:Ue(c),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{}};let d;try{d=this.config.customNetworkLayout(u)}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=d.sceneNodes)&&void 0!==r?r:[],this.sceneEdges=null!==(o=d.sceneEdges)&&void 0!==o?o:[],this.labels=null!==(i=d.labels)&&void 0!==i?i:[],void(this.customLayoutOverlays=null!==(a=d.overlays)&&void 0!==a?a:null)}this.customLayoutOverlays=null;const c=Fe(this.config.chartType);if(!c)return;const{sceneNodes:u,sceneEdges:d,labels:h}=c.buildScene(s,l,this.config,e);this.sceneNodes=u,this.sceneEdges=d,this.labels=h}get isAnimating(){const e=Fe(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Fe(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=Qe(e._prevX0,e._targetX0,n),e.x1=Qe(e._prevX1,e._targetX1,n),e.y0=Qe(e._prevY0,e._targetY0,n),e.y1=Qe(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=Qe(e._prevY0,e._targetY0,n),e.y1=Qe(e._prevY1,e._targetY1,n),e.sankeyWidth=Qe(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,r){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=r.x0,s=n.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=r.x0,s=n.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,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 s=null!==(t=a.duration)&&void 0!==t?t:500,l=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;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=l,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 u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}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 s=i.get(a);if(void 0===s)continue;const l=Je(n,s,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*l})}}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 s=this.nodes.get(n);if(!s)continue;const l=r.metric(s);let c=null;void 0===r.critical||r.critical>l?void 0===r.warning||r.warning>l||(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 tt(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function nt(e){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(!rt(e))return!1;return!0}return rt(t.points)}function rt(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 ot(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:u.createElement(u.Fragment,null,...t)}function it(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function at(e,t,n,r,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=st(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=ht(e,n,r);t&&a>t.distance&&(i=t,a=t.distance)}return i}function st(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),s=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,r);return a>s?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=it(Math.atan2(o,r)),s=it(e.startAngle),l=it(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=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 lt=null,ct=null;function ut(){return ct||(lt=document.createElement("canvas"),lt.width=1,lt.height=1,ct=lt.getContext("2d")),ct}function dt(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 ht(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var r,o;if(!e.pathD)return null;const i=dt(e),a=ut();if(!i||!a)return null;try{if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.source)?e.datum.source:null,a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}const s=a.lineWidth;a.lineWidth=10;const l=a.isPointInStroke(i,t,n);if(a.lineWidth=s,l)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 s=e.x1+a*r,l=e.y1+a*o,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=dt(e),o=ut();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 ft(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?gt(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?gt(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 gt(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 yt(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}const pt="var(--semiotic-focus, #005fcc)";function vt({active:t,hoverPoint:n,margin:r,size:o,shape:i="circle",width:a,height:s}){if(!t||!n)return null;const l=n.x+r.left,c=n.y+r.top;let u;if("rect"===i&&null!=a&&null!=s){const t=Math.max(a,4),n=Math.max(s,4);u=e.jsx("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:pt,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:pt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:pt,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}const mt={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 bt(e,t){return"function"==typeof t?t(e):e[t]}function xt(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 kt(t={}){const{fields:n,title:r,format:o,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(r){const e=bt(t,r);s=xt(e,o)}if(n&&n.length>0)n.forEach(e=>{let n,r,i;"string"==typeof e?(n=e,r=e,i=o):(n=e.label,r=e.accessor||e.key||"",i=e.format||o);const a=bt(t,r);l.push({label:n,value:xt(a,i)})});else if(!r){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=xt(t[n],o);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=xt(t[e[0]],o))}}const c=Object.assign(Object.assign({},mt),i);return e.jsxs("div",{className:("semiotic-tooltip "+a).trim(),style:c,children:[s&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:s}),l.map((t,n)=>e.jsxs("div",{style:{marginTop:0===n&&s?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},n))]})}}function wt(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var r;const o=!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.jsx("div",{className:"semiotic-tooltip",style:mt,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?kt(t):kt())}}function St({x:t,y:n,containerWidth:r,containerHeight:o,margin:i,children:a,className:s="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(t)&&Number.isFinite(n),d=u.useRef(null),[h,f]=u.useState(null);u.useLayoutEffect(()=>{const e=d.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})},[a,s,r,o]);let g;g=h?`translate(${h.width+12>r-t?"calc(-100% - 12px)":"12px"}, ${h.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`;const y=function(e){if(!u.isValidElement(e))return!1;const t=e.props;if("string"==typeof t.className&&t.className.trim().length>0)return!0;const n=t.style;if(n&&"object"==typeof n){if(null!=n.background&&""!==n.background)return!0;if(null!=n.backgroundColor&&""!==n.backgroundColor)return!0}return!1}(a),p=y?null:mt;return c?e.jsx("div",{ref:d,className:y?s:(s+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:i.left+t,top:i.top+n,transform:g,pointerEvents:"none",zIndex:l,width:"max-content"}),children:a}):null}function At(n){let r=null;const o=()=>(r||(r=t.createContext(null)),r),i=Mt(n);return[function({children:r,initialState:i}){const a=t.useRef(i),s=t.useMemo(()=>Mt(n,a.current),[]),l=o();return e.jsx(l.Provider,{value:s,children:r})},e=>{var n;const r=o(),a=null!==(n=t.useContext(r))&&void 0!==n?n:i,s=t.useRef(e);s.current=e;const l=t.useCallback(()=>s.current(a.getState()),[a]),c=t.useCallback(()=>s.current(a.getState()),[a]);return t.useSyncExternalStore(a.subscribe,l,c)}]}function Mt(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 jt(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 Lt(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:Et})})),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 Et=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Dt={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}},Ct={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}},Pt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Et,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 Ot(e,t){if("light"===t)return Dt;if("dark"===t)return Ct;if("high-contrast"===t)return Pt;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?Ct:Dt;return Lt(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 Lt(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[_t,Nt]=At(e=>({theme:Dt,setTheme(t){e(e=>({theme:Ot(e.theme,t)}))}}));const It=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Tt=new WeakMap;let Wt=0,Bt=!1,Rt=null,$t=null,zt=null;function Ht(e,t){var n,r;if(!t)return t;const o=It.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(Bt)return;if("undefined"==typeof window||"undefined"==typeof document)return;Bt=!0;const e=()=>{Wt++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Rt=new MutationObserver(e),Rt.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{$t=window.matchMedia("(prefers-color-scheme: dark)"),zt=e,"function"==typeof $t.addEventListener?$t.addEventListener("change",zt):"function"==typeof $t.addListener&&$t.addListener(zt)}catch(e){}}();let a=Tt.get(i);a&&a.version===Wt||(a={version:Wt,map:new Map},Tt.set(i,a));const s=a.map.get(t);if(void 0!==s)return s;const l=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(r=o[2])||void 0===r?void 0:r.trim())||t;return a.map.set(t,l),l}const Ft="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function Yt(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Xt(e){const n=function(){const[e,n]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),e}(),r=t.useRef(n);r.current=n;const[o,i]=function(e,n,r){const o=t.useRef(null),[i,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!r)return;const e=o.current;if(!e)return;const t=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 t.observe(e),()=>t.disconnect()},[n,r]),[o,[n&&i?i.w:e[0],r&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),a=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),s=i[0]-a.left-a.right,l=i[1]-a.top-a.bottom,c=Yt(e.foregroundGraphics,i,a),d=Yt(e.backgroundGraphics,i,a),h=Nt(e=>e.theme),{transition:f,introEnabled:g}=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),y="semiotic-table-"+u.useId(),p=t.useRef(0),v=t.useRef(()=>{}),m=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);t.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),k=t.useRef(null),w=t.useRef(0),S=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),A=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(S))},[S]),M=t.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),x.current()},[]);t.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const j=e.themeDirtyRef;return Ft(()=>{j&&(Wt++,j.current=!0,m())},[h,m,j]),{reducedMotion:n,reducedMotionRef:r,responsiveRef:o,size:i,margin:a,adjustedWidth:s,adjustedHeight:l,resolvedForeground:c,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:y,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:A,onPointerLeave:M}}const Gt={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function qt(e,t,n,r){let o;return o="function"==typeof n?n(e):(0,Gt[n])(r(e,t)),o}function Vt(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Kt(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const Zt=(t,n,r,o,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=t,g=[];let y=0;const p=!(!n&&!r),v="isolate"===u||void 0===u&&null!=i;return f.forEach((t,u)=>{const m=qt(t,u,d,h),b=Kt(t,o,i),x=i&&i.size>0&&i.has(t.label);g.push(e.jsxs("g",{transform:`translate(0,${y})`,onClick:n?()=>n(t):void 0,onMouseEnter:r?()=>r(t):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?l===a&&u===s?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?x||!1:void 0,"aria-current":p&&!v&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:p?e=>{var r;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+f.length)%f.length;c(l,t);const n=null===(r=e.currentTarget.parentElement)||void 0===r?void 0:r.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?e=>{c(l,u),r&&r(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,x&&e.jsx(Vt,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=22}),g};function Ut({config:t,orientation:n="vertical",width:r=100}){const{colorFn:o,domain:i,label:a,format:s}=t,l=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+u.useId();if("horizontal"===n){const t=12,n=Math.min(r,200),s=Math.max(0,(r-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:o(i[0]+n*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":a||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),a&&e.jsx("text",{x:s+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),e.jsx("rect",{x:s,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])}),e.jsx("text",{x:s+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])})]})}const d=[];for(let t=0;64>=t;t++){const n=t/64;d.push(e.jsx("stop",{offset:100*n+"%",stopColor:o(i[1]-n*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":a||"Gradient legend",children:[a&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])})]})}function Qt(t){const{legendGroups:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,legendInteraction:s,title:l="Legend",width:c=100,height:d=20,orientation:h="vertical"}=t,[f,g]=u.useState(0),[y,p]=u.useState(0),v=u.useCallback((e,t)=>{g(e),p(t)},[]),m="vertical"===h?(({legendGroups:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,f)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:Zt(t,r,o,i,a,s,l,f,c,u)},"legend-group-"+f)),d+=22*t.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:v,legendInteraction:s}):(({legendGroups:t,height:n,width:r,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];t.forEach((t,n)=>{let g=0;t.label&&(g+=16);const y=((t,n,r,o,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=t,y=[];let p=0,v=0;const m=!(!n&&!r),b="isolate"===u||void 0===u&&null!=i;g.forEach((t,u)=>{const x=qt(t,u,h,f),k=Kt(t,o,i),w=i&&i.size>0&&i.has(t.label),S=26+7*t.label.length;d&&d>0&&p>0&&p+S>d&&(v++,p=0),y.push(e.jsxs("g",{transform:`translate(${p},${22*v})`,onClick:n?()=>n(t):void 0,onMouseEnter:r?()=>r(t):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:m?l===a&&u===s?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?w||!1:void 0,"aria-current":m&&!b&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:m?e=>{var r;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+g.length)%g.length;c(l,t);const n=null===(r=e.currentTarget.parentElement)||void 0===r?void 0:r.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?e=>{c(l,u),r&&r(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.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:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.jsx(Vt,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),p+=S});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=v+1;return{items:y,offset:x,totalRows:w,totalHeight:22*w}})(t,o,i,a,s,l,c,n,u,d,r);g+=y.offset+5,f.push(Object.assign(Object.assign({label:t.label},y),{offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight})),h+=g+12});let g=h>r?0:Math.max(0,(r-h)/2);const y=[];return f.forEach((r,o)=>{const i=t[o];i.label&&(y.push(e.jsx("text",{transform:`translate(${g},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)),g+=16),y.push(e.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:r.items},"legend-group-"+o)),g+=r.offset+5,t[o+1]&&y.push(e.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(r.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+o)),g+=12}),e.jsx("g",{children:y})})({legendGroups:n||[],title:l,height:d,width:c,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:v,legendInteraction:s}),b=!(!r&&!o);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===h&&e.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),m]})}function Jt(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function en(e){return"object"==typeof e&&null!==e&&"gradient"in e}function tn(t){const{legend:n,totalWidth:r,totalHeight:o,margin:i,legendPosition:a="right",title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!n)return null;const f="top"===a||"bottom"===a;let g,y;return"left"===a?(g=4,y=i.top):"top"===a?(g=0,y=s?32:8):"bottom"===a?(g=0,y=o-i.bottom+50):(g=r-i.right+10,y=i.top),e.jsx("g",{transform:`translate(${g}, ${y})`,children:en(n)?e.jsx(Ut,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?r:100}):Jt(n)?e.jsx(Qt,{legendGroups:n.legendGroups,title:"",width:f?r:100,orientation:f?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function nn(t){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:a,labels:s,title:l,legend:c,legendHoverBehavior:d,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g,legendPosition:y="right",foregroundGraphics:p,sceneNodes:v,annotations:m,svgAnnotationRules:b}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof l?l:"Network Chart"}),e.jsx("desc",{children:"string"==typeof l?l+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[s.map((t,n)=>e.jsx("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)),m&&m.filter(e=>"widget"!==e.type).map((t,o)=>{if(b){const i=b(t,o,{width:n,height:r,sceneNodes:v});if(i)return e.jsx(u.Fragment,{children:i},"annotation-"+o)}return null}),p]}),l&&"string"==typeof l?e.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:o,height:a.top,children:l}):null,tn({legend:c,totalWidth:o,totalHeight:i,margin:a,legendPosition:y,title:l,legendHoverBehavior:d,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g})]}),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,n)=>{var r,o,i,s,l,c,u,d,h;const f=v.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=a.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=a.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(s=f.y)&&void 0!==s?s:0),p=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(c=t.dy)&&void 0!==c?c:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:g+p-b/2,top:y+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+n)})]})}nn.displayName="NetworkSVGOverlay";const rn={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function on(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const an="undefined"==typeof window||"undefined"==typeof document,sn="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,ln=()=>()=>{},cn=()=>!1,un=()=>!0;function dn(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 hn(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 fn(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 gn=u.createContext(null),yn={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function pn(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 vn=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},mn={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},bn={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},xn={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},kn={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},wn={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Sn={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},An={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Mn({nodes:t,edges:n,chartType:r,tableId:o,chartTitle:i}){var a,s,l,c,d,h,f,g,y,p,v,m,b,x;const[k,w]=u.useState(!1),S=u.useContext(gn),A=null!==(a=null==S?void 0:S.visible)&&void 0!==a&&a,M=k||A,j=i?"Data summary for "+i:o?`Data summary for ${r} ${o}`:"Data summary for "+r,L=u.useRef(null),E=u.useCallback(()=>{k||A||w(!0)},[k,A]),D=u.useCallback(e=>{var t;A||(null===(t=L.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[A]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:yn}):null;if(!M)return e.jsx("div",{id:o,tabIndex:-1,onFocus:E,style:yn,role:"region","aria-label":j,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",n.length," edges)"]})});const C=Array.isArray(t)?t:[],P=Array.isArray(n)?n:[],O=new Map,_=new Map,N=new Map,I=new Map;for(const e of P){if(!e||"object"!=typeof e)continue;const t=null!==(s=e.datum)&&void 0!==s?s:e,n="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,r="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";_.set(e,(null!==(d=_.get(e))&&void 0!==d?d:0)+1),I.set(e,(null!==(h=I.get(e))&&void 0!==h?h:0)+o)}if(null!=r&&""!==r){const e=r+"";O.set(e,(null!==(f=O.get(e))&&void 0!==f?f:0)+1),N.set(e,(null!==(g=N.get(e))&&void 0!==g?g:0)+o)}}const T=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const n=null!==(p=null===(y=t.datum)||void 0===y?void 0:y.id)&&void 0!==p?p:t.id,r=null!=n?n+"":"node-"+e,o=null!==(v=O.get(r))&&void 0!==v?v:0,i=null!==(m=_.get(r))&&void 0!==m?m:0,a=null!==(b=N.get(r))&&void 0!==b?b:0,s=null!==(x=I.get(r))&&void 0!==x?x:0;T.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}T.sort((e,t)=>t.degree-e.degree);let W=0,B=0;if(T.length>0){let e=0;for(const t of T)e+=t.degree,t.degree>B&&(B=t.degree);W=e/T.length}const R=P.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)}),$=[`${T.length} nodes, ${P.length} edges.`];T.length>0&&$.push(`Mean degree: ${vn(W)}, max degree: ${B}.`);const z=T.slice(0,5);return e.jsxs("div",{ref:L,id:o,tabIndex:-1,onBlur:D,style:mn,role:"region","aria-label":j,children:[e.jsx("button",{type:"button",onClick:()=>{A&&S&&S.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:xn,children:"×"}),e.jsx("div",{role:"note",style:bn,children:$.join(" ")}),e.jsxs("table",{role:"table","aria-label":"Node degree summary for "+r,style:kn,children:[e.jsxs("caption",{style:An,children:["Top ",z.length," of ",T.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:wn,children:"id"}),e.jsx("th",{style:wn,children:"degree"}),e.jsx("th",{style:wn,children:"in"}),e.jsx("th",{style:wn,children:"out"}),R&&e.jsx("th",{style:wn,children:"w. degree"}),R&&e.jsx("th",{style:wn,children:"w. in"}),R&&e.jsx("th",{style:wn,children:"w. out"})]})}),e.jsx("tbody",{children:z.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:Sn,children:t.id}),e.jsx("td",{style:Sn,children:t.degree}),e.jsx("td",{style:Sn,children:t.inDeg}),e.jsx("td",{style:Sn,children:t.outDeg}),R&&e.jsx("td",{style:Sn,children:vn(t.wDegree)}),R&&e.jsx("td",{style:Sn,children:vn(t.wInDeg)}),R&&e.jsx("td",{style:Sn,children:vn(t.wOutDeg)})]},n))})]})]})}function jn({summary:t}){return t?e.jsx("div",{role:"note",style:yn,children:t}):null}function Ln({tableId:t}){return e.jsx("a",{href:"#"+t,style:yn,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,yn)},children:"Skip to data table"})}function En({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.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:yn,children:n})}const Dn=Object.freeze([]);function Cn(e){if(!e)return Dn;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 Pn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function On(e,t,n=.3){Pn(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 _n(e,t,n=.6){var r,o,i,a,s;if(!Pn(t))return;const l=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,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 Nn(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function In(e,t){var n,r,o,i,a,s;if(!t.pathD)return;e.save();const l=Nn(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,s="string"==typeof t.style.fill?t.style.fill:"#999",l=Ht(e,s)||s;o.addColorStop(0,1===a.from?l:"transparent"),o.addColorStop(1,1===a.to?l:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&Ht(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(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Tn(e,t){var n,r;e.save();const o=t.style.stroke||"#999";e.strokeStyle=Ht(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 Wn(e,t){var n,r,o,i;if(!t.pathD)return;e.save();const a=Nn(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Ht(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=Ht(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 Bn(e,t){var n,r;if(!t.pathD)return;e.save();const o=Nn(t),i=t.style.stroke||"#999";e.strokeStyle=Ht(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&&Ht(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 Rn={top:20,right:80,bottom:20,left:80},$n={top:40,right:40,bottom:40,left:40},zn=new Set(["chord","force","circlepack","orbit"]),Hn=[800,600],Fn={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 Yn({data:t}){var n,r,o,i,a,s;if("edge"===t.nodeOrEdge){const n=t.data;return n?e.jsxs("div",{className:"semiotic-tooltip",style:Fn,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target]}),null!=n.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""]})]}):null}const l=t.data;if(!l)return null;const c=l.__hierarchyNode;if(c){const t=[];let a=c;for(;a;){const e=null!==(i=null!==(r=null===(n=a.data)||void 0===n?void 0:n.name)&&void 0!==r?r:null===(o=a.data)||void 0===o?void 0:o.id)&&void 0!==i?i:l.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const s=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:Fn,children:[e.jsx("div",{children:t.map((t,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),n===s?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},n))}),null!=l.value&&l.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof l.value?l.value.toLocaleString():l.value+""})]})}const u=((null===(a=l.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(s=l.targetLinks)||void 0===s?void 0:s.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:Fn,children:[e.jsx("div",{style:{fontWeight:600},children:l.id}),null!=l.value&&l.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const Xn=t.forwardRef(function(n,r){var o,i,a,l,c,u,g,y,p,v,m,b,x,k,w,S,A,M;const{chartType:j,nodes:L,edges:E,data:D,initialEdges:C,nodeIDAccessor:P="id",sourceAccessor:O="source",targetAccessor:_="target",valueAccessor:N="value",edgeIdAccessor:I,childrenAccessor:T,hierarchySum:W,orientation:B="horizontal",nodeAlign:R="justify",nodePaddingRatio:$=.05,nodeWidth:z=15,iterations:H=300,forceStrength:F=.1,padAngle:Y=.01,groupWidth:X=20,sortGroups:G,edgeSort:q,treeOrientation:V="vertical",edgeType:K="curve",padding:Z,paddingTop:U,tensionConfig:Q,showParticles:J=!1,particleStyle:ee,nodeStyle:te,edgeStyle:ne,colorBy:re,colorScheme:oe="category10",edgeColorBy:ie="source",edgeOpacity:ae=.5,colorByDepth:se=!1,nodeSize:le=8,nodeSizeRange:ce=[5,20],nodeLabel:ue,showLabels:de=!0,labelMode:he,size:fe=Hn,responsiveWidth:ge,responsiveHeight:ye,margin:pe,className:ve,background:me,enableHover:be=!0,tooltipContent:xe,customHoverBehavior:ke,customClickBehavior:we,onObservation:Se,chartId:Ae,onTopologyChange:Me,annotations:je,svgAnnotationRules:Le,legend:Ee,legendPosition:De,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Oe,legendIsolatedCategories:_e,title:Ne,foregroundGraphics:Ie,backgroundGraphics:Te,decay:We,pulse:Be,transition:Re,animate:$e,staleness:ze,thresholds:He,accessibleTable:Fe=!0,description:Ye,summary:Ge,orbitMode:qe,orbitSize:Ve,orbitSpeed:Ke,orbitRevolution:Ze,orbitRevolutionStyle:Ue,orbitEccentricity:Qe,orbitShowRings:Je,orbitAnimated:tt,customNetworkLayout:nt,layoutConfig:rt}=n,it=zn.has(j)?$n:Rn,st=t.useRef(!0),lt=Xt({sizeProp:fe,responsiveWidth:ge,responsiveHeight:ye,userMargin:pe,marginDefault:it,foregroundGraphics:Ie,backgroundGraphics:Te,animate:$e,transitionProp:Re,themeDirtyRef:st}),{reducedMotionRef:ct,responsiveRef:ut,size:dt,margin:ht,adjustedWidth:gt,adjustedHeight:pt,resolvedForeground:mt,resolvedBackground:bt,transition:xt,introEnabled:kt,tableId:wt,rafRef:At,renderFnRef:Mt,scheduleRender:Lt,currentTheme:Et}=lt,Dt=function(){const[e,n]=t.useState(!1);return sn(()=>{n(!0)},[]),e}(),Ct=function(){const e=t.useSyncExternalStore(ln,cn,un);return t.useRef(e).current}(),Pt=t.useMemo(()=>Cn(L),[L]),Ot=t.useMemo(()=>Array.isArray(E)?Cn(E):E,[E]),_t=t.useMemo(()=>Object.assign(Object.assign({},h),Q),[Q]),Nt=t.useMemo(()=>Object.assign(Object.assign({},f),ee),[ee]),It=t.useMemo(()=>{var e;return{chartType:j,nodeIDAccessor:P,sourceAccessor:O,targetAccessor:_,valueAccessor:N,edgeIdAccessor:I,childrenAccessor:T,hierarchySum:W,orientation:B,nodeAlign:R,nodePaddingRatio:$,nodeWidth:z,iterations:H,forceStrength:F,padAngle:Y,groupWidth:X,sortGroups:G,edgeSort:q,treeOrientation:V,edgeType:K,padding:Z,paddingTop:U,tensionConfig:_t,showParticles:J,particleStyle:Nt,nodeStyle:te,edgeStyle:ne,nodeLabel:ue,showLabels:de,labelMode:he,colorBy:re,colorScheme:oe,themeCategorical:null===(e=null==Et?void 0:Et.colors)||void 0===e?void 0:e.categorical,themeSemantic:jt(Et),edgeColorBy:ie,edgeOpacity:ae,colorByDepth:se,nodeSize:le,nodeSizeRange:ce,decay:We,pulse:Be,transition:xt,introAnimation:kt,staleness:ze,thresholds:He,orbitMode:qe,orbitSize:Ve,orbitSpeed:Ke,orbitRevolution:Ze,orbitRevolutionStyle:Ue,orbitEccentricity:Qe,orbitShowRings:Je,orbitAnimated:tt,customNetworkLayout:nt,layoutConfig:rt}},[j,P,O,_,N,T,W,B,R,$,z,H,F,Y,X,G,q,V,K,Z,U,_t,J,Nt,te,ne,ue,de,he,re,oe,ie,ae,se,le,ce,We,Be,null==xt?void 0:xt.duration,null==xt?void 0:xt.easing,kt,ze,He,qe,Ve,Ke,Ze,Ue,Qe,Je,tt,Et,nt,rt]),Tt=function(e){const n=t.useRef(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return hn(e,t);if(!fn(e)||!fn(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(!hn(n,o))return!1}else{if(!fn(n)||!fn(o))return!1;if(!dn(n,o))return!1}}return!0}(n.current,e)||(n.current=e),n.current}(It),Wt=t.useRef(null),Bt=t.useRef(0),Rt=t.useRef(0),$t=t.useRef(!1),zt=t.useRef(null);zt.current||(zt.current=new et(Tt));const[Ft,Yt]=t.useState(null),[Gt,qt]=t.useState(0),[Vt,Kt]=t.useState(0),[Zt,Ut]=t.useState(!1),[Qt,Jt]=t.useState(null),en=t.useRef(null),tn=t.useRef(new Map),gn=t.useRef(0),yn=t.useCallback(e=>{if("function"==typeof re)return re(e)+"";if("string"==typeof re&&e.data){const t=e.data[re];if(void 0!==t){if(!tn.current.has(t+"")){const e=Array.isArray(oe)?oe:Xe;tn.current.set(t+"",e[gn.current++%e.length])}return tn.current.get(t+"")}}if(tn.current.has(e.id))return tn.current.get(e.id);const t=Array.isArray(oe)?oe:Xe,n=re?t[gn.current++%t.length]:t[0];return tn.current.set(e.id,n),n},[re,oe]),vn=(null===(o=null==Et?void 0:Et.colors)||void 0===o?void 0:o.border)||(null===(i=null==Et?void 0:Et.colors)||void 0===i?void 0:i.secondary)||(null===(a=null==Et?void 0:Et.colors)||void 0===a?void 0:a.primary)||"#999",mn=t.useCallback(e=>{var t,n;return e?"object"==typeof e?e:null!==(n=null===(t=zt.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==n?n:null:null},[]),bn=t.useCallback(e=>{if("function"==typeof ie)return ie(e);const t=mn(e.source),n=mn(e.target);return"target"===ie&&n?yn(n):t?yn(t):vn},[ie,yn,vn,mn]),xn=t.useCallback(e=>{if("function"==typeof Nt.color){const t=mn(e.source);return t?Nt.color(e,t):vn}if(!(null==ee?void 0:ee.colorBy))return bn(e);const t=Nt.colorBy,n=mn(e.source),r=mn(e.target);return"target"===t&&r?yn(r):n?yn(n):vn},[null==ee?void 0:ee.colorBy,Nt.color,Nt.colorBy,yn,bn,vn,mn]),kn=("sankey"===j||!!nt)&&J||!!Be||null!==(c=null===(l=zt.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=zt.current)||void 0===e||e.updateConfig(Tt),st.current=!0,Lt()},[Tt,Lt]);const wn=t.useCallback(()=>{var e,t;Jt(null!==(t=null===(e=zt.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);t.useEffect(()=>{var e;const t=zt.current;if(t){t.buildScene([gt,pt]),wn();for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&tn.current.set(n.id,n.style.fill);st.current=!0,Lt()}},[Et,gt,pt,Lt,wn]);const Sn=t.useCallback(()=>{var e;const t=zt.current;if(!t)return;t.runLayout([gt,pt]),t.buildScene([gt,pt]),wn(),st.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&tn.current.set(n.id,n.style.fill);const n=Array.isArray(oe)?oe:Xe,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];tn.current.has(t.id)||tn.current.set(t.id,n[e%n.length])}if(gn.current=r.length,qt(t.layoutVersion),Me){const{nodes:e,edges:n}=t.getLayoutData();Me(e,n)}},[gt,pt,Me,oe,wn]),An=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=zt.current;t&&(t.ingestEdge(e)&&Sn(),Lt())},[Sn,Lt]),Dn=t.useCallback(e=>{const t=zt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&Sn(),Lt()},[Sn,Lt]),Pn=t.useCallback(()=>{var e;null===(e=zt.current)||void 0===e||e.clear(),tn.current.clear(),gn.current=0,qt(0),Yt(null),en.current=null,st.current=!0,Lt()},[Lt]),Nn=t.useCallback(()=>{const e=zt.current;e&&(e.tension+=999,Sn(),Lt())},[Sn,Lt]);t.useImperativeHandle(r,()=>({push:An,pushMany:Dn,removeNode:e=>{var t,n,r;const o=null!==(n=null===(t=zt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(o){const t=(null===(r=en.current)||void 0===r?void 0:r.data)?"function"==typeof P?P(en.current.data):en.current.data[P]:void 0;en.current&&"node"===en.current.nodeOrEdge&&t===e&&(en.current=null,Yt(null)),tn.current.delete(e),Sn(),st.current=!0,Lt()}return o},removeEdge:(e,t)=>{var n,r;const o=null!==(r=null===(n=zt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==r&&r;if(o){if(en.current&&"edge"===en.current.nodeOrEdge){const n=en.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:!I||!n||("function"==typeof I?I:e=>null==e?void 0:e[I])(n)===e,r&&(en.current=null,Yt(null))}Sn(),st.current=!0,Lt()}return o},updateNode:(e,t)=>{var n,r;const o=null!==(r=null===(n=zt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==r?r:null;return o&&(st.current=!0,Lt()),o},updateEdge:(e,t,n)=>{var r,o;const i=null!==(o=null===(r=zt.current)||void 0===r?void 0:r.updateEdge(e,t,n))&&void 0!==o?o:[];return i.length>0&&(Sn(),st.current=!0,Lt()),i},clear:Pn,getTopology:()=>{var e,t;return null!==(t=null===(e=zt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=zt.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:Nn,getTension:()=>{var e,t;return null!==(t=null===(e=zt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[An,Dn,Pn,Nn,Sn,Lt]);const Fn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),Xn=Fn?D||(Array.isArray(E)?void 0:E):void 0;t.useEffect(()=>{var e;const t=zt.current;if(t)if(Fn&&Xn)t.ingestHierarchy(Xn,[gt,pt]),t.buildScene([gt,pt]),wn(),st.current=!0,Lt();else{const n=Pt,r=Array.isArray(Ot)?Ot:[];if(0===n.length&&0===r.length)return;t.ingestBounded(n,r,[gt,pt]),t.buildScene([gt,pt]),wn();for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&tn.current.set(n.id,n.style.fill+"");const o=Array.isArray(oe)?oe:Xe,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];tn.current.has(t.id)||tn.current.set(t.id,o[e%o.length])}gn.current=i.length,st.current=!0,Lt()}},[Pt,Ot,D,Xn,Fn,gt,pt,Tt,Lt,oe,wn]),t.useEffect(()=>{C&&C.length>0&&Dn(C)},[]);const Gn=t.useCallback(e=>{if(ke&&ke(e),Se){const t=Date.now();Se(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae})}},[ke,Se,Ae]),qn=t.useCallback(e=>{if(we&&we(e),Se){const t=Date.now();Se(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae})}},[we,Se,Ae]),{hoverHandlerRef:Vn,hoverLeaveRef:Kn,onPointerMove:Zn,onPointerLeave:Un}=lt;Vn.current=e=>{if(!be)return;const t=Wt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-ht.left,o=e.clientY-n.top-ht.top;if(0>r||r>gt||0>o||o>pt)return void(en.current&&(en.current=null,Yt(null),Gn&&(Gn(null),st.current=!0),Lt()));const i=zt.current;if(!i)return;const a=at(i.sceneNodes,i.sceneEdges,r,o);if(!a)return void(en.current&&(en.current=null,Yt(null),Gn&&(Gn(null),st.current=!0),Lt()));const s=d(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});en.current=s,Yt(s),Gn&&(Gn(s),st.current=!0),Lt()},Kn.current=()=>{en.current&&(en.current=null,Yt(null),Gn&&(Gn(null),st.current=!0),Lt())};const Qn=t.useRef(()=>{});Qn.current=e=>{if(!we&&!Se)return;const t=Wt.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-ht.left,o=e.clientY-n.top-ht.top;if(0>r||r>gt||0>o||o>pt)return;const i=zt.current;if(!i)return;const a=at(i.sceneNodes,i.sceneEdges,r,o);qn(a?d(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)};const Jn=t.useCallback(e=>Qn.current(e),[]),er=t.useRef(-1),tr=t.useRef(null),nr=t.useRef(-1),rr=t.useCallback(e=>{var t;const n=zt.current;if(!n)return;const r=function(e){var t,n,r,o,i,a;const s=[];for(const l of e)if("circle"===l.type&&null!=l.cx){if(0>=l.r)continue;s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(n=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"})}else if("rect"===l.type&&null!=l.x){if(0>=l.w||0>=l.h)continue;s.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=null===(r=l.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"})}else"arc"===l.type&&null!=l.cx&&s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(a=null===(i=l.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(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=er.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(),er.current=0,nr.current=-1;const t=o.flat[0];tr.current={shape:t.shape,w:t.w,h:t.h};const n=d(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return en.current=n,Yt(n),Gn&&(Gn(n),st.current=!0),void Lt()}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),s=function(e,t,n,r,o){var i,a,s;const l=n.flat[t.flatIndex];if(!l)return ft(e,t,n);const c=null===(i=l.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 s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;o>u&&(o=u,r=i)}return r}(n,l,"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=yt(t.source),a=yt(t.target),s=null!=i,l=null!=a;s&&i+""===r&&l?o.push(a+""):l&&a+""===r&&s&&o.push(i+"")}return o}(c,r);if(0===e.length)return t.flatIndex;const i=null!==(s=n.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=ft(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:[],nr);if(null===s)return;if(e.preventDefault(),0>s)return er.current=-1,tr.current=null,nr.current=-1,en.current=null,Yt(null),Gn&&(Gn(null),st.current=!0),void Lt();er.current=s;const l=o.flat[s];tr.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};en.current=c,Yt(c),Gn&&(Gn(c),st.current=!0),Lt()},[Gn,Lt]),or=t.useCallback(e=>{er.current=-1,tr.current=null,Zn(e)},[Zn]);Mt.current=()=>{var e,t,n,r,o,i,a;At.current=0;const s=Wt.current;if(!s)return;const l=s.getContext("2d");if(!l)return;const c=zt.current;if(!c)return;const u=performance.now(),d=Bt.current?Math.min((u-Bt.current)/1e3,.1):.016;Bt.current=u;const h=c.advanceTransition(ct.current?u+1e6:u),g=!ct.current&&h,y=!ct.current&&c.tickAnimation([gt,pt],d);(h||st.current||y)&&c.buildScene([gt,pt]);const p="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,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),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}(s,dt,ht,p))return;if(l.clearRect(-ht.left,-ht.top,dt[0],dt[1]),me){const e=Ht(l,me);e&&(l.fillStyle=e,l.fillRect(0,0,gt,pt))}We&&c.applyDecay(),Be&&c.applyPulse(u),He&&c.applyThresholds(u),c.applyTopologyDiff(u);const v=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,m=ze&&c.lastIngestTime>0&&u-c.lastIngestTime>v;if(m&&(l.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":In(e,n);break;case"line":Tn(e,n);break;case"ribbon":Wn(e,n);break;case"curved":Bn(e,n)}}(l,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&&Ht(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=Ht(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)),On(e,t),e.restore())}}(l,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&&Ht(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=Ht(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()),_n(e,t),e.restore())}}(l,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&&Ht(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=Ht(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()}}(l,c.sceneNodes),J&&c.particlePool&&!m){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:f.spawnRate,s=null!==(i=r.maxPerEdge)&&void 0!==i?i:f.maxPerEdge;for(let r=0;t.length>r;r++){const o=t[r];if(!o.bezier)continue;if(e.countForEdge(r)>=s)continue;const i=o.value*a*n*(o.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<s;t++)e.spawn(r)}}(c.particlePool,e,d,Nt);const t=.5*(null!==(n=Nt.speedMultiplier)&&void 0!==n?n:1);let r;if(Nt.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(d,t,e,r),function(e,t,n,r,o){var i,a;const s=null!==(i=r.radius)&&void 0!==i?i:f.radius,l=null!==(a=r.opacity)&&void 0!==a?a:f.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=Ht(e,c)||c,e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}e.globalAlpha=1}(l,c.particlePool,e,Nt,xn)}}m&&(l.globalAlpha=1);const b=st.current;if(st.current=!1,b||g||y){const e=Wt.current;e&&e.setAttribute("aria-label",pn(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 x=b||g||y||$t.current;x&&u-Rt.current>=33?(Kt(e=>e+1),Rt.current=u,$t.current=!1):$t.current=!!x,(kn||g||null!=c.transition||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||$t.current)&&(At.current=requestAnimationFrame(()=>Mt.current()))},function(e){const{hydrated:n,wasHydratingFromSSR:r,storeRef:o,dirtyRef:i,renderFnRef:a,cleanup:s}=e;sn(()=>{var e,t;n&&r&&(null===(t=null===(e=o.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),i.current=!0,a.current()},[n,r]);const l=t.useRef(s);l.current=s,t.useEffect(()=>()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)},[])}({hydrated:Dt,wasHydratingFromSSR:Ct,storeRef:zt,dirtyRef:st,renderFnRef:Mt}),t.useEffect(()=>{st.current=!0,Lt()},[j,gt,pt,me,Lt]),function(e,n,r,o,i,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const s=n.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),r.current=!0,o())},1e3);return()=>clearInterval(t)},[e,i,o])}(ze,zt,st,Lt,Zt,Ut);const ir=be&&Ft?e.jsx(St,{x:Ft.x,y:Ft.y,containerWidth:gt,containerHeight:pt,margin:ht,className:"stream-network-tooltip",zIndex:2,children:xe?xe(Ft):e.jsx(Yn,{data:Ft})}):null;if(an||!Dt&&Ct){const t=zt.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),n=e?D||(Array.isArray(E)?void 0:E):void 0;if(e&&n)t.ingestHierarchy(n,[gt,pt]),t.buildScene([gt,pt]);else{const e=Pt,n=Array.isArray(Ot)?Ot:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[gt,pt]),t.buildScene([gt,pt]))}}const n=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],r=null!==(g=null==t?void 0:t.sceneEdges)&&void 0!==g?g:[],o=null!==(y=null==t?void 0:t.labels)&&void 0!==y?y:[];return e.jsxs("div",{ref:ut,className:"stream-network-frame"+(ve?" "+ve:""),role:"img","aria-label":Ye||("string"==typeof Ne?Ne:"Network chart"),style:{position:"relative",width:ge?"100%":dt[0],height:ye?"100%":dt[1]},children:[e.jsx(jn,{summary:Ge}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:dt[0],height:dt[1],style:{position:"absolute",left:0,top:0},children:[bt&&e.jsx("g",{transform:`translate(${ht.left},${ht.top})`,children:bt}),e.jsxs("g",{transform:`translate(${ht.left},${ht.top})`,children:[me&&e.jsx("rect",{x:0,y:0,width:gt,height:pt,fill:me}),r.map((t,n)=>function(t,n){switch(t.type){case"line":return e.jsx("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.jsx("path",{d:r.pathD,fill:on(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.jsx("path",{d:r.pathD,fill:on(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.jsx("path",{d:r.pathD,fill:on(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),n.map((t,n)=>function(t,n){switch(t.type){case"circle":{const r=t;return e.jsx("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:on(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.jsx("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:on(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},"net-rect-"+n)}case"arc":{const r=t,o=s.arc().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2)(rn)||"";return e.jsx("path",{d:o,transform:`translate(${r.cx},${r.cy})`,fill:on(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),o.map((t,n)=>function(t,n){return e.jsx("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.jsx(nn,{width:gt,height:pt,totalWidth:dt[0],totalHeight:dt[1],margin:ht,labels:o,sceneNodes:n,title:Ne,legend:Ee,legendPosition:De,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Oe,legendIsolatedCategories:_e,foregroundGraphics:ot(mt,null===(p=zt.current)||void 0===p?void 0:p.customLayoutOverlays),annotations:je,svgAnnotationRules:Le,annotationFrame:0})]})}const ar=zt.current;return e.jsxs("div",{ref:ut,className:"stream-network-frame"+(ve?" "+ve:""),role:"group","aria-label":Ye||("string"==typeof Ne?Ne:"Network chart"),tabIndex:0,style:{position:"relative",width:ge?"100%":dt[0],height:ye?"100%":dt[1],overflow:"visible"},onKeyDown:rr,children:[Fe&&e.jsx(Ln,{tableId:wt}),Fe&&e.jsx(Mn,{nodes:null!==(v=null==ar?void 0:ar.sceneNodes)&&void 0!==v?v:[],edges:null!==(m=null==ar?void 0:ar.sceneEdges)&&void 0!==m?m:[],chartType:"Network chart",tableId:wt,chartTitle:"string"==typeof Ne?Ne:void 0}),e.jsx(jn,{summary:Ge}),e.jsxs("div",{role:"img","aria-label":Ye||("string"==typeof Ne?Ne:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:be?or:void 0,onMouseLeave:be?Un:void 0,onClick:we||Se?Jn:void 0,children:[bt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:dt[0],height:dt[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${ht.left},${ht.top})`,children:bt})}),e.jsx("canvas",{ref:Wt,"aria-label":pn(null!==(x=null===(b=null==ar?void 0:ar.sceneNodes)||void 0===b?void 0:b.length)&&void 0!==x?x:0,null!==(w=null===(k=null==ar?void 0:ar.sceneEdges)||void 0===k?void 0:k.length)&&void 0!==w?w:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(En,{hoverPoint:Ft}),e.jsx(nn,{width:gt,height:pt,totalWidth:dt[0],totalHeight:dt[1],margin:ht,labels:(null==ar?void 0:ar.labels)||[],sceneNodes:null==ar?void 0:ar.sceneNodes,title:Ne,legend:Ee,legendPosition:De,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Oe,legendIsolatedCategories:_e,foregroundGraphics:ot(mt,Qt),annotations:je,svgAnnotationRules:Le,annotationFrame:Vt}),e.jsx(vt,{active:er.current>=0,hoverPoint:Ft,margin:ht,size:dt,shape:null===(S=tr.current)||void 0===S?void 0:S.shape,width:null===(A=tr.current)||void 0===A?void 0:A.w,height:null===(M=tr.current)||void 0===M?void 0:M.h}),ir,(null==ze?void 0:ze.showBadge)&&e.jsx("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:Zt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Zt?"STALE":"LIVE"})]})]})});function Gn(e,n){const{variant:r,frameRef:o,overrides:i,deps:a}=n;t.useImperativeHandle(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 s=Array.isArray(t)?t:[t],l=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 s){const n=l.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:[]}}}(r,o);return Object.assign(Object.assign({},e),i)},null!=a?a:[])}Xn.displayName="StreamNetworkFrame";const qn=t.createContext(null);function Vn(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 Kn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Zn,Un]=At(e=>({selections:new Map,setClause(t,n){e(e=>{const r=new Map(e.selections),o=Kn(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=Kn(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}})}})),[Qn,Jn]=At(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 er={positions:new Map};const tr=new Set;function nr(){for(const e of tr)e()}function rr(e,t){const n=er.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(er.positions);r.delete(e),er={positions:r},nr()}function or(e){const n=t.useId(),r=e.clientId||n,{name:o}=e,i=Un(e=>e.selections.get(o)),a=Un(e=>e.setClause),s=Un(e=>e.clearClause),l=t.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:t.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Vn(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,r):()=>!0,[i,r]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)};a(o,{clientId:r,type:"point",fields:t})},[r,o,a]),selectInterval:t.useCallback(e=>{const t={};for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r};a(o,{clientId:r,type:"interval",fields:t})},[r,o,a]),clear:t.useCallback(()=>{s(o,r)},[s,o,r]),clientId:r}}const ir=t.createContext(!1),ar=t.createContext(null),sr="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function lr(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 cr(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 ur(){var e;const t=Nt(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 dr(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=Ye[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function hr({data:e,colorBy:n,colorScale:r,showLegend:o,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(ir),u=null!==t.useContext(ar),d=void 0!==o?o:!c&&!!n,h=!!n&&(d||u),f=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const r of e){const e="function"==typeof n?n(r):r[n];null!=e&&t.add(e+"")}return Array.from(t)},[l,n,e,h]);!function(e){const n=t.useContext(ar),r=t.useId(),o=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=t.useRef([]);(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 a=i.current;sr(()=>{if(n)return()=>n.unregisterCategories(r)},[n,r]),sr(()=>{n&&n.registerCategories(r,a)},[n,r,a])}(u&&n?f:[]);const g=t.useMemo(()=>{if(!d||!n)return;const t=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){const s=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?r(a,t,n):n?n(o):Ge[i%Ge.length];return{label:o+"",color:s}});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:s,label:""}]}}({data:e,colorBy:n,colorScale:r,getColor:Ke,categories:f});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,n,e,r,f]),y=t.useMemo(()=>{const e="number"==typeof a?{top:a,bottom:a,left:a,right:a}:null!=a?a:{},t=Object.assign(Object.assign({},s),e);return g&&("right"===i&&110>t.right?t.right=110:"left"===i&&110>t.left?t.left=110:"top"===i&&50>t.top?t.top=50:"bottom"===i&&80>t.bottom&&(t.bottom=80)),t},[s,a,g,i]);return{legend:g,margin:y,legendPosition:i}}u.createContext(void 0);const fr={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 gr(e,t,n){var r,o,i,a,s,l,c;const u=fr[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(r=t.width)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:yr(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function yr(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 pr(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 vr(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 mr(e){return"function"==typeof e?e:t=>t[e]||1}function br({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:o},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=Ke(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ke(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function xr({componentName:t,message:n,diagnosticHint:r,width:o,height:i}){return e.jsx("div",{role:"alert",style:{width:o,height:Math.max(i,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:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),r&&e.jsx("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 kr extends u.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.jsx(xr,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function wr({componentName:t,width:n,height:r,children:o}){return e.jsx(kr,{fallback:o=>e.jsx(xr,{componentName:t,message:o.message,width:n,height:r}),children:o})}"undefined"!=typeof process&&process;const Sr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Ar={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Mr(n){const{nodes:r,edges:o,inferNodes:i=!0,sourceAccessor:a="source",targetAccessor:s="target",colorBy:l,colorScheme:c,showLegend:u,legendPosition:d,legendInteraction:h,selection:f,linkedHover:g,onObservation:y,onClick:p,chartType:v,chartId:m,marginDefaults:b,userMargin:x,width:k,height:w,loading:S,emptyContent:A,emptyDataKey:M="edges"}=n,j=t.useMemo(()=>Cn(o),[o]),L=t.useMemo(()=>Cn(r),[r]),E=function(t,n,r){if(!t)return null;const o=Math.min(5,Math.floor(r/40)),i=Math.max(8,Math.floor(r/(3*o))),a=Math.max(6,Math.floor(r/(2.5*o))),s=Math.floor((r-(o*(i+a)-a))/2);return e.jsx("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:o},(t,r)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ar),{position:"absolute",top:s+r*(i+a),left:Math.floor(.1*n),width:30+(37*r+13)%50+"%",height:i,opacity:.5+r%2*.2})},r))})}(S,k,w),D=E?null:function(t,n,r,o){return!1===o||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},Sr),{width:n,height:r}),children:o||"No data available"}):null}("nodes"===M?void 0===r?void 0:L:void 0===o?void 0:j,k,w,A),C=t.useMemo(()=>i?vr(L,j,a,s):L,[i,L,j,a,s]),P=function(e,n,r){const o=t.useContext(qn),i=ur();return t.useMemo(()=>{var t;if(!n)return;const a=null!==(t=null!=r?r:i&&i.length>0?i:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof n){const t=Array.from(new Set(e.map(e=>n(e)+"")));if(o&&Object.keys(o).length>0){const e=Ze(t.map(e=>({_cat:e})),"_cat",a);return t=>o[t]||e(t)}return Ze(t.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const t=Ze(e,n,a);return e=>o[e]||t(e)}return Ze(e,n,a)}if(o&&Object.keys(o).length>0){const e=Ze([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[e,n,r,o,i])}(C,l,c),O=ur(),_=t.useMemo(()=>{if(Array.isArray(c))return c;if(O&&O.length>0)return O;if("string"==typeof c){const e=Ye[c];if(Array.isArray(e)&&e.length>0)return e}return Xe},[c,O]),N=t.useMemo(()=>{if(!l)return[];const e=new Set;for(const t of C){const n="function"==typeof l?l(t):t[l];null!=n&&e.add(n+"")}return Array.from(e)},[C,l]),I=function(e,n,r){const[o,i]=t.useState(null),[a,s]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&i(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&s(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===r.length?new Set:n})},[e,r.length]),u=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===o}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const r=t?e[t]:"function"==typeof n?n(e):null;return a.has(r)}}:null},[e,n,o,a]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(h,l,N),{legend:T,margin:W,legendPosition:B}=hr({data:C,colorBy:l,colorScale:P,showLegend:u,legendPosition:d,userMargin:x,defaults:b,categories:N}),R=function({selection:e,linkedHover:n,fallbackFields:r=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(n,r),f=or({name:(null==e?void 0:e.name)||"__unused__"}),g=function(e){const n=e.name||"hover",{fields:r}=e,{predicate:o,isActive:i,selectPoints:a,clear:s}=or({name:n});return{onHover:t.useCallback(e=>{if(!e)return void s();const t={};for(const n of r){const r=e[n];void 0!==r&&(t[n]=[r])}Object.keys(t).length>0&&a(t)},[r,a,s,n]),predicate:o,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||r||[]}),y=Jn(e=>e.pushObservation),p=e?{isActive:f.isActive,predicate:f.predicate}:null,[v,m]=t.useState(null),b=u||r[0],x=t.useMemo(()=>{if(!c||null==v||!b)return null;const e=v,t=b;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[t]?n[t]:(null!==(r=n[t])&&void 0!==r?r:"")+"")===e}}},[c,v,b]),k=t.useCallback(e=>{var t,r;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=lr(e,t,h.xField);null!=n&&function(e,t,n){const r=er.positions.get(e);(null==r?void 0:r.locked)||r&&r.xValue===t&&r.sourceId===n||(er={positions:new Map(er.positions).set(e,{xValue:t,sourceId:n})},nr())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&rr(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];m(null!=n?n+"":null)}else m(null);if(i||y){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const o=cr(e),a=Object.assign(Object.assign({},n),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),y&&y(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),y&&y(e)}}},[n,g,h,d,i,a,s,y,c,b]),w=t.useCallback(e=>{var t,n,r,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=lr(e,t,h.xField);null!=n&&function(e,t,n){const r=er.positions.get(e);if(null==r?void 0:r.locked){const t=new Map(er.positions);return t.delete(e),er={positions:t},nr(),!1}er={positions:new Map(er.positions).set(e,{xValue:t,sourceId:n,locked:!0})},nr()}(h.name||"hover",n,d)}if(e&&l){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]),l(r,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||y){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const n=cr(e),a=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(r=e.x)&&void 0!==r?r:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),y&&y(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),y&&y(e)}}},[l,i,y,a,s,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{!function(e,t){const n=er.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const r=new Map(er.positions);r.delete(e),er={positions:r},nr()}(e,d),rr(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}({selection:f,linkedHover:g,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:y,onClick:p,chartType:v,chartId:m}),{customHoverBehavior:$,customClickBehavior:z,activeSelectionHook:H,hoverSelectionHook:F,crosshairSourceId:Y}=R;return{safeNodes:C,safeEdges:j,colorScale:P,effectivePalette:_,themeCategorical:O,allCategories:N,legendState:I,legend:T,margin:W,legendPosition:B,customHoverBehavior:$,customClickBehavior:z,activeSelectionHook:H,hoverSelectionHook:F,crosshairSourceId:Y,loadingEl:E,emptyEl:D}}function jr(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 Lr(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 Er(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=Lr(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 Dr({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 Cr({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=Er(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 Pr=t.forwardRef(function(n,r){var o;const i=t.useRef(null);Gn(r,{variant:"network",frameRef:i});const a=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLegend:n.showLegend,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{nodes:s,edges:l,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:h,sourceAccessor:f="source",targetAccessor:g="target",nodeLabel:y,colorBy:p,colorScheme:v,nodeSize:m=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:k="#999",edgeOpacity:w=.6,iterations:S=300,forceStrength:A=.1,tooltip:M,frameProps:j={},onObservation:L,onClick:E,chartId:D,selection:C,linkedHover:P,loading:O,emptyContent:_,legendInteraction:N,legendPosition:I,stroke:T,strokeWidth:W,opacity:B}=n,R=null!==(o=null!=d?d:h)&&void 0!==o?o:"id",{width:$,height:z,enableHover:H,showLegend:F,showLabels:Y=!1,title:X,description:G,summary:q,accessibleTable:V}=a,K=Mr({nodes:s,edges:l,inferNodes:!1,sourceAccessor:f,targetAccessor:g,colorBy:p,colorScheme:v,showLegend:F,legendPosition:I,legendInteraction:N,selection:C,linkedHover:P,onObservation:L,onClick:E,chartType:"ForceDirectedGraph",chartId:D,marginDefaults:a.marginDefaults,userMargin:c,width:$,height:z,loading:O,emptyContent:_,emptyDataKey:"nodes"}),Z=t.useMemo(()=>new Map,[]),U=t.useMemo(()=>e=>{const t={};return t.fill=p?Ke(e.data||e,p,K.colorScale):dr(0,K.themeCategorical,v),"number"==typeof m&&(t.r=m),t},[p,K.colorScale,m,K.themeCategorical,v,Z]),Q=t.useMemo(()=>jr(U,{stroke:T,strokeWidth:W,opacity:B}),[U,T,W,B]),J=t.useMemo(()=>e=>({stroke:k,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:w}),[x,k,w]),ee=t.useMemo(()=>jr(J,{stroke:T,strokeWidth:W,opacity:B}),[J,T,W,B]),te=t.useMemo(()=>{if(Y&&y)return"function"==typeof y?y:e=>{var t,n,r;return null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t[y])&&void 0!==n?n:e[y])&&void 0!==r?r:e.id}},[Y,y]),ne=Cr({componentName:"ForceDirectedGraph",nodes:s,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:R}});return ne?e.jsx(xr,{componentName:"ForceDirectedGraph",message:ne,width:$,height:z}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e.jsx(wr,{componentName:"ForceDirectedGraph",width:$,height:z,children:e.jsx(Xn,Object.assign({ref:i,chartType:"force"},null!=s&&{nodes:K.safeNodes},null!=l&&{edges:K.safeEdges},{size:[$,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K.margin,nodeIDAccessor:R,sourceAccessor:f,targetAccessor:g,iterations:S,forceStrength:A,nodeStyle:Q,edgeStyle:ee,colorBy:p,colorScheme:K.effectivePalette,nodeSize:m,nodeSizeRange:b,nodeLabel:te,showLabels:Y,enableHover:H,tooltipContent:!1===M?()=>null:wt(M)||void 0,customHoverBehavior:P||L||E?K.customHoverBehavior:void 0,customClickBehavior:L||E?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},N&&"none"!==N&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:u,title:X,description:G,summary:q,accessibleTable:V},null!=n.animate&&{animate:n.animate},j))})});Pr.displayName="ForceDirectedGraph";const Or=t.forwardRef(function(n,r){const o=t.useRef(null);Gn(r,{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 i=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:800,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",orientation:v="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,edgeOpacity:w=.5,edgeSort:S,tooltip:A,frameProps:M={},onObservation:j,onClick:L,chartId:E,selection:D,linkedHover:C,loading:P,emptyContent:O,legendInteraction:_,stroke:N,strokeWidth:I,opacity:T}=n,{width:W,height:B,enableHover:R,showLabels:$=!0,title:z,description:H,summary:F,accessibleTable:Y}=i,X=Mr({nodes:a,edges:s,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:g,colorScheme:y,showLegend:void 0,legendInteraction:_,selection:D,linkedHover:C,onObservation:j,onClick:L,chartType:"SankeyDiagram",chartId:E,marginDefaults:i.marginDefaults,userMargin:l,width:W,height:B,loading:P,emptyContent:O}),G=t.useMemo(()=>new Map,[]),q=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Ke(e.data||e,g,X.colorScale):dr(0,X.themeCategorical,y),t},[g,X.colorScale,X.themeCategorical,y,G]),V=t.useMemo(()=>jr(q,{stroke:N,strokeWidth:I,opacity:T}),[q,N,I,T]),K=t.useMemo(()=>br({edgeColorBy:p,colorBy:g,colorScale:X.colorScale,nodeStyleFn:V,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[p,g,X.colorScale,V,w]),Z=t.useMemo(()=>jr(K,{stroke:N,strokeWidth:I,opacity:T}),[K,N,I,T]),U=t.useMemo(()=>{if(!$)return;const e=k||f;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}},[$,k,f]),Q=Cr({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return Q?e.jsx(xr,{componentName:"SankeyDiagram",message:Q,width:W,height:B}):X.loadingEl?X.loadingEl:X.emptyEl?X.emptyEl:e.jsx(wr,{componentName:"SankeyDiagram",width:W,height:B,children:e.jsx(Xn,Object.assign({ref:o,chartType:"sankey"},X.safeNodes.length>0&&{nodes:X.safeNodes},null!=s&&{edges:X.safeEdges},{size:[W,B],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:X.margin,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:v,nodeAlign:m,nodePaddingRatio:b,nodeWidth:x,nodeStyle:V,edgeStyle:Z,colorBy:g,colorScheme:X.effectivePalette,edgeColorBy:p,edgeOpacity:w,edgeSort:S,nodeLabel:U,showLabels:$,enableHover:R,tooltipContent:!1===A?()=>null:wt(A)||void 0,customHoverBehavior:C||j||L?X.customHoverBehavior:void 0,customClickBehavior:j||L?X.customClickBehavior:void 0},_&&"none"!==_&&{legendHoverBehavior:X.legendState.onLegendHover,legendClickBehavior:X.legendState.onLegendClick,legendHighlightedCategory:X.legendState.highlightedCategory,legendIsolatedCategories:X.legendState.isolatedCategories},{className:c,title:z,description:H,summary:F,accessibleTable:Y},null!=n.animate&&{animate:n.animate},M))})});Or.displayName="SankeyDiagram";const _r=t.forwardRef(function(n,r){const o=t.useRef(null);Gn(r,{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 i=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",padAngle:v=.01,groupWidth:m=20,sortGroups:b,nodeLabel:x,edgeOpacity:k=.5,tooltip:w,frameProps:S={},onObservation:A,onClick:M,chartId:j,selection:L,linkedHover:E,loading:D,emptyContent:C,legendInteraction:P,stroke:O,strokeWidth:_,opacity:N}=n,{width:I,height:T,enableHover:W,showLabels:B=!0,title:R,description:$,summary:z,accessibleTable:H}=i,F=Mr({nodes:a,edges:s,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:g,colorScheme:y,showLegend:!1,legendInteraction:P,selection:L,linkedHover:E,onObservation:A,onClick:M,chartType:"ChordDiagram",chartId:j,marginDefaults:i.marginDefaults,userMargin:l,width:I,height:T,loading:D,emptyContent:C}),Y=t.useMemo(()=>new Map,[]),X=F.safeNodes.length>0,G=t.useMemo(()=>{if(X)return(e,t)=>{var n,r;const o={stroke:"black",strokeWidth:1};if(g)o.fill=Ke(e.data||e,g,F.colorScale);else{const i=Array.isArray(y)?y:Ye[y]||Xe,a=Array.isArray(i)?i:Xe,s=null!==(r=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==r?r:0;o.fill=a[s%a.length]}return o}},[X,g,F.colorScale,y]),q=t.useMemo(()=>G?jr(G,{stroke:O,strokeWidth:_,opacity:N}):void 0,[G,O,_,N]),V=t.useMemo(()=>{if(X)return br({edgeColorBy:p,colorBy:g,colorScale:F.colorScale,nodeStyleFn:q||(e=>({fill:dr(0,F.themeCategorical,y)})),edgeOpacity:k,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:k}})},[X,p,g,F.colorScale,q,k,F.themeCategorical,y,Y]),K=t.useMemo(()=>V?jr(V,{stroke:O,strokeWidth:_,opacity:N}):void 0,[V,O,_,N]),Z=t.useMemo(()=>{if(!B)return;const e=x||f;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}},[B,x,f]),U=Cr({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return U?e.jsx(xr,{componentName:"ChordDiagram",message:U,width:I,height:T}):F.loadingEl?F.loadingEl:F.emptyEl?F.emptyEl:e.jsx(wr,{componentName:"ChordDiagram",width:I,height:T,children:e.jsx(Xn,Object.assign({ref:o,chartType:"chord"},F.safeNodes.length>0&&{nodes:F.safeNodes},null!=s&&{edges:F.safeEdges},{size:[I,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:F.margin,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:v,groupWidth:m,sortGroups:b,nodeStyle:q,edgeStyle:K,colorBy:g,colorScheme:F.effectivePalette,edgeColorBy:p,edgeOpacity:k,nodeLabel:Z,showLabels:B,enableHover:W,tooltipContent:!1===w?()=>null:wt(w)||void 0,customHoverBehavior:E||A||M?F.customHoverBehavior:void 0,customClickBehavior:A||M?F.customClickBehavior:void 0},P&&"none"!==P&&{legendHoverBehavior:F.legendState.onLegendHover,legendClickBehavior:F.legendState.onLegendClick,legendHighlightedCategory:F.legendState.highlightedCategory,legendIsolatedCategories:F.legendState.isolatedCategories},{className:c,title:R,description:$,summary:z,accessibleTable:H},null!=n.animate&&{animate:n.animate},S))})});function Nr(n){const r=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{data:o,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="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,legendInteraction:j,stroke:L,strokeWidth:E,opacity:D}=n,{width:C,height:P,enableHover:O,showLabels:_=!0,title:N,description:I,summary:T,accessibleTable:W}=r,B=Mr({nodes:t.useMemo(()=>pr(null!=o?o:null,c),[o,c]),edges:void 0,inferNodes:!1,colorBy:g?void 0:h,colorScheme:f,showLegend:!1,legendInteraction:j,selection:S,linkedHover:A,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:r.marginDefaults,userMargin:i,width:C,height:P,loading:M}),R=t.useMemo(()=>new Map,[]),$=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?qe[(e.depth||0)%qe.length]:h?Ke(e.data||e,h,B.colorScale):dr(0,B.themeCategorical,f),t},[h,g,B.colorScale,B.themeCategorical,f,R]),z=t.useMemo(()=>jr($,{stroke:L,strokeWidth:E,opacity:D}),[$,L,E,D]),H=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),F=t.useMemo(()=>jr(H,{stroke:L,strokeWidth:E,opacity:D}),[H,L,E,D]),Y=t.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return mr(u)},[s,u]),X=Dr({componentName:"TreeDiagram",data:o});return X?e.jsx(xr,{componentName:"TreeDiagram",message:X,width:C,height:P}):B.loadingEl?B.loadingEl:e.jsx(wr,{componentName:"TreeDiagram",width:C,height:P,children:e.jsx(Xn,Object.assign({chartType:s},null!=o&&{data:o},{size:[C,P],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:B.margin,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:Y,treeOrientation:l,edgeType:y,nodeStyle:z,edgeStyle:F,colorBy:h,colorScheme:B.effectivePalette,colorByDepth:g,nodeSize:v,nodeLabel:_?p||d:void 0,showLabels:_,enableHover:O,tooltipContent:!1===m?()=>null:wt(m)||void 0,customHoverBehavior:A||x||k?B.customHoverBehavior:void 0,customClickBehavior:x||k?B.customClickBehavior:void 0},j&&"none"!==j&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},{className:a,title:N,description:I,summary:T,accessibleTable:W},null!=n.animate&&{animate:n.animate},b))})}function Ir(n){const r=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,linkedHover:n.linkedHover},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:f="leaf",nodeLabel:g,padding:y=4,paddingTop:p,tooltip:v,frameProps:m={},selection:b,linkedHover:x,onObservation:k,onClick:w,chartId:S,loading:A,legendInteraction:M,stroke:j,strokeWidth:L,opacity:E}=n,{width:D,height:C,enableHover:P,showLabels:O=!0,title:_,description:N,summary:I,accessibleTable:T}=r,W=Mr({nodes:t.useMemo(()=>pr(null!=o?o:null,s),[o,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:M,selection:b,linkedHover:x,onObservation:k,onClick:w,chartType:"Treemap",chartId:S,marginDefaults:r.marginDefaults,userMargin:i,width:D,height:C,loading:A}),B=function(e){const n=Nt(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,r;if(void 0!==e||void 0!==n)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(r=null==e?void 0:e.unselectedOpacity)&&void 0!==r?r:n})},[e,n])}(b),R=W.customHoverBehavior,$=t.useCallback(e=>{if(!e)return R(null);const t=e.data||e;R({data:(null==t?void 0:t.data)||t})},[R]),z=t.useMemo(()=>new Map,[]),H=t.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?qe[(e.depth||0)%qe.length]:u?Ke(e.data||e,u,W.colorScale):dr(0,W.themeCategorical,d),t},[u,h,W.colorScale,W.themeCategorical,d,z]),F=t.useMemo(()=>jr(H,{stroke:j,strokeWidth:L,opacity:E}),[H,j,L,E]),Y=t.useMemo(()=>W.activeSelectionHook?e=>{var t;const n=Object.assign({},F(e));if(W.activeSelectionHook.isActive)if(W.activeSelectionHook.predicate(e.data||e))(null==B?void 0:B.selectedStyle)&&Object.assign(n,B.selectedStyle);else{const e=null!==(t=null==B?void 0:B.unselectedOpacity)&&void 0!==t?t:.5;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==B?void 0:B.unselectedStyle)&&Object.assign(n,B.unselectedStyle)}return n}:F,[F,W.activeSelectionHook,B]),X=t.useMemo(()=>mr(l),[l]),G=void 0!==p?p:!O||"parent"!==f&&"all"!==f?void 0:18,q=Dr({componentName:"Treemap",data:o});return q?e.jsx(xr,{componentName:"Treemap",message:q,width:D,height:C}):W.loadingEl?W.loadingEl:e.jsx(wr,{componentName:"Treemap",width:D,height:C,children:e.jsx(Xn,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[D,C],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:W.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:X,padding:y,paddingTop:G,nodeStyle:Y,colorBy:u,colorScheme:W.effectivePalette,colorByDepth:h,nodeLabel:O?g||c:void 0,showLabels:O,labelMode:f,enableHover:P,tooltipContent:!1===v?()=>null:wt(v)||void 0},(x||k||w)&&{customHoverBehavior:$},(k||w)&&{customClickBehavior:W.customClickBehavior},M&&"none"!==M&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},{className:a,title:_,description:N,summary:I,accessibleTable:T},null!=n.animate&&{animate:n.animate},m))})}function Tr(n){const r=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,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,legendInteraction:A,stroke:M,strokeWidth:j,opacity:L}=n,{width:E,height:D,enableHover:C,showLabels:P=!0,title:O,description:_,summary:N,accessibleTable:I}=r,T=Mr({nodes:t.useMemo(()=>pr(null!=o?o:null,s),[o,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:A,selection:k,linkedHover:w,onObservation:m,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:r.marginDefaults,userMargin:i,width:E,height:D,loading:S}),W=t.useMemo(()=>new Map,[]),B=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?qe[(e.depth||0)%qe.length]:u?Ke(e.data||e,u,T.colorScale):dr(0,T.themeCategorical,d),t},[u,h,T.colorScale,g,T.themeCategorical,d,W]),R=t.useMemo(()=>jr(B,{stroke:M,strokeWidth:j,opacity:L}),[B,M,j,L]),$=t.useMemo(()=>mr(l),[l]),z=Dr({componentName:"CirclePack",data:o});return z?e.jsx(xr,{componentName:"CirclePack",message:z,width:E,height:D}):T.loadingEl?T.loadingEl:e.jsx(wr,{componentName:"CirclePack",width:E,height:D,children:e.jsx(Xn,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[E,D],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:T.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:$,padding:y,nodeStyle:R,colorBy:u,colorScheme:T.effectivePalette,colorByDepth:h,nodeLabel:P?f||c:void 0,showLabels:P,enableHover:C,tooltipContent:!1===p?()=>null:wt(p)||void 0,customHoverBehavior:w||m||b?T.customHoverBehavior:void 0,customClickBehavior:m||b?T.customClickBehavior:void 0},A&&"none"!==A&&{legendHoverBehavior:T.legendState.onLegendHover,legendClickBehavior:T.legendState.onLegendClick,legendHighlightedCategory:T.legendState.highlightedCategory,legendIsolatedCategories:T.legendState.isolatedCategories},{className:a,title:O,description:_,summary:N,accessibleTable:I},null!=n.animate&&{animate:n.animate},v))})}_r.displayName="ChordDiagram",Nr.displayName="TreeDiagram",Ir.displayName="Treemap",Tr.displayName="CirclePack";const Wr=qe;function Br(n){const r=gr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:f=2.95,speed:g=.25,revolution:y,revolutionStyle:p,eccentricity:v=1,showRings:m=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:S,annotations:A,frameProps:M={},onObservation:j,onClick:L,chartId:E,selection:D,linkedHover:C,loading:P,stroke:O,strokeWidth:_,opacity:N}=n,{width:I,height:T,enableHover:W,title:B,description:R,summary:$,accessibleTable:z}=r,H=Mr({nodes:t.useMemo(()=>pr(o,s),[o,s]),edges:void 0,inferNodes:!1,colorBy:d?void 0:c,colorScheme:u,showLegend:!1,legendInteraction:void 0,selection:D,linkedHover:C,onObservation:j,onClick:L,chartType:"OrbitDiagram",chartId:E,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:i,width:I,height:T,loading:P}),F=t.useMemo(()=>new Map,[]),Y=t.useMemo(()=>{if(Array.isArray(u))return u;const e=Ye[u];return Array.isArray(e)?e:Xe},[u]),X=t.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},r=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=d?r?Y[0]:Wr[(e.depth||0)%Wr.length]:c?Ke(e.data||e,c,H.colorScale):dr(0,H.themeCategorical,u),n.opacity=r?1:.85,n},[c,d,H.colorScale,Y,H.themeCategorical,u,F]),G=t.useMemo(()=>jr(X,{stroke:O,strokeWidth:_,opacity:N}),[X,O,_,N]),q=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),V=t.useMemo(()=>{if(H.customHoverBehavior)return e=>{H.customHoverBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[H.customHoverBehavior]),K=t.useMemo(()=>{if(H.customClickBehavior)return e=>{H.customClickBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[H.customClickBehavior]),Z=Dr({componentName:"OrbitDiagram",data:o});return Z?e.jsx(xr,{componentName:"OrbitDiagram",message:Z,width:I,height:T}):H.loadingEl?H.loadingEl:e.jsx(wr,{componentName:"OrbitDiagram",width:I,height:T,children:e.jsx(Xn,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[I,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:H.margin,nodeIDAccessor:l,childrenAccessor:s,nodeStyle:G,edgeStyle:q,colorBy:c,colorScheme:H.effectivePalette,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&W,tooltipContent:k?void 0:!1===w?()=>null:wt(w)||void 0,customHoverBehavior:C||j||L?V:void 0,customClickBehavior:j||L?K:void 0,foregroundGraphics:S,annotations:A,className:a,title:B,description:R,summary:$,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k,accessibleTable:z},null!=n.animate&&{animate:n.animate},M))})}function Rr(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 $r(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 zr(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},s=()=>{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)})},l=i.length?Math.min(...i.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};s();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!==u&&(g.push({time:u,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),s();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 j=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;if(A.length>0){const e=A[A.length-1];null!=j&&j>e.t&&e.topMass+e.botMass>0&&A.push({t:j,topMass:e.topMass,botMass:e.botMass});const t=A[0];null!=c&&t.t>c&&t.topMass+t.botMass>0&&A.unshift({t:c,topMass:t.topMass,botMass:t.botMass})}return{samples:A,peak:b,topPeak:x,botPeak:k,localAttachments:S}}function Hr(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Fr(e,t){return e.map(e=>({t:Hr(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Yr(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 Xr(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 Gr(e,t){return 1e3*Yr(e,t)+Xr(e,t)}function qr(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function Vr(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=qr(e,t),a=Gr(t,n);for(let s=0;r>s;s++){const r=Array(o).fill(0),s=Array(o).fill(0);for(const e of n){const n=t[e.source],o=t[e.target];r[n]+=o*(e.value||1),s[n]+=e.value||1,r[o]+=n*(e.value||1),s[o]+=e.value||1}const l=Array.from({length:o},(e,t)=>t).sort((e,t)=>(s[e]>0?r[e]/s[e]:e)-(s[t]>0?r[t]/s[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=Gr(t,n);if(a>d)a=d,i=qr(e,t);else if(d===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=Gr(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 s=Gr(t,n);if(i>s)i=s,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),s=a.slice(),l=Object.assign({},o);let c=a.slice(),u=1/0;const d=()=>{for(const e of i)l[e]=s[o[e]];const e=Gr(l,n);u>e&&(u=e,c=a.slice())},h=(e,t)=>{const n=a[e],r=a[t];a[e]=r,a[t]=n,s[n]=t,s[r]=e};d();const f=Array(r).fill(0);let g=0;for(;r>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),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 Kr(e,t,n,r,o){var i,a,s,l,c,u,d,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);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)}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 d=[];for(const t of e)0===(null!==(a=o.get(t.id))&&void 0!==a?a:0)&&d.push(t.id);for(;d.length;){const e=d.shift();for(const t of null!==(s=r.outgoing[e])&&void 0!==s?s:[]){const r=(null!==(l=n.get(e))&&void 0!==l?l: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)&&d.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!==(u=null==t?void 0:t.end)&&void 0!==u?u:-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,j=null,L=null,E=null;const D=()=>{M=Yr(S,t),L=Xr(S,t)},C=()=>{j=Yr(S,t),E=Xr(S,t)};"crossing-min"===v?(D(),Vr(A,S,t),C()):"inside-out"===v?(D(),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 s=a-1,l=a+1;for(let e=1;o.length>e;e++)e%2==1&&n>l||0>s?i[l++]=o[e].idx:i[s--]=o[e].idx;const c=i.map(t=>e[t]),u=new Map;i.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(A,S),C()):"crossing-min+inside-out"===v&&(D(),Vr(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=Gr(t,n);for(const{slot:s}of o){const o=e.indexOf(s);if(0>o)continue;const l=i;if(o===l)continue;const c=e[o];e.splice(o,1),e.splice(l,0,c);const u=new Map;for(let e=0;r>e;e++)u.set(e,e);if(l>o){for(let e=o+1;l>=e;e++)u.set(e,e-1);u.set(o,l)}else{for(let e=l;o>e;e++)u.set(e,e+1);u.set(o,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=Gr(t,n);if(d>a){const n=e[l];e.splice(l,1),e.splice(o,0,n);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(o>l){for(let e=l+1;o>=e;e++)i.set(e,e-1);i.set(l,o)}else{for(let e=o;l>e;e++)i.set(e,e+1);i.set(l,o)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=d}}(A,S,t),C());const P=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])}),O=(e,t)=>{let n={top:0,bot:0};for(const[r,o]of e){if(r>t)break;n=o}return n},_=[];for(let e=0;A.length-1>e;e++){const t=P[e],n=P[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=O(t,e),i=O(n,e);r.bot+i.top>o&&(o=r.bot+i.top)}_.push(o)}const N=[];let I=g+(null!==(h=null===(d=A[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*y;A.length>0&&N.push(I);for(let e=1;A.length>e;e++)I+=_[e-1]*y+g,N.push(I);if(A.length>0&&(I+=A[A.length-1].peak.botPeak*y+g),I>f){const e=f/I;for(let t=0;N.length>t;t++)N[t]*=e}const T=0===A.length?0:A[0].peak.topPeak+_.reduce((e,t)=>e+t,0)+A[A.length-1].peak.botPeak,W={};for(const t of e)W[t.id]=N[S[t.id]];return{effectiveSlotsHeight:T,centerlines:W,laneLifetime:w,slots:A,slotByNode:S,slotCenter:N,crossingsBefore:M,crossingsAfter:j,lengthBefore:L,lengthAfter:E}}Br.displayName="OrbitDiagram";const Zr=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)a.push({type:"bezier",pathD:e.pathD,style:{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 s=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:s}};function Ur(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function Qr(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Jr(e,t){return"function"==typeof e?e(t):t[e]}const eo=t.forwardRef(function(n,r){const{nodes:o,edges:a,domain:s,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",startTimeAccessor:f="startTime",endTimeAccessor:g="endTime",xExtentAccessor:y="xExtent",edgeIdAccessor:p="id",colorBy:v,colorScheme:m,showLegend:b,legendPosition:x="right",pairing:k="temporal",packing:w="reuse",laneOrder:S="crossing-min",ribbonLane:A="both",lifetimeMode:M="half",showLaneRails:j=!1,showQualityReadout:L=!1,width:E=600,height:D=400,margin:C,title:P,description:O,summary:_,accessibleTable:N,responsiveWidth:I,responsiveHeight:T,loading:W,emptyContent:B,edgeOpacity:R=.35,timeFormat:$,valueFormat:z,tooltip:H,enableHover:F=!0,onObservation:Y,onClick:X,showParticles:G=!1,particleStyle:q,chartId:V,frameProps:K={}}=n,[Z,U]=t.useState([]),[Q,J]=t.useState([]),ee=t.useRef(Z),te=t.useRef(Q);ee.current=Z,te.current=Q;const ne=t.useCallback(e=>{ee.current=e,U(e)},[]),re=t.useCallback(e=>{te.current=e,J(e)},[]),oe=void 0!==a,ie=Cn(oe?a:Z),ae=t.useMemo(()=>{const e=Cn(null!=o?o:[]),t=Q;if(0===e.length&&0===t.length)return vr([],ie,u,d);const n=new Set,r=[];for(const t of e){const e=Jr(c,t)+"";n.has(e)||(n.add(e),r.push(t))}for(const e of t){const t=Jr(c,e)+"";n.has(t)||(n.add(t),r.push(e))}const i=vr([],ie,u,d);for(const e of i)n.has(e.id)||(n.add(e.id),r.push(e));return r},[o,Q,ie,c,u,d]),se=t.useRef(null),le=t.useCallback((e,t)=>{const n=Jr(p,e);return null!=n?n+"":`${Jr(u,e)}-${Jr(d,e)}-${t}`},[p,u,d]),ce=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=Jr(u,t)&&null!=Jr(d,t)},[u,d]);Gn(r,{variant:"network",frameRef:se,overrides:{push(e){if(ce(e)){if(oe)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ne([...ee.current,e])}else re([...te.current,e])},pushMany(e){const t=[],n=[];for(const r of e)ce(r)?t.push(r):n.push(r);t.length>0&&(oe?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ne([...ee.current,...t])),n.length>0&&re([...te.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!oe){const e=ee.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(le(i,o))?n.push(i):r.push(i)}r.length!==e.length&&ne(r)}const r=te.current,o=[];for(const e of r){const r=Jr(c,e)+"";t.has(r)?n.push(e):o.push(e)}return o.length!==r.length&&re(o),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!oe){let e=!1;const o=ee.current.map((o,i)=>n.has(le(o,i))?(r.push(o),e=!0,t(o)):o);e&&ne(o)}let o=!1;const i=te.current.map(e=>{const i=Jr(c,e)+"";return n.has(i)?(r.push(e),o=!0,t(e)):e});return o&&re(i),r},clear(){var e;oe||ne([]),re([]),null===(e=se.current)||void 0===e||e.clear()},getData:()=>null!=ie?ie:[],getScales:()=>null},deps:[oe,ce,le,c,ie,ne,re]});const ue=le,de=t.useCallback(e=>Jr(c,e)+"",[c]),{nodes:he,edges:ge,domain:ye,rawNodeById:pe,rawEdgeById:ve}=t.useMemo(()=>{const e=(null!=ae?ae:[]).map(e=>{const t={id:de(e),__raw:e},n=y?Jr(y,e):null;if(Array.isArray(n)&&2===n.length){const e=Qr(n[0]),r=Qr(n[1]);Number.isFinite(e)&&Number.isFinite(r)&&(t.xExtent=[e,r])}return t}),t=(null!=ie?ie:[]).map((e,t)=>({id:ue(e,t),source:Jr(u,e)+"",target:Jr(d,e)+"",value:Number(Jr(h,e)),startTime:Qr(Jr(f,e)),endTime:Qr(Jr(g,e)),__raw:e})),n=[Qr(s[0]),Qr(s[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}},[ae,ie,s,de,ue,y,u,d,h,f,g]),me=Mr({nodes:ae,edges:ie,inferNodes:!1,sourceAccessor:u,targetAccessor:d,colorBy:v,colorScheme:m,showLegend:!1,legendPosition:x,selection:void 0,linkedHover:void 0,onObservation:Y,onClick:X,chartType:"ProcessSankey",chartId:V,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:C,width:E,height:D,loading:W,emptyContent:B}),be=(null!=b?b:!!v)&&!!v,xe=t.useMemo(()=>{const e=Object.assign({},me.margin);return be&&("right"===x&&140>e.right?e.right=140:"bottom"===x&&80>e.bottom&&(e.bottom=80)),e},[me.margin,be,x]),ke=E-xe.left-xe.right,we=D-xe.top-xe.bottom,Se=t.useMemo(()=>Rr(he,ge,ye),[he,ge,ye]),Ae=t.useMemo(()=>Se.length>0?null:function(e,t,n){var r;const{plotH:o,pairing:i="temporal",packing:a="reuse",laneOrder:s="crossing-min",lifetimeMode:l="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),u=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 s=(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)s(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)s(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=s(r,"source"),n=s(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 d={};for(const t of e)d[t.id]=zr(t,c,u);const h=Kr(e,t,d,c,{plotH:o,padding:12,valueScale:1,packing:a,laneOrder:s,lifetimeMode:l}),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=u.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=>u.get(e.id).sourceSide)),o=new Set(n.map(e=>u.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]&&(u.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]&&(u.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"===u.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===u.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 s=Math.min(i,a),l=n.filter(t=>!f.has(t.id)&&u.get(t.id).sourceSide===e&&s>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(o("top","bot")||o("bot","top")););}d={};for(const t of e)d[t.id]=zr(t,c,u);const g=Kr(e,t,d,c,{plotH:o,padding:12,valueScale:1,packing:a,laneOrder:s,lifetimeMode:l}),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=Kr(e,t,d,c,{plotH:o,padding:p,valueScale:v,packing:a,laneOrder:s,lifetimeMode:l});return{nodeData:d,sides:u,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}}(he,ge,{plotH:we,pairing:k,packing:w,laneOrder:S,lifetimeMode:M}),[Se,he,ge,we,k,w,S,M]),Me=t.useMemo(()=>i.scaleTime().domain(ye).range([0,ke]),[ye,ke]),je=t.useCallback((e,t)=>{if(v&&ae){const t=pe.get(e);if(t)return Ke(t,v,me.colorScale)}return me.effectivePalette[t%me.effectivePalette.length]||"#475569"},[v,ae,pe,me.colorScale,me.effectivePalette]),Le=t.useMemo(()=>{const e=new Map;return he.forEach((t,n)=>e.set(t.id,n)),e},[he]),Ee=t.useMemo(()=>{if(!Ae)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Ae,r=[],o=[];return he.forEach((o,i)=>{var a;const s=t[o.id];if(!s||0===s.samples.length)return;const l=function(e,t,n,r,o){if(0===e.length)return null;const i=Fr(e,o),a=e=>t-i[e].topMass*n,s=e=>t+i[e].botMass*n;let l=`M${r(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)l+=` L${r(i[e].t)},${a(e)}`;l+=` L${r(i[i.length-1].t)},${s(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${r(i[e].t)},${s(e)}`;return l+" Z"}(s.samples,e[o.id],n,Me,ye);if(!l)return;const c=Fr(s.samples,ye),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=e[o.id]+(u.botMass-u.topMass)*n/2,h=je(o.id,i),f=null!==(a=pe.get(o.id))&&void 0!==a?a:o;r.push({id:o.id,pathD:l,fill:h,stroke:h,strokeWidth:.5,rawDatum:f,labelX:Me(u.t)-4,labelY:d,labelText:o.id})}),ge.forEach(r=>{var i,a,s,l;const c=null===(i=t[r.source])||void 0===i?void 0:i.localAttachments.get(r.id),u=null===(a=t[r.target])||void 0===a?void 0:a.localAttachments.get(r.id);if(!c||!u)return;const d=null!==(s=Le.get(r.source))&&void 0!==s?s:0,h=je(r.source,d),f=function(e,t,n,r,o,i,a,s){const l=o,c=e=>s?Math.max(s[0],Math.min(s[1],e)):e,u=i(c(e.time)),d=i(c(n.time)),h=e.value*l,f=n.value*l,g=e.sideMassBefore*l,y=n.sideMassAfter*l;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?u+.85*(d-u):"target"===a?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:v,tx:d,tTop:m,tBot:b,cp1X:x,cp2X:x}}(c,e[r.source],u,e[r.target],n,Me,A,ye),{pathD:g,bezier:y}=fe(f),p=null!==(l=ve.get(r.id))&&void 0!==l?l:r;o.push({id:r.id,pathD:g,fill:h,opacity:R,rawDatum:p,bezier:y})}),{bands:r,ribbons:o}},[Ae,he,ge,Me,ye,je,pe,ve,A,R,Le]),De=t.useMemo(()=>({bands:Ee.bands,ribbons:Ee.ribbons,showLabels:!0}),[Ee]),Ce=t.useMemo(()=>{if(!be||!v)return;const e=new Map;(null!=ae?ae:[]).forEach((t,n)=>{const r=Jr(v,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:je(de(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},[be,v,ae,je,de]),Pe=t.useMemo(()=>!1!==H&&F?void 0===H||!0===H?null:wt(H)||null:null,[H,F]),Oe=t.useCallback(e=>$?$(new Date(e)):new Date(e).toISOString().slice(0,10),[$]),_e=t.useCallback(e=>z?z(e):e+"",[z]),Ne=t.useCallback(t=>{if(!t||!t.data)return null;const n=t.data;if(!Ur(n))return null;const r=n.data;if(Pe)return Pe(r);if("band"===n.__kind){const t=n.id,r=Ae?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}(Ae.nodeData[t]):[],o=5,i=r.length>o?r.length:null,a=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,o);return e.jsxs("div",{style:{minWidth:160},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:t}),a.length>0&&e.jsxs("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{opacity:.6},children:[e.jsx("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),e.jsx("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:{paddingRight:8},children:Oe(t.t)}),e.jsx("td",{style:{textAlign:"right"},children:_e(t.total)}),null!=i&&e.jsx("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:t.mark})]},n))})]}),null!=i&&e.jsxs("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",a.length," of ",i," samples"]})]})}const o=r,i=Jr(u,o),a=Jr(d,o),s=Jr(h,o),l=Jr(f,o),c=Jr(g,o);return e.jsxs("div",{style:{minWidth:160},children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",a+""]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"value"}),e.jsx("span",{style:{textAlign:"right"},children:_e(Number(s))})]}),null!=l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"start"}),e.jsx("span",{style:{textAlign:"right"},children:Oe(Qr(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:Oe(Qr(c))})]})]})]})},[Ae,Pe,Oe,_e,u,d,h,f,g]),Ie=t.useMemo(()=>{if(!Ae)return null;const{centerlines:t,laneLifetime:n,nodeData:r,valueScale:o,compressedPadding:i,crossingsBefore:a,crossingsAfter:s,lengthBefore:c,lengthAfter:u}=Ae;return e.jsxs("g",{children:[L&&null!==(null!=s?s:null)&&e.jsxs("text",{x:ke,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",a," → ",s," ","edge length: ",Math.round(c)," → ",Math.round(u)]}),i&&e.jsx("text",{x:ke,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((t,n)=>{const r=Me(Qr(t.date));return e.jsx("line",{x1:r,y1:0,x2:r,y2:we,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+n)}),j&&he.map((i,a)=>{const s=n[i.id];if(!s||null===s.start)return null;const l=r[i.id],c=l?{topPeak:l.topPeak,botPeak:l.botPeak}:{topPeak:0,botPeak:0},u=t[i.id]+(c.botPeak-c.topPeak)*o/2,d=Me(s.start),h=Me(s.end),f=je(i.id,a);return e.jsxs("g",{children:[e.jsx("line",{x1:d,y1:u,x2:h,y2:u,stroke:f,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e.jsx("line",{x1:d,y1:u-4,x2:d,y2:u+4,stroke:f,strokeOpacity:.5}),e.jsx("line",{x1:h,y1:u-4,x2:h,y2:u+4,stroke:f,strokeOpacity:.5})]},"lane-"+i.id)}),e.jsx("line",{x1:0,y1:we+4,x2:ke,y2:we+4,stroke:"#94a3b8"}),l.map((t,n)=>{const r=Qr(t.date),o=Me(r),i=null!=t.label?t.label:$?$(new Date(r)):"";return e.jsxs("g",{transform:`translate(${o},${we+4})`,children:[e.jsx("line",{y2:6,stroke:"#94a3b8"}),e.jsx("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:i})]},n)})]})},[Ae,l,Me,ke,we,j,he,je,L,$]),Te=t.useMemo(()=>(null!=ae?ae:[]).map(e=>({id:de(e),data:e})),[ae,de]),We=t.useMemo(()=>{const e=new Map;for(const t of Ee.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Ee]),Be=t.useMemo(()=>(null!=ie?ie:[]).map((e,t)=>{const n=ue(e,t),r=Number(Jr(h,e));return{id:n,source:Jr(u,e)+"",target:Jr(d,e)+"",value:Number.isFinite(r)?r:0,bezier:We.get(n),data:e}}),[ie,ue,u,d,h,We]),Re=me.loadingEl,$e=me.emptyEl;return Se.length>0?e.jsxs("svg",{width:E,height:D,role:"img","aria-label":null!=P?P:"Process Sankey validation failed",children:[e.jsx("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Se.map((t,n)=>e.jsx("text",{x:20,y:56+18*n,fontSize:12,fill:"#64748b",children:"• "+$r(t)},n))]}):Re||$e||e.jsx(Xn,Object.assign({ref:se,chartType:"force",nodes:Te,edges:Be,customNetworkLayout:Zr,layoutConfig:De,size:[E,D],responsiveWidth:I,responsiveHeight:T,margin:xe,title:P,description:null!=O?O:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:_,accessibleTable:N,enableHover:F,tooltipContent:!1===H?()=>null:Ne,backgroundGraphics:Ie,showParticles:G,particleStyle:q,legend:Ce,legendPosition:x,onObservation:Y,customClickBehavior:X?e=>{if(!e||!e.data)return;const t=e.data;Ur(t)&&X(t.data,{x:e.x,y:e.y})}:void 0,chartId:V,colorScheme:Array.isArray(m)?m:void 0},K))});eo.displayName="ProcessSankey";const to=t.forwardRef(function(n,r){const{nodes:o,edges:i,layout:a,layoutConfig:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",margin:d,className:h,colorScheme:f,frameProps:g={}}=n,{frameRef:y,resolved:p,normalizedMargin:v}=function(e){const n=t.useRef(null);return Gn(e.imperativeRef,{variant:e.imperativeVariant,frameRef:n}),{frameRef:n,resolved:gr(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:t.useMemo(()=>function(e){if(null!=e)return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:e}(e.margin),[e.margin])}}({imperativeRef:r,imperativeVariant:"network",margin:d,width:n.width,height:n.height,enableHover:n.enableHover,title:n.title,mode:n.mode}),m=t.useMemo(()=>Cn(null!=o?o:[]),[o]),b=t.useMemo(()=>Cn(null!=i?i:[]),[i]),{width:x,height:k,enableHover:w,title:S,description:A,summary:M,accessibleTable:j}=p,L=Object.assign(Object.assign(Object.assign(Object.assign({chartType:"force"},null!=o&&{nodes:m}),null!=i&&{edges:b}),{customNetworkLayout:a,layoutConfig:s,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,colorScheme:f,size:[x,k],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:v,className:h,title:S,description:A,summary:M,accessibleTable:j,enableHover:w}),g);return e.jsx(wr,{componentName:"NetworkCustomChart",width:x,height:k,children:e.jsx(Xn,Object.assign({ref:y},L))})});to.displayName="NetworkCustomChart",exports.ChordDiagram=_r,exports.CirclePack=Tr,exports.ForceDirectedGraph=Pr,exports.NetworkCustomChart=to,exports.OrbitDiagram=Br,exports.ProcessSankey=eo,exports.SankeyDiagram=Or,exports.StreamNetworkFrame=Xn,exports.TreeDiagram=Nr,exports.Treemap=Ir,exports.formatProcessSankeyIssue=$r,exports.validateProcessSankey=Rr;
|