@cyber-harbour/ui 1.1.32 → 1.1.33

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/dist/index.d.mts CHANGED
@@ -1883,9 +1883,7 @@ interface NodeButton {
1883
1883
  loading?: boolean | ((node: NodeObject) => boolean);
1884
1884
  getCount?: (node: NodeObject) => number;
1885
1885
  onClick: (node: NodeObject) => void;
1886
- tooltip?: {
1887
- content?: any;
1888
- };
1886
+ tooltip?: string | ((node: NodeObject) => string);
1889
1887
  }
1890
1888
  type GraphData<NodeType = {}, LinkType = {}> = {
1891
1889
  nodes: NodeObject<NodeType>[];
package/dist/index.d.ts CHANGED
@@ -1883,9 +1883,7 @@ interface NodeButton {
1883
1883
  loading?: boolean | ((node: NodeObject) => boolean);
1884
1884
  getCount?: (node: NodeObject) => number;
1885
1885
  onClick: (node: NodeObject) => void;
1886
- tooltip?: {
1887
- content?: any;
1888
- };
1886
+ tooltip?: string | ((node: NodeObject) => string);
1889
1887
  }
1890
1888
  type GraphData<NodeType = {}, LinkType = {}> = {
1891
1889
  nodes: NodeObject<NodeType>[];
package/dist/index.js CHANGED
@@ -1219,7 +1219,7 @@
1219
1219
  align-items: center;
1220
1220
  justify-content: center;
1221
1221
  `,J9=r(({width:e=280,height:t=280})=>{let n=T1.useTheme();return jsxRuntime.jsx(K9,{children:jsxRuntime.jsxs(L9__default.default,{foregroundColor:n.contentLoader.foreground,backgroundColor:n.contentLoader.background,width:e,height:t,viewBox:"0 0 280 280",children:[jsxRuntime.jsx("path",{d:"m55 38-0.97266 0.22852 7.0801 30.092-18.355-20.979-0.75195 0.6582 19.596 22.395 0.43164 1.834 0.97266-0.22852 0.75195-0.6582-0.37695-0.42969 9.625-27.912-0.94531-0.32617-9.4375 27.371-0.10547-0.12109zm8 34-0.78516 0.61914 0.0957 0.12305-12.311 13.258 0.73242 0.67969 12.205-13.145 14.277 18.084 0.78516-0.61914-14.373-18.207 0.10547-0.11328zm15 19-0.48438 0.875 46.992 25.996 8e-3 4e-3 20.506 11.592-28.182 4.5449 0.15998 0.98819 29.418-4.7441 0.25 0.14062-12.555 24.143 0.88672 0.46094 13-25 15 25 26 30v18l-11 18 0.85352 0.52148 9.8008-16.039-4.6543 33.518 0.99023 0.13867 4.7793-34.408 7.2305 16.27 0.91406-0.40625-7.9141-17.807v-17.104l18 12.316 0.56445-0.82617-18.896-12.928-25.855-29.836-14.633-24.387 0.01562-0.02344h23.805v-1h-23.152l13.848-21.234 55.201-28.791-0.45898-0.88476 0.77734 0.62305 11.402-14.25 16.668-11.842-0.58008-0.81641-16.785 11.928-11.486 14.355-55.434 28.912-14.277 21.893-7.7617-27.166-0.96094 0.27344 7.7227 27.031-1.1191 0.17969-21.604-12.211zm140.43-12.912-6.957-17.338-0.92773 0.37305 6.957 17.338zm-6.957-17.338 0.72266 0.69336 16.232-16.896-0.7207-0.69336zm-3.4766 137.25 5 15 0.94922-0.31641-5-15zm-91-63-0.48047-0.87695-31 17 0.48047 0.87695zm-31 17 5 18 0.96289-0.26758-5-18zm0 0-0.70703-0.70703-12.898 12.898-17.881 9.9336 0.48633 0.875 18-10zm5 18-0.64062-0.76758-18 15 0.64062 0.76758z"}),jsxRuntime.jsx("circle",{cx:"229.92",cy:"63.7318",r:"5",transform:"rotate(173.661 229.92 63.7318)"}),jsxRuntime.jsx("circle",{cx:"227.711",cy:"43.8541",r:"5",transform:"rotate(173.661 227.711 43.8541)"}),jsxRuntime.jsx("circle",{cx:"211.478",cy:"60.7499",r:"5",transform:"rotate(173.661 211.478 60.7499)"}),jsxRuntime.jsx("circle",{cx:"218.434",cy:"78.0877",r:"5",transform:"rotate(173.661 218.434 78.0877)"}),jsxRuntime.jsx("circle",{cx:"246.705",cy:"51.8054",r:"5",transform:"rotate(173.661 246.705 51.8054)"}),jsxRuntime.jsx("circle",{cx:"42",cy:"48",r:"5"}),jsxRuntime.jsx("circle",{cx:"55",cy:"38",r:"5"}),jsxRuntime.jsx("circle",{cx:"73",cy:"43",r:"5"}),jsxRuntime.jsx("circle",{cx:"63",cy:"72",r:"5"}),jsxRuntime.jsx("circle",{cx:"50",cy:"86",r:"5"}),jsxRuntime.jsx("circle",{cx:"78",cy:"91",r:"5"}),jsxRuntime.jsx("circle",{cx:"73",cy:"165",r:"5"}),jsxRuntime.jsx("circle",{cx:"73",cy:"185",r:"5"}),jsxRuntime.jsx("circle",{cx:"91",cy:"170",r:"5"}),jsxRuntime.jsx("circle",{cx:"86",cy:"152",r:"5"}),jsxRuntime.jsx("circle",{cx:"148",cy:"130",r:"5"}),jsxRuntime.jsx("circle",{cx:"189",cy:"185",r:"5"}),jsxRuntime.jsx("circle",{cx:"163",cy:"107",r:"5"}),jsxRuntime.jsx("circle",{cx:"140",cy:"102",r:"5"}),jsxRuntime.jsx("circle",{cx:"117",cy:"135",r:"5"}),jsxRuntime.jsx("circle",{cx:"125",cy:"117",r:"5"}),jsxRuntime.jsx("circle",{cx:"208",cy:"198",r:"5"}),jsxRuntime.jsx("circle",{cx:"189",cy:"203",r:"5"}),jsxRuntime.jsx("circle",{cx:"198",cy:"221",r:"5"}),jsxRuntime.jsx("circle",{cx:"178",cy:"221",r:"5"}),jsxRuntime.jsx("circle",{cx:"184",cy:"239",r:"5"}),jsxRuntime.jsx("circle",{cx:"213",cy:"213",r:"5"}),jsxRuntime.jsx("circle",{cx:"173",cy:"130",r:"5"}),jsxRuntime.jsx("circle",{cx:"163",cy:"155",r:"5"}),jsxRuntime.jsx("circle",{cx:"135",cy:"155",r:"5"}),jsxRuntime.jsx("circle",{cx:"55",cy:"175",r:"5"})]})})},"GraphLoader"),V6=J9;var G2=typeof window<"u"&&window.devicePixelRatio||1;function ge(e){return !e||e.length===0?[]:e.map(t=>({...t,imageCache:new Map}))}r(ge,"prepareButtonImages");var o1={fontSize:4,nodeSizeBase:30,nodeAreaFactor:2,nodeBorderWidth:1,textPaddingFactor:.9,gridSpacing:20,dotSize:1,maxZoom:4},m1=r(e=>e.size??o1.nodeSizeBase,"getNodeSize"),he=r((e,t)=>e.width!==void 0?t?e.width*2:e.width:t?1.5:.5,"getLinkWidth"),be=K6.forwardRef(({loading:e,width:t,height:n,graphData:d,buttons:s=[],enableGrid:u=true,onNodeClick:m,onBackgroundClick:M,onNodeHover:L,onLinkHover:H,onLinkClick:E,onChangeSelectedNodeIds:Z},Y)=>{let R=T1.useTheme(),[i1,a1]=K6.useState(true),[d1,l1]=K6.useState(null),[c1,u1]=K6.useState(null),a=K6.useRef({transform:{x:0,y:0,k:1},isPanning:false,hoveredNode:null,hoveredLink:null,draggedNode:null,selectedNodeIds:new Set,hoveredButtonIndex:null,highlightNodes:new Set,highlightLinks:new Set,lastMousePos:{x:0,y:0},mustBeStoppedPropagation:false,mouseStartPos:null,isDragging:false,width:t*G2,height:n*G2,animation:{id:null,buttonIndex:null},spinnerAngle:0}),{nodes:U,links:s1}=K6.useMemo(()=>ne__default.default(d),[d]),[n1,R2]=K6.useState([]),K=K6.useRef(null),D=K6.useRef(null),w1=K6.useRef(null),I6=d3.scaleOrdinal(d3.schemeCategory10),E6=K6.useCallback(()=>{if(!K.current)return false;try{let o=K.current.getContext("2d");return o?(w1.current=o,!0):(console.error("Failed to get 2D context"),!1)}catch(o){return console.error("Error initializing Canvas 2D context:",o),false}},[]),J=K6.useCallback(()=>D.current?D.current.nodes():null,[]),C1=K6.useCallback(()=>{if(!D.current)return null;let o=D.current.force("link");return o?o.links():null},[]),G5=K6.useCallback(o=>{if(!u)return;o.save(),o.setTransform(1,0,0,1,0,0);let{width:C,height:c}=a.current,p=o1.gridSpacing,f=o1.dotSize;o.fillStyle=R.graph2D.grid.dotColor;for(let S=p/2;S<=C;S+=p)for(let h=p/2;h<=c;h+=p)o.beginPath(),o.arc(S,h,f,0,2*Math.PI),o.fill();o.restore();},[u,R.graph2D.grid.dotColor,o1.gridSpacing,o1.dotSize]),$6=K6.useCallback((o,C,c)=>{if(!o)return "";if(c.measureText(o).width<=C)return o;let f=o,S="...";for(;c.measureText(f+S).width>C&&f.length>0;)f=f.slice(0,-1);return f+S},[]),A2=r(o=>{let c=Math.min(o,o1.maxZoom)/o1.maxZoom;return Math.max(o1.fontSize*c,o1.fontSize)},"calculateFontSize"),R5=K6.useCallback(o=>{let C=C1(),c=J();!C||C.length===0||!c||c.length===0||(o.lineWidth=.5,o.globalAlpha=1,C.forEach(p=>{let f=typeof p.source=="object"?p.source:c.find(r1=>r1.id===p.source),S=typeof p.target=="object"?p.target:c.find(r1=>r1.id===p.target);if(!f||!S)return;let h={x:f.x||0,y:f.y||0},w={x:S.x||0,y:S.y||0},g=w.x-h.x,b=w.y-h.y,x=Math.sqrt(g*g+b*b),v=g/x,$=b/x,k=m1(f)/2,P=m1(S)/2,q=4,N={x:h.x+v*k,y:h.y+$*k},y={x:w.x-v*(P+q),y:w.y-$*(P+q)},z={x:w.x-v*(P+1),y:w.y-$*(P+1)},B=a.current.highlightLinks.has(p),F=B?R.graph2D.link.highlighted:p.color||R.graph2D.link.normal,I=he(p,B),O=h.x+(w.x-h.x)/2,Q=h.y+(w.y-h.y)/2,e1=Math.atan2(b,g);if(p.label){let r1=a.current.transform.k,b1=A2(r1);o.font=`${b1}px Sans-Serif`;let M1=o.measureText(p.label).width,L1=10;o.beginPath(),o.moveTo(N.x,N.y);let H1=x/2-(M1+L1)/2,x1={x:h.x+v*H1,y:h.y+$*H1};o.lineTo(x1.x,x1.y),o.strokeStyle=F,o.lineWidth=I,o.stroke(),o.beginPath();let G1=x/2+(M1+L1)/2,t2={x:h.x+v*G1,y:h.y+$*G1};o.moveTo(t2.x,t2.y),o.lineTo(y.x,y.y),o.strokeStyle=F,o.lineWidth=I,o.stroke();}else o.beginPath(),o.moveTo(N.x,N.y),o.lineTo(y.x,y.y),o.strokeStyle=F,o.lineWidth=I,o.stroke();let j=Math.max(2,I*2),t1=Math.max(4,I*4);if(o.save(),o.translate(z.x,z.y),o.rotate(e1),o.beginPath(),o.moveTo(0,0),o.lineTo(-t1,j),o.lineTo(-t1,0),o.lineTo(-t1,-j),o.closePath(),o.fillStyle=F,o.fill(),o.restore(),p.label){let r1=a.current.transform.k,b1=A2(r1);o.font=`${b1}px Sans-Serif`,o.textAlign="center",o.textBaseline="middle",o.save(),o.translate(O,Q),Math.abs(e1)>Math.PI/2?o.rotate(e1+Math.PI):o.rotate(e1),o.fillStyle=B?R.graph2D.link.highlightedTextColor:R.graph2D.link.textColor,o.fillText(p.label,0,0),o.restore();}}));},[o1,R.graph2D.link]),A5=r((o,C,c,p,f,S,h)=>{try{if(S!=null){let w=f*.8;o.font=`${w}px sans-serif`,o.textBaseline="middle",o.textAlign="left";let g=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1,minimumFractionDigits:0,compactDisplay:"short"}).format(S),b=o.measureText(g).width,x=f*.3,$=(f+x+b)/2;o.drawImage(C,c-$,p-f/2,f,f),o.fillStyle=h||"#99989C",o.fillText(g,c-$+f+x,p);}else o.drawImage(C,c-f/2,p-f/2,f,f);}catch(w){console.warn("Error rendering icon:",w);}},"drawIconWithOptionalCounter"),D5=K6.useCallback((o,C)=>{if(!n1||n1.length===0||!o||!o.x||!o.y)return;let{x:c,y:p}=o,f=m1(o),S=f*o1.nodeAreaFactor/2;C.save();let h=Math.min(n1.length,8),w=Math.min(Math.PI*2/h,Math.PI);for(let g=0;g<h;g++){let b=g*w,x=(g+1)*w,v=a.current.hoveredButtonIndex===g;C.beginPath(),C.arc(c,p,S,b,x,false),C.lineTo(c,p),C.closePath(),C.lineWidth=1,C.strokeStyle=R.graph2D?.button?.stroke||"#FFFFFF",C.stroke(),C.fillStyle=v?R.graph2D?.button?.hoverFill||"rgba(255, 255, 255, 0.3)":R.graph2D?.button?.normalFill||"rgba(255, 255, 255, 0.1)",C.fill();let $=S*.2,k=(b+x)/2,P=S-f/2+$,q=c+Math.cos(k)*P,N=p+Math.sin(k)*P,y=n1[g],z=typeof y.loading=="function"?y.loading(o):y.loading,B=r(j=>typeof j=="function"?j(o):j,"getImageUrl"),F=B(y.img),I=B(y.hoverImg),O=r(j=>{if(!y.imageCache.has(j)){let t1=new Image;t1.src=j,y.imageCache.set(j,t1);}return y.imageCache.get(j)},"getOrCreateImage"),Q=O(F),e1=O(I);if(z){let j=$/2,t1=$/12;C.save(),C.translate(q,N),C.rotate(a.current.spinnerAngle);for(let r1=0;r1<12;r1++){let b1=Math.PI*2*r1/12,M1=r1/12,L1=Math.cos(b1)*j,H1=Math.sin(b1)*j;C.beginPath(),C.fillStyle=V1(R.graph2D?.button?.spinnerColor,M1),C.arc(L1,H1,t1,0,Math.PI*2),C.fill();}C.restore(),a.current.spinnerAngle+=.1,a.current.spinnerAngle>Math.PI*2&&(a.current.spinnerAngle-=Math.PI*2),a.current.animation.id!==null&&(cancelAnimationFrame(a.current.animation.id),a.current.animation.id=null,a.current.animation.buttonIndex=null),a.current.animation.id=requestAnimationFrame(T),a.current.animation.buttonIndex=g;}else {a.current.animation.id&&a.current.animation.buttonIndex===g&&(cancelAnimationFrame(a.current.animation.id),a.current.animation.id=null,a.current.animation.buttonIndex=null);let j=v?e1:Q,t1=y.getCount?y.getCount(o):null;j.complete?A5(C,j,q,N,$,t1,R.graph2D?.button?.textColor):j.onload=()=>{w1.current&&A5(C,j,q,N,$,t1,R.graph2D?.button?.textColor);};}}C.restore();},[n1,R.graph2D?.button]),N5=K6.useCallback(o=>{if(!c1||!d1)return;let C=Number(R.tooltip.padding)||10,c=Number(R.tooltip.maxWidth)||200,p=Number(R.tooltip.fontSize)||14,f=Number(R.tooltip.borderRadius)||4,S=1.4,h=10;o.save(),o.font=`${p}px Sans-Serif`;let g=(typeof c1=="string"?c1:String(c1)).split(`
1222
- `),b=Math.min(c,Math.max(...g.map(y=>o.measureText(y).width))),x=g.length*p*S,v=b+C*2,$=x+C*2,k=d1.x-v/2,P=d1.y-$-h,q=K.current?.getBoundingClientRect();q&&(k<5&&(k=5),k+v>q.width-5&&(k=q.width-v-5),P<5&&(P=d1.y+h));let N=R.tooltip.shadow?.match(/(-?\d+(?:\.\d+)?(?:px)?)\s+(-?\d+(?:\.\d+)?(?:px)?)\s+(-?\d+(?:\.\d+)?(?:px)?)(?:\s+(-?\d+(?:\.\d+)?(?:px)?))?\s+(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8}|\w+)/);N&&(o.shadowOffsetX=parseFloat(N[1]),o.shadowOffsetY=parseFloat(N[2]),o.shadowBlur=parseFloat(N[3]),o.shadowColor=N[5]),o.fillStyle=R.tooltip.background,o.beginPath(),o.roundRect(k,P,v,$,f),o.fill(),o.shadowColor="transparent",o.shadowBlur=0,o.shadowOffsetX=0,o.shadowOffsetY=0,o.fillStyle=R.tooltip.color,o.textAlign="left",o.textBaseline="top",g.forEach((y,z)=>{o.fillText(y,k+C,P+p/4+C+z*p*S);}),o.restore();},[c1,d1,R.tooltip]),W5=K6.useCallback(o=>{let C=J();!C||C.length===0||(o.globalAlpha=1,C.forEach(c=>{let{x:p,y:f,color:S,fontColor:h,label:w}=c,g=c.id&&a.current.selectedNodeIds.has(c.id),b=c.id&&a.current.hoveredNode?.id===c.id,x=m1(c),v=x/2;if(b&&s&&s.length>0&&D5(c,o),g){let $=x/2+o1.nodeBorderWidth,k=x/2+o1.nodeBorderWidth/2;o.save(),o.shadowBlur=o1.nodeBorderWidth*10,o.shadowColor=R.graph2D.ring.selectionFill,o.beginPath(),o.arc(p,f,$,0,2*Math.PI,false),o.fillStyle=R.graph2D.ring.selectionFill,o.fill(),o.restore(),o.beginPath(),o.arc(p,f,k,0,2*Math.PI,false),o.fillStyle=R.graph2D.ring.borderFill,o.fill();}if(o.beginPath(),o.arc(p,f,v,0,2*Math.PI),o.fillStyle=S||I6(c.group||"0"),o.fill(),w){o.save(),o.translate(p,f);let $=a.current.transform.k,k=A2($),P=x*o1.textPaddingFactor;o.font=`${k}px Sans-Serif`,o.textAlign="center",o.textBaseline="middle",o.fillStyle=h||"#000";let q=$6(w,P,o);o.fillText(q,0,0),o.restore();}}));},[R.graph2D.ring,s,D5]),T=K6.useCallback(()=>{let o=w1.current;o&&(o.clearRect(0,0,a.current.width,a.current.height),G5(o),o.save(),o.setTransform(a.current.transform.k,0,0,a.current.transform.k,a.current.transform.x,a.current.transform.y),R5(o),W5(o),o.restore(),N5(o));},[R5,W5,G5,N5]),O5=K6.useCallback((o,C=[],c,p)=>{let f=C1()||[],S=J()||[];if(!D.current||!o.length)return;let{width:h,height:w}=a.current,g=c?.smoothAppearance??false,b=c?.transitionDuration??1e3,x=new Set(S.map(y=>y.id)),v=o.filter(y=>!x.has(y.id)),$=new Set(f.map(y=>`${typeof y.source=="object"?y.source.id:y.source}-${typeof y.target=="object"?y.target.id:y.target}`)),k=C.filter(y=>{let z=`${typeof y.source=="object"?y.source.id:y.source}-${typeof y.target=="object"?y.target.id:y.target}`;return !$.has(z)});if(v.length===0&&k.length===0)return;let P=[...S,...v],q=[...f,...k];g&&(v.forEach(y=>{let z=k.filter(B=>{let F=typeof B.source=="object"?B.source.id:B.source,I=typeof B.target=="object"?B.target.id:B.target;return F===y.id&&x.has(I)||I===y.id&&x.has(F)});if(z.length>0){let B=z[0],F=typeof B.source=="object"?B.source.id===y.id?B.target:B.source.id:B.source===y.id?B.target:B.source,I=P.find(O=>O.id===F);if(I&&I.x!==void 0&&I.y!==void 0){let O=30+Math.random()*20,Q=Math.random()*Math.PI*2;y.x=I.x+Math.cos(Q)*O,y.y=I.y+Math.sin(Q)*O,y.vx=0,y.vy=0;}}else {let B=h/2,F=w/2,I=Math.min(h,w)/4,O=Math.random()*Math.PI*2;y.x=B+Math.cos(O)*(I*Math.random()),y.y=F+Math.sin(O)*(I*Math.random()),y.vx=0,y.vy=0;}}),S.forEach(y=>{y.fx=y.x,y.fy=y.y;})),D.current.nodes(P);let N=D.current.force("link");N&&N.links(q),k.forEach(y=>{let z=typeof y.source=="object"?y.source:P.find(F=>F.id===y.source),B=typeof y.target=="object"?y.target:P.find(F=>F.id===y.target);!z||!B||(!z.neighbors&&(z.neighbors=[]),!B.neighbors&&(B.neighbors=[]),z.neighbors.push(B),B.neighbors.push(z),!z.links&&(z.links=[]),!B.links&&(B.links=[]),z.links.push(y),B.links.push(y));}),g?(D.current.alphaTarget(.3),D.current.alpha(.3),D.current.velocityDecay(.7),D.current.restart(),setTimeout(()=>{S.forEach(y=>{y.fx=void 0,y.fy=void 0;}),D.current?.alphaTarget(0),D.current?.alpha(.1),D.current?.velocityDecay(.6);},b)):D.current.alpha(.1).restart(),T(),p?.();},[U,T]),Y5=K6.useCallback(o=>{let C=J(),c=C1();if(!D.current||!o.length||!C||C.length===0||!c||c.length===0)return;let p=new Set(o);if(o.forEach(g=>a.current.selectedNodeIds.delete(g)),a.current.hoveredNode&&a.current.hoveredNode.id!==void 0&&p.has(a.current.hoveredNode.id)&&(a.current.hoveredNode=null),a.current.hoveredLink){let g=typeof a.current.hoveredLink.source=="object"?a.current.hoveredLink.source.id:a.current.hoveredLink.source,b=typeof a.current.hoveredLink.target=="object"?a.current.hoveredLink.target.id:a.current.hoveredLink.target;(g!==void 0&&p.has(g)||b!==void 0&&p.has(b))&&(a.current.hoveredLink=null);}a.current.draggedNode&&a.current.draggedNode.id!==void 0&&p.has(a.current.draggedNode.id)&&(a.current.draggedNode=null);let f=C.filter(g=>g.id!==void 0&&!p.has(g.id)),S=c.filter(g=>{let b=typeof g.source=="object"?g.source.id:g.source,x=typeof g.target=="object"?g.target.id:g.target;return b!==void 0&&!p.has(b)&&x!==void 0&&!p.has(x)}),h=[];a.current.highlightLinks.forEach(g=>{let b=typeof g.source=="object"?g.source.id:g.source,x=typeof g.target=="object"?g.target.id:g.target;(b!==void 0&&p.has(b)||x!==void 0&&p.has(x))&&h.push(g);}),h.forEach(g=>a.current.highlightLinks.delete(g)),f.forEach(g=>{g.neighbors=[],g.links=[];}),S.forEach(g=>{let b=typeof g.source=="object"?g.source:f.find(v=>v.id===g.source),x=typeof g.target=="object"?g.target:f.find(v=>v.id===g.target);!b||!x||(b.neighbors=b.neighbors||[],x.neighbors=x.neighbors||[],b.neighbors.push(x),x.neighbors.push(b),b.links=b.links||[],x.links=x.links||[],b.links.push(g),x.links.push(g));}),D.current.nodes(f);let w=D.current.force("link");w&&w.links(S),Z?.(a.current.selectedNodeIds),T();},[T,Z]),v1=K6.useCallback((o=0,C=20)=>{let c=J();if(!w1.current||!K.current||!c||!c.length)return;let f=1/0,S=1/0,h=-1/0,w=-1/0;if(c.forEach(g=>{if(g.x===void 0||g.y===void 0)return;let b=g.x,x=g.y;f=Math.min(f,b),S=Math.min(S,x),h=Math.max(h,b),w=Math.max(w,x);}),isFinite(f)&&isFinite(h)&&isFinite(S)&&isFinite(w)){let{width:g,height:b}=a.current;f-=C,S-=C,h+=C,w+=C;let x=h-f,v=w-S,$=x>0?g/x:1,k=v>0?b/v:1,P=Math.min($,k,10),q=f+x/2,N=S+v/2,y={k:P,x:g/2-q*P,y:b/2-N*P};if(o>0){let z={...a.current.transform},B=Date.now(),F=r(()=>{let I=Math.min(1,(Date.now()-B)/o),O=I===1?1:1-Math.pow(1-I,3),Q={k:z.k+(y.k-z.k)*O,x:z.x+(y.x-z.x)*O,y:z.y+(y.y-z.y)*O};a.current.transform=Q,T(),I<1&&requestAnimationFrame(F);},"animateZoom");requestAnimationFrame(F);}else a.current.transform=y,T();}},[]),X5=K6.useCallback((o=0,C=20)=>{let c=J(),p=w1.current,f=a.current.selectedNodeIds;if(!p||!K.current||!c||!c.length||f.size===0)return;let S=c.filter(x=>x.id&&f.has(x.id));if(S.length===0)return;let h=1/0,w=1/0,g=-1/0,b=-1/0;if(S.forEach(x=>{x.x===void 0||x.y===void 0||(h=Math.min(h,x.x),w=Math.min(w,x.y),g=Math.max(g,x.x),b=Math.max(b,x.y));}),h===g&&w===b&&(h-=100,w-=100,g+=100,b+=100),isFinite(h)&&isFinite(g)&&isFinite(w)&&isFinite(b)){let{width:x,height:v}=a.current;h-=C,w-=C,g+=C,b+=C;let $=g-h,k=b-w,P=$>0?x/$:1,q=k>0?v/k:1,N=Math.min(P,q,o1.maxZoom),y=h+$/2,z=w+k/2,B={k:N,x:x/2-y*N,y:v/2-z*N};if(o>0){let F={...a.current.transform},I=Date.now(),O=r(()=>{let Q=Math.min(1,(Date.now()-I)/o),e1=Q===1?1:1-Math.pow(1-Q,3),j={k:F.k+(B.k-F.k)*e1,x:F.x+(B.x-F.x)*e1,y:F.y+(B.y-F.y)*e1};a.current.transform=j,T(),Q<1&&requestAnimationFrame(O);},"animateZoom");requestAnimationFrame(O);}else a.current.transform=B,T();}},[J,T]),_5=K6.useCallback((o,C=0,c=20)=>{let p=J();if(!w1.current||!K.current||!p||!p.length||!o||o.length===0)return;let S=new Set(o),h=p.filter(v=>v.id&&S.has(v.id));if(h.length===0)return;let w=1/0,g=1/0,b=-1/0,x=-1/0;if(h.forEach(v=>{v.x===void 0||v.y===void 0||(w=Math.min(w,v.x),g=Math.min(g,v.y),b=Math.max(b,v.x),x=Math.max(x,v.y));}),w===b&&g===x&&(w-=100,g-=100,b+=100,x+=100),isFinite(w)&&isFinite(b)&&isFinite(g)&&isFinite(x)){let{width:v,height:$}=a.current;w-=c,g-=c,b+=c,x+=c;let k=b-w,P=x-g,q=k>0?v/k:1,N=P>0?$/P:1,y=Math.min(q,N,o1.maxZoom),z=w+k/2,B=g+P/2,F={k:y,x:v/2-z*y,y:$/2-B*y};if(C>0){let I={...a.current.transform},O=Date.now(),Q=r(()=>{let e1=Math.min(1,(Date.now()-O)/C),j=e1===1?1:1-Math.pow(1-e1,3),t1={k:I.k+(F.k-I.k)*j,x:I.x+(F.x-I.x)*j,y:I.y+(F.y-I.y)*j};a.current.transform=t1,T(),e1<1&&requestAnimationFrame(Q);},"animateZoom");requestAnimationFrame(Q);}else a.current.transform=F,T();}},[J,T]),z1=K6.useCallback(o=>{a.current.selectedNodeIds.clear(),a.current.highlightLinks.clear(),o.forEach(C=>a.current.selectedNodeIds.add(C)),Z?.(a.current.selectedNodeIds),T();},[T,Z]),U5=K6.useCallback((o,C)=>{let c=J();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.size=C);}),D.current&&(D.current.force("collide",d3.forceCollide().radius(p=>m1(p)).iterations(2).strength(1)),D.current.alpha(.2).restart()),T());},[J,T]),q5=K6.useCallback((o,C)=>{let c=J();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.color=C);}),T());},[J,T]),j5=K6.useCallback((o,C)=>{let c=C1();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.width=C);}),T());},[C1,T]),K5=K6.useCallback((o,C)=>{let c=C1();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.color=C);}),T());},[C1,T]),J5=K6.useCallback((o,C)=>{let c=J(),p=C1();if(!c||!p||c.length===0||p.length===0)return 0;let f=c.find(b=>b.id===o),S=c.find(b=>b.id===C);if(!f||!S)return console.warn("Source or target node not found"),0;if(o===C)return z1([o]),1;let h=new Map;p.forEach(b=>{let x=typeof b.source=="object"?b.source.id:b.source,v=typeof b.target=="object"?b.target.id:b.target;x===void 0||v===void 0||(h.has(x)||h.set(x,[]),h.has(v)||h.set(v,[]),h.get(x).push({nodeId:v,link:b}),h.get(v).push({nodeId:x,link:b}));});let w=[{nodeId:o,path:[o],links:[]}],g=new Set([o]);for(;w.length>0;){let b=w.shift();if(b.nodeId===C)return z1(b.path),a.current.highlightLinks.clear(),b.links.forEach(v=>{a.current.highlightLinks.add(v);}),T(),b.path.length;(h.get(b.nodeId)||[]).forEach(({nodeId:v,link:$})=>{g.has(v)||(g.add(v),w.push({nodeId:v,path:[...b.path,v],links:[...b.links,$]}));});}return console.warn("No path found between nodes"),0},[J,C1,z1,T]),Q5=K6.useCallback((o,C)=>{let c=J();if(!c||c.length===0||o.size===0)return;let p=C?.spacing??100,f=c.filter(k=>k.id!==void 0&&o.has(k.id));if(f.length===0){console.warn("No nodes found with provided IDs");return}let S=C?.columns??Math.ceil(Math.sqrt(f.length)),h=f.reduce((k,P)=>k+(P.x??0),0)/f.length,w=f.reduce((k,P)=>k+(P.y??0),0)/f.length,g=Math.ceil(f.length/S),b=(S-1)*p,x=(g-1)*p,v=h-b/2,$=w-x/2;f.forEach((k,P)=>{let q=P%S,N=Math.floor(P/S),y=v+q*p,z=$+N*p;k.x=y,k.y=z,k.fx=y,k.fy=z;}),D.current&&D.current.alpha(.3).restart(),T();},[J,T]),e4=K6.useCallback((o,C)=>{let c=J();if(!c||c.length===0)return;let p=C?.spacing??100,f=C?.groupSpacing??200,S=C?.columns,h=new Map;c.forEach(F=>{let I=F[o],O;Array.isArray(I)?O=I.length>0?String(I[0]):"undefined":typeof I=="string"?O=I:O="undefined",h.has(O)||h.set(O,[]),h.get(O).push(F);});let w=h.size,g=Math.ceil(Math.sqrt(w)),b=c.reduce((F,I)=>F+(I.x??0),0)/c.length,x=c.reduce((F,I)=>F+(I.y??0),0)/c.length,v=0,$=[];h.forEach(F=>{let I=S??Math.ceil(Math.sqrt(F.length)),O=Math.ceil(F.length/I),Q=(I-1)*p,e1=(O-1)*p;$.push({width:Q,height:e1});});let k=Math.max(...$.map(F=>F.width),0),P=Math.max(...$.map(F=>F.height),0),q=Math.ceil(w/g),N=(g-1)*(k+f),y=(q-1)*(P+f),z=b-N/2,B=x-y/2;h.forEach((F,I)=>{if(F.length===0){v++;return}let O=v%g,Q=Math.floor(v/g),e1=z+O*(k+f),j=B+Q*(P+f),t1=S??Math.ceil(Math.sqrt(F.length)),r1=Math.ceil(F.length/t1),b1=(t1-1)*p,M1=(r1-1)*p,L1=e1-b1/2,H1=j-M1/2;F.forEach((x1,G1)=>{let t2=G1%t1,z6=Math.floor(G1/t1),i4=L1+t2*p,a4=H1+z6*p;x1.x=i4,x1.y=a4,x1.fx=i4,x1.fy=a4;}),v++;}),D.current&&D.current.alpha(.3).restart(),T(),v1(300,50);},[J,T,v1]),K1=K6.useCallback((o,C)=>{let c=J();if(!c||c.length===0)return null;let p=typeof window<"u"&&window.devicePixelRatio||1,f=(o*p-a.current.transform.x)/a.current.transform.k,S=(C*p-a.current.transform.y)/a.current.transform.k;return c.find(h=>{let w=m1(h)/2,g=(h.x||0)-f,b=(h.y||0)-S;return Math.sqrt(g*g+b*b)<=w})||null},[]),J1=K6.useCallback((o,C)=>{let c=C1(),p=J();if(!c||c.length===0||!p||p.length===0)return null;let f=typeof window<"u"&&window.devicePixelRatio||1,S=(o*f-a.current.transform.x)/a.current.transform.k,h=(C*f-a.current.transform.y)/a.current.transform.k,w=5;return c.find(g=>{let b=typeof g.source=="object"?g.source:p.find(r1=>r1.id===g.source),x=typeof g.target=="object"?g.target:p.find(r1=>r1.id===g.target);if(!b||!x)return false;let v=b.x||0,$=b.y||0,k=x.x||0,P=x.y||0,q=S-v,N=h-$,y=k-v,z=P-$,B=q*y+N*z,F=y*y+z*z;if(F===0)return false;let I=B/F;I=Math.max(0,Math.min(1,I));let O=v+I*y,Q=$+I*z,e1=S-O,j=h-Q;return Math.sqrt(e1*e1+j*j)<=w})||null},[]),t4=K6.useCallback((o,C,c,p,f,S,h)=>{let w=o-c,g=C-p,b=Math.sqrt(w*w+g*g),x=Math.atan2(g,w);x<0&&(x+=2*Math.PI);let k=b>=f*.5&&b<=f*1,P=false;return S===Math.PI&&h===Math.PI*2?P=x>=Math.PI&&x<=Math.PI*2:S===0&&h===Math.PI?P=x>=0&&x<=Math.PI:P=S<=h&&x>=S&&x<=h||S>h&&(x>=S||x<=h),k&&P},[]),D2=K6.useCallback(o=>{o!==a.current.hoveredNode&&(a.current.hoveredNode=o,L&&L(o));},[L]),N2=K6.useCallback((o,C)=>{if(C===a.current.hoveredLink)return;let c=new Set,p=new Set;if(C){p.add(C);let f=J();if(f){let S=typeof C.source=="object"?C.source:f.find(w=>w.id===C.source),h=typeof C.target=="object"?C.target:f.find(w=>w.id===C.target);S&&c.add(S),h&&c.add(h);}}a.current.hoveredLink=C,H&&H(C,o);},[H,J]),o4=K6.useCallback(o=>{E&&E(o);},[E]),r4=K6.useCallback((o,C)=>{C.id&&(o.ctrlKey||o.metaKey?(a.current.selectedNodeIds.has(C.id)?a.current.selectedNodeIds.delete(C.id):a.current.selectedNodeIds.add(C.id),a.current.highlightLinks.clear()):(a.current.selectedNodeIds.clear(),a.current.highlightLinks.clear(),a.current.selectedNodeIds.add(C.id)),Z?.(a.current.selectedNodeIds),T()),m&&m(C);},[m,Z,T]),n4=K6.useCallback(()=>{a.current.selectedNodeIds.clear(),a.current.highlightLinks.clear(),Z?.(a.current.selectedNodeIds),T(),M&&M();},[M,Z,T]),W2=K6.useCallback(o=>{if(!K.current||!D.current)return;let C=K.current.getBoundingClientRect(),c=o.clientX-C.left,p=o.clientY-C.top;a.current.mouseStartPos={x:c,y:p},a.current.isDragging=false;let f=K1(c,p);f?(a.current.draggedNode=f,f.fx=f.x,f.fy=f.y):(a.current.isPanning=true,a.current.lastMousePos={x:c,y:p});},[K1]),Q1=K6.useCallback((o,C)=>{let c=null;if(K.current&&a.current&&n1.length>0&&a.current.hoveredNode){let f=m1(a.current.hoveredNode)*o1.nodeAreaFactor/2,S=K.current.getBoundingClientRect(),h=K.current.width/S.width,w=K.current.height/S.height,g=o*h,b=C*w,x=(g-a.current.transform.x)/a.current.transform.k,v=(b-a.current.transform.y)/a.current.transform.k,$=a.current.hoveredNode?.x||0,k=a.current.hoveredNode?.y||0,P=Math.min(n1.length,8),q=Math.min(Math.PI*2/P,Math.PI);for(let N=0;N<P;N++){let y=N*q,z=(N+1)*q;if(t4(x,v,$,k,f,y,z)){c=N;break}}}return c},[n1]),O2=K6.useCallback(o=>{if(!K.current)return;let C=K.current.getBoundingClientRect(),c=o.clientX-C.left,p=o.clientY-C.top;if(a.current.draggedNode&&a.current.mouseStartPos&&D.current){let h=a.current.mouseStartPos.x,w=a.current.mouseStartPos.y,g=c-h,b=p-w;Math.sqrt(g*g+b*b)>3&&(a.current.isDragging=true,D.current.alphaTarget()===0&&D.current.alphaTarget(0).restart());let $=typeof window<"u"&&window.devicePixelRatio||1,k=(c*$-a.current.transform.x)/a.current.transform.k,P=(p*$-a.current.transform.y)/a.current.transform.k;a.current.draggedNode.fx=k,a.current.draggedNode.fy=P;return}if(a.current.isPanning&&a.current.mouseStartPos){let h=c-a.current.lastMousePos.x,w=p-a.current.lastMousePos.y,g=a.current.mouseStartPos.x,b=a.current.mouseStartPos.y;Math.sqrt(Math.pow(c-g,2)+Math.pow(p-b,2))>3&&(a.current.isDragging=true),a.current.transform={...a.current.transform,x:a.current.transform.x+h,y:a.current.transform.y+w},a.current.lastMousePos={x:c,y:p},T();return}let f,S;if(a.current.hoveredNode&&K.current&&n1.length>0){let h=Q1(c,p);if(h!==null&&(S=a.current.hoveredNode),h!==null&&a.current.hoveredButtonIndex===h&&l1({x:c,y:p}),h!==a.current.hoveredButtonIndex){if(f=true,h!==null){let w=n1[h];w?.tooltip?.content?(u1(w.tooltip.content),l1({x:c,y:p})):(u1(null),l1(null));}else u1(null),l1(null);a.current.hoveredButtonIndex=h;}}else a.current.hoveredButtonIndex!==null&&(a.current.hoveredButtonIndex=null,u1(null),l1(null));if(!S&&(S=K1(c,p),!S)){let h=J1(c,p),w=h!==a.current.hoveredLink;if(h&&a.current.hoveredNode&&D2(null),N2(o,h),K.current&&(K.current.style.cursor=h?"pointer":"default"),w){T();return}}S&&a.current.hoveredLink&&N2(o,null),S!==a.current.hoveredNode&&(f=true),D2(S),K.current&&(K.current.style.cursor=S?"pointer":"default"),f&&T();},[n1,K1,J1,D2,N2,T,t4,Q1]),Z6=K6.useCallback(o=>{a.current.mustBeStoppedPropagation&&(o.stopPropagation(),o.preventDefault()),a.current.mustBeStoppedPropagation=false;},[]),e2=K6.useCallback(o=>{let C=a.current.isDragging;if(C&&(a.current.mustBeStoppedPropagation=true),!C&&a.current.mouseStartPos){let c=K.current?.getBoundingClientRect();if(c){let p=o.clientX-c.left,f=o.clientY-c.top;if(n1.length>0&&a.current.hoveredButtonIndex===null){let h=Q1(p,f);a.current.hoveredButtonIndex=h;}let S=false;if(a.current.hoveredNode&&a.current.hoveredButtonIndex!==null&&s[a.current.hoveredButtonIndex]){let h=s[a.current.hoveredButtonIndex];h&&h.onClick&&(h.onClick(a.current.hoveredNode),S=true,a.current.hoveredButtonIndex=null);}if(!S&&a.current.draggedNode)r4(o,a.current.draggedNode);else if(!S&&!a.current.draggedNode){let h=J1(p,f);h?o4(h):n4();}}}if(a.current.draggedNode&&D.current){if(C){D.current.alphaTarget(0);let c=.05,p=.04,f=.6;D.current.alpha(c).alphaDecay(p),D.current.velocityDecay(f);}else D.current.alphaTarget(0);a.current.draggedNode.fx=void 0,a.current.draggedNode.fy=void 0,a.current.draggedNode=null;}a.current.isDragging=false,a.current.mouseStartPos=null,a.current.isPanning&&(a.current.isPanning=false),T();},[s,T,r4,n4,J1,o4,Q1,n1]),Y2=K6.useCallback(o=>{if(o.stopPropagation(),o.preventDefault(),!K.current)return;let C=K.current.getBoundingClientRect(),c=o.clientX-C.left,p=o.clientY-C.top,S=-o.deltaY>0?1.1:1/1.1,h=a.current.transform,w=h.k*S;if(w<.01||w>10)return;let g=h.k*S,b=c-(c-h.x)*S,x=p-(p-h.y)*S;a.current.transform={k:g,x:b,y:x},T();},[T]),X2=r((o,C)=>{let c=o.touches[0];if(c){let p={clientX:c.clientX,clientY:c.clientY};C(p);}},"convertTouchToMouseEvent"),B6=K6.useCallback(o=>{X2(o,W2);},[W2]),_2=K6.useCallback(o=>{a.current.mustBeStoppedPropagation&&(o.preventDefault(),o.stopPropagation()),a.current.mustBeStoppedPropagation=false,X2(o,e2);},[e2]),T6=K6.useCallback(o=>{X2(o,O2);},[O2]);return K6.useImperativeHandle(Y,()=>({zoomToFit:v1,zoomToSelected:X5,zoomToNodes:_5,addNodes:O5,removeNodes:Y5,setSelectedNodes:z1,setNodeSizes:U5,setNodeColors:q5,setLinkWidths:j5,setLinkColors:K5,findShortestPath:J5,arrangeSelectedInGrid:Q5,arrangeNodesByTypeInGrid:e4}),[v1,X5,_5,O5,Y5,z1,U5,q5,j5,K5,J5,Q5,e4]),K6.useEffect(()=>{let o=K.current,{width:C,height:c}=a.current;if(!o)return;E6(),a1(true);let p=C/2,f=c/2,S=o1.nodeSizeBase,w=S*2.5;D.current&&D.current.stop();let g=D.current=d3.forceSimulation(U).force("link",d3.forceLink(s1).id(b=>b.id).distance(w).strength(.9)).force("charge",d3.forceManyBody().strength(-S/10*200).theta(.5).distanceMin(S*2)).force("x",d3.forceX().strength(.03)).force("y",d3.forceY().strength(.03)).force("center",d3.forceCenter(p,f).strength(.05)).force("collide",d3.forceCollide().radius(b=>m1(b)).iterations(2).strength(1)).velocityDecay(.6);return ()=>{g.stop();}},[U,s1]),K6.useLayoutEffect(()=>{let o=K.current;o&&(a.current.width=t*G2,a.current.height=n*G2,o.width=a.current.width,o.height=a.current.height);},[t,n]),K6.useEffect(()=>{if(D.current){let o=D.current;o.on("tick",()=>{T();}),o.on("end",()=>{i1&&(v1(0,20),setTimeout(()=>{a1(false);},200));});}i1||T();},[U,s1,i1,T,v1]),K6.useEffect(()=>{!U||!s1||s1.forEach(o=>{let C=typeof o.source=="object"?o.source:U.find(p=>p.id===o.source),c=typeof o.target=="object"?o.target:U.find(p=>p.id===o.target);!C||!c||(!C.neighbors&&(C.neighbors=[]),!c.neighbors&&(c.neighbors=[]),C.neighbors.push(c),c.neighbors.push(C),!C.links&&(C.links=[]),!c.links&&(c.links=[]),C.links.push(o),c.links.push(o));});},[U,s1]),K6.useEffect(()=>{s&&s.length>0&&R2(ge(s));},[s]),K6.useEffect(()=>{let o=K.current;if(!(!o||typeof window>"u"))return o.addEventListener("wheel",Y2,{passive:false}),o.addEventListener("touchend",_2,{passive:false}),()=>{o.removeEventListener("wheel",Y2),o.removeEventListener("touchend",_2);}},[Y2,_2]),jsxRuntime.jsx(fe,{children:jsxRuntime.jsxs(me,{children:[(e||i1)&&jsxRuntime.jsx(V6,{width:t,height:n}),jsxRuntime.jsx(xe,{ref:K,style:{width:t,height:n,display:e||i1?"none":"block"},onMouseDown:W2,onMouseMove:O2,onMouseUp:e2,onMouseLeave:e2,onClick:Z6,onTouchStart:B6,onTouchMove:T6})]})})}),fe=T1.styled.div`
1222
+ `),b=Math.min(c,Math.max(...g.map(y=>o.measureText(y).width))),x=g.length*p*S,v=b+C*2,$=x+C*2,k=d1.x-v/2,P=d1.y-$-h,q=K.current?.getBoundingClientRect();q&&(k<5&&(k=5),k+v>q.width-5&&(k=q.width-v-5),P<5&&(P=d1.y+h));let N=R.tooltip.shadow?.match(/(-?\d+(?:\.\d+)?(?:px)?)\s+(-?\d+(?:\.\d+)?(?:px)?)\s+(-?\d+(?:\.\d+)?(?:px)?)(?:\s+(-?\d+(?:\.\d+)?(?:px)?))?\s+(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8}|\w+)/);N&&(o.shadowOffsetX=parseFloat(N[1]),o.shadowOffsetY=parseFloat(N[2]),o.shadowBlur=parseFloat(N[3]),o.shadowColor=N[5]),o.fillStyle=R.tooltip.background,o.beginPath(),o.roundRect(k,P,v,$,f),o.fill(),o.shadowColor="transparent",o.shadowBlur=0,o.shadowOffsetX=0,o.shadowOffsetY=0,o.fillStyle=R.tooltip.color,o.textAlign="left",o.textBaseline="top",g.forEach((y,z)=>{o.fillText(y,k+C,P+p/4+C+z*p*S);}),o.restore();},[c1,d1,R.tooltip]),W5=K6.useCallback(o=>{let C=J();!C||C.length===0||(o.globalAlpha=1,C.forEach(c=>{let{x:p,y:f,color:S,fontColor:h,label:w}=c,g=c.id&&a.current.selectedNodeIds.has(c.id),b=c.id&&a.current.hoveredNode?.id===c.id,x=m1(c),v=x/2;if(b&&s&&s.length>0&&D5(c,o),g){let $=x/2+o1.nodeBorderWidth,k=x/2+o1.nodeBorderWidth/2;o.save(),o.shadowBlur=o1.nodeBorderWidth*10,o.shadowColor=R.graph2D.ring.selectionFill,o.beginPath(),o.arc(p,f,$,0,2*Math.PI,false),o.fillStyle=R.graph2D.ring.selectionFill,o.fill(),o.restore(),o.beginPath(),o.arc(p,f,k,0,2*Math.PI,false),o.fillStyle=R.graph2D.ring.borderFill,o.fill();}if(o.beginPath(),o.arc(p,f,v,0,2*Math.PI),o.fillStyle=S||I6(c.group||"0"),o.fill(),w){o.save(),o.translate(p,f);let $=a.current.transform.k,k=A2($),P=x*o1.textPaddingFactor;o.font=`${k}px Sans-Serif`,o.textAlign="center",o.textBaseline="middle",o.fillStyle=h||"#000";let q=$6(w,P,o);o.fillText(q,0,0),o.restore();}}));},[R.graph2D.ring,s,D5]),T=K6.useCallback(()=>{let o=w1.current;o&&(o.clearRect(0,0,a.current.width,a.current.height),G5(o),o.save(),o.setTransform(a.current.transform.k,0,0,a.current.transform.k,a.current.transform.x,a.current.transform.y),R5(o),W5(o),o.restore(),N5(o));},[R5,W5,G5,N5]),O5=K6.useCallback((o,C=[],c,p)=>{let f=C1()||[],S=J()||[];if(!D.current||!o.length)return;let{width:h,height:w}=a.current,g=c?.smoothAppearance??false,b=c?.transitionDuration??1e3,x=new Set(S.map(y=>y.id)),v=o.filter(y=>!x.has(y.id)),$=new Set(f.map(y=>`${typeof y.source=="object"?y.source.id:y.source}-${typeof y.target=="object"?y.target.id:y.target}`)),k=C.filter(y=>{let z=`${typeof y.source=="object"?y.source.id:y.source}-${typeof y.target=="object"?y.target.id:y.target}`;return !$.has(z)});if(v.length===0&&k.length===0)return;let P=[...S,...v],q=[...f,...k];g&&(v.forEach(y=>{let z=k.filter(B=>{let F=typeof B.source=="object"?B.source.id:B.source,I=typeof B.target=="object"?B.target.id:B.target;return F===y.id&&x.has(I)||I===y.id&&x.has(F)});if(z.length>0){let B=z[0],F=typeof B.source=="object"?B.source.id===y.id?B.target:B.source.id:B.source===y.id?B.target:B.source,I=P.find(O=>O.id===F);if(I&&I.x!==void 0&&I.y!==void 0){let O=30+Math.random()*20,Q=Math.random()*Math.PI*2;y.x=I.x+Math.cos(Q)*O,y.y=I.y+Math.sin(Q)*O,y.vx=0,y.vy=0;}}else {let B=h/2,F=w/2,I=Math.min(h,w)/4,O=Math.random()*Math.PI*2;y.x=B+Math.cos(O)*(I*Math.random()),y.y=F+Math.sin(O)*(I*Math.random()),y.vx=0,y.vy=0;}}),S.forEach(y=>{y.fx=y.x,y.fy=y.y;})),D.current.nodes(P);let N=D.current.force("link");N&&N.links(q),k.forEach(y=>{let z=typeof y.source=="object"?y.source:P.find(F=>F.id===y.source),B=typeof y.target=="object"?y.target:P.find(F=>F.id===y.target);!z||!B||(!z.neighbors&&(z.neighbors=[]),!B.neighbors&&(B.neighbors=[]),z.neighbors.push(B),B.neighbors.push(z),!z.links&&(z.links=[]),!B.links&&(B.links=[]),z.links.push(y),B.links.push(y));}),g?(D.current.alphaTarget(.3),D.current.alpha(.3),D.current.velocityDecay(.7),D.current.restart(),setTimeout(()=>{S.forEach(y=>{y.fx=void 0,y.fy=void 0;}),D.current?.alphaTarget(0),D.current?.alpha(.1),D.current?.velocityDecay(.6);},b)):D.current.alpha(.1).restart(),T(),p?.();},[U,T]),Y5=K6.useCallback(o=>{let C=J(),c=C1();if(!D.current||!o.length||!C||C.length===0||!c||c.length===0)return;let p=new Set(o);if(o.forEach(g=>a.current.selectedNodeIds.delete(g)),a.current.hoveredNode&&a.current.hoveredNode.id!==void 0&&p.has(a.current.hoveredNode.id)&&(a.current.hoveredNode=null),a.current.hoveredLink){let g=typeof a.current.hoveredLink.source=="object"?a.current.hoveredLink.source.id:a.current.hoveredLink.source,b=typeof a.current.hoveredLink.target=="object"?a.current.hoveredLink.target.id:a.current.hoveredLink.target;(g!==void 0&&p.has(g)||b!==void 0&&p.has(b))&&(a.current.hoveredLink=null);}a.current.draggedNode&&a.current.draggedNode.id!==void 0&&p.has(a.current.draggedNode.id)&&(a.current.draggedNode=null);let f=C.filter(g=>g.id!==void 0&&!p.has(g.id)),S=c.filter(g=>{let b=typeof g.source=="object"?g.source.id:g.source,x=typeof g.target=="object"?g.target.id:g.target;return b!==void 0&&!p.has(b)&&x!==void 0&&!p.has(x)}),h=[];a.current.highlightLinks.forEach(g=>{let b=typeof g.source=="object"?g.source.id:g.source,x=typeof g.target=="object"?g.target.id:g.target;(b!==void 0&&p.has(b)||x!==void 0&&p.has(x))&&h.push(g);}),h.forEach(g=>a.current.highlightLinks.delete(g)),f.forEach(g=>{g.neighbors=[],g.links=[];}),S.forEach(g=>{let b=typeof g.source=="object"?g.source:f.find(v=>v.id===g.source),x=typeof g.target=="object"?g.target:f.find(v=>v.id===g.target);!b||!x||(b.neighbors=b.neighbors||[],x.neighbors=x.neighbors||[],b.neighbors.push(x),x.neighbors.push(b),b.links=b.links||[],x.links=x.links||[],b.links.push(g),x.links.push(g));}),D.current.nodes(f);let w=D.current.force("link");w&&w.links(S),Z?.(a.current.selectedNodeIds),T();},[T,Z]),v1=K6.useCallback((o=0,C=20)=>{let c=J();if(!w1.current||!K.current||!c||!c.length)return;let f=1/0,S=1/0,h=-1/0,w=-1/0;if(c.forEach(g=>{if(g.x===void 0||g.y===void 0)return;let b=g.x,x=g.y;f=Math.min(f,b),S=Math.min(S,x),h=Math.max(h,b),w=Math.max(w,x);}),isFinite(f)&&isFinite(h)&&isFinite(S)&&isFinite(w)){let{width:g,height:b}=a.current;f-=C,S-=C,h+=C,w+=C;let x=h-f,v=w-S,$=x>0?g/x:1,k=v>0?b/v:1,P=Math.min($,k,10),q=f+x/2,N=S+v/2,y={k:P,x:g/2-q*P,y:b/2-N*P};if(o>0){let z={...a.current.transform},B=Date.now(),F=r(()=>{let I=Math.min(1,(Date.now()-B)/o),O=I===1?1:1-Math.pow(1-I,3),Q={k:z.k+(y.k-z.k)*O,x:z.x+(y.x-z.x)*O,y:z.y+(y.y-z.y)*O};a.current.transform=Q,T(),I<1&&requestAnimationFrame(F);},"animateZoom");requestAnimationFrame(F);}else a.current.transform=y,T();}},[]),X5=K6.useCallback((o=0,C=20)=>{let c=J(),p=w1.current,f=a.current.selectedNodeIds;if(!p||!K.current||!c||!c.length||f.size===0)return;let S=c.filter(x=>x.id&&f.has(x.id));if(S.length===0)return;let h=1/0,w=1/0,g=-1/0,b=-1/0;if(S.forEach(x=>{x.x===void 0||x.y===void 0||(h=Math.min(h,x.x),w=Math.min(w,x.y),g=Math.max(g,x.x),b=Math.max(b,x.y));}),h===g&&w===b&&(h-=100,w-=100,g+=100,b+=100),isFinite(h)&&isFinite(g)&&isFinite(w)&&isFinite(b)){let{width:x,height:v}=a.current;h-=C,w-=C,g+=C,b+=C;let $=g-h,k=b-w,P=$>0?x/$:1,q=k>0?v/k:1,N=Math.min(P,q,o1.maxZoom),y=h+$/2,z=w+k/2,B={k:N,x:x/2-y*N,y:v/2-z*N};if(o>0){let F={...a.current.transform},I=Date.now(),O=r(()=>{let Q=Math.min(1,(Date.now()-I)/o),e1=Q===1?1:1-Math.pow(1-Q,3),j={k:F.k+(B.k-F.k)*e1,x:F.x+(B.x-F.x)*e1,y:F.y+(B.y-F.y)*e1};a.current.transform=j,T(),Q<1&&requestAnimationFrame(O);},"animateZoom");requestAnimationFrame(O);}else a.current.transform=B,T();}},[J,T]),_5=K6.useCallback((o,C=0,c=20)=>{let p=J();if(!w1.current||!K.current||!p||!p.length||!o||o.length===0)return;let S=new Set(o),h=p.filter(v=>v.id&&S.has(v.id));if(h.length===0)return;let w=1/0,g=1/0,b=-1/0,x=-1/0;if(h.forEach(v=>{v.x===void 0||v.y===void 0||(w=Math.min(w,v.x),g=Math.min(g,v.y),b=Math.max(b,v.x),x=Math.max(x,v.y));}),w===b&&g===x&&(w-=100,g-=100,b+=100,x+=100),isFinite(w)&&isFinite(b)&&isFinite(g)&&isFinite(x)){let{width:v,height:$}=a.current;w-=c,g-=c,b+=c,x+=c;let k=b-w,P=x-g,q=k>0?v/k:1,N=P>0?$/P:1,y=Math.min(q,N,o1.maxZoom),z=w+k/2,B=g+P/2,F={k:y,x:v/2-z*y,y:$/2-B*y};if(C>0){let I={...a.current.transform},O=Date.now(),Q=r(()=>{let e1=Math.min(1,(Date.now()-O)/C),j=e1===1?1:1-Math.pow(1-e1,3),t1={k:I.k+(F.k-I.k)*j,x:I.x+(F.x-I.x)*j,y:I.y+(F.y-I.y)*j};a.current.transform=t1,T(),e1<1&&requestAnimationFrame(Q);},"animateZoom");requestAnimationFrame(Q);}else a.current.transform=F,T();}},[J,T]),z1=K6.useCallback(o=>{a.current.selectedNodeIds.clear(),a.current.highlightLinks.clear(),o.forEach(C=>a.current.selectedNodeIds.add(C)),Z?.(a.current.selectedNodeIds),T();},[T,Z]),U5=K6.useCallback((o,C)=>{let c=J();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.size=C);}),D.current&&(D.current.force("collide",d3.forceCollide().radius(p=>m1(p)).iterations(2).strength(1)),D.current.alpha(.2).restart()),T());},[J,T]),q5=K6.useCallback((o,C)=>{let c=J();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.color=C);}),T());},[J,T]),j5=K6.useCallback((o,C)=>{let c=C1();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.width=C);}),T());},[C1,T]),K5=K6.useCallback((o,C)=>{let c=C1();!c||c.length===0||(c.forEach(p=>{p.id&&o.includes(p.id)&&(p.color=C);}),T());},[C1,T]),J5=K6.useCallback((o,C)=>{let c=J(),p=C1();if(!c||!p||c.length===0||p.length===0)return 0;let f=c.find(b=>b.id===o),S=c.find(b=>b.id===C);if(!f||!S)return console.warn("Source or target node not found"),0;if(o===C)return z1([o]),1;let h=new Map;p.forEach(b=>{let x=typeof b.source=="object"?b.source.id:b.source,v=typeof b.target=="object"?b.target.id:b.target;x===void 0||v===void 0||(h.has(x)||h.set(x,[]),h.has(v)||h.set(v,[]),h.get(x).push({nodeId:v,link:b}),h.get(v).push({nodeId:x,link:b}));});let w=[{nodeId:o,path:[o],links:[]}],g=new Set([o]);for(;w.length>0;){let b=w.shift();if(b.nodeId===C)return z1(b.path),a.current.highlightLinks.clear(),b.links.forEach(v=>{a.current.highlightLinks.add(v);}),T(),b.path.length;(h.get(b.nodeId)||[]).forEach(({nodeId:v,link:$})=>{g.has(v)||(g.add(v),w.push({nodeId:v,path:[...b.path,v],links:[...b.links,$]}));});}return console.warn("No path found between nodes"),0},[J,C1,z1,T]),Q5=K6.useCallback((o,C)=>{let c=J();if(!c||c.length===0||o.size===0)return;let p=C?.spacing??100,f=c.filter(k=>k.id!==void 0&&o.has(k.id));if(f.length===0){console.warn("No nodes found with provided IDs");return}let S=C?.columns??Math.ceil(Math.sqrt(f.length)),h=f.reduce((k,P)=>k+(P.x??0),0)/f.length,w=f.reduce((k,P)=>k+(P.y??0),0)/f.length,g=Math.ceil(f.length/S),b=(S-1)*p,x=(g-1)*p,v=h-b/2,$=w-x/2;f.forEach((k,P)=>{let q=P%S,N=Math.floor(P/S),y=v+q*p,z=$+N*p;k.x=y,k.y=z,k.fx=y,k.fy=z;}),D.current&&D.current.alpha(.3).restart(),T();},[J,T]),e4=K6.useCallback((o,C)=>{let c=J();if(!c||c.length===0)return;let p=C?.spacing??100,f=C?.groupSpacing??200,S=C?.columns,h=new Map;c.forEach(F=>{let I=F[o],O;Array.isArray(I)?O=I.length>0?String(I[0]):"undefined":typeof I=="string"?O=I:O="undefined",h.has(O)||h.set(O,[]),h.get(O).push(F);});let w=h.size,g=Math.ceil(Math.sqrt(w)),b=c.reduce((F,I)=>F+(I.x??0),0)/c.length,x=c.reduce((F,I)=>F+(I.y??0),0)/c.length,v=0,$=[];h.forEach(F=>{let I=S??Math.ceil(Math.sqrt(F.length)),O=Math.ceil(F.length/I),Q=(I-1)*p,e1=(O-1)*p;$.push({width:Q,height:e1});});let k=Math.max(...$.map(F=>F.width),0),P=Math.max(...$.map(F=>F.height),0),q=Math.ceil(w/g),N=(g-1)*(k+f),y=(q-1)*(P+f),z=b-N/2,B=x-y/2;h.forEach((F,I)=>{if(F.length===0){v++;return}let O=v%g,Q=Math.floor(v/g),e1=z+O*(k+f),j=B+Q*(P+f),t1=S??Math.ceil(Math.sqrt(F.length)),r1=Math.ceil(F.length/t1),b1=(t1-1)*p,M1=(r1-1)*p,L1=e1-b1/2,H1=j-M1/2;F.forEach((x1,G1)=>{let t2=G1%t1,z6=Math.floor(G1/t1),i4=L1+t2*p,a4=H1+z6*p;x1.x=i4,x1.y=a4,x1.fx=i4,x1.fy=a4;}),v++;}),D.current&&D.current.alpha(.3).restart(),T(),v1(300,50);},[J,T,v1]),K1=K6.useCallback((o,C)=>{let c=J();if(!c||c.length===0)return null;let p=typeof window<"u"&&window.devicePixelRatio||1,f=(o*p-a.current.transform.x)/a.current.transform.k,S=(C*p-a.current.transform.y)/a.current.transform.k;return c.find(h=>{let w=m1(h)/2,g=(h.x||0)-f,b=(h.y||0)-S;return Math.sqrt(g*g+b*b)<=w})||null},[]),J1=K6.useCallback((o,C)=>{let c=C1(),p=J();if(!c||c.length===0||!p||p.length===0)return null;let f=typeof window<"u"&&window.devicePixelRatio||1,S=(o*f-a.current.transform.x)/a.current.transform.k,h=(C*f-a.current.transform.y)/a.current.transform.k,w=5;return c.find(g=>{let b=typeof g.source=="object"?g.source:p.find(r1=>r1.id===g.source),x=typeof g.target=="object"?g.target:p.find(r1=>r1.id===g.target);if(!b||!x)return false;let v=b.x||0,$=b.y||0,k=x.x||0,P=x.y||0,q=S-v,N=h-$,y=k-v,z=P-$,B=q*y+N*z,F=y*y+z*z;if(F===0)return false;let I=B/F;I=Math.max(0,Math.min(1,I));let O=v+I*y,Q=$+I*z,e1=S-O,j=h-Q;return Math.sqrt(e1*e1+j*j)<=w})||null},[]),t4=K6.useCallback((o,C,c,p,f,S,h)=>{let w=o-c,g=C-p,b=Math.sqrt(w*w+g*g),x=Math.atan2(g,w);x<0&&(x+=2*Math.PI);let k=b>=f*.5&&b<=f*1,P=false;return S===Math.PI&&h===Math.PI*2?P=x>=Math.PI&&x<=Math.PI*2:S===0&&h===Math.PI?P=x>=0&&x<=Math.PI:P=S<=h&&x>=S&&x<=h||S>h&&(x>=S||x<=h),k&&P},[]),D2=K6.useCallback(o=>{o!==a.current.hoveredNode&&(a.current.hoveredNode=o,L&&L(o));},[L]),N2=K6.useCallback((o,C)=>{if(C===a.current.hoveredLink)return;let c=new Set,p=new Set;if(C){p.add(C);let f=J();if(f){let S=typeof C.source=="object"?C.source:f.find(w=>w.id===C.source),h=typeof C.target=="object"?C.target:f.find(w=>w.id===C.target);S&&c.add(S),h&&c.add(h);}}a.current.hoveredLink=C,H&&H(C,o);},[H,J]),o4=K6.useCallback(o=>{E&&E(o);},[E]),r4=K6.useCallback((o,C)=>{C.id&&(o.ctrlKey||o.metaKey?(a.current.selectedNodeIds.has(C.id)?a.current.selectedNodeIds.delete(C.id):a.current.selectedNodeIds.add(C.id),a.current.highlightLinks.clear()):(a.current.selectedNodeIds.clear(),a.current.highlightLinks.clear(),a.current.selectedNodeIds.add(C.id)),Z?.(a.current.selectedNodeIds),T()),m&&m(C);},[m,Z,T]),n4=K6.useCallback(()=>{a.current.selectedNodeIds.clear(),a.current.highlightLinks.clear(),Z?.(a.current.selectedNodeIds),T(),M&&M();},[M,Z,T]),W2=K6.useCallback(o=>{if(!K.current||!D.current)return;let C=K.current.getBoundingClientRect(),c=o.clientX-C.left,p=o.clientY-C.top;a.current.mouseStartPos={x:c,y:p},a.current.isDragging=false;let f=K1(c,p);f?(a.current.draggedNode=f,f.fx=f.x,f.fy=f.y):(a.current.isPanning=true,a.current.lastMousePos={x:c,y:p});},[K1]),Q1=K6.useCallback((o,C)=>{let c=null;if(K.current&&a.current&&n1.length>0&&a.current.hoveredNode){let f=m1(a.current.hoveredNode)*o1.nodeAreaFactor/2,S=K.current.getBoundingClientRect(),h=K.current.width/S.width,w=K.current.height/S.height,g=o*h,b=C*w,x=(g-a.current.transform.x)/a.current.transform.k,v=(b-a.current.transform.y)/a.current.transform.k,$=a.current.hoveredNode?.x||0,k=a.current.hoveredNode?.y||0,P=Math.min(n1.length,8),q=Math.min(Math.PI*2/P,Math.PI);for(let N=0;N<P;N++){let y=N*q,z=(N+1)*q;if(t4(x,v,$,k,f,y,z)){c=N;break}}}return c},[n1]),O2=K6.useCallback(o=>{if(!K.current)return;let C=K.current.getBoundingClientRect(),c=o.clientX-C.left,p=o.clientY-C.top;if(a.current.draggedNode&&a.current.mouseStartPos&&D.current){let h=a.current.mouseStartPos.x,w=a.current.mouseStartPos.y,g=c-h,b=p-w;Math.sqrt(g*g+b*b)>3&&(a.current.isDragging=true,D.current.alphaTarget()===0&&D.current.alphaTarget(0).restart());let $=typeof window<"u"&&window.devicePixelRatio||1,k=(c*$-a.current.transform.x)/a.current.transform.k,P=(p*$-a.current.transform.y)/a.current.transform.k;a.current.draggedNode.fx=k,a.current.draggedNode.fy=P;return}if(a.current.isPanning&&a.current.mouseStartPos){let h=c-a.current.lastMousePos.x,w=p-a.current.lastMousePos.y,g=a.current.mouseStartPos.x,b=a.current.mouseStartPos.y;Math.sqrt(Math.pow(c-g,2)+Math.pow(p-b,2))>3&&(a.current.isDragging=true),a.current.transform={...a.current.transform,x:a.current.transform.x+h,y:a.current.transform.y+w},a.current.lastMousePos={x:c,y:p},T();return}let f,S;if(a.current.hoveredNode&&K.current&&n1.length>0){let h=Q1(c,p);if(h!==null&&(S=a.current.hoveredNode),h!==null&&a.current.hoveredButtonIndex===h&&l1({x:c,y:p}),h!==a.current.hoveredButtonIndex){if(f=true,h!==null){let w=n1[h];if(w?.tooltip){let g=typeof w.tooltip=="function"?w.tooltip(a.current.hoveredNode):w.tooltip;u1(g),l1({x:c,y:p});}else u1(null),l1(null);}else u1(null),l1(null);a.current.hoveredButtonIndex=h;}}else a.current.hoveredButtonIndex!==null&&(a.current.hoveredButtonIndex=null,u1(null),l1(null));if(!S&&(S=K1(c,p),!S)){let h=J1(c,p),w=h!==a.current.hoveredLink;if(h&&a.current.hoveredNode&&D2(null),N2(o,h),K.current&&(K.current.style.cursor=h?"pointer":"default"),w){T();return}}S&&a.current.hoveredLink&&N2(o,null),S!==a.current.hoveredNode&&(f=true),D2(S),K.current&&(K.current.style.cursor=S?"pointer":"default"),f&&T();},[n1,K1,J1,D2,N2,T,t4,Q1]),Z6=K6.useCallback(o=>{a.current.mustBeStoppedPropagation&&(o.stopPropagation(),o.preventDefault()),a.current.mustBeStoppedPropagation=false;},[]),e2=K6.useCallback(o=>{let C=a.current.isDragging;if(C&&(a.current.mustBeStoppedPropagation=true),!C&&a.current.mouseStartPos){let c=K.current?.getBoundingClientRect();if(c){let p=o.clientX-c.left,f=o.clientY-c.top;if(n1.length>0&&a.current.hoveredButtonIndex===null){let h=Q1(p,f);a.current.hoveredButtonIndex=h;}let S=false;if(a.current.hoveredNode&&a.current.hoveredButtonIndex!==null&&s[a.current.hoveredButtonIndex]){let h=s[a.current.hoveredButtonIndex];h&&h.onClick&&(h.onClick(a.current.hoveredNode),S=true,a.current.hoveredButtonIndex=null);}if(!S&&a.current.draggedNode)r4(o,a.current.draggedNode);else if(!S&&!a.current.draggedNode){let h=J1(p,f);h?o4(h):n4();}}}if(a.current.draggedNode&&D.current){if(C){D.current.alphaTarget(0);let c=.05,p=.04,f=.6;D.current.alpha(c).alphaDecay(p),D.current.velocityDecay(f);}else D.current.alphaTarget(0);a.current.draggedNode.fx=void 0,a.current.draggedNode.fy=void 0,a.current.draggedNode=null;}a.current.isDragging=false,a.current.mouseStartPos=null,a.current.isPanning&&(a.current.isPanning=false),T();},[s,T,r4,n4,J1,o4,Q1,n1]),Y2=K6.useCallback(o=>{if(o.stopPropagation(),o.preventDefault(),!K.current)return;let C=K.current.getBoundingClientRect(),c=o.clientX-C.left,p=o.clientY-C.top,S=-o.deltaY>0?1.1:1/1.1,h=a.current.transform,w=h.k*S;if(w<.01||w>10)return;let g=h.k*S,b=c-(c-h.x)*S,x=p-(p-h.y)*S;a.current.transform={k:g,x:b,y:x},T();},[T]),X2=r((o,C)=>{let c=o.touches[0];if(c){let p={clientX:c.clientX,clientY:c.clientY};C(p);}},"convertTouchToMouseEvent"),B6=K6.useCallback(o=>{X2(o,W2);},[W2]),_2=K6.useCallback(o=>{a.current.mustBeStoppedPropagation&&(o.preventDefault(),o.stopPropagation()),a.current.mustBeStoppedPropagation=false,X2(o,e2);},[e2]),T6=K6.useCallback(o=>{X2(o,O2);},[O2]);return K6.useImperativeHandle(Y,()=>({zoomToFit:v1,zoomToSelected:X5,zoomToNodes:_5,addNodes:O5,removeNodes:Y5,setSelectedNodes:z1,setNodeSizes:U5,setNodeColors:q5,setLinkWidths:j5,setLinkColors:K5,findShortestPath:J5,arrangeSelectedInGrid:Q5,arrangeNodesByTypeInGrid:e4}),[v1,X5,_5,O5,Y5,z1,U5,q5,j5,K5,J5,Q5,e4]),K6.useEffect(()=>{let o=K.current,{width:C,height:c}=a.current;if(!o)return;E6(),a1(true);let p=C/2,f=c/2,S=o1.nodeSizeBase,w=S*2.5;D.current&&D.current.stop();let g=D.current=d3.forceSimulation(U).force("link",d3.forceLink(s1).id(b=>b.id).distance(w).strength(.9)).force("charge",d3.forceManyBody().strength(-S/10*200).theta(.5).distanceMin(S*2)).force("x",d3.forceX().strength(.03)).force("y",d3.forceY().strength(.03)).force("center",d3.forceCenter(p,f).strength(.05)).force("collide",d3.forceCollide().radius(b=>m1(b)).iterations(2).strength(1)).velocityDecay(.6);return ()=>{g.stop();}},[U,s1]),K6.useLayoutEffect(()=>{let o=K.current;o&&(a.current.width=t*G2,a.current.height=n*G2,o.width=a.current.width,o.height=a.current.height);},[t,n]),K6.useEffect(()=>{if(D.current){let o=D.current;o.on("tick",()=>{T();}),o.on("end",()=>{i1&&(v1(0,20),setTimeout(()=>{a1(false);},200));});}i1||T();},[U,s1,i1,T,v1]),K6.useEffect(()=>{!U||!s1||s1.forEach(o=>{let C=typeof o.source=="object"?o.source:U.find(p=>p.id===o.source),c=typeof o.target=="object"?o.target:U.find(p=>p.id===o.target);!C||!c||(!C.neighbors&&(C.neighbors=[]),!c.neighbors&&(c.neighbors=[]),C.neighbors.push(c),c.neighbors.push(C),!C.links&&(C.links=[]),!c.links&&(c.links=[]),C.links.push(o),c.links.push(o));});},[U,s1]),K6.useEffect(()=>{s&&s.length>0&&R2(ge(s));},[s]),K6.useEffect(()=>{let o=K.current;if(!(!o||typeof window>"u"))return o.addEventListener("wheel",Y2,{passive:false}),o.addEventListener("touchend",_2,{passive:false}),()=>{o.removeEventListener("wheel",Y2),o.removeEventListener("touchend",_2);}},[Y2,_2]),jsxRuntime.jsx(fe,{children:jsxRuntime.jsxs(me,{children:[(e||i1)&&jsxRuntime.jsx(V6,{width:t,height:n}),jsxRuntime.jsx(xe,{ref:K,style:{width:t,height:n,display:e||i1?"none":"block"},onMouseDown:W2,onMouseMove:O2,onMouseUp:e2,onMouseLeave:e2,onClick:Z6,onTouchStart:B6,onTouchMove:T6})]})})}),fe=T1.styled.div`
1223
1223
  display: flex;
1224
1224
  align-items: center;
1225
1225
  justify-content: center;