nano-brain 2026.6.21 → 2026.6.22
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.
|
@@ -486,4 +486,4 @@ void main() {
|
|
|
486
486
|
v_color.a *= bias;
|
|
487
487
|
}
|
|
488
488
|
`,kY=CY,mI=WebGLRenderingContext,bk=mI.UNSIGNED_BYTE,vu=mI.FLOAT,RY=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],DY=(function(t){function e(){return er(this,e),zr(this,e,arguments)}return Ur(e,t),tr(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:kY,FRAGMENT_SHADER_SOURCE:pI,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:RY,ATTRIBUTES:[{name:"a_positionStart",size:2,type:vu},{name:"a_positionEnd",size:2,type:vu},{name:"a_normal",size:2,type:vu},{name:"a_color",size:4,type:bk,normalized:!0},{name:"a_id",size:4,type:bk,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:vu},{name:"a_normalCoef",size:1,type:vu}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(n,i,a,s,l){var c=l.size||1,f=a.x,p=a.y,h=s.x,g=s.y,y=Dl(l.color),S=h-f,w=g-p,b=S*S+w*w,E=0,P=0;b&&(b=1/Math.sqrt(b),E=-w*b*c,P=S*b*c);var T=this.array;T[i++]=f,T[i++]=p,T[i++]=h,T[i++]=g,T[i++]=E,T[i++]=P,T[i++]=y,T[i++]=n}},{key:"setUniforms",value:function(n,i){var a=i.gl,s=i.uniformLocations,l=s.u_matrix,c=s.u_zoomRatio,f=s.u_feather,p=s.u_pixelRatio,h=s.u_correctionRatio,g=s.u_sizeRatio,y=s.u_minEdgeThickness;a.uniformMatrix3fv(l,!1,n.matrix),a.uniform1f(c,n.zoomRatio),a.uniform1f(g,n.sizeRatio),a.uniform1f(h,n.correctionRatio),a.uniform1f(p,n.pixelRatio),a.uniform1f(f,n.antiAliasingFeather),a.uniform1f(y,n.minEdgeThickness)}}])})(ox),sx=(function(t){function e(){var r;return er(this,e),r=zr(this,e),r.rawEmitter=r,r}return Ur(e,t),tr(e)})(Bj.EventEmitter),r0,wk;function yI(){return wk||(wk=1,r0=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),r0}var jY=yI();const IY=tt(jY);var NY=function(e){return e},MY=function(e){return e*e},LY=function(e){return e*(2-e)},$Y=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},FY=function(e){return e*e*e},BY=function(e){return--e*e*e+1},GY=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},zY={linear:NY,quadraticIn:MY,quadraticOut:LY,quadraticInOut:$Y,cubicIn:FY,cubicOut:BY,cubicInOut:GY},UY={easing:"quadraticInOut",duration:150};function Jr(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function lf(t,e,r){return t[0]=e,t[4]=typeof r=="number"?r:e,t}function xk(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[3]=-r,t[4]=n,t}function Sk(t,e,r){return t[6]=e,t[7]=r,t}function Ci(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],f=t[7],p=t[8],h=e[0],g=e[1],y=e[2],S=e[3],w=e[4],b=e[5],E=e[6],P=e[7],T=e[8];return t[0]=h*r+g*a+y*c,t[1]=h*n+g*s+y*f,t[2]=h*i+g*l+y*p,t[3]=S*r+w*a+b*c,t[4]=S*n+w*s+b*f,t[5]=S*i+w*l+b*p,t[6]=E*r+P*a+T*c,t[7]=E*n+P*s+T*f,t[8]=E*i+P*l+T*p,t}function Ub(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=t[0],i=t[1],a=t[3],s=t[4],l=t[6],c=t[7],f=e.x,p=e.y;return{x:f*n+p*a+l*r,y:f*i+p*s+c*r}}function qY(t,e){var r=t.height/t.width,n=e.height/e.width;return r<1&&n>1||r>1&&n<1?1:Math.min(Math.max(n,1/n),Math.max(1/r,r))}function gu(t,e,r,n,i){var a=t.angle,s=t.ratio,l=t.x,c=t.y,f=e.width,p=e.height,h=Jr(),g=Math.min(f,p)-2*n,y=qY(e,r);return i?(Ci(h,Sk(Jr(),l,c)),Ci(h,lf(Jr(),s)),Ci(h,xk(Jr(),a)),Ci(h,lf(Jr(),f/g/2/y,p/g/2/y))):(Ci(h,lf(Jr(),2*(g/f)*y,2*(g/p)*y)),Ci(h,xk(Jr(),-a)),Ci(h,lf(Jr(),1/s)),Ci(h,Sk(Jr(),-l,-c))),h}function WY(t,e,r){var n=Ub(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=n.x,a=n.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(a,2))/r.width}function HY(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,r=-1/0,n=1/0,i=-1/0;return t.forEachNode(function(a,s){var l=s.x,c=s.y;l<e&&(e=l),l>r&&(r=l),c<n&&(n=c),c>i&&(i=c)}),{x:[e,r],y:[n,i]}}function VY(t){if(!IY(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,r){if(!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function KY(t,e,r){var n=document.createElement(t);if(e)for(var i in e)n.style[i]=e[i];if(r)for(var a in r)n.setAttribute(a,r[a]);return n}function _k(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ek(t,e,r){return r.sort(function(n,i){var a=e(n)||0,s=e(i)||0;return a<s?-1:a>s?1:0})}function Ok(t){var e=os(t.x,2),r=e[0],n=e[1],i=os(t.y,2),a=i[0],s=i[1],l=Math.max(n-r,s-a),c=(n+r)/2,f=(s+a)/2;(l===0||Math.abs(l)===1/0||isNaN(l))&&(l=1),isNaN(c)&&(c=0),isNaN(f)&&(f=0);var p=function(g){return{x:.5+(g.x-c)/l,y:.5+(g.y-f)/l}};return p.applyTo=function(h){h.x=.5+(h.x-c)/l,h.y=.5+(h.y-f)/l},p.inverse=function(h){return{x:c+l*(h.x-.5),y:f+l*(h.y-.5)}},p.ratio=l,p}function qb(t){"@babel/helpers - typeof";return qb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qb(t)}function Ak(t,e){var r=e.size;if(r!==0){var n=t.length;t.length+=r;var i=0;e.forEach(function(a){t[n+i]=a,i++})}}function n0(t){t=t||{};for(var e=0,r=arguments.length<=1?0:arguments.length-1;e<r;e++){var n=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];n&&Object.assign(t,n)}return t}var ux={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:lY,defaultDrawNodeLabel:lI,defaultDrawNodeHover:cY,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},XY={circle:Yd},YY={arrow:TY,line:DY};function i0(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,r=t.maxCameraRatio;if(typeof e=="number"&&typeof r=="number"&&r<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function QY(t){var e=n0({},ux,t);return e.nodeProgramClasses=n0({},XY,e.nodeProgramClasses),e.edgeProgramClasses=n0({},YY,e.edgeProgramClasses),e}var cf=1.5,Pk=(function(t){function e(){var r;return er(this,e),r=zr(this,e),se(r,"x",.5),se(r,"y",.5),se(r,"angle",0),se(r,"ratio",1),se(r,"minRatio",null),se(r,"maxRatio",null),se(r,"enabledZooming",!0),se(r,"enabledPanning",!0),se(r,"enabledRotation",!0),se(r,"clean",null),se(r,"nextFrame",null),se(r,"previousState",null),se(r,"enabled",!0),r.previousState=r.getState(),r}return Ur(e,t),tr(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(n){return this.x===n.x&&this.y===n.y&&this.ratio===n.ratio&&this.angle===n.angle}},{key:"getPreviousState",value:function(){var n=this.previousState;return n?{x:n.x,y:n.y,angle:n.angle,ratio:n.ratio}:null}},{key:"getBoundedRatio",value:function(n){var i=n;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(n){var i={};return this.enabledPanning&&typeof n.x=="number"&&(i.x=n.x),this.enabledPanning&&typeof n.y=="number"&&(i.y=n.y),this.enabledZooming&&typeof n.ratio=="number"&&(i.ratio=this.getBoundedRatio(n.ratio)),this.enabledRotation&&typeof n.angle=="number"&&(i.angle=n.angle),this.clean?this.clean(Pe(Pe({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(n){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(n);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(n){return this.setState(n(this.getState())),this}},{key:"animate",value:function(n){var i=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(y){return i.animate(n,a,y)});if(this.enabled){var l=Pe(Pe({},UY),a),c=this.validateState(n),f=typeof l.easing=="function"?l.easing:zY[l.easing],p=Date.now(),h=this.getState(),g=function(){var S=(Date.now()-p)/l.duration;if(S>=1){i.nextFrame=null,i.setState(c),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=f(S),b={};typeof c.x=="number"&&(b.x=h.x+(c.x-h.x)*w),typeof c.y=="number"&&(b.y=h.y+(c.y-h.y)*w),i.enabledRotation&&typeof c.angle=="number"&&(b.angle=h.angle+(c.angle-h.angle)*w),typeof c.ratio=="number"&&(b.ratio=h.ratio+(c.ratio-h.ratio)*w),i.setState(b),i.nextFrame=requestAnimationFrame(g)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(g)):g(),this.animationCallback=s}}},{key:"animatedZoom",value:function(n){return n?typeof n=="number"?this.animate({ratio:this.ratio/n}):this.animate({ratio:this.ratio/(n.factor||cf)},n):this.animate({ratio:this.ratio/cf})}},{key:"animatedUnzoom",value:function(n){return n?typeof n=="number"?this.animate({ratio:this.ratio*n}):this.animate({ratio:this.ratio*(n.factor||cf)},n):this.animate({ratio:this.ratio*cf})}},{key:"animatedReset",value:function(n){return this.animate({x:.5,y:.5,ratio:1,angle:0},n)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(n){var i=new e;return i.setState(n)}}])})(sx);function an(t,e){var r=e.getBoundingClientRect();return{x:t.clientX-r.left,y:t.clientY-r.top}}function Wn(t,e){var r=Pe(Pe({},an(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t});return r}function mu(t){var e="x"in t?t:Pe(Pe({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function ZY(t,e){return Pe(Pe({},Wn(t,e)),{},{delta:bI(t)})}var JY=2;function hf(t){for(var e=[],r=0,n=Math.min(t.length,JY);r<n;r++)e.push(t[r]);return e}function yu(t,e,r){var n={touches:hf(t.touches).map(function(i){return an(i,r)}),previousTouches:e.map(function(i){return an(i,r)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t};return n}function bI(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var wI=(function(t){function e(r,n){var i;return er(this,e),i=zr(this,e),i.container=r,i.renderer=n,i}return Ur(e,t),tr(e)})(sx),eQ=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],tQ=eQ.reduce(function(t,e){return Pe(Pe({},t),{},se({},e,ux[e]))},{}),rQ=(function(t){function e(r,n){var i;return er(this,e),i=zr(this,e,[r,n]),se(i,"enabled",!0),se(i,"draggedEvents",0),se(i,"downStartTime",null),se(i,"lastMouseX",null),se(i,"lastMouseY",null),se(i,"isMouseDown",!1),se(i,"isMoving",!1),se(i,"movingTimeout",null),se(i,"startCameraState",null),se(i,"clicks",0),se(i,"doubleClickTimeout",null),se(i,"currentWheelDirection",0),se(i,"settings",tQ),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),r.addEventListener("click",i.handleClick,{capture:!1}),r.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),r.addEventListener("mousedown",i.handleDown,{capture:!1}),r.addEventListener("wheel",i.handleWheel,{capture:!1}),r.addEventListener("mouseleave",i.handleLeave,{capture:!1}),r.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return Ur(e,t),tr(e,[{key:"kill",value:function(){var n=this.container;n.removeEventListener("click",this.handleClick),n.removeEventListener("contextmenu",this.handleRightClick),n.removeEventListener("mousedown",this.handleDown),n.removeEventListener("wheel",this.handleWheel),n.removeEventListener("mouseleave",this.handleLeave),n.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(n){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(n);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Wn(n,this.container))}}},{key:"handleRightClick",value:function(n){this.enabled&&this.emit("rightClick",Wn(n,this.container))}},{key:"handleDoubleClick",value:function(n){if(this.enabled){n.preventDefault(),n.stopPropagation();var i=Wn(n,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var a=this.renderer.getCamera(),s=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(an(n,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(n){if(this.enabled){if(n.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=an(n,this.container),a=i.x,s=i.y;this.lastMouseX=a,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Wn(n,this.container))}}},{key:"handleUp",value:function(n){var i=this;if(!(!this.enabled||!this.isMouseDown)){var a=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=an(n,this.container),l=s.x,c=s.y,f=a.getState(),p=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:f.x+this.settings.inertiaRatio*(f.x-p.x),y:f.y+this.settings.inertiaRatio*(f.y-p.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==l||this.lastMouseY!==c)&&a.setState({x:f.x,y:f.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Wn(n,this.container))}}},{key:"handleMove",value:function(n){var i=this;if(this.enabled){var a=Wn(n,this.container);if(this.emit("mousemovebody",a),(n.target===this.container||n.composedPath()[0]===this.container)&&this.emit("mousemove",a),!a.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),l=an(n,this.container),c=l.x,f=l.y,p=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:c,y:f}),g=p.x-h.x,y=p.y-h.y,S=s.getState(),w=S.x+g,b=S.y+y;s.setState({x:w,y:b}),this.lastMouseX=c,this.lastMouseY=f,n.preventDefault(),n.stopPropagation()}}}},{key:"handleLeave",value:function(n){this.emit("mouseleave",Wn(n,this.container))}},{key:"handleEnter",value:function(n){this.emit("mouseenter",Wn(n,this.container))}},{key:"handleWheel",value:function(n){var i=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var s=bI(n);if(s){var l=ZY(n,this.container);if(this.emit("wheel",l),l.sigmaDefaultPrevented){n.preventDefault(),n.stopPropagation();return}var c=a.getState().ratio,f=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,p=a.getBoundedRatio(c*f),h=s>0?1:-1,g=Date.now();c!==p&&(n.preventDefault(),n.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&g-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(an(n,this.container),p),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=g))}}}},{key:"setSettings",value:function(n){this.settings=n}}])})(wI),nQ=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],iQ=nQ.reduce(function(t,e){return Pe(Pe({},t),{},se({},e,ux[e]))},{}),aQ=(function(t){function e(r,n){var i;return er(this,e),i=zr(this,e,[r,n]),se(i,"enabled",!0),se(i,"isMoving",!1),se(i,"hasMoved",!1),se(i,"touchMode",0),se(i,"startTouchesPositions",[]),se(i,"lastTouches",[]),se(i,"lastTap",null),se(i,"settings",iQ),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),r.addEventListener("touchstart",i.handleStart,{capture:!1}),r.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return Ur(e,t),tr(e,[{key:"kill",value:function(){var n=this.container;n.removeEventListener("touchstart",this.handleStart),n.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(n){var i=this;if(this.enabled){n.preventDefault();var a=hf(n.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(y){return an(y,i.container)}),this.touchMode===2){var s=os(this.startTouchesPositions,2),l=s[0],c=l.x,f=l.y,p=s[1],h=p.x,g=p.y;this.startTouchesAngle=Math.atan2(g-f,h-c),this.startTouchesDistance=Math.sqrt(Math.pow(h-c,2)+Math.pow(g-f,2))}this.emit("touchdown",yu(n,this.lastTouches,this.container)),this.lastTouches=a,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(n){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(n.cancelable&&n.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(n.touches.length===1){this.handleStart(n),n.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),a=i.getState(),s=i.getPreviousState()||{x:0,y:0};i.animate({x:a.x+this.settings.inertiaRatio*(a.x-s.x),y:a.y+this.settings.inertiaRatio*(a.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",yu(n,this.lastTouches,this.container)),!n.touches.length){var l=an(this.lastTouches[0],this.container),c=this.startTouchesPositions[0],f=Math.pow(l.x-c.x,2)+Math.pow(l.y-c.y,2);if(!n.touches.length&&f<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var p=yu(n,this.lastTouches,this.container);if(this.emit("doubletap",p),this.lastTap=null,!p.sigmaDefaultPrevented){var h=this.renderer.getCamera(),g=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(l,g),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var y=yu(n,this.lastTouches,this.container);this.emit("tap",y),this.lastTap={time:Date.now(),position:y.touches[0]||y.previousTouches[0]}}}this.lastTouches=hf(n.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(n){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){n.preventDefault();var a=hf(n.touches),s=a.map(function(L){return an(L,i.container)}),l=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=s;var c=yu(n,l,this.container);if(this.emit("touchmove",c),!c.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(L,W){var te=i.startTouchesPositions[W];return te&&(L.x!==te.x||L.y!==te.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var f=this.renderer.getCamera(),p=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var g=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),y=g.x,S=g.y,w=this.renderer.viewportToFramedGraph(s[0]),b=w.x,E=w.y;f.setState({x:p.x+y-b,y:p.y+S-E});break}case 2:{var P={x:.5,y:.5,angle:0,ratio:1},T=s[0],O=T.x,_=T.y,A=s[1],C=A.x,D=A.y,j=Math.atan2(D-_,C-O)-this.startTouchesAngle,G=Math.hypot(D-_,C-O)/this.startTouchesDistance,z=f.getBoundedRatio(p.ratio/G);P.ratio=z,P.angle=p.angle+j;var $=this.getDimensions(),R=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:p}),X=Math.min($.width,$.height)-2*h,K=X/$.width,B=X/$.height,I=z/X,V=O-X/2/K,J=_-X/2/B,ee=[V*Math.cos(-P.angle)-J*Math.sin(-P.angle),J*Math.cos(-P.angle)+V*Math.sin(-P.angle)];V=ee[0],J=ee[1],P.x=R.x-V*I,P.y=R.y+J*I,f.setState(P);break}}}}}},{key:"setSettings",value:function(n){this.settings=n}}])})(wI);function oQ(t){if(Array.isArray(t))return Gb(t)}function sQ(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function uQ(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
489
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tk(t){return oQ(t)||sQ(t)||rI(t)||uQ()}function lQ(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.indexOf(n)!==-1)continue;r[n]=t[n]}return r}function a0(t,e){if(t==null)return{};var r,n,i=lQ(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(n=0;n<a.length;n++)r=a[n],e.indexOf(r)===-1&&{}.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}var Ck=(function(){function t(e,r){er(this,t),this.key=e,this.size=r}return tr(t,null,[{key:"compare",value:function(r,n){return r.size>n.size?-1:r.size<n.size||r.key>n.key?1:-1}}])})(),kk=(function(){function t(){er(this,t),se(this,"width",0),se(this,"height",0),se(this,"cellSize",0),se(this,"columns",0),se(this,"rows",0),se(this,"cells",{})}return tr(t,[{key:"resizeAndClear",value:function(r,n){this.width=r.width,this.height=r.height,this.cellSize=n,this.columns=Math.ceil(r.width/n),this.rows=Math.ceil(r.height/n),this.cells={}}},{key:"getIndex",value:function(r){var n=Math.floor(r.x/this.cellSize),i=Math.floor(r.y/this.cellSize);return i*this.columns+n}},{key:"add",value:function(r,n,i){var a=new Ck(r,n),s=this.getIndex(i),l=this.cells[s];l||(l=[],this.cells[s]=l),l.push(a)}},{key:"organize",value:function(){for(var r in this.cells){var n=this.cells[r];n.sort(Ck.compare)}}},{key:"getLabelsToDisplay",value:function(r,n){var i=this.cellSize*this.cellSize,a=i/r/r,s=a*n/i,l=Math.ceil(s),c=[];for(var f in this.cells)for(var p=this.cells[f],h=0;h<Math.min(l,p.length);h++)c.push(p[h].key);return c}}])})();function cQ(t){var e=t.graph,r=t.hoveredNode,n=t.highlightedNodes,i=t.displayedNodeLabels,a=[];return e.forEachEdge(function(s,l,c,f){(c===r||f===r||n.has(c)||n.has(f)||i.has(c)&&i.has(f))&&a.push(s)}),a}var Rk=150,Dk=50,Kn=Object.prototype.hasOwnProperty;function fQ(t,e,r){if(!Kn.call(r,"x")||!Kn.call(r,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return r.color||(r.color=t.defaultNodeColor),!r.label&&r.label!==""&&(r.label=null),r.label!==void 0&&r.label!==null?r.label=""+r.label:r.label=null,r.size||(r.size=2),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"highlighted")||(r.highlighted=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultNodeType),r.zIndex||(r.zIndex=0),r}function dQ(t,e,r){return r.color||(r.color=t.defaultEdgeColor),r.label||(r.label=""),r.size||(r.size=.5),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultEdgeType),r.zIndex||(r.zIndex=0),r}var hQ=(function(t){function e(r,n){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(er(this,e),i=zr(this,e),se(i,"elements",{}),se(i,"canvasContexts",{}),se(i,"webGLContexts",{}),se(i,"pickingLayers",new Set),se(i,"textures",{}),se(i,"frameBuffers",{}),se(i,"activeListeners",{}),se(i,"labelGrid",new kk),se(i,"nodeDataCache",{}),se(i,"edgeDataCache",{}),se(i,"nodeProgramIndex",{}),se(i,"edgeProgramIndex",{}),se(i,"nodesWithForcedLabels",new Set),se(i,"edgesWithForcedLabels",new Set),se(i,"nodeExtent",{x:[0,1],y:[0,1]}),se(i,"nodeZExtent",[1/0,-1/0]),se(i,"edgeZExtent",[1/0,-1/0]),se(i,"matrix",Jr()),se(i,"invMatrix",Jr()),se(i,"correctionRatio",1),se(i,"customBBox",null),se(i,"normalizationFunction",Ok({x:[0,1],y:[0,1]})),se(i,"graphToViewportRatio",1),se(i,"itemIDsIndex",{}),se(i,"nodeIndices",{}),se(i,"edgeIndices",{}),se(i,"width",0),se(i,"height",0),se(i,"pixelRatio",_k()),se(i,"pickingDownSizingRatio",2*i.pixelRatio),se(i,"displayedNodeLabels",new Set),se(i,"displayedEdgeLabels",new Set),se(i,"highlightedNodes",new Set),se(i,"hoveredNode",null),se(i,"hoveredEdge",null),se(i,"renderFrame",null),se(i,"renderHighlightedNodesFrame",null),se(i,"needToProcess",!1),se(i,"checkEdgesEventsFrame",null),se(i,"nodePrograms",{}),se(i,"nodeHoverPrograms",{}),se(i,"edgePrograms",{}),i.settings=QY(a),i0(i.settings),VY(r),!(n instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=r,i.container=n,i.createWebGLContext("edges",{picking:a.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var l in i.settings.edgeProgramClasses)i.registerEdgeProgram(l,i.settings.edgeProgramClasses[l]);return i.camera=new Pk,i.bindCameraHandlers(),i.mouseCaptor=new rQ(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new aQ(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ur(e,t),tr(e,[{key:"registerNodeProgram",value:function(n,i,a){return this.nodePrograms[n]&&this.nodePrograms[n].kill(),this.nodeHoverPrograms[n]&&this.nodeHoverPrograms[n].kill(),this.nodePrograms[n]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[n]=new(a||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(n,i){return this.edgePrograms[n]&&this.edgePrograms[n].kill(),this.edgePrograms[n]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(n){if(this.nodePrograms[n]){var i=this.nodePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[n]){var l=this.nodeHoverPrograms,c=l[n],f=a0(l,[n].map(Tu));c.kill(),this.nodePrograms=f}return this}},{key:"unregisterEdgeProgram",value:function(n){if(this.edgePrograms[n]){var i=this.edgePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(n){var i=this.webGLContexts[n],a=this.frameBuffers[n],s=this.textures[n];s&&i.deleteTexture(s);var l=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,l,0),this.textures[n]=l,this}},{key:"bindCameraHandlers",value:function(){var n=this;return this.activeListeners.camera=function(){n.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(n){var i=n.x,a=n.y,s=dk(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),l=fk.apply(void 0,Tk(s)),c=this.itemIDsIndex[l];return c&&c.type==="node"?c.id:null}},{key:"bindEventHandlers",value:function(){var n=this;this.activeListeners.handleResize=function(){n.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},c=n.getNodeAtPosition(s);if(c&&n.hoveredNode!==c&&!n.nodeDataCache[c].hidden){n.hoveredNode&&n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.hoveredNode=c,n.emit("enterNode",Pe(Pe({},l),{},{node:c})),n.scheduleHighlightedNodesRender();return}if(n.hoveredNode&&n.getNodeAtPosition(s)!==n.hoveredNode){var f=n.hoveredNode;n.hoveredNode=null,n.emit("leaveNode",Pe(Pe({},l),{},{node:f})),n.scheduleHighlightedNodesRender();return}if(n.settings.enableEdgeEvents){var p=n.hoveredNode?null:n.getEdgeAtPoint(l.event.x,l.event.y);p!==n.hoveredEdge&&(n.hoveredEdge&&n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),p&&n.emit("enterEdge",Pe(Pe({},l),{},{edge:p})),n.hoveredEdge=p)}},this.activeListeners.handleMoveBody=function(a){var s=mu(a);n.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.hoveredNode&&(n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.scheduleHighlightedNodesRender()),n.settings.enableEdgeEvents&&n.hoveredEdge&&(n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),n.scheduleHighlightedNodesRender()),n.emit("leaveStage",Pe({},l))},this.activeListeners.handleEnter=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.emit("enterStage",Pe({},l))};var i=function(s){return function(l){var c=mu(l),f={event:c,preventSigmaDefault:function(){c.preventSigmaDefault()}},p=n.getNodeAtPosition(c);if(p)return n.emit("".concat(s,"Node"),Pe(Pe({},f),{},{node:p}));if(n.settings.enableEdgeEvents){var h=n.getEdgeAtPoint(c.x,c.y);if(h)return n.emit("".concat(s,"Edge"),Pe(Pe({},f),{},{edge:h}))}return n.emit("".concat(s,"Stage"),f)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var n=this,i=this.graph,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachNode(function(p){return n.updateNode(p)});var f=!c||c.some(function(p){return a.has(p)});n.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!f,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachEdge(function(p){return n.updateEdge(p)});var f=c&&["zIndex","type"].some(function(p){return c==null?void 0:c.includes(p)});n.refresh({partialGraph:{edges:i.edges()},skipIndexation:!f,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var l=s.key;n.addNode(l),n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var l=s.key;n.removeNode(l),n.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var l=s.key;n.addEdge(l),n.refresh({partialGraph:{edges:[l]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{edges:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var l=s.key;n.removeEdge(l),n.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){n.clearEdgeState(),n.clearEdgeIndices(),n.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){n.clearEdgeState(),n.clearNodeState(),n.clearEdgeIndices(),n.clearNodeIndices(),n.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var n=this.graph;n.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(n,i){var a=dk(this.webGLContexts.edges,this.frameBuffers.edges,n,i,this.pixelRatio,this.pickingDownSizingRatio),s=fk.apply(void 0,Tk(a)),l=this.itemIDsIndex[s];return l&&l.type==="edge"?l.id:null}},{key:"process",value:function(){var n=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,s=this.getDimensions();if(this.nodeExtent=HY(this.graph),!this.settings.autoRescale){var l=s.width,c=s.height,f=this.nodeExtent,p=f.x,h=f.y;this.nodeExtent={x:[(p[0]+p[1])/2-l/2,(p[0]+p[1])/2+l/2],y:[(h[0]+h[1])/2-c/2,(h[0]+h[1])/2+c/2]}}this.normalizationFunction=Ok(this.customBBox||this.nodeExtent);var g=new Pk,y=gu(g.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,a.labelGridCellSize);for(var S={},w={},b={},E={},P=1,T=i.nodes(),O=0,_=T.length;O<_;O++){var A=T[O],C=this.nodeDataCache[A],D=i.getNodeAttributes(A);C.x=D.x,C.y=D.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(A,C.size,this.framedGraphToViewport(C,{matrix:y})),S[C.type]=(S[C.type]||0)+1}this.labelGrid.organize();for(var j in this.nodePrograms){if(!Kn.call(this.nodePrograms,j))throw new Error('Sigma: could not find a suitable program for node type "'.concat(j,'"!'));this.nodePrograms[j].reallocate(S[j]||0),S[j]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(T=Ek(this.nodeZExtent,function(xe){return n.nodeDataCache[xe].zIndex},T));for(var G=0,z=T.length;G<z;G++){var $=T[G];w[$]=P,E[w[$]]={type:"node",id:$},P++;var R=this.nodeDataCache[$];this.addNodeToProgram($,w[$],S[R.type]++)}for(var X={},K=i.edges(),B=0,I=K.length;B<I;B++){var V=K[B],J=this.edgeDataCache[V];X[J.type]=(X[J.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(K=Ek(this.edgeZExtent,function(xe){return n.edgeDataCache[xe].zIndex},K));for(var ee in this.edgePrograms){if(!Kn.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(X[ee]||0),X[ee]=0}for(var L=0,W=K.length;L<W;L++){var te=K[L];b[te]=P,E[b[te]]={type:"edge",id:te},P++;var we=this.edgeDataCache[te];this.addEdgeToProgram(te,b[te],X[we.type]++)}return this.itemIDsIndex=E,this.nodeIndices=w,this.edgeIndices=b,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(n){var i=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(p){return i.cleanCameraState(p,a.cameraPanBoundaries&&qb(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),n){if(n.edgeProgramClasses!==a.edgeProgramClasses){for(var s in a.edgeProgramClasses)a.edgeProgramClasses[s]!==n.edgeProgramClasses[s]&&this.registerEdgeProgram(s,a.edgeProgramClasses[s]);for(var l in n.edgeProgramClasses)a.edgeProgramClasses[l]||this.unregisterEdgeProgram(l)}if(n.nodeProgramClasses!==a.nodeProgramClasses||n.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var c in a.nodeProgramClasses)(a.nodeProgramClasses[c]!==n.nodeProgramClasses[c]||a.nodeHoverProgramClasses[c]!==n.nodeHoverProgramClasses[c])&&this.registerNodeProgram(c,a.nodeProgramClasses[c],a.nodeHoverProgramClasses[c]);for(var f in n.nodeProgramClasses)a.nodeProgramClasses[f]||this.unregisterNodeProgram(f)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.tolerance,s=a===void 0?0:a,l=i.boundaries,c=Pe({},n),f=l||this.nodeExtent,p=os(f.x,2),h=p[0],g=p[1],y=os(f.y,2),S=y[0],w=y[1],b=[this.graphToViewport({x:h,y:S},{cameraState:n}),this.graphToViewport({x:g,y:S},{cameraState:n}),this.graphToViewport({x:h,y:w},{cameraState:n}),this.graphToViewport({x:g,y:w},{cameraState:n})],E=1/0,P=-1/0,T=1/0,O=-1/0;b.forEach(function(X){var K=X.x,B=X.y;E=Math.min(E,K),P=Math.max(P,K),T=Math.min(T,B),O=Math.max(O,B)});var _=P-E,A=O-T,C=this.getDimensions(),D=C.width,j=C.height,G=0,z=0;if(_>=D?P<D-s?G=P-(D-s):E>s&&(G=E-s):P>D+s?G=P-(D+s):E<-s&&(G=E+s),A>=j?O<j-s?z=O-(j-s):T>s&&(z=T-s):O>j+s?z=O-(j+s):T<-s&&(z=T+s),G||z){var $=this.viewportToFramedGraph({x:0,y:0},{cameraState:n}),R=this.viewportToFramedGraph({x:G,y:z},{cameraState:n});G=R.x-$.x,z=R.y-$.y,c.x+=G,c.y+=z}return c}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var n=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(n.ratio,this.settings.labelDensity);Ak(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,s=0,l=i.length;s<l;s++){var c=i[s],f=this.nodeDataCache[c];if(!this.displayedNodeLabels.has(c)&&!f.hidden){var p=this.framedGraphToViewport(f),h=p.x,g=p.y,y=this.scaleSize(f.size);if(!(!f.forceLabel&&y<this.settings.labelRenderedSizeThreshold)&&!(h<-Rk||h>this.width+Rk||g<-Dk||g>this.height+Dk)){this.displayedNodeLabels.add(c);var S=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[f.type],b=(w==null?void 0:w.drawLabel)||S;b(a,Pe(Pe({key:c},f),{},{size:y,x:h,y:g}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var n=this.canvasContexts.edgeLabels;n.clearRect(0,0,this.width,this.height);var i=cQ({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Ak(i,this.edgesWithForcedLabels);for(var a=new Set,s=0,l=i.length;s<l;s++){var c=i[s],f=this.graph.extremities(c),p=this.nodeDataCache[f[0]],h=this.nodeDataCache[f[1]],g=this.edgeDataCache[c];if(!a.has(c)&&!(g.hidden||p.hidden||h.hidden)){var y=this.settings.defaultDrawEdgeLabel,S=this.edgePrograms[g.type],w=(S==null?void 0:S.drawLabel)||y;w(n,Pe(Pe({key:c},g),{},{size:this.scaleSize(g.size)}),Pe(Pe(Pe({key:f[0]},p),this.framedGraphToViewport(p)),{},{size:this.scaleSize(p.size)}),Pe(Pe(Pe({key:f[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),a.add(c)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var n=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(y){var S=n.nodeDataCache[y],w=n.framedGraphToViewport(S),b=w.x,E=w.y,P=n.scaleSize(S.size),T=n.settings.defaultDrawNodeHover,O=n.nodePrograms[S.type],_=(O==null?void 0:O.drawHover)||T;_(i,Pe(Pe({key:y},S),{},{size:P,x:b,y:E}),n.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(g){g!==n.hoveredNode&&s.push(g)}),s.forEach(function(g){return a(g)});var l={};s.forEach(function(g){var y=n.nodeDataCache[g].type;l[y]=(l[y]||0)+1});for(var c in this.nodeHoverPrograms)this.nodeHoverPrograms[c].reallocate(l[c]||0),l[c]=0;s.forEach(function(g){var y=n.nodeDataCache[g];n.nodeHoverPrograms[y.type].process(0,l[y.type]++,y)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var f=this.getRenderParams();for(var p in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[p];h.render(f)}}},{key:"scheduleHighlightedNodesRender",value:function(){var n=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){n.renderHighlightedNodesFrame=null,n.renderHighlightedNodes(),n.renderEdgeLabels()}))}},{key:"render",value:function(){var n=this;this.emit("beforeRender");var i=function(){return n.emit("afterRender"),n};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(b){return n.resetWebGLTexture(b)}),!this.graph.order)return i();var a=this.mouseCaptor,s=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,l=this.camera.getState(),c=this.getDimensions(),f=this.getGraphDimensions(),p=this.getStagePadding();this.matrix=gu(l,c,f,p),this.invMatrix=gu(l,c,f,p,!0),this.correctionRatio=WY(this.matrix,l,c),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var g in this.nodePrograms){var y=this.nodePrograms[g];y.render(h)}if(!this.settings.hideEdgesOnMove||!s)for(var S in this.edgePrograms){var w=this.edgePrograms[S];w.render(h)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(n){var i=Object.assign({},this.graph.getNodeAttributes(n));this.settings.nodeReducer&&(i=this.settings.nodeReducer(n,i));var a=fQ(this.settings,n,i);this.nodeDataCache[n]=a,this.nodesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(n),this.highlightedNodes.delete(n),a.highlighted&&!a.hidden&&this.highlightedNodes.add(n),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.zIndex))}},{key:"updateNode",value:function(n){this.addNode(n);var i=this.nodeDataCache[n];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(n){delete this.nodeDataCache[n],delete this.nodeProgramIndex[n],this.highlightedNodes.delete(n),this.hoveredNode===n&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(n)}},{key:"addEdge",value:function(n){var i=Object.assign({},this.graph.getEdgeAttributes(n));this.settings.edgeReducer&&(i=this.settings.edgeReducer(n,i));var a=dQ(this.settings,n,i);this.edgeDataCache[n]=a,this.edgesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(n),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.zIndex))}},{key:"updateEdge",value:function(n){this.addEdge(n)}},{key:"removeEdge",value:function(n){delete this.edgeDataCache[n],delete this.edgeProgramIndex[n],this.hoveredEdge===n&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(n)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new kk,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(n,i,a){var s=this.nodeDataCache[n],l=this.nodePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));l.process(i,a,s),this.nodeProgramIndex[n]=a}},{key:"addEdgeToProgram",value:function(n,i,a){var s=this.edgeDataCache[n],l=this.edgePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var c=this.graph.extremities(n),f=this.nodeDataCache[c[0]],p=this.nodeDataCache[c[1]];l.process(i,a,f,p,s),this.edgeProgramIndex[n]=a}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var n=this.settings,i=n.stagePadding,a=n.autoRescale;return a&&i||0}},{key:"createLayer",value:function(n,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[n])throw new Error('Sigma: a layer named "'.concat(n,'" already exists'));var s=KY(i,{position:"absolute"},{class:"sigma-".concat(n)});return a.style&&Object.assign(s.style,a.style),this.elements[n]=s,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(s):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(n,"canvas",i)}},{key:"createCanvasContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(n,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[n]=a.getContext("2d",s),this}},{key:"createWebGLContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(i==null?void 0:i.canvas)||this.createCanvas(n,i);i.hidden&&a.remove();var s=Pe({preserveDrawingBuffer:!1,antialias:!1},i),l;l=a.getContext("webgl2",s),l||(l=a.getContext("webgl",s)),l||(l=a.getContext("experimental-webgl",s));var c=l;if(this.webGLContexts[n]=c,c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(n);var f=c.createFramebuffer();if(!f)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(n));this.frameBuffers[n]=f}return c}},{key:"killLayer",value:function(n){var i=this.elements[n];if(!i)throw new Error("Sigma: cannot kill layer ".concat(n,", which does not exist"));if(this.webGLContexts[n]){var a,s=this.webGLContexts[n];(a=s.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[n]}else this.canvasContexts[n]&&delete this.canvasContexts[n];return i.remove(),delete this.elements[n],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(n){this.unbindCameraHandlers(),this.camera=n,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(n){n!==this.graph&&(this.hoveredNode&&!n.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!n.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=n,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var n=this.customBBox||this.nodeExtent;return{width:n.x[1]-n.x[0]||1,height:n.y[1]-n.y[0]||1}}},{key:"getNodeDisplayData",value:function(n){var i=this.nodeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(n){var i=this.edgeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return Pe({},this.settings)}},{key:"getSetting",value:function(n){return this.settings[n]}},{key:"setSetting",value:function(n,i){var a=Pe({},this.settings);return this.settings[n]=i,i0(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(n,i){return this.setSetting(n,i(this.settings[n])),this}},{key:"setSettings",value:function(n){var i=Pe({},this.settings);return this.settings=Pe(Pe({},this.settings),n),i0(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(n){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=_k(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!n&&i===this.width&&a===this.height)return this;for(var s in this.elements){var l=this.elements[s];l.style.width=this.width+"px",l.style.height=this.height+"px"}for(var c in this.canvasContexts)this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[c].scale(this.pixelRatio,this.pixelRatio);for(var f in this.webGLContexts){this.elements[f].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[f].setAttribute("height",this.height*this.pixelRatio+"px");var p=this.webGLContexts[f];if(p.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(f)){var h=this.textures[f];h&&p.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(n){var i=this,a=(n==null?void 0:n.skipIndexation)!==void 0?n==null?void 0:n.skipIndexation:!1,s=(n==null?void 0:n.schedule)!==void 0?n.schedule:!1,l=!n||!n.partialGraph;if(l)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(O){return i.addNode(O)}),this.graph.forEachEdge(function(O){return i.addEdge(O)});else{for(var c,f,p=((c=n.partialGraph)===null||c===void 0?void 0:c.nodes)||[],h=0,g=(p==null?void 0:p.length)||0;h<g;h++){var y=p[h];if(this.updateNode(y),a){var S=this.nodeProgramIndex[y];if(S===void 0)throw new Error('Sigma: node "'.concat(y,`" can't be repaint`));this.addNodeToProgram(y,this.nodeIndices[y],S)}}for(var w=(n==null||(f=n.partialGraph)===null||f===void 0?void 0:f.edges)||[],b=0,E=w.length;b<E;b++){var P=w[b];if(this.updateEdge(P),a){var T=this.edgeProgramIndex[P];if(T===void 0)throw new Error('Sigma: edge "'.concat(P,`" can't be repaint`));this.addEdgeToProgram(P,this.edgeIndices[P],T)}}}return(l||!a)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var n=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){n.render()})),this}},{key:"scheduleRefresh",value:function(n){return this.refresh(Pe(Pe({},n),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(n,i){var a=this.camera.getState(),s=a.ratio,l=a.angle,c=a.x,f=a.y,p=this.settings,h=p.minCameraRatio,g=p.maxCameraRatio;typeof g=="number"&&(i=Math.min(i,g)),typeof h=="number"&&(i=Math.max(i,h));var y=i/s,S={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(n),b=this.viewportToFramedGraph(S);return{angle:l,x:(w.x-b.x)*(1-y)+c,y:(w.y-b.y)*(1-y)+f,ratio:i}}},{key:"viewRectangle",value:function(){var n=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:n.x,y1:n.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,l=Ub(s,n);return{x:(1+l.x)*this.width/2,y:(1-l.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,l=Ub(s,{x:n.x/this.width*2-1,y:1-n.y/this.height*2});return isNaN(l.x)&&(l.x=0),isNaN(l.y)&&(l.y=0),l}},{key:"viewportToGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(n,i))}},{key:"graphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(n),i)}},{key:"getGraphToViewportRatio",value:function(){var n={x:0,y:0},i={x:1,y:1},a=Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2)),s=this.graphToViewport(n),l=this.graphToViewport(i),c=Math.sqrt(Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2));return c/a}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(n){return this.customBBox=n,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var n=this.container;n.firstChild;)n.removeChild(n.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var l in this.elements)this.killLayer(l);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return n/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var n={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(n[i]=this.elements[i]);return n}}])})(sx);const xI=N.createContext(null),pQ=xI.Provider;function SI(){const t=N.useContext(xI);if(t==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return t}function lx(){return SI().sigma}function vQ(){const{sigma:t}=SI();return N.useCallback((e=>{t&&Object.keys(e).forEach((r=>{t.setSetting(r,e[r])}))}),[t])}function Qd(t){return new Set(Object.keys(t))}const jk=Qd({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Ik=Qd({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Nk=Qd({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Mk=Qd({updated:!0});function gQ(){const t=lx(),e=vQ(),[r,n]=N.useState({});return N.useEffect((()=>{if(!t||!r)return;const i=r,a=Object.keys(i);return a.forEach((s=>{const l=i[s];jk.has(s)&&t.on(s,l),Ik.has(s)&&t.getMouseCaptor().on(s,l),Nk.has(s)&&t.getTouchCaptor().on(s,l),Mk.has(s)&&t.getCamera().on(s,l)})),()=>{t&&a.forEach((s=>{const l=i[s];jk.has(s)&&t.off(s,l),Ik.has(s)&&t.getMouseCaptor().off(s,l),Nk.has(s)&&t.getTouchCaptor().off(s,l),Mk.has(s)&&t.getCamera().off(s,l)}))}}),[t,r,e]),n}function mQ(){const t=lx();return N.useCallback(((e,r=!0)=>{t&&e&&(r&&t.getGraph().order>0&&t.getGraph().clear(),t.getGraph().import(e),t.refresh())}),[t])}function _I(t,e){if(t===e)return!0;if(typeof t=="object"&&t!=null&&typeof e=="object"&&e!=null){if(Object.keys(t).length!=Object.keys(e).length)return!1;for(const r in t)if(!Object.hasOwn(e,r)||!_I(t[r],e[r]))return!1;return!0}return!1}const yQ=N.forwardRef((({graph:t,id:e,className:r,style:n,settings:i={},children:a},s)=>{const l=N.useRef(null),c=N.useRef(null),f={className:`react-sigma ${r||""}`,id:e,style:n},[p,h]=N.useState(null),[g,y]=N.useState(i);N.useEffect((()=>{y((b=>_I(b,i)?b:i))}),[i]),N.useEffect((()=>{let b=null;if(c.current!==null){let E=new Ze;t&&(E=typeof t=="function"?new t:t),b=new hQ(E,c.current,g),h((P=>{let T=null;return P&&(T=P.getCamera().getState()),T&&b.getCamera().setState(T),b}))}return()=>{b&&b.kill()}}),[c,t,g]),N.useImperativeHandle(s,(()=>p),[p]);const S=N.useMemo((()=>p&&l.current?{sigma:p,container:l.current}:null),[p,l]),w=S!==null?Q.createElement(pQ,{value:S},a):null;return Q.createElement("div",Object.assign({},f,{ref:l}),Q.createElement("div",{className:"sigma-container",ref:c}),w)}));var bu={},Lk;function bQ(){if(Lk)return bu;Lk=1;function t(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getNodeAttributes(p))},a.fromEntry=function(f,p){return l(p)}):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){return s(n(p,f.getNodeAttributes(p)))},a.fromEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c),a}function r(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getEdgeAttributes(p))},a.fromEntry=function(f,p){return l(p)},a.fromPartialEntry=a.fromEntry,a.fromMinimalEntry=a.fromEntry):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){var h=f.extremities(p);return s(n(p,f.getEdgeAttributes(p),h[0],h[1],f.getNodeAttributes(h[0]),f.getNodeAttributes(h[1]),f.isUndirected(p)))},a.fromEntry=function(f,p,h,g,y,S,w){return s(n(f,p,h,g,y,S,w))},a.fromPartialEntry=function(f,p,h,g){return s(n(f,p,h,g))},a.fromMinimalEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c,a.fromMinimalEntry=c),a}return bu.createNodeValueGetter=e,bu.createEdgeValueGetter=r,bu.createEdgeWeightGetter=function(n){return r(n,t)},bu}var o0,$k;function wQ(){if($k)return o0;$k=1;var t=0,e=1,r=2,n=3,i=4,a=5,s=6,l=7,c=8,f=9,p=0,h=1,g=2,y=0,S=1,w=2,b=3,E=4,P=5,T=6,O=7,_=8,A=3,C=10,D=3,j=9,G=10;return o0=function($,R,X){var K,B,I,V,J,ee,L,W,te,we,xe=R.length,Ie=X.length,Le=$.adjustSizes,Me=$.barnesHutTheta*$.barnesHutTheta,le,pe,ve,ie,Fe,de,ge,ne=[];for(I=0;I<xe;I+=C)R[I+i]=R[I+r],R[I+a]=R[I+n],R[I+r]=0,R[I+n]=0;if($.outboundAttractionDistribution){for(le=0,I=0;I<xe;I+=C)le+=R[I+s];le/=xe/C}if($.barnesHutOptimize){var it=1/0,kt=-1/0,Rt=1/0,Bt=-1/0,rt,Dt,cn;for(I=0;I<xe;I+=C)it=Math.min(it,R[I+t]),kt=Math.max(kt,R[I+t]),Rt=Math.min(Rt,R[I+e]),Bt=Math.max(Bt,R[I+e]);var fn=kt-it,dn=Bt-Rt;for(fn>dn?(Rt-=(fn-dn)/2,Bt=Rt+fn):(it-=(dn-fn)/2,kt=it+dn),ne[0+y]=-1,ne[0+S]=(it+kt)/2,ne[0+w]=(Rt+Bt)/2,ne[0+b]=Math.max(kt-it,Bt-Rt),ne[0+E]=-1,ne[0+P]=-1,ne[0+T]=0,ne[0+O]=0,ne[0+_]=0,K=1,I=0;I<xe;I+=C)for(B=0,cn=A;;)if(ne[B+P]>=0){R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[I+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+O]=(ne[B+O]*ne[B+T]+R[I+t]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+_]=(ne[B+_]*ne[B+T]+R[I+e]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+T]+=R[I+s],B=rt;continue}else if(ne[B+y]<0){ne[B+y]=I;break}else{if(ne[B+P]=K*j,W=ne[B+b]/2,te=ne[B+P],ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=ne[B+E],ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,K+=4,R[ne[B+y]+t]<ne[B+S]?R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+T]=R[ne[B+y]+s],ne[B+O]=R[ne[B+y]+t],ne[B+_]=R[ne[B+y]+e],ne[rt+y]=ne[B+y],ne[B+y]=-1,R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?Dt=ne[B+P]:Dt=ne[B+P]+j:R[I+e]<ne[B+w]?Dt=ne[B+P]+j*2:Dt=ne[B+P]+j*3,rt===Dt)if(cn--){B=rt;continue}else{cn=A;break}ne[Dt+y]=I;break}}if($.barnesHutOptimize)for(pe=$.scalingRatio,I=0;I<xe;I+=C)for(B=0;;)if(ne[B+P]>=0)if(de=Math.pow(R[I+t]-ne[B+O],2)+Math.pow(R[I+e]-ne[B+_],2),we=ne[B+b],4*we*we/de<Me){if(ve=R[I+t]-ne[B+O],ie=R[I+e]-ne[B+_],Le===!0?de>0?(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*ne[B+T]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge),B=ne[B+E],B<0)break;continue}else{B=ne[B+P];continue}else{if(ee=ne[B+y],ee>=0&&ee!==I&&(ve=R[I+t]-R[ee+t],ie=R[I+e]-R[ee+e],de=ve*ve+ie*ie,Le===!0?de>0?(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*R[ee+s]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge)),B=ne[B+E],B<0)break;continue}else for(pe=$.scalingRatio,V=0;V<xe;V+=C)for(J=0;J<V;J+=C)ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],de>0?(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge):de<0&&(ge=100*pe*R[V+s]*R[J+s],R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge)):(de=Math.sqrt(ve*ve+ie*ie),de>0&&(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge));for(te=$.gravity/$.scalingRatio,pe=$.scalingRatio,I=0;I<xe;I+=C)ge=0,ve=R[I+t],ie=R[I+e],de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.strongGravityMode?de>0&&(ge=pe*R[I+s]*te):de>0&&(ge=pe*R[I+s]*te/de),R[I+r]-=ve*ge,R[I+n]-=ie*ge;for(pe=1*($.outboundAttractionDistribution?le:1),L=0;L<Ie;L+=D)V=X[L+p],J=X[L+h],W=X[L+g],Fe=Math.pow(W,$.edgeWeightInfluence),ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe/R[V+s]):de>0&&(ge=-pe*Fe)):(de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?(de=1,ge=-pe*Fe/R[V+s]):(de=1,ge=-pe*Fe)),de>0&&(R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge);var Xi,Dn,jn,hn,pn,vn;if(Le===!0)for(I=0;I<xe;I+=C)R[I+f]!==1&&(Xi=Math.sqrt(Math.pow(R[I+r],2)+Math.pow(R[I+n],2)),Xi>G&&(R[I+r]=R[I+r]*G/Xi,R[I+n]=R[I+n]*G/Xi),Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=.1*Math.log(1+jn)/(1+Math.sqrt(Dn)),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);else for(I=0;I<xe;I+=C)R[I+f]!==1&&(Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=R[I+l]*Math.log(1+jn)/(1+Math.sqrt(Dn)),R[I+l]=Math.min(1,Math.sqrt(hn*(Math.pow(R[I+r],2)+Math.pow(R[I+n],2))/(1+Math.sqrt(Dn)))),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);return{}},o0}var Un={},Fk;function xQ(){if(Fk)return Un;Fk=1;var t=10,e=3;return Un.assign=function(r){r=r||{};var n=Array.prototype.slice.call(arguments).slice(1),i,a,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(a in n[i])r[a]=n[i][a];return r},Un.validateSettings=function(r){return"linLogMode"in r&&typeof r.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in r&&typeof r.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in r&&typeof r.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in r&&typeof r.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in r&&!(typeof r.scalingRatio=="number"&&r.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Un.graphToByteArrays=function(r,n){var i=r.order,a=r.size,s={},l,c=new Float32Array(i*t),f=new Float32Array(a*e);return l=0,r.forEachNode(function(p,h){s[p]=l,c[l]=h.x,c[l+1]=h.y,c[l+2]=0,c[l+3]=0,c[l+4]=0,c[l+5]=0,c[l+6]=1,c[l+7]=1,c[l+8]=h.size||1,c[l+9]=h.fixed?1:0,l+=t}),l=0,r.forEachEdge(function(p,h,g,y,S,w,b){var E=s[g],P=s[y],T=n(p,h,g,y,S,w,b);c[E+6]+=T,c[P+6]+=T,f[l]=E,f[l+1]=P,f[l+2]=T,l+=e}),{nodes:c,edges:f}},Un.assignLayoutChanges=function(r,n,i){var a=0;r.updateEachNodeAttributes(function(s,l){return l.x=n[a],l.y=n[a+1],a+=t,i?i(s,l):l})},Un.readGraphPositions=function(r,n){var i=0;r.forEachNode(function(a,s){n[i]=s.x,n[i+1]=s.y,i+=t})},Un.collectLayoutChanges=function(r,n,i){for(var a=r.nodes(),s={},l=0,c=0,f=n.length;l<f;l+=t){if(i){var p=Object.assign({},r.getNodeAttributes(a[c]));p.x=n[l],p.y=n[l+1],p=i(a[c],p),s[a[c]]={x:p.x,y:p.y}}else s[a[c]]={x:n[l],y:n[l+1]};c++}return s},Un.createWorker=function(n){var i=window.URL||window.webkitURL,a=n.toString(),s=i.createObjectURL(new Blob(["("+a+").call(this);"],{type:"text/javascript"})),l=new Worker(s);return i.revokeObjectURL(s),l},Un}var s0,Bk;function SQ(){return Bk||(Bk=1,s0={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),s0}var u0,Gk;function _Q(){if(Gk)return u0;Gk=1;var t=yI(),e=bQ().createEdgeWeightGetter,r=wQ(),n=xQ(),i=SQ();function a(c,f,p){if(!t(f))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof p=="number"&&(p={iterations:p});var h=p.iterations;if(typeof h!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(h<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var g=e("getEdgeWeight"in p?p.getEdgeWeight:"weight").fromEntry,y=typeof p.outputReducer=="function"?p.outputReducer:null,S=n.assign({},i,p.settings),w=n.validateSettings(S);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var b=n.graphToByteArrays(f,g),E;for(E=0;E<h;E++)r(S,b.nodes,b.edges);if(c){n.assignLayoutChanges(f,b.nodes,y);return}return n.collectLayoutChanges(f,b.nodes)}function s(c){var f=typeof c=="number"?c:c.order;return{barnesHutOptimize:f>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(f)}}var l=a.bind(null,!1);return l.assign=a.bind(null,!0),l.inferSettings=s,u0=l,u0}var EQ=_Q();const zk=tt(EQ);function OQ({graph:t}){const e=mQ();return N.useEffect(()=>{e(t)},[t,e]),null}function AQ({onNodeClick:t,onNodeHover:e}){const r=lx(),n=gQ();return N.useEffect(()=>{n({clickNode:i=>t==null?void 0:t(i.node),enterNode:i=>e==null?void 0:e(i.node),leaveNode:()=>e==null?void 0:e(void 0)})},[n,t,e]),N.useEffect(()=>{r.setSetting("labelRenderedSizeThreshold",10),r.setSetting("labelFont","Space Grotesk"),r.setSetting("labelColor",{color:"#e4e4ed"}),r.setSetting("edgeLabelColor",{color:"#94a3b8"})},[r]),null}function PQ({graph:t}){return N.useEffect(()=>{if(!(t.order<2))try{const e=zk.inferSettings(t);zk.assign(t,{iterations:Math.min(120,Math.max(40,t.order)),settings:{...e??{},gravity:.6,scalingRatio:10,slowDown:10}})}catch{}},[t]),null}function EI({graph:t,onNodeClick:e,onNodeHover:r}){const[n,i]=N.useState(0);N.useEffect(()=>{i(s=>s+1)},[t]);const a=N.useMemo(()=>({renderEdgeLabels:!0,labelDensity:.5,zIndex:!0}),[]);return H.jsxs(yQ,{graph:t,settings:a,className:"h-full w-full",children:[H.jsx(OQ,{graph:t}),H.jsx(PQ,{graph:t}),H.jsx(AQ,{onNodeClick:e,onNodeHover:r})]},n)}function OI({title:t,subtitle:e,meta:r=[],description:n}){return H.jsxs("div",{className:"card p-4",children:[H.jsx("div",{className:"flex items-start justify-between",children:H.jsxs("div",{children:[H.jsx("p",{className:"text-sm uppercase tracking-[0.3em] text-[#8888a0]",children:"Selected"}),H.jsx("h3",{className:"mt-2 text-lg font-semibold",children:t}),e&&H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:e})]})}),n&&H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:n}),H.jsx("div",{className:"mt-4 grid gap-3 text-sm",children:r.map(i=>H.jsxs("div",{className:"flex items-center justify-between border-b border-[#1f1f2c] pb-2",children:[H.jsx("span",{className:"text-[#8888a0]",children:i.label}),H.jsx("span",{className:"text-right text-[#e4e4ed]",children:i.value??"—"})]},i.label))})]})}const TQ={tool:"#3b82f6",service:"#10b981",concept:"#8b5cf6",decision:"#f59e0b",person:"#ec4899",file:"#6366f1",library:"#14b8a6"},Uk=["#38bdf8","#34d399","#f472b6","#facc15","#a78bfa","#f87171","#22d3ee","#c4b5fd","#fb7185","#4ade80"];function AI(t,e){t.forEachNode(r=>{t.setNodeAttribute(r,"x",(Math.random()-.5)*e),t.setNodeAttribute(r,"y",(Math.random()-.5)*e)})}function CQ(t){const e=new Ze,r=new Map;for(const n of t.edges)r.set(n.sourceId,(r.get(n.sourceId)||0)+1),r.set(n.targetId,(r.get(n.targetId)||0)+1);for(const n of t.nodes){const i=r.get(n.id)||0,a=Math.max(5,Math.min(25,5+i*1.2));e.addNode(String(n.id),{id:String(n.id),label:n.name,entityType:n.type,size:a,color:TQ[n.type]||"#64748b",description:n.description,firstLearnedAt:n.firstLearnedAt,lastConfirmedAt:n.lastConfirmedAt,contradictedAt:n.contradictedAt})}for(const n of t.edges){const i=String(n.sourceId),a=String(n.targetId);e.hasNode(i)&&e.hasNode(a)&&e.addEdgeWithKey(String(n.id),i,a,{label:n.edgeType,edgeType:n.edgeType,size:1,color:"rgba(148, 163, 184, 0.4)"})}return AI(e,800),e}function kQ(t,e,r){const n=new Ze;for(const i of t){const a=Math.max(4,Math.min(20,4+i.centrality*24)),s=i.clusterId!==null?r[i.clusterId]:"#64748b";n.addNode(i.path,{id:i.path,label:i.path.split("/").slice(-2).join("/"),fullPath:i.path,clusterId:i.clusterId,size:a,color:s})}for(const i of e)n.hasNode(i.source)&&n.hasNode(i.target)&&n.addEdge(i.source,i.target,{label:"imports",size:1,color:"rgba(148, 163, 184, 0.35)"});return AI(n,900),n}function RQ(){const t=Lo(c=>c.workspace);console.log("[GraphExplorer] render workspace=",t);const{data:e,isLoading:r,error:n}=Ra({queryKey:["graph-entities",t],queryFn:()=>oF(t)}),[i,a]=N.useState(null);r&&console.log("[GraphExplorer] loading..."),n&&console.error("[GraphExplorer] error:",n),e&&console.log("[GraphExplorer] data: nodes=",e.nodes.length,"edges=",e.edges.length,"stats=",e.stats);const s=N.useMemo(()=>{if(!e)return console.log("[GraphExplorer] no data, skipping graph build"),null;console.log("[GraphExplorer] building graph from",e.nodes.length,"nodes",e.edges.length,"edges");try{const c=CQ(e);return console.log("[GraphExplorer] graph built: order=",c.order,"size=",c.size),c}catch(c){return console.error("[GraphExplorer] graph build FAILED:",c),null}},[e]),l=e==null?void 0:e.nodes.find(c=>String(c.id)===i);return i&&console.log("[GraphExplorer] selected:",i,l==null?void 0:l.name),H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Knowledge Graph"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"Explore memory entities and their relationships."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Nodes: ",(e==null?void 0:e.stats.nodeCount)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.stats.edgeCount)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:c=>a(c)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading graph...":"No graph data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.name,subtitle:l.type,description:l.description,meta:[{label:"First learned",value:l.firstLearnedAt},{label:"Last confirmed",value:l.lastConfirmedAt},{label:"Contradicted",value:l.contradictedAt}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a node to inspect details."}),H.jsxs("div",{className:"card p-4",children:[H.jsx("h3",{className:"text-sm font-semibold",children:"Type distribution"}),H.jsx("div",{className:"mt-3 grid gap-2 text-xs text-[#8888a0]",children:e!=null&&e.stats.typeDistribution?Object.entries(e.stats.typeDistribution).map(([c,f])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsx("span",{children:c}),H.jsx("span",{className:"text-[#e4e4ed]",children:f})]},c)):"—"})]})]})]})]})}function DQ(){const t=Lo(p=>p.workspace),{data:e,isLoading:r}=Ra({queryKey:["code-deps",t],queryFn:()=>sF(t)}),[n,i]=N.useState(null),a=N.useMemo(()=>{const p=new Map;return e==null||e.files.forEach(h=>{if(h.clusterId===null||p.has(h.clusterId))return;const g=Uk[p.size%Uk.length];p.set(h.clusterId,g)}),Object.fromEntries(p.entries())},[e]),s=N.useMemo(()=>e?kQ(e.files,e.edges,a):null,[e,a]),l=e==null?void 0:e.files.find(p=>p.path===n),c=(e==null?void 0:e.edges.filter(p=>p.source===n).length)??0,f=(e==null?void 0:e.edges.filter(p=>p.target===n).length)??0;return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Code Dependencies"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"File-level dependency graph with centrality sizing."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Files: ",(e==null?void 0:e.files.length)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.edges.length)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:p=>i(p)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading code graph...":"No dependency data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.path.split("/").slice(-2).join("/"),subtitle:l.path,meta:[{label:"Centrality",value:l.centrality.toFixed(3)},{label:"Cluster",value:l.clusterId??"—"},{label:"Imports",value:c},{label:"Dependents",value:f}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a file to inspect details."}),H.jsxs("div",{className:"card p-4 text-sm text-[#8888a0]",children:[H.jsx("p",{className:"font-semibold text-[#e4e4ed]",children:"Cluster legend"}),H.jsx("div",{className:"mt-3 grid gap-2",children:Object.entries(a).map(([p,h])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("span",{children:["Cluster ",p]}),H.jsx("span",{className:"h-3 w-6 rounded-full",style:{background:h}})]},p))})]})]})]})]})}function jQ({result:t,expanded:e,onToggle:r}){const n=Math.min(100,Math.max(5,t.score*100));return H.jsxs("button",{type:"button",onClick:r,className:"card w-full cursor-pointer p-4 text-left transition hover:border-[#2a2a38]",children:[H.jsxs("div",{className:"flex items-start justify-between gap-4",children:[H.jsxs("div",{children:[H.jsx("h3",{className:"text-base font-semibold",children:t.title||t.path}),H.jsx("p",{className:"mt-1 text-xs text-[#8888a0]",children:t.path})]}),H.jsxs("div",{className:"min-w-[120px]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Score"}),H.jsx("div",{className:"mt-1 h-2 w-full rounded-full bg-[#1f1f2c]",children:H.jsx("div",{className:"h-2 rounded-full bg-gradient-to-r from-sky-500 via-indigo-500 to-fuchsia-500",style:{width:`${n}%`}})})]})]}),H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-[#8888a0]",children:[H.jsx("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:t.collection}),H.jsxs("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:["doc: ",t.docid]})]}),e&&H.jsxs("div",{className:"mt-4 border-t border-[#1f1f2c] pt-3 text-sm text-[#e4e4ed]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Expanded"}),H.jsx("p",{className:"mt-2 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 text-xs text-[#8888a0]",children:["Doc ID: ",t.docid]})]})]})}function IQ(){const t=Lo(f=>f.workspace),[e,r]=N.useState(""),[n,i]=N.useState(""),[a,s]=N.useState(null);N.useEffect(()=>{const f=window.setTimeout(()=>i(e),300);return()=>window.clearTimeout(f)},[e]);const{data:l,isFetching:c}=Ra({queryKey:["search",n,t],queryFn:()=>uF(n,20,t),enabled:n.trim().length>1});return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Hybrid Search"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"BM25 + vector + knowledge graph reranking."})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("label",{className:"text-xs uppercase text-[#8888a0]",children:"Search query"}),H.jsx("input",{value:e,onChange:f=>r(f.target.value),placeholder:"Search docs, entities, code...",className:"mt-2 w-full rounded-xl border border-[#26263a] bg-[#0f0f16] px-3 py-2 text-sm text-[#e4e4ed]"}),H.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-[#8888a0]",children:[H.jsx("span",{children:c?"Searching...":l?`${l.results.length} results`:"Idle"}),H.jsx("span",{children:l?`${l.executionMs} ms`:"—"})]})]}),H.jsxs("div",{className:"space-y-4",children:[l==null?void 0:l.results.map(f=>H.jsx(jQ,{result:f,expanded:a===f.id,onToggle:()=>s(a===f.id?null:f.id)},f.id)),l&&l.results.length===0&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"No results found."}),n.trim().length<=1&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"Type at least 2 characters to search."})]})]})}function NQ(){return H.jsx(gF,{children:H.jsxs(CL,{children:[H.jsx(vo,{path:"/",element:H.jsx(PL,{to:"/dashboard",replace:!0})}),H.jsx(vo,{path:"/dashboard",element:H.jsx($7,{})}),H.jsx(vo,{path:"/graph",element:H.jsx(RQ,{})}),H.jsx(vo,{path:"/code",element:H.jsx(DQ,{})}),H.jsx(vo,{path:"/search",element:H.jsx(IQ,{})})]})})}const MQ=new D$({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}}),qk=document.getElementById("root");qk&&RM.createRoot(qk).render(H.jsx(Q.StrictMode,{children:H.jsx(I$,{client:MQ,children:H.jsx(JL,{basename:"/web",children:H.jsx(NQ,{})})})}));
|
|
489
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tk(t){return oQ(t)||sQ(t)||rI(t)||uQ()}function lQ(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.indexOf(n)!==-1)continue;r[n]=t[n]}return r}function a0(t,e){if(t==null)return{};var r,n,i=lQ(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(n=0;n<a.length;n++)r=a[n],e.indexOf(r)===-1&&{}.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}var Ck=(function(){function t(e,r){er(this,t),this.key=e,this.size=r}return tr(t,null,[{key:"compare",value:function(r,n){return r.size>n.size?-1:r.size<n.size||r.key>n.key?1:-1}}])})(),kk=(function(){function t(){er(this,t),se(this,"width",0),se(this,"height",0),se(this,"cellSize",0),se(this,"columns",0),se(this,"rows",0),se(this,"cells",{})}return tr(t,[{key:"resizeAndClear",value:function(r,n){this.width=r.width,this.height=r.height,this.cellSize=n,this.columns=Math.ceil(r.width/n),this.rows=Math.ceil(r.height/n),this.cells={}}},{key:"getIndex",value:function(r){var n=Math.floor(r.x/this.cellSize),i=Math.floor(r.y/this.cellSize);return i*this.columns+n}},{key:"add",value:function(r,n,i){var a=new Ck(r,n),s=this.getIndex(i),l=this.cells[s];l||(l=[],this.cells[s]=l),l.push(a)}},{key:"organize",value:function(){for(var r in this.cells){var n=this.cells[r];n.sort(Ck.compare)}}},{key:"getLabelsToDisplay",value:function(r,n){var i=this.cellSize*this.cellSize,a=i/r/r,s=a*n/i,l=Math.ceil(s),c=[];for(var f in this.cells)for(var p=this.cells[f],h=0;h<Math.min(l,p.length);h++)c.push(p[h].key);return c}}])})();function cQ(t){var e=t.graph,r=t.hoveredNode,n=t.highlightedNodes,i=t.displayedNodeLabels,a=[];return e.forEachEdge(function(s,l,c,f){(c===r||f===r||n.has(c)||n.has(f)||i.has(c)&&i.has(f))&&a.push(s)}),a}var Rk=150,Dk=50,Kn=Object.prototype.hasOwnProperty;function fQ(t,e,r){if(!Kn.call(r,"x")||!Kn.call(r,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return r.color||(r.color=t.defaultNodeColor),!r.label&&r.label!==""&&(r.label=null),r.label!==void 0&&r.label!==null?r.label=""+r.label:r.label=null,r.size||(r.size=2),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"highlighted")||(r.highlighted=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultNodeType),r.zIndex||(r.zIndex=0),r}function dQ(t,e,r){return r.color||(r.color=t.defaultEdgeColor),r.label||(r.label=""),r.size||(r.size=.5),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultEdgeType),r.zIndex||(r.zIndex=0),r}var hQ=(function(t){function e(r,n){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(er(this,e),i=zr(this,e),se(i,"elements",{}),se(i,"canvasContexts",{}),se(i,"webGLContexts",{}),se(i,"pickingLayers",new Set),se(i,"textures",{}),se(i,"frameBuffers",{}),se(i,"activeListeners",{}),se(i,"labelGrid",new kk),se(i,"nodeDataCache",{}),se(i,"edgeDataCache",{}),se(i,"nodeProgramIndex",{}),se(i,"edgeProgramIndex",{}),se(i,"nodesWithForcedLabels",new Set),se(i,"edgesWithForcedLabels",new Set),se(i,"nodeExtent",{x:[0,1],y:[0,1]}),se(i,"nodeZExtent",[1/0,-1/0]),se(i,"edgeZExtent",[1/0,-1/0]),se(i,"matrix",Jr()),se(i,"invMatrix",Jr()),se(i,"correctionRatio",1),se(i,"customBBox",null),se(i,"normalizationFunction",Ok({x:[0,1],y:[0,1]})),se(i,"graphToViewportRatio",1),se(i,"itemIDsIndex",{}),se(i,"nodeIndices",{}),se(i,"edgeIndices",{}),se(i,"width",0),se(i,"height",0),se(i,"pixelRatio",_k()),se(i,"pickingDownSizingRatio",2*i.pixelRatio),se(i,"displayedNodeLabels",new Set),se(i,"displayedEdgeLabels",new Set),se(i,"highlightedNodes",new Set),se(i,"hoveredNode",null),se(i,"hoveredEdge",null),se(i,"renderFrame",null),se(i,"renderHighlightedNodesFrame",null),se(i,"needToProcess",!1),se(i,"checkEdgesEventsFrame",null),se(i,"nodePrograms",{}),se(i,"nodeHoverPrograms",{}),se(i,"edgePrograms",{}),i.settings=QY(a),i0(i.settings),VY(r),!(n instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=r,i.container=n,i.createWebGLContext("edges",{picking:a.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var l in i.settings.edgeProgramClasses)i.registerEdgeProgram(l,i.settings.edgeProgramClasses[l]);return i.camera=new Pk,i.bindCameraHandlers(),i.mouseCaptor=new rQ(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new aQ(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ur(e,t),tr(e,[{key:"registerNodeProgram",value:function(n,i,a){return this.nodePrograms[n]&&this.nodePrograms[n].kill(),this.nodeHoverPrograms[n]&&this.nodeHoverPrograms[n].kill(),this.nodePrograms[n]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[n]=new(a||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(n,i){return this.edgePrograms[n]&&this.edgePrograms[n].kill(),this.edgePrograms[n]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(n){if(this.nodePrograms[n]){var i=this.nodePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[n]){var l=this.nodeHoverPrograms,c=l[n],f=a0(l,[n].map(Tu));c.kill(),this.nodePrograms=f}return this}},{key:"unregisterEdgeProgram",value:function(n){if(this.edgePrograms[n]){var i=this.edgePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(n){var i=this.webGLContexts[n],a=this.frameBuffers[n],s=this.textures[n];s&&i.deleteTexture(s);var l=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,l,0),this.textures[n]=l,this}},{key:"bindCameraHandlers",value:function(){var n=this;return this.activeListeners.camera=function(){n.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(n){var i=n.x,a=n.y,s=dk(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),l=fk.apply(void 0,Tk(s)),c=this.itemIDsIndex[l];return c&&c.type==="node"?c.id:null}},{key:"bindEventHandlers",value:function(){var n=this;this.activeListeners.handleResize=function(){n.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},c=n.getNodeAtPosition(s);if(c&&n.hoveredNode!==c&&!n.nodeDataCache[c].hidden){n.hoveredNode&&n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.hoveredNode=c,n.emit("enterNode",Pe(Pe({},l),{},{node:c})),n.scheduleHighlightedNodesRender();return}if(n.hoveredNode&&n.getNodeAtPosition(s)!==n.hoveredNode){var f=n.hoveredNode;n.hoveredNode=null,n.emit("leaveNode",Pe(Pe({},l),{},{node:f})),n.scheduleHighlightedNodesRender();return}if(n.settings.enableEdgeEvents){var p=n.hoveredNode?null:n.getEdgeAtPoint(l.event.x,l.event.y);p!==n.hoveredEdge&&(n.hoveredEdge&&n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),p&&n.emit("enterEdge",Pe(Pe({},l),{},{edge:p})),n.hoveredEdge=p)}},this.activeListeners.handleMoveBody=function(a){var s=mu(a);n.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.hoveredNode&&(n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.scheduleHighlightedNodesRender()),n.settings.enableEdgeEvents&&n.hoveredEdge&&(n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),n.scheduleHighlightedNodesRender()),n.emit("leaveStage",Pe({},l))},this.activeListeners.handleEnter=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.emit("enterStage",Pe({},l))};var i=function(s){return function(l){var c=mu(l),f={event:c,preventSigmaDefault:function(){c.preventSigmaDefault()}},p=n.getNodeAtPosition(c);if(p)return n.emit("".concat(s,"Node"),Pe(Pe({},f),{},{node:p}));if(n.settings.enableEdgeEvents){var h=n.getEdgeAtPoint(c.x,c.y);if(h)return n.emit("".concat(s,"Edge"),Pe(Pe({},f),{},{edge:h}))}return n.emit("".concat(s,"Stage"),f)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var n=this,i=this.graph,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachNode(function(p){return n.updateNode(p)});var f=!c||c.some(function(p){return a.has(p)});n.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!f,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachEdge(function(p){return n.updateEdge(p)});var f=c&&["zIndex","type"].some(function(p){return c==null?void 0:c.includes(p)});n.refresh({partialGraph:{edges:i.edges()},skipIndexation:!f,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var l=s.key;n.addNode(l),n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var l=s.key;n.removeNode(l),n.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var l=s.key;n.addEdge(l),n.refresh({partialGraph:{edges:[l]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{edges:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var l=s.key;n.removeEdge(l),n.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){n.clearEdgeState(),n.clearEdgeIndices(),n.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){n.clearEdgeState(),n.clearNodeState(),n.clearEdgeIndices(),n.clearNodeIndices(),n.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var n=this.graph;n.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(n,i){var a=dk(this.webGLContexts.edges,this.frameBuffers.edges,n,i,this.pixelRatio,this.pickingDownSizingRatio),s=fk.apply(void 0,Tk(a)),l=this.itemIDsIndex[s];return l&&l.type==="edge"?l.id:null}},{key:"process",value:function(){var n=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,s=this.getDimensions();if(this.nodeExtent=HY(this.graph),!this.settings.autoRescale){var l=s.width,c=s.height,f=this.nodeExtent,p=f.x,h=f.y;this.nodeExtent={x:[(p[0]+p[1])/2-l/2,(p[0]+p[1])/2+l/2],y:[(h[0]+h[1])/2-c/2,(h[0]+h[1])/2+c/2]}}this.normalizationFunction=Ok(this.customBBox||this.nodeExtent);var g=new Pk,y=gu(g.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,a.labelGridCellSize);for(var S={},w={},b={},E={},P=1,T=i.nodes(),O=0,_=T.length;O<_;O++){var A=T[O],C=this.nodeDataCache[A],D=i.getNodeAttributes(A);C.x=D.x,C.y=D.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(A,C.size,this.framedGraphToViewport(C,{matrix:y})),S[C.type]=(S[C.type]||0)+1}this.labelGrid.organize();for(var j in this.nodePrograms){if(!Kn.call(this.nodePrograms,j))throw new Error('Sigma: could not find a suitable program for node type "'.concat(j,'"!'));this.nodePrograms[j].reallocate(S[j]||0),S[j]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(T=Ek(this.nodeZExtent,function(xe){return n.nodeDataCache[xe].zIndex},T));for(var G=0,z=T.length;G<z;G++){var $=T[G];w[$]=P,E[w[$]]={type:"node",id:$},P++;var R=this.nodeDataCache[$];this.addNodeToProgram($,w[$],S[R.type]++)}for(var X={},K=i.edges(),B=0,I=K.length;B<I;B++){var V=K[B],J=this.edgeDataCache[V];X[J.type]=(X[J.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(K=Ek(this.edgeZExtent,function(xe){return n.edgeDataCache[xe].zIndex},K));for(var ee in this.edgePrograms){if(!Kn.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(X[ee]||0),X[ee]=0}for(var L=0,W=K.length;L<W;L++){var te=K[L];b[te]=P,E[b[te]]={type:"edge",id:te},P++;var we=this.edgeDataCache[te];this.addEdgeToProgram(te,b[te],X[we.type]++)}return this.itemIDsIndex=E,this.nodeIndices=w,this.edgeIndices=b,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(n){var i=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(p){return i.cleanCameraState(p,a.cameraPanBoundaries&&qb(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),n){if(n.edgeProgramClasses!==a.edgeProgramClasses){for(var s in a.edgeProgramClasses)a.edgeProgramClasses[s]!==n.edgeProgramClasses[s]&&this.registerEdgeProgram(s,a.edgeProgramClasses[s]);for(var l in n.edgeProgramClasses)a.edgeProgramClasses[l]||this.unregisterEdgeProgram(l)}if(n.nodeProgramClasses!==a.nodeProgramClasses||n.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var c in a.nodeProgramClasses)(a.nodeProgramClasses[c]!==n.nodeProgramClasses[c]||a.nodeHoverProgramClasses[c]!==n.nodeHoverProgramClasses[c])&&this.registerNodeProgram(c,a.nodeProgramClasses[c],a.nodeHoverProgramClasses[c]);for(var f in n.nodeProgramClasses)a.nodeProgramClasses[f]||this.unregisterNodeProgram(f)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.tolerance,s=a===void 0?0:a,l=i.boundaries,c=Pe({},n),f=l||this.nodeExtent,p=os(f.x,2),h=p[0],g=p[1],y=os(f.y,2),S=y[0],w=y[1],b=[this.graphToViewport({x:h,y:S},{cameraState:n}),this.graphToViewport({x:g,y:S},{cameraState:n}),this.graphToViewport({x:h,y:w},{cameraState:n}),this.graphToViewport({x:g,y:w},{cameraState:n})],E=1/0,P=-1/0,T=1/0,O=-1/0;b.forEach(function(X){var K=X.x,B=X.y;E=Math.min(E,K),P=Math.max(P,K),T=Math.min(T,B),O=Math.max(O,B)});var _=P-E,A=O-T,C=this.getDimensions(),D=C.width,j=C.height,G=0,z=0;if(_>=D?P<D-s?G=P-(D-s):E>s&&(G=E-s):P>D+s?G=P-(D+s):E<-s&&(G=E+s),A>=j?O<j-s?z=O-(j-s):T>s&&(z=T-s):O>j+s?z=O-(j+s):T<-s&&(z=T+s),G||z){var $=this.viewportToFramedGraph({x:0,y:0},{cameraState:n}),R=this.viewportToFramedGraph({x:G,y:z},{cameraState:n});G=R.x-$.x,z=R.y-$.y,c.x+=G,c.y+=z}return c}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var n=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(n.ratio,this.settings.labelDensity);Ak(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,s=0,l=i.length;s<l;s++){var c=i[s],f=this.nodeDataCache[c];if(!this.displayedNodeLabels.has(c)&&!f.hidden){var p=this.framedGraphToViewport(f),h=p.x,g=p.y,y=this.scaleSize(f.size);if(!(!f.forceLabel&&y<this.settings.labelRenderedSizeThreshold)&&!(h<-Rk||h>this.width+Rk||g<-Dk||g>this.height+Dk)){this.displayedNodeLabels.add(c);var S=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[f.type],b=(w==null?void 0:w.drawLabel)||S;b(a,Pe(Pe({key:c},f),{},{size:y,x:h,y:g}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var n=this.canvasContexts.edgeLabels;n.clearRect(0,0,this.width,this.height);var i=cQ({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Ak(i,this.edgesWithForcedLabels);for(var a=new Set,s=0,l=i.length;s<l;s++){var c=i[s],f=this.graph.extremities(c),p=this.nodeDataCache[f[0]],h=this.nodeDataCache[f[1]],g=this.edgeDataCache[c];if(!a.has(c)&&!(g.hidden||p.hidden||h.hidden)){var y=this.settings.defaultDrawEdgeLabel,S=this.edgePrograms[g.type],w=(S==null?void 0:S.drawLabel)||y;w(n,Pe(Pe({key:c},g),{},{size:this.scaleSize(g.size)}),Pe(Pe(Pe({key:f[0]},p),this.framedGraphToViewport(p)),{},{size:this.scaleSize(p.size)}),Pe(Pe(Pe({key:f[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),a.add(c)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var n=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(y){var S=n.nodeDataCache[y],w=n.framedGraphToViewport(S),b=w.x,E=w.y,P=n.scaleSize(S.size),T=n.settings.defaultDrawNodeHover,O=n.nodePrograms[S.type],_=(O==null?void 0:O.drawHover)||T;_(i,Pe(Pe({key:y},S),{},{size:P,x:b,y:E}),n.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(g){g!==n.hoveredNode&&s.push(g)}),s.forEach(function(g){return a(g)});var l={};s.forEach(function(g){var y=n.nodeDataCache[g].type;l[y]=(l[y]||0)+1});for(var c in this.nodeHoverPrograms)this.nodeHoverPrograms[c].reallocate(l[c]||0),l[c]=0;s.forEach(function(g){var y=n.nodeDataCache[g];n.nodeHoverPrograms[y.type].process(0,l[y.type]++,y)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var f=this.getRenderParams();for(var p in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[p];h.render(f)}}},{key:"scheduleHighlightedNodesRender",value:function(){var n=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){n.renderHighlightedNodesFrame=null,n.renderHighlightedNodes(),n.renderEdgeLabels()}))}},{key:"render",value:function(){var n=this;this.emit("beforeRender");var i=function(){return n.emit("afterRender"),n};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(b){return n.resetWebGLTexture(b)}),!this.graph.order)return i();var a=this.mouseCaptor,s=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,l=this.camera.getState(),c=this.getDimensions(),f=this.getGraphDimensions(),p=this.getStagePadding();this.matrix=gu(l,c,f,p),this.invMatrix=gu(l,c,f,p,!0),this.correctionRatio=WY(this.matrix,l,c),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var g in this.nodePrograms){var y=this.nodePrograms[g];y.render(h)}if(!this.settings.hideEdgesOnMove||!s)for(var S in this.edgePrograms){var w=this.edgePrograms[S];w.render(h)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(n){var i=Object.assign({},this.graph.getNodeAttributes(n));this.settings.nodeReducer&&(i=this.settings.nodeReducer(n,i));var a=fQ(this.settings,n,i);this.nodeDataCache[n]=a,this.nodesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(n),this.highlightedNodes.delete(n),a.highlighted&&!a.hidden&&this.highlightedNodes.add(n),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.zIndex))}},{key:"updateNode",value:function(n){this.addNode(n);var i=this.nodeDataCache[n];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(n){delete this.nodeDataCache[n],delete this.nodeProgramIndex[n],this.highlightedNodes.delete(n),this.hoveredNode===n&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(n)}},{key:"addEdge",value:function(n){var i=Object.assign({},this.graph.getEdgeAttributes(n));this.settings.edgeReducer&&(i=this.settings.edgeReducer(n,i));var a=dQ(this.settings,n,i);this.edgeDataCache[n]=a,this.edgesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(n),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.zIndex))}},{key:"updateEdge",value:function(n){this.addEdge(n)}},{key:"removeEdge",value:function(n){delete this.edgeDataCache[n],delete this.edgeProgramIndex[n],this.hoveredEdge===n&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(n)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new kk,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(n,i,a){var s=this.nodeDataCache[n],l=this.nodePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));l.process(i,a,s),this.nodeProgramIndex[n]=a}},{key:"addEdgeToProgram",value:function(n,i,a){var s=this.edgeDataCache[n],l=this.edgePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var c=this.graph.extremities(n),f=this.nodeDataCache[c[0]],p=this.nodeDataCache[c[1]];l.process(i,a,f,p,s),this.edgeProgramIndex[n]=a}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var n=this.settings,i=n.stagePadding,a=n.autoRescale;return a&&i||0}},{key:"createLayer",value:function(n,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[n])throw new Error('Sigma: a layer named "'.concat(n,'" already exists'));var s=KY(i,{position:"absolute"},{class:"sigma-".concat(n)});return a.style&&Object.assign(s.style,a.style),this.elements[n]=s,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(s):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(n,"canvas",i)}},{key:"createCanvasContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(n,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[n]=a.getContext("2d",s),this}},{key:"createWebGLContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(i==null?void 0:i.canvas)||this.createCanvas(n,i);i.hidden&&a.remove();var s=Pe({preserveDrawingBuffer:!1,antialias:!1},i),l;l=a.getContext("webgl2",s),l||(l=a.getContext("webgl",s)),l||(l=a.getContext("experimental-webgl",s));var c=l;if(this.webGLContexts[n]=c,c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(n);var f=c.createFramebuffer();if(!f)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(n));this.frameBuffers[n]=f}return c}},{key:"killLayer",value:function(n){var i=this.elements[n];if(!i)throw new Error("Sigma: cannot kill layer ".concat(n,", which does not exist"));if(this.webGLContexts[n]){var a,s=this.webGLContexts[n];(a=s.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[n]}else this.canvasContexts[n]&&delete this.canvasContexts[n];return i.remove(),delete this.elements[n],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(n){this.unbindCameraHandlers(),this.camera=n,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(n){n!==this.graph&&(this.hoveredNode&&!n.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!n.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=n,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var n=this.customBBox||this.nodeExtent;return{width:n.x[1]-n.x[0]||1,height:n.y[1]-n.y[0]||1}}},{key:"getNodeDisplayData",value:function(n){var i=this.nodeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(n){var i=this.edgeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return Pe({},this.settings)}},{key:"getSetting",value:function(n){return this.settings[n]}},{key:"setSetting",value:function(n,i){var a=Pe({},this.settings);return this.settings[n]=i,i0(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(n,i){return this.setSetting(n,i(this.settings[n])),this}},{key:"setSettings",value:function(n){var i=Pe({},this.settings);return this.settings=Pe(Pe({},this.settings),n),i0(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(n){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=_k(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!n&&i===this.width&&a===this.height)return this;for(var s in this.elements){var l=this.elements[s];l.style.width=this.width+"px",l.style.height=this.height+"px"}for(var c in this.canvasContexts)this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[c].scale(this.pixelRatio,this.pixelRatio);for(var f in this.webGLContexts){this.elements[f].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[f].setAttribute("height",this.height*this.pixelRatio+"px");var p=this.webGLContexts[f];if(p.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(f)){var h=this.textures[f];h&&p.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(n){var i=this,a=(n==null?void 0:n.skipIndexation)!==void 0?n==null?void 0:n.skipIndexation:!1,s=(n==null?void 0:n.schedule)!==void 0?n.schedule:!1,l=!n||!n.partialGraph;if(l)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(O){return i.addNode(O)}),this.graph.forEachEdge(function(O){return i.addEdge(O)});else{for(var c,f,p=((c=n.partialGraph)===null||c===void 0?void 0:c.nodes)||[],h=0,g=(p==null?void 0:p.length)||0;h<g;h++){var y=p[h];if(this.updateNode(y),a){var S=this.nodeProgramIndex[y];if(S===void 0)throw new Error('Sigma: node "'.concat(y,`" can't be repaint`));this.addNodeToProgram(y,this.nodeIndices[y],S)}}for(var w=(n==null||(f=n.partialGraph)===null||f===void 0?void 0:f.edges)||[],b=0,E=w.length;b<E;b++){var P=w[b];if(this.updateEdge(P),a){var T=this.edgeProgramIndex[P];if(T===void 0)throw new Error('Sigma: edge "'.concat(P,`" can't be repaint`));this.addEdgeToProgram(P,this.edgeIndices[P],T)}}}return(l||!a)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var n=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){n.render()})),this}},{key:"scheduleRefresh",value:function(n){return this.refresh(Pe(Pe({},n),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(n,i){var a=this.camera.getState(),s=a.ratio,l=a.angle,c=a.x,f=a.y,p=this.settings,h=p.minCameraRatio,g=p.maxCameraRatio;typeof g=="number"&&(i=Math.min(i,g)),typeof h=="number"&&(i=Math.max(i,h));var y=i/s,S={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(n),b=this.viewportToFramedGraph(S);return{angle:l,x:(w.x-b.x)*(1-y)+c,y:(w.y-b.y)*(1-y)+f,ratio:i}}},{key:"viewRectangle",value:function(){var n=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:n.x,y1:n.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,l=Ub(s,n);return{x:(1+l.x)*this.width/2,y:(1-l.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,l=Ub(s,{x:n.x/this.width*2-1,y:1-n.y/this.height*2});return isNaN(l.x)&&(l.x=0),isNaN(l.y)&&(l.y=0),l}},{key:"viewportToGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(n,i))}},{key:"graphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(n),i)}},{key:"getGraphToViewportRatio",value:function(){var n={x:0,y:0},i={x:1,y:1},a=Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2)),s=this.graphToViewport(n),l=this.graphToViewport(i),c=Math.sqrt(Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2));return c/a}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(n){return this.customBBox=n,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var n=this.container;n.firstChild;)n.removeChild(n.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var l in this.elements)this.killLayer(l);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return n/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var n={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(n[i]=this.elements[i]);return n}}])})(sx);const xI=N.createContext(null),pQ=xI.Provider;function SI(){const t=N.useContext(xI);if(t==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return t}function lx(){return SI().sigma}function vQ(){const{sigma:t}=SI();return N.useCallback((e=>{t&&Object.keys(e).forEach((r=>{t.setSetting(r,e[r])}))}),[t])}function Qd(t){return new Set(Object.keys(t))}const jk=Qd({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Ik=Qd({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Nk=Qd({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Mk=Qd({updated:!0});function gQ(){const t=lx(),e=vQ(),[r,n]=N.useState({});return N.useEffect((()=>{if(!t||!r)return;const i=r,a=Object.keys(i);return a.forEach((s=>{const l=i[s];jk.has(s)&&t.on(s,l),Ik.has(s)&&t.getMouseCaptor().on(s,l),Nk.has(s)&&t.getTouchCaptor().on(s,l),Mk.has(s)&&t.getCamera().on(s,l)})),()=>{t&&a.forEach((s=>{const l=i[s];jk.has(s)&&t.off(s,l),Ik.has(s)&&t.getMouseCaptor().off(s,l),Nk.has(s)&&t.getTouchCaptor().off(s,l),Mk.has(s)&&t.getCamera().off(s,l)}))}}),[t,r,e]),n}function mQ(){const t=lx();return N.useCallback(((e,r=!0)=>{t&&e&&(r&&t.getGraph().order>0&&t.getGraph().clear(),t.getGraph().import(e),t.refresh())}),[t])}function _I(t,e){if(t===e)return!0;if(typeof t=="object"&&t!=null&&typeof e=="object"&&e!=null){if(Object.keys(t).length!=Object.keys(e).length)return!1;for(const r in t)if(!Object.hasOwn(e,r)||!_I(t[r],e[r]))return!1;return!0}return!1}const yQ=N.forwardRef((({graph:t,id:e,className:r,style:n,settings:i={},children:a},s)=>{const l=N.useRef(null),c=N.useRef(null),f={className:`react-sigma ${r||""}`,id:e,style:n},[p,h]=N.useState(null),[g,y]=N.useState(i);N.useEffect((()=>{y((b=>_I(b,i)?b:i))}),[i]),N.useEffect((()=>{let b=null;if(c.current!==null){let E=new Ze;t&&(E=typeof t=="function"?new t:t),b=new hQ(E,c.current,g),h((P=>{let T=null;return P&&(T=P.getCamera().getState()),T&&b.getCamera().setState(T),b}))}return()=>{b&&b.kill()}}),[c,t,g]),N.useImperativeHandle(s,(()=>p),[p]);const S=N.useMemo((()=>p&&l.current?{sigma:p,container:l.current}:null),[p,l]),w=S!==null?Q.createElement(pQ,{value:S},a):null;return Q.createElement("div",Object.assign({},f,{ref:l}),Q.createElement("div",{className:"sigma-container",ref:c}),w)}));var bu={},Lk;function bQ(){if(Lk)return bu;Lk=1;function t(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getNodeAttributes(p))},a.fromEntry=function(f,p){return l(p)}):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){return s(n(p,f.getNodeAttributes(p)))},a.fromEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c),a}function r(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getEdgeAttributes(p))},a.fromEntry=function(f,p){return l(p)},a.fromPartialEntry=a.fromEntry,a.fromMinimalEntry=a.fromEntry):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){var h=f.extremities(p);return s(n(p,f.getEdgeAttributes(p),h[0],h[1],f.getNodeAttributes(h[0]),f.getNodeAttributes(h[1]),f.isUndirected(p)))},a.fromEntry=function(f,p,h,g,y,S,w){return s(n(f,p,h,g,y,S,w))},a.fromPartialEntry=function(f,p,h,g){return s(n(f,p,h,g))},a.fromMinimalEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c,a.fromMinimalEntry=c),a}return bu.createNodeValueGetter=e,bu.createEdgeValueGetter=r,bu.createEdgeWeightGetter=function(n){return r(n,t)},bu}var o0,$k;function wQ(){if($k)return o0;$k=1;var t=0,e=1,r=2,n=3,i=4,a=5,s=6,l=7,c=8,f=9,p=0,h=1,g=2,y=0,S=1,w=2,b=3,E=4,P=5,T=6,O=7,_=8,A=3,C=10,D=3,j=9,G=10;return o0=function($,R,X){var K,B,I,V,J,ee,L,W,te,we,xe=R.length,Ie=X.length,Le=$.adjustSizes,Me=$.barnesHutTheta*$.barnesHutTheta,le,pe,ve,ie,Fe,de,ge,ne=[];for(I=0;I<xe;I+=C)R[I+i]=R[I+r],R[I+a]=R[I+n],R[I+r]=0,R[I+n]=0;if($.outboundAttractionDistribution){for(le=0,I=0;I<xe;I+=C)le+=R[I+s];le/=xe/C}if($.barnesHutOptimize){var it=1/0,kt=-1/0,Rt=1/0,Bt=-1/0,rt,Dt,cn;for(I=0;I<xe;I+=C)it=Math.min(it,R[I+t]),kt=Math.max(kt,R[I+t]),Rt=Math.min(Rt,R[I+e]),Bt=Math.max(Bt,R[I+e]);var fn=kt-it,dn=Bt-Rt;for(fn>dn?(Rt-=(fn-dn)/2,Bt=Rt+fn):(it-=(dn-fn)/2,kt=it+dn),ne[0+y]=-1,ne[0+S]=(it+kt)/2,ne[0+w]=(Rt+Bt)/2,ne[0+b]=Math.max(kt-it,Bt-Rt),ne[0+E]=-1,ne[0+P]=-1,ne[0+T]=0,ne[0+O]=0,ne[0+_]=0,K=1,I=0;I<xe;I+=C)for(B=0,cn=A;;)if(ne[B+P]>=0){R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[I+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+O]=(ne[B+O]*ne[B+T]+R[I+t]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+_]=(ne[B+_]*ne[B+T]+R[I+e]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+T]+=R[I+s],B=rt;continue}else if(ne[B+y]<0){ne[B+y]=I;break}else{if(ne[B+P]=K*j,W=ne[B+b]/2,te=ne[B+P],ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=ne[B+E],ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,K+=4,R[ne[B+y]+t]<ne[B+S]?R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+T]=R[ne[B+y]+s],ne[B+O]=R[ne[B+y]+t],ne[B+_]=R[ne[B+y]+e],ne[rt+y]=ne[B+y],ne[B+y]=-1,R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?Dt=ne[B+P]:Dt=ne[B+P]+j:R[I+e]<ne[B+w]?Dt=ne[B+P]+j*2:Dt=ne[B+P]+j*3,rt===Dt)if(cn--){B=rt;continue}else{cn=A;break}ne[Dt+y]=I;break}}if($.barnesHutOptimize)for(pe=$.scalingRatio,I=0;I<xe;I+=C)for(B=0;;)if(ne[B+P]>=0)if(de=Math.pow(R[I+t]-ne[B+O],2)+Math.pow(R[I+e]-ne[B+_],2),we=ne[B+b],4*we*we/de<Me){if(ve=R[I+t]-ne[B+O],ie=R[I+e]-ne[B+_],Le===!0?de>0?(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*ne[B+T]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge),B=ne[B+E],B<0)break;continue}else{B=ne[B+P];continue}else{if(ee=ne[B+y],ee>=0&&ee!==I&&(ve=R[I+t]-R[ee+t],ie=R[I+e]-R[ee+e],de=ve*ve+ie*ie,Le===!0?de>0?(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*R[ee+s]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge)),B=ne[B+E],B<0)break;continue}else for(pe=$.scalingRatio,V=0;V<xe;V+=C)for(J=0;J<V;J+=C)ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],de>0?(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge):de<0&&(ge=100*pe*R[V+s]*R[J+s],R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge)):(de=Math.sqrt(ve*ve+ie*ie),de>0&&(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge));for(te=$.gravity/$.scalingRatio,pe=$.scalingRatio,I=0;I<xe;I+=C)ge=0,ve=R[I+t],ie=R[I+e],de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.strongGravityMode?de>0&&(ge=pe*R[I+s]*te):de>0&&(ge=pe*R[I+s]*te/de),R[I+r]-=ve*ge,R[I+n]-=ie*ge;for(pe=1*($.outboundAttractionDistribution?le:1),L=0;L<Ie;L+=D)V=X[L+p],J=X[L+h],W=X[L+g],Fe=Math.pow(W,$.edgeWeightInfluence),ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe/R[V+s]):de>0&&(ge=-pe*Fe)):(de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?(de=1,ge=-pe*Fe/R[V+s]):(de=1,ge=-pe*Fe)),de>0&&(R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge);var Xi,Dn,jn,hn,pn,vn;if(Le===!0)for(I=0;I<xe;I+=C)R[I+f]!==1&&(Xi=Math.sqrt(Math.pow(R[I+r],2)+Math.pow(R[I+n],2)),Xi>G&&(R[I+r]=R[I+r]*G/Xi,R[I+n]=R[I+n]*G/Xi),Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=.1*Math.log(1+jn)/(1+Math.sqrt(Dn)),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);else for(I=0;I<xe;I+=C)R[I+f]!==1&&(Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=R[I+l]*Math.log(1+jn)/(1+Math.sqrt(Dn)),R[I+l]=Math.min(1,Math.sqrt(hn*(Math.pow(R[I+r],2)+Math.pow(R[I+n],2))/(1+Math.sqrt(Dn)))),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);return{}},o0}var Un={},Fk;function xQ(){if(Fk)return Un;Fk=1;var t=10,e=3;return Un.assign=function(r){r=r||{};var n=Array.prototype.slice.call(arguments).slice(1),i,a,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(a in n[i])r[a]=n[i][a];return r},Un.validateSettings=function(r){return"linLogMode"in r&&typeof r.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in r&&typeof r.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in r&&typeof r.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in r&&typeof r.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in r&&!(typeof r.scalingRatio=="number"&&r.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Un.graphToByteArrays=function(r,n){var i=r.order,a=r.size,s={},l,c=new Float32Array(i*t),f=new Float32Array(a*e);return l=0,r.forEachNode(function(p,h){s[p]=l,c[l]=h.x,c[l+1]=h.y,c[l+2]=0,c[l+3]=0,c[l+4]=0,c[l+5]=0,c[l+6]=1,c[l+7]=1,c[l+8]=h.size||1,c[l+9]=h.fixed?1:0,l+=t}),l=0,r.forEachEdge(function(p,h,g,y,S,w,b){var E=s[g],P=s[y],T=n(p,h,g,y,S,w,b);c[E+6]+=T,c[P+6]+=T,f[l]=E,f[l+1]=P,f[l+2]=T,l+=e}),{nodes:c,edges:f}},Un.assignLayoutChanges=function(r,n,i){var a=0;r.updateEachNodeAttributes(function(s,l){return l.x=n[a],l.y=n[a+1],a+=t,i?i(s,l):l})},Un.readGraphPositions=function(r,n){var i=0;r.forEachNode(function(a,s){n[i]=s.x,n[i+1]=s.y,i+=t})},Un.collectLayoutChanges=function(r,n,i){for(var a=r.nodes(),s={},l=0,c=0,f=n.length;l<f;l+=t){if(i){var p=Object.assign({},r.getNodeAttributes(a[c]));p.x=n[l],p.y=n[l+1],p=i(a[c],p),s[a[c]]={x:p.x,y:p.y}}else s[a[c]]={x:n[l],y:n[l+1]};c++}return s},Un.createWorker=function(n){var i=window.URL||window.webkitURL,a=n.toString(),s=i.createObjectURL(new Blob(["("+a+").call(this);"],{type:"text/javascript"})),l=new Worker(s);return i.revokeObjectURL(s),l},Un}var s0,Bk;function SQ(){return Bk||(Bk=1,s0={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),s0}var u0,Gk;function _Q(){if(Gk)return u0;Gk=1;var t=yI(),e=bQ().createEdgeWeightGetter,r=wQ(),n=xQ(),i=SQ();function a(c,f,p){if(!t(f))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof p=="number"&&(p={iterations:p});var h=p.iterations;if(typeof h!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(h<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var g=e("getEdgeWeight"in p?p.getEdgeWeight:"weight").fromEntry,y=typeof p.outputReducer=="function"?p.outputReducer:null,S=n.assign({},i,p.settings),w=n.validateSettings(S);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var b=n.graphToByteArrays(f,g),E;for(E=0;E<h;E++)r(S,b.nodes,b.edges);if(c){n.assignLayoutChanges(f,b.nodes,y);return}return n.collectLayoutChanges(f,b.nodes)}function s(c){var f=typeof c=="number"?c:c.order;return{barnesHutOptimize:f>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(f)}}var l=a.bind(null,!1);return l.assign=a.bind(null,!0),l.inferSettings=s,u0=l,u0}var EQ=_Q();const zk=tt(EQ);function OQ({graph:t}){const e=mQ();return N.useEffect(()=>{e(t)},[t,e]),null}function AQ({onNodeClick:t,onNodeHover:e}){const r=lx(),n=gQ();return N.useEffect(()=>{n({clickNode:i=>t==null?void 0:t(i.node),enterNode:i=>e==null?void 0:e(i.node),leaveNode:()=>e==null?void 0:e(void 0)})},[n,t,e]),N.useEffect(()=>{r.setSetting("labelRenderedSizeThreshold",10),r.setSetting("labelFont","Space Grotesk"),r.setSetting("labelColor",{color:"#e4e4ed"}),r.setSetting("edgeLabelColor",{color:"#94a3b8"})},[r]),null}function PQ({graph:t}){return N.useEffect(()=>{if(!(t.order<2))try{const e=zk.inferSettings(t);zk.assign(t,{iterations:Math.min(120,Math.max(40,t.order)),settings:{...e??{},gravity:.6,scalingRatio:10,slowDown:10}})}catch{}},[t]),null}function EI({graph:t,onNodeClick:e,onNodeHover:r}){const[n,i]=N.useState(0);N.useEffect(()=>{i(s=>s+1)},[t]);const a=N.useMemo(()=>({renderEdgeLabels:!0,labelDensity:.5,zIndex:!0,defaultNodeColor:"#64748b",defaultEdgeColor:"rgba(148, 163, 184, 0.4)",labelColor:{color:"#e4e4ed"},labelFont:"Space Grotesk, system-ui, sans-serif",labelRenderedSizeThreshold:8}),[]);return H.jsxs(yQ,{settings:a,className:"h-full w-full",style:{background:"#0d0d14"},children:[H.jsx(OQ,{graph:t}),H.jsx(PQ,{graph:t}),H.jsx(AQ,{onNodeClick:e,onNodeHover:r})]},n)}function OI({title:t,subtitle:e,meta:r=[],description:n}){return H.jsxs("div",{className:"card p-4",children:[H.jsx("div",{className:"flex items-start justify-between",children:H.jsxs("div",{children:[H.jsx("p",{className:"text-sm uppercase tracking-[0.3em] text-[#8888a0]",children:"Selected"}),H.jsx("h3",{className:"mt-2 text-lg font-semibold",children:t}),e&&H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:e})]})}),n&&H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:n}),H.jsx("div",{className:"mt-4 grid gap-3 text-sm",children:r.map(i=>H.jsxs("div",{className:"flex items-center justify-between border-b border-[#1f1f2c] pb-2",children:[H.jsx("span",{className:"text-[#8888a0]",children:i.label}),H.jsx("span",{className:"text-right text-[#e4e4ed]",children:i.value??"—"})]},i.label))})]})}const TQ={tool:"#3b82f6",service:"#10b981",concept:"#8b5cf6",decision:"#f59e0b",person:"#ec4899",file:"#6366f1",library:"#14b8a6"},Uk=["#38bdf8","#34d399","#f472b6","#facc15","#a78bfa","#f87171","#22d3ee","#c4b5fd","#fb7185","#4ade80"];function AI(t,e){t.forEachNode(r=>{t.setNodeAttribute(r,"x",(Math.random()-.5)*e),t.setNodeAttribute(r,"y",(Math.random()-.5)*e)})}function CQ(t){const e=new Ze,r=new Map;for(const n of t.edges)r.set(n.sourceId,(r.get(n.sourceId)||0)+1),r.set(n.targetId,(r.get(n.targetId)||0)+1);for(const n of t.nodes){const i=r.get(n.id)||0,a=Math.max(5,Math.min(25,5+i*1.2));e.addNode(String(n.id),{id:String(n.id),label:n.name,entityType:n.type,size:a,color:TQ[n.type]||"#64748b",description:n.description,firstLearnedAt:n.firstLearnedAt,lastConfirmedAt:n.lastConfirmedAt,contradictedAt:n.contradictedAt})}for(const n of t.edges){const i=String(n.sourceId),a=String(n.targetId);e.hasNode(i)&&e.hasNode(a)&&e.addEdgeWithKey(String(n.id),i,a,{label:n.edgeType,edgeType:n.edgeType,size:1,color:"rgba(148, 163, 184, 0.4)"})}return AI(e,800),e}function kQ(t,e,r){const n=new Ze;for(const i of t){const a=Math.max(4,Math.min(20,4+i.centrality*24)),s=i.clusterId!==null?r[i.clusterId]:"#64748b";n.addNode(i.path,{id:i.path,label:i.path.split("/").slice(-2).join("/"),fullPath:i.path,clusterId:i.clusterId,size:a,color:s})}for(const i of e)n.hasNode(i.source)&&n.hasNode(i.target)&&n.addEdge(i.source,i.target,{label:"imports",size:1,color:"rgba(148, 163, 184, 0.35)"});return AI(n,900),n}function RQ(){const t=Lo(c=>c.workspace);console.log("[GraphExplorer] render workspace=",t);const{data:e,isLoading:r,error:n}=Ra({queryKey:["graph-entities",t],queryFn:()=>oF(t)}),[i,a]=N.useState(null);r&&console.log("[GraphExplorer] loading..."),n&&console.error("[GraphExplorer] error:",n),e&&console.log("[GraphExplorer] data: nodes=",e.nodes.length,"edges=",e.edges.length,"stats=",e.stats);const s=N.useMemo(()=>{if(!e)return console.log("[GraphExplorer] no data, skipping graph build"),null;console.log("[GraphExplorer] building graph from",e.nodes.length,"nodes",e.edges.length,"edges");try{const c=CQ(e);return console.log("[GraphExplorer] graph built: order=",c.order,"size=",c.size),c}catch(c){return console.error("[GraphExplorer] graph build FAILED:",c),null}},[e]),l=e==null?void 0:e.nodes.find(c=>String(c.id)===i);return i&&console.log("[GraphExplorer] selected:",i,l==null?void 0:l.name),H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Knowledge Graph"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"Explore memory entities and their relationships."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Nodes: ",(e==null?void 0:e.stats.nodeCount)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.stats.edgeCount)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:c=>a(c)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading graph...":"No graph data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.name,subtitle:l.type,description:l.description,meta:[{label:"First learned",value:l.firstLearnedAt},{label:"Last confirmed",value:l.lastConfirmedAt},{label:"Contradicted",value:l.contradictedAt}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a node to inspect details."}),H.jsxs("div",{className:"card p-4",children:[H.jsx("h3",{className:"text-sm font-semibold",children:"Type distribution"}),H.jsx("div",{className:"mt-3 grid gap-2 text-xs text-[#8888a0]",children:e!=null&&e.stats.typeDistribution?Object.entries(e.stats.typeDistribution).map(([c,f])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsx("span",{children:c}),H.jsx("span",{className:"text-[#e4e4ed]",children:f})]},c)):"—"})]})]})]})]})}function DQ(){const t=Lo(p=>p.workspace),{data:e,isLoading:r}=Ra({queryKey:["code-deps",t],queryFn:()=>sF(t)}),[n,i]=N.useState(null),a=N.useMemo(()=>{const p=new Map;return e==null||e.files.forEach(h=>{if(h.clusterId===null||p.has(h.clusterId))return;const g=Uk[p.size%Uk.length];p.set(h.clusterId,g)}),Object.fromEntries(p.entries())},[e]),s=N.useMemo(()=>e?kQ(e.files,e.edges,a):null,[e,a]),l=e==null?void 0:e.files.find(p=>p.path===n),c=(e==null?void 0:e.edges.filter(p=>p.source===n).length)??0,f=(e==null?void 0:e.edges.filter(p=>p.target===n).length)??0;return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Code Dependencies"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"File-level dependency graph with centrality sizing."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Files: ",(e==null?void 0:e.files.length)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.edges.length)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:p=>i(p)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading code graph...":"No dependency data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.path.split("/").slice(-2).join("/"),subtitle:l.path,meta:[{label:"Centrality",value:l.centrality.toFixed(3)},{label:"Cluster",value:l.clusterId??"—"},{label:"Imports",value:c},{label:"Dependents",value:f}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a file to inspect details."}),H.jsxs("div",{className:"card p-4 text-sm text-[#8888a0]",children:[H.jsx("p",{className:"font-semibold text-[#e4e4ed]",children:"Cluster legend"}),H.jsx("div",{className:"mt-3 grid gap-2",children:Object.entries(a).map(([p,h])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("span",{children:["Cluster ",p]}),H.jsx("span",{className:"h-3 w-6 rounded-full",style:{background:h}})]},p))})]})]})]})]})}function jQ({result:t,expanded:e,onToggle:r}){const n=Math.min(100,Math.max(5,t.score*100));return H.jsxs("button",{type:"button",onClick:r,className:"card w-full cursor-pointer p-4 text-left transition hover:border-[#2a2a38]",children:[H.jsxs("div",{className:"flex items-start justify-between gap-4",children:[H.jsxs("div",{children:[H.jsx("h3",{className:"text-base font-semibold",children:t.title||t.path}),H.jsx("p",{className:"mt-1 text-xs text-[#8888a0]",children:t.path})]}),H.jsxs("div",{className:"min-w-[120px]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Score"}),H.jsx("div",{className:"mt-1 h-2 w-full rounded-full bg-[#1f1f2c]",children:H.jsx("div",{className:"h-2 rounded-full bg-gradient-to-r from-sky-500 via-indigo-500 to-fuchsia-500",style:{width:`${n}%`}})})]})]}),H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-[#8888a0]",children:[H.jsx("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:t.collection}),H.jsxs("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:["doc: ",t.docid]})]}),e&&H.jsxs("div",{className:"mt-4 border-t border-[#1f1f2c] pt-3 text-sm text-[#e4e4ed]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Expanded"}),H.jsx("p",{className:"mt-2 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 text-xs text-[#8888a0]",children:["Doc ID: ",t.docid]})]})]})}function IQ(){const t=Lo(f=>f.workspace),[e,r]=N.useState(""),[n,i]=N.useState(""),[a,s]=N.useState(null);N.useEffect(()=>{const f=window.setTimeout(()=>i(e),300);return()=>window.clearTimeout(f)},[e]);const{data:l,isFetching:c}=Ra({queryKey:["search",n,t],queryFn:()=>uF(n,20,t),enabled:n.trim().length>1});return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Hybrid Search"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"BM25 + vector + knowledge graph reranking."})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("label",{className:"text-xs uppercase text-[#8888a0]",children:"Search query"}),H.jsx("input",{value:e,onChange:f=>r(f.target.value),placeholder:"Search docs, entities, code...",className:"mt-2 w-full rounded-xl border border-[#26263a] bg-[#0f0f16] px-3 py-2 text-sm text-[#e4e4ed]"}),H.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-[#8888a0]",children:[H.jsx("span",{children:c?"Searching...":l?`${l.results.length} results`:"Idle"}),H.jsx("span",{children:l?`${l.executionMs} ms`:"—"})]})]}),H.jsxs("div",{className:"space-y-4",children:[l==null?void 0:l.results.map(f=>H.jsx(jQ,{result:f,expanded:a===f.id,onToggle:()=>s(a===f.id?null:f.id)},f.id)),l&&l.results.length===0&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"No results found."}),n.trim().length<=1&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"Type at least 2 characters to search."})]})]})}function NQ(){return H.jsx(gF,{children:H.jsxs(CL,{children:[H.jsx(vo,{path:"/",element:H.jsx(PL,{to:"/dashboard",replace:!0})}),H.jsx(vo,{path:"/dashboard",element:H.jsx($7,{})}),H.jsx(vo,{path:"/graph",element:H.jsx(RQ,{})}),H.jsx(vo,{path:"/code",element:H.jsx(DQ,{})}),H.jsx(vo,{path:"/search",element:H.jsx(IQ,{})})]})})}const MQ=new D$({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}}),qk=document.getElementById("root");qk&&RM.createRoot(qk).render(H.jsx(Q.StrictMode,{children:H.jsx(I$,{client:MQ,children:H.jsx(JL,{basename:"/web",children:H.jsx(NQ,{})})})}));
|
package/dist/web/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>nano-brain dashboard</title>
|
|
7
|
-
<script type="module" crossorigin src="/web/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/web/assets/index-DWCUWBui.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/web/assets/index-BhJ8fAaB.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body class="bg-slate-950 text-slate-200">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nano-brain",
|
|
3
|
-
"version": "2026.6.
|
|
3
|
+
"version": "2026.6.22",
|
|
4
4
|
"description": "Persistent memory and code intelligence for AI coding agents. Local MCP server with self-learning hybrid search (BM25 + vector + knowledge graph + LLM reranking), automatic session ingestion, codebase indexing, and 22 tools. Learns your preferences over time. Works with OpenCode, Claude, Cursor, Windsurf, and any MCP client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -78,12 +78,22 @@ export default function GraphCanvas({ graph, onNodeClick, onNodeHover }: GraphCa
|
|
|
78
78
|
renderEdgeLabels: true,
|
|
79
79
|
labelDensity: 0.5,
|
|
80
80
|
zIndex: true,
|
|
81
|
+
defaultNodeColor: '#64748b',
|
|
82
|
+
defaultEdgeColor: 'rgba(148, 163, 184, 0.4)',
|
|
83
|
+
labelColor: { color: '#e4e4ed' },
|
|
84
|
+
labelFont: 'Space Grotesk, system-ui, sans-serif',
|
|
85
|
+
labelRenderedSizeThreshold: 8,
|
|
81
86
|
}),
|
|
82
87
|
[]
|
|
83
88
|
);
|
|
84
89
|
|
|
85
90
|
return (
|
|
86
|
-
<SigmaContainer
|
|
91
|
+
<SigmaContainer
|
|
92
|
+
key={key}
|
|
93
|
+
settings={settings}
|
|
94
|
+
className="h-full w-full"
|
|
95
|
+
style={{ background: '#0d0d14' }}
|
|
96
|
+
>
|
|
87
97
|
<GraphLoader graph={graph} />
|
|
88
98
|
<GraphLayout graph={graph} />
|
|
89
99
|
<GraphInteractions onNodeClick={onNodeClick} onNodeHover={onNodeHover} />
|