PageSourceSearch

https://vickylabs.ai/assets/swimlanes-42K2YHIH-NYiWTkix.js

js vickylabs.ai collected 2026-10-05 15:27:05 UTC 117,231 bytes, 1 lines download raw bytes

1import{_ as f,a9 as Tr,ak as No,l as Ln}from"./mermaid.core-BnCCVoFs.js";import"./transform-BGiA1A9E.js";import"./index-CHAiQmwl.js";import"./step-C7Mx1GPw.js";import"./string-dheu8l3x.js";var Oo=5,ze=1e-5,Ve=1e-6;function Je(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}f(Je,"buildSegmentList");function Do(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=o.x-n.x,d=o.y-n.y,l=s*d-r*c;if(l===0)return null;const a=n.x-t.x,h=n.y-t.y,m=(a*d-h*c)/l,M=(a*r-h*s)/l;return m<=Ve||m>=1-Ve||M<=Ve||M>=1-Ve?null:{point:{x:t.x+m*s,y:t.y+m*r},tA:m,tB:M}}f(Do,"segmentIntersection");function En(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}f(En,"isHorizontalSeg");function Ho(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=Je(o.points);for(let r=n+1;r<t.length;r++){const c=t[r],d=Je(c.points);for(const[l,a]of s.entries())for(const[h,m]of d.entries()){const M=Do(a.a,a.b,m.a,m.b);if(!M)continue;const p=En(a),u=En(m);(p!==u?p:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:c.id,segIndex:l,t:M.tA,point:M.point}):e.push({jumpEdgeId:c.id,otherEdgeId:o.id,segIndex:h,t:M.tB,point:M.point})}}}return e}f(Ho,"findEdgeIntersections");function le(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}f(le,"fmt");function Oe(t){return`${le(t.x)},${le(t.y)}`}f(Oe,"pointToString");function Xo(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}f(Xo,"getArcSweepFlag");var Ar=.001;function Yo(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&No[e.arrowTypeStart];if(o){const r=t[0],c=t[1],d=Math.atan2(c.y-r.y,c.x-r.x);n[0].x=r.x+o*Math.cos(d),n[0].y=r.y+o*Math.sin(d)}const s=e.arrowTypeEnd&&No[e.arrowTypeEnd];if(s){const r=t.length,c=t[r-2],d=t[r-1],l=Math.atan2(d.y-c.y,d.x-c.x);n[r-1].x=d.x-s*Math.cos(l),n[r-1].y=d.y-s*Math.sin(l)}return n}f(Yo,"applyMarkerOffsets");function Go(t,e,n,o,s){const r=t.point.x,c=t.point.y,d={x:r-e*t.r,y:c-n*t.r},l={x:r+e*t.r,y:c+n*t.r},a=[`L${Oe(d)}`];return s==="arc"?a.push(`A${le(t.r)},${le(t.r)} 0 0 ${o} ${Oe(l)}`):a.push(`M${Oe(l)}`),a}f(Go,"emitJump");function Tn(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=n.x-e.x,d=n.y-e.y,l=Math.hypot(s,r),a=Math.hypot(c,d);if(l<ze||a<ze)return null;const h=s/l,m=r/l,M=c/a,p=d/a,u=h*M+m*p,i=Math.max(-1,Math.min(1,u)),y=Math.acos(i);if(y<ze||Math.abs(Math.PI-y)<ze)return null;const C=Math.min(o/Math.sin(y/2),l/2,a/2);return{startX:e.x-h*C,startY:e.y-m*C,endX:e.x+M*C,endY:e.y+p*C,ctrlX:e.x,ctrlY:e.y,cutLen:C}}f(Tn,"computeRoundedCorner");function $o(t,e,n){const o=t.points;if(o.length<2)return"";const s=Yo(o,t),r=t.curve==="rounded",c=Je(s),d=new Map;for(const a of e){const h=c[a.segIndex];if(!h)continue;const m=Math.hypot(h.b.x-h.a.x,h.b.y-h.a.y),M=d.get(a.segIndex)??[];M.push({t:a.t,point:a.point,d:a.t*m,r:n.jumpRadius}),d.set(a.segIndex,M)}const l=[`M${Oe(s[0])}`];for(let a=0;a<c.length;a++){const h=c[a],m=Math.hypot(h.b.x-h.a.x,h.b.y-h.a.y),M=m===0?0:(h.b.x-h.a.x)/m,p=m===0?0:(h.b.y-h.a.y)/m,u=Xo(h);let i=0;if(r&&a>0){const S=Tn(s[a-1],s[a],s[a+1]??s[a],Oo);S&&(i=S.cutLen)}let y=m,C=null;r&&a<c.length-1&&(C=Tn(s[a],s[a+1],s[a+2]??s[a+1],Oo),C&&(y=m-C.cutLen));const b=[...d.get(a)??[]].sort((S,w)=>S.t-w.t);for(const S of b)S.r=Math.min(S.r,S.d-i,y-S.d);for(let S=0;S<b.length-1;S++){const w=b[S+1].d-b[S].d;if(b[S].r+b[S+1].r>w){const I=w/2;b[S].r=Math.min(b[S].r,I),b[S+1].r=Math.min(b[S+1].r,I)}}for(const S of b)S.r<Ar||l.push(...Go(S,M,p,u,n.jumpStyle));r&&C?(l.push(`L${le(C.startX)},${le(C.startY)}`),l.push(`Q${le(C.ctrlX)},${le(C.ctrlY)} ${le(C.endX)},${le(C.endY)}`)):l.push(`L${Oe(h.b)}`)}return l.join(" ")}f($o,"rewriteEdgePath");function zo(t){return/^[\d\s+,.LMelm-]*$/.test(t)}f(zo,"isStraightPath");function Vo(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}f(Vo,"curveSupportsLineHops");function Uo(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}f(Uo,"decodeDataPoints");function jo(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const a of e)s.set(a.id,a);const r=[],c=new Map;for(const a of e){const h=typeof CSS<"u"&&CSS.escape?CSS.escape(a.id):a.id,m=o.querySelector(`path[data-id="${h}"]`);if(!m)continue;c.set(a.id,m);const p=Uo(m.getAttribute("data-points"))??a.points;r.push({...a,points:p})}const d=Ho(r);if(d.length===0)return;const l=new Map;for(const a of d){const h=l.get(a.jumpEdgeId)??[];h.push(a),l.set(a.jumpEdgeId,h)}for(const a of r){const h=l.get(a.id);if(!h||h.length===0)continue;const m=s.get(a.id),M=m==null?void 0:m.curve;if(M!==void 0&&!Vo(M))continue;const p=c.get(a.id);if(!p)continue;if(M===void 0){const S=p.getAttribute("d")??"";if(!zo(S))continue}const u=p.getAttribute("style")??"",i=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(u),y=i?Number.parseFloat(i[1]):null,C=i?Number.parseFloat(i[2]):null,b=$o(a,h,n);if(p.setAttribute("d",b),y!==null&&C!==null&&typeof p.getTotalLength=="function"){const S=p.getTotalLength(),w=Math.max(0,S-y-C),I=`0 ${y} ${w} ${C}`,x=u.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${I};`).replace(/;\s*;+/g,";");p.setAttribute("style",x)}}}f(jo,"applyLineJumpsToSvg");function Wo(t,{measure:e}){var r,c;const n=(c=(r=t.config)==null?void 0:r.swimlane)==null?void 0:c.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(d=>Array.isArray(d.points)&&d.points.length>=2).map(d=>({id:d.id,points:d.points,curve:d.curve,arrowTypeStart:d.arrowTypeStart,arrowTypeEnd:d.arrowTypeEnd}));jo(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}f(Wo,"applySwimlaneLineJumps");var In="__swimlane_default__",wr=21,Bo=20;function An(t){return Math.max(t.padding??Bo,Bo)}f(An,"topLaneHorizontalPadding");function Ko(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const c=n-s/2,d=Math.min(r,n+s/2),l=Math.min(wr,Math.max(0,d-c)),a=c+l;if(a<=c){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:c,bottom:a}}f(Ko,"assignTopLaneTitleRect");function qo(t){const e=t.direction,n=t.nodes??(t.nodes=[]);for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===In);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:In,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=In}f(qo,"prepareLayoutForSwimlanes");function Jo(t){const e=new Map;for(const l of t.nodes??[])e.set(l.id,l);const n=[];for(const l of t.edges??[]){const a=typeof l.start=="string"?l.start:void 0,h=typeof l.end=="string"?l.end:void 0;!a||!h||l.labelNodeId||n.push({id:l.id,src:a,dst:h,ref:l})}const o=t.nodes??[],s=o.filter(l=>l.isGroup),r=o.filter(l=>!l.isGroup);return{nodes:[...[...s].reverse(),...r].map(l=>l.id),edges:n,layout:t,nodeById:e}}f(Jo,"toGraphView");function Zo(t,e,n,o){const{layout:s}=t,r=t.nodeById,c=(o==null?void 0:o.layerGap)??100,d=(o==null?void 0:o.nodeGap)??40;let l=0;for(const M of e.layers){let p=0;for(const u of M){const i=r.get(u);if(!i){p++;continue}i.layer=l,i.order=p;const y=n.x[u]??p*d,C=n.y[u]??l*c;i.x=y,i.y=C,p++}l++}const a=s.nodes??[],h=new Map,m=[];for(const M of a){if(!(M!=null&&M.isGroup))continue;M.parentId||m.push(M);const p=a.filter(b=>b.parentId===M.id);let u=1/0,i=-1/0,y=1/0,C=-1/0;for(const b of p){const S=b.x??n.x[b.id],w=b.y??n.y[b.id],I=b.width??0,x=b.height??0;S!=null&&w!=null&&(u=Math.min(u,S-I/2),i=Math.max(i,S+I/2),y=Math.min(y,w-x/2),C=Math.max(C,w+x/2))}if(u===1/0||y===1/0)M.x=M.x??0,M.y=M.y??0,M.width=M.width??0,M.height=M.height??0;else{const b=M.padding??20,S=M.parentId?b:2*An(M),w=b,I=Math.max(0,i-u)+S,x=Math.max(0,C-y)+w,L=(u+i)/2,R=(y+C)/2;M.x=L,M.y=R,M.width=I,M.height=x,h.set(M.id,{minX:u,maxX:i,minY:y,maxY:C}
1)}}if(m.length>0&&h.size>0){let M=1/0,p=-1/0,u=0;for(const i of m){const y=i.padding??20;y>u&&(u=y);const C=h.get(i.id);C&&(M=Math.min(M,C.minY),p=Math.max(p,C.maxY))}if(M!==1/0&&p!==-1/0){const i=Math.max(0,p-M),C=Math.max(u,36),b=i+2*C,S=(M+p)/2;for(const F of m)F.y=S,F.height=b,F.swimlaneContentTop=M;const w=[...m].sort((F,A)=>{const P=F.x??0,k=A.x??0;return P-k}),I=[],x=[],L=[];for(const F of w){const A=h.get(F.id);if(!A)continue;const P=Math.max(0,A.maxX-A.minX)+2*An(F),k=(A.minX+A.maxX)/2;I.push(F.id),x.push(k),L.push(P)}const R=I.length;if(R>0){const F=new Map;if(R===1)F.set(I[0],L[0]);else{const A=[];for(let G=0;G<R-1;G++)A.push(x[G+1]-x[G]);const P=new Array(R);P[0]=0;for(let G=0;G<R-1;G++)P[G+1]=2*A[G]-P[G];let k=0,B=Number.POSITIVE_INFINITY;for(let G=0;G<R;G++){const Z=L[G];G%2===0?k=Math.max(k,Z-P[G]):B=Math.min(B,P[G]-Z)}let X=k;k<=B?X=(k+B)/2:X=k;for(let G=0;G<R;G++){const Z=P[G]+(G%2===0?X:-X),ct=Math.max(L[G],Z);F.set(I[G],ct)}}for(const A of m){const P=F.get(A.id);P!=null&&(A.width=P),Ko(A)}}}}}f(Zo,"writeBackToLayoutData");var Rr="[EdgeLabelNodes]";function Qo(t){const e=[],n=[],o=new Map;for(const c of t.nodes)o.set(c.id,c);for(const c of t.edges){if(!c.label||c.label.length===0||c.isLayoutOnly||c.labelNodeId)continue;const d=c.start?o.get(c.start):void 0,l=c.end?o.get(c.end):void 0;if(!d||!l){Ln.warn(Rr,`Edge ${c.id} has missing source or target node`);continue}const a=`edge-label-${c.start}-${c.end}-${c.id}`,m=d.parentId!==l.parentId?l.parentId:d.parentId,M={id:a,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:m,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...d.dir?{dir:d.dir}:{}};e.push(M),c.labelNodeId=a,c.label=void 0,c.text=void 0;const p={id:`${c.id}-to-label`,start:c.start,end:a,type:"normal",isLayoutOnly:!0},u={id:`${c.id}-from-label`,start:a,end:c.end,type:"normal",isLayoutOnly:!0};n.push(p,u)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}f(Qo,"createEdgeLabelNodes");var Yt=.001;function ro(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:Be(e,n,o,s)}:void 0}f(ro,"measuredNodeRect");function io(t){if(t.isGroup)return;const e=ro(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}f(io,"nodeBoundsInfoFor");function ce(t,e,n=Yt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}f(ce,"samePoint");function gt(t,e,n=Yt){return Math.abs(t.x-e.x)<n}f(gt,"sameX");function yt(t,e,n=Yt){return Math.abs(t.y-e.y)<n}f(yt,"sameY");function Nt(t,e,n=Yt){return yt(t,e,n)&&Math.abs(t.x-e.x)>n}f(Nt,"isHorizontalSegment");function Ot(t,e,n=Yt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}f(Ot,"isVerticalSegment");function Wt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}f(Wt,"overlapLength");function de(t,e,n=Yt){return t.horizontal&&e.horizontal&&yt(t.a,e.a,n)?Wt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&gt(t.a,e.a,n)?Wt(t.a.y,t.b.y,e.a.y,e.b.y):0}f(de,"sameAxisSegmentOverlapLength");function Fe(t,e=Yt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],c=Nt(s,r,e),d=Ot(s,r,e);(c||d)&&n.push({index:o,a:s,b:r,horizontal:c,vertical:d})}return n}f(Fe,"orthogonalSegmentsForPoints");function oe(t,e=Yt){const n=Fe(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}f(oe,"countOrthogonalBends");function xt(t,e=Yt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ce(s,o,e))&&n.push({x:o.x,y:o.y})}return n}f(xt,"dedupeConsecutivePoints");function co(t,e=Yt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Nt(n,o,e)&&Ot(o,s,e)&&Nt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&Nt(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}f(co,"classifyThreeSegmentRoute");function an(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),c=Math.min(t.y,e.y),d=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&d>n.top-o&&c<n.bottom+o}f(an,"segmentBoundsOverlapRect");function ao(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}f(ao,"pointInsideRect");function ts(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}f(ts,"rectContainsRect");function Ze(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}f(Ze,"rectsOverlap");function wn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}f(wn,"inflateRect");function Be(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}f(Be,"rectFromCenterSize");function te(t){var e;return(e=ro(t))==null?void 0:e.rect}f(te,"rectOfNodeBounds");
1function Le(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}f(Le,"portForRectSide");function lo(t,e,n,o,s,r=Yt){const c=e==="left"||e==="right",d=o==="left"||o==="right";if(c&&d){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(yt(t,n,r))return[t,n];const m=(t.x+n.x)/2;return[t,{x:m,y:t.y},{x:m,y:n.y},n]}if(e===o){if(yt(t,n,r))return;const m=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:m,y:t.y},{x:m,y:n.y},n]}return}if(!c&&!d){if(e===o){if(gt(t,n,r))return;const M=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:M},{x:n.x,y:M},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const m=(t.y+n.y)/2;return[t,{x:t.x,y:m},{x:n.x,y:m},n]}if(c&&!d){const h=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,m=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return h&&m?[t,{x:n.x,y:t.y},n]:void 0}const l=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,a=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return l&&a?[t,{x:t.x,y:n.y},n]:void 0}f(lo,"buildOrthogonalPortPath");function fo(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}f(fo,"buildSameSideTrackPath");function ln(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=io(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}f(ln,"collectRealNodeBounds");function Me(t){const e=[],n=[];for(const o of t){const s=io(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}f(Me,"collectNodeRectEntries");function es(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,c=o.width??0,d=o.height??0;n.push({nodeId:o.id,...Be(s,r,c,d)})}return n}f(es,"collectLayoutNodeRects");function uo(t,e,n=Yt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),c=e.get(s);if(!(!r||!c))return{srcId:o,dstId:s,srcInfo:r,dstInfo:c,collinearX:Math.abs(r.cx-c.cx)<n,collinearY:Math.abs(r.cy-c.cy)<n}}f(uo,"getNodePairGeometry");function Bt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&an(t,e,r.rect,-s))return!0;return!1}f(Bt,"segmentHitsAnyRect");function ho(t,e,n,o,s=Yt,r=1e-6){const c=yt(t,e,s),d=gt(t,e,s),l=yt(n,o,s),a=gt(n,o,s);if(c&&l||d&&a||!(c||d)||!(l||a))return!1;const h=c?{a:t,b:e}:{a:n,b:o},m=d?{a:t,b:e}:{a:n,b:o},M=h.a.y,p=Math.min(h.a.x,h.b.x),u=Math.max(h.a.x,h.b.x),i=m.a.x,y=Math.min(m.a.y,m.b.y),C=Math.max(m.a.y,m.b.y);if(i<p||i>u||M<y||M>C)return!1;const b=Math.abs(i-h.a.x)<r&&Math.abs(M-h.a.y)<r||Math.abs(i-h.b.x)<r&&Math.abs(M-h.b.y)<r,S=Math.abs(i-m.a.x)<r&&Math.abs(M-m.a.y)<r||Math.abs(i-m.b.x)<r&&Math.abs(M-m.b.y)<r;return!(b&&S)}f(ho,"orthogonalSegmentsCross");function ns(t,e,n,o,s=Yt){const r=yt(t,e,s),c=gt(t,e,s),d=yt(n,o,s),l=gt(n,o,s);return c&&l&&gt(t,n,s)?Wt(t.y,e.y,n.y,o.y)>s:r&&d&&yt(t,n,s)?Wt(t.x,e.x,n.x,o.x)>s:!1}f(ns,"sameAxisSegmentsOverlap");function Qe(t,e,n,o,{epsilon:s=Yt,skipDegenerateOther:r=!1}={}){for(const c of n){if(c===o||c.isLayoutOnly)continue;const d=c.points;if(!(!d||d.length<2))for(let l=0;l<d.length-1;l++){const a=d[l],h=d[l+1];if(!(r&&ce(a,h,s))&&(ho(t,e,a,h,s)||ns(t,e,a,h,s)))return!0}}return!1}f(Qe,"segmentConflictsWithAnyEdge");function he(t,e,n,o,s=Yt){const r=yt(t,e,s),c=gt(t,e,s),d=yt(n,o,s),l=gt(n,o,s);if(!(r&&l||c&&d))return!1;const a=r?{a:t,b:e}:{a:n,b:o},h=r?{a:n,b:o}:{a:t,b:e},m=a.a.y,M=Math.min(a.a.x,a.b.x),p=Math.max(a.a.x,a.b.x),u=h.a.x,i=Math.min(h.a.y,h.b.y),y=Math.max(h.a.y,h.b.y);return u>M+s&&u<p-s&&m>i+s&&m<y-s}f(he,"orthogonalSegmentsStrictlyCross");function Rn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Yt&&t<s-Yt}f(Rn,"strictlyBetween");function os(t,e,n){return gt(t,e)&&gt(e,n)?Rn(e.y,t.y,n.y):yt(t,e)&&yt(e,n)?Rn(e.x,t.x,n.x):!1}f(os,"isCollinearIntermediate");function ss(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],c=o+1<t.length?t[o+1]:void 0;if(s&&c){if(ce(s,c)){o++,e=!0;continue}if(os(s,r,c)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}f(ss,"simplifyPolylineOnce");function tn(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!yt(s,r)){const c=e.length>=2?e[e.length-2]:void 0,l=(c?gt(c,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(l)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ce(s,o))&&n.push(o)}return n}f(tn,"orthogonalizePolyline");function ue(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=ss(e);if(e=o.points,!o.changed)break}return e}f(ue,"simplifyPolyline");var it=.001,Nr=.5,Fo=4;function go(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?te(s):void 0,dstRect:r?te(r):void 0}}f(go,"endpointContextFor");function rs(t,e,n){if(yt(t,e,it))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,it)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}f(rs,"segmentEnterPoint");function Nn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&ao(t[s],e,Nr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const c=rs(t[s],t[r],e);return n?[c,...t.slice(s)]:[...t.slice(0,s+1),c]}f(Nn,"clipEndpoint");function is(t,e){for(const n of t){const o=go(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Nn(s,o.srcRect,!0)),o.dstRect&&(s=Nn(s,o.dstRect,!1)),s=ue(tn(s)),s=mo(s,o.srcRect,o.dstRect),o.edge.points=ue(tn(s))}}f(is,"clipEdgeEndpointsToNodeBoundaries");function On(t,e,n,o=!1){if(yt(t,e,it)){if(e.y<n.top-it||e.y>n.bottom+it)return e;if(o){if(t.x<n.left-it)return{x:n.left,y:t.y};if(t.x>n.right+it)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,it)){if(e.x<n.left-it||e.x>n.right+it)return e;if(o){if(t.y<n.top-it)return{x:t.x,y:n.top};if(t.y>n.bottom+it)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}f(On,"snapEndpointToBoundary");function en(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ce(r,o,it))return r}return t[e+n]}f(en,"firstDistinctAdjacent");function nn(t,e){const n=t+Fo,o=e-Fo;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}f(nn,"cornerClearanceRange");function Bn(t,e,n){const{lo:o,hi:s}=nn(e,n);return Math.min(s,Math.max(o,t))}f(Bn,"clampToCornerClearance");function cs(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}f(cs,"intersectRanges");function Fn(t,e){return e==="left"||e==="right"?nn(t.top,t.bottom):nn(t.left,t.right)}f(Fn,"clearanceRangeForSide");function on(t,e,n){const o=t.y>=n.top-it&&t.y<=n.bottom+it,s=t.x>=n.left-it&&t.x<=n.right+it;if(yt(t,e,it)&&o){if(Math.abs(t.x-n.left)<it)return"left";if(Math.abs(t.x-n.right)<it)return"right"}
1if(gt(t,e,it)&&s){if(Math.abs(t.y-n.top)<it)return"top";if(Math.abs(t.y-n.bottom)<it)return"bottom"}}f(on,"terminalSideForSegment");function ke(t){return t==="left"||t==="right"}f(ke,"isHorizontalSide");function as(t,e,n,o,s){const r=[],c=n?on(t,e,n):void 0,d=o?on(e,t,o):void 0;return n&&c&&ke(c)===s&&r.push(Fn(n,c)),o&&d&&ke(d)===s&&r.push(Fn(o,d)),r.length>0?cs(r):void 0}f(as,"straightClearanceRange");function Pn(t,e,n,o,s){const r=as(t,e,n,o,s);if(!r)return;const c=s?t.y:t.x,d=Math.min(r.hi,Math.max(r.lo,c));if(!(Math.abs(d-c)<it))return s?[{x:t.x,y:d},{x:e.x,y:d}]:[{x:d,y:t.y},{x:d,y:e.y}]}f(Pn,"clearStraightEndpointCornerAxis");function mo(t,e,n){if(t.length!==2)return t;const[o,s]=t;return yt(o,s,it)?Pn(o,s,e,n,!0)??t:gt(o,s,it)?Pn(o,s,e,n,!1)??t:t}f(mo,"clearStraightEndpointCornerConnections");function ls(t,e,n){return ke(n)?{x:t.x,y:Bn(t.y,e.top,e.bottom)}:{x:Bn(t.x,e.left,e.right),y:t.y}}f(ls,"cornerClearedEndpoint");function fs(t,e,n,o,s,r){const c=t.map(d=>({...d}));for(let d=e;d>=0&&d<t.length;d+=n){const l=t[d];if(r&&!yt(l,o,it)||!r&&!gt(l,o,it))break;r?c[d].y=s.y:c[d].x=s.x}return c}f(fs,"moveCollinearEndpointRun");function kn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],c=en(t,o,s);if(!c)return t;const d=on(r,c,e);if(!d)return t;const l=ke(d),a=ls(r,e,d);return ce(r,a,it)?t:fs(t,o,s,r,a,l)}f(kn,"clearEndpointCornerConnection");function _n(t,e,n){const o=Math.min(t.x,e.x)>=n.left-it&&Math.max(t.x,e.x)<=n.right+it,s=Math.min(t.y,e.y)>=n.top-it&&Math.max(t.y,e.y)<=n.bottom+it;if(Math.abs(t.y-n.top)<it&&Math.abs(e.y-n.top)<it&&o)return"top";if(Math.abs(t.y-n.bottom)<it&&Math.abs(e.y-n.bottom)<it&&o)return"bottom";if(Math.abs(t.x-n.left)<it&&Math.abs(e.x-n.left)<it&&s)return"left";if(Math.abs(t.x-n.right)<it&&Math.abs(e.x-n.right)<it&&s)return"right"}f(_n,"borderSideForSegment");function Dn(t,e,n,o){switch(t){case"top":return gt(e,n,it)&&n.y<o.top-it;case"bottom":return gt(e,n,it)&&n.y>o.bottom+it;case"left":return yt(e,n,it)&&n.x<o.left-it;case"right":return yt(e,n,it)&&n.x>o.right+it}}f(Dn,"leavesOutward");function Hn(t,e,n){if(t.length<3)return t;if(n){const r=_n(t[0],t[1],e);return r&&Dn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=_n(t[o-1],t[o],e);return s&&Dn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}f(Hn,"collapseOwnBorderStub");function ds(t,e,n){let o=t;if(e){const r=en(o,0,1);if(r){const c=On(r,o[0],e);c!==o[0]&&(o=[c,...o.slice(1)])}o=Hn(o,e,!0)}if(n){const r=o.length-1,c=en(o,r,-1);if(c){const d=On(c,o[r],n,!0);d!==o[r]&&(o=[...o.slice(0,r),d])}o=Hn(o,n,!1)}const s=mo(o,e,n);return s!==o||o.length===2?s:(e&&(o=kn(o,e,!0)),n&&(o=kn(o,n,!1)),o)}f(ds,"snapAndCollapseEndpoints");function Xn(t,e){for(const n of t){const o=go(n,e,2);if(!o)continue;const s=xt(o.points,it),r=ds(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const c=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=c}}f(Xn,"prepareEdgeEndpointsForRenderer");function yo(t){return new Map(t.map(e=>[e.id,e]))}f(yo,"buildNodeMap");function us(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}f(us,"resolveTopLevelGroupId");function Yn(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}f(Yn,"groupDepth");function po(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const c=r.x,d=r.y;if(typeof c!="number"||typeof d!="number")continue;const l=r.width??0,a=r.height??0;e=Math.min(e,c-l/2),n=Math.max(n,c+l/2),o=Math.min(o,d-a/2),s=Math.max(s,d+a/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}f(po,"boundsForChildren");function hs(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}f(hs,"applyGroupBounds");function gs(t){const e=yo(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>Yn(s,e)-Yn(o,e));for(const o of n){const s=t.filter(c=>c.parentId===o.id),r=po(s);r&&hs(o,r)}}f(gs,"recomputeNestedGroupBounds");function sn(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(l=>!l.isGroup);let r=1/0,c=-1/0;for(const l of s){const a=l[e];
1typeof a=="number"&&(r=Math.min(r,a),c=Math.max(c,a))}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const d=f(l=>r+c-l,"mirror");for(const l of n){const a=l[e];typeof a=="number"&&(l[e]=d(a));const h=l.groupTitleRect;h&&(l.groupTitleRect=e==="x"?{...h,left:d(h.right),right:d(h.left)}:{...h,top:d(h.bottom),bottom:d(h.top)})}for(const l of o)for(const a of l.points??[])a[e]=d(a[e]);return!0}f(sn,"mirrorAxis");function ms(t){return(t.nodes??[]).some(n=>!n.isGroup)?sn(t,"y"):!0}f(ms,"applyBtDirectionTransform");function ys(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(B=>!B.isGroup);let r=1/0,c=1/0;for(const B of s){const X=B.x??0,G=B.y??0;X<r&&(r=X),G<c&&(c=G)}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const d=36;let l=0,a=0;for(const B of s)l+=B.width??0,a+=B.height??0;const h=l/s.length,m=a/s.length,M=m>0?Math.max(1,h/m):1;for(const B of s){const X=B.x??0,Z=((B.y??0)-c)*M+d,ct=X-r;B.x=Z,B.y=ct}for(const B of o)if(B.points)for(const X of B.points){const G=X.x,ct=(X.y-c)*M+d,Mt=G-r;X.x=ct,X.y=Mt}gs(n);const p=n.filter(B=>B.isGroup&&!B.parentId);if(p.length===0)return e==="RL"&&sn(t,"x"),!0;const u=yo(n),i=new Map;for(const B of n){if(B.isGroup)continue;const X=us(B,u);if(!X)continue;const G=i.get(X)??[];G.push(B),i.set(X,G)}let y=0;for(const B of p){const X=B.padding??0;X>y&&(y=X)}const C=[];let b=1/0,S=-1/0;for(const B of p){const X=i.get(B.id)??[],G=po(X);G&&(b=Math.min(b,G.minX),S=Math.max(S,G.maxX),C.push({lane:B,contentTop:G.minY,contentBottom:G.maxY,centerY:(G.minY+G.maxY)/2}))}if(b===1/0||S===-1/0)return!0;const w=Math.max(0,S-b),I=Math.max(y,10),x=w+2*I,L=d+x,A=(b+S)/2-x/2-d,P=A+L/2,k=Math.max(y,d);C.sort((B,X)=>B.centerY-X.centerY);for(let B=0;B<C.length;B++){const X=C[B];let G,Z;if(B===0?G=X.contentTop-k:G=(C[B-1].contentBottom+X.contentTop)/2,B===C.length-1)Z=X.contentBottom+k;else{const Ft=C[B+1];Z=(X.contentBottom+Ft.contentTop)/2}const ct=Math.max(0,Z-G),Mt=(G+Z)/2;X.lane.x=P,X.lane.y=Mt,X.lane.width=L,X.lane.height=ct,X.lane.swimlaneContentTop=X.contentTop,X.lane.groupTitleRect={left:A,right:A+d,top:G,bottom:Z}}return e==="RL"&&sn(t,"x"),!0}f(ys,"applyLrDirectionTransform");var ae=1e-6,Or=8,Ue=Or,Br=[0,Ue,-Ue,2*Ue,-2*Ue];function ps(t,e){const{nodeInfoById:n,realNodeRects:o}=ln(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const c=co(xt(r,ae),ae);if(!c)continue;const{p3:d}=c,l=c.kind==="HVH",a=uo(s,n,ae);if(!a)continue;const{srcId:h,dstId:m,srcInfo:M,dstInfo:p,collinearX:u,collinearY:i}=a;if(u||i)continue;let y;const C=M.rect;for(const b of Br){let S,w,I;if(l){const P=p.cy>M.cy?C.bottom:C.top,k=M.cx+b;if(k<=C.left+ae||k>=C.right-ae)continue;S={x:k,y:P},w={x:k,y:d.y},I={x:d.x,y:d.y}}else{const P=p.cx>M.cx?C.right:C.left,k=M.cy+b;if(k<=C.top+ae||k>=C.bottom-ae)continue;S={x:P,y:k},w={x:d.x,y:k},I={x:d.x,y:d.y}}const x=ce(S,w,ae),L=ce(w,I,ae);if(x&&L||!x&&Bt(S,w,o,[h],1)||!L&&Bt(w,I,o,[m],1))continue;const R=!x&&Qe(S,w,t,s,{epsilon:ae,skipDegenerateOther:!0}),F=!L&&Qe(w,I,t,s,{epsilon:ae,skipDegenerateOther:!0});if(!(R||F)){x?y=[w,I]:L?y=[S,w]:y=[S,w,I];break}}y&&(s.points=y)}}f(ps,"portSwapToLShape");function xs(t,e){const{realNodeRects:r,labelNodeRects:c}=Me(e.values());for(const d of t){if(d.isLayoutOnly)continue;const l=d.points;if(!l||l.length<4)continue;const a=xt(l,.001);if(a.length<4)continue;const h=a.length-1,m=a[h],M=a[h-1],p=a[h-2],u=m.x-M.x,i=m.y-M.y,y=Math.hypot(u,i);if(y>=10||y<.001)continue;const C=M.x-p.x,b=M.y-p.y;if(Math.hypot(C,b)<.001)continue;const w=Nt(M,m,.001),I=Ot(M,m,.001),x=Nt(p,M,.001),L=Ot(p,M,.001);if(!(w&&L||I&&x))continue;const R=d.end,F=d.start,A=R?e.get(R):void 0;if(!A)continue;const P=A.x??0,k=A.y??0,B=te(A);if(!B)continue;let X,G;if(L){const J=b<0;X={x:P,y:p.y},G={x:P,y:J?B.bottom:B.top}}else{const J=C>0;X={x:p.x,y:k},G={x:J?B.right:B.left,y:k}}if(Bt(X,G,r,R?[R]:[],-2)||Bt(X,G,c,[],-2))continue;if(F){const J=e.get(F),rt=J?te(J):void 0;if(rt&&ao(X,rt,2))continue}const Z=f((J,rt)=>`${J.x.toFixed(3)},${J.y.toFixed(3)}|${rt.x.toFixed(3)},${rt.y.toFixed(3)}`,"ownSegmentKey"),ct=new Set;for(let J=0;J<a.length-1;J++)ct.add(Z(a[J],a[J+1]));const Mt=f((J,rt)=>{for(const ut of t){if(ut===d||ut.isLayoutOnly)continue;const pt=ut.points;if(!(!pt||pt.length<2))for(let St=0;St<pt.length-1;St++){const At=pt[St],Kt=pt[St+1];if(!ct.has(Z(At,Kt))&&he(J,rt,At,Kt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(Mt(X,G))continue;if(h-3>=0){const J=a[h-3],rt=[F,R].filter(ut=>!!ut);if(Bt(J,X,r,rt,-2)||Mt(J,X))continue}const Dt=[...a.slice(0,h-2),X,G];d.points=Dt;const nt=d.labelNodeId;if(nt){const J=e.get(nt);if(J){const rt=J.width??0,ut=J.height??0;if(rt>0&&ut>0){let pt,St,At=-1;for(let Kt=0;Kt<Dt.length-1;Kt++){const qt=Dt[Kt],Jt=Dt[Kt+1],se=Math.hypot(Jt.x-qt.x,Jt.y-qt.y),Ee=yt(qt,Jt,.001),me=gt(qt,Jt,.001);(Ee&&se>=rt+2||me&&se>=ut+2)&&se>At&&(At=se,pt=(qt.x+Jt.x)/2,St=(qt.y+Jt.y)/2)}pt!==void 0&&St!==void 0&&(J.x=pt,J.y=St)}}}}}f(xs,"collapseShortTerminalStub");var et=.001,Xt=8,lt=Fe,Sn=f((t,e)=>gt(t,e,et)||yt(t,e,et),"orthogonallyAligned");function bs(t,e){const s=f((p,u)=>{const i=p.x??0,y=p.y??0,C=u.x-i,b=u.y-y;let S=(p.width??0)/2,w=(p.height??0)/2;return Math.abs(b)*S>Math.abs(C)*w?(b<0&&(w=-w),{x:i+(b===0?0:w*C/b),y:y+w}):(C<0&&(S=-S),{x:i+S,y:y+(C===0?0:S*b/C)})},"rectIntersect"),r=f((p,u)=>{const i=xt(p.points??[]);if(i.length<2)return;const y=u?p.start:p.end,C=y?e.get(y):void 0,b=C?te(C):void 0;if(!C||!y||!b)return;const S=u?i[0]:i[i.length-1],w=u?i[1]:i[i.length-2],I=s(C,S);let x=S;
1if(Sn(w,I)&&(x=w),gt(I,x,et))return{edge:p,edgeId:String(p.id??""),nodeId:y,atStart:u,orientation:"V",coord:I.x,min:Math.min(I.y,x.y),max:Math.max(I.y,x.y),boundary:I,railEnd:x,rect:b};if(yt(I,x,et))return{edge:p,edgeId:String(p.id??""),nodeId:y,atStart:u,orientation:"H",coord:I.y,min:Math.min(I.x,x.x),max:Math.max(I.x,x.x),boundary:I,railEnd:x,rect:b}},"terminalLaneFor"),c=f((p,u)=>Math.max(0,Math.min(p.max,u.max)-Math.max(p.min,u.min)),"projectedOverlapLength"),d=f((p,u)=>p.nodeId!==u.nodeId||p.orientation!==u.orientation?!1:p.orientation==="H"?(Math.abs(p.boundary.x-p.rect.left)<1||Math.abs(p.boundary.x-p.rect.right)<1)&&gt(p.boundary,u.boundary,1):(Math.abs(p.boundary.y-p.rect.top)<1||Math.abs(p.boundary.y-p.rect.bottom)<1)&&yt(p.boundary,u.boundary,1),"sameTerminalFace"),l=f((p,u)=>p.nodeId!==u.nodeId||p.orientation!==u.orientation?!1:c(p,u)>=Xt&&Math.abs(p.coord-u.coord)<.5,"exactTerminalLaneConflict"),a=f((p,u)=>{if(p.nodeId!==u.nodeId||p.orientation!==u.orientation||p.orientation!=="H"||p.atStart===u.atStart)return!1;const i=c(p,u);if(i<Xt)return!1;const y=p.rect.bottom-p.rect.top;return i<y||i>2*y?!1:d(p,u)&&Math.abs(p.coord-u.coord)<16},"nearTerminalLaneConflict"),h=f((p,u)=>{const i=xt(p.edge.points??[]);if(i.length<2)return;const y=p.orientation==="V"?{x:p.boundary.x+u,y:p.boundary.y}:{x:p.boundary.x,y:p.boundary.y+u},C=p.orientation==="V"?{x:p.railEnd.x+u,y:p.railEnd.y}:{x:p.railEnd.x,y:p.railEnd.y+u};if(!f(()=>Math.abs(p.boundary.y-p.rect.top)<1||Math.abs(p.boundary.y-p.rect.bottom)<1?yt(y,p.boundary,et)&&y.x>=p.rect.left+1&&y.x<=p.rect.right-1:Math.abs(p.boundary.x-p.rect.left)<1||Math.abs(p.boundary.x-p.rect.right)<1?gt(y,p.boundary,et)&&y.y>=p.rect.top+1&&y.y<=p.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(p.atStart){const x=i.length>1&&ce(i[1],p.railEnd,et),L=i.slice(x?2:1),R=L[0];return R&&!Sn(R,C)?void 0:[y,C,...L]}const S=i.length>1&&ce(i[i.length-2],p.railEnd,et),w=i.slice(0,S?-2:-1),I=w[w.length-1];if(!(I&&!Sn(I,C)))return[...w,C,y]},"shiftedCandidate"),m=f(p=>{const u=p.edge,i=xt(u.points??[]);if(i.length!==2)return!1;const y=u.start,C=u.end,b=y?e.get(y):void 0,S=C?e.get(C):void 0;if(!b||!S)return!1;const w=b.x??0,I=b.y??0,x=S.x??0,L=S.y??0,[R,F]=i;return yt(R,F,et)&&Math.abs(I-L)<1&&Math.abs(w-x)>1||gt(R,F,et)&&Math.abs(w-x)<1&&Math.abs(I-L)>1},"laneIsStraightCollinearConnector"),M=[-7,7,-2*7,2*7,-3*7,3*7];for(let p=0;p<8;p++){const u=t.filter(y=>!y.isLayoutOnly).flatMap(y=>[r(y,!0),r(y,!1)]).filter(y=>!!y);let i=!1;for(let y=0;y<u.length&&!i;y++)for(let C=y+1;C<u.length&&!i;C++){const b=u[y],S=u[C];if(b.edge===S.edge||!(l(b,S)||a(b,S)))continue;const w=!l(b,S),I=[b,S].sort((x,L)=>{const R=m(x),F=m(L);return R!==F?Number(R)-Number(F):+!L.atStart-+!x.atStart});for(const x of I){for(const L of M){const R=h(x,L);if(!R)continue;const F=r({...x.edge,points:R},x.atStart);if(!(!F||u.some(A=>A.edge!==x.edge&&(l(F,A)||w&&a(F,A))))){x.edge.points=R,i=!0;break}}if(i)break}}if(!i)return}}f(bs,"separateSharedRenderedTerminalLanes");function Ms(t,e){const{realNodeRects:s,labelNodeRects:r}=Me(e.values()),c=f((l,a)=>{const h=l.start,m=l.end,M=lt(a);if(M.length!==a.length-1)return!1;const p=[h,m].filter(u=>!!u);for(const u of M)if(Bt(u.a,u.b,s,p,-2)||Bt(u.a,u.b,r,[],-2))return!1;for(const u of t){if(u===l||u.isLayoutOnly)continue;const i=u.points;if(!(!i||i.length<2)){for(const y of M)for(const C of lt(xt(i)))if(de(y,C,.5)>=Xt||he(y.a,y.b,C.a,C.b,et))return!1}}return!0},"candidateIsSafe"),d=f((l,a)=>{if(a+4>=l.length)return;const h=l[a],m=l[a+1],M=l[a+2],p=l[a+3],u=l[a+4],i=Nt(h,m)&&Ot(m,M)&&Nt(M,p)&&Ot(p,u)&&gt(h,p,et)&&gt(h,u,et)&&gt(m,M,et)&&(m.x-h.x)*(p.x-M.x)<0,y=Ot(h,m)&&Nt(m,M)&&Ot(M,p)&&Nt(p,u)&&yt(h,p,et)&&yt(h,u,et)&&yt(m,M,et)&&(m.y-h.y)*(p.y-M.y)<0;if(i||y)return xt([...l.slice(0,a+1),u,...l.slice(a+5)]);if(a+5>=l.length)return;const C=l[a+5],b=Ot(h,m)&&Nt(m,M)&&Ot(M,p)&&Nt(p,u)&&Ot(u,C)&&gt(h,u,et)&&gt(h,C,et)&&gt(M,p,et)&&(M.x-m.x)*(u.x-p.x)<0,S=Nt(h,m)&&Ot(m,M)&&Nt(M,p)&&Ot(p,u)&&Nt(u,C)&&yt(h,u,et)&&yt(h,C,et)&&yt(M,p,et)&&(M.y-m.y)*(u.y-p.y)<0;if(!(!b&&!S))return xt([...l.slice(0,a+1),C,...l.slice(a+6)])},"withoutDogleg");for(let l=0;l<8;l++){let a=!1;for(const h of t){if(h.isLayoutOnly)continue;const m=xt(h.points??[]);for(let M=0;M<=m.length-5;M++){const p=d(m,M);if(!(!p||!c(h,p))){h.points=p,a=!0;break}}if(a)break}if(!a)return}}f(Ms,"collapseRedundantRectangularDoglegs");function Gn(t,e){const{realNodeRects:r,labelNodeRects:c}=Me(e.values()),d=t.filter(u=>!u.isLayoutOnly),l=f((u,i,y)=>xt(u===i?y??[]:u.points??[]),"pointsFor"),a=f((u,i)=>{let y=0;for(let C=0;C<d.length;C++){const b=lt(l(d[C],u,i));for(let S=C+1;S<d.length;S++){const w=lt(l(d[S],u,i));for(const I of b)for(const x of w)he(I.a,I.b,x.a,x.b,et)&&y++}}return y},"strictCrossingCount"),h=f(u=>{const i=lt(u);
1if(i.length!==3)return;const y=i[1];if(!(i[0].horizontal===y.horizontal||i[2].horizontal===y.horizontal))return{index:y.index,horizontal:y.horizontal,vertical:y.vertical,segment:y}},"middleRail"),m=f((u,i)=>{const y=[u.start,u.end].filter(C=>!!C);return r.filter(C=>{if(y.includes(C.id))return!1;const b=C.rect;return i.horizontal?Wt(i.a.x,i.b.x,b.left,b.right)>=Xt&&i.a.y>=b.top-2&&i.a.y<=b.bottom+2:Wt(i.a.y,i.b.y,b.top,b.bottom)>=Xt&&i.a.x>=b.left-2&&i.a.x<=b.right+2})},"blockingRectsFor"),M=f((u,i,y)=>{const C=u.map(S=>({...S}));if(i.horizontal)C[i.index].y=y,C[i.index+1].y=y;else if(i.vertical)C[i.index].x=y,C[i.index+1].x=y;else return;const b=ue(xt(C));return lt(b).length===b.length-1?b:void 0},"candidateByMovingRail"),p=f((u,i,y)=>{const C=[u.start,u.end].filter(S=>!!S),b=lt(i);if(b.length!==i.length-1)return!1;for(const S of b)if(Bt(S.a,S.b,r,C,-2)||Bt(S.a,S.b,c,[],-2))return!1;for(const S of d)if(S!==u){for(const w of b)for(const I of lt(l(S)))if(de(w,I,.5)>=Xt)return!1}return a(u,i)<=y},"candidateIsSafe");for(let u=0;u<8;u++){const i=a();let y=!1;for(const C of d){const b=l(C),S=h(b);if(!S)continue;const w=m(C,S.segment);if(w.length===0)continue;const I=S.horizontal?[Math.min(...w.map(x=>x.rect.top))-20,Math.max(...w.map(x=>x.rect.bottom))+20]:[Math.min(...w.map(x=>x.rect.left))-20,Math.max(...w.map(x=>x.rect.right))+20];for(const x of I){const L=M(b,S.segment,x);if(!(!L||!p(C,L,i))){C.points=L,y=!0;break}}if(y)break}if(!y)return}}f(Gn,"liftObstacleHuggingSameSideRails");function $n(t,e){const o=f(l=>{const a=l.groupTitleRect;if(!(!a||typeof a.left!="number"||typeof a.right!="number"||typeof a.top!="number"||typeof a.bottom!="number"||!Number.isFinite(a.left)||!Number.isFinite(a.right)||!Number.isFinite(a.top)||!Number.isFinite(a.bottom)||a.right<=a.left||a.bottom<=a.top))return{left:a.left,right:a.right,top:a.top,bottom:a.bottom}},"validTitleRect"),s=f(l=>{if(!l.isGroup||l.parentId)return;const a=l.direction,h=typeof a=="string"?a.toUpperCase():"";if(h==="LR"||h==="RL"||h==="BT")return;const m=o(l),M=l.y,p=l.height;if(!m||typeof M!="number"||typeof p!="number"||!Number.isFinite(M)||!Number.isFinite(p)||p<=0)return;const u=m.right-m.left,i=m.bottom-m.top;if(!(i<=0||u<i))return{node:l,rect:m}},"topLaneTitleFor"),r=f((l,a)=>{if(!l.horizontal)return!1;const h=l.a.y;return h<=a.top+et||h>=a.bottom-et?!1:Wt(l.a.x,l.b.x,a.left,a.right)>=Xt},"horizontalSegmentIntersectsTitle"),c=[...e.values()].map(s).filter(l=>!!l);if(c.length===0)return;let d=0;for(const l of t){if(l.isLayoutOnly)continue;const a=xt(l.points??[]);for(const h of lt(a))for(const m of c)r(h,m.rect)&&(d=Math.max(d,m.rect.bottom-h.a.y+4))}if(!(d<=et))for(const l of c){const a=l.node.y,h=l.node.height;typeof a!="number"||typeof h!="number"||!Number.isFinite(a)||!Number.isFinite(h)||h<=0||(l.node.y=a-d/2,l.node.height=h+d,l.node.groupTitleRect={...l.rect,top:l.rect.top-d,bottom:l.rect.bottom-d})}}f($n,"liftTopLaneTitleBandsAboveRails");function zn(t,e){const o=f(a=>{const h=a.groupTitleRect;if(!(!h||typeof h.left!="number"||typeof h.right!="number"||typeof h.top!="number"||typeof h.bottom!="number"||!Number.isFinite(h.left)||!Number.isFinite(h.right)||!Number.isFinite(h.top)||!Number.isFinite(h.bottom)||h.right<=h.left||h.bottom<=h.top))return{left:h.left,right:h.right,top:h.top,bottom:h.bottom}},"validTitleRect"),s=f(a=>{if(!a.isGroup||a.parentId||a.direction!=="LR")return;const m=o(a),M=a.x,p=a.width;if(!m||typeof M!="number"||typeof p!="number"||!Number.isFinite(M)||!Number.isFinite(p)||p<=0)return;const u=m.right-m.left,i=m.bottom-m.top;if(!(u<=0||i<u))return{node:a,rect:m}},"leftLaneTitleFor"),r=f((a,h)=>{if(!a.vertical)return!1;const m=a.a.x;return m<=h.left+et||m>=h.right-et?!1:Wt(a.a.y,a.b.y,h.top,h.bottom)>=Xt},"verticalSegmentIntersectsTitle"),c=f((a,h)=>{if(!a.horizontal)return!1;const m=a.a.y;return m<=h.top+et||m>=h.bottom-et?!1:Wt(a.a.x,a.b.x,h.left,h.right)>=Xt},"horizontalSegmentIntersectsTitle"),d=[...e.values()].map(s).filter(a=>!!a);if(d.length===0)return;let l=0;for(const a of t){if(a.isLayoutOnly)continue;const h=xt(a.points??[]);for(const m of lt(h))for(const M of d)if(r(m,M.rect))l=Math.max(l,M.rect.right-m.a.x+4);else if(c(m,M.rect)){const p=Math.min(m.a.x,m.b.x);l=Math.max(l,M.rect.right-p+4)}}if(!(l<=et))for(const a of d){const h=a.node.x,m=a.node.width;typeof h!="number"||typeof m!="number"||!Number.isFinite(h)||!Number.isFinite(m)||m<=0||(a.node.x=h-l/2,a.node.width=m+l,a.node.groupTitleRect={...a.rect,left:a.rect.left-l,right:a.rect.right-l})}}f(zn,"shiftLeftLaneTitleBandsLeftOfRails");function Is(t,e){const{realNodeRects:s}=Me(e.values()),r=t.filter(i=>!i.isLayoutOnly),c=f((i,y=new Map)=>xt(y.get(i)??i.points??[]),"replacementPointsFor"),d=f((i=new Map)=>{let y=0;for(let C=0;C<r.length;C++){const b=lt(c(r[C],i));for(let S=C+1;S<r.length;S++){const w=lt(c(r[S],i));for(const I of b)for(const x of w)he(I.a,I.b,x.a,x.b,et)&&y++}}return y},"crossingCount"),l=f((i=new Map)=>r.reduce((y,C)=>y+oe(c(C,i)),0),"totalBends"),a=f(i=>{const y=c(i);if(y.length<4)return;const C=y[y.length-2],b=y[y.length-1];if(!(!Nt(C,b,et)&&!Ot(C,b,et)))return{tailStart:C,terminal:b}},"terminalTailFor"),h=f((i,y)=>{const C=c(i);if(C.length<3)return;const b=C[0],S=C[1];let w;if(Nt(b,S,et))w={x:S.x,y:y.tailStart.y};else if(Ot(b,S,et))w={x:y.tailStart.x,y:S.y};else return;const I=ue(xt([b,S,w,y.tailStart,y.terminal]));return lt(I).length===I.length-1?I:void 0},"candidateWithDestinationTail"),m=f((i,y)=>{const C=[i.start,i.end].filter(b=>!!b);for(const b of lt(y))if(Bt(b.a,b.b,s,C,-2))return!0;return!1},"pathHasNodeHit"),M=f((i,y,C)=>{for(const b of r)if(b!==i){for(const S of lt(y))for(const w of lt(c(b,C)))if(de(S,w,.5)>=Xt)return!0}return!1},"pathHasSharedTrack"),p=f((i,y,C)=>!m(i,y)&&!M(i,y,C),"candidateIsSafe"),u=f(()=>{const i=new Map;for(const y of r){const C=y.end;if(!C||!e.has(C)||c(y).length<4)continue;const S=i.get(C)??[];S.push(y),i.set(C,S)}return i},"edgesByDestination");for(let i=0;i<4;i++){const y=d();if(y===0)return;const C=l();let b,S=y,w=C;for(const I of u().values())for(let x=0;x<I.length;x++)for(let L=x+1;L<I.length;L++){const R=I[x],F=I[L],A=a(R),P=a(F);if(!A||!P)continue;
1const k=h(R,P),B=h(F,A);if(!k||!B)continue;const X=new Map([[R,k],[F,B]]);if(!p(R,k,X)||!p(F,B,X))continue;const G=d(X),Z=l(X);G>=y||G>S||G===S&&Z>=w||(b=X,S=G,w=Z)}if(!b)return;for(const[I,x]of b)I.points=x}}f(Is,"swapDestinationTerminalTailsToReduceCrossings");function Ss(t,e){const{realNodeRects:c,labelNodeRects:d}=Me(e.values()),l=t.filter(I=>!I.isLayoutOnly),a=f((I,x=new Map)=>xt(x.get(I)??I.points??[]),"replacementPointsFor"),h=f((I=new Map)=>{let x=0;for(let L=0;L<l.length;L++){const R=lt(a(l[L],I));for(let F=L+1;F<l.length;F++){const A=lt(a(l[F],I));for(const P of R)for(const k of A)he(P.a,P.b,k.a,k.b,et)&&x++}}return x},"strictCrossingCount"),m=f((I=new Map)=>l.reduce((x,L)=>x+oe(a(L,I)),0),"totalBends"),M=f(I=>{const x=I.start,L=I.end,R=x?e.get(x):void 0,F=L?e.get(L):void 0,A=R?te(R):void 0,P=F?te(F):void 0;return A&&P?{src:A,dst:P}:void 0},"endpointRectsFor"),p=f((I,x,L)=>{if(L.index<=0||L.index+1>=x.length-1)return;const R=M(I);if(R){if(L.vertical){const F=L.a.x,A=Math.min(R.src.left,R.dst.left),P=Math.max(R.src.right,R.dst.right),k=F<A-et?"left":F>P+et?"right":void 0;return k?{edge:I,points:x,segmentIndex:L.index,axis:"vertical",side:k,coord:F,min:Math.min(L.a.y,L.b.y),max:Math.max(L.a.y,L.b.y)}:void 0}if(L.horizontal){const F=L.a.y,A=Math.min(R.src.top,R.dst.top),P=Math.max(R.src.bottom,R.dst.bottom),k=F<A-et?"top":F>P+et?"bottom":void 0;return k?{edge:I,points:x,segmentIndex:L.index,axis:"horizontal",side:k,coord:F,min:Math.min(L.a.x,L.b.x),max:Math.max(L.a.x,L.b.x)}:void 0}}},"externalRailForSegment"),u=f(()=>{const I=[];for(const x of l){const L=a(x);for(const R of lt(L)){const F=p(x,L,R);F&&I.push(F)}}return I},"collectExternalRails"),i=f((I,x)=>I.edge!==x.edge&&I.axis===x.axis&&I.side===x.side&&Wt(I.min,I.max,x.min,x.max)>=Xt,"railsInteract"),y=f(I=>{const x=[],L=new Set;for(const R of I){if(L.has(R))continue;const F=[R],A=[];for(L.add(R);F.length>0;){const P=F.pop();A.push(P);for(const k of I)!L.has(k)&&i(P,k)&&(L.add(k),F.push(k))}A.length>1&&x.push(A)}return x},"connectedComponents"),C=f(I=>{const x=[];for(const L of I)x.some(R=>Math.abs(R-L.coord)<et)||x.push(L.coord);for(;x.length<I.length;){const L=Math.min(...x),R=Math.max(...x),F=I[0].side;x.push(F==="left"||F==="top"?L-12*(I.length-x.length):R+12*(I.length-x.length))}return x},"uniqueCoordsFor"),b=f(I=>{const x=I.map(F=>F.coord),L=C(I),R=[];if(I.length<=6){const F=new Array(L.length).fill(!1),A=[],P=f(()=>{if(A.length===I.length){A.some((k,B)=>Math.abs(k-x[B])>=et)&&R.push([...A]);return}for(const[k,B]of L.entries())F[k]||(F[k]=!0,A.push(B),P(),A.pop(),F[k]=!1)},"visit");return P(),R}for(let F=0;F<x.length;F++)for(let A=F+1;A<x.length;A++){const P=[...x];[P[F],P[A]]=[P[A],P[F]],R.push(P)}return R},"coordinateAssignmentsFor"),S=f((I,x)=>{const L=new Map;for(const[F,A]of I.entries()){const P=x[F],k=L.get(A.edge)??A.points.map(B=>({x:B.x,y:B.y}));A.axis==="vertical"?(k[A.segmentIndex].x=P,k[A.segmentIndex+1].x=P):(k[A.segmentIndex].y=P,k[A.segmentIndex+1].y=P),L.set(A.edge,k)}const R=new Map;for(const[F,A]of L){const P=ue(xt(A));if(lt(P).length!==P.length-1)return;R.set(F,P)}return R},"replacementsForAssignment"),w=f(I=>{for(const[x,L]of I){const R=[x.start,x.end].filter(F=>!!F);for(const F of lt(L))if(Bt(F.a,F.b,c,R,-2)||Bt(F.a,F.b,d,[],-2))return!1}for(let x=0;x<l.length;x++){const L=l[x],R=I.has(L),F=lt(a(L,I));for(let A=x+1;A<l.length;A++){const P=l[A];if(!R&&!I.has(P))continue;const k=lt(a(P,I));for(const B of F)for(const X of k)if(de(B,X,.5)>=Xt)return!1}}return!0},"candidateIsSafe");for(let I=0;I<4;I++){const x=h();if(x===0)return;let L,R=x,F=m(),A=Number.POSITIVE_INFINITY;for(const P of y(u()))for(const k of b(P)){const B=S(P,k);if(!B||!w(B))continue;const X=h(B);if(X>=x)continue;const G=m(B),Z=P.reduce((ct,Mt,Ft)=>ct+Math.abs(k[Ft]-Mt.coord),0);X>R||X===R&&(G>F||G===F&&Z>=A)||(L=B,R=X,F=G,A=Z)}if(!L)return;for(const[P,k]of L)P.points=k}}f(Ss,"reassignCrossingExternalRailChannels");function Cs(t,e){const{realNodeRects:s,labelNodeRects:r}=Me(e.values()),c=t.filter(u=>!u.isLayoutOnly),d=f((u,i,y)=>xt(u===i?y??[]:u.points??[]),"pointsFor"),l=f(u=>lt(u).reduce((i,y)=>{const C=y.a.x-y.b.x,b=y.a.y-y.b.y;return i+Math.hypot(C,b)},0),"pathLength"),a=f((u,i)=>{let y=0;for(let C=0;C<c.length;C++){const b=lt(d(c[C],u,i));for(let S=C+1;S<c.length;S++){const w=lt(d(c[S],u,i));for(const I of b)for(const x of w)he(I.a,I.b,x.a,x.b,et)&&y++}}return y},"strictCrossingCount"),h=f((u,i)=>{if(u.horizontal){const y=u.a.y;return(Math.abs(y-i.top)<1||Math.abs(y-i.bottom)<1)&&Wt(u.a.x,u.b.x,i.left,i.right)>=Xt}if(u.vertical){const y=u.a.x;return(Math.abs(y-i.left)<1||Math.abs(y-i.right)<1)&&Wt(u.a.y,u.b.y,i.top,i.bottom)>=Xt}return!1},"segmentRunsAlongRectBorder"),m=f(u=>{const i=[u.start,u.end].filter(C=>!!C),y=[];for(const C of i){const b=e.get(C),S=b?te(b):void 0;S&&y.push(S)}return y},"endpointRectsFor"),M=f((u,i)=>{if(i+3>=u.length)return[];const y=u[i],C=u[i+1],b=u[i+2],S=u[i+3],w=Nt(y,C,et)&&Ot(C,b,et)&&Nt(b,S,et),I=Ot(y,C,et)&&Nt(C,b,et)&&Ot(b,S,et);
1if(!w&&!I)return[];if(!(w?Math.sign(C.x-y.x)!==Math.sign(S.x-b.x):Math.sign(C.y-y.y)!==Math.sign(S.y-b.y)))return[];const L=gt(y,S,et)||yt(y,S,et)?[]:[{x:y.x,y:S.y},{x:S.x,y:y.y}],R=L.length===0?[[...u.slice(0,i+1),...u.slice(i+3)]]:L.map(A=>[...u.slice(0,i+1),A,...u.slice(i+3)]),F=new Set;return R.map(A=>ue(xt(A))).filter(A=>{if(lt(A).length!==A.length-1||!A.some(k=>ce(k,S,et)))return!1;const P=A.map(k=>`${k.x.toFixed(3)},${k.y.toFixed(3)}`).join("|");return F.has(P)?!1:(F.add(P),!0)})},"shortcutCandidatesAt"),p=f((u,i,y)=>{const C=[u.start,u.end].filter(S=>!!S),b=m(u);for(const S of lt(i))if(Bt(S.a,S.b,s,C,-2)||Bt(S.a,S.b,r,[],-2)||b.some(w=>h(S,w)))return!1;for(const S of c)if(S!==u){for(const w of lt(i))for(const I of lt(d(S)))if(de(w,I,.5)>=Xt)return!1}return a(u,i)<=y},"candidateIsSafe");for(let u=0;u<8;u++){const i=a();let y,C,b=i,S=Number.POSITIVE_INFINITY,w=Number.POSITIVE_INFINITY;for(const I of c){const x=d(I),L=oe(x,et),R=l(x);for(let F=0;F<=x.length-4;F++)for(const A of M(x,F)){const P=oe(A,et),k=l(A);
1if(!(P<L||P===L&&k<R-et)||!p(I,A,i))continue;const X=a(I,A);X>b||X===b&&(P>S||P===S&&k>=w)||(y=I,C=A,b=X,S=P,w=k)}}if(!y||!C)return;y.points=C}}f(Cs,"shortcutRedundantOrthogonalJogs");function vs(t,e){const c=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const _=N.x??0,D=N.y??0,U=te(N);U&&c.push({id:String(N.id??""),cx:_,cy:D,rect:U})}if(c.length===0)return;const d=new Map(c.map(N=>[N.id,N])),l=c.map(N=>({id:N.id,rect:N.rect})),a=["top","bottom","left","right"],h={top:Math.min(...c.map(N=>N.rect.top))-20,bottom:Math.max(...c.map(N=>N.rect.bottom))+20,left:Math.min(...c.map(N=>N.rect.left))-20,right:Math.max(...c.map(N=>N.rect.right))+20},m=t.filter(N=>!N.isLayoutOnly),M=new Map(m.map((N,_)=>[N,_])),p=f(N=>{const _=N==="left"||N==="top"?-1:1,D=[];for(let U=0;U<=2;U++)D.push(h[N]+_*20*U);return D},"outwardTracksForSide"),u=f((N,_=new Map)=>xt(_.get(N)??N.points??[]),"replacementPointsFor"),i=f((N,_)=>{let D=0;for(const U of N)for(const K of _)he(U.a,U.b,K.a,K.b,et)&&D++;return D},"crossingCountBetweenSegments"),y=f((N,_)=>i(lt(N),lt(_)),"crossingCountBetweenPaths"),C=f((N=new Map)=>{let _=0;const D=[],U=new Set,K=[],Q=f($=>{U.has($)||(U.add($),K.push($))},"addEdge");for(let $=0;$<m.length;$++){const q=m[$],g=u(q,N);for(let v=$+1;v<m.length;v++){const T=m[v],E=y(g,u(T,N));E>0&&(_+=E,D.push({first:q,second:T,count:E}),Q(q),Q(T))}}return K.sort(($,q)=>(M.get($)??0)-(M.get(q)??0)),{count:_,pairs:D,edgeSet:U,edges:K}},"crossingSnapshot"),b=f((N,_)=>{const D=new Set(_.keys());if(D.size===0)return N.count;let U=0;for(const Q of N.pairs)(D.has(Q.first)||D.has(Q.second))&&(U+=Q.count);let K=0;for(let Q=0;Q<m.length;Q++){const $=m[Q],q=D.has($),g=u($,_);for(let v=Q+1;v<m.length;v++){const T=m[v];!q&&!D.has(T)||(K+=y(g,u(T,_)))}}return N.count-U+K},"crossingCountWithReplacements"),S=f(N=>{const _=new Map;for(const K of N.pairs){const Q=_.get(K.first)??new Set;Q.add(K.second),_.set(K.first,Q);const $=_.get(K.second)??new Set;$.add(K.first),_.set(K.second,$)}const D=[],U=new Set;for(const K of N.edges){if(U.has(K))continue;const Q=[K],$=[];for(U.add(K);Q.length>0;){const q=Q.pop();$.push(q);for(const g of _.get(q)??[])U.has(g)||(U.add(g),Q.push(g))}$.sort((q,g)=>(M.get(q)??0)-(M.get(g)??0)),$.length>1&&D.push($)}return D},"crossingComponents"),w=f(N=>[N.start,N.end].filter(_=>!!_),"endpointIdsFor"),I=f(N=>{const _=[];for(const D of S(N)){const U=new Set(D),K=new Set(D.flatMap($=>w($))),Q=[...D];for(const $ of m)U.has($)||w($).some(q=>K.has(q))&&Q.push($);Q.sort(($,q)=>(M.get($)??0)-(M.get(q)??0)),_.push(Q)}return _},"pairSearchGroups"),x=f((N,_,D)=>b(N,new Map([[_,D]])),"crossingCountWithSingleReplacement"),L=f(N=>{const _=new Map;for(const D of N.pairs)_.set(D.first,(_.get(D.first)??0)+D.count),_.set(D.second,(_.get(D.second)??0)+D.count);return _},"currentCrossingsByEdge"),R=f(N=>N.slice(1).reduce((_,D,U)=>{const K=N[U];return _+Math.abs(D.x-K.x)+Math.abs(D.y-K.y)},0),"pathLength"),F=f((N=new Map)=>m.reduce((_,D)=>_+oe(u(D,N)),0),"totalBends"),A=f((N=new Map)=>m.reduce((_,D)=>_+R(u(D,N)),0),"totalLength"),P=f((N,_,D=new Map)=>{const U=lt(_);for(const K of m)if(K!==N){for(const Q of U)for(const $ of lt(u(K,D)))if(de(Q,$,.5)>=Xt)return!0}return!1},"pathHasSegmentConflict"),k=f((N,_)=>{const D=[N.start,N.end].filter(U=>!!U);for(const U of lt(_))if(Bt(U.a,U.b,l,D,-2))return!0;return!1},"pathHitsNode"),B=f((N,_)=>{const D=ue(xt(_));lt(D).length===D.length-1&&N.push(D)},"pushOrthogonalCandidate"),X=f(N=>N==="left"||N==="right","sideIsHorizontal"),G=f((N,_,D)=>{switch(_){case"left":return Math.min(N.x,D.x)-20;case"right":return Math.max(N.x,D.x)+20;case"top":return Math.min(N.y,D.y)-20;case"bottom":return Math.max(N.y,D.y)+20}},"localTrackForSameSide"),Z=f((N,_,D,U)=>{const K=D==="left"||D==="top"?-1:1,Q=[G(_,D,U),h[D]];for(const $ of Q)for(let q=0;q<=2;q++)B(N,fo(_,D,U,$+K*20*q))},"addSameSideCandidates"),ct=f((N,_,D,U,K)=>{for(const Q of p(D))for(const $ of p(K))B(N,[_,{x:Q,y:_.y},{x:Q,y:$},{x:U.x,y:$},U])},"addHorizontalToVerticalCandidates"),Mt=f((N,_,D,U,K)=>{for(const Q of p(D))for(const $ of p(K))B(N,[_,{x:_.x,y:Q},{x:$,y:Q},{x:$,y:U.y},U])},"addVerticalToHorizontalCandidates"),Ft=f((N,_,D,U,K)=>{const Q=[...p("top"),...p("bottom")];for(const $ of p(D))for(const q of p(K))for(const g of Q)B(N,[_,{x:$,y:_.y},{x:$,y:g},{x:q,y:g},{x:q,y:U.y},U])},"addHorizontalPairCandidates"),Dt=f((N,_,D,U,K)=>{const Q=[...p("left"),...p("right")];for(const $ of p(D))for(const q of p(K))for(const g of Q)B(N,[_,{x:_.x,y:$},{x:g,y:$},{x:g,y:q},{x:U.x,y:q},U])},"addVerticalPairCandidates"),nt=f(N=>{const _=new Set;return N.map(D=>xt(D)).filter(D=>{const U=D.map(K=>`${K.x.toFixed(3)},${K.y.toFixed(3)}`).join("|");return _.has(U)||D.length<2?!1:(_.add(U),!0)})},"dedupeCandidatePaths"),J=f((N,_,D,U)=>{const K=[],Q=lo(N,_,D,U,20,et);Q&&B(K,Q),_===U&&Z(K,N,_,D);const $=X(_),q=X(U);return $&&!q?ct(K,N,_,D,U):!$&&q?Mt(K,N,_,D,U):$?Ft(K,N,_,D,U):Dt(K,N,_,D,U),nt(K)}
1,"buildCandidatesForSides"),rt=f((N,_,D,U)=>{const K=[...p("left"),...p("right")],Q=[...p("top"),...p("bottom")];for(const $ of a){const q=Le(U,$),g=$==="top"||$==="bottom"?p($):Q;for(const v of K){B(N,[_,D,{x:v,y:D.y},{x:v,y:q.y},q]);for(const T of g)B(N,[_,D,{x:v,y:D.y},{x:v,y:T},{x:q.x,y:T},q])}}},"addVerticalDepartureOuterTrackCandidates"),ut=f((N,_,D,U)=>{const K=[...p("left"),...p("right")],Q=[...p("top"),...p("bottom")];for(const $ of a){const q=Le(U,$),g=$==="left"||$==="right"?p($):K;for(const v of Q){B(N,[_,D,{x:D.x,y:v},{x:q.x,y:v},q]);for(const T of g)B(N,[_,D,{x:D.x,y:v},{x:T,y:v},{x:T,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),pt=f(N=>{const _=N.start,D=N.end,U=D?d.get(D):void 0;if(!_||!U)return[];const K=xt(N.points??[]);if(K.length<4)return[];const Q=K[0],$=K[1],q=[];return Ot(Q,$,et)?rt(q,Q,$,U):Nt(Q,$,et)&&ut(q,Q,$,U),q},"terminalPreservingOuterTrackCandidates"),St=f(N=>{const _=N.start,D=N.end,U=_?d.get(_):void 0,K=D?d.get(D):void 0;if(!U||!K)return[];const Q=[];for(const $ of a){const q=Le(U,$);for(const g of a)Q.push(...J(q,$,Le(K,g),g))}return Q.push(...pt(N)),Q},"candidatePathsFor"),At=f(()=>new Map(m.map(N=>[N,lt(u(N))])),"currentSegmentsByEdge"),Kt=f((N,_,D)=>{const U=new Set;for(const K of m){if(K===N)continue;const Q=D.get(K)??lt(u(K));_.some($=>Q.some(q=>de($,q,.5)>=Xt))&&U.add(K)}return U},"sharedTrackConflictsFor"),qt=f((N,_,D,U)=>{const K=new Set;return St(N).map($=>ue(xt($))).filter($=>{if(k(N,$))return!1;const q=$.map(g=>`${g.x.toFixed(3)},${g.y.toFixed(3)}`).join("|");return K.has(q)||$.length<2?!1:(K.add(q),!0)}).map($=>{const q=lt($);let g=0;for(const v of m)v!==N&&(g+=i(q,D.get(v)??lt(u(v))));return{candidate:$,candidateSegments:q,crossings:_.count-(U.get(N)??0)+g,bends:oe($,et),totalBends:oe($),length:R($)}}).filter(({crossings:$})=>$<=_.count).sort(($,q)=>$.crossings-q.crossings||$.bends-q.bends||$.length-q.length).slice(0,48).map($=>({path:$.candidate,segments:$.candidateSegments,sharedTrackConflicts:Kt(N,$.candidateSegments,D),totalBends:$.totalBends,length:$.length}))},"pairCandidatesFor"),Jt=f((N,_,D,U,K,Q)=>{let $=0;for(const g of N.pairs)(g.first===_||g.second===_||g.first===U||g.second===U)&&($+=g.count);let q=i(D.segments,K.segments);for(const g of m){if(g===_||g===U)continue;const v=Q.get(g)??lt(u(g));q+=i(D.segments,v)+i(K.segments,v)}return N.count-$+q},"pairCrossingCount"),se=f((N,_)=>{for(const D of N.sharedTrackConflicts)if(D!==_)return!1;return!0},"conflictsOnlyWith"),Ee=f((N,_)=>N.segments.some(D=>_.segments.some(U=>de(D,U,.5)>=Xt)),"candidatesShareTrack"),me=f((N,_,D,U)=>se(_,D.edge)&&se(U,N.edge)&&!Ee(_,U),"pairCandidatesAreCompatible"),Te=f((N,_,D,U,K)=>{const Q=Jt(N.current,_.edge,D,U.edge,K,N.baseSegments);if(!(Q>=N.current.count))return{replacements:new Map([[_.edge,D.path],[U.edge,K.path]]),crossings:Q,bends:N.currentBends-(N.baseBendsByEdge.get(_.edge)??0)-(N.baseBendsByEdge.get(U.edge)??0)+D.totalBends+K.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(_.edge)??0)-(N.baseLengthByEdge.get(U.edge)??0)+D.length+K.length}},"scorePairReplacement"),un=f((N,_)=>N.crossings<_.crossings||N.crossings===_.crossings&&(N.bends<_.bends||N.bends===_.bends&&N.length<_.length),"pairScoreIsBetter"),hn=f((N,_,D,U)=>{let K=U;for(const Q of _.candidates)for(const $ of D.candidates){if(!me(_,Q,D,$))continue;const q=Te(N,_,Q,D,$);q&&un(q,K)&&(K=q)}return K},"bestScoreForOptionPair"),gn=f(N=>{const _=F(),D=A(),U=At(),K=L(N),Q=new Map(m.map(E=>[E,oe(u(E))])),$=new Map(m.map(E=>[E,R(u(E))])),q=new Map,g=I(N);for(const E of g)for(const O of E){if(q.has(O))continue;const H=qt(O,N,U,K);H.length>0&&q.set(O,{edge:O,candidates:H})}let v={replacements:new Map,crossings:N.count,bends:_,length:D};const T={current:N,currentBends:_,currentLength:D,baseBendsByEdge:Q,baseLengthByEdge:$,baseSegments:U};for(const E of g){const O=new Set(E.filter(W=>N.edgeSet.has(W))),H=E.map(W=>q.get(W)).filter(W=>!!W);for(let W=0;W<H.length;W++){const ot=H[W];for(let j=W+1;j<H.length;j++){const V=H[j];!O.has(ot.edge)&&!O.has(V.edge)||(v=hn(T,ot,V,v))}}}return v.replacements.size>0?v.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const _=C(),D=_.count;if(D===0)return;let U,K,Q=D,$=Number.POSITIVE_INFINITY;for(const g of _.edges){const v=oe(u(g),et);for(const T of St(g)){const E=k(g,T),O=!E&&P(g,T),H=x(_,g,T),W=oe(T,et);E||O||!(H<D||H===D&&W<v)||H>Q||H===Q&&W>=$||(U=g,K=T,Q=H,$=W)}}if(U&&K){U.points=K;continue}const q=gn(_);if(!q)return;for(const[g,v]of q)g.points=v}}f(vs,"resolveRenderedOrthogonalCrossings");var be=.001,Fr=8;function Ls(t,e){const{nodeInfoById:n,realNodeRects:o}=ln(e),s=["top","bottom","left","right"],r=20,c={top:Math.min(...o.map(i=>i.rect.top))-r,bottom:Math.max(...o.map(i=>i.rect.bottom))+r,left:Math.min(...o.map(i=>i.rect.left))-r,right:Math.max(...o.map(i=>i.rect.right))+r},d=f((i,y,C,b)=>{const S=[],w=lo(i,y,C,b,r,be);return w&&S.push(w),y===b&&S.push(fo(i,y,C,c[y])),S},"buildOrthogonalPathCandidates"),l=f((i,y)=>{for(let C=0;C<i.length-1;C++){const b=i[C],S=i[C+1];if(Bt(b,S,o,y,1))return!0}return!1},"pathHitsNode"),a=f((i,y,C=!1)=>{let b=0;const S=Fe(i,be),w=y.start,I=y.end;for(const x of t){if(x===y||x.isLayoutOnly)continue;const L=x.start,R=x.end;if(!C&&w&&I&&(L===w||L===I||R===w||R===I))continue;const F=x.points;if(!(!F||F.length<2))for(const A of S)for(const P of Fe(F,be)){if(ho(A.a,A.b,P.a,P.b,be,be)){b++;continue}de(A,P,be)>=Fr&&b++}}return b},"pathConflictCount"),h=4,m=f((i,y)=>{const C=Math.abs(i.y-y.rect.top),b=Math.abs(i.y-y.rect.bottom),S=Math.abs(i.x-y.rect.left),w=Math.abs(i.x-y.rect.right);let I="top",x=C;return b<x&&(I="bottom",x=b),S<x&&(I="left",x=S),w<x&&(I="right",x=w),I},"nearestSideOfRect"),M=new Map,p=f((i,y,C)=>{const b=M.get(i)??[];b.push({side:y,edgeId:C}),M.set(i,b)},"addFaceClaim");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points??[];if(y.length<1)continue;const C=i.id??"",b=i.start,S=i.end;if(b){const w=n.get(b);w&&p(b,m(y[0],w),C)}if(S){const w=n.get(S);w&&p(S,m(y[y.length-1],w),C)}}const u=f((i,y,C)=>{var b;return((b=M.get(i))==null?void 0:b.some(S=>S.edgeId!==C&&S.side===y))??!1},"faceIsClaimed");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points;if(!y||y.length<2)continue;const C=oe(y,be);if(C<h)continue;const b=i.start,S=i.end;if(!b||!S)continue;const w=n.get(b),I=n.get(S);if(!w||!I)continue;const x=i.id??"",L=a(y,i,!0),R=a(y,i);let F,A=L,P=C;for(const k of s){if(u(b,k,x))continue;const B=Le(w,k);for(const X of s){if(u(S,X,x))continue;const G=Le(I,X);for(const Z of d(B,k,G,X)){if(l(Z,[b,S]))continue;const ct=oe(Z,be);if(L>0){const Mt=a(Z,i,!0);if(Mt>A||Mt===A&&ct>=P)continue;A=Mt,P=ct,F=Z;continue}a(Z,i)>R||ct<P&&(P=ct,F=Z)}}}if(F){i.points=F;const k=M.get(b);k&&M.set(b,k.filter(X=>X.edgeId!==x));const B=M.get(S);B&&M.set(S,B.filter(X=>X.edgeId!==x)),p(b,m(F[0],w),x),p(S,m(F[F.length-1],I),x)}}}f(Ls,"simplifyDetouredEdges");var Qt=.001,Po=10,je=7;function Vn(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const c=r.x-s.x,d=r.y-s.y;if(!(Math.abs(c)+Math.abs(d)<Qt)){if(Math.abs(d)<=Qt){const a=s.x+Math.sign(c)*Po;return{left:Math.min(s.x,a),right:Math.max(s.x,a),top:s.y-je,bottom:s.y+je}}if(Math.abs(c)<=Qt){const a=s.y+Math.sign(d)*Po;return{left:s.x-je,right:s.x+je,top:Math.min(s.y,a),bottom:Math.max(s.y,a)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}f(Vn,"markerClearanceRectFor");function Es(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}f(Es,"normalizeRect");function Un(t,e){const n=xt(e),o=Vn(n,!0),s=Vn(n,!1);return[o,s].some(r=>r&&Ze(t,Es(r)))}f(Un,"labelOverlapsOwnMarker");function Ke(t,e){const n=[];for(const u of t){if(u.isLayoutOnly)continue;const i=u.points;if(!(!i||i.length<2))for(let y=0;y<i.length-1;y++)n.push({edgeId:u.id,p1:i[y],p2:i[y+1]})}const o=[],s=[];for(const u of e.values()){const i=u.isGroup,y=u.parentId;if(i&&!y){const b=te(u);b&&s.push({id:u.id,rect:b});continue}if(i||u.isEdgeLabel)continue;const C=te(u);C&&o.push({nodeId:u.id,rect:C})}const r=3,c=1,d=12,l=f((u,i)=>{const y=wn(i,r);for(const{nodeId:C,rect:b}of o)if(C!==u&&Ze(y,b))return!0;return!1},"labelOverlapsForeignNode"),a=f((u,i)=>{const y=wn(i,r);for(const C of n)if(C.edgeId!==u&&an(C.p1,C.p2,y))return!0;return!1},"labelOverlapsForeignEdge"),h=f((u,i,y)=>l(u,y)||a(i,y),"labelOverlapsAnything"),m=[],M=f(u=>{for(const{id:i,rect:y}of s)if(ts(y,u))return i},"findContainingLane"),p=f((u,i)=>m.some(y=>y.labelId!==u&&Ze(i,y.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const i=u.labelNodeId;if(!i)continue;const y=e.get(i);if(!y)continue;const C=u.points;if(!C||C.length<2)continue;const b=y.width??0,S=y.height??0;if(b<=0||S<=0)continue;const w=[];for(let nt=0;nt<C.length-1;nt++){const J=C[nt],rt=C[nt+1],ut=Math.abs(J.x-rt.x),pt=Math.abs(J.y-rt.y);ut<Qt&&pt<Qt||ut>=Qt&&pt>=Qt||w.push({idx:nt,length:ut+pt,orientation:ut>=Qt?"horizontal":"vertical",midX:(J.x+rt.x)/2,midY:(J.y+rt.y)/2})}if(w.length===0)continue;const I=w.length>=3?w.filter(nt=>nt.idx>0&&nt.idx<w.length-1):w,x=I.length>0?I:w,L=b>=S?"horizontal":"vertical",R=f(nt=>[...nt].sort((J,rt)=>{const ut=J.orientation===L,pt=rt.orientation===L;if(ut!==pt)return ut?-1:1;const St=J.length>=(J.orientation==="horizontal"?b:S)+2,At=rt.length>=(rt.orientation==="horizontal"?b:S)+2;return St!==At?St?-1:1:rt.length-J.length}),"rankSegments"),F=w[0],A=w[w.length-1],P=[.5,.25,.75,.05,.95,.15,.85,.1,.9],k=f((nt,J)=>{const rt=C[nt.idx],ut=C[nt.idx+1];return{midX:rt.x+(ut.x-rt.x)*J,midY:rt.y+(ut.y-rt.y)*J}},"anchorAtT"),B=f((nt,J,rt)=>Math.min(rt,Math.max(J,nt)),"clamp"),X=f((nt,J)=>nt.midX>
1=J.left-Qt&&nt.midX<=J.right+Qt&&nt.midY>=J.top-Qt&&nt.midY<=J.bottom+Qt,"pointInsideRectInclusive"),G=f(nt=>{const J=Be(nt.midX,nt.midY,b,S),rt=M(J);if(rt)return{laneId:rt,anchor:nt,rect:J};const ut=s.find(({rect:se})=>X(nt,se));if(!ut)return;const pt=ut.rect.left+b/2+c,St=ut.rect.right-b/2-c,At=ut.rect.top+S/2+c,Kt=ut.rect.bottom-S/2-c;if(pt>St||At>Kt)return;const qt={midX:B(nt.midX,pt,St),midY:B(nt.midY,At,Kt)},Jt=Be(qt.midX,qt.midY,b,S);return X(nt,Jt)?{laneId:ut.id,anchor:qt,rect:Jt}:void 0},"placementForAnchor"),Z=f((nt,J,rt)=>nt.orientation==="horizontal"?Math.abs(J.midX-rt.x):Math.abs(J.midY-rt.y),"distanceAlongSegment"),ct=f((nt,J)=>{const ut=(nt.orientation==="horizontal"?b/2:S/2)+d;if(nt===F){const pt=C[nt.idx];if(Z(nt,J,pt)+Qt<ut)return!1}if(nt===A){const pt=C[nt.idx+1];if(Z(nt,J,pt)+Qt<ut)return!1}return!0},"labelClearsTerminalEndpoints"),Mt=f(nt=>{const J=R(nt);for(const rt of J)for(const ut of P){const pt=k(rt,ut);if(!ct(rt,pt))continue;const St=G(pt);if(St&&!Un(St.rect,C)&&!p(i,St.rect)&&!h(i,u.id,St.rect))return{laneId:St.laneId,anchor:St.anchor}}},"tryPool"),Ft=f((nt,J,rt=!1)=>{const ut=R(nt);for(const pt of ut){const St={midX:pt.midX,midY:pt.midY};if(J&&!ct(pt,St))continue;const At=G(St);if(At&&!Un(At.rect,C)&&!p(i,At.rect)&&!l(i,At.rect)&&(rt||!a(u.id,At.rect)))return{laneId:At.laneId,anchor:At.anchor}}},"findLaneContainingFallback"),Dt=Mt(x)??(x.length<w.length?Mt(w):void 0)??Ft(w,!0)??Ft(w,!1)??Ft(w,!1,!0);if(Dt){y.x=Dt.anchor.midX,y.y=Dt.anchor.midY,y.parentId=Dt.laneId;const nt=Be(Dt.anchor.midX,Dt.anchor.midY,b,S),J=m.findIndex(rt=>rt.labelId===i);J>=0?m[J]={labelId:i,rect:nt}:m.push({labelId:i,rect:nt})}}}f(Ke,"anchorLabelsToPolyline");var Cn=1e-6,Pr=8,ko=Pr/2,kr=3;function jn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}f(jn,"pairKey");function Ts(t,e){const{nodeInfoById:n,realNodeRects:o}=ln(e),s=new Map;for(const c of e){const d=c.id;if(!c.isGroup&&c.isEdgeLabel){s.set(d,{w:c.width??0,h:c.height??0});continue}}const r=f((c,d,l,a)=>{const h=jn(d,l);let m=0;const M=f(p=>{if(!p)return;const u=s.get(p);if(!u)return;const i=a==="x"?u.w/2:u.h/2;i>m&&(m=i)},"consider");M(c.labelNodeId);for(const p of t){if(p===c||p.isLayoutOnly)continue;const u=p.start,i=p.end;!u||!i||jn(u,i)===h&&M(p.labelNodeId)}return m>0?m+kr:0},"labelClearanceFor");for(const c of t){if(c.isLayoutOnly)continue;const d=c.points;if(!co(d,Cn))continue;const l=uo(c,n,Cn);if(!l)continue;const{srcId:a,dstId:h,srcInfo:m,dstInfo:M,collinearX:p,collinearY:u}=l;if(p===u)continue;let i,y;if(p){const I=M.cy>m.cy;i={x:m.cx,y:I?m.rect.bottom:m.rect.top},y={x:M.cx,y:I?M.rect.top:M.rect.bottom}}else{const I=M.cx>m.cx;i={x:I?m.rect.right:m.rect.left,y:m.cy},y={x:I?M.rect.left:M.rect.right,y:M.cy}}if(Bt(i,y,o,[a,h],1))continue;const b=r(c,a,h,p?"x":"y"),S=b>ko?b:ko,w=[0,S,-S];for(const I of w){const x={...i},L={...y};if(p){if(x.x+=I,L.x+=I,x.x<=m.rect.left||x.x>=m.rect.right||L.x<=M.rect.left||L.x>=M.rect.right)continue}else if(x.y+=I,L.y+=I,x.y<=m.rect.top||x.y>=m.rect.bottom||L.y<=M.rect.top||L.y>=M.rect.bottom)continue;if(!Bt(x,L,o,[a,h],1)&&!Qe(x,L,t,c,{epsilon:Cn})){c.points=[x,L];break}}}}f(Ts,"straightenCollinearSiblingDetours");function Wn(t,e){const{realNodeRects:a,labelNodeRects:h}=Me(e.values()),m=f((x,L)=>Fe(L,.001).map(R=>({...R,edge:x,interior:R.index>=1&&R.index<=L.length-3})),"segmentsFor"),M=f(()=>{const x=[];for(const L of t){if(L.isLayoutOnly)continue;const R=L.points;!R||R.length<2||x.push(...m(L,xt(R)))}return x},"allSegments"),p=f((x,L)=>x.horizontal&&L.horizontal?Wt(x.a.x,x.b.x,L.a.x,L.b.x)>=8&&Math.abs(x.a.y-L.a.y)<7:x.vertical&&L.vertical?Wt(x.a.y,x.b.y,L.a.y,L.b.y)>=8&&Math.abs(x.a.x-L.a.x)<7:!1,"hasCrowdedParallelTrack"),u=f((x,L)=>{const R=x.start,F=x.end,A=m(x,L);if(A.length!==L.length-1)return!1;const P=[R,F].filter(B=>!!B),k=x.labelNodeId?[x.labelNodeId]:[];for(const B of A)if(Bt(B.a,B.b,a,P,-2)||Bt(B.a,B.b,h,k,-2))return!1;for(const B of t){if(B===x||B.isLayoutOnly)continue;const X=B.points;if(!(!X||X.length<2)){for(const G of A)for(const Z of m(B,xt(X)))if(p(G,Z)||he(G.a,G.b,Z.a,Z.b,.001))return!1}}return!0},"candidateIsSafe"),i=f((x,L)=>{const R=xt(x.edge.points??[]);if(R.length<4||x.index>=R.length-1)return;const F=R.map(A=>({...A}));if(x.horizontal)F[x.index].y+=L,F[x.index+1].y+=L;else if(x.vertical)F[x.index].x+=L,F[x.index+1].x+=L;else return;return m(x.edge,F).length===F.length-1?F:void 0},"shiftedCandidate"),y=f((x,L)=>({x:x.x??(L.left+L.right)/2,y:x.y??(L.top+L.bottom)/2}),"nodeCenter"),C=f(x=>{const L=x.edge,R=xt(L.points??[]);if(R.length!==4||x.index!==1)return;const F=L.start?e.get(L.start):void 0,A=L.end?e.get(L.end):void 0,P=F?te(F):void 0,k=A?te(A):void 0,B=R.slice(
1x.index+2);if(!(!F||!A||!P||!k||B.length===0))return{sourceCenter:y(F,P),targetCenter:y(A,k),sourceRect:P,tail:B}},"sourceDetourContextFor"),b=f((x,L,R,F,A,P)=>{const k=F.y>=R.y,B=k?A.bottom:A.top,X=B+(k?20:-20);if(k&&x.b.y<=X+.001||!k&&x.b.y>=X-.001)return;const G=x.a.x+L;return xt([{x:R.x,y:B},{x:R.x,y:X},{x:G,y:X},{x:G,y:x.b.y},...P],.001)},"verticalSourceDetour"),S=f((x,L,R,F,A,P)=>{const k=F.x>=R.x,B=k?A.right:A.left,X=B+(k?20:-20);if(k&&x.b.x<=X+.001||!k&&x.b.x>=X-.001)return;const G=x.a.y+L;return xt([{x:B,y:R.y},{x:X,y:R.y},{x:X,y:G},{x:x.b.x,y:G},...P],.001)},"horizontalSourceDetour"),w=f((x,L)=>{const R=C(x);if(R){if(x.vertical)return b(x,L,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail);if(x.horizontal)return S(x,L,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail)}},"sourceDetourCandidate"),I=[-7,7,-2*7,2*7,-3*7,3*7];for(let x=0;x<12;x++){const L=M();let R=!1;for(let F=0;F<L.length&&!R;F++)for(let A=F+1;A<L.length&&!R;A++){const P=L[F],k=L[A];if(P.edge===k.edge||!p(P,k))continue;const B=[P,k].filter(X=>X.interior);for(const X of B){for(const G of I){const Z=i(X,G);if(Z&&u(X.edge,Z)){X.edge.points=Z,R=!0;break}const ct=w(X,G);if(ct&&u(X.edge,ct)){X.edge.points=ct,R=!0;break}}if(R)break}}if(!R)return}}f(Wn,"nudgeSharedInteriorSubpaths");function As(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=o.x-n.x,d=o.y-n.y,l=s*d-r*c;if(Math.abs(l)<1e-10)return!1;const a=n.x-t.x,h=n.y-t.y,m=(a*d-h*c)/l,M=(a*r-h*s)/l,p=.01;return m>p&&m<1-p&&M>p&&M<1-p}f(As,"segmentsIntersect");function ws(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=es(e),r=1,c=[];for(const l of n){if(l.isLayoutOnly)continue;const a=l.points;if(!a||a.length<2)continue;const h=l.start,m=l.end,M=l.labelNodeId,p=l.id??`${h}->${m}`;for(const u of s)if(!(u.nodeId===h||u.nodeId===m)&&!(M&&u.nodeId===M)){for(let i=0;i<a.length-1;i++)if(an(a[i],a[i+1],u,-r)){o.push({type:"edge-node-overlap",edgeId:p,targetId:u.nodeId,detail:`segment ${i} passes through node "${u.nodeId}"`});break}}for(let u=0;u<a.length-1;u++)c.push({edgeId:p,start:h,end:m,p1:a[u],p2:a[u+1]})}const d=new Set;for(let l=0;l<c.length;l++)for(let a=l+1;a<c.length;a++){const h=c[l],m=c[a];if(h.edgeId!==m.edgeId&&!(h.start===m.start||h.start===m.end||h.end===m.start||h.end===m.end)&&As(h.p1,h.p2,m.p1,m.p2)){const M=h.edgeId<m.edgeId?`${h.edgeId}|${m.edgeId}`:`${m.edgeId}|${h.edgeId}`;d.has(M)||(d.add(M),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:m.edgeId,detail:`edges "${h.edgeId}" and "${m.edgeId}" cross`}))}}if(o.length>0){const l=o.filter(h=>h.type==="edge-node-overlap").length,a=o.filter(h=>h.type==="edge-edge-crossing").length;Ln.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${l} edge-node overlap(s), ${a} edge crossing(s)`);for(const h of o)Ln.warn(`[SWIMLANE_VALIDATE]   ${h.type}: ${h.detail}`)}return o}f(ws,"validateSwimlanesLayout");function Rs(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(d=>!d.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!ys(t,e)||e==="BT"&&s.length>0&&!ms(t))return;for(const d of o){if(d.isLayoutOnly)continue;const l=d.points;!l||l.length<2||(d.points=ue(tn(l)))}Ls(o,n),Ts(o,n),ps(o,n);const r=new Map;for(const d of n)r.set(String(d.id),d);Ke(o,r),is(o,r),xs(o,r),Wn(o,r),bs(o,r),Ms(o,r),Gn(o,r),Is(o,r);const c=f(()=>{vs(o,r),Ss(o,r),Cs(o,r),Ke(o,r),Xn(o,r),Gn(o,r),Ke(o,r),Xn(o,r)},"finalizeRenderedEdges");c(),Wn(o,r),c(),$n(o,r),zn(o,r),$n(o,r),zn(o,r)}f(Rs,"postProcessSwimlaneLayout");function Ie(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const c=`${r.id}:${r.src}->${r.dst}`;n.has(c)||(n.add(c),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}f(Ie,"normalizeGraph");function xo(t,e){return t.edges.filter(n=>n.dst===e)}f(xo,"incoming");function Ns(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}f(Ns,"buildSuccessorMap");function bo(t){const e=Ns(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}f(bo,"buildSortedSuccessorMap");function Mo(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}f(Mo,"buildInDegreeMap");function Io(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}f(Io,"sortedZeroInDegreeNodes");function fn(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src
1));return{preds:n,succs:o}}f(fn,"buildPredecessorSuccessorMaps");function So(t,e,n,o){var c,d;let s=0;for(const l of t.nodes)o!=null&&o.skipGroups&&((c=t.nodeById.get(l))!=null&&c.isGroup)||(s=Math.max(s,n[l]??0));const r=Array.from({length:s+1},()=>[]);for(const l of e)o!=null&&o.skipGroups&&((d=t.nodeById.get(l))!=null&&d.isGroup)||r[Math.max(0,n[l]??0)].push(l);return r}f(So,"buildLayersFromRanks");function _e(t){const e=Mo(t),n=Io(e),o=[],s=bo(t);for(;n.length;){const r=n.shift();o.push(r);for(const c of s.get(r)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let d=0;for(;d<n.length&&n[d]<c;)d++;n.splice(d,0,c)}}return o.length===t.nodes.length?o:null}f(_e,"topoSortIfAcyclic");function Pe(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}f(Pe,"buildLayerIndex");function Co(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let c=n(o,r)+n(r,s),d=o,l=r,a=o;for(;d<r||l<s;)l>=s||d<r&&t[d]<=t[l]?e[a++]=t[d++]:(e[a++]=t[l++],c+=r-d);for(let h=o;h<s;h++)t[h]=e[h];return c},"count");return n(0,t.length)}f(Co,"countInversions");function Os(t){const e=Ie(t),n=new Map;for(const h of e.nodes)n.set(h,[]);for(const h of e.edges)n.get(h.src).push(h);for(const h of n.values())h.sort((m,M)=>m.dst===M.dst?m.id.localeCompare(M.id):m.dst.localeCompare(M.dst));const o=Object.create(null);for(const h of e.nodes)o[h]=0;const s=[],r=f(h=>{o[h]=1;for(const m of n.get(h)??[]){const M=m.dst;o[M]===0?r(M):o[M]===1&&s.push(m)}o[h]=2},"dfs"),c=[...e.nodes].sort((h,m)=>h.localeCompare(m));for(const h of c)o[h]===0&&r(h);const d=new Set(s.map(h=>`${h.id}:${h.src}->${h.dst}`)),l=e.edges.map(h=>d.has(`${h.id}:${h.src}->${h.dst}`)?{id:h.id,src:h.dst,dst:h.src,weight:h.weight,ref:h.ref}:h);return{acyclic:{nodes:[...e.nodes],edges:l,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}f(Os,"removeCycles_DFS");function Bs(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const d=n(r)??r;return e.set(o,d),d},"resolve");for(const o of t.nodes)n(o);return e}f(Bs,"buildTopLaneMap");function ge(t){const e=Bs(t);return n=>e.get(n)??null}f(ge,"createTopLaneResolver");function dn(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}f(dn,"buildTopLaneOrder");function vo(t,e){const n=dn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const c of e)!o.has(c)||s.has(c)||(s.add(c),r.push(c));for(const c of n)s.has(c)||r.push(c);return r}f(vo,"resolveTopLaneOrder");var _r={EPSILON:1e-6},rn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},_o={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Fs(t,e){const n=Ie(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=fn(n);for(const I of r.values())I.sort((x,L)=>x.localeCompare(L));const c=_e(n)??[...n.nodes].sort((I,x)=>I.localeCompare(x)),d=new Map;for(const[I,x]of c.entries())d.set(x,I);const l=new Map,a=new Map;for(const I of n.nodes)a.set(I,[]);for(const I of c){const x=(r.get(I)??[]).filter(L=>l.has(L));if(x.length>0){const L=Ps(I,x,{laneOf:o,rankHint:s,topoIndex:d});l.set(I,L),a.get(L).push(I)}else l.has(I)||l.set(I,null)}for(const I of n.nodes)l.has(I)||l.set(I,null);const h=new Set;for(const I of n.nodes)(l.get(I)??null)===null&&h.add(I);const m=[...h].sort((I,x)=>{const L=d.get(I)??0,R=d.get(x)??0;return L===R?I.localeCompare(x):L-R}),M=ks(n),p=new Map;for(const[I,x]of M.entries())p.set(I,[...x].sort((L,R)=>L.localeCompare(R)));const u=_s(p),i=Ds(p),y=new Map;for(const I of n.nodes)y.set(I,[]);for(const I of i)for(const x of I.nodes){const L=y.get(x);L?L.push(I.id):y.set(x,[I.id])}const C=[],b=[],S=new Set,w=f(I=>{if(!S.has(I)){S.add(I),C.push(I);for(const x of a.get(I)??[])w(x);b.push(I)}},"walk");for(const I of m)w(I);for(const I of c)w(I);return{parent:l,children:a,roots:m,componentOf:u,blocks:i,nodeBlocks:y,adjacency:p,preorder:C,postorder:b,topologicalOrder:c}}f(Fs,"buildDrivingTree");function Ps(t,e,n){const o=n.laneOf(t);return[...e].sort((r,c)=>{var i,y;const d=n.laneOf(r),l=n.laneOf(c),a=d!=null&&d===o,h=l!=null&&l===o;if(a!==h)return a?-1:1;const m=(i=n.rankHint)==null?void 0:i[r],M=(y=n.rankHint)==null?void 0:y[c];if(m!=null&&M!=null&&m!==M)return M-m;const p=n.topoIndex.get(r)??0,u=n.topoIndex.get(c)??0;return p!==u?p-u:r.localeCompare(c)})[0]}f(Ps,"chooseParent");function ks(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}f(ks,"buildAdjacency");function _s(t){const e=new Map;let n=0;
1for(const o of t.keys()){if(e.has(o))continue;const s=[o];for(;s.length>0;){const r=s.pop();if(!e.has(r)){e.set(r,n);for(const c of t.get(r)??[])e.has(c)||s.push(c)}}n++}return e}f(_s,"assignComponents");function Ds(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const c=f((d,l)=>{e.set(d,++r),n.set(d,r);for(const a of t.get(d)??[])a!==l&&(e.has(a)?(e.get(a)??0)<(e.get(d)??0)&&(o.push([d,a]),n.set(d,Math.min(n.get(d)??r,e.get(a)??r))):(o.push([d,a]),c(a,d),n.set(d,Math.min(n.get(d)??r,n.get(a)??r)),(n.get(a)??0)>=(e.get(d)??0)&&s.push(Hs(d,a,o,s.length))))},"visit");for(const d of t.keys())e.has(d)||c(d,null);return s}f(Ds,"computeBlocks");function Hs(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const c=n.pop();if(s.push(c),r.add(c[0]),r.add(c[1]),c[0]===t&&c[1]===e||c[0]===e&&c[1]===t)break}return{id:o,edges:s,nodes:[...r]}}f(Hs,"popBlock");function Xs(t,e,n){const o=[...t.nodes],s=new Map;for(const[b,S]of o.entries())s.set(S,b);const r=o.length,c=new Array(r).fill(-1),d=new Array(r).fill(0),l=[],a=new Set;for(const b of o){const S=n.parent.get(b)??null,w=s.get(b);w!=null&&S==null&&(c[w]=-1,d[w]=0,a.has(b)||(a.add(b),l.push(b)))}for(;l.length>0;){const b=l.shift(),S=s.get(b);if(S==null)continue;const w=n.children.get(b)??[];for(const I of w){if(a.has(I))continue;const x=s.get(I);x!=null&&(c[x]=S,d[x]=d[S]+1,a.add(I),l.push(I))}}for(const b of o){if(a.has(b))continue;const S=s.get(b);S!=null&&(c[S]=-1,d[S]=0,a.add(b))}const h=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),m=Array.from({length:h},()=>new Array(r).fill(-1));for(let b=0;b<r;b++)m[0][b]=c[b];for(let b=1;b<h;b++)for(let S=0;S<r;S++){const w=m[b-1][S];m[b][S]=w===-1?-1:m[b-1][w]}const M=f((b,S)=>{if(b===-1||S===-1)return-1;d[b]<d[S]&&([b,S]=[S,b]);const w=d[b]-d[S];for(let I=0;I<h;I++)if(w>>I&1&&(b=m[I][b],b===-1))return-1;if(b===S)return b;for(let I=h-1;I>=0;I--){const x=m[I][b],L=m[I][S];x===-1||L===-1||x!==L&&(b=x,S=L)}return m[0][b]},"lcaIndex"),p=Array.from({length:r},()=>new Map);for(const b of t.edges){let S=b.src,w=b.dst,I=e[S],x=e[w];if(I==null||x==null||(I>x&&([S,w]=[w,S],[I,x]=[x,I]),I==null||x==null||I===x))continue;const L=s.get(S),R=s.get(w);if(L==null||R==null)continue;const F=M(L,R);if(F===-1)continue;const A=p[F];for(let P=I;P<x;P++)A.set(P,(A.get(P)??0)+1)}const u=new Map,i=f((b,S)=>{if(S.size!==0)for(const[w,I]of S)b.set(w,(b.get(w)??0)+I)},"mergeInto"),y=new Set,C=f(b=>{const S=s.get(b);y.add(b);const w=S==null?void 0:p[S],I=w?new Map(w):new Map,x=n.children.get(b)??[];for(const L of x){const R=C(L),F=e[b];if(F!=null){let A=u.get(b);A||(A=new Map,u.set(b,A));let P=R.get(F)??0;const k=e[L];k!=null&&k>F&&(P+=1),A.set(L,P)}i(I,R)}return I},"dfs");for(const b of n.roots)y.has(b)||C(b);for(const b of o)y.has(b)||C(b);return u}f(Xs,"computeSubtreeCrossCounts");function Ys(t,e,n){const o=new Map,s=f(r=>{let c=n[r]??0;const d=[...e.get(r)??[]];d.sort(Lo(n));for(const l of d){s(l);const a=o.get(l);a!=null&&(c=Math.min(c,a))}o.set(r,c)},"annotate");for(const r of t)s(r);return o}f(Ys,"annotateMinimumLayers");function Lo(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}f(Lo,"compareByRankThenId");function Gs(t,e,n,o){let s=0;for(const l of e){const a=n[l]??0;a>s&&(s=a)}const r=Array.from({length:s+1},()=>[]),c=new Set,d=f(l=>{if(c.has(l))return;c.add(l);const a=n[l]??0;r[a]||(r[a]=[]),r[a].push(l);for(const h of o(l))d(h)},"emit");for(const l of t)d(l);for(const l of e)if(!c.has(l)){const a=n[l]??0;r[a]||(r[a]=[]),r[a].push(l),c.add(l)}return r}f(Gs,"emitNodesInTreeOrder");function $s(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}f($s,"deduplicateLayers");function zs(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const c=e[s]??0,d=[],l=[],a=n.get(s);for(const h of r){const m=o.get(h)??c;m>c?d.push({child:h,min:m}):l.push(h)}return d.sort((h,m)=>h.min===m.min?h.child.localeCompare(m.child):h.min-m.min),l.sort((h,m)=>{const M=(a==null?void 0:a.get(h))??0,p=(a==null?void 0:a.get(m))??0;if(M!==p)return M-p;const u=o.get(h)??c,i=o.get(m)??c;return u!==i?u-i:h.localeCompare(m)}),[...d.map(h=>h.child),...l]}}f(zs,"createChildOrderer");function cn(t,e,n){const o=Fs(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const m of t.nodes)s.has(m)||s.set(m,[]);const c=Xs(t,e,o),d=[...r].sort(Lo(e)),l=Ys(d,s,e),a=zs(s,e,c,l);let h=Gs(d,t.nodes,e,a);return h=$s(h),h}f(cn,"buildMultitreeLayerOrder");function Vs(t,e,n){const o=new Set(t),s=new Set(e),r=Pe(e),c=[];for(const d of n)o.has(d.src)&&s.has(d.dst)&&c.push(r.get(d.dst));return Co(c)}f(Vs,"countCrossingsBetweenAdjacent");function Kn(t,e,n){const o=[];for(const r of e){const c=n[r.src],d=n[r.dst];if(c==null||d==null||c===d)continue;let l=r.src,a=r.dst,h=c,m=d;c>d&&(l=r.dst,a=r.src,h=d,m=c);for(let M=h;M<m;M++)o.push({id:`${r.id}@${M}`,src:l,dst:a,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Vs(t[r],t[r+1],o);return s}f(Kn,"totalCrossings");function Us(t,e){const n={...e},{preds:o}=fn(t),s=ge(t),r=cn(t,n,s);let c=Kn(r,t.edges,n);const d=rn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let l=0;l<d;l++){let a=!1;
1const h=[...t.nodes].sort((m,M)=>(n[M]??0)-(n[m]??0));for(const m of h){const M=n[m]??0;if(M===0)continue;let p=0;for(const C of o.get(m)??[])p=Math.max(p,(n[C]??0)+1);if(p>=M)continue;const u=M;n[m]=p;const i=cn(t,n,s),y=Kn(i,t.edges,n);y<c?(c=y,a=!0):n[m]=u}if(!a)break}return n}f(Us,"optimizeRanksByCrossings");function js(t,e){const n=ge(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const c=t.edges.filter(i=>i.src===s);if(c.length===0)continue;let d=!1,l=0;for(const i of c){const y=n(i.dst);y==null||y===r?d=!0:l++}if(l===0||d)continue;let a=0,h=!1;for(const i of t.edges){if(i.dst!==s)continue;const y=n(i.src);y&&(y===r?h=!0:a++)}if(a>0||!h)continue;const m=e[s]??0,M=m+l;let p=0;for(const i of t.edges)i.dst===s&&(p=Math.max(p,(e[i.src]??0)+1));const u=Math.max(m,p,M);u!==m&&(e[s]=u)}}f(js,"adjustCrossLaneSources");function Ws(t,e){const n=Ie(t),o=_e(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=ge(n);let c=Object.create(null);for(const l of o){const a=xo(n,l),h=e!=null&&e.ignoreCrossLaneEdges?a.filter(m=>{const M=r(m.src),p=r(l);return!M||!p?!0:M===p}):a;if(h.length===0)c[l]=0;else if(s&&h.length===1){const m=h[0].src,M=r(m),p=r(l);M!==p?c[l]=c[m]??0:c[l]=(c[m]??0)+1}else{let m=-1/0;for(const M of h)m=Math.max(m,(c[M.src]??0)+1);c[l]=m===-1/0?0:m}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(c=Us(n,c)),e!=null&&e.ignoreCrossLaneEdges&&js(n,c),{layers:cn(n,c,r),rankOf:c,dummy:new Set}}f(Ws,"assignLayers_LongestPath");function Ks(t,e){const n=Ie(t),s={...Ws(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=ge(n),{preds:c,succs:d}=fn(n,u=>{if(e!=null&&e.ignoreCrossLaneEdges){const i=r(u.src),y=r(u.dst);if(i&&y&&i!==y)return!1}return!0}),l=_e(n)??[...n.nodes],a=[...l].reverse(),h=f((u,i)=>{let y=0;for(const S of c.get(u)??[])y=Math.max(y,(s[S]??0)+1);let C=Number.POSITIVE_INFINITY;const b=d.get(u)??[];return b.length>0&&(C=Math.min(...b.map(S=>(s[S]??0)-1))),Number.isFinite(C)||(C=Math.max(y,i)),Math.min(Math.max(i,y),C)},"clampFeasible"),m=rn.GRAVITY_ITERATIONS,M=f(u=>{let i=!1;for(const y of u){const C=c.get(y)??[],b=d.get(y)??[];if(C.length===0&&b.length===0)continue;const S=C.length>0?C.reduce((L,R)=>L+(s[R]??0)+1,0)/C.length:s[y]??0,w=b.length>0?b.reduce((L,R)=>L+(s[R]??0)-1,0)/b.length:s[y]??0,I=Math.round((S+w)/2),x=h(y,I);x!==s[y]&&(s[y]=x,i=!0)}return i},"relaxOrder");for(let u=0;u<m;u++){const i=M(l),y=M(a);if(!i&&!y)break}for(const u of l){let i=0;for(const y of c.get(u)??[])i=Math.max(i,(s[y]??0)+1);(s[u]??0)<i&&(s[u]=i)}for(const u of a){const i=d.get(u)??[];if(i.length>0){const y=Math.min(...i.map(C=>(s[C]??0)-1));(s[u]??0)>y&&(s[u]=y)}}return{layers:So(n,l,s),rankOf:s,dummy:new Set}}f(Ks,"assignLayers_Gravity");function qs(t){const e=Mo(t),n=bo(t);let o=Io(e);const s=[];for(;o.length>0;){const r=[];for(const c of o){s.push(c);for(const d of n.get(c)??[])e.set(d,(e.get(d)??0)-1),(e.get(d)??0)===0&&r.push(d)}o=r.sort((c,d)=>c.localeCompare(d))}return s.length===t.nodes.length?s:null}f(qs,"topoSortByGenerationIfAcyclic");function Js(t,e){const n=Ie(t),o=(e==null?void 0:e.direction)==="LR"?qs(n)??[...n.nodes].sort():_e(n)??[...n.nodes].sort(),s=ge(n),r=f(h=>s(h)??h,"laneOf"),c=Object.create(null),d=new Map,l=f((h,m)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(h)===r(m)?1:0:1,"edgeWeight");for(const h of o){const m=n.nodeById.get(h);if(m!=null&&m.isGroup)continue;const M=xo(n,h);let p=0;if(M.length>0)for(const C of M){const b=C.src,S=c[b]??0;p=Math.max(p,S+l(b,h))}const u=r(h),i=d.get(u)??0,y=Math.max(p,i);c[h]=y,d.set(u,y+1)}return{layers:So(n,o,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}f(Js,"assignLayers_LaneAwareCompact");function Zs(t,e){const n=Ie(e),{rankOf:o}=t,s=t.layers.map(p=>[...p]),r=new Set(t.dummy?[...t.dummy]:[]);let c=0;const d=new Map(n.nodeById),l=f(p=>{const u=`placeholder-${c++}`,i={id:u,isGroup:!1,isDummy:!0,width:0,height:0};for(d.set(u,i),r.add(u);s.length<=p;)s.push([]);
1return s[p].push(u),o[u]=p,u},"addDummyAt"),a=[...n.edges].sort((p,u)=>p.id===u.id?p.src===u.src?p.dst.localeCompare(u.dst):p.src.localeCompare(u.src):p.id.localeCompare(u.id)),h=[];for(const p of a){const u=o[p.src]??0,i=o[p.dst]??0;if(i-u<=1){h.push(p);continue}let y=p.src;for(let b=u+1,S=0;b<i;b++,S++){const w=l(b);h.push({id:`${p.id}#${S}`,src:y,dst:w,weight:p.weight,ref:p.ref}),y=w}const C=i-u-2;h.push({id:`${p.id}#${Math.max(C+1,0)}`,src:y,dst:p.dst,weight:p.weight,ref:p.ref})}const M={nodes:[...n.nodes,...[...r].filter(p=>!n.nodes.includes(p))],edges:h,layout:n.layout,nodeById:d};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:M}}f(Zs,"makeProperLayering");function qn(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}f(qn,"median");function Jn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}f(Jn,"barycenter");function Qs(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}f(Qs,"neighborPositionsFor");function tr(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}f(tr,"currentOrderTieBreak");function Zn(t,e,n){const o=new Set(t),s=new Set(e),r=Pe(t),c=Pe(e),d=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&d.push({u:r.get(a.src),v:c.get(a.dst)});d.sort((a,h)=>a.u===h.u?a.v-h.v:a.u-h.u);const l=d.map(a=>a.v);return Co(l)}f(Zn,"countCrossingsBetweenAdjacent");function qe(t,e,n){return[...t].sort((o,s)=>{const r=qn(e.get(o)??[]),c=qn(e.get(s)??[]);return r===c?tr(o,s,n):isFinite(r)?isFinite(c)?r-c:-1:1})}f(qe,"sortByHeuristic");function Qn(t,e,n,o,s,r){const c=Pe(t),d=Pe(e),l=Qs(e,c,n,o);if(!s||!r||r.length===0)return qe(e,l,d);const a=new Map;for(const M of e){const p=s(M),u=a.get(p)??[];u.push(M),a.set(p,u)}const h=[];for(const M of r){const p=a.get(M);if(!p||p.length===0)continue;const u=qe(p,l,d);h.push(...u)}const m=a.get(null);if(m&&m.length>0){const M=qe(m,l,d);for(const p of M){const u=Jn(l.get(p)??[]);let i=h.length;if(isFinite(u))for(const[y,C]of h.entries()){const b=Jn(l.get(C)??[]);if(u<b){i=y;break}}h.splice(i,0,p)}}return h}f(Qn,"reorderLayer");function to(t,e,n,o,s){const r=[...e],c=new Set(t),d=new Set(e),l=o?new Set(o):null,a=n.filter(i=>c.has(i.src)&&d.has(i.dst)),h=l?n.filter(i=>d.has(i.src)&&l.has(i.dst)):void 0,m=f(i=>{let y=Zn(t,i,a);return h&&o&&(y+=Zn(i,o,h)),y},"crossingScore"),M=s?new Map:null;if(s&&M)for(const i of e)M.set(i,s(i));let p=!0,u=m(r);for(;p;){p=!1;for(let i=0;i+1<r.length;i++){if(M){const b=M.get(r[i]),S=M.get(r[i+1]);if(b!==S)continue}const y=u;[r[i],r[i+1]]=[r[i+1],r[i]];const C=m(r);C<y?(u=C,p=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}}return r}f(to,"transposeImprove");function er(t,e,n){const o=t.layers.map(d=>[...d]),s=e.edges,r=ge(e),c=vo(e,n==null?void 0:n.laneOrder);for(let d=0;d<3;d++){for(let l=1;l<o.length;l++)o[l]=Qn(o[l-1],o[l],s,"down",r,c),o[l]=to(o[l-1],o[l],s,o[l+1],r);for(let l=o.length-2;l>=0;l--)o[l]=Qn(o[l+1],o[l],s,"up",r,c),o[l]=to(o[l+1],o[l],s,o[l-1],r)}return{layers:o}}f(er,"orderLayers");function nr(t,e,n){const o=(n==null?void 0:n.layerGap)??_o.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??_o.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,c=(n==null?void 0:n.direction)??"TB",d=c==="LR"||c==="RL",l=t.layers,a=Object.create(null),h=Object.create(null),m=f(A=>e.nodeById.get(A),"getNode"),M=f(A=>{var P;return((P=m(A))==null?void 0:P.width)??0},"getWidth"),p=f(A=>{var P;return((P=m(A))==null?void 0:P.height)??0},"getHeight"),u=ge(e),i=vo(e,n==null?void 0:n.laneOrder),y=l.map(A=>A.reduce((P,k)=>Math.max(P,p(k)),0)),C=[];if(d)for(let A=0;A+1<l.length;A++){const P=l[A].reduce((Mt,Ft)=>Math.max(Mt,M(Ft)),0),k=l[A+1].reduce((Mt,Ft)=>Math.max(Mt,M(Ft)),0),B=y[A],X=y[A+1],G=B/2+X/2,Z=(P+k)/2,ct=Math.max(0,Z-G-o);C.push(ct)}const b=new Set;for(const A of l)for(const P of A)b.add(u(P));const S=b.has(null),w=i.filter(A=>b.has(A)),I=[...S?[null]:[],...w],x=Object.create(null);for(const A of w)x[A]=0;S&&(x.null=0);for(const A of l){const P=Object.create(null),k=[];for(const B of A){const X=u(B);X===null?k.push(B):(P[X]||(P[X]=[])).push(B)}for(const[B,X]of Object.entries(P)){const G=X.reduce((Z,ct)=>Z+M(ct),0)+s*Math.max(0,X.length-1);x[B]=Math.max(x[B]??0,G)}if(S&&k.length){const B=k.reduce((X,G)=>X+M(G),0)+s*Math.max(0,k.length-1);x.null=Math.max(x.null??0,B)}}const L=new Map;{const A=I.map(B=>(B===null?x.null:x[B])??0);let k=-(A.reduce((B,X)=>B+X,0)+r*Math.max(0,I.length-1))/2;for(let B=0;B<I.length;B++){const X=I[B],G=A[B]??0,Z=k+G/2;L.set(X,Z),k+=G,B<I.length-1&&(k+=r)}}let R=0;for(const[A,P]of l.entries()){const k=y[A]??0,B=new Map;for(const G of P){const Z=u(G),ct=B.get(Z)??[];ct.push(G),B.set(Z,ct)}for(const G of I){const Z=B.get(G)??[];if(Z.length===0)continue;const ct=L.get(G);if(Z.length===1){const Mt=Z[0];a[Mt]=ct,h[Mt]=R+k/2}else{const Mt=Z.map(nt=>M(nt)),Ft=Mt.reduce((nt,J)=>nt+J,0)+s*(Z.length-1);let Dt=ct-Ft/2;for(const[nt,J]of Z.entries()){const rt=Mt[nt];a[J]=Dt+rt/2,h[J]=R+k/2,Dt+=rt+s}}}const X=C[A]??0;R+=k+o+X}const F=new Map;for(const A of e.edges){const P=A.ref.id;F.has(P)||F.set(P,[]),F.get(P).push(A)}for(const[,A]of F){if(A.length===0)continue;const P=A[0].ref,k=P.start,B=P.end;if(k==null||B==null)continue;const X=Math.round(((a[k]??0)+(a[B]??0))/2),G=new Set;for(const Z of A)G.add(Z.src),G.add(Z.dst);for(const Z of G){if(Z===k||Z===B)continue;const ct=e.nodeById.get(Z);ct!=null&&ct.isDummy&&(a[Z]=X)}}return{x:a,y:h}}f(nr,"assignCoordinates");var or=8;function sr(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}f(sr,"hashString");function rr(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}f(rr,"mulberry32");function ir(t,e){const n=[...t],o=rr(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}f(ir,"deterministicShuffle");function cr(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}f(cr,"sourceDistance");function eo(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:c}of e){const d=n.get(s),l=n.get(r);d==null||l==null||(o+=c*Math.abs(d-l))}return o}f(eo,"laneArrangementCost");function ar(t){const e=dn(t);
1if(e.length<2)return[];const n=new Map(e.map((r,c)=>[r,c])),o=ge(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const c=typeof r.start=="string"?r.start:void 0,d=typeof r.end=="string"?r.end:void 0;if(!c||!d||!t.nodeById.has(c)||!t.nodeById.has(d))continue;const l=o(c),a=o(d);if(!l||!a||l===a)continue;const h=n.get(l),m=n.get(a);if(h==null||m==null)continue;const[M,p]=h<=m?[l,a]:[a,l],u=`${M}\0${p}`,i=s.get(u);i?i.weight++:s.set(u,{a:M,b:p,weight:1})}return[...s.values()]}f(ar,"buildWeightedLaneEdges");function no(t,e,n){const o=[...t];let s=eo(o,e),r=!0,c=0;const d=Math.max(1,o.length);for(;r&&c<d;){r=!1,c++;for(let l=0;l+1<o.length;l++){[o[l],o[l+1]]=[o[l+1],o[l]];const a=eo(o,e);a<s?(s=a,r=!0):[o[l],o[l+1]]=[o[l+1],o[l]]}}return{order:o,cost:s,sourceDistance:cr(o,n)}}f(no,"greedySwitch");function lr(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}f(lr,"isBetterCandidate");function fr(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:c})=>`${s}:${r}:${c}`).join("|");return sr(`${t.join("|")}#${o}#${n}`)}f(fr,"seedForRestart");function dr(t,e={}){const n=dn(t);if(n.length<2)return n;const o=ar(t);if(o.length===0)return n;const s=new Map(n.map((d,l)=>[d,l]));let r=no(n,o,s);const c=Math.max(0,e.restarts??or);for(let d=0;d<c;d++){const l=fr(n,o,d),a=ir(n,l),h=no(a,o,s);lr(h,r)&&(r=h)}return r.order}f(dr,"optimizeTopLaneOrder");function ur(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=Ie(t),r=e!=null&&e.automaticLaneOrdering?dr(s,{restarts:or}):void 0,c=Os(s),d=c.acyclic,l=n?Js(d,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??rn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Ks(d,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??rn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:a,graphWithDummies:h}=Zs(l,d),m=er(a,h,{laneOrder:r}),M=nr(m,h,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:d,reversed:c.reversed,layering:a,ordered:m,coordinates:M}}f(ur,"sugiyamaLayout");var ft=_r.EPSILON,Dr=8,Ce=15,Ne=15,We=25,ie=20,vn=10;function oo(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,c=e.y-s,d=Math.abs(r),l=Math.abs(c);return d<ft&&l<ft?n:l>ft&&l*3>=d?c>0?"bottom":"top":d>ft?r>0?"right":"left":n}f(oo,"chooseOrthogonalSide");function so(t,e){return Math.abs(t.to-e.from)<ft||Math.abs(t.to-e.to)<ft?t.to:t.from}f(so,"sharedLineEndpointCoord");function ve(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}f(ve,"pointOnLine");function hr(t,e){var K,Q,$,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const g of o)g.isLayoutOnly||s.push({...g,__originalEdge:g});const r=new Map,c=new Map,d=[],l=e==="LR";for(const g of n)r.set(g.id,g);const a=n.filter(g=>g.isGroup&&!g.parentId);for(const g of a){const v={id:g.id},T=f(E=>{c.set(E.id,v),n.filter(O=>O.parentId===E.id).forEach(T)},"assignLane");T(g)}const h=n.filter(g=>!g.isGroup&&!g.isEdgeLabel).map(g=>{const v=g.width??10,T=g.height??10,E=g.x??0,O=g.y??0,H=Dr;return{nodeId:g.id,minX:E-v/2-H,maxX:E+v/2+H,minY:O-T/2-H,maxY:O+T/2+H,visualXHalfExtent:l?T/2+H:v/2+H}}),m=f((g,v,T,E)=>{let O=d.find(H=>H.orientation===g&&Math.abs(H.coord-v)<1);return O||(O={id:`pipe-${g}-${v.toFixed(0)}`,orientation:g,coord:v,spanMin:T,spanMax:E,tracks:[]},d.push(O)),O.spanMin=Math.min(O.spanMin,T),O.spanMax=Math.max(O.spanMax,E),O},"getOrAddPipe"),M=f((g,v)=>{const T=g.width??10,E=g.height??10,O=g.x??0,H=g.y??0;switch(v){case"top":return{x:O,y:H-E/2};case"bottom":return{x:O,y:H+E/2};case"left":return{x:O-T/2,y:H};case"right":return{x:O+T/2,y:H}}},"portForSide"),p=f((g,v,T)=>M(g,oo(g,v,T?"bottom":"top")),"getOrthogonalPort"),u=[],i=[],y=new Set,C=1e3,b=f((g,v,T)=>{if(u.length===0)return 0;const E=Math.abs(v.y-T.y)<ft,O=Math.abs(v.x-T.x)<ft;if(!E&&!O)return 0;let H=0;if(E){const W=v.y,ot=Math.min(v.x,T.x)-ft,j=Math.max(v.x,T.x)+ft;if(j<=ot)return 0;for(const V of u)V.edgeIndex===g||V.orientation!=="vertical"||V.pipe.coord<ot||V.pipe.coord>j||V.from-ft<=W&&V.to+ft>=W&&(H+=C)}else if(O){const W=v.x,ot=Math.min(v.y,T.y)-ft,j=Math.max(v.y,T.y)+ft;if(j<=ot)return 0;for(const V of u)V.edgeIndex===g||V.orientation!=="horizontal"||V.pipe.coord<ot||V.pipe.coord>j||V.from-ft<=W&&V.to+ft>=W&&(H+=C)}return H},"crossingPenalty"),S=s.map((g,v)=>{if(!g.start||!g.end)return{idx:v,crossLane:0,dx:0,dy:0};const T=r.get(g.start),E=r.get(g.end),O=c.get(g.start),H=c.get(g.end),W=O&&H&&O.id!==H.id?1:0,ot=T&&E?Math.abs((E.x??0)-(T.x??0)):0,j=T&&E?Math.abs((E.y??0)-(T.y??0)):0;return{idx:v,crossLane:W,dx:ot,dy:j}}).sort((g,v)=>{if(g.crossLane!==v.crossLane)return v.crossLane-g.crossLane;const T=g.dx+g.dy,E=v.dx+v.dy;return Math.abs(T-E)>1?T-E:g.idx-v.idx}).map(g=>g.idx),w=f((g,v,T,E)=>{const O=Math.min(g.x,v.x),H=Math.max(g.x,v.x),W=Math.min(g.y,v.y),ot=Math.max(g.y,v.y);return!!h.find(V=>T&&V.nodeId===T||E&&V.nodeId===E?!1:Math.abs(g.x-v.x)>ft?V.minY<g.y&&V.maxY>g.y&&V.maxX>O&&V.minX<H:V.minX<g.x&&V.maxX>g.x&&V.maxY>W&&V.minY<ot)}
1,"isSegmentBlocked"),I=new Map,x=new Map;for(const g of s)!g.start||!g.end||g.start===g.end||(x.set(g.start,(x.get(g.start)??0)+1),x.set(g.end,(x.get(g.end)??0)+1));const L=f((g,v)=>oo(g,v,"bottom"),"determineSide"),R=new Map;for(const[g,v]of s.entries()){if(!v.start||!v.end||v.start===v.end||v.points&&v.points.length>0)continue;const T=r.get(v.start),E=r.get(v.end);if(!T||!E)continue;const O=(E.x??0)-(T.x??0),H=(E.y??0)-(T.y??0);R.set(g,{edgeIdx:g,srcId:v.start,dstId:v.end,srcSide:L(T,{x:E.x??0,y:E.y??0}),dstSide:L(E,{x:T.x??0,y:T.y??0}),absDx:Math.abs(O),absDy:Math.abs(H),dxSign:Math.sign(O),dySign:Math.sign(H)})}const F=f(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.absDx===0?1/0:g.absDy/g.absDx:g.absDy===0?1/0:g.absDx/g.absDy,"preferenceStrength"),A=f(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.dxSign>=0?"right":"left":g.dySign>=0?"bottom":"top","secondarySide"),P=new Map;for(const g of R.values()){const v=`${g.srcId}:${g.srcSide}`;P.has(v)||P.set(v,[]),P.get(v).push(g)}const k=new Map,B=f((g,v)=>`${g}:${v}`,"loadKey");for(const g of R.values())k.set(B(g.srcId,g.srcSide),(k.get(B(g.srcId,g.srcSide))??0)+1),k.set(B(g.dstId,g.dstSide),(k.get(B(g.dstId,g.dstSide))??0)+1);for(const g of P.values())if(!(g.length<2)){g.sort((v,T)=>{const E=F(v),O=F(T);return Math.abs(E-O)>1e-9?O-E:v.edgeIdx-T.edgeIdx});for(let v=1;v<g.length;v++){const T=g[v],E=A(T),O=k.get(B(T.srcId,T.srcSide))??0,H=k.get(B(T.srcId,E))??0;H>=O||(k.set(B(T.srcId,T.srcSide),O-1),k.set(B(T.srcId,E),H+1),T.srcSide=E)}}const X=f(g=>{const v=g==null?void 0:g.shape;return v==="question"||v==="diamond"},"isDiamondNode"),G=new Map;for(const g of R.values())G.has(g.dstId)||G.set(g.dstId,new Set),G.get(g.dstId).add(g.dstSide);for(const g of R.values()){if(!X(r.get(g.srcId)))continue;const v=G.get(g.srcId);if(!(v!=null&&v.has(g.srcSide)))continue;const T=A(g);if(v.has(T)||(k.get(B(g.srcId,T))??0)>0)continue;const E=k.get(B(g.srcId,g.srcSide))??0;k.set(B(g.srcId,g.srcSide),Math.max(0,E-1)),k.set(B(g.srcId,T),1),g.srcSide=T}for(const g of R.values()){const{edgeIdx:v,srcId:T,dstId:E,srcSide:O,dstSide:H}=g,W=r.get(T),ot=r.get(E),j=`${T}:${O}:src`,V=O==="top"||O==="bottom"?ot.x??0:ot.y??0;I.has(j)||I.set(j,[]),I.get(j).push({edgeIdx:v,oppositeCoord:V});const bt=`${E}:${H}:dst`,dt=H==="top"||H==="bottom"?W.x??0:W.y??0;I.has(bt)||I.set(bt,[]),I.get(bt).push({edgeIdx:v,oppositeCoord:dt})}const Z=new Map,ct=8;for(const[g,v]of I){if(v.length<2)continue;v.sort((wt,Gt)=>wt.oppositeCoord-Gt.oppositeCoord);const T=g.split(":"),E=T.slice(0,-2).join(":"),O=T[T.length-2],H=T[T.length-1],W=r.get(E);if(!W)continue;const j=O==="left"||O==="right"?W.height??10:W.width??10,V=W.shape,dt=V==="question"||V==="diamond"?j*.3:j,st=Math.min(20,Math.max(ct,dt/(v.length+1))),Pt=-(st*(v.length-1))/2;for(const[wt,Gt]of v.entries()){const ee=Pt+wt*st,mn=`${Gt.edgeIdx}:${H}`;Z.set(mn,ee)}}const Mt=f(g=>{var v;return!!((v=s[g])!=null&&v.labelNodeId)},"edgeHasLabelNode"),Ft=f((g,v)=>g?(I.get(`${g}:${v}:src`)??[]).some(({edgeIdx:T})=>Mt(T))||(I.get(`${g}:${v}:dst`)??[]).some(({edgeIdx:T})=>Mt(T)):!1,"faceHasLabelNode"),Dt=f((g,v,T)=>v==="top"||v==="bottom"?{x:g.x+T,y:g.y}:{x:g.x,y:g.y+T},"applyPortOffset"),nt=f((g,v,T)=>{const E=R.get(g),O={x:T.x??0,y:T.y??0},H={x:v.x??0,y:v.y??0},W=(E==null?void 0:E.srcSide)??L(v,O),ot=(E==null?void 0:E.dstSide)??L(T,H);let j=E?M(v,E.srcSide):p(v,O,!0),V=E?M(T,E.dstSide):p(T,H,!1);const bt=Z.get(`${g}:src`),dt=Z.get(`${g}:dst`);return bt!==void 0&&(j=Dt(j,W,bt)),dt!==void 0&&(V=Dt(V,ot,dt)),{pSrcPort:j,pDstPort:V,srcSide:W,dstSide:ot}},"portsForEdge");for(const g of S){const v=s[g];if(i[g]=[],!v.start||!v.end||v.points&&v.points.length>0||v.start===v.end)continue;const T=r.get(v.start),E=r.get(v.end);if(!T||!E)continue;const{pSrcPort:O,pDstPort:H,srcSide:W,dstSide:ot}=nt(g,T,E),j={...O},V={...H},bt=W==="top"||W==="bottom",dt=ot==="top"||ot==="bottom";if(bt){const Y=O.y>(T.y??0);j.y=Y?O.y+ie:O.y-ie}else{const Y=O.x>(T.x??0);j.x=Y?O.x+ie:O.x-ie}if(dt){const Y=H.y>(E.y??0);V.y=Y?H.y+ie:H.y-ie}else{const Y=H.x>(E.x??0);V.x=Y?H.x+ie:H.x-ie}const at=f((Y,z)=>{for(const tt of h)if(!z.includes(tt.nodeId)&&Y.x>tt.minX&&Y.x<tt.maxX&&Y.y>tt.minY&&Y.y<tt.maxY)return{inside:!0,obstacle:tt};return{inside:!1}},"isPointInObstacle"),st=f((Y,z,tt,ht,Tt)=>{if(Tt){const kt=Y.y>(z.y??0);return{x:(tt.x??0)>=Y.x?ht.maxX+Ce:ht.minX-Ce,y:kt?ht.maxY+Ne:ht.minY-Ne,leavesPositiveSide:kt}}const Ct=Y.x>(z.x??0),Rt=(tt.y??0)>=Y.y;return{x:Ct?ht.maxX+Ce:ht.minX-Ce,y:Rt?ht.maxY+Ne:ht.minY-Ne,leavesPositiveSide:Ct}},"obstacleDetour");let It=[];const Pt=[v.start,v.end],wt=at(j,Pt);if(wt.inside&&wt.obstacle){const Y=wt.obstacle;if(bt){const z=st(O,T,E,Y,!0);j.x=z.x,j.y=z.y;const tt=z.leavesPositiveSide?Math.min(Y.minY-2,O.y+ie):Math.max(Y.maxY+2,O.y-ie);It=[{x:O.x,y:tt},{x:z.x,y:tt},{x:z.x,y:z.y}]}else{const z=st(O,T,E,Y,!1),tt=z.leavesPositiveSide?Math.min(Y.minX-2,O.x+ie):Math.max(Y.maxX+2,O.x-ie);j.x=z.x,j.y=z.y,It=[{x:tt,y:O.y},{x:tt,y:z.y},{x:z.x,y:z.y}]}}let Gt=[];const ee=at(V,Pt);if(ee.inside&&ee.obstacle){const Y=ee.obstacle;if(dt){const z=st(H,E,T,Y,!0);V.x=z.x,V.y=z.y,Gt=[{x:z.x,y:z.y},{x:H.x,y:z.y}]}else{const z=st(H,E,T,Y,!1);V.x=z.x,V.y=z.y,Gt=[{x:z.x,y:z.y},{x:z.x,y:H.y}]}}if(It.length===0&&Gt.length===0){const Y=Ce,z=Math.abs(j.x-V.x)<Y,tt=Math.abs(j.y-V.y)<Y,ht=Z.get(`${g}:src`)!==void 0||Z.get(`${g}:dst`)!==void 0,Tt=(((K=I.get(`${v.start??""}:${W}:src`))==null?void 0:K.length)??0)+(((Q=I.get(`${v.start??""}:${W}:dst`))==null?void 0:Q.length)??0),Ct=((($=I.get(`${v.end??""}:${ot}:src`))==null?void 0:$.length)??0)+(((q=I.get(`${v.end??""}:${ot}:dst`))==null?void 0:q.length)??0),Rt=Tt>1||Ct>1,kt=x.get(v.start??"")??0,mt=x.get(v.end??"")??0,Vt=Tt>1&&Ft(v.start,W)||Ct>1&&Ft(v.end,ot),re=Tt<=1||kt<=2,Ht=Ct<=1||mt<=2;if((z||tt)&&!ht&&(!Rt||Rt&&!Vt&&re&&Ht)&&!w(O,H,v.start,v.end)){v.points=[{...O},{...j},{...V},{...H}],y.add(g);const vt=tt?"horizontal":"vertical",jt=tt?O.y:O.x,Lt=tt?Math.min(O.x,H.x):Math.min(O.y,H.y),Et=tt?Math.max(O.x,H.x):Math.max(O.y,H.y),Zt={id:`fast-path-${vt}-${jt.toFixed(0)}-${g}`,orientation:vt,coord:jt,spanMin:Lt,spanMax:Et,tracks:[]};u.push({edgeIndex:g,segmentIndex:0,orientation:vt,pipe:Zt,trackIndex:0,from:Lt,to:Et});continue}}const mn=m("vertical",j.x,j.y,j.y);j.x=mn.coord;const pr=m("vertical",V.x,V.y,V.y);V.x=pr.coord;let ye=Math.min(j.x,V.x)-50,pe=Math.max(j.x,V.x)+50,Ae=Math.min(j.y,V.y)-50,we=Math.max(j.y,V.y)+50;for(const Y of h){const z=Math.min(j.x,V.x),tt=Math.max(j.x,V.x),ht=Math.min(j.y,V.y),Tt=Math.max(j.y,V.y);Y.minX<tt&&Y.maxX>z&&Y.minY<Tt&&Y.maxY>
1ht&&(ye=Math.min(ye,Y.minX-We),pe=Math.max(pe,Y.maxX+We),Ae=Math.min(Ae,Y.minY-We),we=Math.max(we,Y.maxY+We))}for(const Y of h){if(Y.maxX<ye||Y.minX>pe||Y.maxY<Ae||Y.minY>we)continue;const z=Ce;m("horizontal",Y.minY-z,ye,pe),m("horizontal",Y.maxY+z,ye,pe);const tt=Ne;m("vertical",Y.minX-tt,Ae,we),m("vertical",Y.maxX+tt,Ae,we)}m("horizontal",j.y,ye,pe),m("horizontal",V.y,ye,pe);const xr=d.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=Ae&&Y.coord<=we),br=d.filter(Y=>Y.orientation==="vertical"&&Y.coord>=ye&&Y.coord<=pe),De=f((Y,z)=>`${Y.toFixed(1)},${z.toFixed(1)}`,"getKey"),He=De(j.x,j.y),Eo=De(V.x,V.y),Xe=new Map,yn=new Map,pn=new Map,Ye=new Set,Se=[];Xe.set(He,0),pn.set(He,"n"),Se.push({key:He,f:Math.hypot(V.x-j.x,V.y-j.y),pt:j}),Ye.add(He);let $t=[];const xe=f((Y,z)=>w(Y,z,v.start,v.end),"checkSegmentBlocked"),xn={x:V.x,y:j.y},Mr=xe(j,xn),Ir=xe(xn,V),Sr=Mr||Ir,bn={x:j.x,y:V.y},Cr=xe(j,bn),vr=xe(bn,V);if(Sr?Cr||vr||(Math.abs(j.x-V.x)<ft?$t=[j,V]:$t=[j,bn,V]):Math.abs(j.y-V.y)<ft||Math.abs(j.x-V.x)<ft?$t=[j,V]:$t=[j,xn,V],$t.length===0)for(;Se.length>0;){Se.sort((mt,Vt)=>mt.f-Vt.f);const Y=Se.shift();if(Ye.delete(Y.key),Y.key===Eo){let mt=Eo,Vt=V;for($t=[Vt];yn.has(mt);){const re=yn.get(mt);$t.unshift(re),Vt=re,mt=De(re.x,re.y)}break}const z=Y.pt.x,tt=Y.pt.y,ht=br.sort((mt,Vt)=>mt.coord-Vt.coord),Tt=ht.findIndex(mt=>Math.abs(mt.coord-z)<1),Ct=xr.sort((mt,Vt)=>mt.coord-Vt.coord),Rt=Ct.findIndex(mt=>Math.abs(mt.coord-tt)<1),kt=[];Tt>0&&kt.push({x:ht[Tt-1].coord,y:tt}),Tt>=0&&Tt<ht.length-1&&kt.push({x:ht[Tt+1].coord,y:tt}),Rt>0&&kt.push({x:z,y:Ct[Rt-1].coord}),Rt>=0&&Rt<Ct.length-1&&kt.push({x:z,y:Ct[Rt+1].coord});for(const mt of kt){const Vt=Math.min(z,mt.x),re=Math.max(z,mt.x),Ht=Math.min(tt,mt.y),Ut=Math.max(tt,mt.y);if(h.some(ne=>ne.nodeId===v.start||ne.nodeId===v.end?!1:Vt!==re?ne.minY<tt&&ne.maxY>tt&&ne.maxX>Vt&&ne.minX<re:ne.minX<z&&ne.maxX>z&&ne.maxY>Ht&&ne.minY<Ut))continue;const vt=De(mt.x,mt.y),jt=Math.abs(mt.x-z)+Math.abs(mt.y-tt),Lt=b(g,Y.pt,mt);let Et=0;const Zt=V.x-j.x,Re=V.y-j.y,Ge=mt.x-z,Mn=mt.y-tt;(Re>10&&Mn<-5||Re<-10&&Mn>5)&&(Et=Math.abs(Mn)*100),(Zt>10&&Ge<-5||Zt<-10&&Ge>5)&&(Et+=Math.abs(Ge)*50);let To=0;const Ao=pn.get(Y.key)??"n",wo=Math.abs(Ge)>ft?"h":"v";Ao!=="n"&&Ao!==wo&&(To=50);const Lr=jt+Lt+Et+To,$e=(Xe.get(Y.key)??1/0)+Lr,Ro=Math.abs(V.x-mt.x)+Math.abs(V.y-mt.y);if($e<(Xe.get(vt)??1/0))if(yn.set(vt,Y.pt),Xe.set(vt,$e),pn.set(vt,wo),!Ye.has(vt))Se.push({key:vt,f:$e+Ro,pt:mt}),Ye.add(vt);else{const ne=Se.findIndex(Er=>Er.key===vt);ne!==-1&&(Se[ne].f=$e+Ro)}}}if($t.length===0&&($t=[j,{x:j.x,y:V.y},V]),$t.length>4){const Y=$t[0],z=$t[$t.length-1];let tt=Math.min(Y.x,z.x),ht=Math.max(Y.x,z.x),Tt=Math.min(Y.y,z.y),
1Ct=Math.max(Y.y,z.y);for(const Ht of $t)tt=Math.min(tt,Ht.x),ht=Math.max(ht,Ht.x),Tt=Math.min(Tt,Ht.y),Ct=Math.max(Ct,Ht.y);const Rt=ht>Math.max(Y.x,z.x),kt=tt<Math.min(Y.x,z.x);if(l){const Ht=Ne;if(Rt){const Ut=Math.max(Y.x,z.x),_t=Math.min(Y.y,z.y),vt=Math.max(Y.y,z.y),jt=h.filter(Lt=>Lt.minX<Ut&&Lt.maxX>Ut&&Lt.minY<vt&&Lt.maxY>_t);if(jt.length>0){let Lt=Math.max(Y.x,z.x);for(const Et of jt){const Zt=(Et.minX+Et.maxX)/2;if(Et.visualXHalfExtent===void 0||isNaN(Et.visualXHalfExtent))continue;const Re=Zt+Et.visualXHalfExtent+Ht;Lt=Math.max(Lt,Re)}isNaN(Lt)||(ht=Lt)}}if(kt){const Ut=h.filter(_t=>_t.minX<Math.min(Y.x,z.x)+Ht&&_t.minY<Math.max(Y.y,z.y)&&_t.maxY>Math.min(Y.y,z.y));if(Ut.length>0){let _t=Math.min(Y.x,z.x);for(const vt of Ut){const Lt=(vt.minX+vt.maxX)/2-vt.visualXHalfExtent-Ht;_t=Math.min(_t,Lt)}tt=_t}}}const mt=f(Ht=>{const Ut=z.y>Y.y,_t=h.filter(Lt=>{const Et=Math.min(Y.x,z.x)<Lt.maxX&&Math.max(Y.x,z.x)>Lt.minX,Zt=Math.min(Y.y,z.y)<Lt.maxY&&Math.max(Y.y,z.y)>Lt.minY;return Et&&Zt});let vt=_t;if(l&&_t.length>0){const Lt=_t.filter(Et=>Et.minX<Ht&&Et.maxX>Ht);Lt.length>0&&(vt=Lt)}if(vt.length===0)return z.y;const jt=Ce;if(Ut){const Et=Math.max(...vt.map(Zt=>Zt.maxY))+jt;if(Et<z.y-ft)return Et}else{const Et=Math.min(...vt.map(Zt=>Zt.minY))-jt;if(Et>z.y+ft)return Et}return z.y},"findBestReturnY"),Vt=f(Ht=>{const Ut=mt(Ht),_t={x:Ht,y:Y.y},vt={x:Ht,y:Ut},jt={x:z.x,y:Ut},Lt=xe(Y,_t),Et=xe(_t,vt),Zt=xe(vt,jt),Re=Ut!==z.y?xe(jt,z):!1;return!Lt&&!Et&&!Zt&&!Re?Math.abs(Ut-z.y)<ft?[Y,_t,vt,z]:[Y,_t,vt,jt,z]:null},"trySimplifyWithDetourX"),re=Rt&&!kt?Vt(ht):kt&&!Rt?Vt(tt):null;re&&($t=re)}const zt=[O,...It,...$t,...Gt.reverse(),H];if(zt.length>=3){const Y=zt[zt.length-1],z=zt[zt.length-2],tt=zt[zt.length-3],ht=Math.abs(tt.y-z.y)<ft&&Math.abs(z.y-Y.y)<ft,Tt=Math.abs(tt.x-z.x)<ft&&Math.abs(z.x-Y.x)<ft;if(ht){const Ct=Math.sign(z.x-tt.x),Rt=Math.sign(Y.x-tt.x);Ct!==0&&Ct===Rt&&Math.abs(z.x-tt.x)>Math.abs(Y.x-tt.x)&&zt.splice(-2,1)}else if(Tt){const Ct=Math.sign(z.y-tt.y),Rt=Math.sign(Y.y-tt.y);Ct!==0&&Ct===Rt&&Math.abs(z.y-tt.y)>Math.abs(Y.y-tt.y)&&zt.splice(-2,1)}}const fe=[zt[0]];for(let Y=1;Y<zt.length-1;Y++){if(Y===1){fe.push(zt[Y]);continue}const z=fe[fe.length-1],tt=zt[Y],ht=zt[Y+1];if(Math.abs(z.y-tt.y)<ft&&Math.abs(tt.y-ht.y)<ft){const Tt=tt.x>z.x,Ct=ht.x>tt.x;if(Tt!==Ct){fe.push(tt);continue}continue}if(Math.abs(z.x-tt.x)<ft&&Math.abs(tt.x-ht.x)<ft){const Tt=tt.y>z.y,Ct=ht.y>tt.y;if(Tt!==Ct){fe.push(tt);continue}continue}fe.push(tt)}fe.push(zt[zt.length-1]);for(let Y=0;Y<fe.length-1;Y++){const z=fe[Y],tt=fe[Y+1],ht=Math.abs(z.x-tt.x)<ft?"vertical":"horizontal",Tt=ht==="vertical"?z.x:z.y,Ct=ht==="vertical"?Math.min(z.y,tt.y):Math.min(z.x,tt.x),Rt=ht==="vertical"?Math.max(z.y,tt.y):Math.max(z.x,tt.x),kt=m(ht,Tt,Ct,Rt),mt={edgeIndex:g,segmentIndex:Y,orientation:ht,pipe:kt,trackIndex:0,from:Ct,to:Rt};u.push(mt),i[g].push(u.length-1),kt.tracks[0]||(kt.tracks[0]={index:0,coord:kt.coord,segments:[]}),kt.tracks[0].segments.push({edgeIndex:g,segmentIndex:Y,from:Ct,to:Rt})}}const J=f((g,v)=>g.from<v.to&&v.from<g.to,"segmentsOverlap"),rt=f((g,v,T,E)=>{const O=!E.segments.some(W=>(W.edgeIndex!==v.edgeIndex||W.segmentIndex!==v.segmentIndex)&&J(W,g)),H=!T.segments.some(W=>(W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex)&&J(W,v));return O&&H?(g.trackIndex=E.index,v.trackIndex=T.index,T.segments=[...T.segments.filter(W=>W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex),{edgeIndex:v.edgeIndex,segmentIndex:v.segmentIndex,from:v.from,to:v.to}],E.segments=[...E.segments.filter(W=>W.edgeIndex!==v.edgeIndex||W.segmentIndex!==v.segmentIndex),{edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ut=f(g=>{const v=g.tracks.length;return g.tracks[v]={index:v,coord:g.coord,segments:[]},v},"createNewTrack"),pt=f((g,v)=>{const T=g.pipe.tracks[g.trackIndex];T.segments=T.segments.filter(O=>O.edgeIndex!==g.edgeIndex||O.segmentIndex!==g.segmentIndex),g.trackIndex=v,g.pipe.tracks[v].segments.push({edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to})},"moveSegmentToTrack"),St=f((g,v)=>{const T=i[g.edgeIndex];for(const E of T){const O=u[E];O.pipe===g.pipe&&pt(O,v)}},"moveSegmentChainToTrack"),At=f(g=>{const v=i[g.edgeIndex],T=v.indexOf(u.indexOf(g)),E=[];return T>0&&E.push(u[v[T-1]]),T<v.length-1&&E.push(u[v[T+1]]),E},"getAdjacentSegmentsAlongEdge"),Kt=f((g,v)=>{if(g.orientation===v.orientation)return!1;const T=g.orientation==="horizontal"?g:v,E=g.orientation==="horizontal"?v:g;return E.pipe.coord>T.from&&E.pipe.coord<T.to&&T.pipe.coord>E.from&&T.pipe.coord<E.to},"haveAnyCrossing"),qt=f((g,v)=>{for(const T of g.tracks)if(!T.segments.some(O=>(O.edgeIndex!==v.edgeIndex||O.segmentIndex!==v.segmentIndex)&&J(O,v)))return T.index;return-1}
1,"findAvailableTrack"),Jt=f((g,v)=>{if(g.trackIndex===v.trackIndex)return J(g,v);const T=At(g),E=At(v);return T.some(O=>E.some(H=>Kt(O,H)))},"segmentsConflict"),se=f((g,v,T)=>{if(rt(g,v,g.pipe.tracks[g.trackIndex],v.pipe.tracks[v.trackIndex]))return;const E=qt(g.pipe,v);T(v,E!==-1?E:ut(g.pipe))},"resolveTrackConflict"),Ee=f(g=>{let v=0;for(let T=0;T<g.length;T++)for(let E=T+1;E<g.length;E++){const O=g[T],H=g[E];O.pipe===H.pipe&&Jt(O,H)&&(v++,se(O,H,St))}return v},"resolveHandleConflicts"),me=new Map,Te=f(g=>{if(me.has(g))return me.get(g);const v=i[g];if(v.length===0){const ot={dest:0,deviation:0,base:0,delta:0};return me.set(g,ot),ot}const E=u[v[0]].pipe.coord;let O=E;for(let ot=1;ot<v.length;ot++){const j=u[v[ot]];if(j.orientation==="horizontal"){const V=j.from,bt=j.to;O=Math.abs(V-E)>Math.abs(bt-E)?V:bt;break}}const H=Math.abs(O-E),W={dest:O,deviation:H,base:E,delta:O-E};return me.set(g,W),W},"getDestInfo"),un=f(()=>{let g=0;const v=new Map;for(const[E,O]of s.entries())i[E].length!==0&&O.start&&(v.has(O.start)||v.set(O.start,[]),v.get(O.start).push(E));const T=f(E=>{const O=s[E];if(!O.start||!O.end)return 0;const H=r.get(O.start),W=r.get(O.end);if(!H||!W)return 0;const ot=(W.x??0)-(H.x??0),j=(W.y??0)-(H.y??0);return Math.abs(ot)+Math.abs(j)},"getEdgeDistance");for(const E of v.values()){E.sort((H,W)=>{const ot=Te(H),j=Te(W);if(Math.abs(ot.deviation-j.deviation)>1)return ot.deviation-j.deviation;if(Math.abs(ot.dest-j.dest)>1)return ot.dest-j.dest;const V=T(H),bt=T(W);if(Math.abs(V-bt)>1)return bt-V;const dt=i[H].length,at=i[W].length;if(dt!==at)return dt-at;if(dt===1){const st=i[H][0],It=i[W][0];if(u[st]&&u[It]){const Pt=u[st],wt=u[It],Gt=Math.abs(Pt.to-Pt.from),ee=Math.abs(wt.to-wt.from);if(Math.abs(Gt-ee)>1)return Gt-ee}}return 0});const O=E.map(H=>u[i[H][0]]);g+=Ee(O)}return g},"fixSourceHandleCrossings"),hn=f(()=>{let g=0;const v=new Map;for(const[T,E]of s.entries())i[T].length!==0&&E.end&&(v.has(E.end)||v.set(E.end,[]),v.get(E.end).push(T));for(const T of v.values()){T.sort((O,H)=>{const W=f(V=>{const bt=i[V];if(bt.length<2)return 0;const dt=u[bt[bt.length-2]];return Math.abs(dt.to-dt.from)},"getDist"),ot=W(O),j=W(H);return Math.abs(ot-j)>.1?ot-j:O-H});const E=T.map(O=>u[i[O][i[O].length-1]]);g+=Ee(E)}return g},"fixTargetHandleCrossings"),gn=f(()=>{let g=0;for(const v of d){const T=[];for(const E of v.tracks)for(const O of E.segments){const H=i[O.edgeIndex].find(W=>u[W].segmentIndex===O.segmentIndex);H!==void 0&&T.push(u[H])}T.sort((E,O)=>E.edgeIndex-O.edgeIndex||E.segmentIndex-O.segmentIndex);for(let E=0;E<T.length;E++)for(let O=E+1;O<T.length;O++){const H=T[E],W=T[O];Jt(H,W)&&(g++,se(H,W,pt))}}return g},"fixPipeCrossings");let N=0;const _=10;for(;N<_;){let g=0;if(g+=un(),g+=hn(),g+=gn(),g===0)break;N++}const D=new Map;for(const g of d){const v=[];g.tracks.forEach(E=>{E.segments.forEach(O=>{v.push({edgeIndex:O.edgeIndex,segmentIndex:O.segmentIndex,trackIndex:E.index,from:O.from,to:O.to})})}),v.sort((E,O)=>E.from-O.from);const T=[];if(v.length>0){let E=[v[0]],O=v[0].to;for(let H=1;H<v.length;H++){const W=v[H];W.from<O?(E.push(W),O=Math.max(O,W.to)):(T.push(E),E=[W],O=W.to)}T.push(E)}for(const E of T){const O=new Set;E.forEach(st=>O.add(st.trackIndex));const H=new Map;E.forEach(st=>{const It=Te(st.edgeIndex);H.set(st.trackIndex,(H.get(st.trackIndex)??0)+It.delta)});const W=[...O].filter(st=>(H.get(st)??0)<-1),ot=[...O].filter(st=>(H.get(st)??0)>1),j=[...O].filter(st=>Math.abs(H.get(st)??0)<=1);W.sort((st,It)=>(H.get(It)??0)-(H.get(st)??0)),ot.sort((st,It)=>(H.get(st)??0)-(H.get(It)??0));const V=f((st,It)=>{E.filter(Pt=>Pt.trackIndex===st).forEach(Pt=>{const wt=y.has(Pt.edgeIndex)?g.coord:It;D.set(`${Pt.edgeIndex}-${Pt.segmentIndex}`,wt)})},"assignCoord");let bt=0;for(const st of W)bt++,V(st,g.coord-bt*vn);if(j.length===0&&O.size>0){const st=[...O].sort((wt,Gt)=>Math.abs(H.get(wt)??0)-Math.abs(H.get(Gt)??0))[0],It=W.indexOf(st);It!==-1&&W.splice(It,1);const Pt=ot.indexOf(st);Pt!==-1&&ot.splice(Pt,1),j.push(st)}let dt=0;for(const st of j){if(dt===0)V(st,g.coord);else{const It=dt%2===1?1:-1,Pt=Math.ceil(dt/2);V(st,g.coord+It*Pt*vn*.5)}dt++}let at=0;for(const st of ot)at++,V(st,g.coord+at*vn)}}for(const[g,v]of s.entries()){const T=i[g]??[];
1if(T.length===0)continue;const E=[],O=r.get(v.start),H=r.get(v.end),{pSrcPort:W,pDstPort:ot}=nt(g,O,H),j=T.map(dt=>{const at=u[dt],st=D.get(`${at.edgeIndex}-${at.segmentIndex}`)??at.pipe.coord;return{orient:at.orientation,coord:st,from:at.from,to:at.to}});E.push(W);for(let dt=0;dt<j.length;dt++){const at=j[dt],st=E[E.length-1],It=at.orient==="vertical"?st.y:st.x,Pt=at.orient==="vertical"?st.x:st.y,wt=j[dt+1],Gt=dt<j.length-1;if(Math.abs(Pt-at.coord)>ft&&E.push(ve(at,It)),Gt&&wt.orient===at.orient)if(Math.abs(at.coord-wt.coord)>ft){const ee=at.orient==="vertical"?(It+wt.from)/2:so(at,wt);E.push(ve(at,ee),ve(wt,ee))}else(dt===0||dt===j.length-2)&&E.push(ve(at,so(at,wt)));else if(Gt)E.push(ve(at,wt.coord));else{const ee=Math.abs(at.from-It)<Math.abs(at.to-It)?at.to:at.from;E.push(ve(at,ee))}}const V=E[E.length-1];(Math.abs(V.x-ot.x)>ft||Math.abs(V.y-ot.y)>ft)&&E.push(ot);const bt=[];E.length>0&&bt.push(E[0]);for(let dt=1;dt<E.length;dt++){const at=E[dt],st=bt[bt.length-1];(Math.abs(at.x-st.x)>ft||Math.abs(at.y-st.y)>ft)&&bt.push(at)}v.points=bt}for(const g of s){const v=g.__originalEdge;v&&g.points&&(v.points=g.points)}t.edges=(t.edges??[]).filter(g=>!g.isLayoutOnly);const U=f((g,v)=>{const T=v.x??0,E=v.y??0,O=v.width??0,H=v.height??0;if(O<=0||H<=0)return g;const W=T-O/2,ot=T+O/2,j=E-H/2,V=E+H/2;if(g.x<W||g.x>ot||g.y<j||g.y>V)return g;const bt=g.x-W,dt=ot-g.x,at=g.y-j,st=V-g.y,It=Math.min(bt,dt,at,st);return It===bt?{x:W,y:g.y}:It===dt?{x:ot,y:g.y}:It===at?{x:g.x,y:j}:{x:g.x,y:V}},"nodeBoundaryClamp");for(const g of t.edges){const v=g.points;if(!v||v.length<2)continue;const T=g.start,E=g.end,O=T?r.get(T):void 0,H=E?r.get(E):void 0;O&&(v[0]=U(v[0],O)),H&&(v[v.length-1]=U(v[v.length-1],H))}return t}f(hr,"routeEdgesOrthogonal");function gr(t){return t.direction??"TB"}f(gr,"getSwimlaneDirection");function mr(t){var h,m,M,p,u;const e=Jo(t),n=((h=t.config.flowchart)==null?void 0:h.nodeSpacing)??40,o=((m=t.config.flowchart)==null?void 0:m.rankSpacing)??100,s=((M=t.config.swimlane)==null?void 0:M.ignoreCrossLaneEdges)??!0,r=((p=t.config.swimlane)==null?void 0:p.optimizeRanksByCrossings)??!0,c=((u=t.config.swimlane)==null?void 0:u.automaticLaneOrdering)??!1,d=gr(t),{ordered:l,coordinates:a}=ur(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:c,direction:d});Zo(e,l,a,{nodeGap:n,layerGap:o});for(const i of t.edges??[])delete i.points;hr(t,d);for(const i of t.edges??[])(!i.curve||i.curve==="basis")&&(i.curve="rounded");return Rs(t,d),ws(t),d}f(mr,"runSwimlaneLayoutCore");function yr(t){qo(t);const e=Qo(t);t.nodes=e.nodes,t.edges=e.edges}f(yr,"prepareSwimlaneLayout");var Vr=Tr({prepareLayout:yr,runLayoutCore:mr,afterPaint:Wo});export{Vr as render};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.