veoflow 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/veoflow.mjs +1 -1
- package/dist/checkers.mjs +6 -4
- package/dist/veo.mjs +73744 -72544
- package/native/veo-extract.darwin-arm64.node +0 -0
- package/native/veo-extract.darwin-x64.node +0 -0
- package/native/veo-extract.linux-arm64-gnu.node +0 -0
- package/native/veo-extract.linux-x64-gnu.node +0 -0
- package/native/veo-extract.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/web/assets/{index-DDBJiaPK.js → index-B1jlmnXU.js} +2 -2
- package/web/index.html +1 -1
|
@@ -329,10 +329,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
329
329
|
}
|
|
330
330
|
`);i.aPosition=t.getAttribLocation(i,`aPosition`),i.aIndex=t.getAttribLocation(i,`aIndex`),i.aVertType=t.getAttribLocation(i,`aVertType`),i.aTransform=t.getAttribLocation(i,`aTransform`),i.aAtlasId=t.getAttribLocation(i,`aAtlasId`),i.aTex=t.getAttribLocation(i,`aTex`),i.aPointAPointB=t.getAttribLocation(i,`aPointAPointB`),i.aPointCPointD=t.getAttribLocation(i,`aPointCPointD`),i.aLineWidth=t.getAttribLocation(i,`aLineWidth`),i.aColor=t.getAttribLocation(i,`aColor`),i.aCornerRadius=t.getAttribLocation(i,`aCornerRadius`),i.aBorderColor=t.getAttribLocation(i,`aBorderColor`),i.uPanZoomMatrix=t.getUniformLocation(i,`uPanZoomMatrix`),i.uAtlasSize=t.getUniformLocation(i,`uAtlasSize`),i.uBGColor=t.getUniformLocation(i,`uBGColor`),i.uZoom=t.getUniformLocation(i,`uZoom`),i.uTextures=[];for(var a=0;a<this.batchManager.getMaxAtlasesPerBatch();a++)i.uTextures.push(t.getUniformLocation(i,`uTexture${a}`));return i}},{key:`_createVAO`,value:function(){var e=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=e.length/2;var t=this.maxInstances,n=this.gl,r=this.program,i=n.createVertexArray();return n.bindVertexArray(i),Gh(n,`vec2`,r.aPosition,e),this.transformBuffer=qh(n,t,r.aTransform),this.indexBuffer=Kh(n,t,`vec4`,r.aIndex),this.vertTypeBuffer=Kh(n,t,`int`,r.aVertType),this.atlasIdBuffer=Kh(n,t,`int`,r.aAtlasId),this.texBuffer=Kh(n,t,`vec4`,r.aTex),this.pointAPointBBuffer=Kh(n,t,`vec4`,r.aPointAPointB),this.pointCPointDBuffer=Kh(n,t,`vec4`,r.aPointCPointD),this.lineWidthBuffer=Kh(n,t,`vec2`,r.aLineWidth),this.colorBuffer=Kh(n,t,`vec4`,r.aColor),this.cornerRadiusBuffer=Kh(n,t,`vec4`,r.aCornerRadius),this.borderColorBuffer=Kh(n,t,`vec4`,r.aBorderColor),n.bindVertexArray(null),i}},{key:`buffers`,get:function(){var e=this;return this._buffers||=Object.keys(this).filter(function(e){return ht(e,`Buffer`)}).map(function(t){return e[t]}),this._buffers}},{key:`startFrame`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fg.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:`startBatch`,value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:`endFrame`,value:function(){this.endBatch()}},{key:`_isVisible`,value:function(e,t){return e.visible()?t&&t.isVisible?t.isVisible(e):!0:!1}},{key:`drawTexture`,value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,a=r.getRenderTypeOpts(n);if(this._isVisible(e,a)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&a.getTexPickingMode){var o=a.getTexPickingMode(e);if(o===pg.IGNORE)return;if(o==pg.USE_BB){this.drawPickingRectangle(e,t,n);return}}var s=Oe(r.getAtlasInfo(e,n)),c;try{for(s.s();!(c=s.n()).done;){var l=c.value,u=l.atlas,d=l.tex1,f=l.tex2;i.canAddToCurrentBatch(u)||this.endBatch();for(var p=i.getAtlasIndexForBatch(u),m=0,h=[[d,!0],[f,!1]];m<h.length;m++){var g=Pe(h[m],2),_=g[0],v=g[1];if(_.w!=0){var y=this.instanceCount;this.vertTypeBuffer.getView(y)[0]=mg,zh(t,this.indexBuffer.getView(y));var b=this.atlasIdBuffer.getView(y);b[0]=p;var x=this.texBuffer.getView(y);x[0]=_.x,x[1]=_.y,x[2]=_.w,x[3]=_.h;var S=this.transformBuffer.getMatrixView(y);this.setTransformMatrix(e,S,a,l,v),this.instanceCount++,v||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(e){s.e(e)}finally{s.f()}}}},{key:`setTransformMatrix`,value:function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=0;if(n.shapeProps&&n.shapeProps.padding&&(a=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,c=r.tex2,l=s.w/(s.w+c.w);i||(l=1-l);var u=this._getAdjustedBB(o,a,i,l);this._applyTransformMatrix(t,u,n,e)}else{var d=n.getBoundingBox(e),f=this._getAdjustedBB(d,a,!0,1);this._applyTransformMatrix(t,f,n,e)}}},{key:`_applyTransformMatrix`,value:function(e,t,n,r){var i,a;Zh(e);var o=n.getRotation?n.getRotation(r):0;if(o!==0){var s=n.getRotationPoint(r),c=s.x,l=s.y;$h(e,e,[c,l]),eg(e,e,o);var u=n.getRotationOffset(r);i=u.x+(t.xOffset||0),a=u.y+(t.yOffset||0)}else i=t.x1,a=t.y1;$h(e,e,[i,a]),tg(e,e,[t.w,t.h])}},{key:`_getAdjustedBB`,value:function(e,t,n,r){var i=e.x1,a=e.y1,o=e.w,s=e.h,c=e.yOffset;t&&(i-=t,a-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(l=o-u,i+=l,o=u),{x1:i,y1:a,w:o,h:s,xOffset:l,yOffset:c}}},{key:`drawPickingRectangle`,value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=vg,zh(t,this.indexBuffer.getView(i)),Rh([0,0,0],1,this.colorBuffer.getView(i));var a=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,a,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:`drawNode`,value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,a=this._getVertTypeForShape(e,i.shape);if(a===void 0||r.isSimple&&!r.isSimple(e,this.renderTarget)){this.drawTexture(e,t,n);return}var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=a,a===yg||a===bg){var s=r.getBoundingBox(e),c=this._getCornerRadius(e,i.radius,s),l=this.cornerRadiusBuffer.getView(o);l[0]=c,l[1]=c,l[2]=c,l[3]=c,a===bg&&(l[0]=0,l[2]=0)}zh(t,this.indexBuffer.getView(o));var u=this.renderTarget.picking?1:n===`node-body`?e.effectiveOpacity():1,d=this.renderTarget.picking?1:e.pstyle(i.opacity).value*u,f=e.pstyle(i.color).value;Rh(f,d,this.colorBuffer.getView(o));var p=this.lineWidthBuffer.getView(o);if(p[0]=0,p[1]=0,i.border){var m=e.pstyle(`border-width`).value;if(m>0){var h=e.pstyle(`border-color`).value;Rh(h,u*e.pstyle(`border-opacity`).value,this.borderColorBuffer.getView(o));var g=e.pstyle(`border-position`).value;if(g===`inside`)p[0]=0,p[1]=-m;else if(g===`outside`)p[0]=m,p[1]=0;else{var _=m/2;p[0]=_,p[1]=-_}}}var v=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,v,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:`_getVertTypeForShape`,value:function(e,t){switch(e.pstyle(t).value){case`rectangle`:return vg;case`ellipse`:return xg;case`roundrectangle`:case`round-rectangle`:return yg;case`bottom-round-rectangle`:return bg;default:return}}},{key:`_getCornerRadius`,value:function(e,t,n){var r=n.w,i=n.h;if(e.pstyle(t).value===`auto`)return Yi(r,i);var a=e.pstyle(t).pfValue,o=r/2,s=i/2;return Math.min(a,s,o)}},{key:`drawEdgeArrow`,value:function(e,t,n){if(e.visible()){var r=e._private.rscratch,i,a,o;if(n===`source`?(i=r.arrowStartX,a=r.arrowStartY,o=r.srcArrowAngle):(i=r.arrowEndX,a=r.arrowEndY,o=r.tgtArrowAngle),!(isNaN(i)||i==null||isNaN(a)||a==null||isNaN(o)||o==null)&&e.pstyle(n+`-arrow-shape`).value!==`none`){var s=e.pstyle(n+`-arrow-color`).value,c=e.pstyle(`opacity`).value*e.pstyle(`line-opacity`).value,l=e.pstyle(`width`).pfValue,u=e.pstyle(`arrow-scale`).value,d=this.r.getArrowWidth(l,u),f=this.instanceCount,p=this.transformBuffer.getMatrixView(f);Zh(p),$h(p,p,[i,a]),tg(p,p,[d,d]),eg(p,p,o),this.vertTypeBuffer.getView(f)[0]=_g,zh(t,this.indexBuffer.getView(f)),Rh(s,c,this.colorBuffer.getView(f)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`drawEdgeLine`,value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle(`opacity`).value,i=e.pstyle(`line-opacity`).value,a=e.pstyle(`width`).pfValue,o=e.pstyle(`line-color`).value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var c=this.instanceCount;this.vertTypeBuffer.getView(c)[0]=hg,zh(t,this.indexBuffer.getView(c)),Rh(o,s,this.colorBuffer.getView(c));var l=this.lineWidthBuffer.getView(c);l[0]=a;var u=this.pointAPointBBuffer.getView(c);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var d=0;d<n.length-2;d+=2){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=gg,zh(t,this.indexBuffer.getView(f)),Rh(o,s,this.colorBuffer.getView(f));var p=this.lineWidthBuffer.getView(f);p[0]=a;var m=n[d-2],h=n[d-1],g=n[d],_=n[d+1],v=n[d+2],y=n[d+3],b=n[d+4],x=n[d+5];d==0&&(m=2*g-v+.001,h=2*_-y+.001),d==n.length-4&&(b=2*v-g+.001,x=2*y-_+.001);var S=this.pointAPointBBuffer.getView(f);S[0]=m,S[1]=h,S[2]=g,S[3]=_;var C=this.pointCPointDBuffer.getView(f);C[0]=v,C[1]=y,C[2]=b,C[3]=x,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:`_isValidEdge`,value:function(e){var t=e._private.rscratch;return!(t.badLine||t.allpts==null||isNaN(t.allpts[0]))}},{key:`_getEdgePoints`,value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(n.length==4)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:`_getNumSegments`,value:function(e){return Math.min(15,this.maxInstances)}},{key:`_getCurveSegmentPoints`,value:function(e,t){if(e.length==4)return e;for(var n=Array((t+1)*2),r=0;r<=t;r++)if(r==0)n[0]=e[0],n[1]=e[1];else if(r==t)n[r*2]=e[e.length-2],n[r*2+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,r*2)}return n}},{key:`_setCurvePoint`,value:function(e,t,n,r){if(e.length<=2)n[r]=e[0],n[r+1]=e[1];else{for(var i=Array(e.length-2),a=0;a<i.length;a+=2){var o=(1-t)*e[a]+t*e[a+2],s=(1-t)*e[a+1]+t*e[a+3];i[a]=o,i[a+1]=s}return this._setCurvePoint(i,t,n,r)}}},{key:`endBatch`,value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,r=this.instanceCount;if(r!==0){var i=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(i),e.bindVertexArray(t);var a=Oe(this.buffers),o;try{for(a.s();!(o=a.n()).done;)o.value.bufferSubData(r)}catch(e){a.e(e)}finally{a.f()}for(var s=this.batchManager.getAtlases(),c=0;c<s.length;c++)s[c].bufferIfNeeded(e);for(var l=0;l<s.length;l++)e.activeTexture(e.TEXTURE0+l),e.bindTexture(e.TEXTURE_2D,s[l].texture),e.uniform1i(i.uTextures[l],l);e.uniform1f(i.uZoom,Ph(this.r)),e.uniformMatrix3fv(i.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(i.uAtlasSize,this.batchManager.getAtlasSize());var u=Rh(this.bgColor,1);e.uniform4fv(i.uBGColor,u),e.drawArraysInstanced(e.TRIANGLES,0,n,r),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:r,atlasCount:s.length}),this.startBatch()}}},{key:`getDebugInfo`,value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce(function(e,t){return e+t.atlasCount},0),n=this.batchDebugInfo,r=n.reduce(function(e,t){return e+t.count},0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}])}(),Cg={};Cg.initWebgl=function(e,t){var n=this,r=n.data.contexts[n.WEBGL];e.bgColor=wg(n),e.webglTexSize=Math.min(e.webglTexSize,r.getParameter(r.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS)),n.webglDebug=e.webglDebug,n.webglDebugShowAtlases=e.webglDebugShowAtlases,n.pickingFrameBuffer=Jh(r),n.pickingFrameBuffer.needsDraw=!0,n.drawing=new Sg(n,r,e);var i=function(e){return function(t){return n.getTextAngle(t,e)}},a=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},o=function(e){return function(t){return t.pstyle(`${e}-opacity`).value>0}},s=function(e){return e.pstyle(`text-events`).strValue===`yes`?pg.USE_BB:pg.IGNORE},c=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),a=e.outerHeight();return{w:i,h:a,x1:n-i/2,y1:r-a/2}};n.drawing.addAtlasCollection(`node`,{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection(`label`,{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType(`node-body`,{collection:`node`,getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType(`node-body`,{getBoundingBox:c,isSimple:Ih,shapeProps:{shape:`shape`,color:`background-color`,opacity:`background-opacity`,radius:`corner-radius`,border:!0}}),n.drawing.addSimpleShapeRenderType(`node-overlay`,{getBoundingBox:c,isVisible:o(`overlay`),shapeProps:{shape:`overlay-shape`,color:`overlay-color`,opacity:`overlay-opacity`,padding:`overlay-padding`,radius:`overlay-corner-radius`}}),n.drawing.addSimpleShapeRenderType(`node-underlay`,{getBoundingBox:c,isVisible:o(`underlay`),shapeProps:{shape:`underlay-shape`,color:`underlay-color`,opacity:`underlay-opacity`,padding:`underlay-padding`,radius:`underlay-corner-radius`}}),n.drawing.addTextureAtlasRenderType(`label`,{collection:`label`,getTexPickingMode:s,getKey:Eg(t.getLabelKey,null),getBoundingBox:Dg(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:i(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:a(`label`)}),n.drawing.addTextureAtlasRenderType(`edge-source-label`,{collection:`label`,getTexPickingMode:s,getKey:Eg(t.getSourceLabelKey,`source`),getBoundingBox:Dg(t.getSourceLabelBox,`source`),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:i(`source`),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:a(`source-label`)}),n.drawing.addTextureAtlasRenderType(`edge-target-label`,{collection:`label`,getTexPickingMode:s,getKey:Eg(t.getTargetLabelKey,`target`),getBoundingBox:Dg(t.getTargetLabelBox,`target`),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:i(`target`),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:a(`target-label`)});var l=wn(function(){console.log(`garbage collect flag set`),n.data.gc=!0},1e4);n.onUpdateEleCalcs(function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&l()}),Og(n)};function wg(e){var t=e.cy.container();return kt(t&&t.style&&t.style.backgroundColor||`white`)}function Tg(e,t){var n=e._private.rscratch;return pr(n,`labelWrapCachedLines`,t)||[]}var Eg=function(e,t){return function(n){var r=e(n),i=Tg(n,t);return i.length>1?i.map(function(e,t){return`${r}_${t}`}):r}},Dg=function(e,t){return function(n,r){var i=e(n);if(typeof r==`string`){var a=r.indexOf(`_`);if(a>0){var o=Number(r.substring(a+1)),s=Tg(n,t),c=i.h/s.length,l=c*o,u=i.y1+l;return{x1:i.x1,w:i.w,y1:u,h:c,yOffset:l}}}return i}};function Og(e){var t=e.render;e.render=function(n){n||={};var r=e.cy;e.webgl&&(r.zoom()>Sm?(kg(e),t.call(e,n)):(Ag(e),zg(e,n,fg.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,i){return Lg(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var i=e.notify;e.notify=function(t,n){i.call(e,t,n),t===`viewport`||t===`bounds`?e.pickingFrameBuffer.needsDraw=!0:t===`background`&&e.drawing.invalidate(n,{type:`node-body`})}}function kg(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Ag(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}function jg(e){var t=e.canvasWidth,n=e.canvasHeight,r=Nh(e),i=r.pan,a=r.zoom,o=Xh();$h(o,o,[i.x,i.y]),tg(o,o,[a,a]);var s=Xh();ng(s,t,n);var c=Xh();return Qh(c,s,o),c}function Mg(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=Nh(e),a=i.pan,o=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(a.x,a.y),t.scale(o,o)}function Ng(e,t){e.drawSelectionRectangle(t,function(t){return Mg(e,t)})}function Pg(e){var t=e.data.contexts[e.NODE];t.save(),Mg(e,t),t.strokeStyle=`rgba(0, 0, 0, 0.3)`,t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Fg(e){var t=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),a=e.data.contexts[e.NODE],o=i.atlases,s=0;s<o.length;s++){var c=o[s].canvas;if(c){var l=c.width,u=c.height,d=l*s,f=c.height*r,p=.4;a.save(),a.scale(p,p),a.drawImage(c,d,f),a.strokeStyle=`black`,a.rect(d,f,l,u),a.stroke(),a.restore()}}},n=0;t(e.drawing,`node`,n++),t(e.drawing,`label`,n++)}function Ig(e,t,n,r,i){var a,o,s,c,l=Nh(e),u=l.pan,d=l.zoom,f=Pe(Fh(e,u,d,t,n),2),p=f[0],m=f[1],h=6;if(a=p-h/2,o=m-h/2,s=h,c=h,s===0||c===0)return[];var g=e.data.contexts[e.WEBGL];g.bindFramebuffer(g.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(g.viewport(0,0,g.canvas.width,g.canvas.height),zg(e,null,fg.PICKING),e.pickingFrameBuffer.needsDraw=!1);var _=s*c,v=new Uint8Array(_*4);g.readPixels(a,o,s,c,g.RGBA,g.UNSIGNED_BYTE,v),g.bindFramebuffer(g.FRAMEBUFFER,null);for(var y=new Set,b=0;b<_;b++){var x=Bh(v.slice(b*4,b*4+4))-1;x>=0&&y.add(x)}return y}function Lg(e,t,n){var r=Ig(e,t,n),i=e.getCachedZSortedEles(),a,o,s=Oe(r),c;try{for(s.s();!(c=s.n()).done;){var l=i[c.value];if(!a&&l.isNode()&&(a=l),!o&&l.isEdge()&&(o=l),a&&o)break}}catch(e){s.e(e)}finally{s.f()}return[a,o].filter(Boolean)}function Rg(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,`node-underlay`),r.drawNode(n,t,`node-body`),r.drawTexture(n,t,`label`),r.drawNode(n,t,`node-overlay`)):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,`source`),r.drawEdgeArrow(n,t,`target`),r.drawTexture(n,t,`label`),r.drawTexture(n,t,`edge-source-label`),r.drawTexture(n,t,`edge-target-label`))}function zg(e,t,n){var r;e.webglDebug&&(r=performance.now());var i=e.drawing,a=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&Ng(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=jg(e),c=e.getCachedZSortedEles();if(a=c.length,i.startFrame(s,n),n.screen){for(var l=0;l<c.nondrag.length;l++)Rg(e,l,c.nondrag[l]);for(var u=0;u<c.drag.length;u++)Rg(e,u,c.drag[u])}else if(n.picking)for(var d=0;d<c.length;d++)Rg(e,d,c[d]);i.endFrame(),n.screen&&e.webglDebugShowAtlases&&(Pg(e),Fg(e)),e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1}if(e.webglDebug){var f=performance.now(),p=Math.ceil(f-r),m=i.getDebugInfo(),h=[`${a} elements`,`${m.totalInstances} instances`,`${m.batchCount} batches`,`${m.totalAtlases} atlases`,`${m.wrappedCount} wrapped textures`,`${m.simpleCount} simple shapes`].join(`, `);console.log(`WebGL (${n.name}) - frame time ${p}ms`),console.log(`Totals:`),console.log(` ${h}`),console.log(`Texture Atlases Used:`);var g=m.atlasInfo,_=Oe(g),v;try{for(_.s();!(v=_.n()).done;){var y=v.value;console.log(` ${y.type}: ${y.keyCount} keys, ${y.atlasCount} atlases`)}}catch(e){_.e(e)}finally{_.f()}console.log(``)}e.data.gc&&(console.log(`Garbage Collect!`),e.data.gc=!1,i.gc())}var Bg={};Bg.drawPolygonPath=function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var c=1;c<a.length/2;c++)e.lineTo(t+o*a[c*2],n+s*a[c*2+1]);e.closePath()},Bg.drawRoundPolygonPath=function(e,t,n,r,i,a,o){o.forEach(function(t){return Bp(e,t)}),e.closePath()},Bg.drawRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?Yi(r,i):Math.min(a,s,o);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+o,n-s,t+o,n,c),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.arcTo(t-o,n-s,t,n-s,c),e.lineTo(t,n-s),e.closePath()},Bg.drawBottomRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?Yi(r,i):a;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+o,n-s),e.lineTo(t+o,n),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.lineTo(t-o,n-s),e.lineTo(t,n-s),e.closePath()},Bg.drawCutRectanglePath=function(e,t,n,r,i,a,o){var s=r/2,c=i/2,l=o===`auto`?Zi():o;e.beginPath&&e.beginPath(),e.moveTo(t-s+l,n-c),e.lineTo(t+s-l,n-c),e.lineTo(t+s,n-c+l),e.lineTo(t+s,n+c-l),e.lineTo(t+s-l,n+c),e.lineTo(t-s+l,n+c),e.lineTo(t-s,n+c-l),e.lineTo(t-s,n-c+l),e.closePath()},Bg.drawBarrelPath=function(e,t,n,r,i){var a=r/2,o=i/2,s=t-a,c=t+a,l=n-o,u=n+o,d=$i(r,i),f=d.widthOffset,p=d.heightOffset,m=d.ctrlPtOffsetPct*f;e.beginPath&&e.beginPath(),e.moveTo(s,l+p),e.lineTo(s,u-p),e.quadraticCurveTo(s+m,u,s+f,u),e.lineTo(c-f,u),e.quadraticCurveTo(c-m,u,c,u-p),e.lineTo(c,l+p),e.quadraticCurveTo(c-m,l,c-f,l),e.lineTo(s+f,l),e.quadraticCurveTo(s+m,l,s,l+p),e.closePath()};for(var Vg=Math.sin(0),Hg=Math.cos(0),Ug={},Wg={},Gg=Math.PI/40,Kg=0*Math.PI;Kg<2*Math.PI;Kg+=Gg)Ug[Kg]=Math.sin(Kg),Wg[Kg]=Math.cos(Kg);Bg.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var a,o,s=r/2,c=i/2,l=0*Math.PI;l<2*Math.PI;l+=Gg)a=t-s*Ug[l]*Vg+s*Wg[l]*Hg,o=n+c*Wg[l]*Vg+c*Ug[l]*Hg,l===0?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var qg={};qg.createBuffer=function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,[n,n.getContext(`2d`)]},qg.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],a=e.full?Math.ceil(n.h):r[3],o=Y(e.maxWidth)||Y(e.maxHeight),s=this.getPixelRatio(),c=1;if(e.scale!==void 0)i*=e.scale,a*=e.scale,c=e.scale;else if(o){var l=1/0,u=1/0;Y(e.maxWidth)&&(l=c*e.maxWidth/i),Y(e.maxHeight)&&(u=c*e.maxHeight/a),c=Math.min(l,u),i*=c,a*=c}o||(i*=s,a*=s,c*=s);var d=document.createElement(`canvas`);d.width=i,d.height=a,d.style.width=i+`px`,d.style.height=a+`px`;var f=d.getContext(`2d`);if(i>0&&a>0){f.clearRect(0,0,i,a),f.globalCompositeOperation=`source-over`;var p=this.getCachedZSortedEles();if(e.full)f.translate(-n.x1*c,-n.y1*c),f.scale(c,c),this.drawElements(f,p),f.scale(1/c,1/c),f.translate(n.x1*c,n.y1*c);else{var m=t.pan(),h={x:m.x*c,y:m.y*c};c*=t.zoom(),f.translate(h.x,h.y),f.scale(c,c),this.drawElements(f,p),f.scale(1/c,1/c),f.translate(-h.x,-h.y)}e.bg&&(f.globalCompositeOperation=`destination-over`,f.fillStyle=e.bg,f.rect(0,0,i,a),f.fill())}return d};function Jg(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);return new Blob([r],{type:t})}function Yg(e){var t=e.indexOf(`,`);return e.substr(t+1)}function Xg(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case`blob-promise`:return new jo(function(r,i){try{t.toBlob(function(e){e==null?i(Error("`canvas.toBlob()` sent a null value in its callback")):r(e)},n,e.quality)}catch(e){i(e)}});case`blob`:return Jg(Yg(r()),n);case`base64`:return Yg(r());default:return r()}}qg.png=function(e){return Xg(e,this.bufferCanvasImage(e),`image/png`)},qg.jpg=function(e){return Xg(e,this.bufferCanvasImage(e),`image/jpeg`)};var Zg={};Zg.nodeShapeImpl=function(e,t,n,r,i,a,o,s){switch(e){case`ellipse`:return this.drawEllipsePath(t,n,r,i,a);case`polygon`:return this.drawPolygonPath(t,n,r,i,a,o);case`round-polygon`:return this.drawRoundPolygonPath(t,n,r,i,a,o,s);case`roundrectangle`:case`round-rectangle`:return this.drawRoundRectanglePath(t,n,r,i,a,s);case`cutrectangle`:case`cut-rectangle`:return this.drawCutRectanglePath(t,n,r,i,a,o,s);case`bottomroundrectangle`:case`bottom-round-rectangle`:return this.drawBottomRoundRectanglePath(t,n,r,i,a,s);case`barrel`:return this.drawBarrelPath(t,n,r,i,a)}};var Qg=e_,$g=e_.prototype;$g.CANVAS_LAYERS=3,$g.SELECT_BOX=0,$g.DRAG=1,$g.NODE=2,$g.WEBGL=3,$g.CANVAS_TYPES=[`2d`,`2d`,`2d`,`webgl2`],$g.BUFFER_COUNT=3,$g.TEXTURE_BUFFER=0,$g.MOTIONBLUR_BUFFER_NODE=1,$g.MOTIONBLUR_BUFFER_DRAG=2;function e_(e){var t=this,n=t.cy.window().document;e.webgl&&($g.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log(`webgl rendering enabled`)),t.data={canvases:Array($g.CANVAS_LAYERS),contexts:Array($g.CANVAS_LAYERS),canvasNeedsRedraw:Array($g.CANVAS_LAYERS),bufferCanvases:Array($g.BUFFER_COUNT),bufferContexts:Array($g.CANVAS_LAYERS)};var r=`-webkit-tap-highlight-color`,i=`rgba(0,0,0,0)`;t.data.canvasContainer=n.createElement(`div`);var a=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=i,a.position=`relative`,a.zIndex=`0`,a.overflow=`hidden`;var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=i;var s={"-webkit-user-select":`none`,"-moz-user-select":`-moz-none`,"user-select":`none`,"-webkit-tap-highlight-color":`rgba(0,0,0,0)`,"outline-style":`none`};lt()&&(s[`-ms-touch-action`]=`none`,s[`touch-action`]=`none`);for(var c=0;c<$g.CANVAS_LAYERS;c++){var l=t.data.canvases[c]=n.createElement(`canvas`),u=$g.CANVAS_TYPES[c];t.data.contexts[c]=l.getContext(u),t.data.contexts[c]||er(`Could not create canvas of type `+u),Object.keys(s).forEach(function(e){l.style[e]=s[e]}),l.style.position=`absolute`,l.setAttribute(`data-id`,`layer`+c),l.style.zIndex=String($g.CANVAS_LAYERS-c),t.data.canvasContainer.appendChild(l),t.data.canvasNeedsRedraw[c]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[$g.NODE].setAttribute(`data-id`,`layer`+$g.NODE+`-node`),t.data.canvases[$g.SELECT_BOX].setAttribute(`data-id`,`layer`+$g.SELECT_BOX+`-selectbox`),t.data.canvases[$g.DRAG].setAttribute(`data-id`,`layer`+$g.DRAG+`-drag`),t.data.canvases[$g.WEBGL]&&t.data.canvases[$g.WEBGL].setAttribute(`data-id`,`layer`+$g.WEBGL+`-webgl`);for(var c=0;c<$g.BUFFER_COUNT;c++)t.data.bufferCanvases[c]=n.createElement(`canvas`),t.data.bufferContexts[c]=t.data.bufferCanvases[c].getContext(`2d`),t.data.bufferCanvases[c].style.position=`absolute`,t.data.bufferCanvases[c].setAttribute(`data-id`,`buffer`+c),t.data.bufferCanvases[c].style.zIndex=String(-c-1),t.data.bufferCanvases[c].style.visibility=`hidden`;t.pathsEnabled=!0;var d=ui(),f=function(e){return{x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2}},p=function(e){return{x:-e.w/2,y:-e.h/2}},m=function(e){var t=e[0]._private;return t.oldBackgroundTimestamp!==t.backgroundTimestamp},h=function(e){return e[0]._private.nodeKey},g=function(e){return e[0]._private.labelStyleKey},_=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},y=function(e,n,r,i,a){return t.drawElement(e,n,r,!1,!1,a)},b=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`main`,a)},x=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`source`,a)},S=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`target`,a)},C=function(e){return e.boundingBox(),e[0]._private.bodyBounds},w=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||d},T=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||d},E=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||d},D=function(e,t){return t},O=function(e){return f(C(e))},k=function(e,t,n){var r=e?e+`-`:``;return{x:t.x+n.pstyle(r+`text-margin-x`).pfValue,y:t.y+n.pstyle(r+`text-margin-y`).pfValue}},A=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},j=function(e){return k(``,A(e,`labelX`,`labelY`),e)},M=function(e){return k(`source`,A(e,`sourceLabelX`,`sourceLabelY`),e)},N=function(e){return k(`target`,A(e,`targetLabelX`,`targetLabelY`),e)},P=function(e){return p(C(e))},F=function(e){return p(T(e))},I=function(e){return p(E(e))},L=function(e){var t=w(e),n=p(w(e));if(e.isNode()){switch(vu(e.pstyle(`text-halign`).value)){case`left`:n.x=-t.w-(t.leftPad||0);break;case`right`:n.x=-(t.rightPad||0)}switch(yu(e.pstyle(`text-valign`).value)){case`top`:n.y=-t.h-(t.topPad||0);break;case`bottom`:n.y=-(t.botPad||0)}}return n},R=t.data.eleTxrCache=new Rm(t,{getKey:h,doesEleInvalidateKey:m,drawElement:y,getBoundingBox:C,getRotationPoint:O,getRotationOffset:P,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),z=t.data.lblTxrCache=new Rm(t,{getKey:g,drawElement:b,getBoundingBox:w,getRotationPoint:j,getRotationOffset:L,isVisible:D}),B=t.data.slbTxrCache=new Rm(t,{getKey:_,drawElement:x,getBoundingBox:T,getRotationPoint:M,getRotationOffset:F,isVisible:D}),V=t.data.tlbTxrCache=new Rm(t,{getKey:v,drawElement:S,getBoundingBox:E,getRotationPoint:N,getRotationOffset:I,isVisible:D}),H=t.data.lyrTxrCache=new th(t);t.onUpdateEleCalcs(function(e,t){R.invalidateElements(t),z.invalidateElements(t),B.invalidateElements(t),V.invalidateElements(t),H.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var U=function(e){for(var t=0;t<e.length;t++)H.enqueueElementRefinement(e[t].ele)};R.onDequeue(U),z.onDequeue(U),B.onDequeue(U),V.onDequeue(U),e.webgl&&t.initWebgl(e,{getStyleKey:h,getLabelKey:g,getSourceLabelKey:_,getTargetLabelKey:v,drawElement:y,drawLabel:b,drawSourceLabel:x,drawTargetLabel:S,getElementBox:C,getLabelBox:w,getSourceLabelBox:T,getTargetLabelBox:E,getElementRotationPoint:O,getElementRotationOffset:P,getLabelRotationPoint:j,getSourceLabelRotationPoint:M,getTargetLabelRotationPoint:N,getLabelRotationOffset:L,getSourceLabelRotationOffset:F,getTargetLabelRotationOffset:I})}$g.redrawHint=function(e,t){var n=this;switch(e){case`eles`:n.data.canvasNeedsRedraw[$g.NODE]=t;break;case`drag`:n.data.canvasNeedsRedraw[$g.DRAG]=t;break;case`select`:n.data.canvasNeedsRedraw[$g.SELECT_BOX]=t;break;case`gc`:n.data.gc=!0}};var t_=typeof Path2D<`u`;$g.path2dEnabled=function(e){if(e===void 0)return this.pathsEnabled;this.pathsEnabled=!!e},$g.usePaths=function(){return t_&&this.pathsEnabled},$g.setImgSmoothing=function(e,t){e.imageSmoothingEnabled==null?(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t):e.imageSmoothingEnabled=t},$g.getImgSmoothing=function(e){return e.imageSmoothingEnabled==null?e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled:e.imageSmoothingEnabled},$g.makeOffscreenCanvas=function(e,t){var n;return(typeof OffscreenCanvas>`u`?`undefined`:Re(OffscreenCanvas))===`undefined`?(n=this.cy.window().document.createElement(`canvas`),n.width=e,n.height=t):n=new OffscreenCanvas(e,t),n},[ah,fh,yh,xh,Sh,Th,Dh,Cg,Bg,qg,Zg].forEach(function(e){X($g,e)});var n_=[{type:`layout`,extensions:dp},{type:`renderer`,extensions:[{name:`null`,impl:fp},{name:`base`,impl:pm},{name:`canvas`,impl:Qg}]}],r_={},i_={};function a_(e,t,n){var r=n,i=function(n){nr("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if(e===`core`){if(Cf.prototype[t])return i(t);Cf.prototype[t]=n}else if(e===`collection`){if(Id.prototype[t])return i(t);Id.prototype[t]=n}else if(e===`layout`){for(var a=function(e){this.options=e,n.call(this,e),Ye(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.prototype),s=[],c=0;c<s.length;c++){var l=s[c];o[l]=o[l]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var u=n.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return u?u.call(this):this.emit(`layoutstop`),this},o.destroy||=function(){return this},o.cy=function(){return this._private.cy};var d=function(e){return e._private.cy},f={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};X(o,{createEmitter:function(){return this._private.emitter=new id(f,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),Al.eventAliasesOn(o),r=a}else if(e===`renderer`&&t!==`null`&&t!==`base`){var p=o_(`renderer`,`base`),m=p.prototype,h=n,g=n.prototype,_=function(){p.apply(this,arguments),h.apply(this,arguments)},v=_.prototype;for(var y in m){var b=m[y];if(g[y]!=null)return i(y);v[y]=b}for(var x in g)v[x]=g[x];m.clientFunctions.forEach(function(e){v[e]=v[e]||function(){er("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=_}else if(e===`__proto__`||e===`constructor`||e===`prototype`)return er(e+` is an illegal type to be registered, possibly lead to prototype pollutions`);return jt({map:r_,keys:[e,t],value:r})}function o_(e,t){return Mt({map:r_,keys:[e,t]})}function s_(e,t,n,r,i){return jt({map:i_,keys:[e,t,n,r],value:i})}function c_(e,t,n,r){return Mt({map:i_,keys:[e,t,n,r]})}var l_=function(){if(arguments.length===2)return o_.apply(null,arguments);if(arguments.length===3)return a_.apply(null,arguments);if(arguments.length===4)return c_.apply(null,arguments);if(arguments.length===5)return s_.apply(null,arguments);er(`Invalid extension access syntax`)};Cf.prototype.extension=l_,n_.forEach(function(e){e.extensions.forEach(function(t){a_(e.type,t.name,t.impl)})});var u_=function(){if(!(this instanceof u_))return new u_;this.length=0},d_=u_.prototype;d_.instanceString=function(){return`stylesheet`},d_.selector=function(e){var t=this.length++;return this[t]={selector:e,properties:[]},this},d_.css=function(e,t){var n=this.length-1;if(J(e))this[n].properties.push({name:e,value:t});else if(Ye(e))for(var r=e,i=Object.keys(r),a=0;a<i.length;a++){var o=i[a],s=r[o];if(s!=null){var c=_f.properties[o]||_f.properties[ft(o)];if(c!=null){var l=c.name,u=s;this[n].properties.push({name:l,value:u})}}}return this},d_.style=d_.css,d_.generateStyle=function(e){var t=new _f(e);return this.appendToStyle(t)},d_.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var a=0;a<i.length;a++){var o=i[a];e.css(o.name,o.value)}}return e};var f_=`3.34.3`,p_=function(e){if(e===void 0&&(e={}),Ye(e))return new Cf(e);if(J(e))return l_.apply(l_,arguments)};p_.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(p_),e.apply(null,t),this},p_.warnings=function(e){return tr(e)},p_.version=f_,p_.stylesheet=p_.Stylesheet=u_;function m_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h_(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=__(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
331
331
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function g_(e){"@babel/helpers - typeof";return g_=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},g_(e)}function __(e,t){if(e){if(typeof e==`string`)return m_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m_(e,t):void 0}}var v_={nodeSep:void 0,edgeSep:void 0,rankSep:void 0,rankDir:void 0,align:void 0,acyclicer:void 0,ranker:void 0,minLen:function(e){return 1},edgeWeight:function(e){return 1},fit:!0,padding:30,spacingFactor:void 0,nodeDimensionsIncludeLabels:!1,useDagreEdgeControlPoints:!1,automaticDagreEdgeStyle:!1,dagreEdgeStyle:{"curve-style":`unbundled-bezier`,"control-point-weights":function(e){return e.scratch(`controlPointWeights`)},"control-point-distances":function(e){return e.scratch(`controlPointDistances`)},"edge-distances":`intersection`,"edge-ends-overlap":!1},animate:!1,animateFilter:function(e,t){return!0},animationDuration:500,animationEasing:void 0,boundingBox:void 0,transform:function(e,t){return t},ready:function(){},sort:void 0,stop:function(){}},y_=Object.assign==null?function(e){return[...arguments].slice(1).forEach(function(t){Object.keys(t).forEach(function(n){return e[n]=t[n]})}),e}:Object.assign.bind(Object),b_=Object.defineProperty,x_=(e,t,n)=>t in e?b_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S_=(e,t)=>{for(var n in t)b_(e,n,{get:t[n],enumerable:!0})},C_=(e,t,n)=>x_(e,t+``,n),w_={};S_(w_,{Graph:()=>D_,alg:()=>z_,json:()=>P_,version:()=>N_});var T_=Object.defineProperty,E_=(e,t)=>{for(var n in t)T_(e,n,{get:t[n],enumerable:!0})},D_=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let t of this.successors(e))n.add(t);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=A_(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=j_(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,O_(this._preds[a],i),O_(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?M_(this._isDirected,e):A_(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r==`object`?r:{label:r}}hasEdge(e,t,n){return(arguments.length===1?M_(this._isDirected,e):A_(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?M_(this._isDirected,e):A_(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],k_(this._preds[t],e),k_(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function O_(e,t){e[t]?e[t]++:e[t]=1}function k_(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function A_(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function j_(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function M_(e,t){return A_(e,t.v,t.w,t.name)}var N_=`4.0.1`,P_={};E_(P_,{read:()=>R_,write:()=>F_});function F_(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:I_(e),edges:L_(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function I_(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function L_(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function R_(e){let t=new D_(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var z_={};E_(z_,{CycleException:()=>ev,bellmanFord:()=>V_,components:()=>U_,dijkstra:()=>K_,dijkstraAll:()=>J_,findCycles:()=>X_,floydWarshall:()=>Q_,isAcyclic:()=>nv,postorder:()=>ov,preorder:()=>sv,prim:()=>cv,shortestPaths:()=>lv,tarjan:()=>Y_,topsort:()=>tv});var B_=()=>1;function V_(e,t,n,r){return H_(e,String(t),n||B_,r||function(t){return e.outEdges(t)})}function H_(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=n(e);i[e.v].distance+t<i[e.w].distance&&(i[e.w]={distance:i[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function U_(e){let t={},n=[],r;function i(n){n in t||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var W_=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},G_=()=>1;function K_(e,t,n,r){return q_(e,String(t),n||G_,r||function(t){return e.outEdges(t)})}function q_(e,t,n,r){let i={},a=new W_,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t],c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0&&(o=a.removeMin(),s=i[o],s.distance!==1/0);)r(o).forEach(c);return i}function J_(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=K_(e,i,t,n),r},{})}function Y_(e){let t=0,n=[],r={},i=[];function a(o){let s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){e in r?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){let e=[],t;do t=n.pop(),r[t].onStack=!1,e.push(t);while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function X_(e){return Y_(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Z_=()=>1;function Q_(e,t,n){return $_(e,t||Z_,n||function(t){return e.outEdges(t)})}function $_(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){let t=r[e];i.forEach(function(n){let a=r[n];i.forEach(function(n){let r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}var ev=class extends Error{constructor(...e){super(...e)}};function tv(e){let t={},n={},r=[];function i(a){if(a in n)throw new ev;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new ev;return r}function nv(e){try{tv(e)}catch(e){if(e instanceof ev)return!1;throw e}return!0}function rv(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=iv(e,t,n===`post`,o,a,r,i)}),i}function iv(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=iv(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function av(e,t,n){return rv(e,t,n,function(e,t){return e.push(t),e},[])}function ov(e,t){return av(e,t,`post`)}function sv(e,t){return av(e,t,`pre`)}function cv(e,t){let n=new D_,r={},i=new W_,a;function o(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(o!==void 0){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){i.add(e,1/0),n.setNode(e)}),i.decrease(e.nodes()[0],0);let s=!1;for(;i.size()>0;){if(a=i.removeMin(),a in r)n.setEdge(a,r[a]);else{if(s)throw Error(`Input graph is not connected: `+e);s=!0}e.nodeEdges(a).forEach(o)}return n}function lv(e,t,n,r){return uv(e,t,n,r??(t=>e.outEdges(t)??[]))}function uv(e,t,n,r){if(n===void 0)return K_(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=r(a[o]);for(let e=0;e<s.length;e++){let t=s[e],r=t.v===a[o]?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return V_(e,t,n,r)}return K_(e,t,n,r)}function dv(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Dv(r);return n.dummy=t,e.setNode(i,n),i}function fv(e){let t=new D_().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function pv(e){let t=new D_({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function mv(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function hv(e){let t=Ov(Sv(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function gv(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=xv(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function _v(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=xv(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function vv(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),dv(e,`border`,i,t)}function yv(e,t=bv){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var bv=65535;function xv(e,t){return t.length>bv?e(...yv(t).map(t=>e(...t))):e(...t)}function Sv(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return xv(Math.max,t)}function Cv(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function wv(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function Tv(e,t){return t()}var Ev=0;function Dv(e){return e+(``+ ++Ev)}function Ov(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function kv(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Av(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function jv(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Mv=`\0`,Nv=`3.0.0`,Pv=class{constructor(){C_(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Fv(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Fv(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Iv)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Fv(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Iv(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Lv=Pv,Rv=()=>1;function zv(e,t){if(e.nodeCount()<=1)return[];let n=Hv(e,t||Rv);return Bv(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function Bv(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Vv(e,t,n,o);for(;o=i.dequeue();)Vv(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(Vv(e,t,n,o,!0)||[]);break}}}return r}function Vv(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,Uv(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,Uv(t,n,o)}),e.removeNode(r.v),o}function Hv(e,t){let n=new D_,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=Wv(i+r+3).map(()=>new Lv),o=r+1;return n.nodes().forEach(e=>{Uv(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function Uv(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Wv(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function Gv(e){(e.graph().acyclicer===`greedy`?zv(e,t(e)):Kv(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Dv(`rev`))});function t(e){return t=>e.edge(t).weight}}function Kv(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function qv(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Jv(e){e.graph().dummyChains=[],e.edges().forEach(t=>Yv(e,t))}function Yv(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=dv(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Xv(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Zv(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=xv(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function Qv(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var $v=ey;function ey(e){let t=new D_({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;ty(t,e)<i&&(a=ny(t,e),a);)o=t.hasNode(a.v)?Qv(e,a):-Qv(e,a),ry(t,e,o);return t}function ty(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!Qv(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function ny(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=Qv(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function ry(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:iy,postorder:ay}=z_,oy=sy;sy.initLowLimValues=dy,sy.initCutValues=cy,sy.calcCutValue=uy,sy.leaveEdge=py,sy.enterEdge=my,sy.exchangeEdges=hy;function sy(e){e=fv(e),Zv(e);let t=$v(e);dy(t),cy(t,e);let n,r;for(;n=py(t);)r=my(t,e,n),hy(t,e,n,r)}function cy(e,t){let n=ay(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>ly(e,t,n))}function ly(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=uy(e,t,n)}function uy(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,_y(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function dy(e,t){arguments.length<2&&(t=e.nodes()[0]),fy(e,{},1,t)}function fy(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=fy(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function py(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function my(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===vy(e,e.node(t.v),s)&&c!==vy(e,e.node(t.w),s)).reduce((e,n)=>Qv(t,n)<Qv(t,e)?n:e)}function hy(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),dy(e),cy(e,t),gy(e,t)}function gy(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=iy(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function _y(e,t,n){return e.hasEdge(t,n)}function vy(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var yy=by;function by(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Cy(e);break;case`tight-tree`:Sy(e);break;case`longest-path`:xy(e);break;case`none`:break;default:Cy(e)}}var xy=Zv;function Sy(e){Zv(e),$v(e)}function Cy(e){oy(e)}var wy=Ty;function Ty(e){let t=Dy(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Ey(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Ey(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function Dy(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Mv).forEach(r),t}function Oy(e){let t=dv(e,`root`,{},`_root`),n=Ay(e),r=Object.values(n),i=xv(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=jy(e)+1;e.children(Mv).forEach(r=>ky(e,t,a,o,i,n,r)),e.graph().nodeRankFactor=a}function ky(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=vv(e,`_bt`),l=vv(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{ky(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Ay(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Mv).forEach(e=>n(e,1)),t}function jy(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function My(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Ny=Py;function Py(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)Fy(e,`borderLeft`,`_bl`,n,i,t),Fy(e,`borderRight`,`_br`,n,i,t)}}e.children(Mv).forEach(t)}function Fy(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=dv(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Iy(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Ry(e)}function Ly(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&By(e),(t===`lr`||t===`rl`)&&(Hy(e),Ry(e))}function Ry(e){e.nodes().forEach(t=>zy(e.node(t))),e.edges().forEach(t=>zy(e.edge(t)))}function zy(e){let t=e.width;e.width=e.height,e.height=t}function By(e){e.nodes().forEach(t=>Vy(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Vy),Object.hasOwn(r,`y`)&&Vy(r)})}function Vy(e){e.y=-e.y}function Hy(e){e.nodes().forEach(t=>Uy(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Uy),Object.hasOwn(r,`x`)&&Uy(r)})}function Uy(e){let t=e.x;e.x=e.y,e.y=t}function Wy(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),r=n.map(t=>e.node(t).rank),i=Ov(xv(Math.max,r)+1).map(()=>[]);function a(n){if(t[n])return;t[n]=!0;let r=e.node(n);i[r.rank].push(n);let o=e.successors(n);o&&o.forEach(a)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(a),i}function Gy(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Ky(e,t[r-1],t[r]);return n}function Ky(e,t,n){let r=jv(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function qy(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Jy(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Yy(Object.values(n).filter(e=>!e.indegree))}function Yy(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Xy(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>kv(e,[`vs`,`i`,`barycenter`,`weight`]))}function Xy(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Zy(e,t){let n=Cv(e,e=>Object.hasOwn(e,`barycenter`)),r=n.lhs,i=n.rhs.sort((e,t)=>t.i-e.i),a=[],o=0,s=0,c=0;r.sort($y(!!t)),c=Qy(a,i,c),r.forEach(e=>{c+=e.vs.length,a.push(e.vs),o+=e.barycenter*e.weight,s+=e.weight,c=Qy(a,i,c)});let l={vs:a.flat(1)};return s&&(l.barycenter=o/s,l.weight=s),l}function Qy(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function $y(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function eb(e,t,n,r){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=i.filter(e=>e!==o&&e!==s));let l=qy(e,i);l.forEach(t=>{if(e.children(t.v).length){let i=eb(e,t.v,n,r);c[t.v]=i,Object.hasOwn(i,`barycenter`)&&nb(t,i)}});let u=Jy(l,n);tb(u,c);let d=Zy(u,r);if(o&&s){d.vs=[o,d.vs,s].flat(1);let t=e.predecessors(o);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(s),i=e.node(r[0]);Object.hasOwn(d,`barycenter`)||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+n.order+i.order)/(d.weight+2),d.weight+=2}}return d}function tb(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function nb(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function rb(e,t,n,r){r||=e.nodes();let i=ib(e),a=new D_({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function ib(e){let t;for(;e.hasNode(t=Dv(`_root`)););return t}function ab(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function ob(e,t={}){if(typeof t.customOrder==`function`){t.customOrder(e,ob);return}let n=Sv(e),r=sb(e,Ov(1,n+1),`inEdges`),i=sb(e,Ov(n-1,-1,-1),`outEdges`),a=Wy(e);if(lb(e,a),t.disableOptimalOrderHeuristic)return;let o=1/0,s,c=t.constraints||[];for(let t=0,n=0;n<4;++t,++n){cb(t%2?r:i,t%4>=2,c),a=hv(e);let l=Gy(e,a);l<o?(n=0,s=Object.assign({},a),o=l):l===o&&(s=structuredClone(a))}lb(e,s)}function sb(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return rb(e,t,n,r.get(t)||[])})}function cb(e,t,n){let r=new D_;e.forEach(function(e){n.forEach(e=>r.setEdge(e.left,e.right));let i=e.graph().root,a=eb(e,i,r,t);a.vs.forEach((t,n)=>e.node(t).order=n),ab(e,r,a.vs)})}function lb(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function ub(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=fb(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&pb(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function db(e,t){let n={};function r(t,r,i,a,o){Ov(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&pb(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function fb(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function pb(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function mb(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function hb(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s&&s.length){let r=s.sort((e,t)=>{let n=o[e],r=o[t];return(n===void 0?0:n)-(r===void 0?0:r)}),c=(r.length-1)/2;for(let s=Math.floor(c),l=Math.ceil(c);s<=l;++s){let c=r[s];if(c===void 0)continue;let l=o[c];if(l!==void 0&&a[e]===e&&t<l&&!mb(n,e,c)){let n=i[c];n!==void 0&&(a[c]=e,a[e]=i[e]=n,t=l)}}}})}),{root:i,align:a}}function gb(e,t,n,r,i=!1){let a={},o=_b(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function _b(e,t,n,r){let i=new D_,a=e.graph(),o=Sb(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function vb(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Cb(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function yb(e,t){let n=Object.values(t),r=xv(Math.min,n),i=xv(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-xv(Math.min,c);a!==`l`&&(l=i-xv(Math.max,c)),l&&(e[o]=Av(s,e=>e+l))})})}function bb(e,t=void 0){let n=e.ul;return n?Av(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function xb(e){let t=hv(e),n=Object.assign(ub(e,t),db(e,t)),r={},i;return[`u`,`d`].forEach(a=>{i=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(i=i.map(e=>Object.values(e).reverse()));let o=hb(e,i,n,t=>(a===`u`?e.predecessors(t):e.successors(t))||[]),s=gb(e,i,o.root,o.align,t===`r`);t===`r`&&(s=Av(s,e=>-e)),r[a+t]=s})}),yb(r,vb(e,r)),bb(r,e.graph().align)}function Sb(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Cb(e,t){return e.node(t).width}function wb(e){e=pv(e),Tb(e),Object.entries(xb(e)).forEach(([t,n])=>e.node(t).x=n)}function Tb(e){let t=hv(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}function Eb(e,t={}){let n=t.debugTiming?wv:Tv;return n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>Lb(e));return n(` runLayout`,()=>Db(r,n,t)),n(` updateInputGraph`,()=>Ob(e,r)),r})}function Db(e,t,n){t(` makeSpaceForEdgeLabels`,()=>Rb(e)),t(` removeSelfEdges`,()=>qb(e)),t(` acyclic`,()=>Gv(e)),t(` nestingGraph.run`,()=>Oy(e)),t(` rank`,()=>yy(pv(e))),t(` injectEdgeLabelProxies`,()=>zb(e)),t(` removeEmptyRanks`,()=>_v(e)),t(` nestingGraph.cleanup`,()=>My(e)),t(` normalizeRanks`,()=>gv(e)),t(` assignRankMinMax`,()=>Bb(e)),t(` removeEdgeLabelProxies`,()=>Vb(e)),t(` normalize.run`,()=>Jv(e)),t(` parentDummyChains`,()=>wy(e)),t(` addBorderSegments`,()=>Ny(e)),t(` order`,()=>ob(e,n)),t(` insertSelfEdges`,()=>Jb(e)),t(` adjustCoordinateSystem`,()=>Iy(e)),t(` position`,()=>wb(e)),t(` positionSelfEdges`,()=>Yb(e)),t(` removeBorderNodes`,()=>Kb(e)),t(` normalize.undo`,()=>Xv(e)),t(` fixupEdgeLabelCoords`,()=>Wb(e)),t(` undoCoordinateSystem`,()=>Ly(e)),t(` translateGraph`,()=>Hb(e)),t(` assignNodeIntersects`,()=>Ub(e)),t(` reversePoints`,()=>Gb(e)),t(` acyclic.undo`,()=>qv(e))}function Ob(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var kb=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Ab={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},jb=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],Mb=[`width`,`height`,`rank`],Nb={width:0,height:0},Pb=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Fb={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Ib=[`labelpos`];function Lb(e){let t=new D_({multigraph:!0,compound:!0}),n=Zb(e.graph());return t.setGraph(Object.assign({},Ab,Xb(n,kb),kv(n,jb))),e.nodes().forEach(n=>{let r=Xb(Zb(e.node(n)),Mb);Object.keys(Nb).forEach(e=>{r[e]===void 0&&(r[e]=Nb[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Zb(e.edge(n));t.setEdge(n,Object.assign({},Fb,Xb(r,Pb),kv(r,Ib)))}),t}function Rb(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function zb(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);dv(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function Bb(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Vb(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Hb(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function Ub(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(mv(r,a)),n.points.push(mv(i,o))})}function Wb(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function Gb(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Kb(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function qb(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Jb(e){hv(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{dv(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function Yb(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`selfedge`){let r=n,i=e.node(r.e.v),a=i.x+i.width/2,o=i.y,s=n.x-a,c=i.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*s/3,y:o-c},{x:a+5*s/6,y:o-c},{x:a+s,y:o},{x:a+5*s/6,y:o+c},{x:a+2*s/3,y:o+c}],r.label.x=n.x,r.label.y=n.y}})}function Xb(e,t){return Av(kv(e,t),Number)}function Zb(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Qb(e){let t=hv(e),n=new D_({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var $b={graphlib:w_,version:Nv,layout:Eb,debug:Qb,util:{time:wv,notime:Tv}},ex=function(e){return typeof e==`function`},tx=.001;function nx(e){if(e.isParent()){var t=e.children();if(t.length>0)return nx(t[0])}return e}function rx(e){this.options=y_({},v_,e)}function ix(e,t){return{x:lx(e.x-t.x),y:lx(e.y-t.y)}}function ax(e,t){return lx(e.x*t.x)+lx(e.y*t.y)}function ox(e){var t=Math.hypot(e.x,e.y)||1;return{x:e.x/t,y:e.y/t,len:t}}function sx(e){return{x:-e.y,y:e.x}}function cx(e,t){var n=ox(ix(t,e)),r=n.x,i=n.y,a=n.len,o={x:r,y:i};return{src:e,tgt:t,dir:o,normal:sx(o),len:a}}function lx(e){return Math.abs(e)<tx?e<0?-tx:tx:e}function ux(e,t){var n=ix(e,t.src);return{weight:lx(ax(n,t.dir)/t.len),distance:lx(ax(n,t.normal))}}function dx(e){var t=1/0,n=-1/0,r=h_(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;a.weight<t&&(t=a.weight),a.weight>n&&(n=a.weight)}}catch(e){r.e(e)}finally{r.f()}var o=n-t||1;return e.map(function(e){return{distance:e.distance,weight:(e.weight-t)/o}})}function fx(e,t){var n=cx(t.source().position(),t.target().position()),r=dx(e.points.map(function(e){return ux(e,n)}));return{controlPointWeights:r.slice(1,-1).map(function(e){return e.weight}),controlPointDistances:r.slice(1,-1).map(function(e){return e.distance})}}rx.prototype.run=function(){var e=this.options,t=this,n=e.cy,r=e.eles,i=function(e,t){return ex(t)?t.apply(e,[e]):t},a=e.boundingBox||{x1:0,y1:0,w:n.width(),h:n.height()};a.x2===void 0&&(a.x2=a.x1+a.w),a.w===void 0&&(a.w=a.x2-a.x1),a.y2===void 0&&(a.y2=a.y1+a.h),a.h===void 0&&(a.h=a.y2-a.y1);var o=new $b.graphlib.Graph({multigraph:!0,compound:!0}),s={},c=function(e,t){t!=null&&(s[e]=t)};c(`nodesep`,e.nodeSep),c(`edgesep`,e.edgeSep),c(`ranksep`,e.rankSep),c(`rankdir`,e.rankDir),c(`align`,e.align),c(`ranker`,e.ranker),c(`acyclicer`,e.acyclicer),o.setGraph(s),o.setDefaultEdgeLabel(function(){return{}}),o.setDefaultNodeLabel(function(){return{}});var l=r.nodes();ex(e.sort)&&(l=l.sort(e.sort));for(var u=0;u<l.length;u++){var d=l[u],f=d.layoutDimensions(e);o.setNode(d.id(),{width:f.w,height:f.h,shape:`ellipse`,name:d.id()})}for(var p=0;p<l.length;p++){var m=l[p];m.isChild()&&o.setParent(m.id(),m.parent().id())}var h=r.edges();ex(e.sort)&&(h=h.sort(e.sort));for(var g=0;g<h.length;g++){var _=h[g],v=nx(_.source()),y=nx(_.target());o.setEdge(v.id(),y.id(),{minlen:i(_,e.minLen),weight:i(_,e.edgeWeight),name:_.id()},_.id())}$b.layout(o);for(var b=o.nodes(),x=0;x<b.length;x++){var S=b[x],C=o.node(S);n.getElementById(S).scratch().dagre=C}var w;e.boundingBox?(w={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0},l.forEach(function(e){var t=e.scratch().dagre;w.x1=Math.min(w.x1,t.x),w.x2=Math.max(w.x2,t.x),w.y1=Math.min(w.y1,t.y),w.y2=Math.max(w.y2,t.y)}),w.w=w.x2-w.x1,w.h=w.y2-w.y1):w=a;var T=function(t){if(e.boundingBox){var n=w.w===0?0:(t.x-w.x1)/w.w,r=w.h===0?0:(t.y-w.y1)/w.h;return{x:a.x1+n*a.w,y:a.y1+r*a.h}}return t};return l.layoutPositions(t,e,function(e){e=g_(e)===`object`?e:this;var t=e.scratch().dagre;return T({x:t.x,y:t.y})}),e.useDagreEdgeControlPoints&&(e.automaticDagreEdgeStyle&&(n.edges().addClass(`useDagreEdgeControlPoints`),n.style().selector(`edge.useDagreEdgeControlPoints`).style(e.dagreEdgeStyle).update()),o.edges().forEach(function(e){var t=n.getElementById(e.name),r=o.edge(e);r&&r.points&&t.scratch(fx(r,t))})),this};var px=function(e){e&&e(`layout`,`dagre`,rx)};typeof window<`u`&&window.cytoscape!==void 0&&px(window.cytoscape),p_.use(px);function mx(e,t){let n=[...e.map(e=>e.id)].sort(),r=new Set(n),i=p_({headless:!0,styleEnabled:!0,elements:[...n.map(e=>({data:{id:e}})),...t.filter(e=>r.has(e.from)&&r.has(e.to)&&e.from!==e.to).map(e=>({data:{id:`${e.from}->${e.to}`,source:e.from,target:e.to,weight:e.weight}})).sort((e,t)=>e.data.id<t.data.id?-1:1)],style:[{selector:`node`,style:{width:210,height:84,shape:`round-rectangle`}}]});i.layout({name:`dagre`,rankDir:`LR`,nodeSep:30,rankSep:80,edgeWeight:e=>Number(e.data(`weight`))||1,fit:!1,animate:!1}).run();let a={groups:{},packages:{x:0,y:0}},o=-1/0,s=1/0;for(let e of i.nodes().toArray()){let t=e.position();a.groups[e.id()]={x:Math.round(t.x),y:Math.round(t.y)},o=Math.max(o,t.x),s=Math.min(s,t.y)}return i.destroy(),a.packages=n.length?{x:Math.round(o+210+80),y:Math.round(s)}:{x:0,y:0},a}var hx=new Map;function gx(e,t,n){let r=hx.get(e);return r||(r=mx(t,n),hx.set(e,r),hx.size>20&&hx.delete(hx.keys().next().value)),r}function _x(e,t,n){let r=[...e.map(e=>e.id)].sort(),i=new Set(r),a=p_({headless:!0,styleEnabled:!0,elements:[...r.map(e=>({data:{id:e}})),...t.filter(e=>i.has(e.from)&&i.has(e.to)&&e.from!==e.to).map(e=>({data:{id:`${e.from}->${e.to}`,source:e.from,target:e.to}})).sort((e,t)=>e.data.id<t.data.id?-1:1)],style:[{selector:`node`,style:{width:160,height:50,shape:`round-rectangle`}}]});a.layout({name:`dagre`,rankDir:`LR`,nodeSep:18,rankSep:46,fit:!1,animate:!1}).run();let o={nodes:{},stubs:{},box:{x1:0,y1:0,x2:0,y2:0}},s=1/0,c=1/0,l=-1/0,u=-1/0;for(let e of a.nodes().toArray()){let t={x:Math.round(e.position().x),y:Math.round(e.position().y)};o.nodes[e.id()]=t,s=Math.min(s,t.x-80),l=Math.max(l,t.x+80),c=Math.min(c,t.y-25),u=Math.max(u,t.y+25)}a.destroy(),r.length===0&&([s,c,l,u]=[0,0,160,50]),o.box={x1:s-24,y1:c-36,x2:l+24,y2:u+24};let d=o.box.x2+56+90;return[...n.map(e=>e.id)].sort().forEach((e,t)=>{o.stubs[e]={x:Math.round(d),y:Math.round(o.box.y1+23+t*62)}}),o}var vx=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`,yx={"file-not-found":`file not found`,"not-exported":`not exported by the package`,"unknown-package":`unknown package`,"alias-not-configured":`path alias not configured`,"package-not-in-sources":`package in no source yet`,"path-not-in-sources":`folder in no source yet`,"default-excluded":`in a folder left out`,"excluded-by-rule":`left out by a rule`,"too-large":`file too large`,"language-not-analyzed":`language not analyzed`};function bx(e,t){switch(e.kind){case`group`:return`${e.name}\n${vx(e.count,`import`)} · group`;case`ungrouped`:return`${e.source}\n${vx(e.count,`import`)} · other source`;case`packages`:{let n=e.packages.slice(0,3).map(t),r=e.packages.length-n.length;return`${n.join(`, `)}${r>0?` +${r}`:``}\nexternal packages`}default:return`${yx[e.reason]??e.reason}\n${vx(e.count,e.kind===`broken`?`broken import`:e.kind===`pending`?`pending import`:`import not analyzed`)}`}}function xx(e,t){return t&&e.startsWith(`${t}/`)?e.slice(t.length+1):e}function Sx({reply:e,pick:t,onPick:n,onOpenFile:r,onToggleFolder:i,onClear:a,marks:o=null,only:s=null,onContext:c}){let l=(0,d.useRef)(null),u=(0,d.useRef)(null),f=(0,d.useRef)(s);f.current=s;let p=(0,d.useRef)(c);p.current=c,(0,d.useEffect)(()=>{u.current&&_e(u.current,s)},[s]);let m=(0,d.useRef)(o);m.current=o,(0,d.useEffect)(()=>{u.current&&xe(u.current,o)},[o]);let h=(0,d.useRef)({onPick:n,onOpenFile:r,onToggleFolder:i,onClear:a});h.current={onPick:n,onOpenFile:r,onToggleFolder:i,onClear:a};let g=e.group.kind===`cluster`?``:e.group.root;(0,d.useEffect)(()=>{if(!l.current)return;let t=_x(e.nodes,e.imports,e.stubs),n=t.box,r=e=>e.slice(e.lastIndexOf(`:`)+1),i=[{data:{id:`box`,kind:`box`,label:e.group.name,w:n.x2-n.x1,h:n.y2-n.y1},position:{x:(n.x1+n.x2)/2,y:(n.y1+n.y2)/2},classes:`box`},...e.nodes.map(e=>{let n=e.findings,r=n.broken>0?` · ${vx(n.broken,`broken import`)}`:``;return e.kind===`folder`?{data:{id:e.id,kind:`folder`,path:e.path,label:`${xx(e.path,g)}/ (${e.files})\nfolder${r}`},position:t.nodes[e.id],classes:n.broken>0?`folder broken`:`folder`}:{data:{id:e.id,kind:`file`,label:`${xx(e.path,g)}${r?`\n${r.slice(3)}`:``}`},position:t.nodes[e.id],classes:[`file`,n.broken>0?`broken`:``,e.status===`not_analyzed`?`not-analyzed`:``].join(` `)}}),...e.stubs.map(e=>({data:{id:e.id,kind:`stub`,label:bx(e,r)},position:t.stubs[e.id],classes:`stub ${e.kind}`})),...e.imports.map(e=>({data:{id:e.id,kind:`imports`,source:e.from,target:e.to,label:e.count>1?String(e.count):``},classes:`imports`})),...e.stubEdges.map(t=>{let n=e.stubs.find(e=>e.id===t.to);return{data:{id:t.id,kind:`out`,source:t.from,target:t.to,label:t.count>1?String(t.count):``},classes:`out ${n?.kind??``}`}})],a=p_({container:l.current,elements:i,layout:{name:`preset`},autounselectify:!0,minZoom:.1,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:160,height:50,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`144px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:`#1d2330`,"background-color":`#fff`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.box`,style:{width:`data(w)`,height:`data(h)`,"background-color":`#f7faff`,"border-color":`#c6d6f3`,"border-width":2,"text-valign":`top`,"text-halign":`center`,"text-margin-y":22,"font-weight":`bold`,color:`#2a56ad`,events:`no`,"z-compound-depth":`bottom`,"z-index":0}},{selector:`node.folder`,style:{"background-color":`#f3f6fb`,"border-style":`double`,"border-width":3}},{selector:`node.broken`,style:{"border-color":`#c9a45c`}},{selector:`node.not-analyzed`,style:{color:`#8a93a3`,"border-style":`dashed`}},{selector:`node.stub`,style:{width:180,height:46,"border-style":`dashed`,"border-color":`#6b87b8`,color:`#1d2330`}},{selector:`node.stub.packages`,style:{"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`node.stub.broken`,style:{"border-color":`#c9a45c`,"background-color":`#fffaf0`,color:`#6b4600`}},{selector:`node.stub.not-analyzed, node.stub.pending`,style:{"border-color":`#b7c0cf`,"background-color":`#fafbfc`,color:`#5d6675`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":`#8fa0b8`,"target-arrow-shape":`triangle`,"target-arrow-color":`#8fa0b8`,"arrow-scale":.8,label:`data(label)`,"font-size":10,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1}},{selector:`edge.out`,style:{"line-style":`dashed`,"line-color":`#9fb3d6`,"target-arrow-color":`#9fb3d6`}},{selector:`edge.out.broken`,style:{"line-color":`#c9a45c`,"target-arrow-color":`#c9a45c`}},...be,ge,{selector:`node.picked`,style:{"border-width":2,"border-color":`#3b6fd4`,"background-color":`#eef4ff`}},{selector:`edge.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`,width:2.5}},{selector:`.faded`,style:{opacity:.3}}]});return a.on(`tap`,`node`,e=>{let t=e.target.data(`kind`);(t===`file`||t===`folder`)&&h.current.onPick(e.target.id())}),a.on(`dbltap`,`node`,e=>{let t=e.target.data(`kind`);t===`file`?h.current.onOpenFile(e.target.id()):t===`folder`&&h.current.onToggleFolder(e.target.data(`path`))}),a.on(`tap`,e=>{e.target===a&&h.current.onClear()}),Cx(a),u.current=a,l.current&&(l.current.veoCy=a),_e(a,f.current),a.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`file`?`file`:t.kind===`folder`?`folder`:t.kind===`imports`?`edge`:null;if(!n||!l.current)return;let r=l.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};p.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),xe(a,m.current),()=>{u.current=null,a.destroy()}},[e,g]),(0,d.useEffect)(()=>{let e=u.current;e&&e.batch(()=>{e.elements().removeClass(`picked faded`);let n=t?e.getElementById(t):null;if(n&&n.nonempty()){let t=n.union(n.connectedEdges());t.addClass(`picked`),e.elements().not(t).not(t.connectedNodes()).not(`#box`).addClass(`faded`)}})},[t,e]);let _=e.nodes,v=t=>{let n=e.nodes.find(e=>e.id===t);n?.kind===`folder`?i(n.path):n&&r(n.id)};return(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[(0,K.jsx)(`div`,{ref:l,className:`graph map`,"data-testid":`group-canvas`,tabIndex:0,role:`application`,"aria-label":`The group's files: arrow keys move between them, Enter opens a file or a folder`,onKeyDown:e=>{if(_.length===0)return;let r=t?_.findIndex(e=>e.id===t):-1;if(e.key===`ArrowRight`||e.key===`ArrowDown`)n(_[(r+1)%_.length].id);else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)n(_[(r-1+_.length)%_.length].id);else if(e.key===`Enter`&&t)v(t);else if(e.key===`Escape`)a();else return;e.preventDefault()}}),(0,K.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Files and folders`,children:[e.nodes.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{"data-command":`pick-node`,"data-id":e.id,tabIndex:-1,onClick:()=>n(e.id),children:e.path}),e.kind===`folder`?(0,K.jsxs)(`button`,{"data-command":`toggle-folder`,"data-path":e.path,tabIndex:-1,onClick:()=>i(e.path),children:[`Open `,e.path,`/`]}):(0,K.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.id,tabIndex:-1,onClick:()=>r(e.id),children:[`Open `,e.path]})]},e.id)),e.stubs.map(e=>(0,K.jsx)(`li`,{"data-testid":`stub`,"data-id":e.id,"data-count":e.count,children:bx(e,e=>e.slice(e.lastIndexOf(`:`)+1)).replace(`
|
|
332
|
-
`,` · `)},e.id))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>u.current&&Cx(u.current),children:`Fit`})]})}function Cx(e){e.fit(void 0,30);let t=e.zoom();if(t>1.2)e.zoom(1.2),e.center();else if(t<.75){let t=e.elements().boundingBox();e.zoom(.75),e.pan({x:30-t.x1*.75,y:30-t.y1*.75})}}var wx=new Map;function Tx(e,t,n){let r=wx.get(e);return r||(r=n(),wx.set(e,r),r.then(n=>n.committedRun!==t&&wx.delete(e),()=>wx.delete(e)),wx.size>40&&wx.delete(wx.keys().next().value)),r}function Ex(e,t,n,r,i){let[a,o]=(0,d.useState)({key:null,data:null,error:null});return(0,d.useEffect)(()=>{if(e===null)return;let r=!1;return Tx(e,t,n).then(t=>!r&&o({key:e,scope:i,data:t,error:null}),t=>!r&&o({key:e,scope:i,data:null,error:t.message})),()=>{r=!0}},[e,r]),a.key===e?a:i!==void 0&&a.scope===i&&a.data?{data:a.data,error:null}:{data:null,error:null}}function Dx(e,t,n=0,r=null){let{data:i,error:a}=Ex(e?JSON.stringify([`groups`,e,t,r]):null,t,()=>L.groups(e,r),n);return{groups:i,error:a}}function Ox(e,t,n,r,i,a=0){let o=[...r].sort(),{data:s,error:c}=Ex(e&&n?JSON.stringify([`group`,e,t,n,o,i]):null,t,()=>L.group(e,n,o,i),a,JSON.stringify([e,t,n]));return{group:s,error:c}}function kx(e,t,n){let{data:r,error:i}=Ex(e&&n?JSON.stringify([`imports`,e,t,n]):null,t,()=>L.imports(e,n),0);return{imports:r,error:i}}function Ax(e,t,n){let{data:r,error:i}=Ex(e&&n?JSON.stringify([`calls`,e,t,n]):null,t,()=>Promise.all([L.crossFileCalls(e,n,`out`),L.crossFileCalls(e,n,`in`)]).then(([e,t])=>({committedRun:e.committedRun,out:e,in:t})),0);return{calls:r,error:i}}var jx={"dynamic-dispatch":`type unknown`,reflection:`reflection`,"computed-member":`computed name`,metaprogramming:`built at run time`,ambiguous:`could be several functions`,"not-exported":`not exported`,"not-found":`not found`,"template-binding":`awaiting its component`,"template-reference":`registered elsewhere`},Mx=100;function Nx(e,t,n,r,i){let a=JSON.stringify([e,n,r]),o=JSON.stringify([a,t,i]),[s,c]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!e)return;let t=!1;return L.findings(e,r.length?r:[`broken`],n?.kind===`file`?{file:n.file}:n?.kind===`group`?{group:n.group}:n?.kind===`source`?{source:n.source}:{},r.length?1e3:1).then(e=>!t&&c({key:o,same:a,data:e,error:null}),e=>!t&&c({key:o,same:a,data:null,error:e.message})),()=>{t=!0}},[o]),!s||s.same!==a?{data:null,error:null}:{data:s.data,error:s.key===o?s.error:null}}function Px({project:e,run:t,scope:n,wholeProject:r,canScope:i,showPending:a,refresh:o,filter:s,onFilter:c,onWholeProject:l,onTogglePending:u,onSelectSite:f,onOpenImport:p,onManageLicense:m}){let h=r?null:n,{data:g}=Nx(e,t,h,[],o),_=g?.counts,v=s??(_&&_.broken>0?`broken`:`open-call`),{data:y,error:b}=Nx(e,t,h,[v,...a&&v!==`open-call`?[`pending`]:[]],o),{groups:x}=Dx(e,t),S=(0,d.useMemo)(()=>new Map((x?.groups??[]).map(e=>[e.id,e])),[x]),C=e=>{let t=e.group?S.get(e.group):void 0,n=t&&t.kind!==`cluster`&&t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t?`${t.name} › `:``}${n}:${e.line}`},w=n?.kind===`group`?S.get(n.group)?.name??`this group`:``,T=i&&n&&(0,K.jsxs)(`div`,{className:`scope`,role:`group`,"aria-label":`Findings scope`,children:[(0,K.jsx)(`button`,{"aria-pressed":!r,onClick:()=>l(!1),"data-testid":`questions-scope-file`,children:n.kind===`file`?`This file`:n.kind===`group`?`This group (${w})`:`This repository (${n.name??n.source})`}),(0,K.jsx)(`button`,{"aria-pressed":r,onClick:()=>l(!0),"data-testid":`questions-scope-project`,children:`Whole project`})]}),E=(e,t,n)=>(0,K.jsxs)(`button`,{className:`chip`,"aria-pressed":v===e,"data-testid":`findings-filter-${e}`,"data-count":n??``,onClick:()=>c(e),children:[t,` `,(0,K.jsx)(`small`,{children:n??`…`})]},e),D=(y?.findings??[]).filter(e=>e.kind===v),O=(y?.findings??[]).filter(e=>e.kind===`pending`);return(0,K.jsxs)(`div`,{className:`findings-panel`,"data-testid":`findings-panel`,children:[(0,K.jsx)(he,{project:e,run:t,refresh:o,onManage:m}),T,(0,K.jsxs)(`div`,{className:`chips`,role:`group`,"aria-label":`Kinds of findings`,children:[E(`broken`,`Broken imports`,_?.broken),E(`not-analyzed`,`Not analyzed`,_?.notAnalyzed),E(`open-call`,`Open calls`,_?.openCalls)]}),(0,K.jsxs)(`label`,{className:`toggle small muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:a,onChange:u}),`Show pending (waiting for another source)`,_?` · ${_.pending}`:``]}),b?(0,K.jsx)(`p`,{className:`hint error`,children:b}):y?v===`open-call`?(0,K.jsx)(Lx,{rows:D,where:C,project:e,onSelect:f}):(0,K.jsx)(Ix,{rows:D,empty:v===`broken`?`No broken imports.`:`No imports of files left out of analysis.`,where:C,project:e,onOpen:p}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`}),y&&a&&v!==`open-call`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Pending (`,O.length,`)`]}),(0,K.jsx)(Ix,{rows:O,empty:`Nothing waits for another source.`,where:C,project:e,onOpen:p})]}),y?.truncated&&(0,K.jsxs)(`p`,{className:`hint small`,"data-testid":`findings-truncated`,children:[`Showing `,y.findings.length,` of `,y.total,`.`]})]})}function Fx({project:e,id:t}){let[n,r]=(0,d.useState)(!1);return n?(0,K.jsx)(ue,{project:e,id:t,start:!0}):(0,K.jsx)(`button`,{className:`link small`,"data-command":`explain-finding`,onClick:()=>r(!0),children:`Explain`})}function Ix({rows:e,empty:t,where:n,project:r,onOpen:i}){let[a,o]=(0,d.useState)(Mx);return e.length===0?(0,K.jsx)(`p`,{className:`hint`,children:t}):(0,K.jsxs)(`ul`,{className:`questions finding-rows`,"data-testid":`finding-rows`,children:[e.slice(0,a).map(e=>(0,K.jsxs)(`li`,{"data-kind":e.kind,children:[(0,K.jsx)(`div`,{className:`qrow`,children:(0,K.jsxs)(`button`,{"data-command":`open-finding`,"data-id":e.id,onClick:()=>i(e.file,e.id,e.group),children:[(0,K.jsx)(`code`,{children:e.text}),(0,K.jsxs)(`small`,{children:[n(e),` · `,yx[e.reason]??e.reason]})]})}),(0,K.jsx)(Fx,{project:r,id:e.id})]},e.id)),e.length>a&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link`,onClick:()=>o(a+Mx),children:[e.length-a,` more…`]})})]})}function Lx({rows:e,where:t,project:n,onSelect:r}){let[i,a]=(0,d.useState)(Mx),[o,s]=(0,d.useState)(null),c=(0,d.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.text);e?e.push(n):t.set(n.text,[n])}return[...t].sort(([e,t],[n,r])=>r.length-t.length||(e<n?-1:+(e>n)))},[e]),l=e=>e.id.startsWith(`resolution|`)?e.id.slice(11):e.id;return e.length===0?(0,K.jsx)(`p`,{className:`hint`,children:`No open calls.`}):(0,K.jsxs)(`ul`,{className:`questions`,"data-testid":`questions`,children:[c.slice(0,i).map(([e,i])=>{let a=i[0],c=new Set(i.map(e=>e.file)).size,u=i.length===1?t(a):`×${i.length}${c>1?` in ${c} files`:``}`;return(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`div`,{className:`qrow`,children:[(0,K.jsxs)(`button`,{"data-command":`select`,"data-kind":`site`,"data-count":i.length,title:e,onClick:()=>r(l(a),a.file),children:[(0,K.jsx)(`code`,{children:e}),(0,K.jsxs)(`small`,{children:[u,` · `,jx[a.reason]??a.reason]})]}),i.length>1&&(0,K.jsx)(`button`,{className:`icon expand`,"aria-expanded":o===e,"aria-label":`Show all ${i.length}`,onClick:()=>s(o===e?null:e),children:o===e?`▾`:`▸`})]}),i.length===1&&(0,K.jsx)(Fx,{project:n,id:a.id}),o===e&&(0,K.jsx)(`ul`,{className:`occurrences`,children:i.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{"data-command":`select`,"data-kind":`site`,onClick:()=>r(l(e),e.file),children:t(e)}),(0,K.jsx)(Fx,{project:n,id:e.id})]},e.id))})]},e)}),c.length>i&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link`,onClick:()=>a(i+Mx),children:[c.length-i,` more…`]})})]})}function Rx(e,t,n=0){let r=e&&t?`${e}|${t.a}|${t.b}`:null,[i,a]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!r||!e||!t)return;let n=!1;return L.diff(e,t.a,t.b).then(e=>!n&&a({key:r,data:e,error:null}),e=>!n&&a({key:r,data:null,error:e.message})),()=>{n=!0}},[r,n]),i&&i.key===r?{data:i.data,error:i.error}:{data:null,error:null}}var zx={added:`+`,removed:`−`,changed:`~`},Bx={added:`added`,removed:`removed`,changed:`changed`};function Vx(e){let t=e.fact,n=e=>String(e??``).slice(String(e??``).lastIndexOf(`:`)+1);switch(e.type){case`Function`:return`function ${String(t.qualifiedName??t.name??n(e.id))}`;case`File`:return`file ${String(t.path??e.id)}`;case`CALLS`:case`CALLS_CROSS_FILE`:return`call ${n(t.from)} → ${n(t.to)}`;case`IMPORTS`:return`import ${String(t.specifier??``)}`;case`UnresolvedImport`:return`import ${String(t.specifier??``)} (${String(t.outcome??``)}${t.reason?`: ${String(t.reason)}`:``})`;case`UnresolvedCallSite`:return`open call ${String(t.expression??``)}`;case`SiteResolution`:return`call ${String(t.site??``).split(`|`)[3]??``} (${String(t.status??``)})`;case`Group`:return`group ${String(t.name??e.id)}`;case`DEPENDS_ON`:return`dependency ${String(t.from??``)} → ${String(t.to??``)}`;case`ExternalPackage`:return`package ${String(t.name??e.id)}`;case`Finding`:return`finding: ${String(t.message??t.kind??``)}`;default:return`${e.type} ${e.id}`}}function Hx(e){let t=[];for(let[n,r]of Object.entries({Function:`functions`,File:`files`,IMPORTS:`imports`,CALLS:`calls`,CALLS_CROSS_FILE:`cross-file calls`,UnresolvedImport:`unresolved imports`})){let i=e.byType[n];if(!i||i.added+i.removed+i.changed===0)continue;let a=[i.added?`+${i.added}`:``,i.removed?`−${i.removed}`:``,i.changed?`${i.changed} changed`:``].filter(Boolean);t.push(`${a.join(`, `)} ${r}`)}let{added:n,removed:r,changed:i}=e.total;return t.length?t.join(` · `):n+r+i===0?`No changes`:`${n+r+i} changes`}function Ux(e,t){return e.type===`ExternalPackage`?!1:e.change===`removed`?e.file!==null&&e.type!==`File`&&!t.has(e.file):e.file!==null||e.type===`Group`||e.type===`DEPENDS_ON`}var Wx=e=>e.startsWith(`sha256:`)?`folder`:e.slice(0,7),Gx=e=>e?new Date(e).toLocaleString():``;function Kx({run:e,picked:t,viewing:n,onPick:r,onView:i}){let a=e.sources.filter(e=>!e.pinned);return(0,K.jsxs)(`li`,{className:`run-row${n?` viewing`:``}`,"data-run":e.runId,children:[(0,K.jsx)(`label`,{className:`pick`,children:(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`compare-pick`,checked:t,onChange:e=>r(e.target.checked),"aria-label":`Compare run ${e.runId}`})}),(0,K.jsxs)(`span`,{className:`what`,children:[(0,K.jsxs)(`span`,{className:`title`,children:[(0,K.jsxs)(`strong`,{children:[`Run `,e.runId]}),e.current?(0,K.jsx)(`span`,{className:`badge`,children:`latest`}):null,e.kind===`branch`?(0,K.jsx)(`span`,{className:`badge`,children:`branch`}):null,e.kind===`draft`?(0,K.jsx)(`span`,{className:`badge`,children:`draft`}):null,e.kind===`debug`?(0,K.jsxs)(`span`,{className:`badge`,"data-testid":`debug-badge`,children:[`debug · until `,e.until]}):null]}),(0,K.jsx)(`span`,{className:`commits`,children:(a.length?a:e.sources).map(e=>`${e.sourceId}@${Wx(e.revision)}${e.branch?` (${e.branch})`:``}`).join(`, `)||`no sources`}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.trigger===`commit`?`commit hook`:e.trigger,` · +`,e.written,` / −`,e.closed,` ·`,` `,Gx(e.finishedAt)]})]}),(0,K.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:i,disabled:n,children:n?`Viewing`:`View`})]})}function qx({project:e,refresh:t,run:n,compare:r,diff:i,diffError:a,onView:o,onCompare:s,onClose:c,onLocate:l,stages:u=[],onDebug:f}){let[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(r?[r.a,r.b]:[]);(0,d.useEffect)(()=>{r&&b([r.a,r.b])},[r?.a,r?.b]);let[x,S]=(0,d.useState)(``);(0,d.useEffect)(()=>{let t=!1;return L.history(e).then(e=>!t&&(g(e),v(null)),e=>!t&&v(e.message)),()=>{t=!0}},[e,t]);let C=(e,t)=>b(n=>t?[...n.filter(t=>t!==e),e].slice(-2):n.filter(t=>t!==e)),w=y.length===2?{a:Math.min(...y),b:Math.max(...y)}:null,T=(0,d.useMemo)(()=>new Set((i?.items??[]).filter(e=>e.type===`File`&&e.change===`removed`).map(e=>e.id)),[i]),E=(0,d.useMemo)(()=>{if(!i)return[];let e=x.trim().toLowerCase(),t=new Map(i.files.map(e=>[e.file??`\0${e.source}`,e.group?.name??e.source])),n=new Map;for(let r of i.items){let i=Vx(r);if(e&&!`${i} ${r.file??``} ${r.type}`.toLowerCase().includes(e))continue;let a=r.file??`\0${r.source}`,o=t.get(a)??r.source,s=n.get(o);s||n.set(o,s=new Map);let c=s.get(a);c||s.set(a,c=[]),c.push({item:r,words:i})}return[...n].sort(([e],[t])=>e<t?-1:1)},[i,x]);return(0,K.jsxs)(`div`,{className:`history-panel`,"data-testid":`history-panel`,children:[(0,K.jsxs)(`div`,{className:`history-head`,children:[(0,K.jsx)(`strong`,{children:`History`}),(0,K.jsx)(`button`,{className:`icon`,"data-command":`toggle-history`,"aria-label":`Close History`,onClick:c,children:`×`})]}),r?(0,K.jsxs)(`section`,{className:`changes`,"aria-label":`Changes`,"data-testid":`change-list`,children:[(0,K.jsxs)(`div`,{className:`compare-head`,children:[(0,K.jsxs)(`span`,{children:[`Changes from run `,r.a,` to run `,r.b]}),(0,K.jsx)(`button`,{className:`link`,"data-command":`compare-runs`,onClick:()=>s(null),children:`Stop comparing`})]}),a?(0,K.jsx)(`p`,{className:`error`,children:a}):i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`summary`,"data-testid":`change-summary`,children:Hx(i)}),(0,K.jsxs)(`p`,{className:`legend muted small`,children:[`On the canvas:`,` `,(0,K.jsxs)(`span`,{className:`change added`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`+`}),`added`]}),` `,`(solid blue border),`,` `,(0,K.jsxs)(`span`,{className:`change removed`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`−`}),`removed`]}),` `,`(dashed orange),`,` `,(0,K.jsxs)(`span`,{className:`change changed`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`~`}),`changed`]}),` `,`(double purple).`]}),i.latestOnly.length>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`Not compared (plain folders have no history): `,i.latestOnly.join(`, `)]}),(0,K.jsx)(`input`,{type:`search`,className:`filter`,placeholder:`Filter changes`,"aria-label":`Filter changes`,"data-testid":`change-filter`,value:x,onChange:e=>S(e.target.value)}),E.map(([e,t])=>(0,K.jsxs)(`div`,{className:`change-group`,children:[(0,K.jsx)(`h4`,{children:e}),[...t].map(([e,t])=>(0,K.jsxs)(`div`,{className:`change-file`,children:[(0,K.jsx)(`div`,{className:`file-name`,children:e.startsWith(`\0`)?`(the repository)`:e.slice(e.indexOf(`:`)+1)}),(0,K.jsx)(`ul`,{children:t.map(({item:e,words:t})=>{let n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`sign`,"aria-hidden":`true`,children:zx[e.change]}),(0,K.jsxs)(`span`,{className:`visually-hidden`,children:[Bx[e.change],`: `]}),t]});return(0,K.jsx)(`li`,{className:`change ${e.change}`,children:Ux(e,T)?(0,K.jsx)(`button`,{className:`link`,"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,onClick:()=>l(e),children:n}):(0,K.jsx)(`span`,{"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,children:n})},`${e.change}:${e.id}`)})})]},e))]},e)),i.truncated&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`The first `,i.items.length,` of`,` `,i.total.added+i.total.removed+i.total.changed,` changes are listed.`]})]}):(0,K.jsx)(`p`,{className:`muted`,children:`Comparing…`})]}):null,_?(0,K.jsx)(`p`,{className:`error`,children:_}):null,h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`compare-bar`,children:[(0,K.jsx)(`button`,{"data-command":`compare-runs`,disabled:!w,onClick:()=>w&&s(w),title:`Pick two runs to compare`,children:w?`Compare run ${w.a} with run ${w.b}`:`Pick two runs to compare`}),n!==null&&(0,K.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:()=>o(null),children:`Back to latest`})]}),(0,K.jsxs)(`ol`,{className:`runs`,"aria-label":`Runs`,children:[h.draft&&(0,K.jsx)(Kx,{run:h.draft,picked:y.includes(h.draft.runId),viewing:n===h.draft.runId,onPick:e=>C(h.draft.runId,e),onView:()=>o(h.draft.runId)}),h.debug&&(0,K.jsx)(Kx,{run:h.debug,picked:y.includes(h.debug.runId),viewing:n===h.debug.runId,onPick:e=>C(h.debug.runId,e),onView:()=>o(h.debug.runId)}),h.runs.map(e=>(0,K.jsx)(Kx,{run:e,picked:y.includes(e.runId),viewing:n===null?e.current:n===e.runId,onPick:t=>C(e.runId,t),onView:()=>o(e.current?null:e.runId)},e.runId))]}),h.hidden>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[h.hidden,` older runs aren't shown: this license shows 30 days of history.`]}),h.latestOnly.length>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`Not under version control, so latest only: `,h.latestOnly.join(`, `),`. History and diffs need git.`]}),f&&u.length>0&&h.runs.length>0&&(0,K.jsxs)(`form`,{className:`debug-run`,onSubmit:e=>{e.preventDefault(),f(p||u[0])},children:[(0,K.jsxs)(`label`,{className:`muted small`,children:[`Debug run: stop after`,` `,(0,K.jsx)(`select`,{"data-testid":`debug-until`,value:p||u[0],onChange:e=>m(e.target.value),children:u.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsx)(`button`,{type:`submit`,"data-command":`analyze-debug`,"data-testid":`analyze-debug`,title:`Never committed: open it and compare it with the latest`,children:`Run`})]}),(0,K.jsxs)(`p`,{className:`muted small hook-note`,children:[`A run for each commit: `,(0,K.jsx)(`code`,{children:`veoflow hook install`}),` in a repository.`]})]}):!_&&(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`})]})}var Jx=e=>e.startsWith(`sha256:`)?``:e.slice(0,7),Yx=e=>e.split(`
|
|
332
|
+
`,` · `)},e.id))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>u.current&&Cx(u.current),children:`Fit`})]})}function Cx(e){e.fit(void 0,30);let t=e.zoom();if(t>1.2)e.zoom(1.2),e.center();else if(t<.75){let t=e.elements().boundingBox();e.zoom(.75),e.pan({x:30-t.x1*.75,y:30-t.y1*.75})}}var wx=new Map;function Tx(e,t,n){let r=wx.get(e);return r||(r=n(),wx.set(e,r),r.then(n=>n.committedRun!==t&&wx.delete(e),()=>wx.delete(e)),wx.size>40&&wx.delete(wx.keys().next().value)),r}function Ex(e,t,n,r,i){let[a,o]=(0,d.useState)({key:null,data:null,error:null});return(0,d.useEffect)(()=>{if(e===null)return;let r=!1;return Tx(e,t,n).then(t=>!r&&o({key:e,scope:i,data:t,error:null}),t=>!r&&o({key:e,scope:i,data:null,error:t.message})),()=>{r=!0}},[e,r]),a.key===e?a:i!==void 0&&a.scope===i&&a.data?{data:a.data,error:null}:{data:null,error:null}}function Dx(e,t,n=0,r=null){let{data:i,error:a}=Ex(e?JSON.stringify([`groups`,e,t,r]):null,t,()=>L.groups(e,r),n);return{groups:i,error:a}}function Ox(e,t,n,r,i,a=0){let o=[...r].sort(),{data:s,error:c}=Ex(e&&n?JSON.stringify([`group`,e,t,n,o,i]):null,t,()=>L.group(e,n,o,i),a,JSON.stringify([e,t,n]));return{group:s,error:c}}function kx(e,t,n){let{data:r,error:i}=Ex(e&&n?JSON.stringify([`imports`,e,t,n]):null,t,()=>L.imports(e,n),0);return{imports:r,error:i}}function Ax(e,t,n){let{data:r,error:i}=Ex(e&&n?JSON.stringify([`calls`,e,t,n]):null,t,()=>Promise.all([L.crossFileCalls(e,n,`out`),L.crossFileCalls(e,n,`in`)]).then(([e,t])=>({committedRun:e.committedRun,out:e,in:t})),0);return{calls:r,error:i}}var jx={"dynamic-dispatch":`type unknown`,reflection:`reflection`,"computed-member":`computed name`,metaprogramming:`built at run time`,ambiguous:`could be several functions`,"not-exported":`not exported`,"not-found":`not found`,"template-binding":`awaiting its component`,"template-reference":`registered elsewhere`},Mx=100;function Nx(e,t,n,r,i){let a=JSON.stringify([e,n,r]),o=JSON.stringify([a,t,i]),[s,c]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!e)return;let t=!1;return L.findings(e,r.length?r:[`broken`],n?.kind===`file`?{file:n.file}:n?.kind===`group`?{group:n.group}:n?.kind===`source`?{source:n.source}:{},r.length?1e3:1).then(e=>!t&&c({key:o,same:a,data:e,error:null}),e=>!t&&c({key:o,same:a,data:null,error:e.message})),()=>{t=!0}},[o]),!s||s.same!==a?{data:null,error:null}:{data:s.data,error:s.key===o?s.error:null}}function Px({project:e,run:t,scope:n,wholeProject:r,canScope:i,showPending:a,refresh:o,filter:s,onFilter:c,onWholeProject:l,onTogglePending:u,onSelectSite:f,onOpenImport:p,onManageLicense:m}){let h=r?null:n,{data:g}=Nx(e,t,h,[],o),_=g?.counts,v=s??(_&&_.broken>0?`broken`:`open-call`),{data:y,error:b}=Nx(e,t,h,[v,...a&&v!==`open-call`?[`pending`]:[]],o),{groups:x}=Dx(e,t),S=(0,d.useMemo)(()=>new Map((x?.groups??[]).map(e=>[e.id,e])),[x]),C=e=>{let t=e.group?S.get(e.group):void 0,n=t&&t.kind!==`cluster`&&t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t?`${t.name} › `:``}${n}:${e.line}`},w=n?.kind===`group`?S.get(n.group)?.name??`this group`:``,T=i&&n&&(0,K.jsxs)(`div`,{className:`scope`,role:`group`,"aria-label":`Findings scope`,children:[(0,K.jsx)(`button`,{"aria-pressed":!r,onClick:()=>l(!1),"data-testid":`questions-scope-file`,children:n.kind===`file`?`This file`:n.kind===`group`?`This group (${w})`:`This repository (${n.name??n.source})`}),(0,K.jsx)(`button`,{"aria-pressed":r,onClick:()=>l(!0),"data-testid":`questions-scope-project`,children:`Whole project`})]}),E=(e,t,n)=>(0,K.jsxs)(`button`,{className:`chip`,"aria-pressed":v===e,"data-testid":`findings-filter-${e}`,"data-count":n??``,onClick:()=>c(e),children:[t,` `,(0,K.jsx)(`small`,{children:n??`…`})]},e),D=(y?.findings??[]).filter(e=>e.kind===v),O=(y?.findings??[]).filter(e=>e.kind===`pending`);return(0,K.jsxs)(`div`,{className:`findings-panel`,"data-testid":`findings-panel`,children:[(0,K.jsx)(he,{project:e,run:t,refresh:o,onManage:m}),T,(0,K.jsxs)(`div`,{className:`chips`,role:`group`,"aria-label":`Kinds of findings`,children:[E(`broken`,`Broken imports`,_?.broken),E(`not-analyzed`,`Not analyzed`,_?.notAnalyzed),E(`open-call`,`Open calls`,_?.openCalls)]}),(0,K.jsxs)(`label`,{className:`toggle small muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:a,onChange:u}),`Show pending (waiting for another source)`,_?` · ${_.pending}`:``]}),b?(0,K.jsx)(`p`,{className:`hint error`,children:b}):y?v===`open-call`?(0,K.jsx)(Lx,{rows:D,where:C,project:e,onSelect:f}):(0,K.jsx)(Ix,{rows:D,empty:v===`broken`?`No broken imports.`:`No imports of files left out of analysis.`,where:C,project:e,onOpen:p}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`}),y&&a&&v!==`open-call`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Pending (`,O.length,`)`]}),(0,K.jsx)(Ix,{rows:O,empty:`Nothing waits for another source.`,where:C,project:e,onOpen:p})]}),y?.truncated&&(0,K.jsxs)(`p`,{className:`hint small`,"data-testid":`findings-truncated`,children:[`Showing `,y.findings.length,` of `,y.total,`.`]})]})}function Fx({project:e,id:t}){let[n,r]=(0,d.useState)(!1);return n?(0,K.jsx)(ue,{project:e,id:t,start:!0}):(0,K.jsx)(`button`,{className:`link small`,"data-command":`explain-finding`,onClick:()=>r(!0),children:`Explain`})}function Ix({rows:e,empty:t,where:n,project:r,onOpen:i}){let[a,o]=(0,d.useState)(Mx);return e.length===0?(0,K.jsx)(`p`,{className:`hint`,children:t}):(0,K.jsxs)(`ul`,{className:`questions finding-rows`,"data-testid":`finding-rows`,children:[e.slice(0,a).map(e=>(0,K.jsxs)(`li`,{"data-kind":e.kind,children:[(0,K.jsx)(`div`,{className:`qrow`,children:(0,K.jsxs)(`button`,{"data-command":`open-finding`,"data-id":e.id,onClick:()=>i(e.file,e.id,e.group),children:[(0,K.jsx)(`code`,{children:e.text}),(0,K.jsxs)(`small`,{children:[n(e),` · `,yx[e.reason]??e.reason]})]})}),(0,K.jsx)(Fx,{project:r,id:e.id})]},e.id)),e.length>a&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link`,onClick:()=>o(a+Mx),children:[e.length-a,` more…`]})})]})}function Lx({rows:e,where:t,project:n,onSelect:r}){let[i,a]=(0,d.useState)(Mx),[o,s]=(0,d.useState)(null),c=(0,d.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.text);e?e.push(n):t.set(n.text,[n])}return[...t].sort(([e,t],[n,r])=>r.length-t.length||(e<n?-1:+(e>n)))},[e]),l=e=>e.id.startsWith(`resolution|`)?e.id.slice(11):e.id;return e.length===0?(0,K.jsx)(`p`,{className:`hint`,children:`No open calls.`}):(0,K.jsxs)(`ul`,{className:`questions`,"data-testid":`questions`,children:[c.slice(0,i).map(([e,i])=>{let a=i[0],c=new Set(i.map(e=>e.file)).size,u=i.length===1?t(a):`×${i.length}${c>1?` in ${c} files`:``}`;return(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(`div`,{className:`qrow`,children:[(0,K.jsxs)(`button`,{"data-command":`select`,"data-kind":`site`,"data-count":i.length,title:e,onClick:()=>r(l(a),a.file),children:[(0,K.jsx)(`code`,{children:e}),(0,K.jsxs)(`small`,{children:[u,` ·`,` `,a.candidates?a.exhaustive===!1?`${a.candidates} known function${a.candidates===1?``:`s`}, may not be all`:a.candidates===1?`one possible function`:`one of ${a.candidates} functions`:jx[a.reason]??a.reason]})]}),i.length>1&&(0,K.jsx)(`button`,{className:`icon expand`,"aria-expanded":o===e,"aria-label":`Show all ${i.length}`,onClick:()=>s(o===e?null:e),children:o===e?`▾`:`▸`})]}),i.length===1&&(0,K.jsx)(Fx,{project:n,id:a.id}),o===e&&(0,K.jsx)(`ul`,{className:`occurrences`,children:i.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{"data-command":`select`,"data-kind":`site`,onClick:()=>r(l(e),e.file),children:t(e)}),(0,K.jsx)(Fx,{project:n,id:e.id})]},e.id))})]},e)}),c.length>i&&(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link`,onClick:()=>a(i+Mx),children:[c.length-i,` more…`]})})]})}function Rx(e,t,n=0){let r=e&&t?`${e}|${t.a}|${t.b}`:null,[i,a]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!r||!e||!t)return;let n=!1;return L.diff(e,t.a,t.b).then(e=>!n&&a({key:r,data:e,error:null}),e=>!n&&a({key:r,data:null,error:e.message})),()=>{n=!0}},[r,n]),i&&i.key===r?{data:i.data,error:i.error}:{data:null,error:null}}var zx={added:`+`,removed:`−`,changed:`~`},Bx={added:`added`,removed:`removed`,changed:`changed`};function Vx(e){let t=e.fact,n=e=>String(e??``).slice(String(e??``).lastIndexOf(`:`)+1);switch(e.type){case`Function`:return`function ${String(t.qualifiedName??t.name??n(e.id))}`;case`File`:return`file ${String(t.path??e.id)}`;case`CALLS`:case`CALLS_CROSS_FILE`:return`call ${n(t.from)} → ${n(t.to)}`;case`IMPORTS`:return`import ${String(t.specifier??``)}`;case`UnresolvedImport`:return`import ${String(t.specifier??``)} (${String(t.outcome??``)}${t.reason?`: ${String(t.reason)}`:``})`;case`UnresolvedCallSite`:return`open call ${String(t.expression??``)}`;case`SiteResolution`:return`call ${String(t.site??``).split(`|`)[3]??``} (${String(t.status??``)})`;case`Group`:return`group ${String(t.name??e.id)}`;case`DEPENDS_ON`:return`dependency ${String(t.from??``)} → ${String(t.to??``)}`;case`ExternalPackage`:return`package ${String(t.name??e.id)}`;case`Finding`:return`finding: ${String(t.message??t.kind??``)}`;default:return`${e.type} ${e.id}`}}function Hx(e){let t=[];for(let[n,r]of Object.entries({Function:`functions`,File:`files`,IMPORTS:`imports`,CALLS:`calls`,CALLS_CROSS_FILE:`cross-file calls`,UnresolvedImport:`unresolved imports`})){let i=e.byType[n];if(!i||i.added+i.removed+i.changed===0)continue;let a=[i.added?`+${i.added}`:``,i.removed?`−${i.removed}`:``,i.changed?`${i.changed} changed`:``].filter(Boolean);t.push(`${a.join(`, `)} ${r}`)}let{added:n,removed:r,changed:i}=e.total;return t.length?t.join(` · `):n+r+i===0?`No changes`:`${n+r+i} changes`}function Ux(e,t){return e.type===`ExternalPackage`?!1:e.change===`removed`?e.file!==null&&e.type!==`File`&&!t.has(e.file):e.file!==null||e.type===`Group`||e.type===`DEPENDS_ON`}var Wx=e=>e.startsWith(`sha256:`)?`folder`:e.slice(0,7),Gx=e=>e?new Date(e).toLocaleString():``;function Kx({run:e,picked:t,viewing:n,onPick:r,onView:i}){let a=e.sources.filter(e=>!e.pinned);return(0,K.jsxs)(`li`,{className:`run-row${n?` viewing`:``}`,"data-run":e.runId,children:[(0,K.jsx)(`label`,{className:`pick`,children:(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`compare-pick`,checked:t,onChange:e=>r(e.target.checked),"aria-label":`Compare run ${e.runId}`})}),(0,K.jsxs)(`span`,{className:`what`,children:[(0,K.jsxs)(`span`,{className:`title`,children:[(0,K.jsxs)(`strong`,{children:[`Run `,e.runId]}),e.current?(0,K.jsx)(`span`,{className:`badge`,children:`latest`}):null,e.kind===`branch`?(0,K.jsx)(`span`,{className:`badge`,children:`branch`}):null,e.kind===`draft`?(0,K.jsx)(`span`,{className:`badge`,children:`draft`}):null,e.kind===`debug`?(0,K.jsxs)(`span`,{className:`badge`,"data-testid":`debug-badge`,children:[`debug · until `,e.until]}):null]}),(0,K.jsx)(`span`,{className:`commits`,children:(a.length?a:e.sources).map(e=>`${e.sourceId}@${Wx(e.revision)}${e.branch?` (${e.branch})`:``}`).join(`, `)||`no sources`}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.trigger===`commit`?`commit hook`:e.trigger,` · +`,e.written,` / −`,e.closed,` ·`,` `,Gx(e.finishedAt)]})]}),(0,K.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:i,disabled:n,children:n?`Viewing`:`View`})]})}function qx({project:e,refresh:t,run:n,compare:r,diff:i,diffError:a,onView:o,onCompare:s,onClose:c,onLocate:l,stages:u=[],onDebug:f}){let[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(null),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(r?[r.a,r.b]:[]);(0,d.useEffect)(()=>{r&&b([r.a,r.b])},[r?.a,r?.b]);let[x,S]=(0,d.useState)(``);(0,d.useEffect)(()=>{let t=!1;return L.history(e).then(e=>!t&&(g(e),v(null)),e=>!t&&v(e.message)),()=>{t=!0}},[e,t]);let C=(e,t)=>b(n=>t?[...n.filter(t=>t!==e),e].slice(-2):n.filter(t=>t!==e)),w=y.length===2?{a:Math.min(...y),b:Math.max(...y)}:null,T=(0,d.useMemo)(()=>new Set((i?.items??[]).filter(e=>e.type===`File`&&e.change===`removed`).map(e=>e.id)),[i]),E=(0,d.useMemo)(()=>{if(!i)return[];let e=x.trim().toLowerCase(),t=new Map(i.files.map(e=>[e.file??`\0${e.source}`,e.group?.name??e.source])),n=new Map;for(let r of i.items){let i=Vx(r);if(e&&!`${i} ${r.file??``} ${r.type}`.toLowerCase().includes(e))continue;let a=r.file??`\0${r.source}`,o=t.get(a)??r.source,s=n.get(o);s||n.set(o,s=new Map);let c=s.get(a);c||s.set(a,c=[]),c.push({item:r,words:i})}return[...n].sort(([e],[t])=>e<t?-1:1)},[i,x]);return(0,K.jsxs)(`div`,{className:`history-panel`,"data-testid":`history-panel`,children:[(0,K.jsxs)(`div`,{className:`history-head`,children:[(0,K.jsx)(`strong`,{children:`History`}),(0,K.jsx)(`button`,{className:`icon`,"data-command":`toggle-history`,"aria-label":`Close History`,onClick:c,children:`×`})]}),r?(0,K.jsxs)(`section`,{className:`changes`,"aria-label":`Changes`,"data-testid":`change-list`,children:[(0,K.jsxs)(`div`,{className:`compare-head`,children:[(0,K.jsxs)(`span`,{children:[`Changes from run `,r.a,` to run `,r.b]}),(0,K.jsx)(`button`,{className:`link`,"data-command":`compare-runs`,onClick:()=>s(null),children:`Stop comparing`})]}),a?(0,K.jsx)(`p`,{className:`error`,children:a}):i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`summary`,"data-testid":`change-summary`,children:Hx(i)}),(0,K.jsxs)(`p`,{className:`legend muted small`,children:[`On the canvas:`,` `,(0,K.jsxs)(`span`,{className:`change added`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`+`}),`added`]}),` `,`(solid blue border),`,` `,(0,K.jsxs)(`span`,{className:`change removed`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`−`}),`removed`]}),` `,`(dashed orange),`,` `,(0,K.jsxs)(`span`,{className:`change changed`,children:[(0,K.jsx)(`span`,{className:`sign`,children:`~`}),`changed`]}),` `,`(double purple).`]}),i.latestOnly.length>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`Not compared (plain folders have no history): `,i.latestOnly.join(`, `)]}),(0,K.jsx)(`input`,{type:`search`,className:`filter`,placeholder:`Filter changes`,"aria-label":`Filter changes`,"data-testid":`change-filter`,value:x,onChange:e=>S(e.target.value)}),E.map(([e,t])=>(0,K.jsxs)(`div`,{className:`change-group`,children:[(0,K.jsx)(`h4`,{children:e}),[...t].map(([e,t])=>(0,K.jsxs)(`div`,{className:`change-file`,children:[(0,K.jsx)(`div`,{className:`file-name`,children:e.startsWith(`\0`)?`(the repository)`:e.slice(e.indexOf(`:`)+1)}),(0,K.jsx)(`ul`,{children:t.map(({item:e,words:t})=>{let n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`sign`,"aria-hidden":`true`,children:zx[e.change]}),(0,K.jsxs)(`span`,{className:`visually-hidden`,children:[Bx[e.change],`: `]}),t]});return(0,K.jsx)(`li`,{className:`change ${e.change}`,children:Ux(e,T)?(0,K.jsx)(`button`,{className:`link`,"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,onClick:()=>l(e),children:n}):(0,K.jsx)(`span`,{"data-testid":`change-item`,"data-id":e.id,"data-change":e.change,children:n})},`${e.change}:${e.id}`)})})]},e))]},e)),i.truncated&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`The first `,i.items.length,` of`,` `,i.total.added+i.total.removed+i.total.changed,` changes are listed.`]})]}):(0,K.jsx)(`p`,{className:`muted`,children:`Comparing…`})]}):null,_?(0,K.jsx)(`p`,{className:`error`,children:_}):null,h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`compare-bar`,children:[(0,K.jsx)(`button`,{"data-command":`compare-runs`,disabled:!w,onClick:()=>w&&s(w),title:`Pick two runs to compare`,children:w?`Compare run ${w.a} with run ${w.b}`:`Pick two runs to compare`}),n!==null&&(0,K.jsx)(`button`,{className:`link`,"data-command":`open-run`,onClick:()=>o(null),children:`Back to latest`})]}),(0,K.jsxs)(`ol`,{className:`runs`,"aria-label":`Runs`,children:[h.draft&&(0,K.jsx)(Kx,{run:h.draft,picked:y.includes(h.draft.runId),viewing:n===h.draft.runId,onPick:e=>C(h.draft.runId,e),onView:()=>o(h.draft.runId)}),h.debug&&(0,K.jsx)(Kx,{run:h.debug,picked:y.includes(h.debug.runId),viewing:n===h.debug.runId,onPick:e=>C(h.debug.runId,e),onView:()=>o(h.debug.runId)}),h.runs.map(e=>(0,K.jsx)(Kx,{run:e,picked:y.includes(e.runId),viewing:n===null?e.current:n===e.runId,onPick:t=>C(e.runId,t),onView:()=>o(e.current?null:e.runId)},e.runId))]}),h.hidden>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[h.hidden,` older runs aren't shown: this license shows 30 days of history.`]}),h.latestOnly.length>0&&(0,K.jsxs)(`p`,{className:`muted small`,children:[`Not under version control, so latest only: `,h.latestOnly.join(`, `),`. History and diffs need git.`]}),f&&u.length>0&&h.runs.length>0&&(0,K.jsxs)(`form`,{className:`debug-run`,onSubmit:e=>{e.preventDefault(),f(p||u[0])},children:[(0,K.jsxs)(`label`,{className:`muted small`,children:[`Debug run: stop after`,` `,(0,K.jsx)(`select`,{"data-testid":`debug-until`,value:p||u[0],onChange:e=>m(e.target.value),children:u.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsx)(`button`,{type:`submit`,"data-command":`analyze-debug`,"data-testid":`analyze-debug`,title:`Never committed: open it and compare it with the latest`,children:`Run`})]}),(0,K.jsxs)(`p`,{className:`muted small hook-note`,children:[`A run for each commit: `,(0,K.jsx)(`code`,{children:`veoflow hook install`}),` in a repository.`]})]}):!_&&(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`})]})}var Jx=e=>e.startsWith(`sha256:`)?``:e.slice(0,7),Yx=e=>e.split(`
|
|
333
333
|
`).map(e=>e.trim()).filter(Boolean);function Xx({source:e,onSave:t,onCancel:n}){let[r,i]=(0,d.useState)(e.include.join(`
|
|
334
334
|
`)),[a,o]=(0,d.useState)(e.exclude.join(`
|
|
335
|
-
`));return(0,K.jsxs)(`form`,{className:`rules-editor`,"data-testid":`rules-editor`,onSubmit:e=>{e.preventDefault(),t({include:Yx(r),exclude:Yx(a)})},children:[(0,K.jsxs)(`p`,{className:`muted small`,children:[`Glob patterns, one per line, relative to the repository (`,(0,K.jsx)(`code`,{children:`src/legacy/`}),`,`,` `,(0,K.jsx)(`code`,{children:`**/*.test.ts`}),`). Applied at the next analysis; files left out are closed in the graph and kept in history.`]}),(0,K.jsxs)(`label`,{children:[`Include only`,(0,K.jsx)(`textarea`,{"data-testid":`rules-include`,value:r,onChange:e=>i(e.target.value)})]}),(0,K.jsxs)(`label`,{children:[`Leave out`,(0,K.jsx)(`textarea`,{"data-testid":`rules-exclude`,value:a,onChange:e=>o(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`rules-save`,children:`Save and re-analyze`})]})]})}function Zx({project:e,refresh:t,onAdd:n,onChooseFiles:r,onAnalyzeAll:i,onChanged:a,escape:o}){let[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)({top:0,right:0}),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(0);(0,d.useEffect)(()=>{let t=!1;return L.sources(e).then(e=>!t&&c(e.sources.map(e=>({...e,optIn:e.optIn??[]}))),e=>!t&&u(e.message)),()=>{t=!0}},[e,t,O]);let A=async(e,t,n)=>{D(!0),u(``),n&&p(n);try{await e(),p(t),a()}catch(e){p(``),u(e.message??String(e))}finally{D(!1),k(e=>e+1)}},j=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!S)return;j.current?.querySelector(`button`)?.focus();let e=e=>{e.type===`mousedown`&&j.current?.contains(e.target)||C(null)};return document.addEventListener(`mousedown`,e),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[S]),o.current=()=>{if(S){let e=S;return C(null),document.querySelector(`tr[data-source="${CSS.escape(e)}"] [data-testid="repo-more"]`)?.focus(),!0}return m?(h(null),!0):b?(x(null),!0):v?(y(null),!0):!1};let M=(0,d.useRef)(null);if((0,d.useEffect)(()=>{(v||b)&&(M.current?.scrollIntoView({block:`nearest`}),M.current?.querySelector(`textarea, button`)?.focus())},[v,b]),(0,d.useEffect)(()=>{s&&(v&&!s.some(e=>e.id===v)&&y(null),b&&!s.some(e=>e.id===b)&&x(null))},[s,v,b]),!s)return(0,K.jsx)(`p`,{className:l?`error`:`muted`,children:l||`Loading…`});let N=v?s.find(e=>e.id===v):void 0;return(0,K.jsxs)(`div`,{className:`repositories`,"data-testid":`repositories`,children:[(0,K.jsxs)(`div`,{className:`repo-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`repo-add`,onClick:n,children:`+ Add folder`}),(0,K.jsx)(`button`,{"data-testid":`repo-analyze-all`,disabled:E,onClick:i,children:`Re-analyze all`})]}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l}),f&&(0,K.jsx)(`p`,{className:`muted small`,role:`status`,"data-testid":`repo-status`,children:f}),(0,K.jsxs)(`table`,{className:`repo-table`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{children:`Repository`}),(0,K.jsx)(`th`,{children:`Branch and commit`}),(0,K.jsx)(`th`,{children:`Analyzed`}),(0,K.jsx)(`th`,{children:`Files`}),(0,K.jsx)(`th`,{children:`Left out`}),(0,K.jsx)(`th`,{children:(0,K.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,K.jsx)(`tbody`,{children:s.map(t=>{let n=t.analysis,i=t.include.length+t.exclude.length;return(0,K.jsxs)(`tr`,{"data-source":t.id,children:[(0,K.jsxs)(`td`,{children:[m===t.id?(0,K.jsx)(`form`,{onSubmit:n=>{n.preventDefault(),h(null),A(()=>L.updateSource(e,t.id,{name:g}),`Renamed ${t.id} to ${g||t.id}.`)},onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&h(null),children:(0,K.jsx)(`input`,{autoFocus:!0,"aria-label":`New name for ${t.id}`,"data-testid":`repo-name`,value:g,onChange:e=>_(e.target.value)})}):(0,K.jsx)(`strong`,{className:`repo-name`,children:t.name??t.id}),(0,K.jsx)(`div`,{className:`muted small path`,children:t.root}),n?.notices.map(e=>(0,K.jsx)(`div`,{className:`notice-line small`,children:e},e))]}),(0,K.jsx)(`td`,{className:`mono small`,children:n?n.kind===`plain`?`plain folder (latest only)`:`${n.branch??`detached`} · ${Jx(n.revision)}${n.pinned?` (kept)`:``}`:`not analyzed yet`}),(0,K.jsx)(`td`,{className:`small`,children:n?W(n.analyzedAt):``}),(0,K.jsx)(`td`,{className:`small`,children:n?n.files:``}),(0,K.jsx)(`td`,{className:`small`,children:i?`${i} rule${i===1?``:`s`}`:`defaults`}),(0,K.jsxs)(`td`,{className:`row-actions`,children:[(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-analyze`,"aria-label":`Re-analyze ${t.name??t.id}`,disabled:E,onClick:()=>void A(()=>L.analyzeSource(e,t.id),`Analyzing ${t.name??t.id} again (the others stay at their commits)…`,`Starting an analysis of ${t.name??t.id}…`),children:`Re-analyze`}),(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-choose`,"aria-label":`Choose files in ${t.name??t.id}`,onClick:()=>r(t.id),children:`Choose files…`}),(0,K.jsxs)(`span`,{className:`menu-wrap`,children:[(0,K.jsx)(`button`,{className:`icon`,"aria-label":`More for ${t.name??t.id}`,"aria-expanded":S===t.id,"data-testid":`repo-more`,disabled:E,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();T({top:n.bottom+2,right:window.innerWidth-n.right}),C(S===t.id?null:t.id)},children:`⋯`}),S===t.id&&(0,K.jsxs)(`span`,{className:`menu`,role:`menu`,ref:j,style:{top:w.top,right:w.right},children:[(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rename`,onClick:()=>{C(null),_(t.name??t.id),h(t.id)},children:`Rename`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rules`,onClick:()=>{C(null),y(t.id)},children:`Edit rules`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-remove`,onClick:()=>{C(null),x(t.id)},children:`Remove…`})]})]})]})]},t.id)})})]}),s.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No repositories yet: + Add folder adds one.`}),N&&(0,K.jsx)(`div`,{ref:M,children:(0,K.jsx)(Xx,{source:N,onCancel:()=>y(null),onSave:t=>{let n=N.id;y(null),A(async()=>{await L.updateSource(e,n,t),await L.analyzeSource(e,n)},`Rules saved; analyzing ${n} again…`)}},N.id)}),b&&(0,K.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`remove-title`,"data-testid":`repo-remove-confirm`,children:[(0,K.jsx)(`p`,{id:`remove-title`,children:(0,K.jsxs)(`strong`,{children:[`Remove `,s.find(e=>e.id===b)?.name??b,` from this project?`]})}),(0,K.jsx)(`p`,{className:`muted small`,children:`Its files and links leave the current graph. History keeps the analysis: earlier runs still show it, and adding the folder again analyzes it afresh. The folder itself is not touched.`}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{onClick:()=>x(null),"data-testid":`repo-remove-cancel`,children:`Cancel`}),(0,K.jsx)(`button`,{className:`danger`,"data-testid":`repo-remove-yes`,disabled:E,onClick:()=>{let t=b;x(null),A(()=>L.removeSource(e,t),`Removed ${t}; history keeps its analysis.`,`Removing ${t} (a run closes its facts)…`)},children:`Remove`})]})]})]})}function Qx({project:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null);return(0,d.useEffect)(()=>{L.projectSettings(e).then(e=>n(String(e.settings.maxFileMB)),e=>i({ok:!1,text:e.message}))},[e]),(0,K.jsxs)(`form`,{className:`analysis-settings`,onSubmit:n=>{n.preventDefault();let r=Number(t);if(!(r>0&&r<=64))return i({ok:!1,text:`The size limit is more than 0 and at most 64 MB.`});L.saveProjectSettings(e,{maxFileMB:r}).then(e=>i({ok:!0,text:`Saved: files over ${e.settings.maxFileMB} MB are left out at the next analysis.`}),e=>i({ok:!1,text:e.message}))},children:[(0,K.jsxs)(`label`,{children:[`Size limit per file (MB)`,(0,K.jsx)(`input`,{type:`number`,min:.1,max:64,step:.1,required:!0,"data-testid":`analysis-max-mb`,value:t,onChange:e=>n(e.target.value)})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Larger files are listed but not analyzed, unless you choose them in Choose files. Folders of installed libraries, generated output and tools' workspaces (`,(0,K.jsx)(`code`,{children:`node_modules`}),`, `,(0,K.jsx)(`code`,{children:`dist`}),`,`,` `,(0,K.jsx)(`code`,{children:`build`}),`, …) are left out by default; Choose files shows them and can add them.`]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`analysis-save`,children:`Save`}),r&&(0,K.jsx)(`p`,{className:r.ok?`muted small`:`error`,role:r.ok?`status`:`alert`,children:r.text})]})}function $x({project:e,projectName:t,refresh:n,onClose:r,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,covered:c=!1,initialTab:l=`repositories`}){let[u,f]=(0,d.useState)(l),p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)(null);return(0,d.useEffect)(()=>{let e=document.activeElement;return m.current?.focus(),()=>e?.focus?.()},[]),(0,d.useEffect)(()=>{if(c)return;let e=e=>{if(e.key===`Escape`)e.stopPropagation(),h.current?.()||r();else if(e.key===`Tab`&&p.current){let t=[...p.current.querySelectorAll(`button:not([disabled]), input, textarea, select`)],n=t[0],r=t[t.length-1];p.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[c,r]),(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&r(),children:(0,K.jsxs)(`div`,{className:`modal wide`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`project-settings-title`,"data-testid":`project-settings-dialog`,ref:p,children:[(0,K.jsxs)(`div`,{className:`modal-head`,children:[(0,K.jsxs)(`h2`,{id:`project-settings-title`,children:[t,`: settings`]}),(0,K.jsx)(`button`,{className:`icon`,"aria-label":`Close`,onClick:r,ref:m,children:`×`})]}),(0,K.jsx)(`div`,{className:`segmented`,role:`tablist`,"aria-label":`Project settings`,children:[`repositories`,`analysis`,`license`].map(e=>(0,K.jsx)(`button`,{role:`tab`,"aria-selected":u===e,"data-testid":`project-tab-${e}`,onClick:()=>f(e),children:e===`repositories`?`Repositories`:e===`analysis`?`Analysis`:`License`},e))}),u===`repositories`?(0,K.jsx)(Zx,{project:e,refresh:n,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,escape:h}):u===`analysis`?(0,K.jsx)(Qx,{project:e}):(0,K.jsx)(me,{onChanged:s})]})})}var eS={library:`installed library code`,generated:`generated or built output`,tool:`a tool's or coding agent's workspace (settings, history, worktrees)`};function tS(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var nS=(e,t)=>`${e}\0${t}`,rS=(e,t)=>JSON.stringify([e.include,e.exclude,e.optIn??[]])===JSON.stringify([t?.include??[],t?.exclude??[],t?.optIn??[]]);function iS({project:e,files:t,run:n,onAnalyze:r,onClose:i,only:a,at:o}){let[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(new Map),[f,p]=(0,d.useState)(new Set),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(new Map),[S,C]=(0,d.useState)(new Map),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(``),O=(0,d.useRef)(new Set),k=s.length>1,A=(0,d.useCallback)(e=>n?.sources.find(t=>t.sourceId===e),[n]),j=(0,d.useCallback)(async(t,n)=>{let{entries:r}=await L.browse(e,t,n);O.current.add(nS(t,n)),u(e=>new Map(e).set(nS(t,n),r))},[e]),M=(0,d.useCallback)(async()=>{await Promise.all([...O.current].map(e=>{let[t,n]=e.split(`\0`);return j(t,n).catch(()=>O.current.delete(e))}))},[j]);(0,d.useEffect)(()=>{let t=!1;return(async()=>{try{let[{sources:n},{settings:r}]=await Promise.all([L.sources(e),L.projectSettings(e)]);if(t)return;let i=n.map(e=>({...e,optIn:e.optIn??[]})).filter(e=>a===void 0||e.id===a);c(i),T(r.maxFileMB),D(String(r.maxFileMB)),await Promise.all(i.map(e=>j(e.id,``)))}catch(e){t||h(e.message??String(e))}})(),()=>{t=!0}},[e,j,a]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(g?_(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,i]),(0,d.useEffect)(()=>{if(!o||!a||s.length===0)return;let e=o.split(`/`).filter(Boolean),t=e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`));p(e=>new Set([...e,...t.map(e=>nS(a,e))])),Promise.all(t.filter(e=>!O.current.has(nS(a,e))).map(e=>j(a,e))).then(()=>requestAnimationFrame(()=>document.querySelector(`.picker-row[data-path="${CSS.escape(o)}"]`)?.scrollIntoView({block:`center`})),e=>h(e.message))},[o,a,s.length,j]);let N=(e,t)=>{let n=nS(e,t);p(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),O.current.has(n)||j(e,t).catch(e=>h(e.message))},P=(0,d.useMemo)(()=>{let e=[],t=(n,r,i)=>{for(let a of l.get(nS(n,r))??[]){if(a.kind===`file`&&!a.language&&!a.path.toLowerCase().endsWith(`.html`))continue;let r=a.kind===`dir`&&f.has(nS(n,a.path));e.push({source:n,entry:a,depth:i,open:r}),r&&t(n,a.path,i+1)}};for(let e of s)t(e.id,``,+!!k);return e},[l,f,s,k]),F=(e,t)=>{if(t.kind!==`dir`)return!1;let n=e=>e.replace(/^\/+/,``).startsWith(`${t.path}/`),r=l.get(nS(e.id,t.path));if(t.excludedBy)return e.optIn.some(n)?!0:!!r?.some(e=>!e.excludedBy);if(r?.some(e=>e.excludedBy&&(e.kind===`dir`||e.language))||e.exclude.some(e=>e.startsWith(`/`)&&n(e)))return!0;let i=A(e.id),a=t=>e.optIn.some(e=>t===e||t.startsWith(`${e}/`));return i?.defaultExcluded?.some(e=>n(e.path)&&!a(e.path))?!0:rS(e,i?.filter)&&!!i?.ruleExcluded?.some(e=>n(e.path)&&!a(e.path))},I=(e,n,r)=>{if(!r)return-t.filter(t=>t.source===e&&(t.path===n.path||t.path.startsWith(`${n.path}/`))).length;if(n.kind===`file`)return 1;let i=A(e);return i?.defaultExcluded?.find(e=>e.path===n.path)?.files??i?.ruleExcluded?.find(e=>e.path===n.path)?.files??null},R=async(t,n,r)=>{y(!0),h(``),x(e=>new Map(e).set(nS(t,n.path),r));try{let{source:i}=await L.select(e,t,[n.path],r);c(e=>e.map(e=>e.id===t?{...i,optIn:i.optIn??[]}:e)),C(e=>{let i=new Map(e),a=nS(t,n.path);return i.has(a)?i.delete(a):i.set(a,I(t,n,r)),i}),await M()}catch(e){h(e.message??String(e))}finally{x(e=>{let r=new Map(e);return r.delete(nS(t,n.path)),r}),y(!1)}},z=(e,t,n)=>{if(!v){if(n&&t.excludedBy&&t.excludedBy!==`rule`){let n=t.path.slice(t.path.lastIndexOf(`/`)+1),r=A(e)?.defaultExcluded?.find(e=>e.path===t.path),i=t.kind===`dir`&&r?.files?` It has ${r.files.toLocaleString(`en-US`)} file${r.files===1?``:`s`}.`:``;if(t.excludedBy===`too-large`)_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${tS(t.size??0)}, over the ${w??10} MB size limit. Files this large are usually generated or bundled code (minified builds, vendored bundles, source maps), and they slow analysis down. Files over 64 MB are never analyzed.`});else{let r=eS[t.excludedBy]??eS.generated;_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${r}, not your project's own code.${i} Analyzing it makes analysis slower and the graph larger. Its files will be marked as ${t.excludedBy} code and left out of "largest files" and "most called".`})}return}R(e,t,n)}},B=async()=>{let t=Number(E);if(!Number.isFinite(t)||t<=0||t>64){h(`The size limit must be a number of megabytes between 0 and 64.`);return}try{let{settings:n}=await L.saveProjectSettings(e,{maxFileMB:t});T(n.maxFileMB),C(e=>new Map(e).set(`\0limit`,null)),await M()}catch(e){h(e.message??String(e))}},V=S.size>0||s.some(e=>!rS(e,A(e.id)?.filter))||w!==null&&n?.sources[0]?.maxFileBytes!==void 0&&n.sources[0].maxFileBytes!==w*1048576,H=0,U=0,W=!1;for(let[e,t]of S)e!==`\0limit`&&(t===null?W=!0:t>0?H+=t:U-=t);let G=e=>`${e} file${e===1?``:`s`}`,ee=[W?H?`${H}+ files added`:`files added`:H?`${G(H)} added`:``,U?`${G(U)} removed`:``].filter(Boolean).join(`, `);return(0,K.jsxs)(`div`,{className:`picker`,"data-testid":`file-picker`,children:[(0,K.jsxs)(`div`,{className:`picker-head`,children:[(0,K.jsx)(`strong`,{children:`Choose files`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{onClick:i,"data-testid":`picker-done`,children:`Done`})]}),(0,K.jsx)(`p`,{className:`muted small picker-help`,children:`Unchecked files are left out of the graph. Greyed folders are left out by default: libraries and generated output.`}),(0,K.jsxs)(`label`,{className:`picker-limit`,children:[`Skip files over`,(0,K.jsx)(`input`,{type:`number`,min:1,max:64,step:1,value:E,"data-testid":`size-limit`,"aria-label":`Size limit in MB`,onChange:e=>D(e.target.value),onBlur:()=>E!==String(w)&&void B(),onKeyDown:e=>e.key===`Enter`&&void B()}),`MB`]}),m&&(0,K.jsx)(`p`,{className:`error small`,role:`alert`,children:m}),V&&(0,K.jsxs)(`div`,{className:`picker-pending`,"data-testid":`picker-pending`,children:[(0,K.jsxs)(`span`,{children:[ee?(0,K.jsx)(`strong`,{children:ee[0].toUpperCase()+ee.slice(1)}):`Changes`,` at the next analysis`]}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`picker-apply`,disabled:v,onClick:()=>{C(new Map),r()},children:`Apply & re-analyze`})]}),(0,K.jsxs)(`div`,{className:`picker-list`,role:`tree`,"aria-label":`Choose files`,children:[s.map(e=>k?(0,K.jsx)(`div`,{className:`picker-row source`,title:e.root,children:(0,K.jsx)(`strong`,{children:e.id})},`s:${e.id}`):null),P.map(({source:e,entry:t,depth:n,open:r})=>{let i=s.find(t=>t.id===e),a=b.get(nS(e,t.path))??!t.excludedBy,c=F(i,t),l=t.path.slice(t.path.lastIndexOf(`/`)+1),u=t.notAnalyzable?t.notAnalyzable===`declaration-file`?`type declarations`:t.notAnalyzable===`symlink`?`link`:`${tS(t.size??0)} · over 64 MB`:t.excludedBy===`library`?`library`:t.excludedBy===`generated`||t.excludedBy===`tool`?t.excludedBy:t.excludedBy===`too-large`?`${tS(t.size??0)} · too large`:t.excludedBy===`rule`?`excluded`:null,d=t.optedIn?t.origin??null:null;return(0,K.jsxs)(`div`,{className:`picker-row ${t.kind} ${a?``:`excluded`}${t.path===o?` target`:``}`,style:{paddingLeft:8+n*14},role:`treeitem`,"aria-expanded":t.kind===`dir`?r:void 0,"aria-level":n+1,"data-path":t.path,children:[t.kind===`dir`?(0,K.jsx)(`button`,{className:`caret`,"aria-label":`${r?`Close`:`Open`} ${l}`,onClick:()=>N(e,t.path),children:r?`▾`:`▸`}):(0,K.jsx)(`span`,{className:`caret`}),(0,K.jsxs)(`label`,{children:[t.notAnalyzable?(0,K.jsx)(`span`,{className:`caret`}):(0,K.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>z(e,t,n.target.checked)}),(0,K.jsx)(`span`,{className:`name`,children:l})]}),u&&(0,K.jsx)(`small`,{className:`reason`,children:u}),d&&(0,K.jsx)(`small`,{className:`origin ${d}`,children:d})]},nS(e,t.path))}),s.length>0&&P.length===0&&!m&&(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`})]}),g&&(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&_(null),children:(0,K.jsxs)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pick-warning-title`,"data-testid":`pick-warning`,children:[(0,K.jsx)(`h2`,{id:`pick-warning-title`,children:g.title}),(0,K.jsx)(`p`,{children:g.text}),(0,K.jsxs)(`div`,{className:`buttons`,children:[(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{autoFocus:!0,onClick:()=>_(null),children:`Cancel`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`pick-warning-confirm`,onClick:()=>{let e=g;_(null),R(e.source,e.entry,!0)},children:`Analyze anyway`})]})]})})]})}function aS({projects:e,loading:t=!1,onOpen:n,onCreated:r,onAddFolder:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(!1),m=()=>{o(!1),c(``),u(``)},h=async()=>{if(!f){p(!0),u(``);try{let{project:e}=await L.createProject(s.trim());m(),r(e.id)}catch(e){u(e.message??String(e))}finally{p(!1)}}};return(0,K.jsxs)(`section`,{className:`home`,"data-testid":`home`,"aria-labelledby":`home-title`,children:[(0,K.jsxs)(`div`,{className:`home-head`,children:[(0,K.jsx)(`h1`,{id:`home-title`,children:`Projects`}),(0,K.jsxs)(`div`,{className:`home-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`new-project`,onClick:()=>o(!0),children:`+ New project`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`home-add-folder`,onClick:i,children:`Add folder`})]})]}),a&&(0,K.jsxs)(`form`,{className:`new-project`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,K.jsxs)(`label`,{children:[`Name`,(0,K.jsx)(`input`,{autoFocus:!0,"data-testid":`new-project-name`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Escape`&&m()})]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!s.trim()||f,"data-testid":`new-project-create`,children:`Create`}),(0,K.jsx)(`button`,{type:`button`,onClick:m,children:`Cancel`}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l})]}),t?(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`}):e.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`No projects yet. Add a folder to analyze its code.`}):(0,K.jsx)(`ul`,{className:`project-cards`,children:e.map(e=>{let t=e.findings,r=t?t.broken+t.notAnalyzed+t.openCalls:0;return(0,K.jsx)(`li`,{"data-project":e.id,children:(0,K.jsxs)(`button`,{className:`project-card`,"data-testid":`open-project`,onClick:()=>n(e.id),children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.sources,` repositor`,e.sources===1?`y`:`ies`]}),e.error?(0,K.jsxs)(`span`,{className:`error small`,"data-testid":`project-error`,children:[`Can't be read: `,e.error]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`small`,children:e.latest?e.latest.status===`running`?`Analyzing…`:e.latest.status===`failed`?e.latest.errorCode===`cancelled`?`Last analysis cancelled`:`Last analysis failed`:`Analyzed${e.latest.finishedAt?` ${W(e.latest.finishedAt)}`:``}`:`Not analyzed yet`}),t&&(0,K.jsx)(`span`,{className:`muted small`,children:r===0?`No findings`:[t.broken?`${t.broken} broken imports`:``,t.notAnalyzed?`${t.notAnalyzed} not analyzed`:``,t.openCalls?`${t.openCalls} open calls`:``].filter(Boolean).join(` · `)})]})]})},e.id)})})]})}function oS({title:e,entries:t,x:n,y:r,onClose:i}){let a=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=document.activeElement;a.current?.querySelector(`button`)?.focus();let t=e=>{e.type===`mousedown`&&a.current?.contains(e.target)||i()},n=e=>{if(e.key===`Escape`){e.stopPropagation(),i();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let t=[...a.current?.querySelectorAll(`button`)??[]],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},r=e=>{a.current?.contains(e.relatedTarget)||i()},o=a.current;return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,t),document.addEventListener(`scroll`,t,!0),window.addEventListener(`keydown`,n,!0),o?.addEventListener(`focusout`,r),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,t),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`keydown`,n,!0),o?.removeEventListener(`focusout`,r),e&&e!==document.body&&document.contains(e)&&e.focus()}},[i]);let o=Math.max(4,Math.min(n,window.innerWidth-260)),s=Math.max(4,Math.min(r,window.innerHeight-40-t.length*30));return(0,K.jsxs)(`div`,{ref:a,className:`context-menu`,role:`menu`,"aria-label":e,"data-testid":`context-menu`,style:{left:o,top:s},children:[(0,K.jsx)(`div`,{className:`context-title`,"aria-hidden":`true`,children:e}),t.map(e=>(0,K.jsx)(`button`,{role:`menuitem`,tabIndex:-1,"data-command-name":e.command,onClick:()=>{i(),e.run()},children:e.label},e.label))]})}function sS(e,t){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return i;let a=0,o=0;for(let e of r)if(e===n[a]?a++:a>0&&o++,a===n.length)return 100+o;return null}function cS(e,t,n){return n===0?[]:t.map((t,n)=>({item:t,i:n,score:sS(e,t.label)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).slice(0,n).map(e=>e.item)}function lS(e,t){let{view:n,command:r}=t,i=e.trim(),a=[];if(n.project){let e=cS(i,t.files.map(e=>({...e,label:e.path})),i?5:0);for(let i of e)a.push({key:`file:${i.id}`,group:`Files`,label:i.path,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:i.id}):r(`openFile`,{file:i.id})}),e.length<=2&&(n.tab===`imports`&&n.group!==null&&!n.fileLevel&&a.push({key:`only:${i.id}`,group:`Files`,label:`Show only links of ${i.path}`,run:()=>r(`showOnlyLinks`,{id:i.id})}),a.push({key:`leave:${i.id}`,group:`Files`,label:`Leave ${i.path} out of analysis…`,run:()=>t.action(`chooseFiles`,{source:i.id.slice(0,i.id.indexOf(`:`)),path:i.path})}));for(let e of cS(i,t.groups.map(e=>({...e,label:e.name})),i?4:0))a.push({key:`group:${e.id}`,group:`Groups`,label:e.name,detail:`open the group`,run:()=>r(`openGroup`,{group:e.id})}),a.push({key:`only:${e.id}`,group:`Groups`,label:`Show only links of ${e.name}`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}}),a.push({key:`pick:${e.id}`,group:`Groups`,label:`Details of ${e.name}`,detail:`on the project map`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`pickNode`,{id:e.id})}})}let o=[],s=(e,t,n,r)=>o.push({label:e,run:t,...n?{detail:n}:{},...r?{key:r}:{}});if(n.project){s(n.history?`Close History`:`History: runs by commit`,()=>r(`toggleHistory`)),n.compare&&s(`Stop comparing`,()=>r(`compareRuns`,{}));let e=/^(?:compare\s+)?(?:run\s*)?(\d+)\s*(?:\.\.|with|vs|and|,|\s)\s*(?:run\s*)?(\d+)$/i.exec(i);if(e){let[t,n]=[Number(e[1]),Number(e[2])];s(`Compare run ${Math.min(t,n)} with run ${Math.max(t,n)}`,()=>r(`compareRuns`,{a:t,b:n}))}n.run!==null&&s(`Back to latest`,()=>r(`openRun`,{}));let a=/^(?:view\s+)?run\s*(\d+)$/i.exec(i);a&&s(`View run ${a[1]}`,()=>r(`openRun`,{run:Number(a[1])})),s(`File tab`,()=>r(`showTab`,{tab:`file`}),`functions and calls inside a file`),s(`Imports tab`,()=>r(`showTab`,{tab:`imports`}),`how files depend on each other`),s(`Show the code`,()=>r(`showPanel`,{panel:`evidence`})),s(`Show Findings`,()=>r(`showPanel`,{panel:`questions`})),s(n.showPending?`Hide pending imports`:`Show pending imports`,()=>r(`togglePending`)),s(n.showUnresolved?`Hide unresolved call sites`:`Show unresolved call sites`,()=>r(`toggleUnresolved`)),n.selection&&s(`Clear the selection`,()=>r(`clearSelection`)),n.only&&s(`Show everything again`,()=>r(`showOnlyLinks`,{}),`not only one item's links`);for(let e of t.sources)s(`Re-analyze ${e.name??e.id}`,()=>t.action(`analyzeSource`,{source:e.id}),`this repository only`,`analyze:${e.id}`);if(t.sources.length>1){n.source&&s(`Scope: all repositories`,()=>r(`scopeSource`,{}));for(let e of t.sources)e.id!==n.source&&s(`Scope: ${e.name??e.id}`,()=>r(`scopeSource`,{source:e.id}),`one repository only`,`scope:${e.id}`)}n.group&&i.includes(`/`)&&s(`Open or close folder ${i}`,()=>r(`toggleFolder`,{path:i.replace(/^\.?\//,``).replace(/\/$/,``)})),s(`Re-analyze the project`,()=>t.action(`analyze`)),t.canDraft&&s(`Analyze uncommitted edits`,()=>t.action(`analyzeDraft`),`a draft beside the graph`);for(let e of t.stages??[])s(`Debug run: stop after ${e}`,()=>t.action(`analyzeDebug`,{until:e}),`never committed; compare it with the latest`,`debug:${e}`);s(`Repositories…`,()=>t.action(`openProjectSettings`),`re-analyze, choose files, rename, remove`),s(`License…`,()=>t.action(`openProjectSettings`,{tab:`license`}),`what the license includes; add or replace a key`)}n.project&&s(`All projects (home)`,()=>r(`goHome`),`every project and its last run`),s(`Add a folder…`,()=>t.action(`addFolder`)),s(`Settings…`,()=>t.action(`openSettings`),`the model for questions`);for(let e of t.projects)e.id!==n.project&&s(`Switch to project ${e.name}`,()=>r(`selectProject`,{project:e.id}),void 0,`project:${e.id}`);let c=o.filter(e=>/^(Compare run|View run|Open or close folder)/.test(e.label)),l=cS(i,o.filter(e=>!c.includes(e)),i?6:0);for(let e of[...c,...l])a.push({key:`cmd:${e.key??e.label}`,group:`Commands`,label:e.label,run:e.run,...e.detail?{detail:e.detail}:{}});return a}var uS=e=>e.reason===`imported-symbol`||e.reason===`template-reference`;function dS(e){let t=e.group;if(!t)return e.path;let n=t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t.name} › ${n}`}var fS={broken:`its import is broken`,pending:`its import waits for another source`,"not-analyzed":`its import leads to a file not analyzed`};function pS({project:e,graph:t,fn:n,onOpen:r,onShowImports:i}){let[a,o]=(0,d.useState)(null),s=t.file.id,c=t.unresolved.some(uS);(0,d.useEffect)(()=>{if(!c)return;let t=!1;return L.siteLinks(e,s).then(e=>!t&&o({file:s,byId:new Map(e.links.map(e=>[e.site,e]))}),()=>!t&&o({file:s,byId:`error`})),()=>{t=!0}},[e,s,t.committedRun,c]);let l=t.unresolved.filter(e=>e.enclosingFn===n&&uS(e)&&!e.component).sort((e,t)=>e.evidence.span.start.offset-t.evidence.span.start.offset);if(l.length===0)return null;let u=a?.file===s?a.byId:null,f=u===`error`?null:u;return(0,K.jsxs)(`div`,{className:`imported-calls`,"data-testid":`imported-calls`,children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Calls into other files (`,l.length,`)`]}),u===`error`&&(0,K.jsx)(`p`,{className:`small muted`,children:`Where these calls lead couldn't be loaded.`}),l.map(e=>{let t=f?.get(e.id),n=e.importSpecifier?`imported from ${e.importSpecifier}`:`defined in another file`;return(0,K.jsxs)(`div`,{className:`imported-call`,"data-testid":`imported-call`,"data-site":e.id,children:[(0,K.jsxs)(`span`,{className:`mono small`,children:[e.expression,` · line `,e.evidence.span.start.line]}),u===`error`?(0,K.jsx)(`span`,{className:`small muted`,children:n}):f===null?(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`…`]}):t?.status===`linked`&&t.target?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`small`,children:[`calls `,(0,K.jsx)(`strong`,{children:t.target.name}),` in`,` `,(0,K.jsx)(`span`,{className:`mono`,children:dS(t.target)}),`, found by`,` `,t.via===`import`?`import analysis`:`component linking`]}),(0,K.jsxs)(`span`,{className:`small links`,children:[(0,K.jsx)(`button`,{className:`button-link`,"data-command":`open-imported`,onClick:()=>r({id:t.target.id,file:t.target.file}),children:`Open that file`}),(0,K.jsx)(`button`,{className:`button-link`,"data-command":`show-in-imports`,onClick:i,children:`Show in Imports`})]})]}):t?.status===`external`?(0,K.jsxs)(`span`,{className:`small`,children:[`calls into the external package `,(0,K.jsx)(`strong`,{children:t.package?.name})]}):t?(0,K.jsxs)(`span`,{className:`small`,children:[n,`, not linked`,t.importOutcome?`: ${fS[t.importOutcome]}`:t.candidates?.length?`: it could be any of ${t.candidates.length} functions`:t.reason?`: ${t.reason}`:``]}):(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`, not linked yet`]})]},e.id)})]})}function mS(e,t,n,r){let i=e=>e.slice(e.indexOf(`:`)+1),a=e=>e.split(`/`).slice(-2).join(`/`),o=r.calls?t.out.calls:[],s=r.calls?t.in.calls:[],c=new Map;for(let e of o)c.set(e.from.id,e.from.name);for(let e of s)c.set(e.to.id,e.to.name);let l=[...c].sort((e,t)=>e[1]<t[1]?-1:+(e[1]>t[1])).map(([e])=>e),u=(e,t)=>({id:`${e}|${t.id}`,file:t.file,label:`${a(t.path)} ›\n${t.name}`}),d=new Map(s.map(e=>[e.from.id,u(`caller`,e.from)])),f=new Map(o.map(e=>[e.to.id,u(`callee`,e.to)])),p=new Map,m=new Map;if(r.imports&&n){for(let t of n.imports)t.outcome===`file`&&t.file&&t.file.id!==e&&!m.has(t.file.id)&&m.set(t.file.id,{id:`imported|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimported`,edge:t.id});for(let t of n.importedBy.files)t.file.id!==e&&!p.has(t.file.id)&&p.set(t.file.id,{id:`importer|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimports this file`,edge:t.id})}let h=e=>[...e.values()].sort((e,t)=>e.label<t.label?-1:+(e.label>t.label)),g=[...h(d),...h(p)],_=[...h(f),...h(m)],v=Math.max(l.length,1),y=e=>-((e-1)*58)/2,b=[{data:{id:`box`,kind:`box`,label:i(e),w:210,h:v*58+50},position:{x:0,y:0},classes:`box`},...l.map((e,t)=>({data:{id:e,kind:`function`,label:`ƒ ${c.get(e)}`},position:{x:0,y:y(l.length)+t*58+12},classes:`function`})),...g.map((e,t)=>({data:{id:e.id,kind:`port`,side:`left`,file:e.file,label:e.label},position:{x:-330,y:y(g.length)+t*58},classes:e.id.startsWith(`importer|`)?`port file`:`port`})),..._.map((e,t)=>({data:{id:e.id,kind:`port`,side:`right`,file:e.file,label:e.label},position:{x:330,y:y(_.length)+t*58},classes:e.id.startsWith(`imported|`)?`port file`:`port`}))],x=new Map,S=(e,t,n)=>{let r=`${e}->${t}`,i=x.get(r);i?i.calls.push(n):x.set(r,{id:n,source:e,target:t,calls:[n]})};for(let e of o)S(e.from.id,`callee|${e.to.id}`,e.id);for(let e of s)S(`caller|${e.from.id}`,e.to.id,e.id);for(let e of x.values())b.push({data:{id:e.id,kind:`call`,source:e.source,target:e.target,calls:e.calls,label:e.calls.length>1?`×${e.calls.length}`:``},classes:`call`});for(let e of m.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:`box`,target:e.id,label:``},classes:`import`});for(let e of p.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:e.id,target:`box`,label:``},classes:`import`});return b}function hS({file:e,calls:t,imports:n,show:r,pick:i,onPick:a,onOpenFile:o,onClear:s,marks:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let m=(0,d.useRef)(l);m.current=l,(0,d.useEffect)(()=>{f.current&&xe(f.current,c)},[c]);let h=(0,d.useRef)({onPick:a,onOpenFile:o,onClear:s});h.current={onPick:a,onOpenFile:o,onClear:s};let g=(0,d.useMemo)(()=>mS(e,t,n,r),[e,t,n,r.calls,r.imports]);(0,d.useEffect)(()=>{if(!u.current)return;let e=p_({container:u.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.15,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:170,height:36,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:`#1d2330`,"background-color":`#fff`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.box`,style:{"background-color":`#f7faff`,"border-color":`#c6d6f3`,"border-width":2,"text-valign":`top`,"text-margin-y":18,color:`#2a56ad`,"font-weight":`bold`,width:`data(w)`,height:`data(h)`,events:`no`,"z-index":0}},{selector:`node.port`,style:{width:210,height:42,"border-style":`dashed`,"border-color":`#6b87b8`}},{selector:`node.port.file`,style:{"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":`#6b87b8`,"line-style":`dashed`,"target-arrow-shape":`triangle`,"target-arrow-color":`#6b87b8`,"arrow-scale":.8,label:`data(label)`,"font-size":10,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1}},{selector:`edge.import`,style:{"line-color":`#b7c0cf`,"target-arrow-color":`#b7c0cf`}},...be,{selector:`.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`,width:3}}]});return e.on(`tap`,`node`,e=>{e.target.data(`kind`)===`port`&&h.current.onOpenFile(e.target.data(`file`))}),e.on(`tap`,`edge`,e=>h.current.onPick(e.target.data(`edge`)??e.target.id())),e.on(`tap`,t=>{t.target===e&&h.current.onClear()}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),f.current=e,xe(e,p.current),e.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`port`&&t.file?`file`:t.kind===`call`||t.kind===`import`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),()=>{f.current=null,e.destroy()}},[g]),(0,d.useEffect)(()=>{let e=f.current;e&&(e.elements().removeClass(`picked`),i&&e.edges().filter(e=>(e.data(`calls`)??[]).includes(i)||e.data(`edge`)===i).addClass(`picked`))},[i,g]);let _=e=>g.filter(t=>t.data.kind===`port`&&t.data.side===e).map(e=>e.data.id).join(` `),v=[t.in,t.out].filter(e=>e.truncated),y=(r.calls?t.out.calls.length+t.in.calls.length:0)===0,b=[...new Map([...t.in.calls.map(e=>e.from),...t.out.calls.map(e=>e.to)].map(e=>[e.file,e])).values()];return(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[y&&r.calls&&(0,K.jsx)(`p`,{className:`hint overlay`,"data-testid":`no-cross-file-calls`,children:`No calls cross into or out of this file.`}),(0,K.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`file-canvas`,"data-calls":g.filter(e=>e.data.kind===`call`).length,"data-imports":g.filter(e=>e.data.kind===`import`).length,"data-ports-left":_(`left`),"data-ports-right":_(`right`)}),v.length>0&&(0,K.jsxs)(`p`,{className:`hint small overlay bottom`,"data-testid":`calls-truncated`,children:[v.map(e=>`Showing ${e.calls.length} of ${e.total} calls ${e.direction===`in`?`into`:`out of`} this file`).join(`; `),`.`]}),(0,K.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Cross-file calls`,children:[t.in.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`in`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.path,` › `,e.from.name,` calls `,e.to.name]})},e.id)),t.out.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`out`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.name,` calls `,e.to.path,` › `,e.to.name]})},e.id)),b.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.file,tabIndex:-1,onClick:()=>o(e.file),children:[`Open `,e.path]})},e.file))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>f.current?.fit(void 0,30),children:`Fit`})]})}var gS={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`},_S=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`;function vS(e){e.fit(void 0,40);let t=e.zoom();if(t>1.2)e.zoom(1.2),e.center();else if(t<.9){let t=e.elements().boundingBox();e.zoom(.9),e.pan({x:40-t.x1*.9,y:40-t.y1*.9})}}function yS(e,t){if(!e||!t)return 0;let n=Math.abs(t.x-e.x)/290;return n>1.2||t.x<e.x?-(84*.9+12*Math.min(4,n)):0}var bS=(e,t)=>1+6*Math.sqrt(e/Math.max(1,t));function xS({map:e,layoutKey:t,pick:n,showPackages:r,onPick:i,onOpen:a,onClear:o,marks:s=null,only:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let m=(0,d.useRef)(l);m.current=l,(0,d.useEffect)(()=>{f.current&&_e(f.current,c)},[c]);let h=(0,d.useRef)(s);h.current=s,(0,d.useEffect)(()=>{f.current&&xe(f.current,s)},[s]);let g=(0,d.useRef)({x:0,y:0}),_=(0,d.useRef)({onPick:i,onOpen:a,onClear:o});return _.current={onPick:i,onOpen:a,onClear:o},(0,d.useEffect)(()=>{if(!u.current)return;let n=e=>e.imports+e.calls,r=Math.max(1,...e.dependsOn.map(n)),i=gx(t,e.groups,e.dependsOn.map(e=>({from:e.from,to:e.to,weight:n(e)})));g.current=i.packages;let a=[...e.groups.map(e=>{let t=e.findings.broken;return{data:{id:e.id,kind:`group`,label:[e.name,`${e.source} · ${gS[e.kind]??e.kind}`,t>0?`${_S(e.files,`file`)} · ${_S(t,`broken import`)}`:`${_S(e.files,`file`)} · ${_S(e.functions,`function`)}`].join(`
|
|
335
|
+
`));return(0,K.jsxs)(`form`,{className:`rules-editor`,"data-testid":`rules-editor`,onSubmit:e=>{e.preventDefault(),t({include:Yx(r),exclude:Yx(a)})},children:[(0,K.jsxs)(`p`,{className:`muted small`,children:[`Glob patterns, one per line, relative to the repository (`,(0,K.jsx)(`code`,{children:`src/legacy/`}),`,`,` `,(0,K.jsx)(`code`,{children:`**/*.test.ts`}),`). Applied at the next analysis; files left out are closed in the graph and kept in history.`]}),(0,K.jsxs)(`label`,{children:[`Include only`,(0,K.jsx)(`textarea`,{"data-testid":`rules-include`,value:r,onChange:e=>i(e.target.value)})]}),(0,K.jsxs)(`label`,{children:[`Leave out`,(0,K.jsx)(`textarea`,{"data-testid":`rules-exclude`,value:a,onChange:e=>o(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`rules-save`,children:`Save and re-analyze`})]})]})}function Zx({project:e,refresh:t,onAdd:n,onChooseFiles:r,onAnalyzeAll:i,onChanged:a,escape:o}){let[s,c]=(0,d.useState)(null),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[v,y]=(0,d.useState)(null),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)(null),[w,T]=(0,d.useState)({top:0,right:0}),[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(0);(0,d.useEffect)(()=>{let t=!1;return L.sources(e).then(e=>!t&&c(e.sources.map(e=>({...e,optIn:e.optIn??[]}))),e=>!t&&u(e.message)),()=>{t=!0}},[e,t,O]);let A=async(e,t,n)=>{D(!0),u(``),n&&p(n);try{await e(),p(t),a()}catch(e){p(``),u(e.message??String(e))}finally{D(!1),k(e=>e+1)}},j=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!S)return;j.current?.querySelector(`button`)?.focus();let e=e=>{e.type===`mousedown`&&j.current?.contains(e.target)||C(null)};return document.addEventListener(`mousedown`,e),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[S]),o.current=()=>{if(S){let e=S;return C(null),document.querySelector(`tr[data-source="${CSS.escape(e)}"] [data-testid="repo-more"]`)?.focus(),!0}return m?(h(null),!0):b?(x(null),!0):v?(y(null),!0):!1};let M=(0,d.useRef)(null);if((0,d.useEffect)(()=>{(v||b)&&(M.current?.scrollIntoView({block:`nearest`}),M.current?.querySelector(`textarea, button`)?.focus())},[v,b]),(0,d.useEffect)(()=>{s&&(v&&!s.some(e=>e.id===v)&&y(null),b&&!s.some(e=>e.id===b)&&x(null))},[s,v,b]),!s)return(0,K.jsx)(`p`,{className:l?`error`:`muted`,children:l||`Loading…`});let N=v?s.find(e=>e.id===v):void 0;return(0,K.jsxs)(`div`,{className:`repositories`,"data-testid":`repositories`,children:[(0,K.jsxs)(`div`,{className:`repo-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`repo-add`,onClick:n,children:`+ Add folder`}),(0,K.jsx)(`button`,{"data-testid":`repo-analyze-all`,disabled:E,onClick:i,children:`Re-analyze all`})]}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l}),f&&(0,K.jsx)(`p`,{className:`muted small`,role:`status`,"data-testid":`repo-status`,children:f}),(0,K.jsxs)(`table`,{className:`repo-table`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{children:`Repository`}),(0,K.jsx)(`th`,{children:`Branch and commit`}),(0,K.jsx)(`th`,{children:`Analyzed`}),(0,K.jsx)(`th`,{children:`Files`}),(0,K.jsx)(`th`,{children:`Left out`}),(0,K.jsx)(`th`,{children:(0,K.jsx)(`span`,{className:`visually-hidden`,children:`Actions`})})]})}),(0,K.jsx)(`tbody`,{children:s.map(t=>{let n=t.analysis,i=t.include.length+t.exclude.length;return(0,K.jsxs)(`tr`,{"data-source":t.id,children:[(0,K.jsxs)(`td`,{children:[m===t.id?(0,K.jsx)(`form`,{onSubmit:n=>{n.preventDefault(),h(null),A(()=>L.updateSource(e,t.id,{name:g}),`Renamed ${t.id} to ${g||t.id}.`)},onBlur:e=>!e.currentTarget.contains(e.relatedTarget)&&h(null),children:(0,K.jsx)(`input`,{autoFocus:!0,"aria-label":`New name for ${t.id}`,"data-testid":`repo-name`,value:g,onChange:e=>_(e.target.value)})}):(0,K.jsx)(`strong`,{className:`repo-name`,children:t.name??t.id}),(0,K.jsx)(`div`,{className:`muted small path`,children:t.root}),n?.notices.map(e=>(0,K.jsx)(`div`,{className:`notice-line small`,children:e},e))]}),(0,K.jsx)(`td`,{className:`mono small`,children:n?n.kind===`plain`?`plain folder (latest only)`:`${n.branch??`detached`} · ${Jx(n.revision)}${n.pinned?` (kept)`:``}`:`not analyzed yet`}),(0,K.jsx)(`td`,{className:`small`,children:n?W(n.analyzedAt):``}),(0,K.jsx)(`td`,{className:`small`,children:n?n.files:``}),(0,K.jsx)(`td`,{className:`small`,children:i?`${i} rule${i===1?``:`s`}`:`defaults`}),(0,K.jsxs)(`td`,{className:`row-actions`,children:[(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-analyze`,"aria-label":`Re-analyze ${t.name??t.id}`,disabled:E,onClick:()=>void A(()=>L.analyzeSource(e,t.id),`Analyzing ${t.name??t.id} again (the others stay at their commits)…`,`Starting an analysis of ${t.name??t.id}…`),children:`Re-analyze`}),(0,K.jsx)(`button`,{className:`link`,"data-testid":`repo-choose`,"aria-label":`Choose files in ${t.name??t.id}`,onClick:()=>r(t.id),children:`Choose files…`}),(0,K.jsxs)(`span`,{className:`menu-wrap`,children:[(0,K.jsx)(`button`,{className:`icon`,"aria-label":`More for ${t.name??t.id}`,"aria-expanded":S===t.id,"data-testid":`repo-more`,disabled:E,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();T({top:n.bottom+2,right:window.innerWidth-n.right}),C(S===t.id?null:t.id)},children:`⋯`}),S===t.id&&(0,K.jsxs)(`span`,{className:`menu`,role:`menu`,ref:j,style:{top:w.top,right:w.right},children:[(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rename`,onClick:()=>{C(null),_(t.name??t.id),h(t.id)},children:`Rename`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-rules`,onClick:()=>{C(null),y(t.id)},children:`Edit rules`}),(0,K.jsx)(`button`,{role:`menuitem`,"data-testid":`repo-remove`,onClick:()=>{C(null),x(t.id)},children:`Remove…`})]})]})]})]},t.id)})})]}),s.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No repositories yet: + Add folder adds one.`}),N&&(0,K.jsx)(`div`,{ref:M,children:(0,K.jsx)(Xx,{source:N,onCancel:()=>y(null),onSave:t=>{let n=N.id;y(null),A(async()=>{await L.updateSource(e,n,t),await L.analyzeSource(e,n)},`Rules saved; analyzing ${n} again…`)}},N.id)}),b&&(0,K.jsxs)(`div`,{className:`confirm`,role:`alertdialog`,"aria-labelledby":`remove-title`,"data-testid":`repo-remove-confirm`,children:[(0,K.jsx)(`p`,{id:`remove-title`,children:(0,K.jsxs)(`strong`,{children:[`Remove `,s.find(e=>e.id===b)?.name??b,` from this project?`]})}),(0,K.jsx)(`p`,{className:`muted small`,children:`Its files and links leave the current graph. History keeps the analysis: earlier runs still show it, and adding the folder again analyzes it afresh. The folder itself is not touched.`}),(0,K.jsxs)(`div`,{className:`actions`,children:[(0,K.jsx)(`button`,{onClick:()=>x(null),"data-testid":`repo-remove-cancel`,children:`Cancel`}),(0,K.jsx)(`button`,{className:`danger`,"data-testid":`repo-remove-yes`,disabled:E,onClick:()=>{let t=b;x(null),A(()=>L.removeSource(e,t),`Removed ${t}; history keeps its analysis.`,`Removing ${t} (a run closes its facts)…`)},children:`Remove`})]})]})]})}function Qx({project:e}){let[t,n]=(0,d.useState)(``),[r,i]=(0,d.useState)(null);return(0,d.useEffect)(()=>{L.projectSettings(e).then(e=>n(String(e.settings.maxFileMB)),e=>i({ok:!1,text:e.message}))},[e]),(0,K.jsxs)(`form`,{className:`analysis-settings`,onSubmit:n=>{n.preventDefault();let r=Number(t);if(!(r>0&&r<=64))return i({ok:!1,text:`The size limit is more than 0 and at most 64 MB.`});L.saveProjectSettings(e,{maxFileMB:r}).then(e=>i({ok:!0,text:`Saved: files over ${e.settings.maxFileMB} MB are left out at the next analysis.`}),e=>i({ok:!1,text:e.message}))},children:[(0,K.jsxs)(`label`,{children:[`Size limit per file (MB)`,(0,K.jsx)(`input`,{type:`number`,min:.1,max:64,step:.1,required:!0,"data-testid":`analysis-max-mb`,value:t,onChange:e=>n(e.target.value)})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Larger files are listed but not analyzed, unless you choose them in Choose files. Folders of installed libraries, generated output and tools' workspaces (`,(0,K.jsx)(`code`,{children:`node_modules`}),`, `,(0,K.jsx)(`code`,{children:`dist`}),`,`,` `,(0,K.jsx)(`code`,{children:`build`}),`, …) are left out by default; Choose files shows them and can add them.`]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,"data-testid":`analysis-save`,children:`Save`}),r&&(0,K.jsx)(`p`,{className:r.ok?`muted small`:`error`,role:r.ok?`status`:`alert`,children:r.text})]})}function $x({project:e,projectName:t,refresh:n,onClose:r,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,covered:c=!1,initialTab:l=`repositories`}){let[u,f]=(0,d.useState)(l),p=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)(null);return(0,d.useEffect)(()=>{let e=document.activeElement;return m.current?.focus(),()=>e?.focus?.()},[]),(0,d.useEffect)(()=>{if(c)return;let e=e=>{if(e.key===`Escape`)e.stopPropagation(),h.current?.()||r();else if(e.key===`Tab`&&p.current){let t=[...p.current.querySelectorAll(`button:not([disabled]), input, textarea, select`)],n=t[0],r=t[t.length-1];p.current.contains(document.activeElement)?e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus()):(e.preventDefault(),n?.focus())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[c,r]),(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&r(),children:(0,K.jsxs)(`div`,{className:`modal wide`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`project-settings-title`,"data-testid":`project-settings-dialog`,ref:p,children:[(0,K.jsxs)(`div`,{className:`modal-head`,children:[(0,K.jsxs)(`h2`,{id:`project-settings-title`,children:[t,`: settings`]}),(0,K.jsx)(`button`,{className:`icon`,"aria-label":`Close`,onClick:r,ref:m,children:`×`})]}),(0,K.jsx)(`div`,{className:`segmented`,role:`tablist`,"aria-label":`Project settings`,children:[`repositories`,`analysis`,`license`].map(e=>(0,K.jsx)(`button`,{role:`tab`,"aria-selected":u===e,"data-testid":`project-tab-${e}`,onClick:()=>f(e),children:e===`repositories`?`Repositories`:e===`analysis`?`Analysis`:`License`},e))}),u===`repositories`?(0,K.jsx)(Zx,{project:e,refresh:n,onAdd:i,onChooseFiles:a,onAnalyzeAll:o,onChanged:s,escape:h}):u===`analysis`?(0,K.jsx)(Qx,{project:e}):(0,K.jsx)(me,{onChanged:s})]})})}var eS={library:`installed library code`,generated:`generated or built output`,tool:`a tool's or coding agent's workspace (settings, history, worktrees)`};function tS(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var nS=(e,t)=>`${e}\0${t}`,rS=(e,t)=>JSON.stringify([e.include,e.exclude,e.optIn??[]])===JSON.stringify([t?.include??[],t?.exclude??[],t?.optIn??[]]);function iS({project:e,files:t,run:n,onAnalyze:r,onClose:i,only:a,at:o}){let[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(new Map),[f,p]=(0,d.useState)(new Set),[m,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(null),[v,y]=(0,d.useState)(!1),[b,x]=(0,d.useState)(new Map),[S,C]=(0,d.useState)(new Map),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)(``),O=(0,d.useRef)(new Set),k=s.length>1,A=(0,d.useCallback)(e=>n?.sources.find(t=>t.sourceId===e),[n]),j=(0,d.useCallback)(async(t,n)=>{let{entries:r}=await L.browse(e,t,n);O.current.add(nS(t,n)),u(e=>new Map(e).set(nS(t,n),r))},[e]),M=(0,d.useCallback)(async()=>{await Promise.all([...O.current].map(e=>{let[t,n]=e.split(`\0`);return j(t,n).catch(()=>O.current.delete(e))}))},[j]);(0,d.useEffect)(()=>{let t=!1;return(async()=>{try{let[{sources:n},{settings:r}]=await Promise.all([L.sources(e),L.projectSettings(e)]);if(t)return;let i=n.map(e=>({...e,optIn:e.optIn??[]})).filter(e=>a===void 0||e.id===a);c(i),T(r.maxFileMB),D(String(r.maxFileMB)),await Promise.all(i.map(e=>j(e.id,``)))}catch(e){t||h(e.message??String(e))}})(),()=>{t=!0}},[e,j,a]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(g?_(null):i())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,i]),(0,d.useEffect)(()=>{if(!o||!a||s.length===0)return;let e=o.split(`/`).filter(Boolean),t=e.slice(0,-1).map((t,n)=>e.slice(0,n+1).join(`/`));p(e=>new Set([...e,...t.map(e=>nS(a,e))])),Promise.all(t.filter(e=>!O.current.has(nS(a,e))).map(e=>j(a,e))).then(()=>requestAnimationFrame(()=>document.querySelector(`.picker-row[data-path="${CSS.escape(o)}"]`)?.scrollIntoView({block:`center`})),e=>h(e.message))},[o,a,s.length,j]);let N=(e,t)=>{let n=nS(e,t);p(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),O.current.has(n)||j(e,t).catch(e=>h(e.message))},P=(0,d.useMemo)(()=>{let e=[],t=(n,r,i)=>{for(let a of l.get(nS(n,r))??[]){if(a.kind===`file`&&!a.language&&!a.path.toLowerCase().endsWith(`.html`))continue;let r=a.kind===`dir`&&f.has(nS(n,a.path));e.push({source:n,entry:a,depth:i,open:r}),r&&t(n,a.path,i+1)}};for(let e of s)t(e.id,``,+!!k);return e},[l,f,s,k]),F=(e,t)=>{if(t.kind!==`dir`)return!1;let n=e=>e.replace(/^\/+/,``).startsWith(`${t.path}/`),r=l.get(nS(e.id,t.path));if(t.excludedBy)return e.optIn.some(n)?!0:!!r?.some(e=>!e.excludedBy);if(r?.some(e=>e.excludedBy&&(e.kind===`dir`||e.language))||e.exclude.some(e=>e.startsWith(`/`)&&n(e)))return!0;let i=A(e.id),a=t=>e.optIn.some(e=>t===e||t.startsWith(`${e}/`));return i?.defaultExcluded?.some(e=>n(e.path)&&!a(e.path))?!0:rS(e,i?.filter)&&!!i?.ruleExcluded?.some(e=>n(e.path)&&!a(e.path))},I=(e,n,r)=>{if(!r)return-t.filter(t=>t.source===e&&(t.path===n.path||t.path.startsWith(`${n.path}/`))).length;if(n.kind===`file`)return 1;let i=A(e);return i?.defaultExcluded?.find(e=>e.path===n.path)?.files??i?.ruleExcluded?.find(e=>e.path===n.path)?.files??null},R=async(t,n,r)=>{y(!0),h(``),x(e=>new Map(e).set(nS(t,n.path),r));try{let{source:i}=await L.select(e,t,[n.path],r);c(e=>e.map(e=>e.id===t?{...i,optIn:i.optIn??[]}:e)),C(e=>{let i=new Map(e),a=nS(t,n.path);return i.has(a)?i.delete(a):i.set(a,I(t,n,r)),i}),await M()}catch(e){h(e.message??String(e))}finally{x(e=>{let r=new Map(e);return r.delete(nS(t,n.path)),r}),y(!1)}},z=(e,t,n)=>{if(!v){if(n&&t.excludedBy&&t.excludedBy!==`rule`){let n=t.path.slice(t.path.lastIndexOf(`/`)+1),r=A(e)?.defaultExcluded?.find(e=>e.path===t.path),i=t.kind===`dir`&&r?.files?` It has ${r.files.toLocaleString(`en-US`)} file${r.files===1?``:`s`}.`:``;if(t.excludedBy===`too-large`)_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${tS(t.size??0)}, over the ${w??10} MB size limit. Files this large are usually generated or bundled code (minified builds, vendored bundles, source maps), and they slow analysis down. Files over 64 MB are never analyzed.`});else{let r=eS[t.excludedBy]??eS.generated;_({source:e,entry:t,title:`Analyze ${n}?`,text:`${t.path} is ${r}, not your project's own code.${i} Analyzing it makes analysis slower and the graph larger. Its files will be marked as ${t.excludedBy} code and left out of "largest files" and "most called".`})}return}R(e,t,n)}},B=async()=>{let t=Number(E);if(!Number.isFinite(t)||t<=0||t>64){h(`The size limit must be a number of megabytes between 0 and 64.`);return}try{let{settings:n}=await L.saveProjectSettings(e,{maxFileMB:t});T(n.maxFileMB),C(e=>new Map(e).set(`\0limit`,null)),await M()}catch(e){h(e.message??String(e))}},V=S.size>0||s.some(e=>!rS(e,A(e.id)?.filter))||w!==null&&n?.sources[0]?.maxFileBytes!==void 0&&n.sources[0].maxFileBytes!==w*1048576,H=0,U=0,W=!1;for(let[e,t]of S)e!==`\0limit`&&(t===null?W=!0:t>0?H+=t:U-=t);let G=e=>`${e} file${e===1?``:`s`}`,ee=[W?H?`${H}+ files added`:`files added`:H?`${G(H)} added`:``,U?`${G(U)} removed`:``].filter(Boolean).join(`, `);return(0,K.jsxs)(`div`,{className:`picker`,"data-testid":`file-picker`,children:[(0,K.jsxs)(`div`,{className:`picker-head`,children:[(0,K.jsx)(`strong`,{children:`Choose files`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{onClick:i,"data-testid":`picker-done`,children:`Done`})]}),(0,K.jsx)(`p`,{className:`muted small picker-help`,children:`Unchecked files are left out of the graph. Greyed folders are left out by default: libraries and generated output.`}),(0,K.jsxs)(`label`,{className:`picker-limit`,children:[`Skip files over`,(0,K.jsx)(`input`,{type:`number`,min:1,max:64,step:1,value:E,"data-testid":`size-limit`,"aria-label":`Size limit in MB`,onChange:e=>D(e.target.value),onBlur:()=>E!==String(w)&&void B(),onKeyDown:e=>e.key===`Enter`&&void B()}),`MB`]}),m&&(0,K.jsx)(`p`,{className:`error small`,role:`alert`,children:m}),V&&(0,K.jsxs)(`div`,{className:`picker-pending`,"data-testid":`picker-pending`,children:[(0,K.jsxs)(`span`,{children:[ee?(0,K.jsx)(`strong`,{children:ee[0].toUpperCase()+ee.slice(1)}):`Changes`,` at the next analysis`]}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`picker-apply`,disabled:v,onClick:()=>{C(new Map),r()},children:`Apply & re-analyze`})]}),(0,K.jsxs)(`div`,{className:`picker-list`,role:`tree`,"aria-label":`Choose files`,children:[s.map(e=>k?(0,K.jsx)(`div`,{className:`picker-row source`,title:e.root,children:(0,K.jsx)(`strong`,{children:e.id})},`s:${e.id}`):null),P.map(({source:e,entry:t,depth:n,open:r})=>{let i=s.find(t=>t.id===e),a=b.get(nS(e,t.path))??!t.excludedBy,c=F(i,t),l=t.path.slice(t.path.lastIndexOf(`/`)+1),u=t.notAnalyzable?t.notAnalyzable===`declaration-file`?`type declarations`:t.notAnalyzable===`symlink`?`link`:`${tS(t.size??0)} · over 64 MB`:t.excludedBy===`library`?`library`:t.excludedBy===`generated`||t.excludedBy===`tool`?t.excludedBy:t.excludedBy===`too-large`?`${tS(t.size??0)} · too large`:t.excludedBy===`rule`?`excluded`:null,d=t.optedIn?t.origin??null:null;return(0,K.jsxs)(`div`,{className:`picker-row ${t.kind} ${a?``:`excluded`}${t.path===o?` target`:``}`,style:{paddingLeft:8+n*14},role:`treeitem`,"aria-expanded":t.kind===`dir`?r:void 0,"aria-level":n+1,"data-path":t.path,children:[t.kind===`dir`?(0,K.jsx)(`button`,{className:`caret`,"aria-label":`${r?`Close`:`Open`} ${l}`,onClick:()=>N(e,t.path),children:r?`▾`:`▸`}):(0,K.jsx)(`span`,{className:`caret`}),(0,K.jsxs)(`label`,{children:[t.notAnalyzable?(0,K.jsx)(`span`,{className:`caret`}):(0,K.jsx)(`input`,{type:`checkbox`,checked:a,"data-testid":`pick`,ref:e=>{e&&(e.indeterminate=c)},"aria-checked":c?`mixed`:a,onChange:n=>z(e,t,n.target.checked)}),(0,K.jsx)(`span`,{className:`name`,children:l})]}),u&&(0,K.jsx)(`small`,{className:`reason`,children:u}),d&&(0,K.jsx)(`small`,{className:`origin ${d}`,children:d})]},nS(e,t.path))}),s.length>0&&P.length===0&&!m&&(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`})]}),g&&(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:e=>e.target===e.currentTarget&&_(null),children:(0,K.jsxs)(`div`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`pick-warning-title`,"data-testid":`pick-warning`,children:[(0,K.jsx)(`h2`,{id:`pick-warning-title`,children:g.title}),(0,K.jsx)(`p`,{children:g.text}),(0,K.jsxs)(`div`,{className:`buttons`,children:[(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{autoFocus:!0,onClick:()=>_(null),children:`Cancel`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`pick-warning-confirm`,onClick:()=>{let e=g;_(null),R(e.source,e.entry,!0)},children:`Analyze anyway`})]})]})})]})}function aS({projects:e,loading:t=!1,onOpen:n,onCreated:r,onAddFolder:i}){let[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(``),[l,u]=(0,d.useState)(``),[f,p]=(0,d.useState)(!1),m=()=>{o(!1),c(``),u(``)},h=async()=>{if(!f){p(!0),u(``);try{let{project:e}=await L.createProject(s.trim());m(),r(e.id)}catch(e){u(e.message??String(e))}finally{p(!1)}}};return(0,K.jsxs)(`section`,{className:`home`,"data-testid":`home`,"aria-labelledby":`home-title`,children:[(0,K.jsxs)(`div`,{className:`home-head`,children:[(0,K.jsx)(`h1`,{id:`home-title`,children:`Projects`}),(0,K.jsxs)(`div`,{className:`home-actions`,children:[(0,K.jsx)(`button`,{"data-testid":`new-project`,onClick:()=>o(!0),children:`+ New project`}),(0,K.jsx)(`button`,{className:`primary`,"data-testid":`home-add-folder`,onClick:i,children:`Add folder`})]})]}),a&&(0,K.jsxs)(`form`,{className:`new-project`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,K.jsxs)(`label`,{children:[`Name`,(0,K.jsx)(`input`,{autoFocus:!0,"data-testid":`new-project-name`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Escape`&&m()})]}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!s.trim()||f,"data-testid":`new-project-create`,children:`Create`}),(0,K.jsx)(`button`,{type:`button`,onClick:m,children:`Cancel`}),l&&(0,K.jsx)(`p`,{className:`error`,role:`alert`,children:l})]}),t?(0,K.jsx)(`p`,{className:`muted`,children:`Loading…`}):e.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`No projects yet. Add a folder to analyze its code.`}):(0,K.jsx)(`ul`,{className:`project-cards`,children:e.map(e=>{let t=e.findings,r=t?t.broken+t.notAnalyzed+t.openCalls:0;return(0,K.jsx)(`li`,{"data-project":e.id,children:(0,K.jsxs)(`button`,{className:`project-card`,"data-testid":`open-project`,onClick:()=>n(e.id),children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.sources,` repositor`,e.sources===1?`y`:`ies`]}),e.error?(0,K.jsxs)(`span`,{className:`error small`,"data-testid":`project-error`,children:[`Can't be read: `,e.error]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`small`,children:e.latest?e.latest.status===`running`?`Analyzing…`:e.latest.status===`failed`?e.latest.errorCode===`cancelled`?`Last analysis cancelled`:`Last analysis failed`:`Analyzed${e.latest.finishedAt?` ${W(e.latest.finishedAt)}`:``}`:`Not analyzed yet`}),t&&(0,K.jsx)(`span`,{className:`muted small`,children:r===0?`No findings`:[t.broken?`${t.broken} broken imports`:``,t.notAnalyzed?`${t.notAnalyzed} not analyzed`:``,t.openCalls?`${t.openCalls} open calls`:``].filter(Boolean).join(` · `)})]})]})},e.id)})})]})}function oS({title:e,entries:t,x:n,y:r,onClose:i}){let a=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=document.activeElement;a.current?.querySelector(`button`)?.focus();let t=e=>{e.type===`mousedown`&&a.current?.contains(e.target)||i()},n=e=>{if(e.key===`Escape`){e.stopPropagation(),i();return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;e.preventDefault();let t=[...a.current?.querySelectorAll(`button`)??[]],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},r=e=>{a.current?.contains(e.relatedTarget)||i()},o=a.current;return document.addEventListener(`mousedown`,t),window.addEventListener(`resize`,t),document.addEventListener(`scroll`,t,!0),window.addEventListener(`keydown`,n,!0),o?.addEventListener(`focusout`,r),()=>{document.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,t),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`keydown`,n,!0),o?.removeEventListener(`focusout`,r),e&&e!==document.body&&document.contains(e)&&e.focus()}},[i]);let o=Math.max(4,Math.min(n,window.innerWidth-260)),s=Math.max(4,Math.min(r,window.innerHeight-40-t.length*30));return(0,K.jsxs)(`div`,{ref:a,className:`context-menu`,role:`menu`,"aria-label":e,"data-testid":`context-menu`,style:{left:o,top:s},children:[(0,K.jsx)(`div`,{className:`context-title`,"aria-hidden":`true`,children:e}),t.map(e=>(0,K.jsx)(`button`,{role:`menuitem`,tabIndex:-1,"data-command-name":e.command,onClick:()=>{i(),e.run()},children:e.label},e.label))]})}function sS(e,t){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);if(i>=0)return i;let a=0,o=0;for(let e of r)if(e===n[a]?a++:a>0&&o++,a===n.length)return 100+o;return null}function cS(e,t,n){return n===0?[]:t.map((t,n)=>({item:t,i:n,score:sS(e,t.label)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).slice(0,n).map(e=>e.item)}function lS(e,t){let{view:n,command:r}=t,i=e.trim(),a=[];if(n.project){let e=cS(i,t.files.map(e=>({...e,label:e.path})),i?5:0);for(let i of e)a.push({key:`file:${i.id}`,group:`Files`,label:i.path,run:()=>n.tab===`imports`?r(`openImportsFile`,{file:i.id}):r(`openFile`,{file:i.id})}),e.length<=2&&(n.tab===`imports`&&n.group!==null&&!n.fileLevel&&a.push({key:`only:${i.id}`,group:`Files`,label:`Show only links of ${i.path}`,run:()=>r(`showOnlyLinks`,{id:i.id})}),a.push({key:`leave:${i.id}`,group:`Files`,label:`Leave ${i.path} out of analysis…`,run:()=>t.action(`chooseFiles`,{source:i.id.slice(0,i.id.indexOf(`:`)),path:i.path})}));for(let e of cS(i,t.groups.map(e=>({...e,label:e.name})),i?4:0))a.push({key:`group:${e.id}`,group:`Groups`,label:e.name,detail:`open the group`,run:()=>r(`openGroup`,{group:e.id})}),a.push({key:`only:${e.id}`,group:`Groups`,label:`Show only links of ${e.name}`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`showOnlyLinks`,{id:e.id})}}),a.push({key:`pick:${e.id}`,group:`Groups`,label:`Details of ${e.name}`,detail:`on the project map`,run:()=>{(n.tab!==`imports`||n.group!==null||n.fileLevel)&&r(`openGroup`,{}),r(`pickNode`,{id:e.id})}})}let o=[],s=(e,t,n,r)=>o.push({label:e,run:t,...n?{detail:n}:{},...r?{key:r}:{}});if(n.project){s(n.history?`Close History`:`History: runs by commit`,()=>r(`toggleHistory`)),n.compare&&s(`Stop comparing`,()=>r(`compareRuns`,{}));let e=/^(?:compare\s+)?(?:run\s*)?(\d+)\s*(?:\.\.|with|vs|and|,|\s)\s*(?:run\s*)?(\d+)$/i.exec(i);if(e){let[t,n]=[Number(e[1]),Number(e[2])];s(`Compare run ${Math.min(t,n)} with run ${Math.max(t,n)}`,()=>r(`compareRuns`,{a:t,b:n}))}n.run!==null&&s(`Back to latest`,()=>r(`openRun`,{}));let a=/^(?:view\s+)?run\s*(\d+)$/i.exec(i);a&&s(`View run ${a[1]}`,()=>r(`openRun`,{run:Number(a[1])})),s(`File tab`,()=>r(`showTab`,{tab:`file`}),`functions and calls inside a file`),s(`Imports tab`,()=>r(`showTab`,{tab:`imports`}),`how files depend on each other`),s(`Show the code`,()=>r(`showPanel`,{panel:`evidence`})),s(`Show Findings`,()=>r(`showPanel`,{panel:`questions`})),s(n.showPending?`Hide pending imports`:`Show pending imports`,()=>r(`togglePending`)),s(n.showUnresolved?`Hide unresolved call sites`:`Show unresolved call sites`,()=>r(`toggleUnresolved`)),n.selection&&s(`Clear the selection`,()=>r(`clearSelection`)),n.only&&s(`Show everything again`,()=>r(`showOnlyLinks`,{}),`not only one item's links`);for(let e of t.sources)s(`Re-analyze ${e.name??e.id}`,()=>t.action(`analyzeSource`,{source:e.id}),`this repository only`,`analyze:${e.id}`);if(t.sources.length>1){n.source&&s(`Scope: all repositories`,()=>r(`scopeSource`,{}));for(let e of t.sources)e.id!==n.source&&s(`Scope: ${e.name??e.id}`,()=>r(`scopeSource`,{source:e.id}),`one repository only`,`scope:${e.id}`)}n.group&&i.includes(`/`)&&s(`Open or close folder ${i}`,()=>r(`toggleFolder`,{path:i.replace(/^\.?\//,``).replace(/\/$/,``)})),s(`Re-analyze the project`,()=>t.action(`analyze`)),t.canDraft&&s(`Analyze uncommitted edits`,()=>t.action(`analyzeDraft`),`a draft beside the graph`);for(let e of t.stages??[])s(`Debug run: stop after ${e}`,()=>t.action(`analyzeDebug`,{until:e}),`never committed; compare it with the latest`,`debug:${e}`);s(`Repositories…`,()=>t.action(`openProjectSettings`),`re-analyze, choose files, rename, remove`),s(`License…`,()=>t.action(`openProjectSettings`,{tab:`license`}),`what the license includes; add or replace a key`)}n.project&&s(`All projects (home)`,()=>r(`goHome`),`every project and its last run`),s(`Add a folder…`,()=>t.action(`addFolder`)),s(`Settings…`,()=>t.action(`openSettings`),`the model for questions`);for(let e of t.projects)e.id!==n.project&&s(`Switch to project ${e.name}`,()=>r(`selectProject`,{project:e.id}),void 0,`project:${e.id}`);let c=o.filter(e=>/^(Compare run|View run|Open or close folder)/.test(e.label)),l=cS(i,o.filter(e=>!c.includes(e)),i?6:0);for(let e of[...c,...l])a.push({key:`cmd:${e.key??e.label}`,group:`Commands`,label:e.label,run:e.run,...e.detail?{detail:e.detail}:{}});return a}var uS=e=>e.reason===`imported-symbol`||e.reason===`template-reference`;function dS(e){let t=e.group;if(!t)return e.path;let n=t.root&&e.path.startsWith(`${t.root}/`)?e.path.slice(t.root.length+1):e.path;return`${t.name} › ${n}`}var fS={broken:`its import is broken`,pending:`its import waits for another source`,"not-analyzed":`its import leads to a file not analyzed`};function pS({project:e,graph:t,fn:n,onOpen:r,onShowImports:i}){let[a,o]=(0,d.useState)(null),s=t.file.id,c=t.unresolved.some(uS);(0,d.useEffect)(()=>{if(!c)return;let t=!1;return L.siteLinks(e,s).then(e=>!t&&o({file:s,byId:new Map(e.links.map(e=>[e.site,e]))}),()=>!t&&o({file:s,byId:`error`})),()=>{t=!0}},[e,s,t.committedRun,c]);let l=t.unresolved.filter(e=>e.enclosingFn===n&&uS(e)&&!e.component).sort((e,t)=>e.evidence.span.start.offset-t.evidence.span.start.offset);if(l.length===0)return null;let u=a?.file===s?a.byId:null,f=u===`error`?null:u;return(0,K.jsxs)(`div`,{className:`imported-calls`,"data-testid":`imported-calls`,children:[(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Calls into other files (`,l.length,`)`]}),u===`error`&&(0,K.jsx)(`p`,{className:`small muted`,children:`Where these calls lead couldn't be loaded.`}),l.map(e=>{let t=f?.get(e.id),n=e.importSpecifier?`imported from ${e.importSpecifier}`:`defined in another file`;return(0,K.jsxs)(`div`,{className:`imported-call`,"data-testid":`imported-call`,"data-site":e.id,children:[(0,K.jsxs)(`span`,{className:`mono small`,children:[e.expression,` · line `,e.evidence.span.start.line]}),u===`error`?(0,K.jsx)(`span`,{className:`small muted`,children:n}):f===null?(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`…`]}):t?.status===`linked`&&t.target?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`small`,children:[`calls `,(0,K.jsx)(`strong`,{children:t.target.name}),` in`,` `,(0,K.jsx)(`span`,{className:`mono`,children:dS(t.target)}),`, found by`,` `,t.via===`import`?`import analysis`:`component linking`]}),(0,K.jsxs)(`span`,{className:`small links`,children:[(0,K.jsx)(`button`,{className:`button-link`,"data-command":`open-imported`,onClick:()=>r({id:t.target.id,file:t.target.file}),children:`Open that file`}),(0,K.jsx)(`button`,{className:`button-link`,"data-command":`show-in-imports`,onClick:i,children:`Show in Imports`})]})]}):t?.status===`external`?(0,K.jsxs)(`span`,{className:`small`,children:[`calls into the external package `,(0,K.jsx)(`strong`,{children:t.package?.name})]}):t?(0,K.jsxs)(`span`,{className:`small`,children:[n,`, not linked`,t.importOutcome?`: ${fS[t.importOutcome]}`:t.candidates?.length?t.exhaustive===!1?`: ${t.candidates.length} known function${t.candidates.length===1?``:`s`} could run (may not be all)`:`: it could be any of ${t.candidates.length} functions`:t.reason?`: ${t.reason}`:``]}):(0,K.jsxs)(`span`,{className:`small muted`,children:[n,`, not linked yet`]})]},e.id)})]})}function mS(e,t,n,r){let i=e=>e.slice(e.indexOf(`:`)+1),a=e=>e.split(`/`).slice(-2).join(`/`),o=r.calls?t.out.calls:[],s=r.calls?t.in.calls:[],c=new Map;for(let e of o)c.set(e.from.id,e.from.name);for(let e of s)c.set(e.to.id,e.to.name);let l=[...c].sort((e,t)=>e[1]<t[1]?-1:+(e[1]>t[1])).map(([e])=>e),u=(e,t)=>({id:`${e}|${t.id}`,file:t.file,label:`${a(t.path)} ›\n${t.name}`}),d=new Map(s.map(e=>[e.from.id,u(`caller`,e.from)])),f=new Map(o.map(e=>[e.to.id,u(`callee`,e.to)])),p=new Map,m=new Map;if(r.imports&&n){for(let t of n.imports)t.outcome===`file`&&t.file&&t.file.id!==e&&!m.has(t.file.id)&&m.set(t.file.id,{id:`imported|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimported`,edge:t.id});for(let t of n.importedBy.files)t.file.id!==e&&!p.has(t.file.id)&&p.set(t.file.id,{id:`importer|${t.file.id}`,file:t.file.id,label:`${a(t.file.path)}\nimports this file`,edge:t.id})}let h=e=>[...e.values()].sort((e,t)=>e.label<t.label?-1:+(e.label>t.label)),g=[...h(d),...h(p)],_=[...h(f),...h(m)],v=Math.max(l.length,1),y=e=>-((e-1)*58)/2,b=[{data:{id:`box`,kind:`box`,label:i(e),w:210,h:v*58+50},position:{x:0,y:0},classes:`box`},...l.map((e,t)=>({data:{id:e,kind:`function`,label:`ƒ ${c.get(e)}`},position:{x:0,y:y(l.length)+t*58+12},classes:`function`})),...g.map((e,t)=>({data:{id:e.id,kind:`port`,side:`left`,file:e.file,label:e.label},position:{x:-330,y:y(g.length)+t*58},classes:e.id.startsWith(`importer|`)?`port file`:`port`})),..._.map((e,t)=>({data:{id:e.id,kind:`port`,side:`right`,file:e.file,label:e.label},position:{x:330,y:y(_.length)+t*58},classes:e.id.startsWith(`imported|`)?`port file`:`port`}))],x=new Map,S=(e,t,n)=>{let r=`${e}->${t}`,i=x.get(r);i?i.calls.push(n):x.set(r,{id:n,source:e,target:t,calls:[n]})};for(let e of o)S(e.from.id,`callee|${e.to.id}`,e.id);for(let e of s)S(`caller|${e.from.id}`,e.to.id,e.id);for(let e of x.values())b.push({data:{id:e.id,kind:`call`,source:e.source,target:e.target,calls:e.calls,label:e.calls.length>1?`×${e.calls.length}`:``},classes:`call`});for(let e of m.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:`box`,target:e.id,label:``},classes:`import`});for(let e of p.values())b.push({data:{id:`edge|${e.edge}`,edge:e.edge,kind:`import`,source:e.id,target:`box`,label:``},classes:`import`});return b}function hS({file:e,calls:t,imports:n,show:r,pick:i,onPick:a,onOpenFile:o,onClear:s,marks:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let m=(0,d.useRef)(l);m.current=l,(0,d.useEffect)(()=>{f.current&&xe(f.current,c)},[c]);let h=(0,d.useRef)({onPick:a,onOpenFile:o,onClear:s});h.current={onPick:a,onOpenFile:o,onClear:s};let g=(0,d.useMemo)(()=>mS(e,t,n,r),[e,t,n,r.calls,r.imports]);(0,d.useEffect)(()=>{if(!u.current)return;let e=p_({container:u.current,elements:g,layout:{name:`preset`},autounselectify:!0,minZoom:.15,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:170,height:36,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`194px`,"text-valign":`center`,"text-halign":`center`,"font-size":12,color:`#1d2330`,"background-color":`#fff`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.box`,style:{"background-color":`#f7faff`,"border-color":`#c6d6f3`,"border-width":2,"text-valign":`top`,"text-margin-y":18,color:`#2a56ad`,"font-weight":`bold`,width:`data(w)`,height:`data(h)`,events:`no`,"z-index":0}},{selector:`node.port`,style:{width:210,height:42,"border-style":`dashed`,"border-color":`#6b87b8`}},{selector:`node.port.file`,style:{"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"line-color":`#6b87b8`,"line-style":`dashed`,"target-arrow-shape":`triangle`,"target-arrow-color":`#6b87b8`,"arrow-scale":.8,label:`data(label)`,"font-size":10,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1}},{selector:`edge.import`,style:{"line-color":`#b7c0cf`,"target-arrow-color":`#b7c0cf`}},...be,{selector:`.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`,width:3}}]});return e.on(`tap`,`node`,e=>{e.target.data(`kind`)===`port`&&h.current.onOpenFile(e.target.data(`file`))}),e.on(`tap`,`edge`,e=>h.current.onPick(e.target.data(`edge`)??e.target.id())),e.on(`tap`,t=>{t.target===e&&h.current.onClear()}),e.fit(void 0,30),e.zoom()>1.2&&(e.zoom(1.2),e.center()),f.current=e,xe(e,p.current),e.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`port`&&t.file?`file`:t.kind===`call`||t.kind===`import`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),()=>{f.current=null,e.destroy()}},[g]),(0,d.useEffect)(()=>{let e=f.current;e&&(e.elements().removeClass(`picked`),i&&e.edges().filter(e=>(e.data(`calls`)??[]).includes(i)||e.data(`edge`)===i).addClass(`picked`))},[i,g]);let _=e=>g.filter(t=>t.data.kind===`port`&&t.data.side===e).map(e=>e.data.id).join(` `),v=[t.in,t.out].filter(e=>e.truncated),y=(r.calls?t.out.calls.length+t.in.calls.length:0)===0,b=[...new Map([...t.in.calls.map(e=>e.from),...t.out.calls.map(e=>e.to)].map(e=>[e.file,e])).values()];return(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[y&&r.calls&&(0,K.jsx)(`p`,{className:`hint overlay`,"data-testid":`no-cross-file-calls`,children:`No calls cross into or out of this file.`}),(0,K.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`file-canvas`,"data-calls":g.filter(e=>e.data.kind===`call`).length,"data-imports":g.filter(e=>e.data.kind===`import`).length,"data-ports-left":_(`left`),"data-ports-right":_(`right`)}),v.length>0&&(0,K.jsxs)(`p`,{className:`hint small overlay bottom`,"data-testid":`calls-truncated`,children:[v.map(e=>`Showing ${e.calls.length} of ${e.total} calls ${e.direction===`in`?`into`:`out of`} this file`).join(`; `),`.`]}),(0,K.jsxs)(`ul`,{className:`visually-hidden`,"aria-label":`Cross-file calls`,children:[t.in.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`in`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.path,` › `,e.from.name,` calls `,e.to.name]})},e.id)),t.out.calls.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`pick-node`,"data-kind":`call`,"data-id":e.id,"data-direction":`out`,tabIndex:-1,onClick:()=>a(e.id),children:[e.from.name,` calls `,e.to.path,` › `,e.to.name]})},e.id)),b.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"data-command":`open-imports-file`,"data-id":e.file,tabIndex:-1,onClick:()=>o(e.file),children:[`Open `,e.path]})},e.file))]}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>f.current?.fit(void 0,30),children:`Fit`})]})}var gS={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`},_S=(e,t)=>`${e.toLocaleString()} ${t}${e===1?``:`s`}`;function vS(e){e.fit(void 0,40);let t=e.zoom();if(t>1.2)e.zoom(1.2),e.center();else if(t<.9){let t=e.elements().boundingBox();e.zoom(.9),e.pan({x:40-t.x1*.9,y:40-t.y1*.9})}}function yS(e,t){if(!e||!t)return 0;let n=Math.abs(t.x-e.x)/290;return n>1.2||t.x<e.x?-(84*.9+12*Math.min(4,n)):0}var bS=(e,t)=>1+6*Math.sqrt(e/Math.max(1,t));function xS({map:e,layoutKey:t,pick:n,showPackages:r,onPick:i,onOpen:a,onClear:o,marks:s=null,only:c=null,onContext:l}){let u=(0,d.useRef)(null),f=(0,d.useRef)(null),p=(0,d.useRef)(c);p.current=c;let m=(0,d.useRef)(l);m.current=l,(0,d.useEffect)(()=>{f.current&&_e(f.current,c)},[c]);let h=(0,d.useRef)(s);h.current=s,(0,d.useEffect)(()=>{f.current&&xe(f.current,s)},[s]);let g=(0,d.useRef)({x:0,y:0}),_=(0,d.useRef)({onPick:i,onOpen:a,onClear:o});return _.current={onPick:i,onOpen:a,onClear:o},(0,d.useEffect)(()=>{if(!u.current)return;let n=e=>e.imports+e.calls,r=Math.max(1,...e.dependsOn.map(n)),i=gx(t,e.groups,e.dependsOn.map(e=>({from:e.from,to:e.to,weight:n(e)})));g.current=i.packages;let a=[...e.groups.map(e=>{let t=e.findings.broken;return{data:{id:e.id,kind:`group`,label:[e.name,`${e.source} · ${gS[e.kind]??e.kind}`,t>0?`${_S(e.files,`file`)} · ${_S(t,`broken import`)}`:`${_S(e.files,`file`)} · ${_S(e.functions,`function`)}`].join(`
|
|
336
336
|
`)},position:i.groups[e.id]??{x:0,y:0},classes:t>0?`group broken`:`group`}}),...e.dependsOn.map(e=>({data:{bend:yS(i.groups[e.from],i.groups[e.to]),id:e.id,kind:`depends`,source:e.from,target:e.to,width:bS(n(e),r),label:n(e)*3>=r&&n(e)>1?String(n(e)):``},classes:`depends`}))],o=p_({container:u.current,elements:a,layout:{name:`preset`},autounselectify:!0,minZoom:.1,maxZoom:2.5,style:[{selector:`node`,style:{shape:`round-rectangle`,width:210,height:84,label:`data(label)`,"text-wrap":`wrap`,"text-max-width":`190px`,"text-valign":`center`,"text-halign":`center`,"font-size":13,"line-height":1.45,color:`#1d2330`,"background-color":`#f7f9fc`,"border-width":1,"border-color":`#c9d1de`}},{selector:`node.broken`,style:{"border-color":`#c9a45c`}},{selector:`node.packages`,style:{"background-color":`#fff`,"border-style":`dashed`,"border-color":`#b7c0cf`,color:`#4a5262`}},{selector:`edge`,style:{width:`data(width)`,"curve-style":`unbundled-bezier`,"control-point-distances":`data(bend)`,"control-point-weights":.5,"line-color":`#9aa6b8`,"target-arrow-shape":`triangle`,"target-arrow-color":`#9aa6b8`,"arrow-scale":.8,label:`data(label)`,"font-size":11,color:`#5d6675`,"text-background-color":`#fff`,"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.uses`,style:{"line-style":`dashed`,"line-color":`#c9d1de`,"target-arrow-shape":`none`}},...be,ge,{selector:`node.picked`,style:{"border-width":2,"border-color":`#3b6fd4`,"background-color":`#eef4ff`}},{selector:`edge.picked`,style:{"line-color":`#3b6fd4`,"target-arrow-color":`#3b6fd4`}},{selector:`.faded`,style:{opacity:.25}}]});return o.on(`tap`,`node`,e=>{e.target.data(`kind`)===`group`&&_.current.onPick(e.target.id())}),o.on(`dbltap`,`node`,e=>{e.target.data(`kind`)===`group`&&_.current.onOpen(e.target.id())}),o.on(`tap`,e=>{e.target===o&&_.current.onClear()}),vS(o),f.current=o,u.current&&(u.current.veoCy=o),_e(o,p.current),o.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`group`?`group`:t.kind===`depends`?`edge`:null;if(!n||!u.current)return;let r=u.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};m.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),xe(o,h.current),()=>{f.current=null,o.destroy()}},[e,t]),(0,d.useEffect)(()=>{let t=f.current;if(!t||(t.remove(`#packages, .uses`),!r||e.externalPackages.total===0))return;let n=[],i=e.externalPackages.top.slice(0,4).map(e=>e.name),a=e.externalPackages.total-i.length;n.push({data:{id:`packages`,kind:`packages`,label:[`External packages`,i.join(`, `),a>0?`+ ${a} more`:``].filter(Boolean).join(`
|
|
337
337
|
`)},position:g.current,classes:`packages`});for(let t of e.groups)t.externalPackages>0&&n.push({data:{id:`packages|${t.id}`,kind:`uses`,source:t.id,target:`packages`,width:1,label:``,bend:0},classes:`uses`});t.add(n)},[e,t,r]),(0,d.useEffect)(()=>{let e=f.current;e&&e.batch(()=>{e.elements().removeClass(`picked faded`);let t=n?e.getElementById(n):null;if(t&&t.nonempty()){let n=t.union(t.connectedEdges(`[kind = "depends"]`));n.addClass(`picked`),e.elements().not(n).not(n.connectedNodes()).addClass(`faded`)}})},[n,e,t,r]),(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[(0,K.jsx)(`div`,{ref:u,className:`graph map`,"data-testid":`project-map`,tabIndex:0,role:`application`,"aria-label":`Project map: arrow keys move between groups, Enter opens one`,onKeyDown:t=>{let r=e.groups.map(e=>e.id);if(r.length===0)return;let s=n?r.indexOf(n):-1;if(t.key===`ArrowRight`||t.key===`ArrowDown`)i(r[(s+1)%r.length]);else if(t.key===`ArrowLeft`||t.key===`ArrowUp`)i(r[(s-1+r.length)%r.length]);else if(t.key===`Enter`&&n)a(n);else if(t.key===`Escape`)o();else return;t.preventDefault()}}),(0,K.jsx)(`ul`,{className:`visually-hidden`,"aria-label":`Groups`,children:e.groups.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{"data-command":`pick-node`,"data-id":e.id,tabIndex:-1,onClick:()=>i(e.id),children:e.name}),(0,K.jsxs)(`button`,{"data-command":`open-group`,"data-id":e.id,tabIndex:-1,onClick:()=>a(e.id),children:[`Open `,e.name]})]},e.id))}),(0,K.jsx)(`button`,{className:`fit`,onClick:()=>f.current&&vS(f.current),children:`Fit`})]})}function SS({project:e,projectName:t,run:n,group:r,source:i=null,pick:a,file:o,fileLevel:s,expand:c,showPending:l,tabs:u,onPick:f,onOpenGroup:p,onOpenFile:m,onToggleFolder:h,onTogglePending:g,onClear:_,marks:v=null,only:y=null,onContext:b}){let[x,S]=(0,d.useState)(0),{groups:C,error:w}=Dx(e,n,x,i),[T,E]=(0,d.useState)(!1),D=s&&o!==null,{imports:O}=kx(e,n,D?o:null),{calls:k,error:A}=Ax(e,n,D?o:null),[j,M]=(0,d.useState)({calls:!0,imports:!0}),N=D?O?O.file.group:null:r??(C&&C.total===1?C.groups[0].id:null),P=N?C?.groups.find(e=>e.id===N):void 0,[F,I]=(0,d.useState)(0),{group:L,error:R}=Ox(e,n,D?null:N,c,l,F),z=(0,K.jsxs)(`div`,{className:`toolbar`,children:[u,(0,K.jsx)(`nav`,{className:`breadcrumb`,"aria-label":`Zoom`,"data-testid":`breadcrumb`,children:N?(0,K.jsxs)(K.Fragment,{children:[C?.total===1?(0,K.jsx)(`span`,{children:t}):(0,K.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>p(),children:t}),(0,K.jsx)(`span`,{className:`muted`,children:`›`}),D?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>p(N),children:P?.name??N}),(0,K.jsx)(`span`,{className:`muted`,children:`›`}),(0,K.jsx)(`strong`,{className:`mono`,children:xx(wS(o),TS(P))})]}):(0,K.jsx)(`strong`,{children:P?.name??N})]}):D?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`link`,"data-command":`open-group`,onClick:()=>p(),children:t}),(0,K.jsx)(`span`,{className:`muted`,children:`›`}),(0,K.jsx)(`strong`,{className:`mono`,children:wS(o)})]}):(0,K.jsx)(`strong`,{children:t})}),C&&!N&&C.stage2&&(0,K.jsxs)(`span`,{className:`small muted`,children:[`project map · `,C.total,` group`,C.total===1?``:`s`]}),L&&!D&&(0,K.jsxs)(`span`,{className:`small muted`,children:[`group · `,L.group.files,` file`,L.group.files===1?``:`s`,` · `,L.group.source]}),N&&!D&&c.length>0&&(0,K.jsx)(`span`,{className:`open-folders small`,children:c.map(e=>(0,K.jsxs)(`span`,{className:`chip`,children:[xx(e,TS(P)),`/`,(0,K.jsx)(`button`,{className:`icon`,"data-command":`toggle-folder`,"data-testid":`close-folder`,"data-path":e,"aria-label":`Close the folder ${e}`,onClick:()=>h(e),children:`×`})]},e))}),D&&(0,K.jsx)(`span`,{className:`small muted`,children:`its imports and cross-file calls`}),(0,K.jsx)(`span`,{className:`spacer`}),D&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-calls`,checked:j.calls,onChange:e=>M({...j,calls:e.target.checked})}),`Cross-file calls`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-imports`,checked:j.imports,onChange:e=>M({...j,imports:e.target.checked})}),`Imports`]})]}),N&&!D&&(0,K.jsxs)(`label`,{className:`toggle`,title:`Imports waiting for another source to be added`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-command":`toggle-pending`,checked:l,onChange:g}),`Pending imports`]}),C&&!N&&C.externalPackages.total>0&&(0,K.jsxs)(`label`,{className:`toggle`,title:`External packages are hidden by default: nearly every group imports the same few`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"data-testid":`toggle-packages`,checked:T,onChange:e=>E(e.target.checked)}),`External packages`]})]});if(w)return(0,K.jsxs)(K.Fragment,{children:[z,(0,K.jsxs)(`p`,{className:`hint error`,children:[w,` `,(0,K.jsx)(`button`,{className:`link`,onClick:()=>S(e=>e+1),children:`Try again`})]})]});if(!C)return(0,K.jsxs)(K.Fragment,{children:[z,(0,K.jsx)(`p`,{className:`hint`,children:`Loading the imports…`})]});if(!C.stage2)return(0,K.jsxs)(K.Fragment,{children:[z,(0,K.jsx)(`p`,{className:`hint`,"data-testid":`imports-no-stage2`,children:`Imports haven't been analyzed in this project yet: Stage 2, which follows imports across files, hasn't run. Analyze the project again to see them.`})]});let B=C.stats;return(0,K.jsxs)(K.Fragment,{children:[z,D?A?(0,K.jsx)(`p`,{className:`hint error`,children:A}):k?(0,K.jsx)(`div`,{className:`group-level`,"data-testid":`file-level`,children:(0,K.jsx)(hS,{marks:v,onContext:b,file:o,calls:k,imports:O,show:j,pick:a,onPick:f,onOpenFile:e=>m(e),onClear:_})}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading the file…`}):N?R?(0,K.jsxs)(`p`,{className:`hint error`,children:[R,` `,(0,K.jsx)(`button`,{className:`link`,onClick:()=>I(e=>e+1),children:`Try again`})]}):L?(0,K.jsxs)(`div`,{className:`group-level`,"data-testid":`group-level`,children:[L.truncated&&(0,K.jsxs)(`p`,{className:`hint small`,children:[`Showing `,L.nodes.length,` of `,L.total,` files and folders.`]}),(0,K.jsx)(Sx,{marks:v,onContext:b,only:y,reply:L,pick:a,onPick:f,onOpenFile:e=>m(e,N),onToggleFolder:h,onClear:_})]}):(0,K.jsx)(`p`,{className:`hint`,children:`Loading the group…`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`dl`,{className:`map-stats`,"data-testid":`map-stats`,children:[(0,K.jsx)(CS,{n:B.files,label:`files`}),(0,K.jsx)(CS,{n:B.functions,label:`functions`}),(0,K.jsx)(CS,{n:B.crossFileCalls,label:`cross-file calls`}),(0,K.jsx)(CS,{n:B.brokenImports,label:`broken imports`,tone:B.brokenImports>0?`warn`:void 0}),(0,K.jsx)(CS,{n:B.openCalls,label:`open questions`}),(0,K.jsx)(CS,{n:C.externalPackages.total,label:T?`external packages`:`external packages (hidden)`})]}),C.total===0?(0,K.jsx)(`p`,{className:`hint`,children:`No groups: nothing was analyzed.`}):(0,K.jsx)(xS,{marks:v,onContext:b,only:y,map:C,layoutKey:`${e}|${C.committedRun}|${i??``}`,pick:a,showPackages:T,onPick:f,onOpen:e=>p(e),onClear:_}),C.truncated&&(0,K.jsxs)(`p`,{className:`hint small`,children:[`Showing `,C.groups.length,` of `,C.total,` groups.`]})]})]})}function CS({n:e,label:t,tone:n}){return(0,K.jsxs)(`div`,{className:n,children:[(0,K.jsx)(`dd`,{children:e.toLocaleString()}),(0,K.jsx)(`dt`,{children:t})]})}var wS=e=>e.slice(e.indexOf(`:`)+1);function TS(e){return!e||e.kind===`cluster`?``:e.root}var ES={focus:3,site:2,call:1},DS=e=>e.end.column<=1&&e.end.line>e.start.line?e.end.line-1:e.end.line;function OS(e,t){if(e.kind!==`call`||DS(e)===e.start.line)return e;let n=Array.from(t(e.start.line)??``),r=n.indexOf(`(`,e.start.column-1),i=r>=0?r+2:n.length+1;return{...e,end:{line:e.start.line,column:i}}}function kS(e,t){let n=t=>e.lines[t-e.startLine],r=t.map(e=>OS(e,n)),i=r.map(e=>(e.end.line-e.start.line)*1e4+(e.end.column-e.start.column)),a=new Map;r.forEach((t,n)=>{let r=Math.max(t.start.line,e.startLine),i=Math.min(DS(t),e.startLine+e.lines.length-1);for(let e=r;e<=i;e++){let t=a.get(e);t?t.push(n):a.set(e,[n])}});let o=new Set;return e.lines.map((t,n)=>{let s=e.startLine+n,c=Array.from(t),l=c.map(()=>null);for(let e of a.get(s)??[]){let t=r[e],n=s===t.start.line?t.start.column-1:0,a=s===t.end.line?t.end.column-1:c.length;for(let o=Math.max(0,n);o<Math.min(c.length,a);o++){let n=l[o];(n==null||ES[t.kind]>ES[r[n].kind]||ES[t.kind]===ES[r[n].kind]&&i[e]<i[n])&&(l[o]=e)}}let u=[];return c.forEach((e,t)=>{let n=u[u.length-1],r=l[t]??null;if(n&&n.mark===r)n.text+=e;else{let t=r!==null&&!o.has(r);r!==null&&o.add(r),u.push({text:e,mark:r,first:t})}}),{n:s,runs:u,focus:r.some(e=>e.kind===`focus`&&s>=e.start.line&&s<=DS(e))}})}function AS({snippet:e,marks:t,focusLine:n,testId:r,className:i}){let a=(0,d.useRef)(null),o=(0,d.useMemo)(()=>kS(e,t),[e,t]);(0,d.useEffect)(()=>{let e=a.current,t=e?.querySelector(`[data-line="${n}"]`);e&&t&&(e.scrollTop=Math.max(0,t.offsetTop-e.clientHeight/3))},[e,n]);let s=e=>{let n=e?.closest(`[data-mark]`);if(!n)return!1;let r=t[Number(n.dataset.mark)];return r?.onClick?(r.onClick(),!0):!1};return(0,K.jsx)(`pre`,{className:`code ${i??``}`,"data-testid":r,ref:a,onClick:e=>s(e.target),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&s(e.target)&&e.preventDefault()},children:o.map(({n:e,runs:n,focus:r})=>(0,K.jsxs)(`div`,{"data-line":e,className:r?`focus-line`:``,children:[(0,K.jsx)(`span`,{className:`ln`,"aria-hidden":`true`,children:e}),` `,n.map((e,n)=>{if(e.mark===null)return e.text;let r=t[e.mark],i=r.kind===`focus`?`hit`:r.kind===`site`?`site-mark`:`call-mark`,a=!!r.onClick;return(0,K.jsx)(`span`,{className:`mark ${i}${a?` clickable`:``}`,"data-mark":e.mark,title:r.title,...a&&e.first?{role:`button`,tabIndex:0}:{},children:e.text},n)})]},e))})}var jS={repository:`repository`,"workspace-package":`workspace package`,cluster:`cluster`};function MS(e){let{project:t,run:n,pick:r,file:i,fileLevel:a}=e;return a&&i&&r?.startsWith(`CALLS_CROSS_FILE|`)?(0,K.jsx)(zS,{project:t,run:n,file:i,call:r}):a&&i&&(r?.startsWith(`IMPORTS|`)||r?.startsWith(`unresolved-import|`))?(0,K.jsx)(BS,{project:t,run:n,file:i,edge:r}):a&&i?(0,K.jsx)(FS,{project:t,run:n,file:i,onOpenFile:e.onOpenFile}):r&&r.startsWith(`folder|`)?(0,K.jsx)(IS,{...e,folder:r}):r&&!r.startsWith(`group|`)?(0,K.jsx)(FS,{project:t,run:n,file:r,onOpenFile:e.onOpenFile,canOpen:!0}):(0,K.jsx)(NS,{project:t,run:n,group:e.group,pick:r,onOpenGroup:e.onOpenGroup,onPick:e.onPick})}function NS({project:e,run:t,group:n,pick:r,onOpenGroup:i,onPick:a}){let{groups:o}=Dx(e,t),s=n??(o?.total===1?o.groups[0].id:r),c=s&&o?o.groups.find(e=>e.id===s):void 0;if(!o)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!o.stage2)return(0,K.jsx)(`p`,{className:`hint`,children:`Stage 2 hasn't run on this project, so there are no groups yet.`});if(!c)return(0,K.jsx)(`p`,{className:`hint`,children:`Pick a group on the map to see what it holds and what it depends on; double-click or press Enter to open it.`});let l=e=>o.groups.find(t=>t.id===e)?.name??e,u=o.dependsOn.filter(e=>e.from===c.id),d=o.dependsOn.filter(e=>e.to===c.id),f=c.findings,p=(e,t)=>e.length===0?(0,K.jsx)(`p`,{className:`small muted`,children:`None`}):(0,K.jsx)(`ul`,{className:`plain`,children:e.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`button`,{className:`link`,onClick:()=>n?i(e[t]):a(e[t]),children:l(e[t])}),` `,(0,K.jsxs)(`span`,{className:`small muted`,children:[e.imports,` import`,e.imports===1?``:`s`,` · `,e.calls,` call`,e.calls===1?``:`s`]})]},e.id))});return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`group-details`,children:[(0,K.jsx)(`h3`,{children:c.name}),(0,K.jsxs)(`p`,{className:`muted small`,children:[c.source,` · `,jS[c.kind]??c.kind,c.root?` · ${c.root}`:``]}),(0,K.jsxs)(`p`,{children:[c.files.toLocaleString(),` files · `,c.functions.toLocaleString(),` functions · `,c.externalPackages,` `,`external package`,c.externalPackages===1?``:`s`]}),f.broken+f.notAnalyzed+f.openCalls+f.pending>0&&(0,K.jsx)(`p`,{className:`small`,"data-testid":`group-findings`,children:[f.broken?`${f.broken} broken import${f.broken===1?``:`s`}`:``,f.notAnalyzed?`${f.notAnalyzed} import${f.notAnalyzed===1?``:`s`} of files not analyzed`:``,f.openCalls?`${f.openCalls} open question${f.openCalls===1?``:`s`}`:``,f.pending?`${f.pending} pending`:``].filter(Boolean).join(` · `)}),(0,K.jsx)(`h4`,{className:`muted small`,children:`Depends on`}),p(u,`to`),(0,K.jsx)(`h4`,{className:`muted small`,children:`Used by`}),p(d,`from`),!n&&o.total>1&&(0,K.jsxs)(`button`,{"data-command":`open-group`,"data-testid":`open-picked`,onClick:()=>i(c.id),children:[`Open `,c.name]})]})}var PS=e=>e.slice(e.indexOf(`:`)+1);function FS({project:e,run:t,file:n,onOpenFile:r,canOpen:i=!1}){let{imports:a,error:o}=kx(e,t,n),{groups:s}=Dx(e,t);if(o)return(0,K.jsx)(`p`,{className:`hint error`,children:o});if(!a)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});let c=a.file.group?s?.groups.find(e=>e.id===a.file.group):void 0,l=c&&c.kind!==`cluster`?c.root:``;return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`file-details`,children:[(0,K.jsx)(`h3`,{className:`mono`,children:xx(a.file.path,l)}),(0,K.jsx)(`p`,{className:`muted small`,children:c?`${c.name} · ${c.source}`:PS(n)}),(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Imports (`,a.total,`)`]}),a.imports.length===0?(0,K.jsx)(`p`,{className:`small muted`,children:`None`}):(0,K.jsx)(`ul`,{className:`plain`,"data-testid":`file-imports`,children:a.imports.map(e=>(0,K.jsxs)(`li`,{className:e.outcome===`broken`?`broken`:void 0,"data-outcome":e.outcome,children:[(0,K.jsx)(`span`,{className:`mono small`,children:e.specifier}),` `,e.outcome===`file`&&e.file?(0,K.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path}):e.outcome===`package`&&e.package?(0,K.jsxs)(`span`,{className:`small muted`,children:[`package `,e.package.name,e.package.version?` ${e.package.version}`:``]}):(0,K.jsxs)(`span`,{className:`small outcome`,children:[`(`,e.outcome===`not-analyzed`?`not analyzed`:e.outcome,`:`,` `,yx[e.reason??``]??e.reason,`)`]})]},e.id))}),a.truncated&&(0,K.jsxs)(`p`,{className:`small muted`,children:[`Showing `,a.imports.length,` of `,a.total,`.`]}),(0,K.jsxs)(`h4`,{className:`muted small`,children:[`Imported by (`,a.importedBy.total,`)`]}),a.importedBy.files.length===0?(0,K.jsx)(`p`,{className:`small muted`,children:`None`}):(0,K.jsx)(`ul`,{className:`plain`,"data-testid":`file-importers`,children:a.importedBy.files.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(`button`,{className:`link small`,onClick:()=>r(e.file.id),children:e.file.path})},e.id))}),i&&(0,K.jsx)(`button`,{"data-command":`open-imports-file`,"data-testid":`open-picked-file`,onClick:()=>r(n),children:`Open file`})]})}function IS({project:e,run:t,group:n,folder:r,expand:i,showPending:a,onToggleFolder:o}){let{groups:s}=Dx(e,t),{group:c}=Ox(e,t,n??(s?.total===1?s.groups[0].id:null),i,a),l=c?.nodes.find(e=>e.id===r);return!l||l.kind!==`folder`?(0,K.jsx)(`p`,{className:`hint`,children:`Pick a file or a folder in the group.`}):(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`folder-details`,children:[(0,K.jsxs)(`h3`,{className:`mono`,children:[l.path,`/`]}),(0,K.jsxs)(`p`,{children:[l.files.toLocaleString(),` files`]}),l.findings.broken>0&&(0,K.jsxs)(`p`,{className:`small`,children:[l.findings.broken,` broken import`,l.findings.broken===1?``:`s`]}),(0,K.jsx)(`button`,{"data-command":`toggle-folder`,onClick:()=>o(l.path),children:`Open the folder`})]})}function LS({project:e,run:t,file:n,span:r}){let[i,a]=(0,d.useState)(null),o=`${t}|${n}|${r.start.offset}|${r.end.offset}`;return(0,d.useEffect)(()=>{let t=!1;return a(null),L.snippet(e,n,r).then(e=>!t&&a(e),()=>!t&&a(`error`)),()=>{t=!0}},[e,o]),i?i===`error`?(0,K.jsx)(`p`,{className:`small muted`,children:`The code couldn't be loaded.`}):(0,K.jsx)(AS,{snippet:i,marks:[{start:r.start,end:r.end,kind:`focus`}],focusLine:r.start.line,testId:`snippet`}):null}function RS({file:e,span:t}){return(0,K.jsx)(`p`,{className:`location small`,"data-testid":`evidence-location`,children:(0,K.jsxs)(`code`,{children:[PS(e),`:`,t.start.line,`:`,t.start.column]})})}function zS({project:e,run:t,file:n,call:r}){let{calls:i}=Ax(e,t,n),a=i?[...i.out.calls,...i.in.calls].find(e=>e.id===r):void 0;if(!i)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});if(!a)return(0,K.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let o=a.via===`import`?`found by import analysis${a.hops?.length?`, through ${a.hops.length} re-export${a.hops.length===1?``:`s`}`:``}`:a.via===`component`?`found by component linking`:`found by the template link`,s=a.steps?.find(e=>e.kind===`import`);return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`call-details`,children:[(0,K.jsxs)(`h3`,{"data-testid":`evidence-title`,children:[a.from.name,` calls `,a.to.name]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`across files · `,o]}),s&&(0,K.jsx)(`p`,{className:`small`,"data-testid":`call-import`,children:s.detail}),a.hops&&a.hops.length>0&&(0,K.jsxs)(`p`,{className:`small muted`,children:[`through `,a.hops.join(` › `)]}),a.provenance&&(0,K.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,U(a.provenance.stage),` · run `,a.provenance.run]}),(0,K.jsx)(RS,{file:a.evidence.file,span:a.evidence.span}),(0,K.jsx)(LS,{project:e,run:t,file:a.evidence.file,span:a.evidence.span}),(0,K.jsx)(ue,{project:e,id:a.id},a.id)]})}function BS({project:e,run:t,file:n,edge:r}){let{imports:i}=kx(e,t,n);if(!i)return(0,K.jsx)(`p`,{className:`hint`,children:`Loading…`});let a=i.imports.find(e=>e.id===r),o=i.importedBy.files.find(e=>e.id===r);if(!a&&!o)return(0,K.jsx)(`p`,{className:`hint`,children:`Pick a call or an import on the canvas.`});let s=a?.evidence??o.evidence;return(0,K.jsxs)(`div`,{className:`evidence imports-details`,"data-testid":`import-details`,children:[(0,K.jsx)(`h3`,{"data-testid":`evidence-title`,children:a?`imports ${a.specifier}`:`${o.file.path} imports this file`}),a?.file&&(0,K.jsxs)(`p`,{className:`small`,children:[`resolves to `,a.file.path]}),a&&!a.file&&!a.package&&(0,K.jsxs)(`p`,{className:`small`,"data-testid":`import-outcome`,children:[a.outcome===`not-analyzed`?`not analyzed`:a.outcome,`:`,` `,yx[a.reason??``]??a.reason]}),a?.steps.map((e,t)=>(0,K.jsx)(`p`,{className:`small muted`,children:e.detail},t)),(a?.provenance??o?.provenance)&&(0,K.jsxs)(`p`,{className:`muted small`,"data-testid":`evidence-provenance`,children:[`Found by `,U((a?.provenance??o.provenance).stage),` · run`,` `,(a?.provenance??o.provenance).run]}),(0,K.jsx)(RS,{file:s.file,span:s.span}),(0,K.jsx)(LS,{project:e,run:t,file:s.file,span:s.span}),(0,K.jsx)(ue,{project:e,id:r},r)]})}var VS=o(),HS=24,US=12,WS=300,GS=new Set([`apps`,`packages`,`services`,`libs`,`modules`,`crates`,`projects`]),KS=/(^|\/)(__tests__|__mocks__|tests?|e2e|specs?|fixtures?)\/|\.(test|spec|e2e|stories)\.[a-z0-9]+$/i,qS=/(^|\/)([\w-]+\.config\.[cm]?[jt]sx?|\.?[\w-]*rc\.[cm]?[jt]s|(vite|vitest|jest|webpack|rollup|babel|eslint|prettier|tailwind|postcss|playwright|next|nuxt|svelte|astro|tsup|knip|commitlint|stylelint)\.[\w.-]*[cm]?[jt]s)$/i;function JS(e){return KS.test(e)?`tests`:qS.test(e)?`config`:`source`}var YS=e=>e.status!==`analyzed`,XS={"parse-failure":`could not be parsed`,"declaration-file":`type declarations`,"language-not-analyzed":`language not analyzed yet`,"too-large":`too large`,binary:`not text`},ZS=(e,t)=>e<t?-1:+(e>t);function QS(e,t,n){let r={key:``,name:``,dirs:new Map,files:[],total:0,functions:0};for(let i of e){let e=(n?`${i.source}/${i.path}`:i.path).split(`/`);e.pop();let a=r,o=t[i.id]?.functions??0;a.total++,a.functions+=o;let s=``;for(let t of e){s=s?`${s}/${t}`:t;let e=a.dirs.get(t);e||(e={key:s,name:t,dirs:new Map,files:[],total:0,functions:0},a.dirs.set(t,e)),a=e,a.total++,a.functions+=o}a.files.push(i)}return r}function $S(e,t=!1,n=0){for(let[r,i]of e.dirs)e.dirs.set(r,$S(i,t,n+1));if(e.key!==``&&!(t&&n===1)&&e.files.length===0&&e.dirs.size===1){let t=[...e.dirs.values()][0];return{...t,name:`${e.name}/${t.name}`}}return e}function eC(e,t,n){let r=[],i=(e,a)=>{let o=[...e.dirs.values()].sort((e,t)=>{if(a===0){let n=+!GS.has(e.name.split(`/`)[0]),r=+!GS.has(t.name.split(`/`)[0]);if(n!==r)return n-r}return ZS(e.name,t.name)});for(let e of o){let n=t.has(e.key);r.push({type:`dir`,key:e.key,name:e.name,depth:a,open:n,total:e.total,functions:e.functions}),n&&i(e,a+1)}for(let t of[...e.files].sort((e,t)=>ZS(e.path,t.path))){let e=n[t.id];r.push({type:`file`,file:t,depth:a,label:t.path.slice(t.path.lastIndexOf(`/`)+1),...e?{hint:`${e.functions}ƒ`}:{}})}};return i(e,0),r}var tC=60;function nC(e,t){let n=new Set,r=e=>{for(let t of e.dirs.values())n.add(t.key),r(t)};if(t<=tC)return r(e),n;for(let t of e.dirs.values())if(n.add(t.key),GS.has(t.name.split(`/`).pop())||GS.has(t.name.split(`/`)[0]))for(let e of t.dirs.values())n.add(e.key);return n}var rC=e=>`veoflow.tree.${e}`;function iC(e){try{let t=localStorage.getItem(rC(e)),n=t?JSON.parse(t):[];return n.length>0?new Set(n):null}catch{return null}}function aC(e,t){try{localStorage.setItem(rC(e),JSON.stringify([...t]))}catch{}}function oC({project:e,files:t,counts:n,current:r,onOpen:i,run:a=null,onAnalyze:o,sources:s=[],scope:c=null,onScope:l}){let[u,f]=(0,d.useState)(!1),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)({source:!0,tests:!1,config:!0}),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(new Set),[x,S]=(0,d.useState)(0),[C,w]=(0,d.useState)(600),[T,E]=(0,d.useState)(0),D=(0,d.useRef)(null),O=(0,d.useRef)(null),k=t;t=(0,d.useMemo)(()=>c?k.filter(e=>e.source===c):k,[k,c]);let A=(0,d.useMemo)(()=>s.length>1||new Set(k.map(e=>e.source)).size>1,[k,s.length]),j=(0,d.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),M=e=>{let t=j.get(e)?.analysis;return t?t.kind===`git`?`${t.branch??`detached`} · ${t.revision.slice(0,7)} · ${W(t.analyzedAt)}`:`plain folder · latest only`:``},N=(0,d.useMemo)(()=>{let e={source:0,tests:0,config:0,attention:0};for(let n of t)e[JS(n.path)]++,YS(n)&&e.attention++;return e},[t]),P=(0,d.useMemo)(()=>t.filter(e=>_?YS(e):e.id===r||h[JS(e.path)]||YS(e)),[t,h,_,r]),F=(0,d.useMemo)(()=>{let e=$S(QS(P,n,A),A);return c&&A?e.dirs.get(c)??{...e,dirs:new Map,files:[]}:e},[P,n,A,c]),I=(0,d.useRef)(!1);(0,d.useEffect)(()=>{!I.current&&e&&t.length!==0&&(I.current=!0,b(iC(e)??nC(F,t.length)))},[e,t,F]);let L=t.find(e=>e.id===r);(0,d.useEffect)(()=>{if(!L)return;let e=(A?`${L.source}/${L.path}`:L.path).split(`/`);e.pop(),b(t=>{let n=new Set(t),r=``,i=!1;for(let t of e)r=r?`${r}/${t}`:t,n.has(r)||(n.add(r),i=!0);return i?n:t})},[L?.id]);let R=(0,d.useMemo)(()=>{let e=p.trim().toLowerCase();return e?t.map(t=>{let n=t.path.toLowerCase(),r=n.slice(n.lastIndexOf(`/`)+1);return{f:t,rank:r.replace(/\.[^.]+$/,``)===e||r===e?0:r.startsWith(e)?1:r.includes(e)?2:n.includes(e)?3:-1,kind:JS(t.path)===`source`?0:1}}).filter(e=>e.rank>=0).sort((e,t)=>e.rank-t.rank||e.kind-t.kind||e.f.path.length-t.f.path.length||ZS(e.f.path,t.f.path)).slice(0,WS).map(({f:e})=>{let t=e.path.includes(`/`)?e.path.slice(0,e.path.lastIndexOf(`/`)):``,n=A?j.get(e.source)?.name??e.source:``;return{type:`file`,file:e,depth:0,label:e.path.slice(e.path.lastIndexOf(`/`)+1),hint:[n,t].filter(Boolean).join(` · `)}}):eC(F,y,n)},[p,F,y,n,t,A,j]);(0,d.useEffect)(()=>{I.current&&e&&aC(e,y)},[y,e]),(0,d.useEffect)(()=>{T>=R.length&&E(Math.max(0,R.length-1))},[R.length,T]),(0,d.useEffect)(()=>{let e=D.current;if(!e)return;let t=new ResizeObserver(()=>w(e.clientHeight));return t.observe(e),()=>t.disconnect()},[]);let z=(0,d.useRef)(null),B=p.trim()!==``;(0,d.useEffect)(()=>{let e=r?`${r}\0${B}`:null;if(!r||z.current===e)return;let t=R.findIndex(e=>e.type===`file`&&e.file.id===r);if(t<0||!D.current)return;z.current=e;let n=t*HS,i=D.current;(n<i.scrollTop||n+HS>i.scrollTop+i.clientHeight)&&(i.scrollTop=Math.max(0,n-i.clientHeight/3),S(i.scrollTop)),E(t)},[r,R,B]),(0,d.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`p`&&(e.preventDefault(),O.current?.focus(),O.current?.select())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let V=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),H=e=>{let t=Math.max(0,Math.min(R.length-1,e)),n=D.current;if(n){let e=t*HS,r=n.scrollTop;e<r?r=e:e+HS>r+n.clientHeight&&(r=e+HS-n.clientHeight),n.scrollTop=r,(0,VS.flushSync)(()=>{S(r),E(t)})}else E(t);D.current?.querySelector(`[data-row="${t}"]`)?.focus({preventScroll:!0})},U=e=>{let t=R[e]?.depth??0;for(let n=e-1;n>=0;n--)if(R[n].type===`dir`&&R[n].depth<t)return n;return-1},G=e=>{let t=R[T];if(e.key===`ArrowDown`)H(T+1);else if(e.key===`ArrowUp`)H(T-1);else if(e.key===`Home`)H(0);else if(e.key===`End`)H(R.length-1);else if(e.key===`ArrowRight`&&t?.type===`dir`)t.open?H(T+1):V(t.key);else if(e.key===`ArrowLeft`){if(t?.type===`dir`&&t.open)V(t.key);else{let e=U(T);e>=0&&H(e)}}else return;e.preventDefault()},ee=Math.max(0,Math.floor(x/HS)-US),te=Math.min(R.length,Math.ceil((x+C)/HS)+US),ne=(e,t)=>N[e]===0?null:(0,K.jsxs)(`button`,{className:`chip`,"aria-pressed":!_&&h[e],"data-testid":`chip-${e}`,disabled:N[e]===0,onClick:()=>{v(!1),g(t=>({...t,[e]:!t[e]}))},children:[t,` `,(0,K.jsx)(`small`,{children:N[e]})]}),re=(0,d.useMemo)(()=>{let e=0,t=0;for(let n of a?.sources??[])e+=n.defaultExcluded?.length??0,t+=(n.ruleExcluded?.length??0)+(n.ruleExcludedMore??0);return{folders:e,paths:t}},[a]);return u&&e?(0,K.jsx)(`nav`,{className:`nav`,"aria-label":`Files`,children:(0,K.jsx)(iS,{project:e,files:t,run:a,onAnalyze:()=>{o?.(),f(!1)},onClose:()=>f(!1)})}):(0,K.jsxs)(`nav`,{className:`nav`,"aria-label":`Files`,children:[(0,K.jsxs)(`div`,{className:`nav-head`,children:[(s.length>1||c)&&(0,K.jsxs)(`label`,{className:`nav-scope`,children:[(0,K.jsx)(`span`,{className:`small muted`,children:`Scope`}),(0,K.jsxs)(`select`,{"data-command":`scope-source`,value:c??``,onChange:e=>l?.(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`All repositories`}),s.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),(0,K.jsx)(`input`,{ref:O,className:`nav-filter`,"data-testid":`file-filter`,type:`search`,placeholder:`Filter ${t.length} files… ⌘P`,"aria-label":`Filter files`,value:p,onChange:e=>{m(e.target.value),D.current&&(D.current.scrollTop=0),E(0)},onKeyDown:e=>{if(e.key===`Enter`&&p.trim()){let e=R.find(e=>e.type===`file`);e?.type===`file`&&i(e.file.id)}else e.key===`ArrowDown`?(e.preventDefault(),H(0)):e.key===`Escape`&&m(``)}}),(0,K.jsxs)(`div`,{className:`nav-chips`,role:`group`,"aria-label":`Show`,children:[ne(`source`,`Source`),ne(`tests`,`Tests`),ne(`config`,`Config`),N.attention>0&&(0,K.jsxs)(`button`,{className:`chip attention`,"aria-pressed":_,"data-testid":`chip-attention`,title:`Files that were not fully analyzed`,onClick:()=>v(e=>!e),children:[`⚠ `,(0,K.jsx)(`small`,{children:N.attention})]})]})]}),(0,K.jsxs)(`div`,{className:`nav-list`,ref:D,role:`tree`,"aria-label":`Files`,onScroll:e=>S(e.currentTarget.scrollTop),onKeyDown:G,children:[R.length===0&&t.length>0&&(0,K.jsx)(`p`,{className:`hint`,children:`No files match.`}),(0,K.jsx)(`div`,{style:{height:R.length*HS,position:`relative`},children:R.slice(ee,te).map((e,t)=>{let n=ee+t,a={top:n*HS,paddingLeft:8+e.depth*14};if(e.type===`dir`&&A&&!c&&e.depth===0&&j.has(e.key))return(0,K.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":1,"aria-setsize":R.length,"aria-posinset":n+1,tabIndex:n===T?0:-1,className:`row dir repo`,"data-testid":`repo-row`,"data-source":e.key,style:a,title:j.get(e.key)?.root??e.key,onClick:()=>{E(n),V(e.key)},children:[(0,K.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,K.jsx)(`strong`,{className:`name`,children:j.get(e.key)?.name??e.key}),(0,K.jsx)(`small`,{className:`muted repo-hint`,children:M(e.key)}),(0,K.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`r:${e.key}`);if(e.type===`dir`)return(0,K.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-expanded":e.open,"aria-level":e.depth+1,"aria-setsize":R.length,"aria-posinset":n+1,tabIndex:n===T?0:-1,className:`row dir`,style:a,title:e.key,onClick:()=>{E(n),V(e.key)},children:[(0,K.jsx)(`span`,{className:`caret`,children:e.open?`▾`:`▸`}),(0,K.jsx)(`span`,{className:`name`,children:e.name}),(0,K.jsx)(`small`,{className:`count`,title:`${e.total} files, ${e.functions} functions`,children:e.total})]},`d:${e.key}`);let o=e.file;return(0,K.jsxs)(`button`,{"data-row":n,role:`treeitem`,"aria-level":e.depth+1,"aria-setsize":R.length,"aria-posinset":n+1,"aria-selected":o.id===r,tabIndex:n===T?0:-1,"data-command":`open-file`,"data-file":o.path,className:`row file ${o.id===r?`current`:``} ${o.status}`,style:a,title:o.status===`analyzed`?o.path:`${o.path} — ${o.status}: ${o.reason??``}`,onClick:()=>{E(n),i(o.id)},children:[(0,K.jsx)(`span`,{className:`caret`}),(0,K.jsxs)(`span`,{className:`name`,children:[e.label,p.trim()&&e.hint?(0,K.jsxs)(`small`,{className:`muted`,children:[` `,e.hint]}):null]}),o.origin&&(0,K.jsx)(`small`,{className:`origin ${o.origin}`,title:o.origin===`library`?`Installed library code, not the project's own`:o.origin===`tool`?`A tool's or coding agent's workspace, not the project's own code`:`Generated output, not the project's own code`,children:o.origin}),YS(o)?(0,K.jsxs)(`small`,{className:`warn`,"aria-label":`${o.status}: ${o.reason??``}`,children:[`⚠ `,XS[o.reason??``]??o.reason??o.status]}):!p.trim()&&e.hint&&(0,K.jsx)(`small`,{className:`count`,children:e.hint})]},`f:${o.id}`)})})]}),e&&o&&(0,K.jsxs)(`div`,{className:`nav-foot`,children:[(0,K.jsx)(`small`,{className:`muted`,"data-testid":`left-out`,children:re.folders+re.paths===0?``:`Left out: ${[re.folders?`${re.folders} by default (libraries, generated, tools)`:``,re.paths?`${re.paths} by your choice`:``].filter(Boolean).join(`, `)}`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{"data-testid":`choose-files`,onClick:()=>f(!0),title:`Choose which files are analyzed`,children:`Choose files…`})]})]})}p_.use(px);function sC(e){try{return cC(e)}catch{return lC(e)}}function cC(e){let t=p_({headless:!0,styleEnabled:!0,elements:[...e.nodes.map(e=>({data:{id:e.id,w:e.w,h:e.h}})),...e.edges.map(e=>({data:{id:e.id,source:e.source,target:e.target}}))],style:[{selector:`node`,style:{width:`data(w)`,height:`data(h)`}}]}),n=e=>t.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1,animate:!1}).run();try{n(`LR`);let r=t.elements().boundingBox(),{w:i,h:a}=e.canvas;r.w*e.fitZoom>i-2*e.pad&&r.w/Math.max(1,r.h)>i/a&&n(`TB`)}catch(e){throw t.destroy(),e}let r={};for(let e of t.nodes().toArray())r[e.id()]={...e.position()};return t.destroy(),r}function lC(e){let t=Math.max(1,Math.ceil(Math.sqrt(e.nodes.length))),n=Math.max(40,...e.nodes.map(e=>e.w))+24,r={};return e.nodes.forEach((e,i)=>{r[e.id]={x:i%t*n,y:Math.floor(i/t)*40}}),r}var uC=null,dC=typeof Worker>`u`,fC=0,pC=new Map,mC=e=>new Promise(t=>setTimeout(()=>t(sC(e)),0));function hC(){try{let e=new Worker(new URL(`/assets/callLayout.worker-BugXMtxI.js`,``+import.meta.url),{type:`module`});return e.addEventListener(`message`,e=>{let t=pC.get(e.data.id);t&&(pC.delete(e.data.id),e.data.error===void 0?t.resolve(e.data.positions):(console.error(`veoflow: laying out this graph failed; placed in a grid`,e.data.error),t.resolve(lC(t.input))))}),e.addEventListener(`error`,t=>{console.error(`veoflow: the layout worker failed; laying out on the page instead`,t),dC=!0,e.terminate(),uC=null;for(let[e,t]of pC)pC.delete(e),mC(t.input).then(t.resolve)}),e}catch{return dC=!0,null}}function gC(e){if(pC.size>0&&uC&&(uC.terminate(),uC=null,pC.clear()),!dC&&!uC&&(uC=hC()),!uC)return mC(e);let t=++fC;return new Promise(n=>{pC.set(t,{input:e,resolve:n}),uC.postMessage({id:t,input:e})})}var _C=2,vC=40,yC=25,bC=7;function xC(e,t,n=null){let r=new Map,i=(e,t)=>{e!==t&&(r.has(e)||r.set(e,new Set),r.get(e).add(t))};for(let t of e.calls)i(t.from,t.to),i(t.to,t.from);let a=e=>r.get(e)?.size??0,o=(e,t)=>[...e].sort((e,t)=>a(t)-a(e)||(e<t?-1:1)).slice(0,t),s=new Set(e.functions.map(e=>e.id));if(n&&s.has(n[0])&&s.has(n[1])){let e=new Set(n);for(let t of n)for(let n of o(r.get(t)??[],bC))e.add(n);return e}if(t&&s.has(t)){let e=new Set([t]),n=o(r.get(t)??[],yC);for(let t of n)e.add(t);for(let t=1;t<_C&&e.size<vC;t++)for(let t of n)for(let n of o(r.get(t)??[],5))e.size<vC&&e.add(n);return e}return new Set(o(s,vC))}var SC=e=>`site:${e}`,CC=(e,t)=>`pair:${e}->${t}`;p_.use(px);var wC=.85,TC=1.25,EC=45,DC=.68,OC=4,kC=36,AC=e=>Math.max(36,String(e.data(`label`)).length*7+18);function jC(e){let t=e.nodes(`[kind = "function"], [kind = "port"], [kind = "ghost"]`).not(`.hidden`),n=e.edges(`[kind = "call"], [kind = "ghost-call"]`).not(`.hidden`),r=t.filter(e=>e.connectedEdges(`[kind = "call"], [kind = "ghost-call"]`).not(`.hidden`).empty());return{fns:t,isolated:r,connected:t.difference(r).union(n)}}var MC=300;function NC(e){let{connected:t}=jC(e);return{nodes:t.nodes().toArray().map(e=>({id:e.id(),w:e.outerWidth(),h:e.outerHeight()})),edges:t.edges().map(e=>({id:e.id(),source:e.source().id(),target:e.target().id()})),canvas:{w:Math.max(1,e.width()),h:Math.max(1,e.height())},fitZoom:DC,pad:kC}}function PC(e,t){let{fns:n,isolated:r,connected:i}=jC(e),a=e=>i.layout({name:`dagre`,rankDir:e,nodeSep:14,rankSep:e===`LR`?70:50,fit:!1}).run(),o={w:Math.max(1,e.width()),h:Math.max(1,e.height())};if(t)e.batch(()=>{for(let e of i.nodes().toArray()){let n=t[e.id()];n&&e.position(n)}});else if(i.nonempty()){a(`LR`);let e=i.boundingBox();e.w*DC>o.w-72&&e.w/Math.max(1,e.h)>o.w/o.h&&a(`TB`)}let s=r.toArray(),c=i.nonempty()?i.boundingBox():{x1:0,y1:0,x2:0,y2:0,w:0,h:0},l=i.nonempty()?c.y2+48:0,u=Math.max(0,...s.map(e=>AC(e)))+24,d=Math.max(OC,Math.floor(Math.max(c.w,o.w/wC-72)/u));s.forEach((e,t)=>{e.position({x:c.x1+t%d*u+u/2,y:l+Math.floor(t/d)*34})});for(let e of n.toArray()){let t=e.outgoers(`node[kind = "site"]`).not(`.hidden`).toArray();if(t.length===0)continue;let n=e.position(),r=n.x+AC(e)/2+48;t.forEach((e,i)=>e.position({x:r+AC(e)/2,y:n.y+(i-(t.length-1)/2)*26}))}}function FC(e,t){if(t.empty())return;e.fit(t,kC);let n=e.zoom(),r=t.nodes().length<=EC?DC:wC;if(n>TC)e.zoom(TC),e.center(t);else if(n<r){let n=t.boundingBox();e.zoom(r),e.pan({x:kC-n.x1*r,y:kC-n.y1*r})}}function IC(e,t){if(t.edges().nonempty()||t.nodes(`[kind = "site"]`).nonempty()){FC(e,t.union(t.edges().connectedNodes()).union(t.nodes().incomers(`node`)));return}let n=t,r=n.renderedBoundingBox(),i=e.width(),a=e.height();r.x1>=0&&r.y1>=0&&r.x2<=i&&r.y2<=a||e.animate({center:{eles:n}},{duration:250})}function LC({graph:e,showUnresolved:t,selection:n,onSelect:r,onClear:i,focus:a,sitesFor:o,answered:s,marks:c,only:l=null,onContext:f,extraSite:p=null}){let m=(0,d.useRef)(null),h=(0,d.useRef)(null),g=(0,d.useRef)(l);g.current=l;let _=(0,d.useRef)(f);_.current=f,(0,d.useEffect)(()=>{h.current&&_e(h.current,l)},[l]);let v=(0,d.useRef)(0),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(0);(0,d.useEffect)(()=>{let n=new Set(e.functions.map(e=>e.id)),a=new Map;for(let t of e.calls){if(!t.crossFile)continue;let e=n.has(t.from)?t.to:t.from;if(n.has(e)||a.has(e))continue;let r=t.function.path.split(`/`).pop()??t.function.path;a.set(e,`${r} › ${V(t.function.qualifiedName,void 0,t.function.title).name}`)}for(let e of a.keys())n.add(e);let o=new Set(e.calls.filter(e=>e.from===e.to).map(e=>e.from)),s=new Map;for(let t of e.calls){if(t.from===t.to||!n.has(t.from)||!n.has(t.to))continue;let e=CC(t.from,t.to),r=s.get(e);r?r.calls.push(t.id):s.set(e,{from:t.from,to:t.to,calls:[t.id]})}let c=e.functions.map(e=>V(e.qualifiedName,e.evidence.span.start.line,e.title).name),l=new Set(c.filter((e,t)=>c.indexOf(e)!==t)),d=[...e.functions.map((e,t)=>{let n=c[t],r=l.has(n)&&!n.includes(`· line`)?`${n} · line ${e.evidence.span.start.line}`:n;return{data:{id:e.id,label:o.has(e.id)?`${r} ↻`:r,kind:`function`},classes:e.qualifiedName===`<module>`?`module`:``}}),...[...a].map(([e,t])=>({data:{id:e,label:t,kind:`port`},classes:`port`})),...[...s].map(([e,t])=>({data:{id:e,source:t.from,target:t.to,kind:`call`,calls:t.calls,label:t.calls.length>1?`×${t.calls.length}`:``}}))];if(t||p){let r=new Map;for(let i of e.unresolved){if(!n.has(i.enclosingFn)||!(t&&u(i))&&i.id!==p)continue;let e=`${i.enclosingFn}\u0000${i.expression}\u0000${i.status}`,a=r.get(e);a?a.ids.push(i.id):r.set(e,{fn:i.enclosingFn,expression:i.expression,ids:[i.id],status:i.status})}for(let e of r.values()){let t=SC(e.ids[0]),n=e.expression.length>40?`${e.expression.slice(0,39)}…`:e.expression;d.push({data:{id:t,label:e.ids.length>1?`${n} ×${e.ids.length}`:n,kind:`site`,ids:e.ids},classes:`site ${e.status}`},{data:{id:`edge:${t}`,source:e.fn,target:t,kind:`site-edge`},classes:`site-edge`})}}let f=p_({container:m.current,elements:d,autounselectify:!0,layout:{name:`preset`},minZoom:.15,maxZoom:3,style:[{selector:`node`,style:{label:`data(label)`,"font-size":12,"text-valign":`center`,"text-halign":`center`,shape:`round-rectangle`,width:AC,height:22,"background-color":`#e8eef8`,"border-width":1,"border-color":`#6b87b8`,color:`#1d2330`}},{selector:`node.module`,style:{"background-color":`#f3f3f3`,"border-color":`#aaa`}},{selector:`node.port`,style:{"background-color":`#fff`,"border-style":`dashed`,"border-color":`#7a8aa0`,color:`#4a5568`}},{selector:`node.site`,style:{"background-color":`#fff`,"border-style":`dashed`,"border-color":`#c07a00`,color:`#8a5a00`}},{selector:`node.site.awaiting-link, node.site.external`,style:{"border-color":`#999`,color:`#777`}},{selector:`edge`,style:{width:1.5,"curve-style":`bezier`,"target-arrow-shape":`triangle`,"line-color":`#8fa6cc`,"target-arrow-color":`#8fa6cc`,label:`data(label)`,"font-size":10,color:`#5c6678`,"text-background-color":`#fafbfc`,"text-background-opacity":1,"text-background-padding":`2px`}},{selector:`edge.site-edge`,style:{"line-style":`dashed`,"line-color":`#c9a45c`,"target-arrow-color":`#c9a45c`}},...be,ge,{selector:`.hidden`,style:{display:`none`}},{selector:`node.answered`,style:{"border-width":2,"border-color":`#d99a00`,"background-color":`#fff4cc`}},{selector:`.faded`,style:{opacity:.22}},{selector:`node.picked`,style:{"border-width":2,"border-color":`#2f5fbf`,"background-color":`#d6e3fa`}},{selector:`edge.picked`,style:{"line-color":`#2f5fbf`,"target-arrow-color":`#2f5fbf`,width:3}}]});return f.on(`tap`,`node, edge`,e=>{let t=e.target.data(`kind`),n=e.target.id();t===`function`?r({kind:`function`,id:n}):t===`call`?r({kind:`call`,id:e.target.data(`calls`)[0]}):t===`site`&&r({kind:`site`,id:e.target.data(`ids`)[0]})}),f.on(`tap`,e=>{e.target===f&&i()}),h.current=f,_e(f,g.current),f.on(`cxttap`,`node, edge`,e=>{let t=e.target.data(),n=t.kind===`function`?`function`:t.kind===`call`?`edge`:null;if(!n||!m.current)return;let r=m.current.getBoundingClientRect(),i=e.renderedPosition??{x:0,y:0};_.current?.({kind:n,id:n===`file`&&typeof t.file==`string`?t.file:e.target.id(),data:t,x:r.left+i.x,y:r.top+i.y})}),m.current&&(m.current.veoCy=f),()=>{h.current=null,f.destroy()}},[e,t,r,i,p]);let C=(c?.removed??[]).filter(t=>t.file===e.file.id&&(t.type===`Function`||t.type===`CALLS`)).map(e=>e.id).join(`
|
|
338
338
|
`);(0,d.useEffect)(()=>{let t=h.current;t&&t.batch(()=>{if(t.elements(`.ghost`).remove(),t.elements().removeClass(`diff-added diff-removed diff-changed`),!c)return;t.nodes(`[kind = "function"]`).forEach(e=>{let t=c.byId.get(e.id());t&&e.addClass(ye(t))}),t.edges(`[kind = "call"]`).forEach(e=>{let t=e.data(`calls`).map(e=>c.byId.get(e)).find(Boolean);t&&e.addClass(ye(t))});let n=new Set(t.nodes().map(e=>e.id())),r=new Set,i=[];for(let t of c.removed){if(t.type!==`Function`||t.file!==e.file.id||n.has(t.id))continue;let a=t.fact;r.add(t.id),i.push({data:{id:t.id,label:`${a.qualifiedName??a.name??t.id} (removed)`,kind:`ghost`},classes:`diff-removed ghost`})}for(let e of c.removed){if(e.type!==`CALLS`)continue;let t=e.fact,a=e=>!!e&&(n.has(e)||r.has(e));a(t.from)&&a(t.to)&&t.from!==t.to&&i.push({data:{id:`gone:${e.id}`,source:t.from,target:t.to,kind:`ghost-call`,label:``},classes:`diff-removed ghost`})}i.length&&t.add(i)})},[c,e,t,p]);let w=a?o:null;return(0,d.useEffect)(()=>{let e=h.current;if(!e)return;e.batch(()=>{if(e.elements().removeClass(`hidden`),a){let t=e.nodes().filter(e=>e.data(`kind`)===`function`?!a.has(e.id()):e.incomers(`node`).first().id()!==w);t.addClass(`hidden`),t.connectedEdges().addClass(`hidden`)}});let t=++v.current;if(jC(e).connected.nodes().length<=MC){PC(e),FC(e,e.elements().not(`.hidden`)),g.current&&_e(e,g.current),b(!1);return}b(!0),gC(NC(e)).then(n=>{t===v.current&&h.current===e&&(PC(e,n),FC(e,e.elements().not(`.hidden`)),g.current&&_e(e,g.current),b(!1),S(e=>e+1))})},[a,e,t,w,C,p]),(0,d.useEffect)(()=>{let t=h.current;if(!t||(t.batch(()=>{t.elements().removeClass(`picked faded`)}),m.current?.setAttribute(`data-picked`,``),!n))return;let r=n.kind===`site`?t.nodes(`[kind = "site"]`).filter(e=>e.data(`ids`).includes(n.id)):t.getElementById(n.id);if(r.empty()&&n.kind===`call`&&(r=t.edges().filter(e=>(e.data(`calls`)??[]).includes(n.id)),r.empty())){let i=e.calls.find(e=>e.id===n.id);i&&(r=t.getElementById(i.from))}if(r.empty())return;m.current?.setAttribute(`data-picked`,`${n.kind}:${n.id}`);let i=r.union(r.nodes().closedNeighborhood()).union(r.edges().connectedNodes());t.batch(()=>{r.addClass(`picked`),a||t.elements().not(i).addClass(`faded`)}),IC(t,r)},[n,e,t,a,x,p]),(0,d.useEffect)(()=>{let e=h.current;e&&e.batch(()=>{e.nodes().removeClass(`answered`),s&&e.nodes().filter(e=>s.has(e.id())).addClass(`answered`)})},[s,e,t,a,p]),(0,K.jsxs)(`div`,{className:`graph-wrap`,children:[(0,K.jsx)(`div`,{className:`graph`,ref:m,"data-testid":`graph`,"data-laying-out":y||void 0}),y&&(0,K.jsx)(`div`,{className:`laying-out`,children:`Laying out…`}),(0,K.jsx)(`button`,{className:`fit`,title:`Fit the graph to the view`,"aria-label":`Fit the graph to the view`,onClick:()=>{let e=h.current;e&&FC(e,e.elements().not(`.hidden`))},children:`Fit`})]})}function RC({run:e,quiet:t=!1}){let n=e?.sources??[],r=n.flatMap(e=>(e.notices??[]).map(t=>n.length>1?`${e.sourceId}: ${t}`:t));return r.length?(0,K.jsx)(`ul`,{className:`run-notices${t?` quiet`:``}`,"data-testid":`run-notices`,"aria-label":`Notes from the analysis`,children:r.map(e=>(0,K.jsx)(`li`,{children:e},e))}):null}function zC({project:e,files:t,run:n,counts:r,questions:i,onOpen:a,onQuestions:o}){let[s,c]=(0,d.useState)([]);(0,d.useEffect)(()=>{let t=!1;return L.aggregate(e,`CALLS`,`to`,30,!0).then(e=>!t&&c(e.groups.filter(e=>JS(e.key.slice(e.key.indexOf(`:`)+1,e.key.lastIndexOf(`:`)))===`source`).slice(0,5)),()=>!t&&c([])),()=>{t=!0}},[e,t]);let l=(0,d.useMemo)(()=>{let e=0,t=0;for(let n of Object.values(r))e+=n.functions,t+=n.calls;return{functions:e,calls:t}},[r]),u=(0,d.useMemo)(()=>t.filter(e=>JS(e.path)===`source`&&!e.origin).map(e=>({f:e,n:r[e.id]?.functions??0})).filter(e=>e.n>0).sort((e,t)=>t.n-e.n||(e.f.path<t.f.path?-1:1)).slice(0,5),[t,r]),f=(0,d.useMemo)(()=>new Map(t.map(e=>[e.id,e.path])),[t]),p=e=>e.toLocaleString(`en-US`);return(0,K.jsxs)(`div`,{className:`overview`,"data-testid":`overview`,children:[(0,K.jsx)(RC,{run:n,quiet:!0}),(0,K.jsxs)(`dl`,{className:`stats`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`files`}),(0,K.jsx)(`dd`,{children:p(t.length)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`functions`}),(0,K.jsx)(`dd`,{children:p(l.functions)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`calls`}),(0,K.jsx)(`dd`,{children:p(l.calls)})]}),(0,K.jsxs)(`div`,{className:`muted-stat`,children:[(0,K.jsxs)(`dt`,{children:[`open questions`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`small`,{children:`mostly calls on values of unknown type`})]}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`button`,{className:`stat-link`,onClick:o,title:`Show the open questions`,children:i===null?`…`:p(i.length)})})]})]}),(0,K.jsxs)(`div`,{className:`columns`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h4`,{children:`Largest files`}),(0,K.jsx)(`ul`,{children:u.map(({f:e,n:t})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row`,onClick:()=>a(e.id),title:e.path,children:[(0,K.jsx)(`span`,{className:`name`,children:e.path}),(0,K.jsxs)(`small`,{children:[t,` functions`]})]})},e.id))})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`h4`,{children:`Most called`}),(0,K.jsx)(`ul`,{children:s.map(e=>{let t=e.key.slice(0,e.key.lastIndexOf(`:`));return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:`link-row`,onClick:()=>a(t),title:`${e.name??e.key} in ${f.get(t)??t}`,children:[(0,K.jsxs)(`span`,{className:`name`,children:[V(e.name??e.key).name,s.filter(t=>t.name===e.name).length>1&&(0,K.jsxs)(`small`,{className:`muted`,children:[` `,(f.get(t)??t).split(`/`).pop()]})]}),(0,K.jsxs)(`small`,{children:[e.count,` calls`]})]})},e.key)})})]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`Open a file on the left, or ask a question above (⌘K).`})]})}function BC({onClose:e,onSaved:t}){let[n,r]=(0,d.useState)(null),[i,a]=(0,d.useState)(``),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(``),[u,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1),h=(0,d.useRef)(null);(0,d.useEffect)(()=>{L.settings().then(({model:e})=>{r(e),a(e.baseUrl),s(e.model),setTimeout(()=>h.current?.focus(),0)},e=>f({ok:!1,text:`Could not load the settings: ${e.message??String(e)}`}))},[]),(0,d.useEffect)(()=>{let t=t=>t.key===`Escape`&&e();return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let g=async(e={})=>{m(!0),f(null);try{let{model:n}=await L.saveSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{},...e});return r(n),l(``),t(n),n}catch(e){return f({ok:!1,text:e.message??String(e)}),null}finally{m(!1)}},[_,v]=(0,d.useState)(!1),y=async(t=!1)=>{if(!t&&(c.trim()||n?.apiKeySet)){m(!0),f(null);let e=!1;try{let t=await L.testSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{}});e=t.ok,t.ok||f({ok:!1,text:t.message})}catch(e){f({ok:!1,text:e.message??String(e)})}finally{m(!1)}if(!e){v(!0);return}}await g()&&e()},b=async()=>{m(!0),f(null);try{let e=await L.testSettings({baseUrl:i,model:o,...c.trim()?{apiKey:c.trim()}:{}});f({ok:e.ok&&e.toolCalls,text:e.message})}catch(e){f({ok:!1,text:e.message??String(e)})}finally{m(!1)}};return(0,K.jsx)(`div`,{className:`backdrop`,onMouseDown:t=>t.target===t.currentTarget&&e(),children:(0,K.jsxs)(`form`,{className:`modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,"data-testid":`settings-dialog`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,K.jsx)(`h2`,{id:`settings-title`,children:`Settings`}),(0,K.jsxs)(`p`,{className:`muted`,children:[`Built-in questions work without a model. To ask anything, connect a model through`,` `,(0,K.jsx)(`a`,{href:`https://openrouter.ai/keys`,target:`_blank`,rel:`noreferrer`,children:`OpenRouter`}),` `,`(or any OpenAI-compatible endpoint) with your own key.`]}),(0,K.jsxs)(`fieldset`,{disabled:!n,className:`plain`,children:[(0,K.jsxs)(`label`,{children:[`Model`,(0,K.jsx)(`input`,{ref:h,"data-testid":`settings-model`,value:o,onChange:e=>s(e.target.value),placeholder:`anthropic/claude-sonnet-5.5`,spellCheck:!1}),(0,K.jsx)(`small`,{className:`muted`,children:`An OpenRouter model id that supports tool calls.`})]}),(0,K.jsxs)(`label`,{children:[`API key`,(0,K.jsx)(`input`,{"data-testid":`settings-key`,type:`password`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),placeholder:n?.apiKeySet?`Saved (…${n.apiKeyHint})${n.keySource===`env`?` from OPENROUTER_API_KEY`:``}`:`sk-or-…`,spellCheck:!1}),(0,K.jsx)(`small`,{className:`muted`,children:`Stored only on this computer, in the veoflow folder (readable by you only). It is never shown again.`})]}),(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{children:`Advanced`}),(0,K.jsxs)(`label`,{children:[`Base URL`,(0,K.jsx)(`input`,{"data-testid":`settings-base-url`,value:i,onChange:e=>a(e.target.value),placeholder:`https://openrouter.ai/api/v1`,spellCheck:!1})]})]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`When a model answers, your question and the graph data it looks up (names, file paths, line numbers) are sent to the provider. Nothing is sent for built-in questions.`}),u&&(0,K.jsx)(`p`,{className:u.ok?`ok`:`error`,role:`status`,"data-testid":`settings-status`,children:u.text}),(0,K.jsxs)(`div`,{className:`buttons`,children:[n?.apiKeySet&&n.keySource===`config`&&(0,K.jsx)(`button`,{type:`button`,className:`danger`,disabled:p,onClick:()=>void g({apiKey:null}),"data-testid":`settings-remove-key`,children:`Remove key`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{type:`button`,disabled:p||!n,onClick:()=>void b(),"data-testid":`settings-test`,children:`Test connection`}),(0,K.jsx)(`button`,{type:`button`,onClick:e,children:`Cancel`}),_&&(0,K.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void y(!0),"data-testid":`settings-save-anyway`,children:`Save anyway`}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:p||!n,"data-testid":`settings-save`,children:`Save`})]})]})})}function VC(e,t){if(t.type===`undo`)return C(e);if(t.type===`redo`)return w(e);if(t.type===`load`)return T(t.view)===T(e.present)?e:{past:[...e.past,e.present],present:t.view,future:[]};let n={name:t.name,...t.args?{args:t.args}:{}};try{return t.type===`reset`?{...e,present:S(x(e.present),n).present}:S(e,n)}catch(t){return console.warn(t),e}}var HC=[{id:`stage1`,name:`Functions & calls`,release:`R1`},{id:`stage2`,name:`Cross-file links`,release:`R2`},{id:`stage3`,name:`APIs & data`,release:`R4`},{id:`stage4`,name:`Runtime`,release:`R11`},{id:`stage5`,name:`Deployment`,release:`R10`}];function UC(){let[e,t]=(0,d.useReducer)(VC,void 0,()=>x(D(location.hash.slice(1)))),n=e.present,r=(0,d.useCallback)((e,n)=>t({type:`command`,name:e,...n?{args:n}:{}}),[]),[i,a]=(0,d.useState)([]),o=(0,d.useRef)(!0),[s,c]=(0,d.useState)(!1),[l,f]=(0,d.useState)([]),[p,m]=(0,d.useState)({}),[h,g]=(0,d.useState)(null),[_,y]=(0,d.useState)(null),[b,S]=(0,d.useState)(`file`),[C,w]=(0,d.useState)(``),[E,j]=(0,d.useState)(null),[P,F]=(0,d.useState)(!1),[I,z]=(0,d.useState)(!1),[B,H]=(0,d.useState)(null),[U,W]=(0,d.useState)(null),[G,ee]=(0,d.useState)(null),[ne,re]=(0,d.useState)([]),[q,ie]=(0,d.useState)([]),ae=(0,d.useMemo)(()=>new Set(q.flatMap(e=>[...e.changed,...e.removed].map(t=>`${e.sourceId}:${t}`))),[q]),[oe,se]=(0,d.useState)(`pending`),le=(0,d.useRef)(!1);le.current=oe===`running`;let[ue,de]=(0,d.useState)(``),[fe,pe]=(0,d.useState)(``),[me,he]=(0,d.useState)(``),[ge,_e]=(0,d.useState)(!1),[ye,be]=(0,d.useState)(null),[xe,Se]=(0,d.useState)(null),[Ce,we]=(0,d.useState)(null),[Te,Ee]=(0,d.useReducer)(e=>e+1,0);N(n.run);let De=(0,d.useRef)(!0);(0,d.useEffect)(()=>{if(De.current){De.current=!1;return}Ee()},[n.run]);let Oe=(0,d.useRef)(n);Oe.current=n,(0,d.useEffect)(()=>{let e=e=>{let{run:n,reason:r}=e.detail??{};Oe.current.run&&n===Oe.current.run&&(t({type:`reset`,name:`openRun`,args:{}}),he(r===`history`?`That run is older than the 30 days of history this license shows, so the latest analysis is shown.`:`That run is no longer available (a newer draft or analysis replaced it), so the latest analysis is shown.`))};return window.addEventListener(`veo-run-gone`,e),()=>window.removeEventListener(`veo-run-gone`,e)},[]);let ke=n.run??B,Ae=Rx(n.project,n.compare,Te),je=(0,d.useMemo)(()=>ve(Ae.data),[Ae.data]),{groups:Me}=Dx(n.project,ke,0,n.source),Ne=(0,d.useCallback)((e,t)=>r(`select`,{kind:`function`,id:e,file:t}),[r]),Pe=(0,d.useCallback)(e=>{let t=e.file,i=e=>n.tab!==e&&r(`showTab`,{tab:e});if(e.change===`removed`){t&&e.type!==`File`&&je?.fileFacts.get(t)!==`removed`&&(i(`file`),r(`openFile`,{file:t}));return}switch(e.type){case`Function`:if(t)return r(`select`,{kind:`function`,id:e.id,file:t});break;case`CALLS`:case`CALLS_CROSS_FILE`:if(t)return r(`select`,{kind:`call`,id:e.id,file:t});break;case`UnresolvedCallSite`:if(t)return r(`select`,{kind:`site`,id:e.id,file:t});break;case`IMPORTS`:case`UnresolvedImport`:if(t)return r(`openImportsFile`,{file:t,pick:e.id});break;case`Group`:return i(`imports`),r(`openGroup`,{group:e.id});case`DEPENDS_ON`:return i(`imports`),r(`openGroup`,{group:String(e.fact.from)})}t&&(i(`file`),r(`openFile`,{file:t}))},[r,n.tab,je]),[Fe,Ie]=(0,d.useState)(null),[Le,Re]=(0,d.useState)(null),ze=(0,d.useRef)(n.project);ze.current=n.project;let Be=(0,d.useRef)(n.file);Be.current=n.file;let Ve=(0,d.useRef)(n.source);Ve.current=n.source;let[He,Ue]=(0,d.useState)(!1),[We,Ge]=(0,d.useState)([]),[Ke,J]=(0,d.useState)([]),[qe,Je]=(0,d.useState)(null),[Ye,Xe]=(0,d.useState)(!1),[Y,Ze]=(0,d.useState)(!1),[Qe,$e]=(0,d.useState)(0),et=(0,d.useRef)(null),tt=(0,d.useRef)(null),[nt,rt]=(0,d.useState)(!1),[it,at]=(0,d.useState)(null);(0,d.useEffect)(()=>{if($e(0),!He)return;let e=Date.now(),t=setInterval(()=>$e(Math.round((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[He,Le]),(0,d.useEffect)(()=>{L.settings().then(e=>Je(e.model),()=>void 0)},[]);let ot=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=`#${T(n)}`,t=JSON.stringify([n.project,n.file,n.selection,n.tab,n.group,n.fileLevel]);if(location.hash!==e){let r=T(D(location.hash.slice(1)))===T(n);ot.current!==null&&ot.current!==t&&!r?window.history.pushState(null,``,e):window.history.replaceState(null,``,e)}ot.current=t},[n]),(0,d.useEffect)(()=>{let e=()=>t({type:`load`,view:D(location.hash.slice(1))});return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]),(0,d.useEffect)(()=>{let e=!1;return L.projects(!n.project).then(({projects:r})=>{if(e)return;a(r),c(!0);let i=r.some(e=>e.id===n.project);n.project&&!i&&pe(`Project ${n.project} was not found.`),(o.current&&!n.project||n.project&&!i)&&t(r.length===1?{type:`reset`,name:`selectProject`,args:{project:r[0].id}}:{type:`reset`,name:`goHome`,args:{}}),o.current=!1},t=>!e&&pe(t.message)),()=>{e=!0}},[Te,n.project===null]),(0,d.useEffect)(()=>{if(!n.project)return J([]);let e=!1;return L.suggestions(n.project).then(t=>!e&&J(t.suggestions),()=>!e&&J([])),()=>{e=!0}},[n.project,Te]),(0,d.useEffect)(()=>{f([]),m({}),Ie(null),Ue(!1),Re(null),bt.current++,de(``),j(null),F(!1),z(!1),H(null),se(`pending`),W(null),ee(null),re([]),ie([])},[n.project]),(0,d.useEffect)(()=>{if(!n.project){f([]);return}let e=!1,t=n.project;return L.files(t).then(t=>{e||(f(t.files),z(!0))},()=>{e||(f([]),z(!0))}),L.fileCounts(t).then(t=>!e&&m(t.counts),()=>!e&&m({})),L.status(t).then(t=>{e||(j(t.latest),W(t.draft??null),ee(t.debug??null),H(t.committedRun),F(!0),se(t.runInProgress?`running`:t.latest?.status===`failed`?`failed`:t.latest?`done`:`pending`))},()=>void 0),()=>{e=!0}},[n.project,Te]),(0,d.useEffect)(()=>{if(ie([]),!n.project||B===null)return;let e=n.project,t=!1,r=()=>!le.current&&void L.stale(e).then(e=>!t&&ie(e.committedRun===B?e.sources:[]),()=>void 0);return r(),window.addEventListener(`focus`,r),()=>{t=!0,window.removeEventListener(`focus`,r)}},[n.project,B]);let st=b===`file`?n.file:null,[ct,lt]=(0,d.useState)([]),ut=(0,d.useMemo)(()=>n.file&&(n.tab===`file`||n.fileLevel)?{kind:`file`,file:n.file}:n.tab===`imports`&&n.group?{kind:`group`,group:n.group}:n.source?{kind:`source`,source:n.source,name:ct.find(e=>e.id===n.source)?.name}:null,[n.file,n.tab,n.fileLevel,n.group,n.source,ct]);(0,d.useEffect)(()=>{if(!n.project)return lt([]);let e=!1;return L.sources(n.project).then(t=>!e&<(t.sources.map(e=>({...e,optIn:e.optIn??[]}))),()=>void 0),()=>{e=!0}},[n.project,Te]),(0,d.useEffect)(()=>{n.source&&ct.length>0&&!ct.some(e=>e.id===n.source)&&t({type:`reset`,name:`scopeSource`,args:{}})},[n.source,ct]);let{data:dt}=Nx(n.project,ke,b===`project`?null:ut,[],Te),ft=dt?dt.counts.broken+dt.counts.notAnalyzed+dt.counts.openCalls:null,[pt,mt]=(0,d.useState)(null),ht=(0,d.useRef)(``);(0,d.useEffect)(()=>{let e=`${n.project??``}|${st??``}`;if(ht.current!==e&&y(null),ht.current=e,!n.project)return;let t=!1;return L.unresolved(n.project,st??void 0).then(e=>!t&&y(e.sites),()=>!t&&y([])),()=>{t=!0}},[n.project,st,Te]);let gt=(0,d.useRef)(null);(0,d.useEffect)(()=>{if(!n.project||!n.file){g(null);return}n.file!==gt.current&&he(``),gt.current=n.file,g(e=>e&&e.file.id===n.file?e:null),rt(!1);let e=!1,r=n.file;return L.fileGraph(n.project,r).then(t=>!e&&g(t),r=>{e||M(r)||(g(null),he(n.run===null?`That file wasn't in the latest analysis, so the project overview is shown instead.`:`That file isn't in run ${n.run}, so the project overview is shown instead.`),t({type:`reset`,name:`selectProject`,args:{project:n.project}}))}),()=>{e=!0}},[n.project,n.file,Te]),(0,d.useEffect)(()=>R(Ee,e=>{if(!n.project){(e.type===`run.started`||e.type===`run.committed`||e.type===`run.failed`)&&Ee();return}e.projectId===n.project&&(e.type===`run.started`?(se(`running`),de(`Analyzing…`)):e.type===`stage.completed`?de(`Analyzing…`):e.type===`run.committed`?(ie([]),se(`done`),de(`Analyzed just now`),Ee()):e.type===`run.failed`&&(se(`failed`),de(`Analysis failed: ${String(e.error)}`),Ee()))}),[n.project]),(0,d.useEffect)(()=>{let e=e=>{let n=e.target;if(!document.querySelector(`[role="dialog"], [role="menu"]`)&&!n.closest(`input:not([type="checkbox"]):not([type="radio"]), textarea, select, [contenteditable], [role=dialog]`)){if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`z`){e.preventDefault(),t({type:e.shiftKey?`redo`:`undo`});return}e.metaKey||e.ctrlKey||e.altKey||(e.key===`Escape`?r(`clearSelection`):e.key===`u`&&r(`toggleUnresolved`))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let _t=(0,d.useCallback)(e=>r(`select`,e),[r]),vt=(0,d.useCallback)(()=>r(`clearSelection`),[r]),yt=async(e,t)=>{if(w(``),!aw(e)){w(`Enter an absolute path (for example /Users/you/app), not "${e}"`);return}let i=t?ye??n.project:null;try{k(`addFolder`,{root:e}),i||(i=(await L.createProject(e.split(/[\\/]/).filter(Boolean).pop()??`project`,e)).project.id,r(`selectProject`,{project:i})),await L.addSource(i,e)}catch(e){w(e.message??String(e));return}_e(!1),be(null),w(``),se(`running`);try{await L.analyze(i)}catch(e){pe(e.message??String(e))}Ee()},bt=(0,d.useRef)(0),xt=(0,d.useRef)(null),St=async(e,i)=>{if(!n.project)return;k(`ask`,{question:e});let a=++bt.current,o=n.project;xt.current?.abort();let s=new AbortController;xt.current=s,t({type:`reset`,name:`showPanel`,args:{panel:`answer`}}),Ue(!0),Re(e),Ge(t=>[e,...t.filter(t=>t!==e)].slice(0,5));let c;try{c=await L.ask(o,e,i,Be.current,s.signal,Ve.current)}catch(t){let n=t;c={question:e,via:`help`,...i?{mode:i}:{},summary:`Could not answer: ${n.message??String(t)}`,results:[],toolCalls:[],error:{code:n.code??`error`,message:n.message??String(t)}}}if(a!==bt.current||ze.current!==o)return;let l=c.results[0];l?.kind===`function`&&l.file===Be.current&&(c.intent===`callers`||c.intent===`callees`||c.intent===`definition`)&&(r(`select`,{kind:`function`,id:l.id,file:l.file}),t({type:`reset`,name:`showPanel`,args:{panel:`answer`}})),Ie(c),Ue(!1),Re(null)},Ct=e=>{for(let t of A(e))r(t.name,t.args);t({type:`reset`,name:`showPanel`,args:{panel:`answer`}})},wt=()=>{xt.current?.abort(),bt.current++,Ue(!1),Re(null)},X=()=>{n.project&&(k(`analyzeDraft`),pe(``),de(`Analyzing your uncommitted edits as a draft…`),L.analyzeDraft(n.project).catch(e=>{pe(e.message),Ee()}))},Tt=e=>{n.project&&(k(`analyzeDebug`,{until:e}),pe(``),de(`Debug run: analyzing up to ${e}…`),L.analyzeDebug(n.project,e).catch(e=>{pe(e.message),Ee()}))};(0,d.useEffect)(()=>{if(!n.project)return;let e=!1;return L.stages(n.project).then(t=>!e&&re(t.pipeline),()=>!e&&re([])),()=>{e=!0}},[n.project]);let[Et,Dt]=(0,d.useState)(null),Ot=(0,d.useCallback)(()=>Dt(null),[]),kt=e=>{let t=e=>e.slice(0,e.indexOf(`:`)),i=e=>decodeURIComponent(e.slice(e.indexOf(`:`)+1)),a=e=>e.slice(0,e.indexOf(`:`,e.indexOf(`:`)+1)),o=(e,t)=>({label:`Leave it out of analysis…`,command:`chooseFiles`,run:()=>we({source:e,...t?{path:t}:{}})}),s=e=>({label:`Re-analyze its repository`,command:`analyzeSource`,run:()=>void At(e)}),c=e=>({label:`Broken imports in it`,command:`showPanel`,run:()=>{e(),mt(`broken`),r(`showPanel`,{panel:`questions`})}});if(e.kind===`group`){let[,t=``,i=``]=e.id.split(`|`);return{title:String(e.data.label??e.id).split(`
|