semiotic 3.7.4 → 3.7.5
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 +10 -7
- package/README.md +36 -19
- package/ai/schema.json +221 -1
- package/ai/system-prompt.md +2 -1
- package/dist/components/Annotation.d.ts +4 -0
- package/dist/components/DataSummaryContext.d.ts +1 -0
- package/dist/components/ai/chartCapabilityTypes.d.ts +16 -0
- package/dist/components/ai/dataPitfallsBridge.d.ts +101 -0
- package/dist/components/ai/dataQualityBridge.d.ts +201 -0
- package/dist/components/ai/describeChart.d.ts +2 -0
- package/dist/components/ai/generativeChart.d.ts +145 -0
- package/dist/components/charts/custom/NetworkCustomChart.d.ts +14 -1
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +7 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +21 -0
- package/dist/components/charts/realtime/aggregate.d.ts +51 -0
- package/dist/components/charts/realtime/eventTime.d.ts +26 -0
- package/dist/components/charts/shared/colorPalettes.d.ts +2 -0
- package/dist/components/charts/shared/colorUtils.d.ts +1 -12
- package/dist/components/charts/shared/minMax.d.ts +3 -0
- package/dist/components/charts/shared/radialGeometry.d.ts +0 -18
- package/dist/components/charts/shared/smartTooltip.d.ts +27 -0
- package/dist/components/charts/shared/statisticalOverlays.d.ts +35 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +2 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/validateChartData.d.ts +1 -1
- package/dist/components/charts/xy/Scatterplot.d.ts +9 -0
- package/dist/components/data/fromArrow.d.ts +54 -0
- package/dist/components/data/fromMermaid.d.ts +47 -0
- package/dist/components/data/fromObservablePlot.d.ts +69 -0
- package/dist/components/data/portability/index.d.ts +14 -0
- package/dist/components/data/portability/spec.d.ts +129 -0
- package/dist/components/data/portability/vegaLite.d.ts +62 -0
- package/dist/components/realtime/ReorderBuffer.d.ts +54 -0
- package/dist/components/realtime/RunningStats.d.ts +66 -0
- package/dist/components/realtime/WindowAccumulator.d.ts +105 -0
- package/dist/components/realtime/parseWindowDuration.d.ts +12 -0
- package/dist/components/recipes/customTooltip.d.ts +31 -0
- package/dist/components/recipes/gofish.d.ts +207 -0
- package/dist/components/recipes/gofishBoba.d.ts +23 -0
- package/dist/components/recipes/gofishIR.d.ts +169 -0
- package/dist/components/recipes/gofishIRExamples.d.ts +89 -0
- package/dist/components/recipes/gofishInterpreter.d.ts +52 -0
- package/dist/components/recipes/gofishLambdas.d.ts +145 -0
- package/dist/components/recipes/mermaidDag.d.ts +44 -0
- package/dist/components/recipes/packedClusterMatrix.d.ts +166 -0
- package/dist/components/recipes/recipeChrome.d.ts +100 -0
- package/dist/components/recipes/recipeLegend.d.ts +57 -0
- package/dist/components/recipes/recipeUtils.d.ts +105 -0
- package/dist/components/semiotic-ai.d.ts +6 -0
- package/dist/components/semiotic-data.d.ts +2 -0
- package/dist/components/semiotic-experimental.d.ts +20 -0
- package/dist/components/semiotic-network.d.ts +3 -1
- package/dist/components/semiotic-ordinal.d.ts +2 -0
- package/dist/components/semiotic-realtime.d.ts +9 -1
- package/dist/components/semiotic-recipes.d.ts +18 -1
- package/dist/components/semiotic-themes.d.ts +2 -0
- package/dist/components/semiotic-xy.d.ts +2 -0
- package/dist/components/semiotic.d.ts +4 -0
- package/dist/components/store/ObservationStore.d.ts +21 -2
- package/dist/components/store/SelectionStore.d.ts +1 -1
- package/dist/components/store/ThemeStore.d.ts +1 -1
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/createStore.d.ts +1 -1
- package/dist/components/store/designTokens.d.ts +15 -0
- package/dist/components/stream/NetworkHtmlMarksLayer.d.ts +44 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +32 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +12 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +18 -0
- package/dist/components/stream/PipelineStore.d.ts +27 -0
- package/dist/components/stream/SceneGraph.d.ts +5 -1
- package/dist/components/stream/customLayout.d.ts +20 -0
- package/dist/components/stream/customLayoutDiagnostics.d.ts +11 -0
- package/dist/components/stream/customLayoutSelection.d.ts +52 -0
- package/dist/components/stream/networkCustomLayout.d.ts +66 -1
- package/dist/components/stream/networkTypes.d.ts +29 -1
- package/dist/components/stream/ordinalCustomLayout.d.ts +17 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
- package/dist/components/stream/ordinalTypes.d.ts +19 -3
- package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +2 -0
- package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +2 -0
- package/dist/components/stream/stalenessBands.d.ts +28 -0
- package/dist/components/stream/symbolPath.d.ts +24 -0
- package/dist/components/stream/types.d.ts +72 -3
- package/dist/components/stream/useStalenessCheck.d.ts +6 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/xySceneBuilders/types.d.ts +5 -0
- 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-semiotic-ai-u954ylUn.js +2 -0
- package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +1 -0
- package/dist/semiotic-ai.d.ts +6 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental.d.ts +20 -0
- package/dist/semiotic-experimental.min.js +1 -0
- package/dist/semiotic-experimental.module.min.js +1 -0
- package/dist/semiotic-network.d.ts +3 -1
- package/dist/semiotic-ordinal.d.ts +2 -0
- package/dist/semiotic-realtime.d.ts +9 -1
- package/dist/semiotic-recipes.d.ts +18 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-semiotic-BmrYbi99.js +2 -0
- package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -0
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +2 -0
- package/dist/semiotic.d.ts +4 -0
- 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-semiotic-xy-Dufu3D0-.js +2 -0
- package/dist/xy-statisticalOverlays-3Ni9bRph.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +11 -3
- package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +0 -1
- package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +0 -1
- package/dist/xy-statisticalOverlays-C2PPlmXv.js +0 -1
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"),n=require("d3-interpolate"),o=require("d3-array"),r=require("d3-force"),i=require("d3-scale"),a=require("d3-chord"),s=require("d3-shape"),l=require("d3-hierarchy"),c=require("d3-quadtree");function d(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const u=d(t);function h(e){return Array.isArray(e)?e[0]:e}function f(e,t,n,o){return Object.assign({data:h(e),x:t,y:n,__semioticHoverData:!0},o)}const g={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},y={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function p(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function m(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function v(e){const t=e.map(p),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return m(e,n,o)}if(e>=1){const[e,o,r]=t[n];return m(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[a,s,l]=t[r],[c,d,u]=t[r+1];return m(Math.round(a+(c-a)*i),Math.round(s+(d-s)*i),Math.round(l+(u-l)*i))}}const b=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],x=v(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),k=v(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),w=v(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),S=v(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),M=v(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]);v(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]);const A=v(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),j=v(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]);v(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),v(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),v(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),v(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),v(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),v(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),v(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),v(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),v(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),v(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),v(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);class L{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1,this._freeIndices.push(i);continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;a.t+=e*t*l*(s.bezier.circular?.3:1),1>a.t?C(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 C(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,d,u,h]=e[s];E(c,d,u,h,l,r);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;r.x+=-g/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,i,a,s]=e.points;E(r,i,a,s,t,o);const l=s.x-r.x,c=s.y-r.y,d=Math.sqrt(l*l+c*c);if(d>.001){const t=l/d;o.x+=-c/d*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function E(e,t,n,o,r,i){const a=1-r,s=a*a,l=s*a,c=r*r,d=c*r;i.x=l*e.x+3*s*r*t.x+3*a*c*n.x+d*o.x,i.y=l*e.y+3*s*r*t.y+3*a*c*n.y+d*o.y}function D(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function O(e,t){var n,o=[],r=[],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,o,u=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(d(n,r),u=!0):i[o]||(u=c(o));if(u)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),u}function d(e,t){var n=[].concat(t).concat(e);o.push(n)}function u(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,d=0,u=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=o[t]=d,r[t]=!0,d+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=o[y]=d,r[y]=!0,d+=1,l.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||s[t].push(a[y])}i[t]=g}else{if(o[t]===n[t]){var p=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(r[b]=!1,p.push(b),m.push(s[b]),v+=s[b].length,a[b]=u.length,b===t){l.length=g;break}}u.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}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:u,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[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=u(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 o}function N(e){return e.y0-e.y1>0?"up":"down"}function P(e,t){return t(e.source)==t(e.target)}function _(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 T(e){return e.target.x0-e.source.x1}function I(e,t){var n=W(e),o=T(t)/Math.tan(n);return"up"==N(e)?e.y1-o:e.y1+o}function R(e,t){var n=W(e),o=T(t)/Math.tan(n);return"up"==N(e)?e.y1+o:e.y1-o}function W(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function B(e,t){return t(e)}function $(e){return H(e.source)}function z(e){return H(e.target)}function H(e){return(e.y0+e.y1)/2}function F(e){return e.virtual?0:e.value}function Y(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!P(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!P(e,t)?o+1:o}),n+o}function X(e){return e.target.depth}function G(e,t){return e.sourceLinks.length?e.depth:t-1}function q(e,t){return e.y0-t.y0}function V(e,t){return t.y0-e.y0}function K(e,t){return e.y1-t.y1}function Q(e,t){return t.y1-e.y1}function Z(e,t){return J(e.source,t.source)||e.index-t.index}function U(e,t){return J(e.target,t.target)||e.index-t.index}function J(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ee(e,t){return te(e)==te(t)?"bottom"==e.circularLinkType?V(e,t):q(e,t):te(t)-te(e)}function te(e){return e.target.column-e.source.column}function ne(e,t){return oe(e)==oe(t)}function oe(e){return e.y0-e.y1>0?"up":"down"}function re(e,t,n,r,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=o.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}),ie(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),ie(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+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,P(e,t)&&_(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+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 o=e.source.column,s=e.circularLinkType,c=a.links.filter(function(e){return e.source.column==o&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?V:q);var d=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+d,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+d),d+=t._circularWidth||t.width}),o=e.target.column,(c=a.links.filter(function(e){return e.target.column==o&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?Q:K),d=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+d,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+d),d+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(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,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),a}function ie(e,t,n){e.sort(ee);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(P(e,t)&&_(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&ae(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 ae(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function se(e){return function(){return e}}function le(e){return e.index}function ce(e){return e.nodes}function de(e){return e.links}function ue(e,t,n){var r=o.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=H(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=H(e.target)*t,o+=t}}),o>0?r/o:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=s.get(e),o=s.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Y(t,n)-Y(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Y(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function he(e,t,n,r,i,a){var s=o.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var l=1,c=a;c>0;--c)d(l*=.99,n),u();function d(t,n){var r=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&&Y(i,n)>0){var c=o.mean(i.sourceLinks,z),d=o.mean(i.targetLinks,$),u=c&&d?(c+d)/2:c||d;if(u){var h=(u-H(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==r-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=o.mean(i.sourceLinks,z),g=o.mean(i.targetLinks,$),y=((f&&g?(f+g)/2:f||g)-H(i))*t;i.y0+=y,i.y1+=y}})})}function u(){s.forEach(function(n){var o,a,s,l=e.y0,c=n.length;for(n.sort(t||J),s=0;c>s;++s)(a=l-(o=n[s]).y0)>0&&(o.y0+=a,o.y1+=a),l=o.y1+r;if((a=l-r-e.y1)>0)for(l=o.y0-=a,o.y1-=a,s=c-2;s>=0;--s)(a=(o=n[s]).y1+i-l)>0&&(o.y0-=a,o.y1-=a),l=o.y0})}}function fe(e){e.nodes.forEach(function(e){e.sourceLinks.sort(U),e.targetLinks.sort(Z)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function ge(){var e=0,t=0,n=1,r=1,i=24,a=8,s=null,l=le,c=G,d=void 0,u=32,h=2,f=ce,g=de;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=r,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 o.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 o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=D(n,o)),"object"!=typeof r&&(r=e.target=D(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(f,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=O(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var d=l[r].slice(-2);c[d[0]]||(c[d[0]]={}),c[d[0]][d[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,d),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){B(e,t)!=B(r.source,t)&&B(e,t)!=B(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),P(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(o.sum(e.sourceLinks,F),o.sum(e.targetLinks,F)),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 o,r,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(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(f,d,c);var g=a;if(null!==s){var y=o.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=o.max(y,function(e){return e.length});p>1&&(g=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=o.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=o.min(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/o.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=o.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),ue(f,d,l),he(f,d,l,g,g,u),fe(f),re(f,l,h,10,8),ue(f,d,l),he(f,d,l,g,g,u),fe(f),re(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 o=n.links.filter(function(n){return B(n.source,t)==B(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!ne(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=I(t,e);return e.y1-n}if(t.target.column>e.target.column)return I(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(f,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return B(n.target,t)==B(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!ne(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=R(t,e);return e.y0-n}if(t.source.column>e.source.column)return R(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(f,l),function(e){var t=e.nodes,n=e.links,r=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==r||0==i){var a=o.min(t,function(e){return e.y0}),s=o.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),re(f,l,h,10,8)}(y),y}return y.update=function(e){return fe(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:se(e),y):f},y.links=function(e){return arguments.length?(g="function"==typeof e?e:se(e),y):g},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:se(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:se(e),y):c},y.nodeSort=function(e){return arguments.length?(d=e,y):d},y.iterations=function(e){return arguments.length?(u=+e,y):u},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[e,t],[n,r]]},y.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],y):[n-e,r-t]},y}function ye(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(n+o)/2,d=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${l},${i} ${r},${i}`,`L${r},${a}`,`C${l},${a} ${s},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:d},{x:r,y:d}],halfWidth:(o-n)/2}}}const pe=e=>{let t,o,r,i,a,s,l,c,d;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,r=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),d=l(.5),`M${t},${a}C${t},${c} ${o},${d} ${o},${s}L${r},${s}C${r},${d} ${i},${c} ${i},${a}Z`;const u=e.sankeyWidth/2,h=n.interpolateNumber(e.source.x1,e.target.x0),{pathD:f}=ye({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:h(.5),cp2X:h(.5)});return f};function me(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,d=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*f}L${c+o},${u+h*o-h*f}L${c+o-f},${u+h*o}L${d-o+f},${u+h*o}L${d-o},${u+h*o-h*f}L${d-o},${l-h*n+h*f}L${d-o+f},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${d+o},${l+h*n}L${d+o},${u-h*o}L${c-o},${u-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const ve=new Set,be=new WeakMap;function xe(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=be.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,be.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ve.has(e)||(ve.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}const ke={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(X))-1:0},justify:G};function we(e){return"string"==typeof e?e:e.id}const Se={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,d;if(0===e.length)return;const u="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(r=n.nodeWidth)&&void 0!==r?r:15,g=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===u?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=ge().extent(v).links(m).nodes(p).nodeAlign(ke[h]||G).nodeId(e=>e.id).nodeWidth(f).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of p)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.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>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,d=o[0],u=o[1];if(i>0&&a>0&&(0>e||0>n||t>d||r>u)){const t=Math.min(d/i,u/a),o=-e*t+(d-i*t)/2,r=-n*t+(u-a*t)/2;for(const e of p)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=we(e.source),n=we(e.target),o=k.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(d=e.width)&&void 0!==d?d:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=u;const r=x.get(t),i=x.get(n);r&&(o.source=r),i&&(o.target=i)}}},buildScene(e,t,n,o){var r,i,a,s,l,c;const d="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,f=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:b,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const m=[],v=[],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 o=u?u(xe(t,"nodeStyle")):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};k.set(t.id,("string"==typeof r.fill?r.fill:null)||p.get(t.id)||"#4d430c"),m.push("down"===d?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:r,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const 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,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";r="function"==typeof g?g(e)||r:"target"===g?k.get(o.id)||p.get(o.id)||r:k.get(t.id)||p.get(t.id)||r;const d=h?h(xe(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),i=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=d.fill||r;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:a,fillOpacity:null!==(s=d.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:d.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),v.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=d.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:d.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-i,x1:t.targetX}});continue}let u;if(u=e.circular&&e.circularPathData?me(e):pe(e),!u)continue;const y={fill:d.fill||r,fillOpacity:null!==(c=d.fillOpacity)&&void 0!==c?c:f,stroke:d.stroke||"none",strokeWidth:d.strokeWidth,opacity:d.opacity};v.push({type:"bezier",pathD:u,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,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,l;"down"===d?(a=n.y0+(n.y1-n.y0)/2,s=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),s=n.y0+r/2),x.push({x:a,y:s,text:i+"",anchor:"down"===d?"middle":l,baseline:"middle",fontSize:11})}}var S;return{sceneNodes:m,sceneEdges:v,labels:x}}},Me={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var i,a;if(0===e.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,l=o[0]/2,c=o[1]/2,d=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==d?void 0:d.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const f=u>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 o=Ae(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=je(e.id),i=r%360*(Math.PI/180),a=10+r%20;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=je(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=l+o*Math.cos(n),e.y=c+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=l+e*Math.cos(r),o.y=c+e*Math.sin(r)}}}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=Le(n.nodeSize,n.nodeSizeRange,e),m=e=>p(e);if(y>0){const n=r.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),o=r.forceSimulation().force("charge",r.forceManyBody().strength(e=>-25*m(e))).force("center",r.forceCenter(l,c).strength(.8)).force("x",r.forceX(l).strength(.15)).force("y",r.forceY(c).strength(.15));if(o.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));n.links(e),o.force("link",n)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let e=0;y>e;++e)o.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a,s,l,c,d;const u=n.nodeStyle,h=n.edgeStyle,f=Le(n.nodeSize,n.nodeSizeRange,e),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:b,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],m=[],v=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(xe(t,"nodeSize")),o=u?u(xe(t,"nodeStyle")):{},s={fill:o.fill||y.get(t.id)||(null===(r=n.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:2,opacity:o.opacity};p.push({type:"circle",cx:t.x,cy:t.y,r:e,style: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),o="object"==typeof e.target?e.target:x.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=h?h(xe(e,"edgeStyle")):{},i={stroke:r.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=r.strokeWidth)&&void 0!==c?c:1,opacity:null!==(d=r.opacity)&&void 0!==d?d:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:i,datum:e})}if(!1!==n.showLabels){const t=(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 o=f(xe(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Ae(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function je(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 Le(e,t,n){var r,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!==(r=o.min(l))&&void 0!==r?r:0,d=null!==(a=o.max(l))&&void 0!==a?a:1;if(c===d)return()=>(s[0]+s[1])/2;const u=i.scaleLinear().domain([c,d]).range(s).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?s[0]:u(o)}}const Ce=b,Ee={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:l}=n,c=Math.min(o[0],o[1])/2,d=c-i,u=o[0]/2,h=o[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,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=y.get("string"==typeof e.source?e.source:e.source.id),o=y.get(t);if(void 0===n||void 0===o)continue;const r=f(e);m[n][o]=r}const v=a.chord().padAngle(r);l&&v.sortGroups(l);const b=v(m),x=b.groups,k=s.arc().innerRadius(d).outerRadius(c);for(const t of x){const n=e[t.index],o=k.centroid({innerRadius:d,outerRadius:c,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+u,n.y=o[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),o=w.get(t);n&&(e.source=n),o&&(e.target=o)}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,o=e[t.target.index].id,r=S.get(`${n}\0${o}`)||S.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){var r,i,s,l;const{groupWidth:c=20,edgeOpacity:d=.5}=n,u=Math.min(o[0],o[1])/2,h=u-c,f=o[0]/2,g=o[1]/2,y=n.nodeStyle,p=n.edgeStyle,m=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Ce,b=new Map;e.forEach((e,t)=>{b.set(e.id,v[t%v.length])});const x=a.ribbon().radius(h),k=[],w=[],S=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let i;i=y?y(xe(n,"nodeStyle")).fill||b.get(n.id)||v[t%v.length]:b.get(n.id)||v[t%v.length];const a=y?y(xe(n,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:u,startAngle:o.startAngle-Math.PI/2,endAngle:o.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 o=x(t);if(!o)continue;const r=De(o,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(xe(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===m&&n?a=b.get(n.id)||a:t&&(a=b.get(t.id)||a)}const c=p?p(xe(e,"edgeStyle")):{},u={fill:a,fillOpacity:null!==(l=c.fillOpacity)&&void 0!==l?l:d,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity};w.push({type:"ribbon",pathD:r,style:u,datum:e})}if(!1!==n.showLabels){const t=(M=n.nodeLabel)?"function"==typeof M?M:e=>e[M]||e.id:null,o=u+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;S.push({x:f+Math.cos(a)*o,y:g+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var M;return{sceneNodes:k,sceneEdges:w,labels:S}}};function De(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const Oe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ne(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function Pe(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function _e(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 Te(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Oe}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 Re(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}const We={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;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,d="function"==typeof c?c:"string"==typeof c?e=>Number(e[c])||0:e=>Number(e.value)||0,u=l.hierarchy(i,s);u.sum(d),u.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[h,f]=o;switch(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=l.tree();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,h,f);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=l.cluster();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,h,f);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=l.treemap().size([n,o]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(e)}(u,n,h,f);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;l.pack().size([n,o]).padding(i)(e)}(u,n,h,f);break;case"partition":!function(e,t,n,o){var r;l.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(u,n,h,f)}const g=u.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;g.length>t;t++){const o=g[t],i={id:Pe(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===a||"cluster"===a?Be(i,o,n):"treemap"===a||"partition"===a?$e(i,o):"circlepack"===a&&ze(i,o),i.__hierarchyNode=o,e.push(i),y.set(o,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const n=y.get(e.parent),o=y.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,d,u,h,f;const g=[],y=[],p=[],m=n.treeOrientation||"vertical",v="radial"===m,b=o[0]/2,x=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const t of e){let e=t.x,o=t.y;v&&(e+=b,o+=x);const i=r(xe(t,"nodeStyle"));let l=i.fill||Ie(n);if(n.colorByDepth&&void 0!==t.depth){const e=Te(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:o,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,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,a=t.y,s=o.x,l=o.y;v&&(r+=b,a+=x,s+=b,l+=x);const f=Re(r,a,s,l,m),g=i(xe(e,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(d=n.themeSemantic)||void 0===d?void 0:d.secondary)||"#999",strokeWidth:null!==(u=g.strokeWidth)&&void 0!==u?u:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:S};y.push({type:"curved",pathD:f,style:p,datum:e})}if(!1!==n.showLabels){const t=_e(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(v&&(a+=b,s+=x),v){const e=a-b,t=s-x,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=a-k-6,i="end"):(o=a+k+6,i="start"),r=s):(o=a,r=s+k+14,i="middle");p.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i,a,s,l;const c=[],d=[];for(const n of e){const e=n.x1-n.x0,a=n.y1-n.y0;if(0>=e||0>=a)continue;const s=o(xe(n,"nodeStyle"));let l=s.fill||Ie(t);if(t.colorByDepth&&void 0!==n.depth){const e=Te(t);l=e[n.depth%e.length]}const d={fill:l,stroke:s.stroke||(null===(r=t.themeSemantic)||void 0===r?void 0:r.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:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=_e(t.nodeLabel),r=t.labelMode||"leaf",i="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,u=c.y1-c.y0;if(0>=e||0>=u)continue;const h=!((null===(a=c.data)||void 0===a?void 0:a.children)&&c.data.children.length>0);if(!i){if("leaf"===r&&!h)continue;if("parent"===r&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>e||(h?16:14)>u)continue;let g=o(xe(c,"nodeStyle")).fill||Ie(t);if(t.colorByDepth&&void 0!==c.depth){const e=Te(t);g=e[c.depth%e.length]}const y="string"==typeof g?Ne(g):null!==(l=null===(s=t.themeSemantic)||void 0===s?void 0:s.text)&&void 0!==l?l:"#000";d.push(h?{x:c.x0+e/2,y:c.y0+u/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,u)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:d}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l,c,d,u,h,f;const g=[],y=[];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const l=o(xe(n,"nodeStyle"));let c=l.fill||Ie(t);if(t.colorByDepth&&void 0!==n.depth){const e=Te(t);c=e[n.depth%e.length]}const d={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:d,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=_e(t.nodeLabel);for(const r of e){const e=null!==(l=r.__radius)&&void 0!==l?l:5,i=n?n(r):r.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let s=o(xe(r,"nodeStyle")).fill||Ie(t);if(t.colorByDepth&&void 0!==r.depth){const e=Te(t);s=e[r.depth%e.length]}if(a){const n="string"==typeof s?Ne(s):null!==(u=null===(d=t.themeSemantic)||void 0===d?void 0:d.text)&&void 0!==u?u:"#000";y.push({x:r.x,y:r.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else y.push({x:r.x,y:r.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=t.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Be(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function $e(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function ze(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function He(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const Fe={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){var i,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),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),d=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof u?()=>u:u,g="number"==typeof h?()=>h:h,y=He(n);y.metaMap.clear(),o.length=0,r.length=0;const p=new Map;function m(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 v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));o.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),y.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,a,u,h,p){const v=l(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,w=0;for(;b>k;)k+=d[Math.min(w,d.length-1)],w++,x++;let S=0;for(let b=0;x>b;b++){const k=d[Math.min(b,d.length-1)],w=v.slice(S,S+k);if(!w.length)break;const M=(b+1)/x,A={id:n,depth:h,data:t,parentId:n},j=p?u/f(A)*M:u*M,L=s.pie().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),C=L(w),E=g(A);for(let t=0;w.length>t;t++){const s=(C[t].startAngle+C[t].endAngle)/2,l=w[t],d=m(c(l)),u=i+j*Math.sin(s),f=a+j*Math.cos(s)*E;o.push({id:d,x:u,y:f,x0:u,x1:u,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:l}),y.metaMap.set(d,{ring:j,angle:s,depth:h,parentId:n,eccentricity:E}),r.push({source:n,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:d}}),e(l,d,u,f,j,h+1,!0)}S+=k}}(e,k,v,b,x,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){var r,i,a,s,l,c,d;const u=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const t=He(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const s=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;y.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(xe(t,"nodeSize")),o=u?u(xe(t,"nodeStyle")):{},c={fill:o.fill||(null===(r=n.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=o.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 m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:m.get(e.source),n="object"==typeof e.target?e.target:m.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(xe(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t&&null!==(d=null===(c=n.data)||void 0===c?void 0:c[t])&&void 0!==d?d:n.id;p.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const r=He(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,a=null!==(o=t.orbitRevolution)&&void 0!==o?o:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-r.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=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const o=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(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},Ye={sankey:Se,force:Me,chord:Ee,tree:We,cluster:We,treemap:We,circlepack:We,partition:We,orbit:Fe};function Xe(e){return Ye[e]}const Ge={category10:b,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:x,reds:k,greens:w,oranges:S,purples:M,viridis:A,plasma:j},qe=b,Ve=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Ke=["#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 Ze(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Qe.has(t)}(o)?n(o):o}const o=(null==e?void 0:e[t])+"";return n?n(o):qe[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%qe.length]}function Ue(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return i.scaleOrdinal().domain(o).range(n).unknown("#999");const a=Ge[n]||Ge.category10;if(r&&"function"==typeof a){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:qe;return i.scaleOrdinal().domain(o).range(e).unknown("#999")}}function Je(e){return 0===e.length?()=>"#4e79a7":t=>{var n;let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return null!==(n=e[Math.abs(o)%e.length])&&void 0!==n?n:"#4e79a7"}}function et(e,t,n){return e+(t-e)*n}function tt(e,t,n){var o,r,i;if(1>=n)return 1;const a=null!==(o=e.minOpacity)&&void 0!==o?o:.1,s=n-1-t;switch(e.type){case"linear":return a+(1-s/(n-1))*(1-a);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r: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 nt{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,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._decayAgeMap=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({},g),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new L(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({},g),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new L(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},ot(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",r=c(n)+"",i=d(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},ot(o)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},ot(r)),{data:n}));const u=`${o}\0${r}\0${e}`,h={source:o,target:r,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:u};n&&"object"==typeof n&&rt(n.bezier)&&(h.bezier=n.bezier),this.edges.set(u,h)}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,ot(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,ot(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+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,o,r,i,a,s,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=Xe(this.config.chartType);if(!c)return;let d=Array.from(this.nodes.values());const u=Array.from(this.edges.values());if(0===d.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const s of d)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!==(o=s._prevY1)&&void 0!==o?o:0)-(null!==(r=s._prevY0)&&void 0!==r?r: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(d,u,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&d.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of d)this.nodes.set(e.id,e);for(let e=0;u.length>e;e++){const t=u[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,d=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const f=d.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=null!==(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)&&d.length>0&&g>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=e,this.previousEdgeKeys=t}buildScene(e){var t,n,o,r,i,a,s;if(this._sceneNodesRevision++,this.config.customNetworkLayout){const l=Array.from(this.nodes.values()),c=Array.from(this.edges.values()),d=function(e,t,n){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Ge[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,b),u={nodes:l,edges:c,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:[...d]},resolveColor:Je(d),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{},selection:null!==(o=this.config.layoutSelection)&&void 0!==o?o:null};let h;try{h=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=h.sceneNodes)&&void 0!==r?r:[],this.sceneEdges=null!==(i=h.sceneEdges)&&void 0!==i?i:[],this.labels=null!==(a=h.labels)&&void 0!==a?a:[],void(this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null)}this.customLayoutOverlays=null;const l=Xe(this.config.chartType);if(!l)return;const c=l.hierarchical?Array.from(this.nodes.values()):this.nodesArray,d=l.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:u,sceneEdges:h,labels:f}=l.buildScene(c,d,this.config,e);this.sceneNodes=u,this.sceneEdges=h,this.labels=f}rebuildNodeQuadtree(){let e=0,t=0;for(const n of this.sceneNodes)"circle"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxNodeRadius=t,nt.QUADTREE_THRESHOLD>=e)return void(this._nodeQuadtree=null);const n=Array(e);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(n[o++]=e);this._nodeQuadtree=c.quadtree().x(e=>e.cx).y(e=>e.cy).addAll(n)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=Xe(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Xe(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=et(e._prevX0,e._targetX0,n),e.x1=et(e._prevX1,e._targetX1,n),e.y0=et(e._prevY0,e._targetY0,n),e.y1=et(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=et(e._prevY0,e._targetY0,n),e.y1=et(e._prevY1,e._targetY1,n),e.sankeyWidth=et(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,o){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=o.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:r}}const i=t.x1,a=o.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:r}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const 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!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const d=e-c;s>d&&(t._pulseIntensity=1-d/s,t._pulseColor=l)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const o=this.nodeTimestamps.size;if(1>=o)return;if(!this._decaySortedNodes){this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const e=new Map;for(let t=0;this._decaySortedNodes.length>t;t++)e.set(this._decaySortedNodes[t][0],t);this._decayAgeMap=e}const r=this._decayAgeMap;for(const i of this.sceneNodes){const a=i.id;if(!a)continue;const s=r.get(a);if(void 0===s)continue;const l=tt(n,s,o),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const o=this.nodes.get(e);if(!o)return null;const r=o.data?Object.assign({},o.data):{};return o.data=t(null!==(n=o.data)&&void 0!==n?n:{}),this.layoutVersion++,r}updateEdge(e,t,n){var o;const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,a=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){a.push(r.data?Object.assign({},r.data):{}),r.data=n(null!==(o=r.data)&&void 0!==o?o:{});const e=i(r.data);null!=e&&(r.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,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.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear()}}function ot(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 rt(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(!it(e))return!1;return!0}return it(t.points)}function it(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 at(...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 st(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function lt(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function ct(e,t,n,o,r=30,i,a=0){let s=null,l=r,c=1/0;if(i){const e=function(e,t,n,o,r,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(o,r+5,12),c=t-l,d=t+l,u=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,r,l,y,p)=>{if(r>d||c>y||l>h||u>p)return!0;if(!e.length){let r=e;do{const e=r.data,l=i(e)-t,c=a(e)-n,d=Math.sqrt(l*l+c*c);st(s(e),o)>=d&&g>d&&(f=e,g=d),r=r.next}while(r)}return!1}),f?{node:f,distance:g}:null}(i,n,o,r,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=dt(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(s=e,c=n)}else l>e.distance&&(s=e,l=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=yt(e,n,o);t&&l>t.distance&&(s=t,l=t.distance)}return s}function dt(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,a=Math.sqrt(r*r+i*i);return a>st(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,o);case"rect":return function(e,t,n){const o=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const a=lt(Math.atan2(r,o)),s=lt(e.startAngle),l=lt(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}}nt.QUADTREE_THRESHOLD=500;let ut=null,ht=null;function ft(){return ht||(ut=document.createElement("canvas"),ut.width=1,ut.height=1,ht=ut.getContext("2d")),ht}function gt(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 yt(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=gt(e),r=ft();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,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 o=gt(e),r=ft();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function pt(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?mt(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?mt(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function mt(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function vt(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}const bt="var(--semiotic-focus, #005fcc)";function xt({active:t,hoverPoint:n,margin:o,size:r,shape:i="circle",width:a,height:s}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let d;if("rect"===i&&null!=a&&null!=s){const t=Math.max(a,4),n=Math.max(s,4);d=e.jsx("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:bt,strokeWidth:2,strokeDasharray:"4,2"})}else d=e.jsx("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:bt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:bt,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:d})}const kt={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 wt(e,t){return"function"==typeof t?t(e):e[t]}function St(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 Mt(t={}){const{fields:n,title:o,format:r,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(o){const e=wt(t,o);s=St(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=wt(t,o);l.push({label:n,value:St(a,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=St(t[n],r);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=St(t[e[0]],r))}}const c=Object.assign(Object.assign({},kt),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 At(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var o;const r=h(!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(o=t.data)&&void 0!==o?o:{}:t),i=n(r);return null==i?null:e.jsx("div",{className:"semiotic-tooltip",style:kt,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Mt(t):Mt())}}function jt({x:t,y:n,containerWidth:o,containerHeight:r,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,o,r]);let g;g=h?`translate(${h.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const y=function(e){if(!u.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(a),p=y?null:kt;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 Lt(n){let o=null;const r=()=>(o||(o=t.createContext(null)),o),i=Ct(n);return[function({children:o,initialState:i}){const a=t.useRef(i),s=t.useMemo(()=>Ct(n,a.current),[]),l=r();return e.jsx(l.Provider,{value:s,children:o})},e=>{var n;const o=r(),a=null!==(n=t.useContext(o))&&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 Ct(e,t){const n=new EventTarget;let o=Object.assign(Object.assign({},e(function(e){o=Object.assign(Object.assign({},o),e(o)),n.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>o,subscribe:function(e){return n.addEventListener("update",e),()=>n.removeEventListener("update",e)}}}function Et(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 Dt(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:Ot})})),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 Ot=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Nt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Pt={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},_t={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Ot,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 Tt(e,t){if("light"===t)return Nt;if("dark"===t)return Pt;if("high-contrast"===t)return _t;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?Pt:Nt;return Dt(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 Dt(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[It,Rt]=Lt(e=>({theme:Nt,setTheme(t){e(e=>({theme:Tt(e.theme,t)}))}}));const Wt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Bt=new WeakMap;let $t=0,zt=!1,Ht=null,Ft=null,Yt=null;function Xt(e,t){var n,o;if(!t)return t;const r=Wt.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;!function(){if(zt)return;if("undefined"==typeof window||"undefined"==typeof document)return;zt=!0;const e=()=>{$t++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Ht=new MutationObserver(e),Ht.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Ft=window.matchMedia("(prefers-color-scheme: dark)"),Yt=e,"function"==typeof Ft.addEventListener?Ft.addEventListener("change",Yt):"function"==typeof Ft.addListener&&Ft.addListener(Yt)}catch(e){}}();let a=Bt.get(i);a&&a.version===$t||(a={version:$t,map:new Map},Bt.set(i,a));const s=a.map.get(t);if(void 0!==s)return s;const l=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return a.map.set(t,l),l}const Gt="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function qt(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Vt(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){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>n(e.matches))},[]),e}(),o=t.useRef(n);o.current=n;const[r,i]=function(e,n,o){const r=t.useRef(null),[i,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!o)return;const e=r.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,o]),[r,[n&&i?i.w:e[0],o&&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=qt(e.foregroundGraphics,i,a),d=qt(e.backgroundGraphics,i,a),h=Rt(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const r="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(r||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+u.useId(),p=t.useRef(0),m=t.useRef(()=>{}),v=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>m.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)},[]),M=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(S))},[S]),A=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 Gt(()=>{j&&($t++,j.current=!0,v())},[h,v,j]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:r,size:i,margin:a,adjustedWidth:s,adjustedHeight:l,resolvedForeground:c,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:y,rafRef:p,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:M,onPointerLeave:A}}function Kt({isStale:t,position:n}){return e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===n?{top:4,left:4}:"bottom-left"===n?{bottom:4,left:4}:"bottom-right"===n?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"}),children:t?"STALE":"LIVE"})}const Qt={fill:(t,n)=>e.jsx("rect",{style:t,width:n,height:n}),line:(t,n)=>e.jsx("line",{style:t,x1:0,y1:0,x2:n,y2:n})};function Zt(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,Qt[n])(o(e,t),r),i}function Ut({swatchSize:t}){return e.jsx("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Jt(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const en=(t,n,o,r,i,a,s,l,c,d,u)=>{const{type:h="fill",styleFn:f,items:g}=t,y=[];let p=0;const m=!(!n&&!o),v="isolate"===d||void 0===d&&null!=i,{swatchSize:b,labelGap:x,rowHeight:k}=u;return g.forEach((t,d)=>{const u=Zt(t,d,h,f,b),w=Jt(t,r,i),S=i&&i.size>0&&i.has(t.label);y.push(e.jsxs("g",{transform:`translate(0,${p})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?l===a&&d===s?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&v?S||!1:void 0,"aria-current":m&&!v&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:m?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(d+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?e=>{c(l,d),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+x+2+7*t.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,S&&e.jsx(Ut,{swatchSize:b}),e.jsx("text",{y:b/2,x:b+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+d)),p+=k}),y};function tn({config:t,orientation:n="vertical",width:o=100}){const{colorFn:r,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(o,200),s=Math.max(0,(o-n)/2),d=[];for(let t=0;64>=t;t++){const n=t/64;d.push(e.jsx("stop",{offset:100*n+"%",stopColor:r(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:d})}),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:r(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 nn(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,legendInteraction:s,title:l="Legend",width:c=100,height:d=20,orientation:h="vertical",legendLayout:f}=t,g=function(e){var t,n,o,r,i;const a=Math.max(1,null!==(t=null==e?void 0:e.swatchSize)&&void 0!==t?t:16),s=Math.max(a,null!==(n=null==e?void 0:e.rowHeight)&&void 0!==n?n:22);return{swatchSize:a,labelGap:Math.max(0,null!==(o=null==e?void 0:e.labelGap)&&void 0!==o?o:6),itemGap:Math.max(0,null!==(r=null==e?void 0:e.itemGap)&&void 0!==r?r:10),rowHeight:s,align:"left"===(null==e?void 0:e.align)?"start":"right"===(null==e?void 0:e.align)?"end":null!==(i=null==e?void 0:e.align)&&void 0!==i?i:"start",maxWidth:null==e?void 0:e.maxWidth}}(f),[y,p]=u.useState(0),[m,v]=u.useState(0),b=u.useCallback((e,t)=>{p(e),v(t)},[]),x="vertical"===h?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:d,metrics:u})=>{let h=24;const f=[];return t.forEach((t,g)=>{h+=5,f.push(e.jsx("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,t.label&&(h+=16,f.push(e.jsx("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),h+=8),f.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:en(t,o,r,i,a,s,l,g,c,d,u)},"legend-group-"+g)),h+=t.items.length*u.rowHeight+8}),f})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:y,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:s,metrics:g}):(({legendGroups:t,height:n,width:o,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:s,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:d,legendInteraction:u,metrics:h})=>{var f;let g=0;const y=[];t.forEach((t,n)=>{var f;let p=0;t.label&&(p+=16);const m=((t,n,o,r,i,a,s,l,c,d,u,h)=>{const{type:f="fill",styleFn:g,items:y}=t,p=[],{swatchSize:m,labelGap:v,itemGap:b,rowHeight:x,align:k}=u,w=!(!n&&!o),S="isolate"===d||void 0===d&&null!=i,M=y.map(e=>m+v+7*e.label.length),A=[];let j=0,L=0;M.forEach((e,t)=>{const n=0===L?e:L+b+e;h&&h>0&&L>0&&n>h?(A.push({start:j,end:t,width:L}),j=t,L=e):L=n}),y.length>0&&A.push({start:j,end:y.length,width:L}),A.forEach((t,d)=>{let u="center"===k?Math.max(0,((null!=h?h:t.width)-t.width)/2):"end"===k?Math.max(0,(null!=h?h:t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=y[h],k=Zt(t,h,f,g,m),A=Jt(t,r,i),j=i&&i.size>0&&i.has(t.label);p.push(e.jsxs("g",{transform:`translate(${u},${d*x})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:w?l===a&&h===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&S?j||!1:void 0,"aria-current":w&&!S&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:w?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(h+("ArrowRight"===e.key?1:-1)+y.length)%y.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:w?e=>{c(l,h),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+v+2+7*t.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,j&&e.jsx(Ut,{swatchSize:m}),e.jsx("text",{y:m/2,x:m+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+h)),u+=M[h]+b}});const C=Math.max(0,...A.map(e=>e.width)),E=A.length;return{items:p,offset:C,totalRows:E,totalHeight:E*x}})(t,r,i,a,s,l,c,n,d,u,h,null!==(f=h.maxWidth)&&void 0!==f?f:o);p+=m.offset+5,y.push(Object.assign(Object.assign({label:t.label},m),{offset:p,totalRows:m.totalRows,totalHeight:m.totalHeight})),g+=p+12});const p=null!==(f=h.maxWidth)&&void 0!==f?f:o;let m=g>p?0:"center"===h.align?Math.max(0,(p-g)/2):"end"===h.align?Math.max(0,p-g):0;const v=[];return y.forEach((o,r)=>{const i=t[r];i.label&&(v.push(e.jsx("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+r)),m+=16),v.push(e.jsx("g",{className:"legend-item",transform:`translate(${m},0)`,children:o.items},"legend-group-"+r)),m+=o.offset+5,t[r+1]&&v.push(e.jsx("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+r)),m+=12}),e.jsx("g",{children:v})})({legendGroups:n||[],title:l,height:d,width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:y,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:s,metrics:g}),k=!(!o&&!r);return e.jsxs("g",{role:k?"listbox":void 0,"aria-multiselectable":!(!k||"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}),x]})}function on(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function rn(e){return"object"==typeof e&&null!==e&&"gradient"in e}function an(t){var n;const{legend:o,totalWidth:r,totalHeight:i,margin:a,legendPosition:s="right",legendLayout:l,title:c,legendHoverBehavior:d,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=t;if(!o)return null;const y="top"===s||"bottom"===s,p=!!c,m=Math.max(1,y?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,r-a.left-a.right):100);let v,b;return"left"===s?(v=Math.max(4,a.left-m-10),b=a.top):"top"===s?(v=a.left,b=p?32:8):"bottom"===s?(v=a.left,b=i-a.bottom+38):(v=r-a.right+10,b=a.top),e.jsx("g",{transform:`translate(${v}, ${b})`,children:rn(o)?e.jsx(tn,{config:o.gradient,orientation:y?"horizontal":"vertical",width:m}):on(o)?e.jsx(nn,{legendGroups:o.legendGroups,title:"",width:m,orientation:y?"horizontal":"vertical",legendLayout:l,customHoverBehavior:d,customClickBehavior:u,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}const sn={secondary:0,primary:3},ln=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function cn(e){return!0===(null==e?void 0:e._annotationDeferred)}function dn(e){return"blended"===(null==e?void 0:e.cohesion)||"layer"===(null==e?void 0:e.cohesion)?e.cohesion:null}function un(e){var t;const n=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function hn(e){return Math.max(.72,.95-.06*e)}function fn(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function gn(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function yn(e){return null==e?null:e+""}function pn(e,t,n){var o;return null===(o=t.stickyPositionCache)||void 0===o||o.set(e,n),n}const mn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function vn(e){return!!e&&"object"==typeof e&&mn.has(function(e){return"string"==typeof(null==e?void 0:e.type)?e.type:""}(e))}function bn(e){return"primary"===(null==e?void 0:e.emphasis)||!0===(null==e?void 0:e.defensive)}function xn(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function kn(e){var t,n;let o;const r=null==e?void 0:e.emphasis;o="primary"===r?100:"secondary"===r?10:50;const i=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(o+=15*function(e){return Math.max(0,Math.min(1,e))}(i)),null===(n=null==e?void 0:e.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}new Set(["label","callout","callout-circle","callout-rect"]);const wn=32,Sn=6,Mn=4,An=8,jn=72;const Ln={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Cn(e){return vn(e)}function En(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function Dn(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function On(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Nn(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Pn(e,t,n,o,r,i,a,s){const l=On(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(l,r,i,s);for(const e of n)c+=12*Nn(l,e);for(const e of o)c+=4*Nn(l,e);return c}function _n(e,t,n){var o,r;if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const i=null!==(o=e.pointId)&&void 0!==o?o:e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const a=e.coordinates,s=null===(r=n.scales)||void 0===r?void 0:r.geoProjection;if(Array.isArray(a)&&a.length>=2&&s){const e=a[0],t=a[1];if("number"==typeof e&&"number"==typeof t){const n=s([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?function(e,t,n){var o,r;const i=e.anchor||(null===(o=e.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return pn(t,n,{x:r.x,y:r.y})}const o=function(e){var t,n,o,r,i,a;const s=e.data;if(!s||0===s.length)return null;const l=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,d=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!d)return null;const u=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==u||null==h?null:{x:c(u),y:d(h)}}(n);return o?pn(t,n,o):null}if("semantic"===i){const o=function(e,t,n){var o,r;const i=function(e){var t,n;return yn(null!==(n=null===(t=e.provenance)||void 0===t?void 0:t.stableId)&&void 0!==n?n:e.stableId)}(e);if(!i)return null;const a=null===(o=n.pointNodes)||void 0===o?void 0:o.find(e=>yn(e.pointId)===i);if(a)return pn(t,n,{x:a.x,y:a.y});const s=null===(r=n.data)||void 0===r?void 0:r.find(e=>function(e){var t,n,o;return yn(null!==(n=null!==(t=e.stableId)&&void 0!==t?t:e.id)&&void 0!==n?n:null===(o=e.provenance)||void 0===o?void 0:o.stableId)}(e)===i);if(!s)return null;const l=fn(s,n),c=gn(s,n);return null==l||null==c?null:pn(t,n,{x:l,y:c})}(e,t,n);if(o)return o}let a=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(a=t.x,s=t.y)}if(null!=a&&null!=s||(a=fn(e,n),s=gn(e,n)),null!=a&&null!=s)return pn(t,n,{x:a,y:s});if("sticky"===i){const e=null===(r=n.stickyPositionCache)||void 0===r?void 0:r.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function Tn(e){var t;const{annotations:n,context:o,defaultOffset:r=wn,notePadding:i=Sn,markPadding:a=Mn,edgePadding:s=An,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:d=jn,density:u,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:y,audience:p}=e,m=o.width||0,v=o.height||0;if(0===n.length||0>=m||0>=v)return n.slice();const b=[],x=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(o,a);let k=!1;const w=n.map((e,t)=>{if(!Cn(e))return e;const n=_n(e,t,o);if(!n)return e;const a=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...En("string"==typeof e.title?e.title:void 0,t),...En("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(l&&("number"==typeof(u=e).dx||"number"==typeof u.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return b.push(On(Dn(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,a),i)),e}var u;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Pn(Dn(n.x,n.y,e.dx,e.dy,a),e,b,x,m,v,i,s);f>t&&(h=e,f=t)}if(!h)return e;const g=On(Dn(n.x,n.y,h.dx,h.dy,a),i);b.push(g);const y=Math.hypot(h.dx,h.dy),p=c&&y>=d&&"text"!==e.type&&"widget"!==e.type?Object.assign(Object.assign({},e.connector||{end:"arrow"}),{type:"curve"}):e.connector;return k=!0,Object.assign(Object.assign(Object.assign({},e),{dx:h.dx,dy:h.dy}),p?{connector:p}:{})}),S=k?w:n.slice();let M=S;if(f){let e=!1;const t=S.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:Object.assign(Object.assign({},e),{_redundantConnector:!0})}(t);return n!==t&&(e=!0),n});M=e?t:S}{let e=!1;const t=M.map(t=>{if(!0!==(null==t?void 0:t.defensive))return t;const n=function(e){var t;const n=null==e?void 0:e.provenance;if(!n||"object"!=typeof n)return e;const o="string"==typeof n.source?null!==(t=Ln[n.source])&&void 0!==t?t:n.source:null,r="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const i=[o,r].filter(Boolean).join(" · "),a="string"==typeof e.label?e.label:"";return a.includes(`(${i})`)?e:Object.assign(Object.assign({},e),{label:a?`${a} (${i})`:`(${i})`})}(t);return n!==t&&(e=!0),n});M=e?t:M}const A=new Set;if(u){const e="object"==typeof u?u:{},n=function(e){if(!e)return 1;const t=function(e){const t=null==e?void 0:e.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(p),o=1===n?e:Object.assign(Object.assign({},e),{maxAnnotations:Math.max(0,Math.round((null!==(t=e.maxAnnotations)&&void 0!==t?t:xn(m,v,e))*n))}),{deferred:r}=function(e){var t;const{annotations:n,width:o,height:r}=e,i=Math.max(0,null!==(t=e.minVisible)&&void 0!==t?t:1),a=xn(o,r,e),s=n.map((e,t)=>{return{annotation:e,index:t,note:(n=e,vn(n))};var n}),l=s.filter(e=>e.note);if(0===l.length||a>=l.length)return{visible:n.slice(),deferred:[],budget:a};const c=l.filter(e=>bn(e.annotation)),d=l.filter(e=>!bn(e.annotation)).sort((e,t)=>kn(t.annotation)-kn(e.annotation)||e.index-t.index),u=Math.min(d.length,Math.max(Math.max(0,a-c.length),Math.max(0,i-c.length))),h=new Set([...c.map(e=>e.index),...d.slice(0,u).map(e=>e.index)]),f=[],g=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?f.push(e):g.push(e);return{visible:f,deferred:g,budget:a}}(Object.assign({annotations:M,width:m,height:v},o));for(const e of r)A.add(e)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const e of M)Cn(e)&&"secondary"===e.emphasis&&A.add(e);if(A.size>0)for(const e of M)!0===(null==e?void 0:e.defensive)&&A.delete(e);let j;return j=0===A.size?M:h?M.map(e=>A.has(e)?Object.assign(Object.assign({},e),{_annotationDeferred:!0}):e):M.filter(e=>!A.has(e)),y?function(e,t){let n=!1;const o=e.map(e=>Cn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,Object.assign(Object.assign({},e),{cohesion:t})):e);return n?o:e}(j,y):j}function In(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,labels:s,title:l,legend:c,legendHoverBehavior:d,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g,legendPosition:y="right",legendLayout:p,foregroundGraphics:m,sceneNodes:v,annotations:b,autoPlaceAnnotations:x,svgAnnotationRules:k}=t,w=u.useMemo(()=>{const e=(v||[]).flatMap(e=>{const t=function(e){var t,n,o,r;const i=null!==(t=e.cx)&&void 0!==t?t:null!=e.x&&null!=e.w?e.x+e.w/2:e.x,a=null!==(n=e.cy)&&void 0!==n?n:null!=e.y&&null!=e.h?e.y+e.h/2:e.y;return"number"!=typeof i||"number"!=typeof a?null:{x:i,y:a,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):Math.max(1,null!==(o=e.w)&&void 0!==o?o:0,null!==(r=e.h)&&void 0!==r?r:0)/2}}(e),n=function(e){var t,n,o,r,i,a,s,l;const c=null!==(a=null!==(o=null!==(t=e.id)&&void 0!==t?t:null===(n=e.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:null===(i=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===i?void 0:i.id)&&void 0!==a?a:null===(l=null===(s=e.datum)||void 0===s?void 0:s.data)||void 0===l?void 0:l.name;return null==c?void 0:c+""}(e);return t?[Object.assign({pointId:n},t)]:[]});return{scales:null,width:n,height:o,frameType:"network",pointNodes:e,sceneNodes:v}},[o,v,n]),S=u.useMemo(()=>b&&x?Tn(Object.assign({annotations:b,context:w},"object"==typeof x?x:{})):b,[b,x,w]),M=S?function(t){const n=t.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:un(e.annotation),readingOrder:null,rank:1};var n}),o=n.some(e=>null!=e.emphasis||null!=e.confidence),r=t.some(e=>cn(e.annotation)),i=t.some(e=>null!=dn(e.annotation)),a=t.some(e=>"layer"===dn(e.annotation));if(!o&&!r&&!i)return t.map(e=>e.node);const s=n.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>{var n,o;return(null!==(n=t.confidence)&&void 0!==n?n:0)-(null!==(o=e.confidence)&&void 0!==o?o:0)||e.i-t.i});s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of n)e.emphasis&&(e.rank=sn[e.emphasis]);const l=n.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(t=>{const{p:n,i:o,emphasis:r,readingOrder:i}=t,a=cn(n.annotation);let s=n.node;if("primary"===r||"secondary"===r||null!=i){const t=null==r&&null!=i;s=e.jsx("g",Object.assign({className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r},"secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},t?{opacity:hn(i),"data-annotation-reading-order":i}:{},{children:n.node}),"annotation-emphasis-"+o)}const l=dn(n.annotation);return l&&(s=e.jsx("g",{className:"annotation-cohesion--"+l,children:s},"annotation-cohesion-"+o)),a&&(s=e.jsx("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+o)),s});return r&&l.unshift(e.jsx("style",{children:ln},"annotation-disclosure-style")),a&&l.unshift(e.jsx("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),l}(S.reduce((t,n,o)=>{if("widget"===n.type||!k)return t;const r=k(n,o,w);return r&&t.push({node:e.jsx(u.Fragment,{children:r},"annotation-"+o),annotation:n}),t},[])):null,A=!0===(null==S?void 0:S.some(e=>"widget"===e.type&&!0===e._annotationDeferred));return e.jsxs(e.Fragment,{children:[A&&e.jsx("style",{children:ln},"annotation-widget-disclosure-style"),e.jsxs("svg",{role:"img",width:r,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]}),l&&"string"==typeof l?e.jsx("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:r,height:a.top,children:l}):null,an({legend:c,totalWidth:r,totalHeight:i,margin:a,legendPosition:y,title:l,legendLayout:p,legendHoverBehavior:d,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g})]}),null==S?void 0:S.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,n)=>{var o,r,i,s,l,c,d,u,h;const f=!0===t._annotationDeferred,g=v.find(e=>{var n,o,r,i,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(r=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.id)===t.nodeId||(null===(a=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===t.nodeId});if(!g)return null;const y=a.left+(null!==(o=g.cx)&&void 0!==o?o:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(r=g.x)&&void 0!==r?r:0),p=a.top+(null!==(i=g.cy)&&void 0!==i?i:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(s=g.y)&&void 0!==s?s:0),m=null!==(l=t.dx)&&void 0!==l?l:0,b=null!==(c=t.dy)&&void 0!==c?c:-16,x=null!==(d=t.width)&&void 0!==d?d:32,k=null!==(u=t.height)&&void 0!==u?u:32,w=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{className:f?"annotation-deferred":void 0,"data-annotation-disclosure":f?"deferred":void 0,style:{position:"absolute",left:y+m-x/2,top:p+b-k/2,width:x,height:k,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:w},"widget-"+n)})]})}In.displayName="NetworkSVGOverlay";const Rn={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Wn(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Bn="undefined"==typeof window||"undefined"==typeof document,$n="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,zn=()=>()=>{},Hn=()=>!1,Fn=()=>!0;function Yn(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 Gn(e,t);if(!qn(e)||!qn(t))return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!Gn(n,r))return!1}else{if(!qn(n)||!qn(r))return!1;if(!Xn(n,r))return!1}}return!0}(n.current,e)||(n.current=e),n.current}function Xn(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function Gn(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 qn(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 Vn=u.createContext(null),Kn={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Qn(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}const Zn=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Un="semiotic-accessible-data-table",Jn=Un+" semiotic-accessible-data-table-hidden",eo=Un+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",to={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},no={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},oo={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ro={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},io={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},ao={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},so={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},lo={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function co({nodes:t,edges:n,chartType:o,tableId:r,chartTitle:i}){var a,s,l,c,d,h,f,g,y,p,m,v,b,x;const[k,w]=u.useState(!1),[S,M]=u.useState(5),A=u.useContext(Vn),j=null!==(a=null==A?void 0:A.visible)&&void 0!==a&&a,L=k||j,C=i?"Data summary for "+i:r?`Data summary for ${o} ${r}`:"Data summary for "+o,E=u.useRef(null);u.useEffect(()=>{L||M(5)},[L]);const D=u.useCallback(e=>{e.target===e.currentTarget&&(k||j||w(!0))},[k,j]),O=u.useCallback(e=>{var t;j||(null===(t=E.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[j]);if(!t||0===t.length)return r?e.jsx("span",{id:r,tabIndex:-1,style:Kn}):null;if(!L)return e.jsx("div",{id:r,className:Jn,tabIndex:-1,onFocus:D,style:Kn,role:"region","aria-label":C,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",n.length," edges)"]})});const N=Array.isArray(t)?t:[],P=Array.isArray(n)?n:[],_=new Map,T=new Map,I=new Map,R=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,o="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,r="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(d=T.get(e))&&void 0!==d?d:0)+1),R.set(e,(null!==(h=R.get(e))&&void 0!==h?h:0)+r)}if(null!=o&&""!==o){const e=o+"";_.set(e,(null!==(f=_.get(e))&&void 0!==f?f:0)+1),I.set(e,(null!==(g=I.get(e))&&void 0!==g?g:0)+r)}}const W=[];for(let e=0;N.length>e;e++){const t=N[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,o=null!=n?n+"":"node-"+e,r=null!==(m=_.get(o))&&void 0!==m?m:0,i=null!==(v=T.get(o))&&void 0!==v?v:0,a=null!==(b=I.get(o))&&void 0!==b?b:0,s=null!==(x=R.get(o))&&void 0!==x?x:0;W.push({id:o,degree:r+i,inDeg:r,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}W.sort((e,t)=>t.degree-e.degree);let B=0,$=0;if(W.length>0){let e=0;for(const t of W)e+=t.degree,t.degree>$&&($=t.degree);B=e/W.length}const z=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)}),H=[`${W.length} nodes, ${P.length} edges.`];W.length>0&&H.push(`Mean degree: ${Zn(B)}, max degree: ${$}.`);const F=Math.min(S,W.length),Y=W.slice(0,F),X=W.length-F;return e.jsxs("div",{ref:E,id:r,className:eo,tabIndex:-1,onBlur:O,style:to,role:"region","aria-label":C,children:[e.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{j&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:oo,children:"×"}),e.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:no,children:H.join(" ")}),e.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+o,style:ro,children:[e.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:so,children:X>0?`Top ${F} of ${W.length} nodes by degree`:`All ${W.length} nodes by degree`}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:io,children:"id"}),e.jsx("th",{style:io,children:"degree"}),e.jsx("th",{style:io,children:"in"}),e.jsx("th",{style:io,children:"out"}),z&&e.jsx("th",{style:io,children:"w. degree"}),z&&e.jsx("th",{style:io,children:"w. in"}),z&&e.jsx("th",{style:io,children:"w. out"})]})}),e.jsx("tbody",{children:Y.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:ao,children:t.id}),e.jsx("td",{style:ao,children:t.degree}),e.jsx("td",{style:ao,children:t.inDeg}),e.jsx("td",{style:ao,children:t.outDeg}),z&&e.jsx("td",{style:ao,children:Zn(t.wDegree)}),z&&e.jsx("td",{style:ao,children:Zn(t.wInDeg)}),z&&e.jsx("td",{style:ao,children:Zn(t.wOutDeg)})]},n))})]}),X>0&&e.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>M(e=>e+25),style:lo,children:["Show ",Math.min(25,X)," more"," ",1===X?"node":"nodes"," (",X," remaining)"]})]})}function uo({summary:t}){return t?e.jsx("div",{role:"note",style:Kn,children:t}):null}function ho({tableId:t}){return e.jsx("a",{href:"#"+t,style:Kn,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,Kn)},children:"Skip to data table"})}function fo({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:Kn,children:n})}const go=Object.freeze([]);function yo(e){if(!e)return go;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function po(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function mo(e,t,n=.3){po(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 vo(e,t,n=.6){var o,r,i,a,s;if(!po(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,d=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,u=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(d,u,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function bo(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function xo(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=bo(t);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s="string"==typeof t.style.fill?t.style.fill:"#999",l=Xt(e,s)||s;r.addColorStop(0,1===a.from?l:"transparent"),r.addColorStop(1,1===a.to?l:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&Xt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Xt(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 ko(e,t){var n,o;e.save();const r=t.style.stroke||"#999";e.strokeStyle=Xt(e,r)||r,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function wo(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=bo(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Xt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Xt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function So(e,t){var n,o;if(!t.pathD)return;e.save();const r=bo(t),i=t.style.stroke||"#999";e.strokeStyle=Xt(e,i)||i,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Xt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}const Mo={top:20,right:80,bottom:20,left:80},Ao={top:40,right:40,bottom:40,left:40},jo=new Set(["chord","force","circlepack","orbit"]),Lo=[800,600],Co={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 Eo({data:t}){var n,o,r,i,a,s;if("edge"===t.nodeOrEdge){const n=t.data;return n?e.jsxs("div",{className:"semiotic-tooltip",style:Co,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!==(o=null===(n=a.data)||void 0===n?void 0:n.name)&&void 0!==o?o:null===(r=a.data)||void 0===r?void 0:r.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:Co,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 d=((null===(a=l.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(s=l.targetLinks)||void 0===s?void 0:s.length)||0),u=(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:Co,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+""]}),d>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",d,u!==d&&` (weighted: ${u.toLocaleString()})`]})]})}Eo.ownsChrome=!0;const Do=t.forwardRef(function(n,o){var r,i,a,l,c,d,u,h,p,m,v,b,x,k,w,S,M,A,j;const{chartType:L,nodes:C,edges:E,data:D,initialEdges:O,nodeIDAccessor:N="id",sourceAccessor:P="source",targetAccessor:_="target",valueAccessor:T="value",edgeIdAccessor:I,childrenAccessor:R,hierarchySum:W,orientation:B="horizontal",nodeAlign:$="justify",nodePaddingRatio:z=.05,nodeWidth:H=15,iterations:F=300,forceStrength:Y=.1,padAngle:X=.01,groupWidth:G=20,sortGroups:q,edgeSort:V,treeOrientation:K="vertical",edgeType:Q="curve",padding:Z,paddingTop:U,tensionConfig:J,showParticles:ee=!1,particleStyle:te,nodeStyle:ne,edgeStyle:oe,colorBy:re,colorScheme:ie="category10",edgeColorBy:ae="source",edgeOpacity:se=.5,colorByDepth:le=!1,nodeSize:ce=8,nodeSizeRange:de=[5,20],nodeLabel:ue,showLabels:he=!0,labelMode:fe,size:ge=Lo,responsiveWidth:ye,responsiveHeight:pe,margin:me,className:ve,background:be,enableHover:xe=!0,tooltipContent:ke,customHoverBehavior:we,customClickBehavior:Se,onObservation:Me,chartId:Ae,onTopologyChange:je,annotations:Le,autoPlaceAnnotations:Ce,svgAnnotationRules:Ee,legend:De,legendPosition:Oe,legendLayout:Ne,legendHoverBehavior:Pe,legendClickBehavior:_e,legendHighlightedCategory:Te,legendIsolatedCategories:Ie,title:Re,foregroundGraphics:We,backgroundGraphics:Be,decay:$e,pulse:ze,transition:He,animate:Fe,staleness:Ye,thresholds:Xe,accessibleTable:Ge=!0,description:Ve,summary:Ke,orbitMode:Qe,orbitSize:Ze,orbitSpeed:Ue,orbitRevolution:Je,orbitRevolutionStyle:et,orbitEccentricity:tt,orbitShowRings:ot,orbitAnimated:rt,customNetworkLayout:it,layoutConfig:st,layoutSelection:lt}=n,dt=jo.has(L)?Ao:Mo,ut=t.useRef(!0),ht=Vt({sizeProp:ge,responsiveWidth:ye,responsiveHeight:pe,userMargin:me,marginDefault:dt,foregroundGraphics:We,backgroundGraphics:Be,animate:Fe,transitionProp:He,themeDirtyRef:ut}),{reducedMotionRef:ft,responsiveRef:gt,size:yt,margin:mt,adjustedWidth:bt,adjustedHeight:kt,resolvedForeground:wt,resolvedBackground:St,transition:Mt,introEnabled:At,tableId:Lt,rafRef:Ct,renderFnRef:Dt,scheduleRender:Ot,currentTheme:Nt}=ht,Pt=function(){const[e,n]=t.useState(!1);return $n(()=>{n(!0)},[]),e}(),_t=function(){const e=t.useSyncExternalStore(zn,Hn,Fn);return t.useRef(e).current}(),Tt=t.useMemo(()=>yo(C),[C]),It=t.useMemo(()=>Array.isArray(E)?yo(E):E,[E]),Rt=t.useMemo(()=>Object.assign(Object.assign({},g),J),[J]),Wt=t.useMemo(()=>Object.assign(Object.assign({},y),te),[te]),Bt=t.useMemo(()=>{var e;return{chartType:L,nodeIDAccessor:N,sourceAccessor:P,targetAccessor:_,valueAccessor:T,edgeIdAccessor:I,childrenAccessor:R,hierarchySum:W,orientation:B,nodeAlign:$,nodePaddingRatio:z,nodeWidth:H,iterations:F,forceStrength:Y,padAngle:X,groupWidth:G,sortGroups:q,edgeSort:V,treeOrientation:K,edgeType:Q,padding:Z,paddingTop:U,tensionConfig:Rt,showParticles:ee,particleStyle:Wt,nodeStyle:ne,edgeStyle:oe,nodeLabel:ue,showLabels:he,labelMode:fe,colorBy:re,colorScheme:ie,themeCategorical:null===(e=null==Nt?void 0:Nt.colors)||void 0===e?void 0:e.categorical,themeSemantic:Et(Nt),edgeColorBy:ae,edgeOpacity:se,colorByDepth:le,nodeSize:ce,nodeSizeRange:de,decay:$e,pulse:ze,transition:Mt,introAnimation:At,staleness:Ye,thresholds:Xe,orbitMode:Qe,orbitSize:Ze,orbitSpeed:Ue,orbitRevolution:Je,orbitRevolutionStyle:et,orbitEccentricity:tt,orbitShowRings:ot,orbitAnimated:rt,customNetworkLayout:it,layoutConfig:st,layoutSelection:lt}},[L,N,P,_,T,R,W,B,$,z,H,F,Y,X,G,q,V,K,Q,Z,U,Rt,ee,Wt,ne,oe,ue,he,fe,re,ie,ae,se,le,ce,de,$e,ze,null==Mt?void 0:Mt.duration,null==Mt?void 0:Mt.easing,At,Ye,Xe,Qe,Ze,Ue,Je,et,tt,ot,rt,Nt,it,st,lt]),$t=Yn(Bt),zt=Yn({chartType:L,nodeIDAccessor:N,sourceAccessor:P,targetAccessor:_,valueAccessor:T,childrenAccessor:R,hierarchySum:W,orientation:B,nodeAlign:$,nodePaddingRatio:z,nodeWidth:H,iterations:F,forceStrength:Y,padAngle:X,groupWidth:G,sortGroups:q,edgeSort:V,treeOrientation:K,edgeType:Q,padding:Z,paddingTop:U,tensionConfig:Rt,orbitMode:Qe,orbitSize:Ze,orbitEccentricity:tt,customNetworkLayout:it}),Ht=t.useRef(null),Ft=t.useRef(0),Yt=t.useRef(0),Gt=t.useRef(!1),qt=t.useRef(null);qt.current||(qt.current=new nt($t));const[Qt,Zt]=t.useState(null),[Ut,Jt]=t.useState(0),[en,tn]=t.useState(0),[nn,on]=t.useState(!1),rn=t.useRef(null),an=t.useRef(new Map),sn=t.useRef(0),ln=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(!an.current.has(t+"")){const e=Array.isArray(ie)?ie:qe;an.current.set(t+"",e[sn.current++%e.length])}return an.current.get(t+"")}}if(an.current.has(e.id))return an.current.get(e.id);const t=Array.isArray(ie)?ie:qe,n=re?t[sn.current++%t.length]:t[0];return an.current.set(e.id,n),n},[re,ie]),cn=(null===(r=null==Nt?void 0:Nt.colors)||void 0===r?void 0:r.border)||(null===(i=null==Nt?void 0:Nt.colors)||void 0===i?void 0:i.secondary)||(null===(a=null==Nt?void 0:Nt.colors)||void 0===a?void 0:a.primary)||"#999",dn=t.useCallback(e=>{var t,n;return e?"object"==typeof e?e:null!==(n=null===(t=qt.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==n?n:null:null},[]),un=t.useCallback(e=>{if("function"==typeof ae)return ae(e);const t=dn(e.source),n=dn(e.target);return"target"===ae&&n?ln(n):t?ln(t):cn},[ae,ln,cn,dn]),hn=t.useCallback(e=>{if("function"==typeof Wt.color){const t=dn(e.source);return t?Wt.color(e,t):cn}if(!(null==te?void 0:te.colorBy))return un(e);const t=Wt.colorBy,n=dn(e.source),o=dn(e.target);return"target"===t&&o?ln(o):n?ln(n):cn},[null==te?void 0:te.colorBy,Wt.color,Wt.colorBy,ln,un,cn,dn]),fn=("sankey"===L||!!it)&&ee||!!ze||null!==(c=null===(l=qt.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=qt.current)||void 0===e||e.updateConfig($t),ut.current=!0,Ot()},[$t,Ot]),t.useEffect(()=>{var e;const t=qt.current;if(t){t.buildScene([bt,kt]);for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&an.current.set(n.id,n.style.fill);ut.current=!0,Ot()}},[Nt,bt,kt,Ot]);const gn=t.useCallback(()=>{var e;const t=qt.current;if(!t)return;t.runLayout([bt,kt]),t.buildScene([bt,kt]),ut.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&an.current.set(n.id,n.style.fill);const n=Array.isArray(ie)?ie:qe,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];an.current.has(t.id)||an.current.set(t.id,n[e%n.length])}if(sn.current=o.length,Jt(t.layoutVersion),je){const{nodes:e,edges:n}=t.getLayoutData();je(e,n)}},[bt,kt,je,ie]),yn=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=qt.current;t&&(t.ingestEdge(e)&&gn(),Ot())},[gn,Ot]),pn=t.useCallback(e=>{const t=qt.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&gn(),Ot()},[gn,Ot]),mn=t.useCallback(()=>{var e,t,n;null===(e=qt.current)||void 0===e||e.clear(),an.current.clear(),sn.current=0,Jt(null!==(n=null===(t=qt.current)||void 0===t?void 0:t.layoutVersion)&&void 0!==n?n:0),Zt(null),rn.current=null,ut.current=!0,Ot()},[Ot]),vn=t.useCallback(()=>{const e=qt.current;e&&(e.tension+=999,gn(),Ot())},[gn,Ot]);t.useImperativeHandle(o,()=>({push:yn,pushMany:pn,removeNode:e=>{var t,n,o;const r=null!==(n=null===(t=qt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(r){const t=(null===(o=rn.current)||void 0===o?void 0:o.data)?"function"==typeof N?N(rn.current.data):rn.current.data[N]:void 0;rn.current&&"node"===rn.current.nodeOrEdge&&t===e&&(rn.current=null,Zt(null)),an.current.delete(e),gn(),ut.current=!0,Ot()}return r},removeEdge:(e,t)=>{var n,o;const r=null!==(o=null===(n=qt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==o&&o;if(r){if(rn.current&&"edge"===rn.current.nodeOrEdge){const n=rn.current.data;let o;o=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!I||!n||("function"==typeof I?I:e=>null==e?void 0:e[I])(n)===e,o&&(rn.current=null,Zt(null))}gn(),ut.current=!0,Ot()}return r},updateNode:(e,t)=>{var n,o;const r=null!==(o=null===(n=qt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==o?o:null;return r&&(ut.current=!0,Ot()),r},updateEdge:(e,t,n)=>{var o,r;const i=null!==(r=null===(o=qt.current)||void 0===o?void 0:o.updateEdge(e,t,n))&&void 0!==r?r:[];return i.length>0&&(gn(),ut.current=!0,Ot()),i},clear:mn,getTopology:()=>{var e,t;return null!==(t=null===(e=qt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=qt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:vn,getTension:()=>{var e,t;return null!==(t=null===(e=qt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[yn,pn,mn,vn,gn,Ot]);const bn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(L),xn=bn?D||(Array.isArray(E)?void 0:E):void 0;t.useEffect(()=>{var e;const t=qt.current;if(t)if(bn&&xn)t.ingestHierarchy(xn,[bt,kt]),t.buildScene([bt,kt]),ut.current=!0,Ot();else{const n=Tt,o=Array.isArray(It)?It:[];if(0===n.length&&0===o.length)return;t.ingestBounded(n,o,[bt,kt]),t.buildScene([bt,kt]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&an.current.set(n.id,n.style.fill+"");const r=Array.isArray(ie)?ie:qe,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];an.current.has(t.id)||an.current.set(t.id,r[e%r.length])}sn.current=i.length,ut.current=!0,Ot()}},[Tt,It,D,xn,bn,bt,kt,zt,Ot,ie]),t.useEffect(()=>{O&&O.length>0&&pn(O)},[]);const kn=t.useCallback(e=>{if(we&&we(e),Me){const t=Date.now();Me(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})}},[we,Me,Ae]),wn=t.useCallback(e=>{if(Se&&Se(e),Me){const t=Date.now();Me(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})}},[Se,Me,Ae]),{hoverHandlerRef:Sn,hoverLeaveRef:Mn,onPointerMove:An,onPointerLeave:jn}=ht;Sn.current=e=>{if(!xe)return;const t=Ht.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-mt.left,r=e.clientY-n.top-mt.top;if(0>o||o>bt||0>r||r>kt)return void(rn.current&&(rn.current=null,Zt(null),kn&&(kn(null),ut.current=!0),Ot()));const i=qt.current;if(!i)return;const a=ct(i.sceneNodes,i.sceneEdges,o,r,30,i.nodeQuadtree,i.maxNodeRadius);if(!a)return void(rn.current&&(rn.current=null,Zt(null),kn&&(kn(null),ut.current=!0),Ot()));const s=f(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});rn.current=s,Zt(s),kn&&(kn(s),ut.current=!0),Ot()},Mn.current=()=>{rn.current&&(rn.current=null,Zt(null),kn&&(kn(null),ut.current=!0),Ot())};const Ln=t.useRef(()=>{});Ln.current=e=>{if(!Se&&!Me)return;const t=Ht.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-mt.left,r=e.clientY-n.top-mt.top;if(0>o||o>bt||0>r||r>kt)return;const i=qt.current;if(!i)return;const a=ct(i.sceneNodes,i.sceneEdges,o,r,30,i.nodeQuadtree,i.maxNodeRadius);wn(a?f(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)};const Cn=t.useCallback(e=>Ln.current(e),[]),En=t.useRef(-1),Dn=t.useRef(null),On=t.useRef(-1),Nn=t.useCallback(e=>{var t;const n=qt.current;if(!n)return;const o=function(e){var t,n,o,r,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!==(r=null===(o=l.datum)||void 0===o?void 0:o.id)&&void 0!==r?r:"_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===o.length)return;const r=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:a}}(o),i=En.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(),En.current=0,On.current=-1;const t=r.flat[0];Dn.current={shape:t.shape,w:t.w,h:t.h};const n=f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return rn.current=n,Zt(n),kn&&(kn(n),ut.current=!0),void Ot()}const a=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}(r,i),s=function(e,t,n,o,r){var i,a,s;const l=n.flat[t.flatIndex];if(!l)return pt(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 o=null!==(a=function(e,t,n){let o=null,r=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const 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 d=s*s+l*l;r>d&&(r=d,o=i)}return o}(n,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n;const o=e+"",r=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,i=vt(t.source),a=vt(t.target),s=null!=i,l=null!=a;s&&i+""===o&&l?r.push(a+""):l&&a+""===o&&s&&r.push(i+"")}return r}(c,o);if(0===e.length)return t.flatIndex;const i=null!==(s=n.idToIdx.get(e[(r.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(r.current=-1,i)}default:{const o=pt(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,a,r,null!==(t=n.sceneEdges)&&void 0!==t?t:[],On);if(null===s)return;if(e.preventDefault(),0>s)return En.current=-1,Dn.current=null,On.current=-1,rn.current=null,Zt(null),kn&&(kn(null),ut.current=!0),void Ot();En.current=s;const l=r.flat[s];Dn.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"};rn.current=c,Zt(c),kn&&(kn(c),ut.current=!0),Ot()},[kn,Ot]),Pn=t.useCallback(e=>{En.current=-1,Dn.current=null,An(e)},[An]);Dt.current=()=>{var e,t,n,o,r,i,a;Ct.current=0;const s=Ht.current;if(!s)return;const l=s.getContext("2d");if(!l)return;const c=qt.current;if(!c)return;const d=performance.now(),u=Ft.current?Math.min((d-Ft.current)/1e3,.1):.016;Ft.current=d;const h=c.advanceTransition(ft.current?d+1e6:d),f=!ft.current&&h,g=!ft.current&&c.tickAnimation([bt,kt],u);(h||ut.current||g)&&c.buildScene([bt,kt]);const p="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,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),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}(s,yt,mt,p))return;if(l.clearRect(-mt.left,-mt.top,yt[0],yt[1]),be){const e=Xt(l,be);e&&(l.fillStyle=e,l.fillRect(0,0,bt,kt))}$e&&c.applyDecay(),ze&&c.applyPulse(d),Xe&&c.applyThresholds(d),c.applyTopologyDiff(d);const m=null!==(e=null==Ye?void 0:Ye.threshold)&&void 0!==e?e:5e3,v=Ye&&c.lastIngestTime>0&&d-c.lastIngestTime>m;if(v&&(l.globalAlpha=null!==(t=null==Ye?void 0:Ye.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":xo(e,n);break;case"line":ko(e,n);break;case"ribbon":wo(e,n);break;case"curved":So(e,n)}}(l,c.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Xt(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=Xt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),mo(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Xt(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=Xt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),vo(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Xt(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=Xt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(l,c.sceneNodes),ee&&c.particlePool&&!v){const e=c.edgesArray;if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:y.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:y.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let d=l;Math.random()<c&&d++;for(let t=0;d>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(c.particlePool,e,u,Wt);const t=.5*(null!==(n=Wt.speedMultiplier)&&void 0!==n?n:1);let o;if(Wt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(u,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:y.radius,l=null!==(a=o.opacity)&&void 0!==a?a:y.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 o.color&&"inherit"!==o.color?o.color:r(l),e.fillStyle=Xt(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,Wt,hn)}}v&&(l.globalAlpha=1);const b=ut.current;if(ut.current=!1,b||f||g){const e=Ht.current;e&&e.setAttribute("aria-label",Qn(null!==(r=null===(o=c.sceneNodes)||void 0===o?void 0:o.length)&&void 0!==r?r:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}const x=b||f||g||Gt.current;x&&d-Yt.current>=33?(tn(e=>e+1),Yt.current=d,Gt.current=!1):Gt.current=!!x,(fn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Gt.current)&&(Ct.current=requestAnimationFrame(()=>Dt.current()))},function(e){const{hydrated:n,wasHydratingFromSSR:o,storeRef:r,dirtyRef:i,renderFnRef:a,cleanup:s}=e;$n(()=>{var e,t;n&&o&&(null===(t=null===(e=r.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),i.current=!0,a.current()},[n,o]);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:Pt,wasHydratingFromSSR:_t,storeRef:qt,dirtyRef:ut,renderFnRef:Dt}),t.useEffect(()=>{ut.current=!0,Ot()},[L,bt,kt,be,Ot]),function(e,n,o,r,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,d=l-s.lastIngestTime>c;d!==i&&(a(d),o.current=!0,r())},1e3);return()=>clearInterval(t)},[e,i,r])}(Ye,qt,ut,Ot,nn,on);const _n=xe&&Qt?e.jsx(jt,{x:Qt.x,y:Qt.y,containerWidth:bt,containerHeight:kt,margin:mt,className:"stream-network-tooltip",zIndex:2,children:ke?ke(Qt):e.jsx(Eo,{data:Qt})}):null;if(Bn||!Pt&&_t){const t=qt.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(L),n=e?D||(Array.isArray(E)?void 0:E):void 0;if(e&&n)t.ingestHierarchy(n,[bt,kt]),t.buildScene([bt,kt]);else{const e=Tt,n=Array.isArray(It)?It:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[bt,kt]),t.buildScene([bt,kt]))}}const n=null!==(d=null==t?void 0:t.sceneNodes)&&void 0!==d?d:[],o=null!==(u=null==t?void 0:t.sceneEdges)&&void 0!==u?u:[],r=null!==(h=null==t?void 0:t.labels)&&void 0!==h?h:[];return e.jsxs("div",{ref:gt,className:"stream-network-frame"+(ve?" "+ve:""),role:"img","aria-label":Ve||("string"==typeof Re?Re:"Network chart"),style:{position:"relative",width:ye?"100%":yt[0],height:pe?"100%":yt[1]},children:[e.jsx(uo,{summary:Ke}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:yt[0],height:yt[1],style:{position:"absolute",left:0,top:0},children:[St&&e.jsx("g",{transform:`translate(${mt.left},${mt.top})`,children:St}),e.jsxs("g",{transform:`translate(${mt.left},${mt.top})`,children:[be&&e.jsx("rect",{x:0,y:0,width:bt,height:kt,fill:be}),o.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 o=t;return e.jsx("path",{d:o.pathD,fill:Wn(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=t;return e.jsx("path",{d:o.pathD,fill:Wn(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=t;return e.jsx("path",{d:o.pathD,fill:Wn(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(t,n)).filter(Boolean),n.map((t,n)=>function(t,n){switch(t.type){case"circle":{const o=t;return e.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Wn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=t;return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Wn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=t,r=s.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(Rn)||"";return e.jsx("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Wn(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}default:return null}}(t,n)).filter(Boolean),r.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(In,{width:bt,height:kt,totalWidth:yt[0],totalHeight:yt[1],margin:mt,labels:r,sceneNodes:n,title:Re,legend:De,legendPosition:Oe,legendLayout:Ne,legendHoverBehavior:Pe,legendClickBehavior:_e,legendHighlightedCategory:Te,legendIsolatedCategories:Ie,foregroundGraphics:at(wt,null===(p=qt.current)||void 0===p?void 0:p.customLayoutOverlays),annotations:Le,autoPlaceAnnotations:Ce,svgAnnotationRules:Ee,annotationFrame:0})]})}const Tn=qt.current;return e.jsxs("div",{ref:gt,className:"stream-network-frame"+(ve?" "+ve:""),role:"group","aria-label":Ve||("string"==typeof Re?Re:"Network chart"),tabIndex:0,style:{position:"relative",width:ye?"100%":yt[0],height:pe?"100%":yt[1],overflow:"visible"},onKeyDown:Nn,children:[Ge&&e.jsx(ho,{tableId:Lt}),Ge&&e.jsx(co,{nodes:null!==(m=null==Tn?void 0:Tn.sceneNodes)&&void 0!==m?m:[],edges:null!==(v=null==Tn?void 0:Tn.sceneEdges)&&void 0!==v?v:[],chartType:"Network chart",tableId:Lt,chartTitle:"string"==typeof Re?Re:void 0}),e.jsx(uo,{summary:Ke}),e.jsx(fo,{hoverPoint:Qt}),e.jsxs("div",{role:"img","aria-label":Ve||("string"==typeof Re?Re:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:xe?Pn:void 0,onMouseLeave:xe?jn:void 0,onClick:Se||Me?Cn:void 0,children:[St&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:yt[0],height:yt[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${mt.left},${mt.top})`,children:St})}),e.jsx("canvas",{ref:Ht,"aria-label":Qn(null!==(x=null===(b=null==Tn?void 0:Tn.sceneNodes)||void 0===b?void 0:b.length)&&void 0!==x?x:0,null!==(w=null===(k=null==Tn?void 0:Tn.sceneEdges)||void 0===k?void 0:k.length)&&void 0!==w?w:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(In,{width:bt,height:kt,totalWidth:yt[0],totalHeight:yt[1],margin:mt,labels:(null==Tn?void 0:Tn.labels)||[],sceneNodes:null==Tn?void 0:Tn.sceneNodes,title:Re,legend:De,legendPosition:Oe,legendLayout:Ne,legendHoverBehavior:Pe,legendClickBehavior:_e,legendHighlightedCategory:Te,legendIsolatedCategories:Ie,foregroundGraphics:at(wt,null===(S=qt.current)||void 0===S?void 0:S.customLayoutOverlays),annotations:Le,autoPlaceAnnotations:Ce,svgAnnotationRules:Ee,annotationFrame:en}),e.jsx(xt,{active:En.current>=0,hoverPoint:Qt,margin:mt,size:yt,shape:null===(M=Dn.current)||void 0===M?void 0:M.shape,width:null===(A=Dn.current)||void 0===A?void 0:A.w,height:null===(j=Dn.current)||void 0===j?void 0:j.h}),_n,(null==Ye?void 0:Ye.showBadge)&&e.jsx(Kt,{isStale:nn,position:Ye.badgePosition})]})]})});function Oo(e,n){const{variant:o,frameRef:r,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,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,r;return null!==(r=null===(o=e.current)||void 0===o?void 0:o.update(t,n))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==n?n:null}}}if("network"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o,r,i,a;const s=Array.isArray(t)?t:[t],l=null!==(r=null===(o=null===(n=e.current)||void 0===n?void 0:n.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==r?r:[],c=[];for(const t of 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 o;const r=null===(o=e.current)||void 0===o?void 0:o.updateNode(t,n);return r?[Object.assign(Object.assign({},r),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n,o,r;return null!==(r=null===(o=null===(n=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==r?r:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,r,i;const a=null!==(r=null===(o=e.current)||void 0===o?void 0:o.removePoint(t))&&void 0!==r?r:[];for(const t of a)null===(i=e.current)||void 0===i||i.push(n(t));return a},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]}}}const n=t;return{push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,r,i;const a=null!==(r=null===(o=n.current)||void 0===o?void 0:o.removeLine(e))&&void 0!==r?r:[];for(const e of a)null===(i=n.current)||void 0===i||i.pushLine(t(e));return a},clear:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getLines())&&void 0!==t?t:[]}}}(o,r);return Object.assign(Object.assign({},e),i)},null!=a?a:[])}Do.displayName="StreamNetworkFrame";const No=t.createContext(null);function Po(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function _o(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[To,Io]=Lt(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=_o(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=_o(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Ro,Wo]=Lt(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 Bo={positions:new Map};const $o=new Set;function zo(){for(const e of $o)e()}function Ho(e,t){const n=Bo.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Bo.positions);o.delete(e),Bo={positions:o},zo()}function Fo(e){const n=t.useId(),o=e.clientId||n,{name:r}=e,i=Io(e=>e.selections.get(r)),a=Io(e=>e.setClause),s=Io(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[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Po(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(r,{clientId:o,type:"point",fields:t})},[o,r,a]),selectInterval:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(r,{clientId:o,type:"interval",fields:t})},[o,r,a]),clear:t.useCallback(()=>{s(r,o)},[s,r,o]),clientId:o}}const Yo=t.createContext(!1),Xo=t.createContext(null),Go="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function qo(e,t,n){var o;const r=null!==(o=e.xValue)&&void 0!==o?o:null==t?void 0:t[n];if(null==r)return null;const i=Number(r);return Number.isFinite(i)?i:null}function Vo(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 Ko(){var e;const t=Rt(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 Qo(e,t,n,o,r){let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=Ge[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function Zo({selection:e,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:a,chartId:s,onClick:l,hoverHighlight:c,colorByField:d}){const u=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,seriesField:e.seriesField}:null}(n,o),f="series"===(null==h?void 0:h.mode)?[h.seriesField||d||o[0]].filter(e=>!!e):(null==h?void 0:h.fields)||o||[],g=Fo({name:(null==e?void 0:e.name)||"__unused__"}),y=function(e){const n=e.name||"hover",{fields:o}=e,{predicate:r,isActive:i,selectPoints:a,clear:s}=Fo({name:n});return{onHover:t.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&a(t)},[o,a,s,n]),predicate:r,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:f}),p=Wo(e=>e.pushObservation),m=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,b]=t.useState(null),x=d||o[0],k=t.useMemo(()=>{if(!c||null==v||!x)return null;const e=v,t=x;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,v,x]),w=t.useCallback(e=>{var t,o;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=qo(e,t,h.xField);null!=n&&function(e,t,n){const o=Bo.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Bo={positions:new Map(Bo.positions).set(e,{xValue:t,sourceId:n})},zo())}(h.name||"hover",n,u)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Ho(h.name||"hover",u),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&x)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[x];b(null!=n?n+"":null)}else b(null);if(i||p){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const r=Vo(e),a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,y,h,u,i,a,s,p,c,x]),S=t.useCallback(e=>{var t,n,o,r;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=qo(e,t,h.xField);null!=n&&function(e,t,n){const o=Bo.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Bo.positions);return t.delete(e),Bo={positions:t},zo(),!1}Bo={positions:new Map(Bo.positions).set(e,{xValue:t,sourceId:n,locked:!0})},zo()}(h.name||"hover",n,u)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){const n=Vo(e),a=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,a,s,h,u]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{!function(e,t){const n=Bo.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Bo.positions);o.delete(e),Bo={positions:o},zo()}(e,u),Ho(e,u)}},[null==h?void 0:h.mode,null==h?void 0:h.name,u]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:w,customClickBehavior:S,crosshairSourceId:u}}function Uo({data:e,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(Yo),d=null!==t.useContext(Xo),u=void 0!==r?r:!c&&!!n,h=!!n&&(u||d),f=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const o of e){const e="function"==typeof n?n(o):o[n];null!=e&&t.add(e+"")}return Array.from(t)},[l,n,e,h]);!function(e){const n=t.useContext(Xo),o=t.useId(),r=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),i=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,r)||(i.current=r);const a=i.current;Go(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),Go(()=>{n&&n.registerCategories(o,a)},[n,o,a])}(d&&n?f:[]);const g=t.useMemo(()=>{if(!u||!n)return;const t=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,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((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=a?o(a,t,n):n?n(r):Ve[i%Ve.length];return{label:r+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:s,label:""}]}}({data:e,colorBy:n,colorScale:o,getColor:Ze,categories:f});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[u,n,e,o,f]),y=t.useMemo(()=>{const e="number"==typeof a?{top:a,bottom:a,left:a,right:a}:null!=a?a:{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];return g&&("right"===i&&!o("right")&&110>n.right?n.right=110:"left"===i&&!o("left")&&110>n.left?n.left=110:"top"===i&&!o("top")&&50>n.top?n.top=50:"bottom"===i&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,a,g,i]);return{legend:g,margin:y,legendPosition:i}}u.createContext(void 0);const Jo={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 er(e,t,n){var o,r,i,a,s,l,c;const d=Jo[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?d.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?d.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:d.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:d.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||d.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:d.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:d.showLabels,title:u?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:tr(d.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:u}}function tr(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function nr(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function or(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function rr(e){return"function"==typeof e?e:t=>t[e]||1}function ir({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},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=Ze(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ze(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function ar({componentName:t,message:n,diagnosticHint:o,width:r,height:i}){return e.jsx("div",{role:"alert",style:{width:r,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}),o&&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:o})]})})}class sr extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.jsx(ar,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function lr({componentName:t,width:n,height:o,children:r}){return e.jsx(sr,{fallback:r=>e.jsx(ar,{componentName:t,message:r.message,width:n,height:o}),children:r})}"undefined"!=typeof process&&process;const cr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},dr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ur(n){const{nodes:o,edges:r,inferNodes:i=!0,sourceAccessor:a="source",targetAccessor:s="target",colorBy:l,colorScheme:c,showLegend:d,legendPosition:u,legendInteraction:h,selection:f,linkedHover:g,onObservation:y,onClick:p,chartType:m,chartId:v,marginDefaults:b,userMargin:x,width:k,height:w,loading:S,loadingContent:M,emptyContent:A,emptyDataKey:j="edges"}=n,L=t.useMemo(()=>yo(r),[r]),C=t.useMemo(()=>yo(o),[o]),E=function(t,n,o,r){if(!t)return null;if(!1===r)return null;if(null!=r)return e.jsx("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const i=Math.min(5,Math.floor(o/40)),a=Math.max(8,Math.floor(o/(3*i))),s=Math.max(6,Math.floor(o/(2.5*i))),l=Math.floor((o-(i*(a+s)-s))/2);return e.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,o)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},dr),{position:"absolute",top:l+o*(a+s),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:a,opacity:.5+o%2*.2})},o))})}(S,k,w,M),D=E?null:function(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},cr),{width:n,height:o}),children:r||"No data available"}):null}("nodes"===j?void 0===o?void 0:C:void 0===r?void 0:L,k,w,A),O=t.useMemo(()=>i?or(C,L,a,s):C,[i,C,L,a,s]),N=function(e,n,o){const r=t.useContext(No),i=Ko();return t.useMemo(()=>{var t;if(!n)return;const a=null!==(t=null!=o?o: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(r&&Object.keys(r).length>0){const e=Ue(t.map(e=>({_cat:e})),"_cat",a);return t=>r[t]||e(t)}return Ue(t.map(e=>({_cat:e})),"_cat",a)}if(r&&Object.keys(r).length>0){const t=Ue(e,n,a);return e=>r[e]||t(e)}return Ue(e,n,a)}if(r&&Object.keys(r).length>0){const e=Ue([{_:"a"}],"_",a);return t=>r[t]||e(t)}},[e,n,o,r,i])}(O,l,c),P=Ko(),_=t.useMemo(()=>{if(Array.isArray(c))return c;if(P&&P.length>0)return P;if("string"==typeof c){const e=Ge[c];if(Array.isArray(e)&&e.length>0)return e}return qe},[c,P]),T=t.useMemo(()=>{if(!l)return[];const e=new Set;for(const t of O){const n="function"==typeof l?l(t):t[l];null!=n&&e.add(n+"")}return Array.from(e)},[O,l]),I=function(e,n,o){const[r,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===o.length?new Set:n})},[e,o.length]),d=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===r}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const o=t?e[t]:"function"==typeof n?n(e):null;return a.has(o)}}:null},[e,n,r,a]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:d}}(h,l,T),{legend:R,margin:W,legendPosition:B}=Uo({data:O,colorBy:l,colorScale:N,showLegend:d,legendPosition:u,userMargin:x,defaults:b,categories:T}),$=Zo({selection:f,linkedHover:g,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:y,onClick:p,chartType:m,chartId:v}),{customHoverBehavior:z,customClickBehavior:H,activeSelectionHook:F,hoverSelectionHook:Y,crosshairSourceId:X}=$;return{safeNodes:O,safeEdges:L,colorScale:N,effectivePalette:_,themeCategorical:P,allCategories:T,legendState:I,legend:R,margin:W,legendPosition:B,customHoverBehavior:z,customClickBehavior:H,activeSelectionHook:F,hoverSelectionHook:Y,crosshairSourceId:X,loadingEl:E,emptyEl:D}}function hr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}function fr(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function gr(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let o,r=n+1;for(const n of t){const t=fr(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function yr({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 pr({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=gr(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}const mr=t.forwardRef(function(n,o){var r;const i=t.useRef(null);Oo(o,{variant:"network",frameRef:i});const a=er(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:d,nodeIdAccessor:u,nodeIDAccessor:h,sourceAccessor:f="source",targetAccessor:g="target",nodeLabel:y,colorBy:p,colorScheme:m,nodeSize:v=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:k="#999",edgeOpacity:w=.6,iterations:S=300,forceStrength:M=.1,tooltip:A,frameProps:j={},onObservation:L,onClick:C,chartId:E,selection:D,linkedHover:O,loading:N,loadingContent:P,emptyContent:_,legendInteraction:T,legendPosition:I,stroke:R,strokeWidth:W,opacity:B}=n,$=null!==(r=null!=u?u:h)&&void 0!==r?r:"id",{width:z,height:H,enableHover:F,showLegend:Y,showLabels:X=!1,title:G,description:q,summary:V,accessibleTable:K}=a,Q=ur({nodes:s,edges:l,inferNodes:!1,sourceAccessor:f,targetAccessor:g,colorBy:p,colorScheme:m,showLegend:Y,legendPosition:I,legendInteraction:T,selection:D,linkedHover:O,onObservation:L,onClick:C,chartType:"ForceDirectedGraph",chartId:E,marginDefaults:a.marginDefaults,userMargin:c,width:z,height:H,loading:N,loadingContent:P,emptyContent:_,emptyDataKey:"nodes"}),Z=t.useMemo(()=>new Map,[]),U=t.useMemo(()=>e=>{const t={};return t.fill=p?Ze(e.data||e,p,Q.colorScale):Qo(0,Q.themeCategorical,m),"number"==typeof v&&(t.r=v),t},[p,Q.colorScale,v,Q.themeCategorical,m,Z]),J=t.useMemo(()=>hr(U,{stroke:R,strokeWidth:W,opacity:B}),[U,R,W,B]),ee=t.useMemo(()=>e=>({stroke:k,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:w}),[x,k,w]),te=t.useMemo(()=>hr(ee,{stroke:R,strokeWidth:W,opacity:B}),[ee,R,W,B]),ne=t.useMemo(()=>{if(X&&y)return"function"==typeof y?y:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[y])&&void 0!==n?n:e[y])&&void 0!==o?o:e.id}},[X,y]),oe=pr({componentName:"ForceDirectedGraph",nodes:s,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:$}});return oe?e.jsx(ar,{componentName:"ForceDirectedGraph",message:oe,width:z,height:H}):Q.loadingEl?Q.loadingEl:Q.emptyEl?Q.emptyEl:e.jsx(lr,{componentName:"ForceDirectedGraph",width:z,height:H,children:e.jsx(Do,Object.assign({ref:i,chartType:"force"},null!=s&&{nodes:Q.safeNodes},null!=l&&{edges:Q.safeEdges},{size:[z,H],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Q.margin,nodeIDAccessor:$,sourceAccessor:f,targetAccessor:g,iterations:S,forceStrength:M,nodeStyle:J,edgeStyle:te,colorBy:p,colorScheme:Q.effectivePalette,nodeSize:v,nodeSizeRange:b,nodeLabel:ne,showLabels:X,enableHover:F,tooltipContent:!1===A?()=>null:At(A)||void 0,customHoverBehavior:O||L||C?Q.customHoverBehavior:void 0,customClickBehavior:L||C?Q.customClickBehavior:void 0,legend:Q.legend,legendPosition:Q.legendPosition},T&&"none"!==T&&{legendHoverBehavior:Q.legendState.onLegendHover,legendClickBehavior:Q.legendState.onLegendClick,legendHighlightedCategory:Q.legendState.highlightedCategory,legendIsolatedCategories:Q.legendState.isolatedCategories},{className:d,title:G,description:q,summary:V,accessibleTable:K},null!=n.animate&&{animate:n.animate},j))})});mr.displayName="ForceDirectedGraph";const vr=t.forwardRef(function(n,o){const r=t.useRef(null);Oo(o,{variant:"network",frameRef:r,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const i=er(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:d="source",targetAccessor:u="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",orientation:m="horizontal",nodeAlign:v="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,edgeOpacity:w=.5,edgeSort:S,tooltip:M,frameProps:A={},onObservation:j,onClick:L,chartId:C,selection:E,linkedHover:D,loading:O,loadingContent:N,emptyContent:P,showLegend:_,legendPosition:T,legendInteraction:I,stroke:R,strokeWidth:W,opacity:B}=n,{width:$,height:z,enableHover:H,showLabels:F=!0,title:Y,description:X,summary:G,accessibleTable:q}=i,V=ur({nodes:a,edges:s,inferNodes:!0,sourceAccessor:d,targetAccessor:u,colorBy:g,colorScheme:y,showLegend:_,legendPosition:T,legendInteraction:I,selection:E,linkedHover:D,onObservation:j,onClick:L,chartType:"SankeyDiagram",chartId:C,marginDefaults:i.marginDefaults,userMargin:l,width:$,height:z,loading:O,loadingContent:N,emptyContent:P}),K=t.useMemo(()=>new Map,[]),Q=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Ze(e.data||e,g,V.colorScale):Qo(0,V.themeCategorical,y),t},[g,V.colorScale,V.themeCategorical,y,K]),Z=t.useMemo(()=>hr(Q,{stroke:R,strokeWidth:W,opacity:B}),[Q,R,W,B]),U=t.useMemo(()=>ir({edgeColorBy:p,colorBy:g,colorScale:V.colorScale,nodeStyleFn:Z,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[p,g,V.colorScale,Z,w]),J=t.useMemo(()=>hr(U,{stroke:R,strokeWidth:W,opacity:B}),[U,R,W,B]),ee=t.useMemo(()=>{if(!F)return;const e=k||f;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[F,k,f]),te=pr({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return te?e.jsx(ar,{componentName:"SankeyDiagram",message:te,width:$,height:z}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:e.jsx(lr,{componentName:"SankeyDiagram",width:$,height:z,children:e.jsx(Do,Object.assign({ref:r,chartType:"sankey"},V.safeNodes.length>0&&{nodes:V.safeNodes},null!=s&&{edges:V.safeEdges},{size:[$,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:V.margin,nodeIDAccessor:f,sourceAccessor:d,targetAccessor:u,valueAccessor:h,orientation:m,nodeAlign:v,nodePaddingRatio:b,nodeWidth:x,nodeStyle:Z,edgeStyle:J,colorBy:g,colorScheme:V.effectivePalette,edgeColorBy:p,edgeOpacity:w,edgeSort:S,nodeLabel:ee,showLabels:F,enableHover:H,tooltipContent:!1===M?()=>null:At(M)||void 0,customHoverBehavior:D||j||L?V.customHoverBehavior:void 0,customClickBehavior:j||L?V.customClickBehavior:void 0,legend:V.legend,legendPosition:V.legendPosition},I&&"none"!==I&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},{className:c,title:Y,description:X,summary:G,accessibleTable:q},null!=n.animate&&{animate:n.animate},A))})});vr.displayName="SankeyDiagram";const br=t.forwardRef(function(n,o){const r=t.useRef(null);Oo(o,{variant:"network",frameRef:r,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const i=er(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:d="source",targetAccessor:u="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",padAngle:m=.01,groupWidth:v=20,sortGroups:b,nodeLabel:x,edgeOpacity:k=.5,tooltip:w,frameProps:S={},onObservation:M,onClick:A,chartId:j,selection:L,linkedHover:C,loading:E,loadingContent:D,emptyContent:O,legendInteraction:N,stroke:P,strokeWidth:_,opacity:T}=n,{width:I,height:R,enableHover:W,showLabels:B=!0,title:$,description:z,summary:H,accessibleTable:F}=i,Y=ur({nodes:a,edges:s,inferNodes:!0,sourceAccessor:d,targetAccessor:u,colorBy:g,colorScheme:y,showLegend:!1,legendInteraction:N,selection:L,linkedHover:C,onObservation:M,onClick:A,chartType:"ChordDiagram",chartId:j,marginDefaults:i.marginDefaults,userMargin:l,width:I,height:R,loading:E,loadingContent:D,emptyContent:O}),X=t.useMemo(()=>new Map,[]),G=Y.safeNodes.length>0,q=t.useMemo(()=>{if(G)return(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(g)r.fill=Ze(e.data||e,g,Y.colorScale);else{const i=Array.isArray(y)?y:Ge[y]||qe,a=Array.isArray(i)?i:qe,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r}},[G,g,Y.colorScale,y]),V=t.useMemo(()=>q?hr(q,{stroke:P,strokeWidth:_,opacity:T}):void 0,[q,P,_,T]),K=t.useMemo(()=>{if(G)return ir({edgeColorBy:p,colorBy:g,colorScale:Y.colorScale,nodeStyleFn:V||(e=>({fill:Qo(0,Y.themeCategorical,y)})),edgeOpacity:k,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:k}})},[G,p,g,Y.colorScale,V,k,Y.themeCategorical,y,X]),Q=t.useMemo(()=>K?hr(K,{stroke:P,strokeWidth:_,opacity:T}):void 0,[K,P,_,T]),Z=t.useMemo(()=>{if(!B)return;const e=x||f;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[B,x,f]),U=pr({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return U?e.jsx(ar,{componentName:"ChordDiagram",message:U,width:I,height:R}):Y.loadingEl?Y.loadingEl:Y.emptyEl?Y.emptyEl:e.jsx(lr,{componentName:"ChordDiagram",width:I,height:R,children:e.jsx(Do,Object.assign({ref:r,chartType:"chord"},Y.safeNodes.length>0&&{nodes:Y.safeNodes},null!=s&&{edges:Y.safeEdges},{size:[I,R],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Y.margin,nodeIDAccessor:f,sourceAccessor:d,targetAccessor:u,valueAccessor:h,padAngle:m,groupWidth:v,sortGroups:b,nodeStyle:V,edgeStyle:Q,colorBy:g,colorScheme:Y.effectivePalette,edgeColorBy:p,edgeOpacity:k,nodeLabel:Z,showLabels:B,enableHover:W,tooltipContent:!1===w?()=>null:At(w)||void 0,customHoverBehavior:C||M||A?Y.customHoverBehavior:void 0,customClickBehavior:M||A?Y.customClickBehavior:void 0},N&&"none"!==N&&{legendHoverBehavior:Y.legendState.onLegendHover,legendClickBehavior:Y.legendState.onLegendClick,legendHighlightedCategory:Y.legendState.highlightedCategory,legendIsolatedCategories:Y.legendState.isolatedCategories},{className:c,title:$,description:z,summary:H,accessibleTable:F},null!=n.animate&&{animate:n.animate},S))})});function xr(n){const o=er(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:r,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:d="value",nodeIdAccessor:u="name",colorBy:h,colorScheme:f,colorByDepth:g=!1,edgeStyle:y="curve",nodeLabel:p,nodeSize:m=5,tooltip:v,frameProps:b={},onObservation:x,onClick:k,chartId:w,selection:S,linkedHover:M,loading:A,loadingContent:j,legendInteraction:L,stroke:C,strokeWidth:E,opacity:D}=n,{width:O,height:N,enableHover:P,showLabels:_=!0,title:T,description:I,summary:R,accessibleTable:W}=o,B=ur({nodes:t.useMemo(()=>nr(null!=r?r:null,c),[r,c]),edges:void 0,inferNodes:!1,colorBy:g?void 0:h,colorScheme:f,showLegend:!1,legendInteraction:L,selection:S,linkedHover:M,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:o.marginDefaults,userMargin:i,width:O,height:N,loading:A,loadingContent:j}),$=t.useMemo(()=>new Map,[]),z=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?Ke[(e.depth||0)%Ke.length]:h?Ze(e.data||e,h,B.colorScale):Qo(0,B.themeCategorical,f),t},[h,g,B.colorScale,B.themeCategorical,f,$]),H=t.useMemo(()=>hr(z,{stroke:C,strokeWidth:E,opacity:D}),[z,C,E,D]),F=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),Y=t.useMemo(()=>hr(F,{stroke:C,strokeWidth:E,opacity:D}),[F,C,E,D]),X=t.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return rr(d)},[s,d]),G=yr({componentName:"TreeDiagram",data:r});return G?e.jsx(ar,{componentName:"TreeDiagram",message:G,width:O,height:N}):B.loadingEl?B.loadingEl:e.jsx(lr,{componentName:"TreeDiagram",width:O,height:N,children:e.jsx(Do,Object.assign({chartType:s},null!=r&&{data:r},{size:[O,N],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:B.margin,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:X,treeOrientation:l,edgeType:y,nodeStyle:H,edgeStyle:Y,colorBy:h,colorScheme:B.effectivePalette,colorByDepth:g,nodeSize:m,nodeLabel:_?p||u:void 0,showLabels:_,enableHover:P,tooltipContent:!1===v?()=>null:At(v)||void 0,customHoverBehavior:M||x||k?B.customHoverBehavior:void 0,customClickBehavior:x||k?B.customClickBehavior:void 0},L&&"none"!==L&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},{className:a,title:T,description:I,summary:R,accessibleTable:W},null!=n.animate&&{animate:n.animate},b))})}function kr(n){const o=er(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:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:u,colorByDepth:h=!1,labelMode:f="leaf",nodeLabel:g,padding:y=4,paddingTop:p,nodeStyle:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:S,chartId:M,loading:A,loadingContent:j,legendInteraction:L,stroke:C,strokeWidth:E,opacity:D}=n,{nodeStyle:O}=b,N=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(b,["nodeStyle"]),{width:P,height:_,enableHover:T,showLabels:I=!0,title:R,description:W,summary:B,accessibleTable:$}=o,z=ur({nodes:t.useMemo(()=>nr(null!=r?r:null,s),[r,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:d,colorScheme:u,showLegend:!1,legendInteraction:L,selection:x,linkedHover:k,onObservation:w,onClick:S,chartType:"Treemap",chartId:M,marginDefaults:o.marginDefaults,userMargin:i,width:P,height:_,loading:A,loadingContent:j}),H=function(e){const n=Rt(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,o;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!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:n})},[e,n])}(x),F=z.customHoverBehavior,Y=t.useCallback(e=>{if(!e)return F(null);const t=e.data||e;F({data:(null==t?void 0:t.data)||t})},[F]),X=t.useMemo(()=>new Map,[]),G=t.useMemo(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=h?Ke[(e.depth||0)%Ke.length]:d?Ze(e.data||e,d,z.colorScale):Qo(0,z.themeCategorical,u),t},[d,h,z.colorScale,z.themeCategorical,u,X]),q=t.useMemo(()=>m||O?e=>{var t,n;return Object.assign(Object.assign(Object.assign({},G(e)),O&&null!==(t=O(e))&&void 0!==t?t:{}),m&&null!==(n=m(e))&&void 0!==n?n:{})}:G,[G,m,O]),V=t.useMemo(()=>hr(q,{stroke:C,strokeWidth:E,opacity:D}),[q,C,E,D]),K=t.useMemo(()=>z.activeSelectionHook?e=>{var t;const n=Object.assign({},V(e));if(z.activeSelectionHook.isActive)if(z.activeSelectionHook.predicate(e.data||e))(null==H?void 0:H.selectedStyle)&&Object.assign(n,H.selectedStyle);else{const e=null!==(t=null==H?void 0:H.unselectedOpacity)&&void 0!==t?t:.5;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==H?void 0:H.unselectedStyle)&&Object.assign(n,H.unselectedStyle)}return n}:V,[V,z.activeSelectionHook,H]),Q=t.useMemo(()=>rr(l),[l]),Z=void 0!==p?p:!I||"parent"!==f&&"all"!==f?void 0:18,U=yr({componentName:"Treemap",data:r});return U?e.jsx(ar,{componentName:"Treemap",message:U,width:P,height:_}):z.loadingEl?z.loadingEl:e.jsx(lr,{componentName:"Treemap",width:P,height:_,children:e.jsx(Do,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[P,_],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:z.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:Q,padding:y,paddingTop:Z,nodeStyle:K,colorBy:d,colorScheme:z.effectivePalette,colorByDepth:h,nodeLabel:I?g||c:void 0,showLabels:I,labelMode:f,enableHover:T,tooltipContent:!1===v?()=>null:At(v)||void 0},(k||w||S)&&{customHoverBehavior:Y},(w||S)&&{customClickBehavior:z.customClickBehavior},L&&"none"!==L&&{legendHoverBehavior:z.legendState.onLegendHover,legendClickBehavior:z.legendState.onLegendClick,legendHighlightedCategory:z.legendState.highlightedCategory,legendIsolatedCategories:z.legendState.isolatedCategories},{className:a,title:R,description:W,summary:B,accessibleTable:$},null!=n.animate&&{animate:n.animate},N))})}function wr(n){const o=er(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:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:d,colorScheme:u,colorByDepth:h=!1,nodeLabel:f,circleOpacity:g=.7,padding:y=4,tooltip:p,frameProps:m={},onObservation:v,onClick:b,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:M,legendInteraction:A,stroke:j,strokeWidth:L,opacity:C}=n,{width:E,height:D,enableHover:O,showLabels:N=!0,title:P,description:_,summary:T,accessibleTable:I}=o,R=ur({nodes:t.useMemo(()=>nr(null!=r?r:null,s),[r,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:d,colorScheme:u,showLegend:!1,legendInteraction:A,selection:k,linkedHover:w,onObservation:v,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:o.marginDefaults,userMargin:i,width:E,height:D,loading:S,loadingContent:M}),W=t.useMemo(()=>new Map,[]),B=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?Ke[(e.depth||0)%Ke.length]:d?Ze(e.data||e,d,R.colorScale):Qo(0,R.themeCategorical,u),t},[d,h,R.colorScale,g,R.themeCategorical,u,W]),$=t.useMemo(()=>hr(B,{stroke:j,strokeWidth:L,opacity:C}),[B,j,L,C]),z=t.useMemo(()=>rr(l),[l]),H=yr({componentName:"CirclePack",data:r});return H?e.jsx(ar,{componentName:"CirclePack",message:H,width:E,height:D}):R.loadingEl?R.loadingEl:e.jsx(lr,{componentName:"CirclePack",width:E,height:D,children:e.jsx(Do,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[E,D],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:R.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:z,padding:y,nodeStyle:$,colorBy:d,colorScheme:R.effectivePalette,colorByDepth:h,nodeLabel:N?f||c:void 0,showLabels:N,enableHover:O,tooltipContent:!1===p?()=>null:At(p)||void 0,customHoverBehavior:w||v||b?R.customHoverBehavior:void 0,customClickBehavior:v||b?R.customClickBehavior:void 0},A&&"none"!==A&&{legendHoverBehavior:R.legendState.onLegendHover,legendClickBehavior:R.legendState.onLegendClick,legendHighlightedCategory:R.legendState.highlightedCategory,legendIsolatedCategories:R.legendState.isolatedCategories},{className:a,title:P,description:_,summary:T,accessibleTable:I},null!=n.animate&&{animate:n.animate},m))})}br.displayName="ChordDiagram",xr.displayName="TreeDiagram","function"==typeof SuppressedError&&SuppressedError,kr.displayName="Treemap",wr.displayName="CirclePack";const Sr=Ke;function Mr(n){const o=er(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:r,margin:i,className:a,childrenAccessor:s="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:d,colorByDepth:u=!1,orbitMode:h="flat",orbitSize:f=2.95,speed:g=.25,revolution:y,revolutionStyle:p,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:S,annotations:M,frameProps:A={},onObservation:j,onClick:L,chartId:C,selection:E,linkedHover:D,loading:O,loadingContent:N,stroke:P,strokeWidth:_,opacity:T}=n,{width:I,height:R,enableHover:W,title:B,description:$,summary:z,accessibleTable:H}=o,F=ur({nodes:t.useMemo(()=>nr(r,s),[r,s]),edges:void 0,inferNodes:!1,colorBy:u?void 0:c,colorScheme:d,showLegend:!1,legendInteraction:void 0,selection:E,linkedHover:D,onObservation:j,onClick:L,chartType:"OrbitDiagram",chartId:C,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:i,width:I,height:R,loading:O,loadingContent:N}),Y=t.useMemo(()=>new Map,[]),{colorScale:X,customClickBehavior:G,customHoverBehavior:q,themeCategorical:V}=F,K=t.useMemo(()=>{if(Array.isArray(d))return d;const e=Ge[d];return Array.isArray(e)?e:qe},[d]),Q=t.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=u?o?K[0]:Sr[(e.depth||0)%Sr.length]:c?Ze(e.data||e,c,X):Qo(0,V,d),n.opacity=o?1:.85,n},[c,u,X,K,V,d,Y]),Z=t.useMemo(()=>hr(Q,{stroke:P,strokeWidth:_,opacity:T}),[Q,P,_,T]),U=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),J=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]),ee=t.useMemo(()=>{if(G)return e=>{G(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[G]),te=yr({componentName:"OrbitDiagram",data:r});return te?e.jsx(ar,{componentName:"OrbitDiagram",message:te,width:I,height:R}):F.loadingEl?F.loadingEl:e.jsx(lr,{componentName:"OrbitDiagram",width:I,height:R,children:e.jsx(Do,Object.assign({chartType:"orbit"},null!=r&&{data:r},{size:[I,R],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:F.margin,nodeIDAccessor:l,childrenAccessor:s,nodeStyle:Z,edgeStyle:U,colorBy:c,colorScheme:F.effectivePalette,colorByDepth:u,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&W,tooltipContent:k?void 0:!1===w?()=>null:At(w)||void 0,customHoverBehavior:D||j||L?J:void 0,customClickBehavior:j||L?ee:void 0,foregroundGraphics:S,annotations:M,className:a,title:B,description:$,summary:z,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:H},null!=n.animate&&{animate:n.animate},A))})}function Ar(e,t,n){const o=[],r=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,a=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&a&&a&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||o.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}function jr(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 Lr(e,t,n){const o=t.incoming[e.id],r=t.outgoing[e.id],i=[];for(const e of o)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const a={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},s=()=>{i.sort((e,t)=>{var n,o;return e.time-t.time||(null!==(n=a[e.kind])&&void 0!==n?n:99)-(null!==(o=a[t.kind])&&void 0!==o?o:99)})},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,d=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,u=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;u.length>e;e++)h.set(u[e],u[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=d?d:e};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",o=Math.min(n,"top"===t?y:p);if(o>0){const r=f(e.time);g.push({time:r,delta:-o,kind:"transfer-out",side:t}),g.push({time:r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:p-=o,"top"===e.side?y+=o:p+=o,n-=o}n>0&&null!==d&&(g.push({time:d,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:p+=n)}"top"===e.side?y-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:p+=t}i.push(...g),s();let m=0,v=0,b=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:m,botMass:v}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:v;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?m+=e.delta:v+=e.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:e.time,topMass:m,botMass:v})}const M=[];let A=0;for(;w.length>A;){let e=A;for(;w.length>e+1&&w[e+1].t===w[A].t;)e++;M.push(w[A]);for(let t=A+1;e>=t;t++){const e=M[M.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||M.push(w[t])}A=e+1}const j=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let L=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===L||L>e.systemInTime)&&(L=e.systemInTime);let C=null;for(const e of o)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===C||e.systemOutTime>C)&&(C=e.systemOutTime);if(M.length>0){const e=M[M.length-1],t=Math.max(null!=j?j:-1/0,null!=C?C:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&M.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=M[0],o=Math.min(null!=c?c:1/0,null!=L?L:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&M.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:M,peak:b,topPeak:x,botPeak:k,localAttachments:S}}function Cr(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Er(e,t){return e.map(e=>({t:Cr(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Dr(e,t,n){const o=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}function Or(e,t){let n=0;for(let o=0;t.length>o;o++)for(let r=o+1;t.length>r;r++){const i=t[o],a=t[r];i.source!==a.source&&i.target!==a.target&&i.source!==a.target&&i.target!==a.source&&(Math.min(i.endTime,a.endTime)>Math.max(i.startTime,a.startTime)&&e[a.source]>e[i.source]!=e[a.target]>e[i.target]&&n++)}return n}function Nr(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function Pr(e,t){return 1e3*Or(e,t)+Nr(e,t)}function _r(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function Tr(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=_r(e,t),a=Pr(t,n);for(let s=0;o>s;s++){const o=Array(r).fill(0),s=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];o[n]+=r*(e.value||1),s[n]+=e.value||1,o[r]+=n*(e.value||1),s[r]+=e.value||1}const l=Array.from({length:r},(e,t)=>t).sort((e,t)=>(s[e]>0?o[e]/s[e]:e)-(s[t]>0?o[t]/s[t]:t)),c=l.map(t=>e[t]),d=new Map;l.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t);const u=Pr(t,n);if(a>u)a=u,i=_r(e,t);else if(u===a)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=Pr(t,n);for(let a=0;o>a;a++){let o=!1;for(let a=0;r-1>a;a++){const r=e[a];e[a]=e[a+1],e[a+1]=r;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const s=Pr(t,n);if(i>s)i=s,o=!0;else{const n=e[a];e[a]=e[a+1],e[a+1]=n;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const r=Object.assign({},t),i=Object.keys(r),a=Array.from({length:o},(e,t)=>t),s=a.slice(),l=Object.assign({},r);let c=a.slice(),d=1/0;const u=()=>{for(const e of i)l[e]=s[r[e]];const e=Pr(l,n);d>e&&(d=e,c=a.slice())},h=(e,t)=>{const n=a[e],o=a[t];a[e]=o,a[t]=n,s[n]=t,s[o]=e};u();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),u(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function Ir(e,t,n,o,r){var i,a,s,l,c,d,u,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:m,lifetimeMode:v="full"}=r,b={},x={};for(const t of e)b[t.id]=n[t.id].topPeak||0,x[t.id]=n[t.id].botPeak||0;const k="half"===v,w={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=k?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=k?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}w[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}const S={},M=[];if("reuse"===p){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(null!==(i=r.get(e.target))&&void 0!==i?i:0)+1);const u=[];for(const t of e)0===(null!==(a=r.get(t.id))&&void 0!==a?a:0)&&u.push(t.id);for(;u.length;){const e=u.shift();for(const t of null!==(s=o.outgoing[e])&&void 0!==s?s:[]){const o=(null!==(l=n.get(e))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(t.target))&&void 0!==c?c:0)&&n.set(t.target,o),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&u.push(t.target)}}const h=[...e].filter(e=>null!==w[e.id].start).sort((e,t)=>{var o,r;const i=null!==(o=n.get(e.id))&&void 0!==o?o:0,a=null!==(r=n.get(t.id))&&void 0!==r?r:0;return i!==a?i-a:w[e.id].start-w[t.id].start}),f=e.filter(e=>null===w[e.id].start);for(const e of[...h,...f]){const t=w[e.id];let n=-1;for(let e=0;M.length>e;e++){const o=M[e].occupants[M[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(M.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=M.length-1),M[n].occupants.push({id:e.id,end:null!==(d=null==t?void 0:t.end)&&void 0!==d?d:-1/0}),M[n].peak.topPeak=Math.max(M[n].peak.topPeak,b[e.id]),M[n].peak.botPeak=Math.max(M[n].peak.botPeak,x[e.id]),S[e.id]=n}}else e.forEach((e,t)=>{var n,o;M.push({occupants:[{id:e.id,end:null!==(o=null===(n=w[e.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:b[e.id],botPeak:x[e.id]}}),S[e.id]=t});let A=null,j=null,L=null,C=null;const E=()=>{A=Or(S,t),L=Nr(S,t)},D=()=>{j=Or(S,t),C=Nr(S,t)};"crossing-min"===m?(E(),Tr(M,S,t),D()):"inside-out"===m?(E(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),i=Array(n),a=Math.floor((n-1)/2);i[a]=r[0].idx;let s=a-1,l=a+1;for(let e=1;r.length>e;e++)e%2==1&&n>l||0>s?i[l++]=r[e].idx:i[s--]=r[e].idx;const c=i.map(t=>e[t]),d=new Map;i.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t)}(M,S),D()):"crossing-min+inside-out"===m&&(E(),Tr(M,S,t),function(e,t,n){const o=e.length;if(1>=o)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((o-1)/2);let a=Pr(t,n);for(const{slot:s}of r){const r=e.indexOf(s);if(0>r)continue;const l=i;if(r===l)continue;const c=e[r];e.splice(r,1),e.splice(l,0,c);const d=new Map;for(let e=0;o>e;e++)d.set(e,e);if(l>r){for(let e=r+1;l>=e;e++)d.set(e,e-1);d.set(r,l)}else{for(let e=l;r>e;e++)d.set(e,e+1);d.set(r,l)}for(const e of Object.keys(t))t[e]=d.get(t[e]);const u=Pr(t,n);if(u>a){const n=e[l];e.splice(l,1),e.splice(r,0,n);const i=new Map;for(let e=0;o>e;e++)i.set(e,e);if(r>l){for(let e=l+1;r>=e;e++)i.set(e,e-1);i.set(l,r)}else{for(let e=r;l>e;e++)i.set(e,e+1);i.set(l,r)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=u}}(M,S,t),D());const O=M.map(e=>{const t=new Map;for(const o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),N=(e,t)=>{let n={top:0,bot:0};for(const[o,r]of e){if(o>t)break;n=r}return n},P=[];for(let e=0;M.length-1>e;e++){const t=O[e],n=O[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of o){const o=N(t,e),i=N(n,e);o.bot+i.top>r&&(r=o.bot+i.top)}P.push(r)}const _=[];let T=g+(null!==(h=null===(u=M[0])||void 0===u?void 0:u.peak.topPeak)&&void 0!==h?h:0)*y;M.length>0&&_.push(T);for(let e=1;M.length>e;e++)T+=P[e-1]*y+g,_.push(T);if(M.length>0&&(T+=M[M.length-1].peak.botPeak*y+g),T>f){const e=f/T;for(let t=0;_.length>t;t++)_[t]*=e}const I=0===M.length?0:M[0].peak.topPeak+P.reduce((e,t)=>e+t,0)+M[M.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=_[S[t.id]];return{effectiveSlotsHeight:I,centerlines:R,laneLifetime:w,slots:M,slotByNode:S,slotCenter:_,crossingsBefore:A,crossingsAfter:j,lengthBefore:L,lengthAfter:C}}Mr.displayName="OrbitDiagram";const Rr=e=>{var t,n;const{bands:o=[],ribbons:r=[],showLabels:i=!0}=e.config,a=[];for(const e of r)a.push(Object.assign(Object.assign({type:"bezier",pathD:e.pathD},e.bezier&&{bezierCache:e.bezier}),{style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}}));for(const e of o)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];a.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of o)a.push({type:"bezier",pathD:e.pathD,style:Object.assign(Object.assign({},e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86}),{stroke:null!==(t=e.stroke)&&void 0!==t?t:e.fill,strokeWidth:null!==(n=e.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const s=i?o.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:s}};function Wr(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function Br(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function $r(e,t){return"function"==typeof e?e(t):t[e]}const zr=t.forwardRef(function(n,o){const{nodes:r,edges:a,domain:s,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:d="source",targetAccessor:u="target",valueAccessor:h="value",startTimeAccessor:f="startTime",endTimeAccessor:g="endTime",systemInTimeAccessor:y,systemOutTimeAccessor:p,xExtentAccessor:m="xExtent",edgeIdAccessor:v="id",colorBy:b,colorScheme:x,showLegend:k,legendPosition:w="right",pairing:S="temporal",packing:M="reuse",laneOrder:A="crossing-min",ribbonLane:j="both",lifetimeMode:L="half",showLaneRails:C=!1,showQualityReadout:E=!1,showLabels:D=!0,width:O=600,height:N=400,margin:P,title:_,description:T,summary:I,accessibleTable:R,responsiveWidth:W,responsiveHeight:B,loading:$,loadingContent:z,emptyContent:H,edgeOpacity:F=.35,timeFormat:Y,valueFormat:X,tooltip:G,enableHover:q=!0,onObservation:V,onClick:K,showParticles:Q=!1,particleStyle:Z,chartId:U,frameProps:J={}}=n,[ee,te]=t.useState([]),[ne,oe]=t.useState([]),re=t.useRef(ee),ie=t.useRef(ne);re.current=ee,ie.current=ne;const ae=t.useCallback(e=>{re.current=e,te(e)},[]),se=t.useCallback(e=>{ie.current=e,oe(e)},[]),le=void 0!==a,ce=yo(le?a:ee),de=t.useMemo(()=>{const e=yo(null!=r?r:[]),t=ne;if(0===e.length&&0===t.length)return or([],ce,d,u);const n=new Set,o=[];for(const t of e){const e=$r(c,t)+"";n.has(e)||(n.add(e),o.push(t))}for(const e of t){const t=$r(c,e)+"";n.has(t)||(n.add(t),o.push(e))}const i=or([],ce,d,u);for(const e of i)n.has(e.id)||(n.add(e.id),o.push(e));return o},[r,ne,ce,c,d,u]),ue=t.useRef(null),he=t.useCallback((e,t)=>{const n=$r(v,e);return null!=n?n+"":`${$r(d,e)}-${$r(u,e)}-${t}`},[v,d,u]),fe=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=$r(d,t)&&null!=$r(u,t)},[d,u]);Oo(o,{variant:"network",frameRef:ue,overrides:{push(e){if(fe(e)){if(le)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ae([...re.current,e])}else se([...ie.current,e])},pushMany(e){const t=[],n=[];for(const o of e)fe(o)?t.push(o):n.push(o);t.length>0&&(le?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ae([...re.current,...t])),n.length>0&&se([...ie.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!le){const e=re.current,o=[];for(let r=0;e.length>r;r++){const i=e[r];t.has(he(i,r))?n.push(i):o.push(i)}o.length!==e.length&&ae(o)}const o=ie.current,r=[];for(const e of o){const o=$r(c,e)+"";t.has(o)?n.push(e):r.push(e)}return r.length!==o.length&&se(r),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!le){let e=!1;const r=re.current.map((r,i)=>n.has(he(r,i))?(o.push(r),e=!0,t(r)):r);e&&ae(r)}let r=!1;const i=ie.current.map(e=>{const i=$r(c,e)+"";return n.has(i)?(o.push(e),r=!0,t(e)):e});return r&&se(i),o},clear(){var e;le||ae([]),se([]),null===(e=ue.current)||void 0===e||e.clear()},getData:()=>null!=ce?ce:[],getScales:()=>null},deps:[le,fe,he,c,ce,ae,se]});const ge=he,pe=t.useCallback(e=>$r(c,e)+"",[c]),{nodes:me,edges:ve,domain:be,rawNodeById:xe,rawEdgeById:ke}=t.useMemo(()=>{const e=(null!=de?de:[]).map(e=>{const t={id:pe(e),__raw:e},n=m?$r(m,e):null;if(Array.isArray(n)&&2===n.length){const e=Br(n[0]),o=Br(n[1]);Number.isFinite(e)&&Number.isFinite(o)&&(t.xExtent=[e,o])}return t}),t=(null!=ce?ce:[]).map((e,t)=>{const n={id:ge(e,t),source:$r(d,e)+"",target:$r(u,e)+"",value:Number($r(h,e)),startTime:Br($r(f,e)),endTime:Br($r(g,e)),__raw:e};if(y){const t=Br($r(y,e));Number.isFinite(t)&&(n.systemInTime=t)}if(p){const t=Br($r(p,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Br(s[0]),Br(s[1])],o=new Map;for(const t of e)null!=t.__raw&&o.set(t.id,t.__raw);const r=new Map;for(const e of t)null!=e.__raw&&r.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:o,rawEdgeById:r}},[de,ce,s,pe,ge,m,d,u,h,f,g,y,p]),we=ur({nodes:de,edges:ce,inferNodes:!1,sourceAccessor:d,targetAccessor:u,colorBy:b,colorScheme:x,showLegend:!1,legendPosition:w,selection:void 0,linkedHover:void 0,onObservation:V,onClick:K,chartType:"ProcessSankey",chartId:U,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:P,width:O,height:N,loading:$,loadingContent:z,emptyContent:H}),Se=(null!=k?k:!!b)&&!!b,Me=t.useCallback(e=>null!=P&&("number"==typeof P||null!=P[e]),[P]),Ae=t.useMemo(()=>{const e=Object.assign({},we.margin);return Se&&("right"===w&&!Me("right")&&140>e.right?e.right=140:"bottom"===w&&!Me("bottom")&&80>e.bottom&&(e.bottom=80)),e},[we.margin,Se,w,Me]),je=O-Ae.left-Ae.right,Le=N-Ae.top-Ae.bottom,Ce=t.useMemo(()=>Ar(me,ve,be),[me,ve,be]),Ee=t.useMemo(()=>Ce.length>0?null:function(e,t,n){var o;const{plotH:r,pairing:i="temporal",packing:a="reuse",laneOrder:s="crossing-min",lifetimeMode:l="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),d=function(e,t,n,o="value"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===o?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const a=[...n.values()];a.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:r);return a};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)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(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(o,"source"),n=s(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=o}}}return a}(e,t,c,i);let u={};for(const t of e)u[t.id]=Lr(t,c,d);const h=Ir(e,t,u,c,{plotH:r,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 o=d.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>d.get(e.id).sourceSide)),r=new Set(n.map(e=>d.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)h.slotByNode[t.source]===h.slotByNode[t.target]&&(d.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)h.slotByNode[n.source]===h.slotByNode[n.target]&&(d.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const o=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===d.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===d.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=o(),i="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,a="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=i||0>=a)return!1;const s=Math.min(i,a),l=n.filter(t=>!f.has(t.id)&&d.get(t.id).sourceSide===e&&s>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(d.get(l[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=Lr(t,c,d);const g=Ir(e,t,u,c,{plotH:r,padding:12,valueScale:1,packing:a,laneOrder:s,lifetimeMode:l}),y=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),p=Math.min(12,.35*r/Math.max(g.slots.length+1,1)),m=y>0?Math.max(0,(r-p*(g.slots.length+1))/y):1,v=Ir(e,t,u,c,{plotH:r,padding:p,valueScale:m,packing:a,laneOrder:s,lifetimeMode:l});return{nodeData:u,sides:d,valueScale:m,padding:p,compressedPadding:12>p,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(me,ve,{plotH:Le,pairing:S,packing:M,laneOrder:A,lifetimeMode:L}),[Ce,me,ve,Le,S,M,A,L]),De=t.useMemo(()=>i.scaleTime().domain(be).range([0,je]),[be,je]),Oe=t.useCallback((e,t)=>{if(b&&de){const t=xe.get(e);if(t)return Ze(t,b,we.colorScale)}return we.effectivePalette[t%we.effectivePalette.length]||"#475569"},[b,de,xe,we.colorScale,we.effectivePalette]),Ne=t.useMemo(()=>{const e=new Map;return me.forEach((t,n)=>e.set(t.id,n)),e},[me]),Pe=t.useMemo(()=>{if(!Ee)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Ee,o=[],r=[];return me.forEach((r,i)=>{var a;const s=t[r.id];if(!s||0===s.samples.length)return;const l=function(e,t,n,o,r){if(0===e.length)return null;const i=Er(e,r),a=e=>t-i[e].topMass*n,s=e=>t+i[e].botMass*n;let l=`M${o(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)l+=` L${o(i[e].t)},${a(e)}`;l+=` L${o(i[i.length-1].t)},${s(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${o(i[e].t)},${s(e)}`;return l+" Z"}(s.samples,e[r.id],n,De,be);if(!l)return;const c=Er(s.samples,be),d=c.find(e=>e.topMass+e.botMass>0)||c[0],u=e[r.id]+(d.botMass-d.topMass)*n/2,h=Oe(r.id,i),f=null!==(a=xe.get(r.id))&&void 0!==a?a:r,g=function(e,t,n,o,r){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const a=n.valueScale,s=n.centerlines[e],l=Er(i.samples,r),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],u=o(c.t),h=o(d.t),f=e=>o(Cr(e,r)),g=[],y=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),o=f(n.startTime),r=t-20,i=Math.max(u,r);if(o>i){const[n,l]=Dr(e,s,a);g.push({pathD:y(i,n,o,l),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),o=f(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,l]=Dr(e,s,a);g.push({pathD:y(o,n,i,l),x0:t,x1:r,from:1,to:0})}}}}return g}(r.id,ve,Ee,De,be);o.push(Object.assign(Object.assign({id:r.id,pathD:l,fill:h,stroke:h,strokeWidth:.5},g.length>0&&{gradientStubs:g}),{rawDatum:f,labelX:De(d.t)-4,labelY:u,labelText:r.id}))}),ve.forEach(o=>{var i,a,s,l;const c=null===(i=t[o.source])||void 0===i?void 0:i.localAttachments.get(o.id),d=null===(a=t[o.target])||void 0===a?void 0:a.localAttachments.get(o.id);if(!c||!d)return;const u=null!==(s=Ne.get(o.source))&&void 0!==s?s:0,h=Oe(o.source,u),f=function(e,t,n,o,r,i,a,s){const l=r,c=e=>s?Math.max(s[0],Math.min(s[1],e)):e,d=i(c(e.time)),u=i(c(n.time)),h=e.value*l,f=n.value*l,g=e.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,v,b;"top"===e.side?(p=t-g,m=p+h):(m=t+g,p=m-h),"top"===n.side?(v=o-y,b=v+f):(b=o+y,v=b-f);const x="source"===a?d+.85*(u-d):"target"===a?d+.15*(u-d):(d+u)/2;return{sx:d,sTop:p,sBot:m,tx:u,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,e[o.source],d,e[o.target],n,De,j,be),{pathD:g,bezier:y}=ye(f),p=null!==(l=ke.get(o.id))&&void 0!==l?l:o;r.push({id:o.id,pathD:g,fill:h,opacity:F,rawDatum:p,bezier:y})}),{bands:o,ribbons:r}},[Ee,me,ve,De,be,Oe,xe,ke,j,F,Ne]),_e=t.useMemo(()=>({bands:Pe.bands,ribbons:Pe.ribbons,showLabels:D}),[Pe,D]),Te=t.useMemo(()=>{if(!Se||!b)return;const e=new Map;(null!=de?de:[]).forEach((t,n)=>{const o=$r(b,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:Oe(pe(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},[Se,b,de,Oe,pe]),Ie=t.useMemo(()=>!1!==G&&q?void 0===G||!0===G?null:At(G)||null:null,[G,q]),Re=t.useCallback(e=>Y?Y(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[Y]),We=t.useCallback(e=>X?X(e):e+"",[X]),Be=t.useCallback(t=>{if(!t||!t.data)return null;const n=t.data;if(!Wr(n))return null;const o=n.data;if(Ie)return Ie(o);if("band"===n.__kind){const t=n.id,o=Ee?function(e){if(!e)return[];const t=new Set,n=[];for(const o of e.samples){const e=o.topMass+o.botMass,r=`${o.t}:${e}`;t.has(r)||(t.add(r),n.push({t:o.t,total:e}))}return n}(Ee.nodeData[t]):[],r=5,i=o.length>r?o.length:null,a=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),o=n.length-1,r=[Object.assign(Object.assign({},n[0]),{mark:"min"}),Object.assign(Object.assign({},n[Math.floor(.25*o)]),{mark:"q25"}),Object.assign(Object.assign({},n[Math.floor(.5*o)]),{mark:"median"}),Object.assign(Object.assign({},n[Math.floor(.75*o)]),{mark:"q75"}),Object.assign(Object.assign({},n[o]),{mark:"max"})],i=new Set,a=[];for(const e of r)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(o,r);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:Re(t.t)}),e.jsx("td",{style:{textAlign:"right"},children:We(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 r=o,i=$r(d,r),a=$r(u,r),s=$r(h,r),l=$r(f,r),c=$r(g,r);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:We(Number(s))})]}),null!=l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"start"}),e.jsx("span",{style:{textAlign:"right"},children:Re(Br(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:Re(Br(c))})]})]})]})},[Ee,Ie,Re,We,d,u,h,f,g]),$e=t.useMemo(()=>{if(!Ee)return null;const{centerlines:t,laneLifetime:n,nodeData:o,valueScale:r,compressedPadding:i,crossingsBefore:a,crossingsAfter:s,lengthBefore:c,lengthAfter:d}=Ee;let u=null,h=null;for(const e of me){const t=n[e.id];if(!t||null===t.start||null===t.end)continue;const o=De(t.start),r=De(t.end);(null===u||u>o)&&(u=o),(null===h||r>h)&&(h=r)}const f=e=>Math.max(0,Math.min(je,e)),g=f(null!=u?u:0),y=Math.max(g,f(null!=h?h:je));return e.jsxs("g",{children:[E&&null!==(null!=s?s:null)&&e.jsxs("text",{x:je,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",a," → ",s," ","edge length: ",Math.round(c)," → ",Math.round(d)]}),i&&e.jsx("text",{x:je,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((t,n)=>{const o=De(Br(t.date));return g-.5>o||o>y+.5?null:e.jsx("line",{x1:o,y1:0,x2:o,y2:Le,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+n)}),C&&me.map((i,a)=>{const s=n[i.id];if(!s||null===s.start)return null;const l=o[i.id],c=l?{topPeak:l.topPeak,botPeak:l.botPeak}:{topPeak:0,botPeak:0},d=t[i.id]+(c.botPeak-c.topPeak)*r/2,u=De(s.start),h=De(s.end),f=Oe(i.id,a);return e.jsxs("g",{children:[e.jsx("line",{x1:u,y1:d,x2:h,y2:d,stroke:f,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e.jsx("line",{x1:u,y1:d-4,x2:u,y2:d+4,stroke:f,strokeOpacity:.5}),e.jsx("line",{x1:h,y1:d-4,x2:h,y2:d+4,stroke:f,strokeOpacity:.5})]},"lane-"+i.id)}),e.jsx("line",{x1:g,y1:Le+4,x2:y,y2:Le+4,stroke:"#94a3b8"}),l.map((t,n)=>{const o=Br(t.date),r=De(o);if(g-.5>r||r>y+.5)return null;const i=null!=t.label?t.label:Y?Y(new Date(o)):"";return e.jsxs("g",{transform:`translate(${r},${Le+4})`,children:[e.jsx("line",{y2:6,stroke:"#94a3b8"}),e.jsx("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:i})]},n)})]})},[Ee,l,De,je,Le,C,me,Oe,E,Y]),ze=t.useMemo(()=>(null!=de?de:[]).map(e=>({id:pe(e),data:e})),[de,pe]),He=t.useMemo(()=>{const e=new Map;for(const t of Pe.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Pe]),Fe=t.useMemo(()=>(null!=ce?ce:[]).map((e,t)=>{const n=ge(e,t),o=Number($r(h,e));return{id:n,source:$r(d,e)+"",target:$r(u,e)+"",value:Number.isFinite(o)?o:0,bezier:He.get(n),data:e}}),[ce,ge,d,u,h,He]),Ye=we.loadingEl,Xe=we.emptyEl;return Ce.length>0?e.jsxs("svg",{width:O,height:N,role:"img","aria-label":null!=_?_:"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"}),Ce.map((t,n)=>e.jsx("text",{x:20,y:56+18*n,fontSize:12,fill:"#64748b",children:"• "+jr(t)},n))]}):Ye||Xe||e.jsx(Do,Object.assign({ref:ue,chartType:"force",nodes:ze,edges:Fe,customNetworkLayout:Rr,layoutConfig:_e,size:[O,N],responsiveWidth:W,responsiveHeight:B,margin:Ae,title:_,description:null!=T?T:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:I,accessibleTable:R,enableHover:q,tooltipContent:!1===G?()=>null:Be,backgroundGraphics:$e,showParticles:Q,particleStyle:Z,legend:Te,legendPosition:w,onObservation:V,customClickBehavior:K?e=>{if(!e||!e.data)return;const t=e.data;Wr(t)&&K(t.data,{x:e.x,y:e.y})}:void 0,chartId:U,colorScheme:Array.isArray(x)?x:void 0},J))});zr.displayName="ProcessSankey";const Hr=t.forwardRef(function(n,o){const{nodes:r,edges:i,layout:a,layoutConfig:s,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:d="target",margin:u,className:h,colorScheme:f,selection:g,linkedHover:y,onObservation:p,onClick:m,chartId:v,frameProps:b={}}=n,{frameRef:x,resolved:k,normalizedMargin:w}=function(e){const n=t.useRef(null);return Oo(e.imperativeRef,{variant:e.imperativeVariant,frameRef:n}),{frameRef:n,resolved:er(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;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:o,imperativeVariant:"network",margin:u,width:n.width,height:n.height,enableHover:n.enableHover,title:n.title,mode:n.mode}),S=t.useMemo(()=>yo(null!=r?r:[]),[r]),M=t.useMemo(()=>yo(null!=i?i:[]),[i]),{customHoverBehavior:A,customClickBehavior:j,activeSelectionHook:L}=Zo({selection:g,linkedHover:y,fallbackFields:[],onObservation:p,onClick:m,chartType:"NetworkCustomChart",chartId:v}),C=t.useMemo(()=>(null==L?void 0:L.isActive)?{isActive:!0,predicate:L.predicate}:null,[null==L?void 0:L.isActive,null==L?void 0:L.predicate]),{width:E,height:D,enableHover:O,title:N,description:P,summary:_,accessibleTable:T}=k,I=Object.assign(Object.assign(Object.assign(Object.assign({chartType:"force"},null!=r&&{nodes:S}),null!=i&&{edges:M}),{customNetworkLayout:a,layoutConfig:s,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:d,colorScheme:f,size:[E,D],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:w,className:h,title:N,description:P,summary:_,accessibleTable:T,enableHover:O,customHoverBehavior:y||p||m?A:void 0,customClickBehavior:p||m?j:void 0,layoutSelection:C}),b);return e.jsx(lr,{componentName:"NetworkCustomChart",width:E,height:D,children:e.jsx(Do,Object.assign({ref:x},I))})});Hr.displayName="NetworkCustomChart",exports.ChordDiagram=br,exports.CirclePack=wr,exports.ForceDirectedGraph=mr,exports.NetworkCustomChart=Hr,exports.OrbitDiagram=Mr,exports.ProcessSankey=zr,exports.SankeyDiagram=vr,exports.StreamNetworkFrame=Do,exports.TreeDiagram=xr,exports.Treemap=kr,exports.formatProcessSankeyIssue=jr,exports.validateProcessSankey=Ar;
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react"),n=require("d3-interpolate"),o=require("d3-array"),r=require("d3-force"),i=require("d3-scale"),s=require("d3-chord"),a=require("d3-shape"),l=require("d3-hierarchy"),c=require("d3-quadtree");function u(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const d=u(t);function h(e){return Array.isArray(e)?e[0]:e}function f(e,t,n,o){return Object.assign({data:h(e),x:t,y:n,__semioticHoverData:!0},o)}const g=["name","label","title"],y=["type","kind","category","group","class","status","role","shape"],p=["value","amount","total","count","weight","score"],m=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function v(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}const b={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 x(e,t){return"function"==typeof t?t(e):e[t]}function k(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 w(t={}){const{fields:n,title:o,format:r,style:i={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=x(t,o);a=k(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const s=x(t,o);l.push({label:n,value:k(s,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=k(t[n],r);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=k(t[e[0]],r))}}const c=Object.assign(Object.assign({},b),i);return e.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((t,n)=>e.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},n))]})}}function S(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var o;let r=h(!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(o=t.data)&&void 0!==o?o:{}:t);("node"===(null==t?void 0:t.nodeOrEdge)&&"number"==typeof(null==r?void 0:r.x0)&&"number"==typeof(null==r?void 0:r.x1)||"edge"===(null==t?void 0:t.nodeOrEdge)&&"number"==typeof(null==r?void 0:r.sankeyWidth))&&r.data&&"object"==typeof r.data&&(r=r.data);const i=n(r);return null==i?null:e.jsx("div",{className:"semiotic-tooltip",style:b,children:i})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?w(t):w())}}const M={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},A={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function j(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function L(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function C(e){const t=e.map(j),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return L(e,n,o)}if(e>=1){const[e,o,r]=t[n];return L(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[s,a,l]=t[r],[c,u,d]=t[r+1];return L(Math.round(s+(c-s)*i),Math.round(a+(u-a)*i),Math.round(l+(d-l)*i))}}const E=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],O=C(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),D=C(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),_=C(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),N=C(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),P=C(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),T=C(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),I={blues:O,reds:D,greens:_,viridis:C(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oranges:N,purples:P,greys:T,plasma:C(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:C(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:C(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:C(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:C(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])};C(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),C(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),C(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),C(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),C(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),C(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),C(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);class R{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const s=this.particles[i];if(!s.active)continue;const a=n[s.edgeIndex];if(!a||!a.bezier){s.active=!1,this._freeIndices.push(i);continue}const l=o&&null!==(r=o[s.edgeIndex])&&void 0!==r?r:1;s.t+=e*t*l*(a.bezier.circular?.3:1),1>s.t?W(a.bezier,s.t,s.offset,s):(s.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 W(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),l=s-a,[c,u,d,h]=e[a];$(c,u,d,h,l,r);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;r.x+=-g/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,i,s,a]=e.points;$(r,i,s,a,t,o);const l=a.x-r.x,c=a.y-r.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;o.x+=-c/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function $(e,t,n,o,r,i){const s=1-r,a=s*s,l=a*s,c=r*r,u=c*r;i.x=l*e.x+3*a*r*t.x+3*s*c*n.x+u*o.x,i.y=l*e.y+3*a*r*t.y+3*s*c*n.y+u*o.y}function B(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function z(e,t){var n,o=[],r=[],i=[],s={},a=[];function l(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;a[e].length>t;t++)(o=a[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[o=a[e][t]];h||(s[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.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,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[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]=o[y]=u,r[y]=!0,u+=1,l.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>s[y]||a[t].push(s[y])}i[t]=g}else{if(o[t]===n[t]){var p=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(r[b]=!1,p.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===t){l.length=g;break}}d.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}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),r=o.components.filter(function(e){return e.length>1}),i=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)i>r[s][a]&&(i=r[s][a],n=s);var l=r[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,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];i[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return o}function H(e){return e.y0-e.y1>0?"up":"down"}function F(e,t){return t(e.source)==t(e.target)}function Y(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 X(e){return e.target.x0-e.source.x1}function G(e,t){var n=V(e),o=X(t)/Math.tan(n);return"up"==H(e)?e.y1-o:e.y1+o}function q(e,t){var n=V(e),o=X(t)/Math.tan(n);return"up"==H(e)?e.y1+o:e.y1-o}function V(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function K(e,t){return t(e)}function Q(e){return U(e.source)}function Z(e){return U(e.target)}function U(e){return(e.y0+e.y1)/2}function J(e){return e.virtual?0:e.value}function ee(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!F(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!F(e,t)?o+1:o}),n+o}function te(e){return e.target.depth}function ne(e,t){return e.sourceLinks.length?e.depth:t-1}function oe(e,t){return e.y0-t.y0}function re(e,t){return t.y0-e.y0}function ie(e,t){return e.y1-t.y1}function se(e,t){return t.y1-e.y1}function ae(e,t){return ce(e.source,t.source)||e.index-t.index}function le(e,t){return ce(e.target,t.target)||e.index-t.index}function ce(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ue(e,t){return de(e)==de(t)?"bottom"==e.circularLinkType?re(e,t):oe(e,t):de(t)-de(e)}function de(e){return e.target.column-e.source.column}function he(e,t){return fe(e)==fe(t)}function fe(e){return e.y0-e.y1>0?"up":"down"}function ge(e,t,n,r,i){let s=e;var a=Math.max(8,.15*(s.y1-s.y0));s.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var l=o.min(s.links,function(e){return e.source.y0});s.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=s.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}),ye(s.links.filter(function(e){return"top"==e.circularLinkType}),t,n),ye(s.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),s.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,F(e,t)&&Y(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+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 o=e.source.column,a=e.circularLinkType,c=s.links.filter(function(e){return e.source.column==o&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?re:oe);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),o=e.target.column,(c=s.links.filter(function(e){return e.target.column==o&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?se:ie),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(s.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,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),s}function ye(e,t,n){e.sort(ue);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(F(e,t)&&Y(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&pe(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function pe(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function me(e){return function(){return e}}function ve(e){return e.index}function be(e){return e.nodes}function xe(e){return e.links}function ke(e,t,n){var r=o.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=U(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=U(e.target)*t,o+=t}}),o>0?r/o:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),o=a.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?ee(t,n)-ee(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==ee(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function we(e,t,n,r,i,s){var a=o.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=s;c>0;--c)u(l*=.99,n),d();function u(t,n){var r=a.length;a.forEach(function(i){var s=i.length,a=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&ee(i,n)>0){var c=o.mean(i.sourceLinks,Z),u=o.mean(i.targetLinks,Q),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-U(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==s)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(a==r-1&&1==s)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=o.mean(i.sourceLinks,Z),g=o.mean(i.targetLinks,Q),y=((f&&g?(f+g)/2:f||g)-U(i))*t;i.y0+=y,i.y1+=y}})})}function d(){a.forEach(function(n){var o,s,a,l=e.y0,c=n.length;for(n.sort(t||ce),a=0;c>a;++a)(s=l-(o=n[a]).y0)>0&&(o.y0+=s,o.y1+=s),l=o.y1+r;if((s=l-r-e.y1)>0)for(l=o.y0-=s,o.y1-=s,a=c-2;a>=0;--a)(s=(o=n[a]).y1+i-l)>0&&(o.y0-=s,o.y1-=s),l=o.y0})}}function Se(e){e.nodes.forEach(function(e){e.sourceLinks.sort(le),e.targetLinks.sort(ae)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Me(){var e=0,t=0,n=1,r=1,i=24,s=8,a=null,l=ve,c=ne,u=void 0,d=32,h=2,f=be,g=xe;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=r,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 o.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 o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=B(n,o)),"object"!=typeof r&&(r=e.target=B(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(f,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],s=i.source.index,a=i.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=z(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,u),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){K(e,t)!=K(r.source,t)&&K(e,t)!=K(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),F(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(o.sum(e.sourceLinks,J),o.sum(e.targetLinks,J)),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 o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(f,u,c);var g=s;if(null!==a){var y=o.groups(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=o.max(y,function(e){return e.length});p>1&&(g=Math.max(1,(r-t)*a/(p-1)))}(function(e,t,n){var r=o.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=o.min(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/o.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var s=o.max(e.nodes,function(e){return e.column});e.nodes.forEach(s>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/s),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,g,i),ke(f,u,l),we(f,u,l,g,g,d),Se(f),ge(f,l,h,10,8),ke(f,u,l),we(f,u,l,g,g,d),Se(f),ge(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 o=n.links.filter(function(n){return K(n.source,t)==K(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!he(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=G(t,e);return e.y1-n}if(t.target.column>e.target.column)return G(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;r>i;i++)s+=o[i].width;t.y0=e.y1-s-t.width/2}})})}(f,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return K(n.target,t)==K(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!he(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=q(t,e);return e.y0-n}if(t.source.column>e.source.column)return q(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;r>i;i++)s+=o[i].width;t.y1=e.y1-s-t.width/2}})})}(f,l),function(e){var t=e.nodes,n=e.links,r=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==r||0==i){var s=o.min(t,function(e){return e.y0}),a=o.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(a-s);function c(t){return(t-s)/(a-s)*(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),ge(f,l,h,10,8)}(y),y}return y.update=function(e){return Se(e),ge(e,l,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(s=+e,y):s},y.nodePaddingRatio=function(e){return arguments.length?(a=+e,y):a},y.nodes=function(e){return arguments.length?(f="function"==typeof e?e:me(e),y):f},y.links=function(e){return arguments.length?(g="function"==typeof e?e:me(e),y):g},y.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:me(e),y):l},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:me(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(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[e,t],[n,r]]},y.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],y):[n-e,r-t]},y}function Ae(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:s,cp1X:a,cp2X:l}=e,c=(n+o)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${l},${i} ${r},${i}`,`L${r},${s}`,`C${l},${s} ${a},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:r,y:u}],halfWidth:(o-n)/2}}}const je=e=>{let t,o,r,i,s,a,l,c,u;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,s=e.source.x1,a=e.target.x0,l=n.interpolateNumber(s,a),c=l(.5),u=l(.5),`M${t},${s}C${t},${c} ${o},${u} ${o},${a}L${r},${a}C${r},${u} ${i},${c} ${i},${s}Z`;const d=e.sankeyWidth/2,h=n.interpolateNumber(e.source.x1,e.target.x0),{pathD:f}=Ae({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 Le(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+a},${o-n}L${t+a},${o+n}L${t},${o+n}ZM${i},${s-n}L${i-l},${s-n}L${i-l},${s+n}L${i},${s+n}Z`}const i=r.sourceX,s=r.sourceY,a=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${i},${s-h*n}L${c},${s-h*n}L${c+o},${s-h*n+h*f}L${c+o},${d+h*o-h*f}L${c+o-f},${d+h*o}L${u-o+f},${d+h*o}L${u-o},${d+h*o-h*f}L${u-o},${l-h*n+h*f}L${u-o+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${s+h*n}L${i},${s+h*n}Z`}const Ce=new Set,Ee=new WeakMap;function Oe(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Ee.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Ee.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Ce.has(e)||(Ce.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}const De={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(te))-1:0},justify:ne};function _e(e){return"string"==typeof e?e:e.id}const Ne={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,s,a,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(r=n.nodeWidth)&&void 0!==r?r:15,g=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=Me().extent(v).links(m).nodes(p).nodeAlign(De[h]||ne).nodeId(e=>e.id).nodeWidth(f).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of p)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,s=(null!==(l=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>r&&(r=i.verticalFullExtent+s)}const i=t-e,s=r-n,u=o[0],d=o[1];if(i>0&&s>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/s),o=-e*t+(u-i*t)/2,r=-n*t+(d-s*t)/2;for(const e of p)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=_e(e.source),n=_e(e.target),o=k.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=d;const r=x.get(t),i=x.get(n);r&&(o.source=r),i&&(o.target=i)}}},buildScene(e,t,n,o){var r,i,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:E,p=new Map;e.forEach((e,t)=>{p.set(e.id,y[t%y.length])});const m=[],v=[],b=[],x=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=d?d(Oe(t,"nodeStyle")):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};x.set(t.id,("string"==typeof r.fill?r.fill:null)||p.get(t.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:r,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const k=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of k){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";r="function"==typeof g?g(e)||r:"target"===g?x.get(o.id)||p.get(o.id)||r:x.get(t.id)||p.get(t.id)||r;const u=h?h(Oe(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),i=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),s=u.fill||r;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),v.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:s,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?Le(e):je(e),!d)continue;const y={fill:u.fill||r,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:y,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+r/2),b.push({x:s,y:a,text:i+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},Pe={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var i,s;if(0===e.length)return;const a=null!==(i=n.forceStrength)&&void 0!==i?i:.1,l=o[0]/2,c=o[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 o=Te(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=Ie(e.id),i=r%360*(Math.PI/180),s=10+r%20;e.x=t/o.length+s*Math.cos(i),e.y=n/o.length+s*Math.sin(i)}else{const t=Ie(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=l+o*Math.cos(n),e.y=c+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=l+e*Math.cos(r),o.y=c+e*Math.sin(r)}}}const g=null!==(s=n.iterations)&&void 0!==s?s:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),y=0===n.iterations?0:f?40:g,p=Re(n.nodeSize,n.nodeSizeRange,e),m=e=>p(e);if(y>0){const n=r.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*a:a)}).id(e=>e.id),o=r.forceSimulation().force("charge",r.forceManyBody().strength(e=>-25*m(e))).force("center",r.forceCenter(l,c).strength(.8)).force("x",r.forceX(l).strength(.15)).force("y",r.forceY(c).strength(.15));if(o.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));n.links(e),o.force("link",n)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let e=0;y>e;++e)o.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Re(n.nodeSize,n.nodeSizeRange,e),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:E,y=new Map;e.forEach((e,t)=>{y.set(e.id,g[t%g.length])});const p=[],m=[],v=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(Oe(t,"nodeSize")),o=d?d(Oe(t,"nodeStyle")):{},a={fill:o.fill||y.get(t.id)||(null===(r=n.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:t.x,cy:t.y,r:e,style:a,datum:t,id:t.id,label:t.id})}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:b.get(e.source),o="object"==typeof e.target?e.target:b.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=h?h(Oe(e,"edgeStyle")):{},i={stroke:r.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=r.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=r.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:i,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=f(Oe(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Te(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function Ie(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 Re(e,t,n){var o;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],s=[];for(const t of n){const n=null===(o=t.data)||void 0===o?void 0:o[e];"number"==typeof n&&s.push(n)}if(0===s.length)return()=>r[0];const[a,l]=function(e){let t=1/0,n=-1/0;for(const o of e)t>o&&(t=o),o>n&&(n=o);return[t,n]}(s);if(a===l)return()=>(r[0]+r[1])/2;const c=i.scaleLinear().domain([a,l]).range(r).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?r[0]:c(o)}}const We=E,$e={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:l}=n,c=Math.min(o[0],o[1])/2,u=c-i,d=o[0]/2,h=o[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,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=y.get("string"==typeof e.source?e.source:e.source.id),o=y.get(t);if(void 0===n||void 0===o)continue;const r=f(e);m[n][o]=r}const v=s.chord().padAngle(r);l&&v.sortGroups(l);const b=v(m),x=b.groups,k=a.arc().innerRadius(u).outerRadius(c);for(const t of x){const n=e[t.index],o=k.centroid({innerRadius:u,outerRadius:c,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+d,n.y=o[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),o=w.get(t);n&&(e.source=n),o&&(e.target=o)}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,o=e[t.target.index].id,r=S.get(`${n}\0${o}`)||S.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){var r,i,a,l;const{groupWidth:c=20,edgeOpacity:u=.5}=n,d=Math.min(o[0],o[1])/2,h=d-c,f=o[0]/2,g=o[1]/2,y=n.nodeStyle,p=n.edgeStyle,m=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:We,b=new Map;e.forEach((e,t)=>{b.set(e.id,v[t%v.length])});const x=s.ribbon().radius(h),k=[],w=[],S=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let i;i=y?y(Oe(n,"nodeStyle")).fill||b.get(n.id)||v[t%v.length]:b.get(n.id)||v[t%v.length];const s=y?y(Oe(n,"nodeStyle")):{},a={fill:i,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:d,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=x(t);if(!o)continue;const r=Be(o,f,g);let s=(null===(i=n.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=n.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";if(p)s=p(Oe(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===m&&n?s=b.get(n.id)||s:t&&(s=b.get(t.id)||s)}const c=p?p(Oe(e,"edgeStyle")):{},d={fill:s,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:r,style:d,datum:e})}if(!1!==n.showLabels){const t=(M=n.nodeLabel)?"function"==typeof M?M:e=>e[M]||e.id:null,o=d+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;S.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var M;return{sceneNodes:k,sceneEdges:w,labels:S}}};function Be(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const ze=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function He(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function Fe(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Ye(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>{var n;return t(null!==(n=e.data)&&void 0!==n?n:e)}}return t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}}function Xe(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:ze}function Ge(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 qe(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}const Ve={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const s=n.chartType,a=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,a);d.sum(u),d.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[h,f]=o;switch(s){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=l.tree();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,h,f);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=l.cluster();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,h,f);break;case"treemap":!function(e,t,n,o){var r,i;const s=null!==(r=t.padding)&&void 0!==r?r:4,a=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=l.treemap().size([n,o]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(e)}(d,n,h,f);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;l.pack().size([n,o]).padding(i)(e)}(d,n,h,f);break;case"partition":!function(e,t,n,o){var r;l.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r: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 o=g[t],i={id:Fe(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?Ke(i,o,n):"treemap"===s||"partition"===s?Qe(i,o):"circlepack"===s&&Ze(i,o),i.__hierarchyNode=o,e.push(i),y.set(o,i)}if("tree"===s||"cluster"===s)for(const e of g)if(e.parent){const n=y.get(e.parent),o=y.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var s,a,l,c,u,d,h,f;const g=[],y=[],p=[],m=n.treeOrientation||"vertical",v="radial"===m,b=o[0]/2,x=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const t of e){let e=t.x,o=t.y;v&&(e+=b,o+=x);const i=r(Oe(t,"nodeStyle"));let l=i.fill||Ge(n);if(n.colorByDepth&&void 0!==t.depth){const e=Xe(n);l=e[t.depth%e.length]}const c={fill:l,stroke:i.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};g.push({type:"circle",cx:e,cy:o,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const S=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,s=t.y,a=o.x,l=o.y;v&&(r+=b,s+=x,a+=b,l+=x);const f=qe(r,s,a,l,m),g=i(Oe(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=Ye(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,s=n.x,a=n.y;if(v&&(s+=b,a+=x),v){const e=s-b,t=a-x,n=Math.sqrt(e*e+t*t);n>0?(o=s+e/n*10,r=a+t/n*10,i=0>e?"end":"start"):(o=s,r=a-12,i="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=s-k-6,i="end"):(o=s+k+6,i="start"),r=a):(o=s,r=a+k+14,i="middle");p.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i,s,a,l;const c=[],u=[];for(const n of e){const e=n.x1-n.x0,s=n.y1-n.y0;if(0>=e||0>=s)continue;const a=o(Oe(n,"nodeStyle"));let l=a.fill||Ge(t);if(t.colorByDepth&&void 0!==n.depth){const e=Xe(t);l=e[n.depth%e.length]}const u={fill:l,stroke:a.stroke||(null===(r=t.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:a.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:e,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ye(t.nodeLabel),r=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===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!i){if("leaf"===r&&!h)continue;if("parent"===r&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>e||(h?16:14)>d)continue;let g=o(Oe(c,"nodeStyle")).fill||Ge(t);if(t.colorByDepth&&void 0!==c.depth){const e=Xe(t);g=e[c.depth%e.length]}const y="string"==typeof g?He(g):null!==(l=null===(a=t.themeSemantic)||void 0===a?void 0:a.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,r);case"circlepack":return function(e,t,n,o){var r,i,s,a,l,c,u,d,h,f;const g=[],y=[];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const l=o(Oe(n,"nodeStyle"));let c=l.fill||Ge(t);if(t.colorByDepth&&void 0!==n.depth){const e=Xe(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!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.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=Ye(t.nodeLabel);for(const r of e){const e=null!==(l=r.__radius)&&void 0!==l?l:5,i=n?n(r):r.id;if(!i)continue;if(15>e)continue;const s=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let a=o(Oe(r,"nodeStyle")).fill||Ge(t);if(t.colorByDepth&&void 0!==r.depth){const e=Xe(t);a=e[r.depth%e.length]}if(s){const n="string"==typeof a?He(a):null!==(d=null===(u=t.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:r.x,y:r.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else y.push({x:r.x,y:r.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=t.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ke(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Qe(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Ze(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function Ue(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const Je={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){var i,s;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!==(s=n.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,y=Ue(n);y.metaMap.clear(),o.length=0,r.length=0;const p=new Map;function m(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 v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));o.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),y.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,s,d,h,p){const v=l(t);if(!(null==v?void 0:v.length))return;const b=v.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=v.slice(S,S+k);if(!w.length)break;const M=(b+1)/x,A={id:n,depth:h,data:t,parentId:n},j=p?d/f(A)*M:d*M,L=a.pie().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),C=L(w),E=g(A);for(let t=0;w.length>t;t++){const a=(C[t].startAngle+C[t].endAngle)/2,l=w[t],u=m(c(l)),d=i+j*Math.sin(a),f=s+j*Math.cos(a)*E;o.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:a,depth:h,parentId:n,eccentricity:E}),r.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,v,b,x,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){var r,i,s,a,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=Ue(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const a=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;y.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(Oe(t,"nodeSize")),o=d?d(Oe(t,"nodeStyle")):{},c={fill:o.fill||(null===(r=n.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(i=n.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a: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 m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:m.get(e.source),n="object"==typeof e.target?e.target:m.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(Oe(n,"nodeSize"));if(4>=e)continue;const o="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:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const r=Ue(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,s=null!==(o=t.orbitRevolution)&&void 0!==o?o:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.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=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const o=e.angle+a*l*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},et={sankey:Ne,force:Pe,chord:$e,tree:Ve,cluster:Ve,treemap:Ve,circlepack:Ve,partition:Ve,orbit:Je};function tt(e){return et[e]}const nt=Object.assign({category10:E,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]},I),ot=E,rt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],it=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],st=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function at(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||st.has(t)}(o)?n(o):o}const o=(null==e?void 0:e[t])+"";return n?n(o):ot[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%ot.length]}function lt(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return i.scaleOrdinal().domain(o).range(n).unknown("#999");const s=nt[n]||nt.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:ot;return i.scaleOrdinal().domain(o).range(e).unknown("#999")}}function ct(e){return 0===e.length?()=>"#4e79a7":t=>{var n;let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return null!==(n=e[Math.abs(o)%e.length])&&void 0!==n?n:"#4e79a7"}}function ut(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(ut))}function dt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function ht(e,t,n){return e+(t-e)*n}function ft(e,t,n){var o,r,i;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:s;default:return 1}}class gt{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.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,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._decayAgeMap=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({},M),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new R(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(e.layoutSelection=t.layoutSelection),this.config=e,this.tensionConfig=Object.assign(Object.assign({},M),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new R(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:s="value"}=this.config,a="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>{var t;return null!==(t=e[s])&&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=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},yt(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",r=c(n)+"",i=u(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},yt(o)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},yt(r)),{data:n}));const d=`${o}\0${r}\0${e}`,h={source:o,target:r,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:d};n&&"object"==typeof n&&pt(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:o}=e,r=0===this.nodes.size;let i=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,yt(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,yt(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;return l?(l.value+=o,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,o,r,i,s,a,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=tt(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 a of u)if(void 0!==a._prevX0){const l=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(o=a._prevY1)&&void 0!==o?o:0)-(null!==(r=a._prevY0)&&void 0!==r?r:0);e.set(a.id,{x:(null!==(i=a._prevX0)&&void 0!==i?i:0)+l/2,y:(null!==(s=a._prevY0)&&void 0!==s?s:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.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===(a=this.config.transition)||void 0===a?void 0:a.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}setLayoutSelection(e){this.config.layoutSelection=e}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const e of this.sceneNodes)this._baseStyles.set(e,e.style);for(const e of this.sceneEdges)this._baseStyles.set(e,e.style)}restyleScene(e){var t,n;if(this._customRestyle){const n=this._customRestyle;for(const o of this.sceneNodes){const r=null!==(t=this._baseStyles.get(o))&&void 0!==t?t:o.style,i=n(o,e);o.style=i?Object.assign(Object.assign({},r),i):r}}if(this._customRestyleEdge){const t=this._customRestyleEdge;for(const o of this.sceneEdges){const r=null!==(n=this._baseStyles.get(o))&&void 0!==n?n:o.style,i=t(o,e);o.style=i?Object.assign(Object.assign({},r),i):r}}}buildScene(e){var t,n,o,r,i,s,a,l,c;if(this._sceneNodesRevision++,this.config.customNetworkLayout){const u=Array.from(this.nodes.values()),d=Array.from(this.edges.values()),h=function(e,t,n){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=nt[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,E),f={nodes:u,edges:d,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:[...h]},resolveColor:ct(h),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{},selection:null!==(o=this.config.layoutSelection)&&void 0!==o?o:null};let g;try{g=this.config.customNetworkLayout(f)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,void(this.customLayoutHtmlMarks=[])}return this.sceneNodes=null!==(r=g.sceneNodes)&&void 0!==r?r:[],this.sceneEdges=null!==(i=g.sceneEdges)&&void 0!==i?i:[],this.labels=null!==(s=g.labels)&&void 0!==s?s:[],this.customLayoutOverlays=null!==(a=g.overlays)&&void 0!==a?a:null,this.customLayoutHtmlMarks=null!==(l=g.htmlMarks)&&void 0!==l?l:[],this._customRestyle=g.restyle,this._customRestyleEdge=g.restyleEdge,this.hasCustomRestyle=!(!g.restyle&&!g.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(null!==(c=this.config.layoutSelection)&&void 0!==c?c:null)),void function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:o,warned:r}=e;ut(o)&&0===n.length&&dt(r,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&dt(r,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[];const u=tt(this.config.chartType);if(!u)return;const d=u.hierarchical?Array.from(this.nodes.values()):this.nodesArray,h=u.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:f,sceneEdges:g,labels:y}=u.buildScene(d,h,this.config,e);this.sceneNodes=f,this.sceneEdges=g,this.labels=y}rebuildNodeQuadtree(){let e=0,t=0;for(const n of this.sceneNodes)"circle"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxNodeRadius=t,gt.QUADTREE_THRESHOLD>=e)return void(this._nodeQuadtree=null);const n=Array(e);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(n[o++]=e);this._nodeQuadtree=c.quadtree().x(e=>e.cx).y(e=>e.cy).addAll(n)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=tt(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=tt(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ht(e._prevX0,e._targetX0,n),e.x1=ht(e._prevX1,e._targetX1,n),e.y0=ht(e._prevY0,e._targetY0,n),e.y1=ht(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=ht(e._prevY0,e._targetY0,n),e.y1=ht(e._prevY1,e._targetY1,n),e.sankeyWidth=ht(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,o){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,s=o.x0,a=n.interpolateNumber(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:s}],halfWidth:r}}const i=t.x1,s=o.x0,a=n.interpolateNumber(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:s,y:e.y1}],halfWidth:r}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,s=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const s=this.config.pulse;if(!s)return;const a=null!==(t=s.duration)&&void 0!==t?t:500,l=null!==(n=s.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=s.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;a>r&&(t._pulseIntensity=1-r/a,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,s="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!s)continue;const c=this.edgeTimestamps.get(`${o}\0${s}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=l)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const o=this.nodeTimestamps.size;if(1>=o)return;if(!this._decaySortedNodes){this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const e=new Map;for(let t=0;this._decaySortedNodes.length>t;t++)e.set(this._decaySortedNodes[t][0],t);this._decayAgeMap=e}const r=this._decayAgeMap;for(const i of this.sceneNodes){const s=i.id;if(!s)continue;const a=r.get(s);if(void 0===a)continue;const l=ft(n,a,o),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",s=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const l=o.metric(a);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),s&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const o=this.nodes.get(e);if(!o)return null;const r=o.data?Object.assign({},o.data):{};return o.data=t(null!==(n=o.data)&&void 0!==n?n:{}),this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}updateEdge(e,t,n){var o;const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,s=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){s.push(r.data?Object.assign({},r.data):{}),r.data=n(null!==(o=r.data)&&void 0!==o?o:{});const e=i(r.data);null!=e&&(r.value=Number(e))}return s.length>0&&(this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now()),s}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++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&(this.layoutVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now()),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,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.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear()}}function yt(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 pt(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(!mt(e))return!1;return!0}return mt(t.points)}function mt(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 vt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:d.createElement(d.Fragment,null,...t)}gt.QUADTREE_THRESHOLD=500;const bt={isActive:!1,predicate:()=>!0},xt=d.createContext(null);function kt({value:t,children:n}){return e.jsx(xt.Provider,{value:t,children:n})}function wt(t,n){return null!=t?e.jsx(kt,{value:n,children:t}):t}function St(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function Mt(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}const At={circle:a.symbolCircle,square:a.symbolSquare,triangle:a.symbolTriangle,diamond:a.symbolDiamond,star:a.symbolStar,cross:a.symbolCross,wye:a.symbolWye};function jt(e,t,n){var o,r;if(n)return n;const i=null!=e?e:"circle";if("chevron"===i)return function(e){const t=1.5*Lt(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t);const s=null!==(o=At[i])&&void 0!==o?o:a.symbolCircle;return null!==(r=a.symbol(s,Math.max(1,t))())&&void 0!==r?r:""}function Lt(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function Ct(e,t,n,o,r=30,i,s=0){let a=null,l=r,c=1/0;if(i){const e=function(e,t,n,o,r,i=e=>e.x,s=e=>e.y,a=e=>e.r){const l=Math.max(o,r+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,r,l,y,p)=>{if(r>u||c>y||l>h||d>p)return!0;if(!e.length){let r=e;do{const e=r.data,l=i(e)-t,c=s(e)-n,u=Math.sqrt(l*l+c*c);St(a(e),o)>=u&&g>u&&(f=e,g=u),r=r.next}while(r)}return!1}),f?{node:f,distance:g}:null}(i,n,o,r,s,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Et(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Pt(e,n,o);t&&l>t.distance&&(a=t,l=t.distance)}return a}function Et(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,s=Math.sqrt(r*r+i*i);return s>St(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,o);case"rect":return function(e,t,n){const o=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const s=Mt(Math.atan2(r,o)),a=Mt(e.startAngle),l=Mt(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){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);case"symbol":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,s=Math.sqrt(r*r+i*i);return s>St(Lt(e.size),o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,o);default:return null}}let Ot=null,Dt=null;function _t(){return Dt||(Ot=document.createElement("canvas"),Ot.width=1,Ot.height=1,Dt=Ot.getContext("2d")),Dt}function Nt(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 Pt(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Nt(e),r=_t();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const s=r.isPointInStroke(o,t,n);if(r.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let s=((t-e.x1)*o+(n-e.y1)*r)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*o,l=e.y1+s*r,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Nt(e),r=_t();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const s=r.isPointInStroke(o,t,n);if(r.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Tt(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?It(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?It(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function It(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function Rt(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}const Wt="var(--semiotic-focus, #005fcc)";function $t({active:t,hoverPoint:n,margin:o,size:r,shape:i="circle",width:s,height:a}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===i&&null!=s&&null!=a){const t=Math.max(s,4),n=Math.max(a,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:Wt,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:Wt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Wt,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Bt({x:t,y:n,containerWidth:o,containerHeight:r,margin:i,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(t)&&Number.isFinite(n),u=d.useRef(null),[h,f]=d.useState(null);d.useLayoutEffect(()=>{const e=u.current;if(!e)return;const t=e.getBoundingClientRect();f(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,o,r]);let g;g=h?`translate(${h.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const y=function(e){if(!d.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(s),p=y?null:b;return c?e.jsx("div",{ref:u,className:y?a:(a+" 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:s}):null}function zt(n){let o=null;const r=()=>(o||(o=t.createContext(null)),o),i=Ht(n);return[function({children:o,initialState:i}){const s=t.useRef(i),a=t.useMemo(()=>Ht(n,s.current),[]),l=r();return e.jsx(l.Provider,{value:a,children:o})},(e,n)=>{var o;const s=r(),a=null!==(o=t.useContext(s))&&void 0!==o?o:i,l=t.useRef(e);l.current=e;const c=t.useRef({hasValue:!1,value:void 0}),u=t.useCallback(()=>{const e=l.current(a.getState()),t=c.current;return t.hasValue&&n&&n(t.value,e)?t.value:(c.current={hasValue:!0,value:e},e)},[a,n]),d=t.useCallback(()=>l.current(a.getState()),[a]);return t.useSyncExternalStore(a.subscribe,u,d)}]}function Ht(e,t){const n=new Set;let o=Object.assign(Object.assign({},e(function(e){const t=e(o);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){o=Object.assign(Object.assign({},o),t);for(const e of n)e()}})),null!=t?t:{});return{getState:()=>o,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Ft(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 Yt(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"],Gt={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},qt={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Vt={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 Kt(e,t){if("light"===t)return Gt;if("dark"===t)return qt;if("high-contrast"===t)return Vt;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?qt:Gt;return Yt(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 Yt(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[Qt,Zt]=zt(e=>({theme:Gt,setTheme(t){e(e=>({theme:Kt(e.theme,t)}))}}));const Ut=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Jt=new WeakMap;let en=0,tn=!1,nn=null,on=null,rn=null;function sn(e,t){var n,o;if(!t)return t;const r=Ut.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;!function(){if(tn)return;if("undefined"==typeof window||"undefined"==typeof document)return;tn=!0;const e=()=>{en++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(nn=new MutationObserver(e),nn.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{on=window.matchMedia("(prefers-color-scheme: dark)"),rn=e,"function"==typeof on.addEventListener?on.addEventListener("change",rn):"function"==typeof on.addListener&&on.addListener(rn)}catch(e){}}();let s=Jt.get(i);s&&s.version===en||(s={version:en,map:new Map},Jt.set(i,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return s.map.set(t,l),l}const an="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function ln(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function cn(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){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>n(e.matches))},[]),e}(),o=t.useRef(n);o.current=n;const[r,i]=function(e,n,o){const r=t.useRef(null),[i,s]=t.useState(null);return t.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:e[0],o&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),s=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),a=i[0]-s.left-s.right,l=i[1]-s.top-s.bottom,c=ln(e.foregroundGraphics,i,s),u=ln(e.backgroundGraphics,i,s),h=Zt(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const r="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(r||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+d.useId(),p=t.useRef(0),m=t.useRef(()=>{}),v=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>m.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)},[]),M=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(S))},[S]),A=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 an(()=>{j&&(en++,j.current=!0,v())},[h,v,j]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:r,size:i,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:h,transition:f,introEnabled:g,tableId:y,rafRef:p,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:M,onPointerLeave:A}}const un={fresh:1,aging:.7,stale:.45,expired:.25},dn={alpha:1,band:"fresh",isStale:!1};function hn({isStale:t,position:n}){return e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===n?{top:4,left:4}:"bottom-left"===n?{bottom:4,left:4}:"bottom-right"===n?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"}),children:t?"STALE":"LIVE"})}const fn={fill:(t,n)=>e.jsx("rect",{style:t,width:n,height:n}),line:(t,n)=>e.jsx("line",{style:t,x1:0,y1:0,x2:n,y2:n})};function gn(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,fn[n])(o(e,t),r),i}function yn({swatchSize:t}){return e.jsx("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function pn(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const mn=(t,n,o,r,i,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=t,y=[];let p=0;const m=!(!n&&!o),v="isolate"===u||void 0===u&&null!=i,{swatchSize:b,labelGap:x,rowHeight:k}=d;return g.forEach((t,u)=>{const d=gn(t,u,h,f,b),w=pn(t,r,i),S=i&&i.size>0&&i.has(t.label);y.push(e.jsxs("g",{transform:`translate(0,${p})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?l===s&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&v?S||!1:void 0,"aria-current":m&&!v&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:m?e=>{var o;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)+g.length)%g.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+x+2+7*t.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),d,S&&e.jsx(yn,{swatchSize:b}),e.jsx("text",{y:b/2,x:b+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),p+=k}),y};function vn({config:t,orientation:n="vertical",width:o=100}){const{colorFn:r,domain:i,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+d.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:r(i[0]+n*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&e.jsx("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])}),e.jsx("text",{x:a+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])})]})}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:r(i[1]-n*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),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 bn(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:h="vertical",legendLayout:f}=t,g=function(e){var t,n,o,r,i;const s=Math.max(1,null!==(t=null==e?void 0:e.swatchSize)&&void 0!==t?t:16),a=Math.max(s,null!==(n=null==e?void 0:e.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(o=null==e?void 0:e.labelGap)&&void 0!==o?o:6),itemGap:Math.max(0,null!==(r=null==e?void 0:e.itemGap)&&void 0!==r?r:10),rowHeight:a,align:"left"===(null==e?void 0:e.align)?"start":"right"===(null==e?void 0:e.align)?"end":null!==(i=null==e?void 0:e.align)&&void 0!==i?i:"start",maxWidth:null==e?void 0:e.maxWidth}}(f),[y,p]=d.useState(0),[m,v]=d.useState(0),b=d.useCallback((e,t)=>{p(e),v(t)},[]),x="vertical"===h?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return t.forEach((t,g)=>{h+=5,f.push(e.jsx("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,t.label&&(h+=16,f.push(e.jsx("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),h+=8),f.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:mn(t,o,r,i,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=t.items.length*d.rowHeight+8}),f})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:y,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:a,metrics:g}):(({legendGroups:t,height:n,width:o,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d,metrics:h})=>{var f;let g=0;const y=[];t.forEach((t,n)=>{var f;let p=0;t.label&&(p+=16);const m=((t,n,o,r,i,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=t,p=[],{swatchSize:m,labelGap:v,itemGap:b,rowHeight:x,align:k}=d,w=!(!n&&!o),S="isolate"===u||void 0===u&&null!=i,M=y.map(e=>m+v+7*e.label.length),A=[];let j=0,L=0;M.forEach((e,t)=>{const n=0===L?e:L+b+e;h&&h>0&&L>0&&n>h?(A.push({start:j,end:t,width:L}),j=t,L=e):L=n}),y.length>0&&A.push({start:j,end:y.length,width:L}),A.forEach((t,u)=>{let d="center"===k?Math.max(0,((null!=h?h:t.width)-t.width)/2):"end"===k?Math.max(0,(null!=h?h:t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=y[h],k=gn(t,h,f,g,m),A=pn(t,r,i),j=i&&i.size>0&&i.has(t.label);p.push(e.jsxs("g",{transform:`translate(${d},${u*x})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:w?l===s&&h===a?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&S?j||!1:void 0,"aria-current":w&&!S&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:w?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(h+("ArrowRight"===e.key?1:-1)+y.length)%y.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:w?e=>{c(l,h),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+v+2+7*t.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,j&&e.jsx(yn,{swatchSize:m}),e.jsx("text",{y:m/2,x:m+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+h)),d+=M[h]+b}});const C=Math.max(0,...A.map(e=>e.width)),E=A.length;return{items:p,offset:C,totalRows:E,totalHeight:E*x}})(t,r,i,s,a,l,c,n,u,d,h,null!==(f=h.maxWidth)&&void 0!==f?f:o);p+=m.offset+5,y.push(Object.assign(Object.assign({label:t.label},m),{offset:p,totalRows:m.totalRows,totalHeight:m.totalHeight})),g+=p+12});const p=null!==(f=h.maxWidth)&&void 0!==f?f:o;let m=g>p?0:"center"===h.align?Math.max(0,(p-g)/2):"end"===h.align?Math.max(0,p-g):0;const v=[];return y.forEach((o,r)=>{const i=t[r];i.label&&(v.push(e.jsx("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+r)),m+=16),v.push(e.jsx("g",{className:"legend-item",transform:`translate(${m},0)`,children:o.items},"legend-group-"+r)),m+=o.offset+5,t[r+1]&&v.push(e.jsx("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+r)),m+=12}),e.jsx("g",{children:v})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:y,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:a,metrics:g}),k=!(!o&&!r);return e.jsxs("g",{role:k?"listbox":void 0,"aria-multiselectable":!(!k||"isolate"!==a&&(void 0!==a||null==s))||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}),x]})}function xn(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function kn(e){return"object"==typeof e&&null!==e&&"gradient"in e}function wn(t){var n;const{legend:o,totalWidth:r,totalHeight:i,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=t;if(!o)return null;const y="top"===a||"bottom"===a,p=!!c,m=Math.max(1,y?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,r-s.left-s.right):100);let v,b;return"left"===a?(v=Math.max(4,s.left-m-10),b=s.top):"top"===a?(v=s.left,b=p?32:8):"bottom"===a?(v=s.left,b=i-s.bottom+38):(v=r-s.right+10,b=s.top),e.jsx("g",{transform:`translate(${v}, ${b})`,children:kn(o)?e.jsx(vn,{config:o.gradient,orientation:y?"horizontal":"vertical",width:m}):xn(o)?e.jsx(bn,{legendGroups:o.legendGroups,title:"",width:m,orientation:y?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}const Sn={secondary:0,primary:3},Mn=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function An(e){return!0===(null==e?void 0:e._annotationDeferred)}function jn(e){return"blended"===(null==e?void 0:e.cohesion)||"layer"===(null==e?void 0:e.cohesion)?e.cohesion:null}function Ln(e){var t;const n=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function Cn(e){return Math.max(.72,.95-.06*e)}function En(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function On(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Dn(e){return null==e?null:e+""}function _n(e,t,n){var o;return null===(o=t.stickyPositionCache)||void 0===o||o.set(e,n),n}const Nn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Pn(e){return!!e&&"object"==typeof e&&Nn.has(function(e){return"string"==typeof(null==e?void 0:e.type)?e.type:""}(e))}function Tn(e){return"primary"===(null==e?void 0:e.emphasis)||!0===(null==e?void 0:e.defensive)}function In(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Rn(e){var t,n;let o;const r=null==e?void 0:e.emphasis;o="primary"===r?100:"secondary"===r?10:50;const i=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(o+=15*function(e){return Math.max(0,Math.min(1,e))}(i)),null===(n=null==e?void 0:e.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}new Set(["label","callout","callout-circle","callout-rect"]);const Wn=32,$n=6,Bn=4,zn=8,Hn=72;const Fn={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Yn(e){return Pn(e)}function Xn(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function Gn(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function qn(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Vn(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Kn(e,t,n,o,r,i,s,a){const l=qn(e,s);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(l,r,i,a);for(const e of n)c+=12*Vn(l,e);for(const e of o)c+=4*Vn(l,e);return c}function Qn(e,t,n){var o,r;if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const i=null!==(o=e.pointId)&&void 0!==o?o:e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const s=e.coordinates,a=null===(r=n.scales)||void 0===r?void 0:r.geoProjection;if(Array.isArray(s)&&s.length>=2&&a){const e=s[0],t=s[1];if("number"==typeof e&&"number"==typeof t){const n=a([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?function(e,t,n){var o,r;const i=e.anchor||(null===(o=e.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return _n(t,n,{x:r.x,y:r.y})}const o=function(e){var t,n,o,r,i,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return o?_n(t,n,o):null}if("semantic"===i){const o=function(e,t,n){var o,r;const i=function(e){var t,n;return Dn(null!==(n=null===(t=e.provenance)||void 0===t?void 0:t.stableId)&&void 0!==n?n:e.stableId)}(e);if(!i)return null;const s=null===(o=n.pointNodes)||void 0===o?void 0:o.find(e=>Dn(e.pointId)===i);if(s)return _n(t,n,{x:s.x,y:s.y});const a=null===(r=n.data)||void 0===r?void 0:r.find(e=>function(e){var t,n,o;return Dn(null!==(n=null!==(t=e.stableId)&&void 0!==t?t:e.id)&&void 0!==n?n:null===(o=e.provenance)||void 0===o?void 0:o.stableId)}(e)===i);if(!a)return null;const l=En(a,n),c=On(a,n);return null==l||null==c?null:_n(t,n,{x:l,y:c})}(e,t,n);if(o)return o}let s=null,a=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,a=t.y)}if(null!=s&&null!=a||(s=En(e,n),a=On(e,n)),null!=s&&null!=a)return _n(t,n,{x:s,y:a});if("sticky"===i){const e=null===(r=n.stickyPositionCache)||void 0===r?void 0:r.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function Zn(e){var t;const{annotations:n,context:o,defaultOffset:r=Wn,notePadding:i=$n,markPadding:s=Bn,edgePadding:a=zn,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:u=Hn,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:y,audience:p}=e,m=o.width||0,v=o.height||0;if(0===n.length||0>=m||0>=v)return n.slice();const b=[],x=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(o,s);let k=!1;const w=n.map((e,t)=>{if(!Yn(e))return e;const n=Qn(e,t,o);if(!n)return e;const s=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...Xn("string"==typeof e.title?e.title:void 0,t),...Xn("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(l&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return b.push(qn(Gn(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,s),i)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Kn(Gn(n.x,n.y,e.dx,e.dy,s),e,b,x,m,v,i,a);f>t&&(h=e,f=t)}if(!h)return e;const g=qn(Gn(n.x,n.y,h.dx,h.dy,s),i);b.push(g);const y=Math.hypot(h.dx,h.dy),p=c&&y>=u&&"text"!==e.type&&"widget"!==e.type?Object.assign(Object.assign({},e.connector||{end:"arrow"}),{type:"curve"}):e.connector;return k=!0,Object.assign(Object.assign(Object.assign({},e),{dx:h.dx,dy:h.dy}),p?{connector:p}:{})}),S=k?w:n.slice();let M=S;if(f){let e=!1;const t=S.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:Object.assign(Object.assign({},e),{_redundantConnector:!0})}(t);return n!==t&&(e=!0),n});M=e?t:S}{let e=!1;const t=M.map(t=>{if(!0!==(null==t?void 0:t.defensive))return t;const n=function(e){var t;const n=null==e?void 0:e.provenance;if(!n||"object"!=typeof n)return e;const o="string"==typeof n.source?null!==(t=Fn[n.source])&&void 0!==t?t:n.source:null,r="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const i=[o,r].filter(Boolean).join(" · "),s="string"==typeof e.label?e.label:"";return s.includes(`(${i})`)?e:Object.assign(Object.assign({},e),{label:s?`${s} (${i})`:`(${i})`})}(t);return n!==t&&(e=!0),n});M=e?t:M}const A=new Set;if(d){const e="object"==typeof d?d:{},n=function(e){if(!e)return 1;const t=function(e){const t=null==e?void 0:e.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(p),o=1===n?e:Object.assign(Object.assign({},e),{maxAnnotations:Math.max(0,Math.round((null!==(t=e.maxAnnotations)&&void 0!==t?t:In(m,v,e))*n))}),{deferred:r}=function(e){var t;const{annotations:n,width:o,height:r}=e,i=Math.max(0,null!==(t=e.minVisible)&&void 0!==t?t:1),s=In(o,r,e),a=n.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Pn(n))};var n}),l=a.filter(e=>e.note);if(0===l.length||s>=l.length)return{visible:n.slice(),deferred:[],budget:s};const c=l.filter(e=>Tn(e.annotation)),u=l.filter(e=>!Tn(e.annotation)).sort((e,t)=>Rn(t.annotation)-Rn(e.annotation)||e.index-t.index),d=Math.min(u.length,Math.max(Math.max(0,s-c.length),Math.max(0,i-c.length))),h=new Set([...c.map(e=>e.index),...u.slice(0,d).map(e=>e.index)]),f=[],g=[];for(const{annotation:e,index:t,note:n}of a)!n||h.has(t)?f.push(e):g.push(e);return{visible:f,deferred:g,budget:s}}(Object.assign({annotations:M,width:m,height:v},o));for(const e of r)A.add(e)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const e of M)Yn(e)&&"secondary"===e.emphasis&&A.add(e);if(A.size>0)for(const e of M)!0===(null==e?void 0:e.defensive)&&A.delete(e);let j;return j=0===A.size?M:h?M.map(e=>A.has(e)?Object.assign(Object.assign({},e),{_annotationDeferred:!0}):e):M.filter(e=>!A.has(e)),y?function(e,t){let n=!1;const o=e.map(e=>Yn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,Object.assign(Object.assign({},e),{cohesion:t})):e);return n?o:e}(j,y):j}function Un(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,labels:a,title:l,legend:c,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g,legendPosition:y="right",legendLayout:p,foregroundGraphics:m,sceneNodes:v,annotations:b,autoPlaceAnnotations:x,svgAnnotationRules:k}=t,w=d.useMemo(()=>{const e=(v||[]).flatMap(e=>{const t=function(e){var t,n,o,r;const i=null!==(t=e.cx)&&void 0!==t?t:null!=e.x&&null!=e.w?e.x+e.w/2:e.x,s=null!==(n=e.cy)&&void 0!==n?n:null!=e.y&&null!=e.h?e.y+e.h/2:e.y;return"number"!=typeof i||"number"!=typeof s?null:{x:i,y:s,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Lt(e.size)):Math.max(1,null!==(o=e.w)&&void 0!==o?o:0,null!==(r=e.h)&&void 0!==r?r:0)/2}}(e),n=function(e){var t,n,o,r,i,s,a,l;const c=null!==(s=null!==(o=null!==(t=e.id)&&void 0!==t?t:null===(n=e.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:null===(i=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===i?void 0:i.id)&&void 0!==s?s:null===(l=null===(a=e.datum)||void 0===a?void 0:a.data)||void 0===l?void 0:l.name;return null==c?void 0:c+""}(e);return t?[Object.assign({pointId:n},t)]:[]});return{scales:null,width:n,height:o,frameType:"network",pointNodes:e,sceneNodes:v}},[o,v,n]),S=d.useMemo(()=>b&&x?Zn(Object.assign({annotations:b,context:w},"object"==typeof x?x:{})):b,[b,x,w]),M=S?function(t){const n=t.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:Ln(e.annotation),readingOrder:null,rank:1};var n}),o=n.some(e=>null!=e.emphasis||null!=e.confidence),r=t.some(e=>An(e.annotation)),i=t.some(e=>null!=jn(e.annotation)),s=t.some(e=>"layer"===jn(e.annotation));if(!o&&!r&&!i)return t.map(e=>e.node);const a=n.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>{var n,o;return(null!==(n=t.confidence)&&void 0!==n?n:0)-(null!==(o=e.confidence)&&void 0!==o?o:0)||e.i-t.i});a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of n)e.emphasis&&(e.rank=Sn[e.emphasis]);const l=n.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(t=>{const{p:n,i:o,emphasis:r,readingOrder:i}=t,s=An(n.annotation);let a=n.node;if("primary"===r||"secondary"===r||null!=i){const t=null==r&&null!=i;a=e.jsx("g",Object.assign({className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r},"secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},t?{opacity:Cn(i),"data-annotation-reading-order":i}:{},{children:n.node}),"annotation-emphasis-"+o)}const l=jn(n.annotation);return l&&(a=e.jsx("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+o)),s&&(a=e.jsx("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+o)),a});return r&&l.unshift(e.jsx("style",{children:Mn},"annotation-disclosure-style")),s&&l.unshift(e.jsx("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),l}(S.reduce((t,n,o)=>{if("widget"===n.type||!k)return t;const r=k(n,o,w);return r&&t.push({node:e.jsx(d.Fragment,{children:r},"annotation-"+o),annotation:n}),t},[])):null,A=!0===(null==S?void 0:S.some(e=>"widget"===e.type&&!0===e._annotationDeferred));return e.jsxs(e.Fragment,{children:[A&&e.jsx("style",{children:Mn},"annotation-widget-disclosure-style"),e.jsxs("svg",{role:"img",width:r,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(${s.left},${s.top})`,children:[a.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]}),l&&"string"==typeof l?e.jsx("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:r,height:s.top,children:l}):null,wn({legend:c,totalWidth:r,totalHeight:i,margin:s,legendPosition:y,title:l,legendLayout:p,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:f,legendIsolatedCategories:g})]}),null==S?void 0:S.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,n)=>{var o,r,i,a,l,c,u,d,h;const f=!0===t._annotationDeferred,g=v.find(e=>{var n,o,r,i,s;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(r=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.id)===t.nodeId||(null===(s=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===s?void 0:s.name)===t.nodeId});if(!g)return null;const y=s.left+(null!==(o=g.cx)&&void 0!==o?o:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(r=g.x)&&void 0!==r?r:0),p=s.top+(null!==(i=g.cy)&&void 0!==i?i:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(a=g.y)&&void 0!==a?a:0),m=null!==(l=t.dx)&&void 0!==l?l:0,b=null!==(c=t.dy)&&void 0!==c?c:-16,x=null!==(u=t.width)&&void 0!==u?u:32,k=null!==(d=t.height)&&void 0!==d?d:32,w=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{className:f?"annotation-deferred":void 0,"data-annotation-disclosure":f?"deferred":void 0,style:{position:"absolute",left:y+m-x/2,top:p+b-k/2,width:x,height:k,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:w},"widget-"+n)})]})}Un.displayName="NetworkSVGOverlay";const Jn={position:"absolute",top:0,left:0,pointerEvents:"none"};function eo({marks:t,margin:n,selection:o=null,overscan:r=400}){const i=d.useRef(null),s=function(e,t,n){const[o,r]=d.useState(null);return d.useLayoutEffect(()=>{const e=t.current,n=function(e){var t;let n=null!==(t=null==e?void 0:e.parentElement)&&void 0!==t?t:null;for(;n;){const{overflow:e,overflowX:t,overflowY:o}=window.getComputedStyle(n);if(/(auto|scroll|overlay)/.test(`${e} ${o} ${t}`))return n;n=n.parentElement}return null}(e);if(!e||!n)return void r(null);let o=0;const i=()=>{o=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();r(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===o&&(o=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),d.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:i}=o,s=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=r+e.x,n=i+e.y;return!(s>t+e.width||t>a||l>n+e.height||n>c)})},[e,o,n])}(t,i,r);if(!t||0===t.length)return null;const a=e.jsx("div",{className:"semiotic-network-html-marks",ref:i,style:Object.assign(Object.assign({},Jn),{transform:`translate(${n.left}px, ${n.top}px)`}),children:(null!=s?s:t).map(t=>e.jsx("div",{className:"semiotic-network-html-mark","data-mark-id":t.id,style:{position:"absolute",transform:`translate(${t.x}px, ${t.y}px)`,width:t.width,height:t.height,pointerEvents:"none"},children:t.content},t.id))});return null!=o?e.jsx(kt,{value:o,children:a}):a}const to={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function no(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const oo="undefined"==typeof window||"undefined"==typeof document,ro="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,io=()=>()=>{},so=()=>!1,ao=()=>!0;function lo(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 uo(e,t);if(!ho(e)||!ho(t))return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!uo(n,r))return!1}else{if(!ho(n)||!ho(r))return!1;if(!co(n,r))return!1}}return!0}(n.current,e)||(n.current=e),n.current}function co(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function uo(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 ho(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 fo=d.createContext(null),go={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function yo(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}const po=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},mo="semiotic-accessible-data-table",vo=mo+" semiotic-accessible-data-table-hidden",bo=mo+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",xo={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},ko={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},wo={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},So={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Mo={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Ao={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},jo={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Lo={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Co({nodes:t,edges:n,chartType:o,tableId:r,chartTitle:i}){var s,a,l,c,u,h,f,g,y,p,m,v,b,x;const[k,w]=d.useState(!1),[S,M]=d.useState(5),A=d.useContext(fo),j=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,L=k||j,C=i?"Data summary for "+i:r?`Data summary for ${o} ${r}`:"Data summary for "+o,E=d.useRef(null);d.useEffect(()=>{L||M(5)},[L]);const O=d.useCallback(e=>{e.target===e.currentTarget&&(k||j||w(!0))},[k,j]),D=d.useCallback(e=>{var t;j||(null===(t=E.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[j]);if(!t||0===t.length)return r?e.jsx("span",{id:r,tabIndex:-1,style:go}):null;if(!L)return e.jsx("div",{id:r,className:vo,tabIndex:-1,onFocus:O,style:go,role:"region","aria-label":C,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",n.length," edges)"]})});const _=Array.isArray(t)?t:[],N=Array.isArray(n)?n:[],P=new Map,T=new Map,I=new Map,R=new Map;for(const e of N){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,n="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,o="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,r="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(u=T.get(e))&&void 0!==u?u:0)+1),R.set(e,(null!==(h=R.get(e))&&void 0!==h?h:0)+r)}if(null!=o&&""!==o){const e=o+"";P.set(e,(null!==(f=P.get(e))&&void 0!==f?f:0)+1),I.set(e,(null!==(g=I.get(e))&&void 0!==g?g:0)+r)}}const W=[];for(let e=0;_.length>e;e++){const t=_[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,o=null!=n?n+"":"node-"+e,r=null!==(m=P.get(o))&&void 0!==m?m:0,i=null!==(v=T.get(o))&&void 0!==v?v:0,s=null!==(b=I.get(o))&&void 0!==b?b:0,a=null!==(x=R.get(o))&&void 0!==x?x:0;W.push({id:o,degree:r+i,inDeg:r,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}W.sort((e,t)=>t.degree-e.degree);let $=0,B=0;if(W.length>0){let e=0;for(const t of W)e+=t.degree,t.degree>B&&(B=t.degree);$=e/W.length}const z=N.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)}),H=[`${W.length} nodes, ${N.length} edges.`];W.length>0&&H.push(`Mean degree: ${po($)}, max degree: ${B}.`);const F=Math.min(S,W.length),Y=W.slice(0,F),X=W.length-F;return e.jsxs("div",{ref:E,id:r,className:bo,tabIndex:-1,onBlur:D,style:xo,role:"region","aria-label":C,children:[e.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{j&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:wo,children:"×"}),e.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:ko,children:H.join(" ")}),e.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+o,style:So,children:[e.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:jo,children:X>0?`Top ${F} of ${W.length} nodes by degree`:`All ${W.length} nodes by degree`}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Mo,children:"id"}),e.jsx("th",{style:Mo,children:"degree"}),e.jsx("th",{style:Mo,children:"in"}),e.jsx("th",{style:Mo,children:"out"}),z&&e.jsx("th",{style:Mo,children:"w. degree"}),z&&e.jsx("th",{style:Mo,children:"w. in"}),z&&e.jsx("th",{style:Mo,children:"w. out"})]})}),e.jsx("tbody",{children:Y.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:Ao,children:t.id}),e.jsx("td",{style:Ao,children:t.degree}),e.jsx("td",{style:Ao,children:t.inDeg}),e.jsx("td",{style:Ao,children:t.outDeg}),z&&e.jsx("td",{style:Ao,children:po(t.wDegree)}),z&&e.jsx("td",{style:Ao,children:po(t.wInDeg)}),z&&e.jsx("td",{style:Ao,children:po(t.wOutDeg)})]},n))})]}),X>0&&e.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>M(e=>e+25),style:Lo,children:["Show ",Math.min(25,X)," more"," ",1===X?"node":"nodes"," (",X," remaining)"]})]})}function Eo({summary:t}){return t?e.jsx("div",{role:"note",style:go,children:t}):null}function Oo({tableId:t}){return e.jsx("a",{href:"#"+t,style:go,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,go)},children:"Skip to data table"})}function Do({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:go,children:n})}const _o=Object.freeze([]);function No(e){if(!e)return _o;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function Po(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function To(e,t,n=.3){Po(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 Io(e,t,n=.6){var o,r,i,s,a;if(!Po(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a: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()}const Ro=new Map;function Wo(e){var t;try{if(e.path)return new Path2D(e.path);const n=`${null!==(t=e.symbolType)&&void 0!==t?t:"circle"}:${Math.round(e.size)}`;let o=Ro.get(n);return o||(o=new Path2D(jt(e.symbolType,e.size)),Ro.size>256&&Ro.clear(),Ro.set(n,o)),o}catch(e){return null}}function $o(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Bo(e,t){var n,o,r,i,s,a;if(!t.pathD)return;e.save();const l=$o(t);if(t.style.fill&&"none"!==t.style.fill){const s=t._gradient;if(s){const r=e.createLinearGradient(s.x0,0,s.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,a="string"==typeof t.style.fill?t.style.fill:"#999",l=sn(e,a)||a;r.addColorStop(0,1===s.from?l:"transparent"),r.addColorStop(1,1===s.to?l:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&sn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=sn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(s=t.style.strokeWidth)&&void 0!==s?s:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a: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 zo(e,t){var n,o;e.save();const r=t.style.stroke||"#999";e.strokeStyle=sn(e,r)||r,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Ho(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const s=$o(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&sn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(s)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=sn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(s)),e.restore()}function Fo(e,t){var n,o;if(!t.pathD)return;e.save();const r=$o(t),i=t.style.stroke||"#999";e.strokeStyle=sn(e,i)||i,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&sn(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}const Yo={top:20,right:80,bottom:20,left:80},Xo={top:40,right:40,bottom:40,left:40},Go=new Set(["chord","force","circlepack","orbit"]),qo=[800,600],Vo={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 Ko({data:t}){var n,o,r,i,s,a,l;if("edge"===t.nodeOrEdge){const n=t.data;return n?e.jsxs("div",{className:"semiotic-tooltip",style:Vo,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 c=t.data;if(!c)return null;const u=c.__hierarchyNode;if(u){const t=[];let s=u;for(;s;){const e=null!==(i=null!==(o=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==o?o:null===(r=s.data)||void 0===r?void 0:r.id)&&void 0!==i?i:c.id;null!=e&&t.unshift(e+""),s=s.parent}t.length>1&&t.shift();const a=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:Vo,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===a?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},n))}),null!=c.value&&c.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const d=((null===(s=c.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=c.targetLinks)||void 0===a?void 0:a.length)||0),h=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),f=function(e,t={}){var n;if(!e||"object"!=typeof e)return{entries:[]};const o=null!==(n=t.maxEntries)&&void 0!==n?n:6,r=!1!==t.skipPositional,i=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&m.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&i.push({key:t,lower:t.toLowerCase(),value:n})}if(0===i.length)return{entries:[]};let s=i.findIndex(e=>g.includes(e.lower));const a=s>=0;0>s&&(s=i.findIndex(e=>"id"===e.lower)),0>s&&(s=i.findIndex(e=>"string"==typeof e.value));const l=0>s?void 0:i[s];let c=i.filter((e,t)=>t!==s);a&&(c=c.filter(e=>"id"!==e.lower));const u=v(c,y),d=v(c,p),h=new Set(y),f=new Set(p),b=[];u&&b.push({key:u.key,value:u.value}),d&&b.push({key:d.key,value:d.value});for(const e of c){if(b.length>=o)break;e!==u&&e!==d&&(h.has(e.lower)||f.has(e.lower)||b.push({key:e.key,value:e.value}))}return{titleKey:null==l?void 0:l.key,title:null==l?void 0:l.value,entries:b}}(null!==(l=c.data)&&void 0!==l?l:c),b=null!=f.title?f.title+"":c.id,x=f.entries.some(e=>Qo.test(e.key));return e.jsxs("div",{className:"semiotic-tooltip",style:Vo,children:[e.jsx("div",{style:{fontWeight:600},children:b}),f.entries.map(t=>{return e.jsxs("div",{style:{marginTop:4,opacity:.8},children:[t.key,": ",(n=t.value,null==n?"–":"number"==typeof n?Math.abs(n)>9999?n.toLocaleString():n+"":n instanceof Date?n.toLocaleDateString():n+"")]},t.key);var n}),!x&&null!=c.value&&c.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),d>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",d,h!==d&&` (weighted: ${h.toLocaleString()})`]})]})}const Qo=/^(value|amount|total|count|weight|score)$/i;Ko.ownsChrome=!0;const Zo=t.forwardRef(function(n,o){var r,i,s,l,c,u,d,h,g,y,p,m,v,b,x,k,w,S,j;const{chartType:L,nodes:C,edges:E,data:O,initialEdges:D,nodeIDAccessor:_="id",sourceAccessor:N="source",targetAccessor:P="target",valueAccessor:T="value",edgeIdAccessor:I,childrenAccessor:R,hierarchySum:W,orientation:$="horizontal",nodeAlign:B="justify",nodePaddingRatio:z=.05,nodeWidth:H=15,iterations:F=300,forceStrength:Y=.1,padAngle:X=.01,groupWidth:G=20,sortGroups:q,edgeSort:V,treeOrientation:K="vertical",edgeType:Q="curve",padding:Z,paddingTop:U,tensionConfig:J,showParticles:ee=!1,particleStyle:te,nodeStyle:ne,edgeStyle:oe,colorBy:re,colorScheme:ie="category10",edgeColorBy:se="source",edgeOpacity:ae=.5,colorByDepth:le=!1,nodeSize:ce=8,nodeSizeRange:ue=[5,20],nodeLabel:de,showLabels:he=!0,labelMode:fe,size:ge=qo,responsiveWidth:ye,responsiveHeight:pe,margin:me,className:ve,background:be,enableHover:xe=!0,tooltipContent:ke,customHoverBehavior:we,customClickBehavior:Se,onObservation:Me,chartId:Ae,onTopologyChange:je,annotations:Le,autoPlaceAnnotations:Ce,svgAnnotationRules:Ee,legend:Oe,legendPosition:De,legendLayout:_e,legendHoverBehavior:Ne,legendClickBehavior:Pe,legendHighlightedCategory:Te,legendIsolatedCategories:Ie,title:Re,foregroundGraphics:We,backgroundGraphics:$e,decay:Be,pulse:ze,transition:He,animate:Fe,staleness:Ye,thresholds:Xe,accessibleTable:Ge=!0,description:qe,summary:Ve,orbitMode:Ke,orbitSize:Qe,orbitSpeed:Ze,orbitRevolution:Ue,orbitRevolutionStyle:Je,orbitEccentricity:et,orbitShowRings:tt,orbitAnimated:nt,customNetworkLayout:rt,layoutConfig:it,layoutSelection:st}=n,at=Go.has(L)?Xo:Yo,lt=t.useRef(!0),ct=cn({sizeProp:ge,responsiveWidth:ye,responsiveHeight:pe,userMargin:me,marginDefault:at,foregroundGraphics:We,backgroundGraphics:$e,animate:Fe,transitionProp:He,themeDirtyRef:lt}),{reducedMotionRef:ut,responsiveRef:dt,size:ht,margin:ft,adjustedWidth:yt,adjustedHeight:pt,resolvedForeground:mt,resolvedBackground:bt,transition:xt,introEnabled:kt,tableId:St,rafRef:Mt,renderFnRef:At,scheduleRender:Lt,currentTheme:Et}=ct,Ot=function(){const[e,n]=t.useState(!1);return ro(()=>{n(!0)},[]),e}(),Dt=function(){const e=t.useSyncExternalStore(io,so,ao);return t.useRef(e).current}(),_t=t.useMemo(()=>No(C),[C]),Nt=t.useMemo(()=>Array.isArray(E)?No(E):E,[E]),Pt=t.useMemo(()=>Object.assign(Object.assign({},M),J),[J]),It=t.useMemo(()=>Object.assign(Object.assign({},A),te),[te]),Wt=t.useMemo(()=>{var e;return{chartType:L,nodeIDAccessor:_,sourceAccessor:N,targetAccessor:P,valueAccessor:T,edgeIdAccessor:I,childrenAccessor:R,hierarchySum:W,orientation:$,nodeAlign:B,nodePaddingRatio:z,nodeWidth:H,iterations:F,forceStrength:Y,padAngle:X,groupWidth:G,sortGroups:q,edgeSort:V,treeOrientation:K,edgeType:Q,padding:Z,paddingTop:U,tensionConfig:Pt,showParticles:ee,particleStyle:It,nodeStyle:ne,edgeStyle:oe,nodeLabel:de,showLabels:he,labelMode:fe,colorBy:re,colorScheme:ie,themeCategorical:null===(e=null==Et?void 0:Et.colors)||void 0===e?void 0:e.categorical,themeSemantic:Ft(Et),edgeColorBy:se,edgeOpacity:ae,colorByDepth:le,nodeSize:ce,nodeSizeRange:ue,decay:Be,pulse:ze,transition:xt,introAnimation:kt,staleness:Ye,thresholds:Xe,orbitMode:Ke,orbitSize:Qe,orbitSpeed:Ze,orbitRevolution:Ue,orbitRevolutionStyle:Je,orbitEccentricity:et,orbitShowRings:tt,orbitAnimated:nt,customNetworkLayout:rt,layoutConfig:it}},[L,_,N,P,T,R,W,$,B,z,H,F,Y,X,G,q,V,K,Q,Z,U,Pt,ee,It,ne,oe,de,he,fe,re,ie,se,ae,le,ce,ue,Be,ze,null==xt?void 0:xt.duration,null==xt?void 0:xt.easing,kt,Ye,Xe,Ke,Qe,Ze,Ue,Je,et,tt,nt,Et,rt,it]),zt=lo(Wt),Ht=lo({chartType:L,nodeIDAccessor:_,sourceAccessor:N,targetAccessor:P,valueAccessor:T,childrenAccessor:R,hierarchySum:W,orientation:$,nodeAlign:B,nodePaddingRatio:z,nodeWidth:H,iterations:F,forceStrength:Y,padAngle:X,groupWidth:G,sortGroups:q,edgeSort:V,treeOrientation:K,edgeType:Q,padding:Z,paddingTop:U,tensionConfig:Pt,orbitMode:Ke,orbitSize:Qe,orbitEccentricity:et,customNetworkLayout:rt}),Yt=t.useRef(null),Xt=t.useRef(0),Gt=t.useRef(0),qt=t.useRef(!1),Vt=t.useRef(null);Vt.current||(Vt.current=new gt(zt));const[Kt,Qt]=t.useState(null),[Zt,Ut]=t.useState(0),[Jt,en]=t.useState(0),[tn,nn]=t.useState(!1),on=t.useRef(null),rn=t.useRef(new Map),an=t.useRef(0),ln=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(!rn.current.has(t+"")){const e=Array.isArray(ie)?ie:ot;rn.current.set(t+"",e[an.current++%e.length])}return rn.current.get(t+"")}}if(rn.current.has(e.id))return rn.current.get(e.id);const t=Array.isArray(ie)?ie:ot,n=re?t[an.current++%t.length]:t[0];return rn.current.set(e.id,n),n},[re,ie]),fn=(null===(r=null==Et?void 0:Et.colors)||void 0===r?void 0:r.border)||(null===(i=null==Et?void 0:Et.colors)||void 0===i?void 0:i.secondary)||(null===(s=null==Et?void 0:Et.colors)||void 0===s?void 0:s.primary)||"#999",gn=t.useCallback(e=>{var t,n;return e?"object"==typeof e?e:null!==(n=null===(t=Vt.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==n?n:null:null},[]),yn=t.useCallback(e=>{if("function"==typeof se)return se(e);const t=gn(e.source),n=gn(e.target);return"target"===se&&n?ln(n):t?ln(t):fn},[se,ln,fn,gn]),pn=t.useCallback(e=>{if("function"==typeof It.color){const t=gn(e.source);return t?It.color(e,t):fn}if(!(null==te?void 0:te.colorBy))return yn(e);const t=It.colorBy,n=gn(e.source),o=gn(e.target);return"target"===t&&o?ln(o):n?ln(n):fn},[null==te?void 0:te.colorBy,It.color,It.colorBy,ln,yn,fn,gn]),mn=("sankey"===L||!!rt)&&ee||!!ze||null!==(c=null===(l=Vt.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=Vt.current)||void 0===e||e.updateConfig(zt),lt.current=!0,Lt()},[zt,Lt]);const vn=t.useRef(null);t.useEffect(()=>{const e=Vt.current;if(!e)return;const t=null!=st?st:null;vn.current!==t&&(vn.current=t,e.setLayoutSelection(t),e.hasCustomRestyle?e.restyleScene(t):lt.current=!0,Lt())},[st,Lt]),t.useEffect(()=>{var e;const t=Vt.current;if(t){t.buildScene([yt,pt]);for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&rn.current.set(n.id,n.style.fill);lt.current=!0,Lt()}},[Et,yt,pt,Lt]);const bn=t.useCallback(()=>{var e;const t=Vt.current;if(!t)return;t.runLayout([yt,pt]),t.buildScene([yt,pt]),lt.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&rn.current.set(n.id,n.style.fill);const n=Array.isArray(ie)?ie:ot,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];rn.current.has(t.id)||rn.current.set(t.id,n[e%n.length])}if(an.current=o.length,Ut(t.layoutVersion),je){const{nodes:e,edges:n}=t.getLayoutData();je(e,n)}},[yt,pt,je,ie]),xn=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=Vt.current;t&&(t.ingestEdge(e)&&bn(),Lt())},[bn,Lt]),kn=t.useCallback(e=>{const t=Vt.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&bn(),Lt()},[bn,Lt]),wn=t.useCallback(()=>{var e,t,n;null===(e=Vt.current)||void 0===e||e.clear(),rn.current.clear(),an.current=0,Ut(null!==(n=null===(t=Vt.current)||void 0===t?void 0:t.layoutVersion)&&void 0!==n?n:0),Qt(null),on.current=null,lt.current=!0,Lt()},[Lt]),Sn=t.useCallback(()=>{const e=Vt.current;e&&(e.tension+=999,bn(),Lt())},[bn,Lt]);t.useImperativeHandle(o,()=>({push:xn,pushMany:kn,removeNode:e=>{var t,n,o;const r=null!==(n=null===(t=Vt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(r){const t=(null===(o=on.current)||void 0===o?void 0:o.data)?"function"==typeof _?_(on.current.data):on.current.data[_]:void 0;on.current&&"node"===on.current.nodeOrEdge&&t===e&&(on.current=null,Qt(null)),rn.current.delete(e),bn(),lt.current=!0,Lt()}return r},removeEdge:(e,t)=>{var n,o;const r=null!==(o=null===(n=Vt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==o&&o;if(r){if(on.current&&"edge"===on.current.nodeOrEdge){const n=on.current.data;let o;o=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!I||!n||("function"==typeof I?I:e=>null==e?void 0:e[I])(n)===e,o&&(on.current=null,Qt(null))}bn(),lt.current=!0,Lt()}return r},updateNode:(e,t)=>{var n,o;const r=null!==(o=null===(n=Vt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==o?o:null;return r&&(lt.current=!0,Lt()),r},updateEdge:(e,t,n)=>{var o,r;const i=null!==(r=null===(o=Vt.current)||void 0===o?void 0:o.updateEdge(e,t,n))&&void 0!==r?r:[];return i.length>0&&(bn(),lt.current=!0,Lt()),i},clear:wn,getTopology:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Vt.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:Sn,getTension:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[xn,kn,wn,Sn,bn,Lt]);const Mn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(L),An=Mn?O||(Array.isArray(E)?void 0:E):void 0;t.useEffect(()=>{var e;const t=Vt.current;if(t)if(Mn&&An)t.ingestHierarchy(An,[yt,pt]),t.buildScene([yt,pt]),lt.current=!0,Lt();else{const n=_t,o=Array.isArray(Nt)?Nt:[];if(0===n.length&&0===o.length)return;t.ingestBounded(n,o,[yt,pt]),t.buildScene([yt,pt]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&rn.current.set(n.id,n.style.fill+"");const r=Array.isArray(ie)?ie:ot,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];rn.current.has(t.id)||rn.current.set(t.id,r[e%r.length])}an.current=i.length,lt.current=!0,Lt()}},[_t,Nt,O,An,Mn,yt,pt,Ht,Lt,ie]),t.useEffect(()=>{D&&D.length>0&&kn(D)},[]);const jn=t.useCallback(e=>{if(we&&we(e),Me){const t=Date.now();Me(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})}},[we,Me,Ae]),Ln=t.useCallback(e=>{if(Se&&Se(e),Me){const t=Date.now();Me(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})}},[Se,Me,Ae]),{hoverHandlerRef:Cn,hoverLeaveRef:En,onPointerMove:On,onPointerLeave:Dn}=ct,_n=()=>{var e,t;return!rt||null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.hasCustomRestyle)&&void 0!==t&&t};Cn.current=e=>{if(!xe)return;const t=_n(),n=Yt.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-ft.left,i=e.clientY-o.top-ft.top;if(0>r||r>yt||0>i||i>pt)return void(on.current&&(on.current=null,Qt(null),jn&&(jn(null),t&&(lt.current=!0)),t&&Lt()));const s=Vt.current;if(!s)return;const a=Ct(s.sceneNodes,s.sceneEdges,r,i,30,s.nodeQuadtree,s.maxNodeRadius);if(!a)return void(on.current&&(on.current=null,Qt(null),jn&&(jn(null),t&&(lt.current=!0)),t&&Lt()));const l=f(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});on.current=l,Qt(l),jn&&(jn(l),t&&(lt.current=!0)),t&&Lt()},En.current=()=>{if(on.current){const e=_n();on.current=null,Qt(null),jn&&(jn(null),e&&(lt.current=!0)),e&&Lt()}};const Nn=t.useRef(()=>{});Nn.current=e=>{if(!Se&&!Me)return;const t=Yt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-ft.left,r=e.clientY-n.top-ft.top;if(0>o||o>yt||0>r||r>pt)return;const i=Vt.current;if(!i)return;const s=Ct(i.sceneNodes,i.sceneEdges,o,r,30,i.nodeQuadtree,i.maxNodeRadius);Ln(s?f(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const Pn=t.useCallback(e=>Nn.current(e),[]),Tn=t.useRef(-1),In=t.useRef(null),Rn=t.useRef(-1),Wn=t.useCallback(e=>{var t;const n=Vt.current;if(!n)return;const o=function(e){var t,n,o,r,i,s,a,l;const c=[];for(const u of e)if("circle"===u.type&&null!=u.cx){if(0>=u.r)continue;c.push({x:u.cx,y:u.cy,datum:u.datum,shape:"circle",group:null!==(n=null===(t=u.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"})}else if("rect"===u.type&&null!=u.x){if(0>=u.w||0>=u.h)continue;c.push({x:u.x+u.w/2,y:u.y+u.h/2,datum:u.datum,shape:"rect",w:u.w,h:u.h,group:null!==(r=null===(o=u.datum)||void 0===o?void 0:o.id)&&void 0!==r?r:"_default"})}else if("arc"===u.type&&null!=u.cx)c.push({x:u.cx,y:u.cy,datum:u.datum,shape:"circle",group:null!==(s=null===(i=u.datum)||void 0===i?void 0:i.id)&&void 0!==s?s:"_default"});else if("symbol"===u.type&&null!=u.cx){if(0>=u.size)continue;c.push({x:u.cx,y:u.cy,datum:u.datum,shape:"circle",group:null!==(l=null===(a=u.datum)||void 0===a?void 0:a.id)&&void 0!==l?l:"_default"})}return c.sort((e,t)=>e.x-t.x||e.y-t.y),c}(n.sceneNodes);if(0===o.length)return;const r=function(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const s=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&&s.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:s}}(o),i=Tn.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(),Tn.current=0,Rn.current=-1;const t=r.flat[0];In.current={shape:t.shape,w:t.w,h:t.h};const n=f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return on.current=n,Qt(n),jn&&(jn(n),lt.current=!0),void Lt()}const s=function(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}(r,i),a=function(e,t,n,o,r){var i,s,a;const l=n.flat[t.flatIndex];if(!l)return Tt(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 o=null!==(s=function(e,t,n){let o=null,r=1/0;for(let i=0;e.flat.length>i;i++){const s=e.flat[i];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;r>u&&(r=u,o=i)}return o}(n,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==s?s:t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n;const o=e+"",r=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,i=Rt(t.source),s=Rt(t.target),a=null!=i,l=null!=s;a&&i+""===o&&l?r.push(s+""):l&&s+""===o&&a&&r.push(i+"")}return r}(c,o);if(0===e.length)return t.flatIndex;const i=null!==(a=n.idToIdx.get(e[(r.current+1)%e.length]))&&void 0!==a?a:-1;return 0>i?t.flatIndex:(r.current=-1,i)}default:{const o=Tt(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,s,r,null!==(t=n.sceneEdges)&&void 0!==t?t:[],Rn);if(null===a)return;if(e.preventDefault(),0>a)return Tn.current=-1,In.current=null,Rn.current=-1,on.current=null,Qt(null),jn&&(jn(null),lt.current=!0),void Lt();Tn.current=a;const l=r.flat[a];In.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"};on.current=c,Qt(c),jn&&(jn(c),lt.current=!0),Lt()},[jn,Lt]),$n=t.useCallback(e=>{Tn.current=-1,In.current=null,On(e)},[On]);At.current=()=>{var e,t,n,o,r,i,s;Mt.current=0;const a=Yt.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=Vt.current;if(!c)return;const u=performance.now(),d=Xt.current?Math.min((u-Xt.current)/1e3,.1):.016;Xt.current=u;const h=c.advanceTransition(ut.current?u+1e6:u),f=!ut.current&&h,g=!ut.current&&c.tickAnimation([yt,pt],d);(h||lt.current||g)&&c.buildScene([yt,pt]);const y="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}(a,ht,ft,y))return;if(l.clearRect(-ft.left,-ft.top,ht[0],ht[1]),be){const e=sn(l,be);e&&(l.fillStyle=e,l.fillRect(0,0,yt,pt))}Be&&c.applyDecay(),ze&&c.applyPulse(u),Xe&&c.applyThresholds(u),!1!==Fe&&c.applyTopologyDiff(u);const p=null!==(e=null==Ye?void 0:Ye.threshold)&&void 0!==e?e:5e3,m=Ye&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(m&&(l.globalAlpha=null!==(t=null==Ye?void 0:Ye.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Bo(e,n);break;case"line":zo(e,n);break;case"ribbon":Ho(e,n);break;case"curved":Fo(e,n)}}(l,c.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&sn(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=sn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),To(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&sn(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=sn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),Io(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&sn(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=sn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(l,c.sceneNodes),function(e,t){var n,o,r;const i=e.globalAlpha;for(const s of t){if("symbol"!==s.type)continue;const t=s;if(0>=t.size)continue;const a=Wo(t);if(!a)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const l=null!==(n=t.style.opacity)&&void 0!==n?n:1;t.style.fill&&(e.globalAlpha=i*l*(null!==(o=t.style.fillOpacity)&&void 0!==o?o:1),e.fillStyle="string"==typeof t.style.fill&&sn(e,t.style.fill)||t.style.fill,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=i*l,e.strokeStyle=sn(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,e.stroke(a)),e.restore()}}(l,c.sceneNodes),ee&&c.particlePool&&!m){const e=c.edgesArray;if(e.length>0){!function(e,t,n,o){var r,i;const s=null!==(r=o.spawnRate)&&void 0!==r?r:A.spawnRate,a=null!==(i=o.maxPerEdge)&&void 0!==i?i:A.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=a)continue;const i=r.value*s*n*(r.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(o)<a;t++)e.spawn(o)}}(c.particlePool,e,d,It);const t=.5*(null!==(n=It.speedMultiplier)&&void 0!==n?n:1);let o;if(It.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,o),function(e,t,n,o,r){var i,s;const a=null!==(i=o.radius)&&void 0!==i?i:A.radius,l=null!==(s=o.opacity)&&void 0!==s?s:A.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const s=t.particles[i];if(!s.active)continue;const l=n[s.edgeIndex];if(!l)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.color:r(l),e.fillStyle=sn(e,c)||c,e.beginPath(),e.arc(s.x,s.y,a,0,2*Math.PI),e.fill()}e.globalAlpha=1}(l,c.particlePool,e,It,pn)}}m&&(l.globalAlpha=1);const v=lt.current;if(lt.current=!1,v||f||g){const e=Yt.current;e&&e.setAttribute("aria-label",yo(null!==(r=null===(o=c.sceneNodes)||void 0===o?void 0:o.length)&&void 0!==r?r:0,null!==(s=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==s?s:0,"Network chart"))}const b=v||f||g||qt.current;b&&u-Gt.current>=33?(en(e=>e+1),Gt.current=u,qt.current=!1):qt.current=!!b,(mn||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||!1!==Fe&&c.hasActiveTopologyDiff||qt.current)&&(Mt.current=requestAnimationFrame(()=>At.current()))},function(e){const{hydrated:n,wasHydratingFromSSR:o,storeRef:r,dirtyRef:i,renderFnRef:s,cleanup:a}=e;ro(()=>{var e,t;n&&o&&(null===(t=null===(e=r.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),i.current=!0,s.current()},[n,o]);const l=t.useRef(a);l.current=a,t.useEffect(()=>()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)},[])}({hydrated:Ot,wasHydratingFromSSR:Dt,storeRef:Vt,dirtyRef:lt,renderFnRef:At}),t.useEffect(()=>{lt.current=!0,Lt()},[L,yt,pt,be,Lt]),function(e,n,o,r,i,s){const a=t.useRef("fresh");t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{const t=n.current;if(!t||0===t.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){var n,o;if(!e||0>=t)return dn;const r=null!=e.threshold&&e.threshold>0?e.threshold:5e3,i=e.graded;if(i){const e="object"==typeof i?i:{},o=function(e,t,n={}){var o,r,i;if(!Number.isFinite(t)||0>=t)return"fresh";if(Number.isNaN(e))return"fresh";if(e===1/0)return"expired";if(0>e)return"fresh";const s=null!==(o=n.fresh)&&void 0!==o?o:1,a=null!==(r=n.aging)&&void 0!==r?r:1.5,l=null!==(i=n.stale)&&void 0!==i?i:3;return t*s>e?"fresh":t*a>e?"aging":t*l>e?"stale":"expired"}(t,r,e.thresholds);return{alpha:Object.assign(Object.assign({},un),null!==(n=e.opacities)&&void 0!==n?n:{})[o],band:o,isStale:"fresh"!==o}}return t>r?{alpha:null!==(o=e.dimOpacity)&&void 0!==o?o:.5,band:"stale",isStale:!0}:dn}(e,l-t.lastIngestTime);c.band===a.current&&c.isStale===i||(a.current=c.band,c.isStale!==i&&s(c.isStale),o.current=!0,r())},1e3);return()=>clearInterval(t)},[e,i,r])}(Ye,Vt,lt,Lt,tn,nn);const Bn=xe&&Kt?e.jsx(Bt,{x:Kt.x,y:Kt.y,containerWidth:yt,containerHeight:pt,margin:ft,className:"stream-network-tooltip",zIndex:2,children:ke?ke(Kt):e.jsx(Ko,{data:Kt})}):null;if(oo||!Ot&&Dt){const t=Vt.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(L),n=e?O||(Array.isArray(E)?void 0:E):void 0;if(e&&n)t.ingestHierarchy(n,[yt,pt]),t.buildScene([yt,pt]);else{const e=_t,n=Array.isArray(Nt)?Nt:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[yt,pt]),t.buildScene([yt,pt]))}}const n=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],o=null!==(d=null==t?void 0:t.sceneEdges)&&void 0!==d?d:[],r=null!==(h=null==t?void 0:t.labels)&&void 0!==h?h:[];return e.jsxs("div",{ref:dt,className:"stream-network-frame"+(ve?" "+ve:""),role:"img","aria-label":qe||("string"==typeof Re?Re:"Network chart"),style:{position:"relative",width:ye?"100%":ht[0],height:pe?"100%":ht[1]},children:[e.jsx(Eo,{summary:Ve}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ht[0],height:ht[1],style:{position:"absolute",left:0,top:0},children:[bt&&e.jsx("g",{transform:`translate(${ft.left},${ft.top})`,children:bt}),e.jsxs("g",{transform:`translate(${ft.left},${ft.top})`,children:[be&&e.jsx("rect",{x:0,y:0,width:yt,height:pt,fill:be}),o.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 o=t;return e.jsx("path",{d:o.pathD,fill:no(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=t;return e.jsx("path",{d:o.pathD,fill:no(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=t;return e.jsx("path",{d:o.pathD,fill:no(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(t,n)).filter(Boolean),n.map((t,n)=>function(t,n){switch(t.type){case"circle":{const o=t;return e.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:no(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=t;return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:no(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=t,r=a.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(to)||"";return e.jsx("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:no(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}case"symbol":{const o=t,r=jt(o.symbolType,o.size,o.path);return e.jsx("path",{d:r,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?no(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-symbol-"+n)}default:return null}}(t,n)).filter(Boolean),r.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(Un,{width:yt,height:pt,totalWidth:ht[0],totalHeight:ht[1],margin:ft,labels:r,sceneNodes:n,title:Re,legend:Oe,legendPosition:De,legendLayout:_e,legendHoverBehavior:Ne,legendClickBehavior:Pe,legendHighlightedCategory:Te,legendIsolatedCategories:Ie,foregroundGraphics:vt(mt,wt(null===(g=Vt.current)||void 0===g?void 0:g.customLayoutOverlays,null!=st?st:null)),annotations:Le,autoPlaceAnnotations:Ce,svgAnnotationRules:Ee,annotationFrame:0}),e.jsx(eo,{marks:null==t?void 0:t.customLayoutHtmlMarks,margin:ft,selection:null!=st?st:null})]})}const zn=Vt.current;return e.jsxs("div",{ref:dt,className:"stream-network-frame"+(ve?" "+ve:""),role:"group","aria-label":qe||("string"==typeof Re?Re:"Network chart"),tabIndex:0,style:{position:"relative",width:ye?"100%":ht[0],height:pe?"100%":ht[1],overflow:"visible"},onKeyDown:Wn,children:[Ge&&e.jsx(Oo,{tableId:St}),Ge&&e.jsx(Co,{nodes:null!==(y=null==zn?void 0:zn.sceneNodes)&&void 0!==y?y:[],edges:null!==(p=null==zn?void 0:zn.sceneEdges)&&void 0!==p?p:[],chartType:"Network chart",tableId:St,chartTitle:"string"==typeof Re?Re:void 0}),e.jsx(Eo,{summary:Ve}),e.jsx(Do,{hoverPoint:Kt}),e.jsxs("div",{role:"img","aria-label":qe||("string"==typeof Re?Re:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:xe?$n:void 0,onMouseLeave:xe?Dn:void 0,onClick:Se||Me?Pn:void 0,children:[bt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ht[0],height:ht[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${ft.left},${ft.top})`,children:bt})}),e.jsx("canvas",{ref:Yt,"aria-label":yo(null!==(v=null===(m=null==zn?void 0:zn.sceneNodes)||void 0===m?void 0:m.length)&&void 0!==v?v:0,null!==(x=null===(b=null==zn?void 0:zn.sceneEdges)||void 0===b?void 0:b.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(Un,{width:yt,height:pt,totalWidth:ht[0],totalHeight:ht[1],margin:ft,labels:(null==zn?void 0:zn.labels)||[],sceneNodes:null==zn?void 0:zn.sceneNodes,title:Re,legend:Oe,legendPosition:De,legendLayout:_e,legendHoverBehavior:Ne,legendClickBehavior:Pe,legendHighlightedCategory:Te,legendIsolatedCategories:Ie,foregroundGraphics:vt(mt,wt(null===(k=Vt.current)||void 0===k?void 0:k.customLayoutOverlays,null!=st?st:null)),annotations:Le,autoPlaceAnnotations:Ce,svgAnnotationRules:Ee,annotationFrame:Jt}),e.jsx(eo,{marks:null==zn?void 0:zn.customLayoutHtmlMarks,margin:ft,selection:null!=st?st:null}),e.jsx($t,{active:Tn.current>=0,hoverPoint:Kt,margin:ft,size:ht,shape:null===(w=In.current)||void 0===w?void 0:w.shape,width:null===(S=In.current)||void 0===S?void 0:S.w,height:null===(j=In.current)||void 0===j?void 0:j.h}),Bn,(null==Ye?void 0:Ye.showBadge)&&e.jsx(hn,{isStale:tn,position:Ye.badgePosition})]})]})});function Uo(e,n){const{variant:o,frameRef:r,overrides:i,deps:s}=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,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,r;return null!==(r=null===(o=e.current)||void 0===o?void 0:o.update(t,n))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==n?n:null}}}if("network"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o,r,i,s;const a=Array.isArray(t)?t:[t],l=null!==(r=null===(o=null===(n=e.current)||void 0===n?void 0:n.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==r?r:[],c=[];for(const t of a){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===(s=e.current)||void 0===s||s.removeNode(t)}return c},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var o;const r=null===(o=e.current)||void 0===o?void 0:o.updateNode(t,n);return r?[Object.assign(Object.assign({},r),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n,o,r;return null!==(r=null===(o=null===(n=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==r?r:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,r,i;const s=null!==(r=null===(o=e.current)||void 0===o?void 0:o.removePoint(t))&&void 0!==r?r:[];for(const t of s)null===(i=e.current)||void 0===i||i.push(n(t));return s},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]}}}const n=t;return{push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,r,i;const s=null!==(r=null===(o=n.current)||void 0===o?void 0:o.removeLine(e))&&void 0!==r?r:[];for(const e of s)null===(i=n.current)||void 0===i||i.pushLine(t(e));return s},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:[]}}}(o,r);return Object.assign(Object.assign({},e),i)},null!=s?s:[])}Zo.displayName="StreamNetworkFrame";const Jo=t.createContext(null);function er(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function tr(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function nr(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}const[or,rr]=zt(e=>({selections:new Map,setClause(t,n){e(e=>{const o=e.selections.get(t),r=null==o?void 0:o.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,o]of n){const n=t.fields[e];if(!n||!nr(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),s=tr(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,Object.assign(Object.assign({},s),{clauses:a})),{selections:i}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o||!o.clauses.has(n))return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=e.selections.get(t);if((null==o?void 0:o.resolution)===n)return{};const r=new Map(e.selections),i=tr(r,t);return r.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const o=new Map(e.selections);return o.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[ir,sr]=zt(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 ar={positions:new Map};const lr=new Set;function cr(){for(const e of lr)e()}function ur(e,t){const n=ar.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(ar.positions);o.delete(e),ar={positions:o},cr()}function dr(e){const n=t.useId(),o=e.clientId||n,{name:r}=e,i=rr(e=>e.selections.get(r)),s=rr(e=>e.setClause),a=rr(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[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(er(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:t.useCallback(e=>{const t={};let n=!1;for(const[o,r]of Object.entries(e))t[o]={type:"point",values:new Set(r)},n=!0;n&&s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:t.useCallback(e=>{const t={};let n=!1;for(const[o,r]of Object.entries(e))t[o]={type:"interval",range:r},n=!0;n&&s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:t.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}const hr=t.createContext(!1),fr=t.createContext(null),gr="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function yr(e,t,n){var o;const r=null!==(o=e.xValue)&&void 0!==o?o:null==t?void 0:t[n];if(null==r)return null;const i=Number(r);return Number.isFinite(i)?i:null}function pr(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 mr(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function vr(){var e;const t=Zt(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 br(e,t,n,o,r){let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=nt[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function xr({selection:e,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a,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,seriesField:e.seriesField}:null}(n,o),f="series"===(null==h?void 0:h.mode)?[h.seriesField||u||o[0]].filter(e=>!!e):(null==h?void 0:h.fields)||o||[],g=dr({name:(null==e?void 0:e.name)||"__unused__"}),y=function(e){const n=e.name||"hover",{fields:o}=e,{predicate:r,isActive:i,selectPoints:s,clear:a}=dr({name:n}),l=t.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&s(t)},[o,s,a,n]);return{onHover:l,predicate:r,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:f}),p=sr(e=>e.pushObservation),m=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,b]=t.useState(null),x=u||o[0],k=t.useMemo(()=>{if(!c||null==v||!x)return null;const e=v,t=x;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,v,x]),w=t.useCallback(e=>{var t,o;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=yr(e,t,h.xField);null!=n&&function(e,t,n){const o=ar.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(ar={positions:new Map(ar.positions).set(e,{xValue:t,sourceId:n})},cr())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&y.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&ur(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&y.onHover(null);if(c&&x)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[x];b(null!=n?n+"":null)}else b(null);if(i||p){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const r=pr(e),s=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),p&&p(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,y,h,d,i,s,a,p,c,x]),S=t.useCallback(e=>{var t,n,o,r;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=yr(e,t,h.xField);null!=n&&function(e,t,n){const o=ar.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(ar.positions);return t.delete(e),ar={positions:t},cr(),!1}ar={positions:new Map(ar.positions).set(e,{xValue:t,sourceId:n,locked:!0})},cr()}(h.name||"hover",n,d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const n=pr(e),s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,s,a,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=ar.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(ar.positions);o.delete(e),ar={positions:o},cr()}(e,d),ur(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:w,customClickBehavior:S,crosshairSourceId:d}}function kr({data:e,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(hr),u=null!==t.useContext(fr),d=void 0!==r?r:!c&&!!n,h=!!n&&(d||u),f=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const o of e){const e="function"==typeof n?n(o):o[n];null!=e&&t.add(e+"")}return Array.from(t)},[l,n,e,h]);!function(e){const n=t.useContext(fr),o=t.useId(),r=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),i=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,r)||(i.current=r);const s=i.current;gr(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),gr(()=>{n&&n.registerCategories(o,s)},[n,o,s])}(u&&n?f:[]);const g=t.useMemo(()=>{if(!d||!n)return;const t=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):rt[i%rt.length];return{label:r+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:a,label:""}]}}({data:e,colorBy:n,colorScale:o,getColor:at,categories:f});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,n,e,o,f]),y=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];return g&&("right"===i&&!o("right")&&110>n.right?n.right=110:"left"===i&&!o("left")&&110>n.left?n.left=110:"top"===i&&!o("top")&&50>n.top?n.top=50:"bottom"===i&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,s,g,i]);return{legend:g,margin:y,legendPosition:i}}d.createContext(void 0);const wr={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 Sr(e,t,n){var o,r,i,s,a,l,c;const u=wr[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(r=t.height)&&void 0!==r?r: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!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!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:Mr(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function Mr(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Ar(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function jr(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function Lr(e){return"function"==typeof e?e:t=>t[e]||1}function Cr({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return s=>{const a=Object.assign({fillOpacity:r},i);if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=at(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=at(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*r);return a}}function Er({componentName:t,message:n,diagnosticHint:o,width:r,height:i}){return e.jsx("div",{role:"alert",style:{width:r,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}),o&&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:o})]})})}class Or extends d.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.jsx(Er,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Dr({componentName:t,width:n,height:o,children:r}){return e.jsx(Or,{fallback:r=>e.jsx(Er,{componentName:t,message:r.message,width:n,height:o}),children:r})}"undefined"!=typeof process&&process;const _r={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Nr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Pr(n){const{nodes:o,edges:r,inferNodes:i=!0,sourceAccessor:s="source",targetAccessor:a="target",colorBy:l,colorScheme:c,showLegend:u,legendPosition:d,legendInteraction:h,selection:f,linkedHover:g,onObservation:y,onClick:p,chartType:m,chartId:v,marginDefaults:b,userMargin:x,width:k,height:w,loading:S,loadingContent:M,emptyContent:A,emptyDataKey:j="edges"}=n,L=t.useMemo(()=>No(r),[r]),C=t.useMemo(()=>No(o),[o]),E=function(t,n,o,r){if(!t)return null;if(!1===r)return null;if(null!=r)return e.jsx("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const i=Math.min(5,Math.floor(o/40)),s=Math.max(8,Math.floor(o/(3*i))),a=Math.max(6,Math.floor(o/(2.5*i))),l=Math.floor((o-(i*(s+a)-a))/2);return e.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,o)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Nr),{position:"absolute",top:l+o*(s+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:s,opacity:.5+o%2*.2})},o))})}(S,k,w,M),O=E?null:function(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},_r),{width:n,height:o}),children:r||"No data available"}):null}("nodes"===j?void 0===o?void 0:C:void 0===r?void 0:L,k,w,A),D=t.useMemo(()=>i?jr(C,L,s,a):C,[i,C,L,s,a]),_=function(e,n,o){const r=t.useContext(Jo),i=vr();return t.useMemo(()=>{var t;if(!n)return;const s=null!=r?r:void 0,a=null!==(t=null!=o?o: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(s&&mr(s)){const e=lt(t.map(e=>({_cat:e})),"_cat",a);return t=>s[t]||e(t)}return lt(t.map(e=>({_cat:e})),"_cat",a)}if(s&&mr(s)){const t=lt(e,n,a);return e=>s[e]||t(e)}return lt(e,n,a)}if(s&&mr(s)){const e=lt([{_:"a"}],"_",a);return t=>s[t]||e(t)}},[e,n,o,r,i])}(D,l,c),N=vr(),P=t.useMemo(()=>{if(Array.isArray(c))return c;if(N&&N.length>0)return N;if("string"==typeof c){const e=nt[c];if(Array.isArray(e)&&e.length>0)return e}return ot},[c,N]),T=t.useMemo(()=>{if(!l)return[];const e=new Set;for(const t of D){const n="function"==typeof l?l(t):t[l];null!=n&&e.add(n+"")}return Array.from(e)},[D,l]),I=function(e,n,o){const[r,i]=t.useState(null),[s,a]=t.useState(new Set),l=t.useMemo(()=>new Set,[]),c=t.useCallback(t=>{"highlight"===e&&i(t?t.label:null)},[e]),u=t.useCallback(t=>{"isolate"===e&&a(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),d=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===r}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=t?e[t]:"function"==typeof n?n(e):null;return s.has(o)}}:null},[e,n,r,s]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?s:l,onLegendHover:c,onLegendClick:u,legendSelectionHook:d}}(h,l,T),{legend:R,margin:W,legendPosition:$}=kr({data:D,colorBy:l,colorScale:_,showLegend:u,legendPosition:d,userMargin:x,defaults:b,categories:T}),B=xr({selection:f,linkedHover:g,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:y,onClick:p,chartType:m,chartId:v}),{customHoverBehavior:z,customClickBehavior:H,activeSelectionHook:F,hoverSelectionHook:Y,crosshairSourceId:X}=B;return{safeNodes:D,safeEdges:L,colorScale:_,effectivePalette:P,themeCategorical:N,allCategories:T,legendState:I,legend:R,margin:W,legendPosition:$,customHoverBehavior:z,customClickBehavior:H,activeSelectionHook:F,hoverSelectionHook:Y,crosshairSourceId:X,loadingEl:E,emptyEl:O}}function Tr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}function Ir(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function Rr(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let o,r=n+1;for(const n of t){const t=Ir(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function Wr({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 $r({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(s=t,s.length>3?[s[0],s[Math.floor(s.length/2)],s[s.length-1]]:s).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Rr(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var s;return null}const Br=t.forwardRef(function(n,o){var r;const i=t.useRef(null);Uo(o,{variant:"network",frameRef:i});const s=Sr(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:a,edges:l,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:h,sourceAccessor:f="source",targetAccessor:g="target",nodeLabel:y,colorBy:p,colorScheme:m,nodeSize:v=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:k="#999",edgeOpacity:w=.6,iterations:M=300,forceStrength:A=.1,tooltip:j,frameProps:L={},onObservation:C,onClick:E,chartId:O,selection:D,linkedHover:_,loading:N,loadingContent:P,emptyContent:T,legendInteraction:I,legendPosition:R,stroke:W,strokeWidth:$,opacity:B}=n,z=null!==(r=null!=d?d:h)&&void 0!==r?r:"id",{width:H,height:F,enableHover:Y,showLegend:X,showLabels:G=!1,title:q,description:V,summary:K,accessibleTable:Q}=s,Z=Pr({nodes:a,edges:l,inferNodes:!1,sourceAccessor:f,targetAccessor:g,colorBy:p,colorScheme:m,showLegend:X,legendPosition:R,legendInteraction:I,selection:D,linkedHover:_,onObservation:C,onClick:E,chartType:"ForceDirectedGraph",chartId:O,marginDefaults:s.marginDefaults,userMargin:c,width:H,height:F,loading:N,loadingContent:P,emptyContent:T,emptyDataKey:"nodes"}),U=t.useMemo(()=>new Map,[]),J=t.useMemo(()=>e=>{const t={};return t.fill=p?at(e.data||e,p,Z.colorScale):br(0,Z.themeCategorical,m),"number"==typeof v&&(t.r=v),t},[p,Z.colorScale,v,Z.themeCategorical,m,U]),ee=t.useMemo(()=>Tr(J,{stroke:W,strokeWidth:$,opacity:B}),[J,W,$,B]),te=t.useMemo(()=>e=>{const t=e.data||e;let n;if("number"==typeof x)n=x;else if("function"==typeof x)n=x(t);else{const e=t[x],o="number"==typeof e?e:Number(e);n=Number.isFinite(o)&&o>0?o:1}return{stroke:k,strokeWidth:n,opacity:w}},[x,k,w]),ne=t.useMemo(()=>Tr(te,{stroke:W,strokeWidth:$,opacity:B}),[te,W,$,B]),oe=t.useMemo(()=>{if(G&&y)return"function"==typeof y?y:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[y])&&void 0!==n?n:e[y])&&void 0!==o?o:e.id}},[G,y]),re=$r({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:z}});return re?e.jsx(Er,{componentName:"ForceDirectedGraph",message:re,width:H,height:F}):Z.loadingEl?Z.loadingEl:Z.emptyEl?Z.emptyEl:e.jsx(Dr,{componentName:"ForceDirectedGraph",width:H,height:F,children:e.jsx(Zo,Object.assign({ref:i,chartType:"force"},null!=a&&{nodes:Z.safeNodes},null!=l&&{edges:Z.safeEdges},{size:[H,F],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Z.margin,nodeIDAccessor:z,sourceAccessor:f,targetAccessor:g,iterations:M,forceStrength:A,nodeStyle:ee,edgeStyle:ne,colorBy:p,colorScheme:Z.effectivePalette,nodeSize:v,nodeSizeRange:b,nodeLabel:oe,showLabels:G,enableHover:Y,tooltipContent:!1===j?()=>null:S(j)||void 0,customHoverBehavior:_||C||E?Z.customHoverBehavior:void 0,customClickBehavior:C||E?Z.customClickBehavior:void 0,legend:Z.legend,legendPosition:Z.legendPosition},I&&"none"!==I&&{legendHoverBehavior:Z.legendState.onLegendHover,legendClickBehavior:Z.legendState.onLegendClick,legendHighlightedCategory:Z.legendState.highlightedCategory,legendIsolatedCategories:Z.legendState.isolatedCategories},{className:u,title:q,description:V,summary:K,accessibleTable:Q},null!=n.animate&&{animate:n.animate},L))})});Br.displayName="ForceDirectedGraph";const zr=t.forwardRef(function(n,o){const r=t.useRef(null);Uo(o,{variant:"network",frameRef:r,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const i=Sr(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:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",orientation:m="horizontal",nodeAlign:v="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,edgeOpacity:w=.5,edgeSort:M,tooltip:A,frameProps:j={},onObservation:L,onClick:C,chartId:E,selection:O,linkedHover:D,loading:_,loadingContent:N,emptyContent:P,showLegend:T,legendPosition:I,legendInteraction:R,stroke:W,strokeWidth:$,opacity:B}=n,{width:z,height:H,enableHover:F,showLabels:Y=!0,title:X,description:G,summary:q,accessibleTable:V}=i,K=Pr({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:g,colorScheme:y,showLegend:T,legendPosition:I,legendInteraction:R,selection:O,linkedHover:D,onObservation:L,onClick:C,chartType:"SankeyDiagram",chartId:E,marginDefaults:i.marginDefaults,userMargin:l,width:z,height:H,loading:_,loadingContent:N,emptyContent:P}),Q=t.useMemo(()=>new Map,[]),Z=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?at(e.data||e,g,K.colorScale):br(0,K.themeCategorical,y),t},[g,K.colorScale,K.themeCategorical,y,Q]),U=t.useMemo(()=>Tr(Z,{stroke:W,strokeWidth:$,opacity:B}),[Z,W,$,B]),J=t.useMemo(()=>Cr({edgeColorBy:p,colorBy:g,colorScale:K.colorScale,nodeStyleFn:U,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[p,g,K.colorScale,U,w]),ee=t.useMemo(()=>Tr(J,{stroke:W,strokeWidth:$,opacity:B}),[J,W,$,B]),te=t.useMemo(()=>{if(!Y)return;const e=k||f;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[Y,k,f]),ne=$r({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return ne?e.jsx(Er,{componentName:"SankeyDiagram",message:ne,width:z,height:H}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e.jsx(Dr,{componentName:"SankeyDiagram",width:z,height:H,children:e.jsx(Zo,Object.assign({ref:r,chartType:"sankey"},K.safeNodes.length>0&&{nodes:K.safeNodes},null!=a&&{edges:K.safeEdges},{size:[z,H],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K.margin,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:m,nodeAlign:v,nodePaddingRatio:b,nodeWidth:x,nodeStyle:U,edgeStyle:ee,colorBy:g,colorScheme:K.effectivePalette,edgeColorBy:p,edgeOpacity:w,edgeSort:M,nodeLabel:te,showLabels:Y,enableHover:F,tooltipContent:!1===A?()=>null:S(A)||void 0,customHoverBehavior:D||L||C?K.customHoverBehavior:void 0,customClickBehavior:L||C?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},R&&"none"!==R&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:c,title:X,description:G,summary:q,accessibleTable:V},null!=n.animate&&{animate:n.animate},j))})});zr.displayName="SankeyDiagram";const Hr=t.forwardRef(function(n,o){const r=t.useRef(null);Uo(o,{variant:"network",frameRef:r,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const i=Sr(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:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:y,edgeColorBy:p="source",padAngle:m=.01,groupWidth:v=20,sortGroups:b,nodeLabel:x,edgeOpacity:k=.5,tooltip:w,frameProps:M={},onObservation:A,onClick:j,chartId:L,selection:C,linkedHover:E,loading:O,loadingContent:D,emptyContent:_,legendInteraction:N,stroke:P,strokeWidth:T,opacity:I}=n,{width:R,height:W,enableHover:$,showLabels:B=!0,title:z,description:H,summary:F,accessibleTable:Y}=i,X=Pr({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:g,colorScheme:y,showLegend:!1,legendInteraction:N,selection:C,linkedHover:E,onObservation:A,onClick:j,chartType:"ChordDiagram",chartId:L,marginDefaults:i.marginDefaults,userMargin:l,width:R,height:W,loading:O,loadingContent:D,emptyContent:_}),G=t.useMemo(()=>new Map,[]),q=X.safeNodes.length>0,V=t.useMemo(()=>{if(q)return(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(g)r.fill=at(e.data||e,g,X.colorScale);else{const i=Array.isArray(y)?y:nt[y]||ot,s=Array.isArray(i)?i:ot,a=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=s[a%s.length]}return r}},[q,g,X.colorScale,y]),K=t.useMemo(()=>V?Tr(V,{stroke:P,strokeWidth:T,opacity:I}):void 0,[V,P,T,I]),Q=t.useMemo(()=>{if(q)return Cr({edgeColorBy:p,colorBy:g,colorScale:X.colorScale,nodeStyleFn:K||(e=>({fill:br(0,X.themeCategorical,y)})),edgeOpacity:k,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:k}})},[q,p,g,X.colorScale,K,k,X.themeCategorical,y,G]),Z=t.useMemo(()=>Q?Tr(Q,{stroke:P,strokeWidth:T,opacity:I}):void 0,[Q,P,T,I]),U=t.useMemo(()=>{if(!B)return;const e=x||f;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[B,x,f]),J=$r({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return J?e.jsx(Er,{componentName:"ChordDiagram",message:J,width:R,height:W}):X.loadingEl?X.loadingEl:X.emptyEl?X.emptyEl:e.jsx(Dr,{componentName:"ChordDiagram",width:R,height:W,children:e.jsx(Zo,Object.assign({ref:r,chartType:"chord"},X.safeNodes.length>0&&{nodes:X.safeNodes},null!=a&&{edges:X.safeEdges},{size:[R,W],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:X.margin,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:m,groupWidth:v,sortGroups:b,nodeStyle:K,edgeStyle:Z,colorBy:g,colorScheme:X.effectivePalette,edgeColorBy:p,edgeOpacity:k,nodeLabel:U,showLabels:B,enableHover:$,tooltipContent:!1===w?()=>null:S(w)||void 0,customHoverBehavior:E||A||j?X.customHoverBehavior:void 0,customClickBehavior:A||j?X.customClickBehavior:void 0},N&&"none"!==N&&{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))})});function Fr(n){const o=Sr(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:r,margin:i,className:s,layout:a="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:m=5,tooltip:v,frameProps:b={},onObservation:x,onClick:k,chartId:w,selection:M,linkedHover:A,loading:j,loadingContent:L,legendInteraction:C,stroke:E,strokeWidth:O,opacity:D}=n,{width:_,height:N,enableHover:P,showLabels:T=!0,title:I,description:R,summary:W,accessibleTable:$}=o,B=Pr({nodes:t.useMemo(()=>Ar(null!=r?r:null,c),[r,c]),edges:void 0,inferNodes:!1,colorBy:g?void 0:h,colorScheme:f,showLegend:!1,legendInteraction:C,selection:M,linkedHover:A,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:o.marginDefaults,userMargin:i,width:_,height:N,loading:j,loadingContent:L}),z=t.useMemo(()=>new Map,[]),H=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?it[(e.depth||0)%it.length]:h?at(e.data||e,h,B.colorScale):br(0,B.themeCategorical,f),t},[h,g,B.colorScale,B.themeCategorical,f,z]),F=t.useMemo(()=>Tr(H,{stroke:E,strokeWidth:O,opacity:D}),[H,E,O,D]),Y=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),X=t.useMemo(()=>Tr(Y,{stroke:E,strokeWidth:O,opacity:D}),[Y,E,O,D]),G=t.useMemo(()=>{if("treemap"===a||"circlepack"===a||"partition"===a)return Lr(u)},[a,u]),q=Wr({componentName:"TreeDiagram",data:r});return q?e.jsx(Er,{componentName:"TreeDiagram",message:q,width:_,height:N}):B.loadingEl?B.loadingEl:e.jsx(Dr,{componentName:"TreeDiagram",width:_,height:N,children:e.jsx(Zo,Object.assign({chartType:a},null!=r&&{data:r},{size:[_,N],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:B.margin,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:G,treeOrientation:l,edgeType:y,nodeStyle:F,edgeStyle:X,colorBy:h,colorScheme:B.effectivePalette,colorByDepth:g,nodeSize:m,nodeLabel:T?p||d:void 0,showLabels:T,enableHover:P,tooltipContent:!1===v?()=>null:S(v)||void 0,customHoverBehavior:A||x||k?B.customHoverBehavior:void 0,customClickBehavior:x||k?B.customClickBehavior:void 0},C&&"none"!==C&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},{className:s,title:I,description:R,summary:W,accessibleTable:$},null!=n.animate&&{animate:n.animate},b))})}function Yr(n){const o=Sr(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:r,margin:i,className:s,childrenAccessor:a="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:f="leaf",nodeLabel:g,padding:y=4,paddingTop:p,nodeStyle:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:M,chartId:A,loading:j,loadingContent:L,legendInteraction:C,stroke:E,strokeWidth:O,opacity:D}=n,{nodeStyle:_}=b,N=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(b,["nodeStyle"]),{width:P,height:T,enableHover:I,showLabels:R=!0,title:W,description:$,summary:B,accessibleTable:z}=o,H=Pr({nodes:t.useMemo(()=>Ar(null!=r?r:null,a),[r,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:C,selection:x,linkedHover:k,onObservation:w,onClick:M,chartType:"Treemap",chartId:A,marginDefaults:o.marginDefaults,userMargin:i,width:P,height:T,loading:j,loadingContent:L}),F=function(e){const n=Zt(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,o;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!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:n})},[e,n])}(x),Y=H.customHoverBehavior,X=t.useCallback(e=>{if(!e)return Y(null);const t=e.data||e;Y({data:(null==t?void 0:t.data)||t})},[Y]),G=t.useMemo(()=>new Map,[]),q=t.useMemo(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=h?it[(e.depth||0)%it.length]:u?at(e.data||e,u,H.colorScale):br(0,H.themeCategorical,d),t},[u,h,H.colorScale,H.themeCategorical,d,G]),V=t.useMemo(()=>m||_?e=>{var t,n;return Object.assign(Object.assign(Object.assign({},q(e)),_&&null!==(t=_(e))&&void 0!==t?t:{}),m&&null!==(n=m(e))&&void 0!==n?n:{})}:q,[q,m,_]),K=t.useMemo(()=>Tr(V,{stroke:E,strokeWidth:O,opacity:D}),[V,E,O,D]),Q=t.useMemo(()=>H.activeSelectionHook?e=>{var t;const n=Object.assign({},K(e));if(H.activeSelectionHook.isActive)if(H.activeSelectionHook.predicate(e.data||e))(null==F?void 0:F.selectedStyle)&&Object.assign(n,F.selectedStyle);else{const e=null!==(t=null==F?void 0:F.unselectedOpacity)&&void 0!==t?t:.5;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==F?void 0:F.unselectedStyle)&&Object.assign(n,F.unselectedStyle)}return n}:K,[K,H.activeSelectionHook,F]),Z=t.useMemo(()=>Lr(l),[l]),U=void 0!==p?p:!R||"parent"!==f&&"all"!==f?void 0:18,J=Wr({componentName:"Treemap",data:r});return J?e.jsx(Er,{componentName:"Treemap",message:J,width:P,height:T}):H.loadingEl?H.loadingEl:e.jsx(Dr,{componentName:"Treemap",width:P,height:T,children:e.jsx(Zo,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[P,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:H.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:Z,padding:y,paddingTop:U,nodeStyle:Q,colorBy:u,colorScheme:H.effectivePalette,colorByDepth:h,nodeLabel:R?g||c:void 0,showLabels:R,labelMode:f,enableHover:I,tooltipContent:!1===v?()=>null:S(v)||void 0},(k||w||M)&&{customHoverBehavior:X},(w||M)&&{customClickBehavior:H.customClickBehavior},C&&"none"!==C&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:s,title:W,description:$,summary:B,accessibleTable:z},null!=n.animate&&{animate:n.animate},N))})}function Xr(n){const o=Sr(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:r,margin:i,className:s,childrenAccessor:a="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:m={},onObservation:v,onClick:b,chartId:x,selection:k,linkedHover:w,loading:M,loadingContent:A,legendInteraction:j,stroke:L,strokeWidth:C,opacity:E}=n,{width:O,height:D,enableHover:_,showLabels:N=!0,title:P,description:T,summary:I,accessibleTable:R}=o,W=Pr({nodes:t.useMemo(()=>Ar(null!=r?r:null,a),[r,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:j,selection:k,linkedHover:w,onObservation:v,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:o.marginDefaults,userMargin:i,width:O,height:D,loading:M,loadingContent:A}),$=t.useMemo(()=>new Map,[]),B=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?it[(e.depth||0)%it.length]:u?at(e.data||e,u,W.colorScale):br(0,W.themeCategorical,d),t},[u,h,W.colorScale,g,W.themeCategorical,d,$]),z=t.useMemo(()=>Tr(B,{stroke:L,strokeWidth:C,opacity:E}),[B,L,C,E]),H=t.useMemo(()=>Lr(l),[l]),F=Wr({componentName:"CirclePack",data:r});return F?e.jsx(Er,{componentName:"CirclePack",message:F,width:O,height:D}):W.loadingEl?W.loadingEl:e.jsx(Dr,{componentName:"CirclePack",width:O,height:D,children:e.jsx(Zo,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[O,D],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:W.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:H,padding:y,nodeStyle:z,colorBy:u,colorScheme:W.effectivePalette,colorByDepth:h,nodeLabel:N?f||c:void 0,showLabels:N,enableHover:_,tooltipContent:!1===p?()=>null:S(p)||void 0,customHoverBehavior:w||v||b?W.customHoverBehavior:void 0,customClickBehavior:v||b?W.customClickBehavior:void 0},j&&"none"!==j&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},{className:s,title:P,description:T,summary:I,accessibleTable:R},null!=n.animate&&{animate:n.animate},m))})}Hr.displayName="ChordDiagram",Fr.displayName="TreeDiagram","function"==typeof SuppressedError&&SuppressedError,Yr.displayName="Treemap",Xr.displayName="CirclePack";const Gr=it;function qr(n){const o=Sr(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:r,margin:i,className:s,childrenAccessor:a="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:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:M,annotations:A,frameProps:j={},onObservation:L,onClick:C,chartId:E,selection:O,linkedHover:D,loading:_,loadingContent:N,stroke:P,strokeWidth:T,opacity:I}=n,{width:R,height:W,enableHover:$,title:B,description:z,summary:H,accessibleTable:F}=o,Y=Pr({nodes:t.useMemo(()=>Ar(r,a),[r,a]),edges:void 0,inferNodes:!1,colorBy:d?void 0:c,colorScheme:u,showLegend:!1,legendInteraction:void 0,selection:O,linkedHover:D,onObservation:L,onClick:C,chartType:"OrbitDiagram",chartId:E,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:i,width:R,height:W,loading:_,loadingContent:N}),X=t.useMemo(()=>new Map,[]),{colorScale:G,customClickBehavior:q,customHoverBehavior:V,themeCategorical:K}=Y,Q=t.useMemo(()=>{if(Array.isArray(u))return u;const e=nt[u];return Array.isArray(e)?e:ot},[u]),Z=t.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=d?o?Q[0]:Gr[(e.depth||0)%Gr.length]:c?at(e.data||e,c,G):br(0,K,u),n.opacity=o?1:.85,n},[c,d,G,Q,K,u,X]),U=t.useMemo(()=>Tr(Z,{stroke:P,strokeWidth:T,opacity:I}),[Z,P,T,I]),J=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),ee=t.useMemo(()=>{if(V)return e=>{V(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[V]),te=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]),ne=Wr({componentName:"OrbitDiagram",data:r});return ne?e.jsx(Er,{componentName:"OrbitDiagram",message:ne,width:R,height:W}):Y.loadingEl?Y.loadingEl:e.jsx(Dr,{componentName:"OrbitDiagram",width:R,height:W,children:e.jsx(Zo,Object.assign({chartType:"orbit"},null!=r&&{data:r},{size:[R,W],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Y.margin,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:U,edgeStyle:J,colorBy:c,colorScheme:Y.effectivePalette,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&$,tooltipContent:k?void 0:!1===w?()=>null:S(w)||void 0,customHoverBehavior:D||L||C?ee:void 0,customClickBehavior:L||C?te:void 0,foregroundGraphics:M,annotations:A,className:s,title:B,description:z,summary:H,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:y,orbitRevolutionStyle:p,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:F},null!=n.animate&&{animate:n.animate},j))})}function Vr(e,t,n){const o=[],r=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,s=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&s&&s&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||o.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}function Kr(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 Qr(e,t,n){const o=t.incoming[e.id],r=t.outgoing[e.id],i=[];for(const e of o)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{i.sort((e,t)=>{var n,o;return e.time-t.time||(null!==(n=s[e.kind])&&void 0!==n?n:99)-(null!==(o=s[t.kind])&&void 0!==o?o:99)})},l=i.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(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};a();const g=[];let y=0,p=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:p);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?y:p);if(o>0){const r=f(e.time);g.push({time:r,delta:-o,kind:"transfer-out",side:t}),g.push({time:r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:p-=o,"top"===e.side?y+=o:p+=o,n-=o}n>0&&null!==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),a();let m=0,v=0,b=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:m,botMass:v}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:v;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?m+=e.delta:v+=e.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:e.time,topMass:m,botMass:v})}const M=[];let A=0;for(;w.length>A;){let e=A;for(;w.length>e+1&&w[e+1].t===w[A].t;)e++;M.push(w[A]);for(let t=A+1;e>=t;t++){const e=M[M.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||M.push(w[t])}A=e+1}const j=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let L=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===L||L>e.systemInTime)&&(L=e.systemInTime);let C=null;for(const e of o)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===C||e.systemOutTime>C)&&(C=e.systemOutTime);if(M.length>0){const e=M[M.length-1],t=Math.max(null!=j?j:-1/0,null!=C?C:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&M.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=M[0],o=Math.min(null!=c?c:1/0,null!=L?L:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&M.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:M,peak:b,topPeak:x,botPeak:k,localAttachments:S}}function Zr(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Ur(e,t){return e.map(e=>({t:Zr(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Jr(e,t,n){const o=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}function ei(e,t){let n=0;for(let o=0;t.length>o;o++)for(let r=o+1;t.length>r;r++){const i=t[o],s=t[r];i.source!==s.source&&i.target!==s.target&&i.source!==s.target&&i.target!==s.source&&(Math.min(i.endTime,s.endTime)>Math.max(i.startTime,s.startTime)&&e[s.source]>e[i.source]!=e[s.target]>e[i.target]&&n++)}return n}function ti(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function ni(e,t){return 1e3*ei(e,t)+ti(e,t)}function oi(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function ri(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=oi(e,t),s=ni(t,n);for(let a=0;o>a;a++){const o=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];o[n]+=r*(e.value||1),a[n]+=e.value||1,o[r]+=n*(e.value||1),a[r]+=e.value||1}const l=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?o[e]/a[e]:e)-(a[t]>0?o[t]/a[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=ni(t,n);if(s>d)s=d,i=oi(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=ni(t,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;r-1>s;s++){const r=e[s];e[s]=e[s+1],e[s+1]=r;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=ni(t,n);if(i>a)i=a,o=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const r=Object.assign({},t),i=Object.keys(r),s=Array.from({length:o},(e,t)=>t),a=s.slice(),l=Object.assign({},r);let c=s.slice(),u=1/0;const d=()=>{for(const e of i)l[e]=a[r[e]];const e=ni(l,n);u>e&&(u=e,c=s.slice())},h=(e,t)=>{const n=s[e],o=s[t];s[e]=o,s[t]=n,a[n]=t,a[o]=e};d();const f=Array(o).fill(0);let g=0;for(;o>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 ii(e,t,n,o,r){var i,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:m,lifetimeMode:v="full"}=r,b={},x={};for(const t of e)b[t.id]=n[t.id].topPeak||0,x[t.id]=n[t.id].botPeak||0;const k="half"===v,w={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=k?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=k?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}w[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}const S={},M=[];if("reuse"===p){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(null!==(i=r.get(e.target))&&void 0!==i?i:0)+1);const d=[];for(const t of e)0===(null!==(s=r.get(t.id))&&void 0!==s?s:0)&&d.push(t.id);for(;d.length;){const e=d.shift();for(const t of null!==(a=o.outgoing[e])&&void 0!==a?a:[]){const o=(null!==(l=n.get(e))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(t.target))&&void 0!==c?c:0)&&n.set(t.target,o),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&d.push(t.target)}}const h=[...e].filter(e=>null!==w[e.id].start).sort((e,t)=>{var o,r;const i=null!==(o=n.get(e.id))&&void 0!==o?o:0,s=null!==(r=n.get(t.id))&&void 0!==r?r:0;return i!==s?i-s: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;M.length>e;e++){const o=M[e].occupants[M[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(M.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=M.length-1),M[n].occupants.push({id:e.id,end:null!==(u=null==t?void 0:t.end)&&void 0!==u?u:-1/0}),M[n].peak.topPeak=Math.max(M[n].peak.topPeak,b[e.id]),M[n].peak.botPeak=Math.max(M[n].peak.botPeak,x[e.id]),S[e.id]=n}}else e.forEach((e,t)=>{var n,o;M.push({occupants:[{id:e.id,end:null!==(o=null===(n=w[e.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:b[e.id],botPeak:x[e.id]}}),S[e.id]=t});let A=null,j=null,L=null,C=null;const E=()=>{A=ei(S,t),L=ti(S,t)},O=()=>{j=ei(S,t),C=ti(S,t)};"crossing-min"===m?(E(),ri(M,S,t),O()):"inside-out"===m?(E(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),i=Array(n),s=Math.floor((n-1)/2);i[s]=r[0].idx;let a=s-1,l=s+1;for(let e=1;r.length>e;e++)e%2==1&&n>l||0>a?i[l++]=r[e].idx:i[a--]=r[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)}(M,S),O()):"crossing-min+inside-out"===m&&(E(),ri(M,S,t),function(e,t,n){const o=e.length;if(1>=o)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((o-1)/2);let s=ni(t,n);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const l=i;if(r===l)continue;const c=e[r];e.splice(r,1),e.splice(l,0,c);const u=new Map;for(let e=0;o>e;e++)u.set(e,e);if(l>r){for(let e=r+1;l>=e;e++)u.set(e,e-1);u.set(r,l)}else{for(let e=l;r>e;e++)u.set(e,e+1);u.set(r,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=ni(t,n);if(d>s){const n=e[l];e.splice(l,1),e.splice(r,0,n);const i=new Map;for(let e=0;o>e;e++)i.set(e,e);if(r>l){for(let e=l+1;r>=e;e++)i.set(e,e-1);i.set(l,r)}else{for(let e=r;l>e;e++)i.set(e,e+1);i.set(l,r)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else s=d}}(M,S,t),O());const D=M.map(e=>{const t=new Map;for(const o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),_=(e,t)=>{let n={top:0,bot:0};for(const[o,r]of e){if(o>t)break;n=r}return n},N=[];for(let e=0;M.length-1>e;e++){const t=D[e],n=D[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of o){const o=_(t,e),i=_(n,e);o.bot+i.top>r&&(r=o.bot+i.top)}N.push(r)}const P=[];let T=g+(null!==(h=null===(d=M[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*y;M.length>0&&P.push(T);for(let e=1;M.length>e;e++)T+=N[e-1]*y+g,P.push(T);if(M.length>0&&(T+=M[M.length-1].peak.botPeak*y+g),T>f){const e=f/T;for(let t=0;P.length>t;t++)P[t]*=e}const I=0===M.length?0:M[0].peak.topPeak+N.reduce((e,t)=>e+t,0)+M[M.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=P[S[t.id]];return{effectiveSlotsHeight:I,centerlines:R,laneLifetime:w,slots:M,slotByNode:S,slotCenter:P,crossingsBefore:A,crossingsAfter:j,lengthBefore:L,lengthAfter:C}}qr.displayName="OrbitDiagram";const si=e=>{var t,n;const{bands:o=[],ribbons:r=[],showLabels:i=!0}=e.config,s=[];for(const e of r)s.push(Object.assign(Object.assign({type:"bezier",pathD:e.pathD},e.bezier&&{bezierCache:e.bezier}),{style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}}));for(const e of o)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of o)s.push({type:"bezier",pathD:e.pathD,style:Object.assign(Object.assign({},e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86}),{stroke:null!==(t=e.stroke)&&void 0!==t?t:e.fill,strokeWidth:null!==(n=e.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const a=i?o.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:a}};function ai(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function li(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function ci(e,t){return"function"==typeof e?e(t):t[e]}const ui=t.forwardRef(function(n,o){const{nodes:r,edges:s,domain:a,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",startTimeAccessor:f="startTime",endTimeAccessor:g="endTime",systemInTimeAccessor:y,systemOutTimeAccessor:p,xExtentAccessor:m="xExtent",edgeIdAccessor:v="id",colorBy:b,colorScheme:x,showLegend:k,legendPosition:w="right",pairing:M="temporal",packing:A="reuse",laneOrder:j="crossing-min",ribbonLane:L="both",lifetimeMode:C="half",showLaneRails:E=!1,showQualityReadout:O=!1,showLabels:D=!0,width:_=600,height:N=400,margin:P,title:T,description:I,summary:R,accessibleTable:W,responsiveWidth:$,responsiveHeight:B,loading:z,loadingContent:H,emptyContent:F,edgeOpacity:Y=.35,timeFormat:X,valueFormat:G,tooltip:q,enableHover:V=!0,onObservation:K,onClick:Q,showParticles:Z=!1,particleStyle:U,chartId:J,frameProps:ee={}}=n,[te,ne]=t.useState([]),[oe,re]=t.useState([]),ie=t.useRef(te),se=t.useRef(oe);ie.current=te,se.current=oe;const ae=t.useCallback(e=>{ie.current=e,ne(e)},[]),le=t.useCallback(e=>{se.current=e,re(e)},[]),ce=void 0!==s,ue=No(ce?s:te),de=t.useMemo(()=>{const e=No(null!=r?r:[]),t=oe;if(0===e.length&&0===t.length)return jr([],ue,u,d);const n=new Set,o=[];for(const t of e){const e=ci(c,t)+"";n.has(e)||(n.add(e),o.push(t))}for(const e of t){const t=ci(c,e)+"";n.has(t)||(n.add(t),o.push(e))}const i=jr([],ue,u,d);for(const e of i)n.has(e.id)||(n.add(e.id),o.push(e));return o},[r,oe,ue,c,u,d]),he=t.useRef(null),fe=t.useCallback((e,t)=>{const n=ci(v,e);return null!=n?n+"":`${ci(u,e)}-${ci(d,e)}-${t}`},[v,u,d]),ge=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=ci(u,t)&&null!=ci(d,t)},[u,d]);Uo(o,{variant:"network",frameRef:he,overrides:{push(e){if(ge(e)){if(ce)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ae([...ie.current,e])}else le([...se.current,e])},pushMany(e){const t=[],n=[];for(const o of e)ge(o)?t.push(o):n.push(o);t.length>0&&(ce?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ae([...ie.current,...t])),n.length>0&&le([...se.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!ce){const e=ie.current,o=[];for(let r=0;e.length>r;r++){const i=e[r];t.has(fe(i,r))?n.push(i):o.push(i)}o.length!==e.length&&ae(o)}const o=se.current,r=[];for(const e of o){const o=ci(c,e)+"";t.has(o)?n.push(e):r.push(e)}return r.length!==o.length&&le(r),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!ce){let e=!1;const r=ie.current.map((r,i)=>n.has(fe(r,i))?(o.push(r),e=!0,t(r)):r);e&&ae(r)}let r=!1;const i=se.current.map(e=>{const i=ci(c,e)+"";return n.has(i)?(o.push(e),r=!0,t(e)):e});return r&&le(i),o},clear(){var e;ce||ae([]),le([]),null===(e=he.current)||void 0===e||e.clear()},getData:()=>null!=ue?ue:[],getScales:()=>null},deps:[ce,ge,fe,c,ue,ae,le]});const ye=fe,pe=t.useCallback(e=>ci(c,e)+"",[c]),{nodes:me,edges:ve,domain:be,rawNodeById:xe,rawEdgeById:ke}=t.useMemo(()=>{const e=(null!=de?de:[]).map(e=>{const t={id:pe(e),__raw:e},n=m?ci(m,e):null;if(Array.isArray(n)&&2===n.length){const e=li(n[0]),o=li(n[1]);Number.isFinite(e)&&Number.isFinite(o)&&(t.xExtent=[e,o])}return t}),t=(null!=ue?ue:[]).map((e,t)=>{const n={id:ye(e,t),source:ci(u,e)+"",target:ci(d,e)+"",value:Number(ci(h,e)),startTime:li(ci(f,e)),endTime:li(ci(g,e)),__raw:e};if(y){const t=li(ci(y,e));Number.isFinite(t)&&(n.systemInTime=t)}if(p){const t=li(ci(p,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[li(a[0]),li(a[1])],o=new Map;for(const t of e)null!=t.__raw&&o.set(t.id,t.__raw);const r=new Map;for(const e of t)null!=e.__raw&&r.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:o,rawEdgeById:r}},[de,ue,a,pe,ye,m,u,d,h,f,g,y,p]),we=Pr({nodes:de,edges:ue,inferNodes:!1,sourceAccessor:u,targetAccessor:d,colorBy:b,colorScheme:x,showLegend:!1,legendPosition:w,selection:void 0,linkedHover:void 0,onObservation:K,onClick:Q,chartType:"ProcessSankey",chartId:J,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:P,width:_,height:N,loading:z,loadingContent:H,emptyContent:F}),Se=(null!=k?k:!!b)&&!!b,Me=t.useCallback(e=>null!=P&&("number"==typeof P||null!=P[e]),[P]),je=t.useMemo(()=>{const e=Object.assign({},we.margin);return Se&&("right"===w&&!Me("right")&&140>e.right?e.right=140:"bottom"===w&&!Me("bottom")&&80>e.bottom&&(e.bottom=80)),e},[we.margin,Se,w,Me]),Le=_-je.left-je.right,Ce=N-je.top-je.bottom,Ee=t.useMemo(()=>Vr(me,ve,be),[me,ve,be]),Oe=t.useMemo(()=>Ee.length>0?null:function(e,t,n){var o;const{plotH:r,pairing:i="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),u=function(e,t,n,o="value"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===o?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?i:r);return s};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(o,"source"),n=a(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=o}}}return s}(e,t,c,i);let d={};for(const t of e)d[t.id]=Qr(t,c,u);const h=ii(e,t,d,c,{plotH:r,padding:12,valueScale:1,packing:s,laneOrder:a,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 o=u.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>u.get(e.id).sourceSide)),r=new Set(n.map(e=>u.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)h.slotByNode[t.source]===h.slotByNode[t.target]&&(u.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)h.slotByNode[n.source]===h.slotByNode[n.target]&&(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 o=()=>{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},r=(e,t)=>{const r=o(),i="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=i||0>=s)return!1;const a=Math.min(i,s),l=n.filter(t=>!f.has(t.id)&&u.get(t.id).sourceSide===e&&a>=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&&(r("top","bot")||r("bot","top")););}d={};for(const t of e)d[t.id]=Qr(t,c,u);const g=ii(e,t,d,c,{plotH:r,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),y=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),p=Math.min(12,.35*r/Math.max(g.slots.length+1,1)),m=y>0?Math.max(0,(r-p*(g.slots.length+1))/y):1,v=ii(e,t,d,c,{plotH:r,padding:p,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:p,compressedPadding:12>p,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(me,ve,{plotH:Ce,pairing:M,packing:A,laneOrder:j,lifetimeMode:C}),[Ee,me,ve,Ce,M,A,j,C]),De=t.useMemo(()=>i.scaleTime().domain(be).range([0,Le]),[be,Le]),_e=t.useCallback((e,t)=>{if(b&&de){const t=xe.get(e);if(t)return at(t,b,we.colorScale)}return we.effectivePalette[t%we.effectivePalette.length]||"#475569"},[b,de,xe,we.colorScale,we.effectivePalette]),Ne=t.useMemo(()=>{const e=new Map;return me.forEach((t,n)=>e.set(t.id,n)),e},[me]),Pe=t.useMemo(()=>{if(!Oe)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Oe,o=[],r=[];return me.forEach((r,i)=>{var s;const a=t[r.id];if(!a||0===a.samples.length)return;const l=function(e,t,n,o,r){if(0===e.length)return null;const i=Ur(e,r),s=e=>t-i[e].topMass*n,a=e=>t+i[e].botMass*n;let l=`M${o(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)l+=` L${o(i[e].t)},${s(e)}`;l+=` L${o(i[i.length-1].t)},${a(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${o(i[e].t)},${a(e)}`;return l+" Z"}(a.samples,e[r.id],n,De,be);if(!l)return;const c=Ur(a.samples,be),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=e[r.id]+(u.botMass-u.topMass)*n/2,h=_e(r.id,i),f=null!==(s=xe.get(r.id))&&void 0!==s?s:r,g=function(e,t,n,o,r){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],l=Ur(i.samples,r),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=o(c.t),h=o(u.t),f=e=>o(Zr(e,r)),g=[],y=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),o=f(n.startTime),r=t-20,i=Math.max(d,r);if(o>i){const[n,l]=Jr(e,a,s);g.push({pathD:y(i,n,o,l),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),o=f(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,l]=Jr(e,a,s);g.push({pathD:y(o,n,i,l),x0:t,x1:r,from:1,to:0})}}}}return g}(r.id,ve,Oe,De,be);o.push(Object.assign(Object.assign({id:r.id,pathD:l,fill:h,stroke:h,strokeWidth:.5},g.length>0&&{gradientStubs:g}),{rawDatum:f,labelX:De(u.t)-4,labelY:d,labelText:r.id}))}),ve.forEach(o=>{var i,s,a,l;const c=null===(i=t[o.source])||void 0===i?void 0:i.localAttachments.get(o.id),u=null===(s=t[o.target])||void 0===s?void 0:s.localAttachments.get(o.id);if(!c||!u)return;const d=null!==(a=Ne.get(o.source))&&void 0!==a?a:0,h=_e(o.source,d),f=function(e,t,n,o,r,i,s,a){const l=r,c=e=>a?Math.max(a[0],Math.min(a[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,m,v,b;"top"===e.side?(p=t-g,m=p+h):(m=t+g,p=m-h),"top"===n.side?(v=o-y,b=v+f):(b=o+y,v=b-f);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,e[o.source],u,e[o.target],n,De,L,be),{pathD:g,bezier:y}=Ae(f),p=null!==(l=ke.get(o.id))&&void 0!==l?l:o;r.push({id:o.id,pathD:g,fill:h,opacity:Y,rawDatum:p,bezier:y})}),{bands:o,ribbons:r}},[Oe,me,ve,De,be,_e,xe,ke,L,Y,Ne]),Te=t.useMemo(()=>({bands:Pe.bands,ribbons:Pe.ribbons,showLabels:D}),[Pe,D]),Ie=t.useMemo(()=>{if(!Se||!b)return;const e=new Map;(null!=de?de:[]).forEach((t,n)=>{const o=ci(b,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:_e(pe(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},[Se,b,de,_e,pe]),Re=t.useMemo(()=>!1!==q&&V?void 0===q||!0===q?null:S(q)||null:null,[q,V]),We=t.useCallback(e=>X?X(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[X]),$e=t.useCallback(e=>G?G(e):e+"",[G]),Be=t.useCallback(t=>{if(!t||!t.data)return null;const n=t.data;if(!ai(n))return null;const o=n.data;if(Re)return Re(o);if("band"===n.__kind){const t=n.id,o=Oe?function(e){if(!e)return[];const t=new Set,n=[];for(const o of e.samples){const e=o.topMass+o.botMass,r=`${o.t}:${e}`;t.has(r)||(t.add(r),n.push({t:o.t,total:e}))}return n}(Oe.nodeData[t]):[],r=5,i=o.length>r?o.length:null,s=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),o=n.length-1,r=[Object.assign(Object.assign({},n[0]),{mark:"min"}),Object.assign(Object.assign({},n[Math.floor(.25*o)]),{mark:"q25"}),Object.assign(Object.assign({},n[Math.floor(.5*o)]),{mark:"median"}),Object.assign(Object.assign({},n[Math.floor(.75*o)]),{mark:"q75"}),Object.assign(Object.assign({},n[o]),{mark:"max"})],i=new Set,s=[];for(const e of r)i.has(e.t)||(i.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(o,r);return e.jsxs("div",{style:{minWidth:160},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:t}),s.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:s.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:{paddingRight:8},children:We(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 ",s.length," of ",i," samples"]})]})}const r=o,i=ci(u,r),s=ci(d,r),a=ci(h,r),l=ci(f,r),c=ci(g,r);return e.jsxs("div",{style:{minWidth:160},children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",s+""]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"value"}),e.jsx("span",{style:{textAlign:"right"},children:$e(Number(a))})]}),null!=l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"start"}),e.jsx("span",{style:{textAlign:"right"},children:We(li(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:We(li(c))})]})]})]})},[Oe,Re,We,$e,u,d,h,f,g]),ze=t.useMemo(()=>{if(!Oe)return null;const{centerlines:t,laneLifetime:n,nodeData:o,valueScale:r,compressedPadding:i,crossingsBefore:s,crossingsAfter:a,lengthBefore:c,lengthAfter:u}=Oe;let d=null,h=null;for(const e of me){const t=n[e.id];if(!t||null===t.start||null===t.end)continue;const o=De(t.start),r=De(t.end);(null===d||d>o)&&(d=o),(null===h||r>h)&&(h=r)}const f=e=>Math.max(0,Math.min(Le,e)),g=f(null!=d?d:0),y=Math.max(g,f(null!=h?h:Le));return e.jsxs("g",{children:[O&&null!==(null!=a?a:null)&&e.jsxs("text",{x:Le,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",s," → ",a," ","edge length: ",Math.round(c)," → ",Math.round(u)]}),i&&e.jsx("text",{x:Le,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((t,n)=>{const o=De(li(t.date));return g-.5>o||o>y+.5?null:e.jsx("line",{x1:o,y1:0,x2:o,y2:Ce,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+n)}),E&&me.map((i,s)=>{const a=n[i.id];if(!a||null===a.start)return null;const l=o[i.id],c=l?{topPeak:l.topPeak,botPeak:l.botPeak}:{topPeak:0,botPeak:0},u=t[i.id]+(c.botPeak-c.topPeak)*r/2,d=De(a.start),h=De(a.end),f=_e(i.id,s);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:g,y1:Ce+4,x2:y,y2:Ce+4,stroke:"#94a3b8"}),l.map((t,n)=>{const o=li(t.date),r=De(o);if(g-.5>r||r>y+.5)return null;const i=null!=t.label?t.label:X?X(new Date(o)):"";return e.jsxs("g",{transform:`translate(${r},${Ce+4})`,children:[e.jsx("line",{y2:6,stroke:"#94a3b8"}),e.jsx("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:i})]},n)})]})},[Oe,l,De,Le,Ce,E,me,_e,O,X]),He=t.useMemo(()=>(null!=de?de:[]).map(e=>({id:pe(e),data:e})),[de,pe]),Fe=t.useMemo(()=>{const e=new Map;for(const t of Pe.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Pe]),Ye=t.useMemo(()=>(null!=ue?ue:[]).map((e,t)=>{const n=ye(e,t),o=Number(ci(h,e));return{id:n,source:ci(u,e)+"",target:ci(d,e)+"",value:Number.isFinite(o)?o:0,bezier:Fe.get(n),data:e}}),[ue,ye,u,d,h,Fe]),Xe=we.loadingEl,Ge=we.emptyEl;return Ee.length>0?e.jsxs("svg",{width:_,height:N,role:"img","aria-label":null!=T?T:"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"}),Ee.map((t,n)=>e.jsx("text",{x:20,y:56+18*n,fontSize:12,fill:"#64748b",children:"• "+Kr(t)},n))]}):Xe||Ge||e.jsx(Zo,Object.assign({ref:he,chartType:"force",nodes:He,edges:Ye,customNetworkLayout:si,layoutConfig:Te,size:[_,N],responsiveWidth:$,responsiveHeight:B,margin:je,title:T,description:null!=I?I:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:R,accessibleTable:W,enableHover:V,tooltipContent:!1===q?()=>null:Be,backgroundGraphics:ze,showParticles:Z,particleStyle:U,legend:Ie,legendPosition:w,onObservation:K,customClickBehavior:Q?e=>{if(!e||!e.data)return;const t=e.data;ai(t)&&Q(t.data,{x:e.x,y:e.y})}:void 0,chartId:J,colorScheme:Array.isArray(x)?x:void 0},ee))});ui.displayName="ProcessSankey";const di=t.forwardRef(function(n,o){const{nodes:r,edges:i,layout:s,layoutConfig:a,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:u="target",margin:d,className:h,colorScheme:f,selection:g,linkedHover:y,onObservation:p,onClick:m,chartId:v,annotations:b,autoPlaceAnnotations:x,frameProps:k={}}=n,{frameRef:w,resolved:S,normalizedMargin:M}=function(e){const n=t.useRef(null);return Uo(e.imperativeRef,{variant:e.imperativeVariant,frameRef:n}),{frameRef:n,resolved:Sr(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;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:o,imperativeVariant:"network",margin:d,width:n.width,height:n.height,enableHover:n.enableHover,title:n.title,mode:n.mode}),A=t.useMemo(()=>No(null!=r?r:[]),[r]),j=t.useMemo(()=>No(null!=i?i:[]),[i]),{customHoverBehavior:L,customClickBehavior:C,activeSelectionHook:E}=xr({selection:g,linkedHover:y,fallbackFields:[],onObservation:p,onClick:m,chartType:"NetworkCustomChart",chartId:v}),O=t.useMemo(()=>(null==E?void 0:E.isActive)?{isActive:!0,predicate:E.predicate}:null,[null==E?void 0:E.isActive,null==E?void 0:E.predicate]),{width:D,height:_,enableHover:N,title:P,description:T,summary:I,accessibleTable:R}=S,W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"force"},null!=r&&{nodes:A}),null!=i&&{edges:j}),{customNetworkLayout:s,layoutConfig:a,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:u,colorScheme:f,size:[D,_],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:M,className:h,title:P,description:T,summary:I,accessibleTable:R,enableHover:N,customHoverBehavior:y||p||m?L:void 0,customClickBehavior:p||m?C:void 0,layoutSelection:O}),null!=b&&{annotations:b}),null!=x&&{autoPlaceAnnotations:x}),k);return e.jsx(Dr,{componentName:"NetworkCustomChart",width:D,height:_,children:e.jsx(Zo,Object.assign({ref:w},W))})});di.displayName="NetworkCustomChart",exports.ChordDiagram=Hr,exports.CirclePack=Xr,exports.ForceDirectedGraph=Br,exports.NetworkCustomChart=di,exports.OrbitDiagram=qr,exports.ProcessSankey=ui,exports.SankeyDiagram=zr,exports.StreamNetworkFrame=Zo,exports.TreeDiagram=Fr,exports.Treemap=Yr,exports.formatProcessSankeyIssue=Kr,exports.useCustomLayoutSelection=function(){var e;return null!==(e=d.useContext(xt))&&void 0!==e?e:bt},exports.validateProcessSankey=Vr;
|