@theruansilva/omp-web 2.2.2 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/client/assets/{CodeViewer-DFvO6hY8.js → CodeViewer-DHlYSlFA.js} +2 -2
  2. package/dist/client/assets/TerminalPanel-B7ErBads.js +126 -0
  3. package/dist/client/assets/{UnifiedDiffViewer-BjuD29RQ.js → UnifiedDiffViewer-Bsxe8vEO.js} +1 -1
  4. package/dist/client/assets/{abnfDiagram-O67JEVCF-SLRtz9OB.js → abnfDiagram-O67JEVCF-Bd6-T6CG.js} +1 -1
  5. package/dist/client/assets/{arc-CUNKbxyw.js → arc-Cx4UzFEe.js} +1 -1
  6. package/dist/client/assets/{architectureDiagram-NJMV4G6O-Cg80o9g4.js → architectureDiagram-NJMV4G6O-DNZZOJHJ.js} +1 -1
  7. package/dist/client/assets/{blockDiagram-BEXU5L5S-nZRhUgoO.js → blockDiagram-BEXU5L5S-DLGMX1ky.js} +2 -2
  8. package/dist/client/assets/{c4Diagram-YGBWAQC7-B2q8gSrU.js → c4Diagram-YGBWAQC7-ZicrYBFE.js} +1 -1
  9. package/dist/client/assets/channel-Cy0oVDAk.js +1 -0
  10. package/dist/client/assets/{chunk-2Q5K7J3B-flkpXKt7.js → chunk-2Q5K7J3B-BTdneniS.js} +1 -1
  11. package/dist/client/assets/{chunk-3FUC2YCW-kMKg81Pk.js → chunk-3FUC2YCW-DClqbl7t.js} +2 -2
  12. package/dist/client/assets/{chunk-5VM5RSS4-3Lib-uGP.js → chunk-5VM5RSS4-xVtxN_Sa.js} +1 -1
  13. package/dist/client/assets/{chunk-GTNCS2PH-CdX8cblt.js → chunk-GTNCS2PH-Da56Sthk.js} +1 -1
  14. package/dist/client/assets/{chunk-GWA4HPMP-CwHQm4wS.js → chunk-GWA4HPMP-D40kcLEo.js} +1 -1
  15. package/dist/client/assets/{chunk-JWPE2WC7-BsqVo0Tf.js → chunk-JWPE2WC7-CVgZV6Wp.js} +1 -1
  16. package/dist/client/assets/{chunk-NETBCI7D-p3q1dAb3.js → chunk-NETBCI7D-DNI4Nu1k.js} +1 -1
  17. package/dist/client/assets/{chunk-WEXAMYUT-Bv_MfOEM.js → chunk-WEXAMYUT-IVsvOCJJ.js} +1 -1
  18. package/dist/client/assets/{chunk-XXDRQBXY-w71UKmME.js → chunk-XXDRQBXY-ByZI65OQ.js} +1 -1
  19. package/dist/client/assets/{classDiagram-v2-NBCMYWYE-Ch9Lx94A.js → classDiagram-v2-NBCMYWYE-CT9N6_lF.js} +1 -1
  20. package/dist/client/assets/{cose-bilkent-JH36ORCC-BrpIQScu.js → cose-bilkent-JH36ORCC-CBJJYOd5.js} +1 -1
  21. package/dist/client/assets/{cynefin-OW5HDTMX-CRiWF9ki.js → cynefin-OW5HDTMX-BUpMG_46.js} +1 -1
  22. package/dist/client/assets/{cynefinDiagram-VND7K2PF-qbMIgfpH.js → cynefinDiagram-VND7K2PF-otEJqM7K.js} +1 -1
  23. package/dist/client/assets/dagre-6A5THRUB-qquzH4Ev.js +4 -0
  24. package/dist/client/assets/{diagram-22UHCM2B-B8hKRE_o.js → diagram-22UHCM2B-HDLtgJRK.js} +1 -1
  25. package/dist/client/assets/{diagram-3UASUU5V-B4uZ3GNA.js → diagram-3UASUU5V-Bc2_UO5k.js} +1 -1
  26. package/dist/client/assets/{diagram-ATOU4E4O-CzGwlb-Y.js → diagram-ATOU4E4O-DR72H135.js} +1 -1
  27. package/dist/client/assets/{diagram-CDSNMT55-BXiuQ_UO.js → diagram-CDSNMT55-hNm66Cr9.js} +1 -1
  28. package/dist/client/assets/{diagram-MLGK6HIB-Dsw8Iqaq.js → diagram-MLGK6HIB-ChaEhVd4.js} +1 -1
  29. package/dist/client/assets/{diagram-MPIPVDR6-T4zPzapt.js → diagram-MPIPVDR6-gYxYar4V.js} +1 -1
  30. package/dist/client/assets/{ebnfDiagram-ZINNZB2B-CnvJApL-.js → ebnfDiagram-ZINNZB2B-CRQjE5YW.js} +1 -1
  31. package/dist/client/assets/{elk-276RUBZZ-C0qbqSzX.js → elk-276RUBZZ-OZ3Zw5zt.js} +3 -3
  32. package/dist/client/assets/{erDiagram-OPXOYQCR-CPCRCRVW.js → erDiagram-OPXOYQCR-CB71jEyA.js} +1 -1
  33. package/dist/client/assets/{flowDiagram-KWPJA3E3-CRR5EuoG.js → flowDiagram-KWPJA3E3-CYfjFu_3.js} +1 -1
  34. package/dist/client/assets/{ganttDiagram-FUAMR5RP-CCJy4INc.js → ganttDiagram-FUAMR5RP-BE7B_UzV.js} +1 -1
  35. package/dist/client/assets/{gitGraphDiagram-X574FWY7-BiGivFUj.js → gitGraphDiagram-X574FWY7-HBid3FDo.js} +1 -1
  36. package/dist/client/assets/graph-D8UmR1vK.js +1 -0
  37. package/dist/client/assets/{index-DqFyJdiT.js → index-C-cQEbCY.js} +358 -333
  38. package/dist/client/assets/{infoDiagram-VRGFBTTK-BdSqUdzZ.js → infoDiagram-VRGFBTTK-4JprhzHA.js} +1 -1
  39. package/dist/client/assets/{ishikawaDiagram-OU5B5YK6-Bto15O_-.js → ishikawaDiagram-OU5B5YK6-UAP9bqUn.js} +1 -1
  40. package/dist/client/assets/{journeyDiagram-ZHPQQLJL-C1FkG7_Y.js → journeyDiagram-ZHPQQLJL-j9c9R8jU.js} +1 -1
  41. package/dist/client/assets/{kanban-definition-PNTS6WVX-7Og64Ylp.js → kanban-definition-PNTS6WVX-DWQBxist.js} +1 -1
  42. package/dist/client/assets/{linear-CYEx6yMl.js → linear-T6d_7ZeJ.js} +1 -1
  43. package/dist/client/assets/{mindmap-definition-NLK3R4M7-BDi04G8P.js → mindmap-definition-NLK3R4M7-CvMFAKuS.js} +1 -1
  44. package/dist/client/assets/{pegDiagram-GJSIUBJH-niwxJYhI.js → pegDiagram-GJSIUBJH-hvF632kF.js} +1 -1
  45. package/dist/client/assets/{pieDiagram-5QR66LMP-DUKBH1DT.js → pieDiagram-5QR66LMP-BXICkLn_.js} +1 -1
  46. package/dist/client/assets/{quadrantDiagram-O4NWA36T-DA4vON7R.js → quadrantDiagram-O4NWA36T-CnFY0fxq.js} +1 -1
  47. package/dist/client/assets/{railroadDiagram-XR7U4H2S-CHDT9c0L.js → railroadDiagram-XR7U4H2S-BeRVo7yu.js} +1 -1
  48. package/dist/client/assets/{requirementDiagram-PLB6GJNP-D8QwjsX7.js → requirementDiagram-PLB6GJNP-DmnKxfFp.js} +1 -1
  49. package/dist/client/assets/{sankeyDiagram-IPEJSGJF-DWGxFQm3.js → sankeyDiagram-IPEJSGJF-Bz1YIaMr.js} +1 -1
  50. package/dist/client/assets/{sequenceDiagram-PO4LG4MO-_ejeE6EX.js → sequenceDiagram-PO4LG4MO-4cmBIYSV.js} +1 -1
  51. package/dist/client/assets/{sizeCapture-INFHLROL-QLEMuHkm.js → sizeCapture-INFHLROL-B6mTYfgL.js} +1 -1
  52. package/dist/client/assets/{stateDiagram-v2-GCMORJYK-Gd_SeXN9.js → stateDiagram-v2-GCMORJYK-BKkiHc4R.js} +1 -1
  53. package/dist/client/assets/swimlanes-2SLR337P-CBONvDhF.js +1 -0
  54. package/dist/client/assets/swimlanesDiagram-TC7HE7FX-DUA_t92u.js +8 -0
  55. package/dist/client/assets/{timeline-definition-EJHVYXUP-DYl9dUjO.js → timeline-definition-EJHVYXUP-BG9z7YWj.js} +1 -1
  56. package/dist/client/assets/usecaseDiagram-POWQR4AR--yXc6tgF.js +370 -0
  57. package/dist/client/assets/{vendor-editor-core-D-5q2tVX.js → vendor-editor-core-DbsheCh1.js} +30 -29
  58. package/dist/client/assets/vendor-editor-languages-B1l-thbw.js +26 -0
  59. package/dist/client/assets/{vennDiagram-UO4OBE2U-Ded7JPVG.js → vennDiagram-UO4OBE2U-DYr42cwJ.js} +1 -1
  60. package/dist/client/assets/{wardleyDiagram-VNRHLVJA-losDIeQr.js → wardleyDiagram-VNRHLVJA-DksCy2aR.js} +1 -1
  61. package/dist/client/assets/{xychartDiagram-PMCCYNJV-B7_BBfaW.js → xychartDiagram-PMCCYNJV-DPxnNxcI.js} +1 -1
  62. package/dist/client/index.html +3 -3
  63. package/dist/config.js +20 -0
  64. package/dist/config.js.map +1 -1
  65. package/dist/omp-web-plugins/usage/omp-web-plugin.js +41 -0
  66. package/dist/omp-web-plugins/usage/package.json +9 -0
  67. package/dist/omp-web-plugins/usage/types.js +2 -0
  68. package/dist/omp-web-plugins/usage/usageLogic.js +162 -0
  69. package/dist/omp-web-plugins/usage/usagePanelElement.js +442 -0
  70. package/dist/server/app.js +37 -1
  71. package/dist/server/app.js.map +1 -1
  72. package/dist/server/index.js +11 -3
  73. package/dist/server/index.js.map +1 -1
  74. package/dist/server/machines/machineProxyRoutes.js +16 -1
  75. package/dist/server/machines/machineProxyRoutes.js.map +1 -1
  76. package/dist/server/machines/machineService.js +15 -6
  77. package/dist/server/machines/machineService.js.map +1 -1
  78. package/dist/server/mcpRoutes.js +11 -1
  79. package/dist/server/mcpRoutes.js.map +1 -1
  80. package/dist/server/projects/projectService.js +23 -0
  81. package/dist/server/projects/projectService.js.map +1 -1
  82. package/dist/server/security.js +112 -9
  83. package/dist/server/security.js.map +1 -1
  84. package/dist/server/sessions/authService.js +23 -3
  85. package/dist/server/sessions/authService.js.map +1 -1
  86. package/dist/server/sessions/piAgentSession.js +46 -1
  87. package/dist/server/sessions/piAgentSession.js.map +1 -1
  88. package/dist/server/sessions/sessionCommandService.js +20 -9
  89. package/dist/server/sessions/sessionCommandService.js.map +1 -1
  90. package/dist/server/terminalProxyRoutes.js +16 -1
  91. package/dist/server/terminalProxyRoutes.js.map +1 -1
  92. package/dist/server/usageRoutes.js +202 -0
  93. package/dist/server/usageRoutes.js.map +1 -0
  94. package/dist/server/webSocketBridge.js +15 -0
  95. package/dist/server/webSocketBridge.js.map +1 -1
  96. package/dist/shared/apiTypes.d.ts +3 -0
  97. package/dist/shared/federatedRoutes.js +2 -0
  98. package/dist/shared/federatedRoutes.js.map +1 -1
  99. package/package.json +1 -1
  100. package/dist/client/assets/TerminalPanel-zgTnfKO5.js +0 -126
  101. package/dist/client/assets/_basePickBy-vr4256UX.js +0 -1
  102. package/dist/client/assets/_baseUniq-CHc60b6y.js +0 -1
  103. package/dist/client/assets/channel-CI4_doFA.js +0 -1
  104. package/dist/client/assets/dagre-6A5THRUB-CNLq2-K8.js +0 -4
  105. package/dist/client/assets/graph-C2De1HlQ.js +0 -1
  106. package/dist/client/assets/swimlanes-2SLR337P-BOtWDtXR.js +0 -1
  107. package/dist/client/assets/swimlanesDiagram-TC7HE7FX-CMZDG2D-.js +0 -8
  108. package/dist/client/assets/usecaseDiagram-POWQR4AR-B_DlB3UM.js +0 -370
  109. package/dist/client/assets/vendor-editor-languages-B6WRt0aC.js +0 -26
@@ -1 +0,0 @@
1
- import{a as sr}from"./chunk-NETBCI7D-p3q1dAb3.js";import{c as rr}from"./chunk-3FUC2YCW-kMKg81Pk.js";import{_ as a,l as yn}from"./index-DqFyJdiT.js";import"./graph-C2De1HlQ.js";import"./_baseUniq-CHc60b6y.js";import"./vendor-editor-core-D-5q2tVX.js";import"./vendor-editor-languages-B6WRt0aC.js";function Lo(t,{measure:e}){const n=t.config?.swimlane?.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(r=>Array.isArray(r.points)&&r.points.length>=2).map(r=>({id:r.id,points:r.points,curve:r.curve,arrowTypeStart:r.arrowTypeStart,arrowTypeEnd:r.arrowTypeEnd}));sr(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}a(Lo,"applySwimlaneLineJumps");var hn="__swimlane_default__",ir=21,Io=20;function xn(t){return Math.max(t.padding??Io,Io)}a(xn,"topLaneHorizontalPadding");function To(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 l=n-s/2,f=Math.min(r,n+s/2),u=Math.min(ir,Math.max(0,f-l)),g=l+u;if(g<=l){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:l,bottom:g}}a(To,"assignTopLaneTitleRect");function wo(t){const e=t.direction,n=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===hn);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:hn,label:"",isGroup:!0,shape:"swimlane",padding:20,look:t.config?.look,colorIndex:n.reduce((r,l)=>Math.max(r,l.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=hn}a(wo,"prepareLayoutForSwimlanes");function Eo(t){const e=new Map;for(const u of t.nodes??[])e.set(u.id,u);const n=[];for(const u of t.edges??[]){const g=typeof u.start=="string"?u.start:void 0,b=typeof u.end=="string"?u.end:void 0;!g||!b||u.labelNodeId||n.push({id:u.id,src:g,dst:b,ref:u})}const o=t.nodes??[],s=o.filter(u=>u.isGroup),r=o.filter(u=>!u.isGroup);return{nodes:[...[...s].reverse(),...r].map(u=>u.id),edges:n,layout:t,nodeById:e}}a(Eo,"toGraphView");function Ao(t,e,n,o){const{layout:s}=t,r=t.nodeById,l=o?.layerGap??100,f=o?.nodeGap??40;let u=0;for(const v of e.layers){let d=0;for(const h of v){const i=r.get(h);if(!i){d++;continue}i.layer=u,i.order=d;const y=n.x[h]??d*f,L=n.y[h]??u*l;i.x=y,i.y=L,d++}u++}const g=s.nodes??[],b=new Map,p=[];for(const v of g){if(!v?.isGroup)continue;v.parentId||p.push(v);const d=g.filter(I=>I.parentId===v.id);let h=1/0,i=-1/0,y=1/0,L=-1/0;for(const I of d){const E=I.x??n.x[I.id],T=I.y??n.y[I.id],m=I.width??0,M=I.height??0;E!=null&&T!=null&&(h=Math.min(h,E-m/2),i=Math.max(i,E+m/2),y=Math.min(y,T-M/2),L=Math.max(L,T+M/2))}if(h===1/0||y===1/0)v.x=v.x??0,v.y=v.y??0,v.width=v.width??0,v.height=v.height??0;else{const I=v.padding??20,E=v.parentId?I:2*xn(v),T=I,m=Math.max(0,i-h)+E,M=Math.max(0,L-y)+T,A=(h+i)/2,R=(y+L)/2;v.x=A,v.y=R,v.width=m,v.height=M,b.set(v.id,{minX:h,maxX:i,minY:y,maxY:L})}}if(p.length>0&&b.size>0){let v=1/0,d=-1/0,h=0;for(const i of p){const y=i.padding??20;y>h&&(h=y);const L=b.get(i.id);L&&(v=Math.min(v,L.minY),d=Math.max(d,L.maxY))}if(v!==1/0&&d!==-1/0){const i=Math.max(0,d-v),L=Math.max(h,36),I=i+2*L,E=(v+d)/2;for(const k of p)k.y=E,k.height=I,k.swimlaneContentTop=v;const T=[...p].sort((k,O)=>{const F=k.x??0,D=O.x??0;return F-D}),m=[],M=[],A=[];for(const k of T){const O=b.get(k.id);if(!O)continue;const F=Math.max(0,O.maxX-O.minX)+2*xn(k),D=(O.minX+O.maxX)/2;m.push(k.id),M.push(D),A.push(F)}const R=m.length;if(R>0){const k=new Map;if(R===1)k.set(m[0],A[0]);else{const O=[];for(let j=0;j<R-1;j++)O.push(M[j+1]-M[j]);const F=new Array(R);F[0]=0;for(let j=0;j<R-1;j++)F[j+1]=2*O[j]-F[j];let D=0,B=Number.POSITIVE_INFINITY;for(let j=0;j<R;j++){const Z=A[j];j%2===0?D=Math.max(D,Z-F[j]):B=Math.min(B,F[j]-Z)}let G=D;D<=B?G=(D+B)/2:G=D;for(let j=0;j<R;j++){const Z=F[j]+(j%2===0?G:-G),dt=Math.max(A[j],Z);k.set(m[j],dt)}}for(const O of p){const F=k.get(O.id);F!=null&&(O.width=F),To(O)}}}}}a(Ao,"writeBackToLayoutData");var cr="[EdgeLabelNodes]";function Ro(t){const e=[],n=[],o=new Map;for(const l of t.nodes)o.set(l.id,l);for(const l of t.edges){if(!l.label||l.label.length===0||l.isLayoutOnly||l.labelNodeId)continue;const f=l.start?o.get(l.start):void 0,u=l.end?o.get(l.end):void 0;if(!f||!u){yn.warn(cr,`Edge ${l.id} has missing source or target node`);continue}const g=`edge-label-${l.start}-${l.end}-${l.id}`,p=f.parentId!==u.parentId?u.parentId:f.parentId,v={id:g,label:l.label,edgeStart:l.start??"",edgeEnd:l.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:p,isGroup:!1,labelStyle:Array.isArray(l.labelStyle)?l.labelStyle[0]:l.labelStyle??"",...f.dir?{dir:f.dir}:{}};e.push(v),l.labelNodeId=g,l.label=void 0,l.text=void 0;const d={id:`${l.id}-to-label`,start:l.start,end:g,type:"normal",isLayoutOnly:!0},h={id:`${l.id}-from-label`,start:g,end:l.end,type:"normal",isLayoutOnly:!0};n.push(d,h)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}a(Ro,"createEdgeLabelNodes");var _t=.001;function Kn(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:we(e,n,o,s)}:void 0}a(Kn,"measuredNodeRect");function qn(t){if(t.isGroup)return;const e=Kn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}a(qn,"nodeBoundsInfoFor");function oe(t,e,n=_t){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}a(oe,"samePoint");function ft(t,e,n=_t){return Math.abs(t.x-e.x)<n}a(ft,"sameX");function ht(t,e,n=_t){return Math.abs(t.y-e.y)<n}a(ht,"sameY");function wt(t,e,n=_t){return ht(t,e,n)&&Math.abs(t.x-e.x)>n}a(wt,"isHorizontalSegment");function Et(t,e,n=_t){return ft(t,e,n)&&Math.abs(t.y-e.y)>n}a(Et,"isVerticalSegment");function $t(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)))}a($t,"overlapLength");function ie(t,e,n=_t){return t.horizontal&&e.horizontal&&ht(t.a,e.a,n)?$t(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&ft(t.a,e.a,n)?$t(t.a.y,t.b.y,e.a.y,e.b.y):0}a(ie,"sameAxisSegmentOverlapLength");function Ee(t,e=_t){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],l=wt(s,r,e),f=Et(s,r,e);(l||f)&&n.push({index:o,a:s,b:r,horizontal:l,vertical:f})}return n}a(Ee,"orthogonalSegmentsForPoints");function Qt(t,e=_t){const n=Ee(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}a(Qt,"countOrthogonalBends");function mt(t,e=_t){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!oe(s,o,e))&&n.push({x:o.x,y:o.y})}return n}a(mt,"dedupeConsecutivePoints");function Zn(t,e=_t){if(!t||t.length!==4)return;const[n,o,s,r]=t;return wt(n,o,e)&&Et(o,s,e)&&wt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Et(n,o,e)&&wt(o,s,e)&&Et(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}a(Zn,"classifyThreeSegmentRoute");function Je(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),l=Math.min(t.y,e.y),f=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&f>n.top-o&&l<n.bottom+o}a(Je,"segmentBoundsOverlapRect");function Jn(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}a(Jn,"pointInsideRect");function No(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}a(No,"rectContainsRect");function ze(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}a(ze,"rectsOverlap");function bn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}a(bn,"inflateRect");function we(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}a(we,"rectFromCenterSize");function qt(t){return Kn(t)?.rect}a(qt,"rectOfNodeBounds");function Ie(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}}}a(Ie,"portForRectSide");function Qn(t,e,n,o,s,r=_t){const l=e==="left"||e==="right",f=o==="left"||o==="right";if(l&&f){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(ht(t,n,r))return[t,n];const p=(t.x+n.x)/2;return[t,{x:p,y:t.y},{x:p,y:n.y},n]}if(e===o){if(ht(t,n,r))return;const p=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:p,y:t.y},{x:p,y:n.y},n]}return}if(!l&&!f){if(e===o){if(ft(t,n,r))return;const v=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:v},{x:n.x,y:v},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(ft(t,n,r))return[t,n];const p=(t.y+n.y)/2;return[t,{x:t.x,y:p},{x:n.x,y:p},n]}if(l&&!f){const b=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,p=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return b&&p?[t,{x:n.x,y:t.y},n]:void 0}const u=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,g=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return u&&g?[t,{x:t.x,y:n.y},n]:void 0}a(Qn,"buildOrthogonalPortPath");function to(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]}a(to,"buildSameSideTrackPath");function Qe(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=qn(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}a(Qe,"collectRealNodeBounds");function me(t){const e=[],n=[];for(const o of t){const s=qn(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}}a(me,"collectNodeRectEntries");function Oo(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,l=o.width??0,f=o.height??0;n.push({nodeId:o.id,...we(s,r,l,f)})}return n}a(Oo,"collectLayoutNodeRects");function eo(t,e,n=_t){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),l=e.get(s);if(!(!r||!l))return{srcId:o,dstId:s,srcInfo:r,dstInfo:l,collinearX:Math.abs(r.cx-l.cx)<n,collinearY:Math.abs(r.cy-l.cy)<n}}a(eo,"getNodePairGeometry");function At(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&Je(t,e,r.rect,-s))return!0;return!1}a(At,"segmentHitsAnyRect");function no(t,e,n,o,s=_t,r=1e-6){const l=ht(t,e,s),f=ft(t,e,s),u=ht(n,o,s),g=ft(n,o,s);if(l&&u||f&&g||!(l||f)||!(u||g))return!1;const b=l?{a:t,b:e}:{a:n,b:o},p=f?{a:t,b:e}:{a:n,b:o},v=b.a.y,d=Math.min(b.a.x,b.b.x),h=Math.max(b.a.x,b.b.x),i=p.a.x,y=Math.min(p.a.y,p.b.y),L=Math.max(p.a.y,p.b.y);if(i<d||i>h||v<y||v>L)return!1;const I=Math.abs(i-b.a.x)<r&&Math.abs(v-b.a.y)<r||Math.abs(i-b.b.x)<r&&Math.abs(v-b.b.y)<r,E=Math.abs(i-p.a.x)<r&&Math.abs(v-p.a.y)<r||Math.abs(i-p.b.x)<r&&Math.abs(v-p.b.y)<r;return!(I&&E)}a(no,"orthogonalSegmentsCross");function Bo(t,e,n,o,s=_t){const r=ht(t,e,s),l=ft(t,e,s),f=ht(n,o,s),u=ft(n,o,s);return l&&u&&ft(t,n,s)?$t(t.y,e.y,n.y,o.y)>s:r&&f&&ht(t,n,s)?$t(t.x,e.x,n.x,o.x)>s:!1}a(Bo,"sameAxisSegmentsOverlap");function $e(t,e,n,o,{epsilon:s=_t,skipDegenerateOther:r=!1}={}){for(const l of n){if(l===o||l.isLayoutOnly)continue;const f=l.points;if(!(!f||f.length<2))for(let u=0;u<f.length-1;u++){const g=f[u],b=f[u+1];if(!(r&&oe(g,b,s))&&(no(t,e,g,b,s)||Bo(t,e,g,b,s)))return!0}}return!1}a($e,"segmentConflictsWithAnyEdge");function ae(t,e,n,o,s=_t){const r=ht(t,e,s),l=ft(t,e,s),f=ht(n,o,s),u=ft(n,o,s);if(!(r&&u||l&&f))return!1;const g=r?{a:t,b:e}:{a:n,b:o},b=r?{a:n,b:o}:{a:t,b:e},p=g.a.y,v=Math.min(g.a.x,g.b.x),d=Math.max(g.a.x,g.b.x),h=b.a.x,i=Math.min(b.a.y,b.b.y),y=Math.max(b.a.y,b.b.y);return h>v+s&&h<d-s&&p>i+s&&p<y-s}a(ae,"orthogonalSegmentsStrictlyCross");function In(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+_t&&t<s-_t}a(In,"strictlyBetween");function Po(t,e,n){return ft(t,e)&&ft(e,n)?In(e.y,t.y,n.y):ht(t,e)&&ht(e,n)?In(e.x,t.x,n.x):!1}a(Po,"isCollinearIntermediate");function ko(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],l=o+1<t.length?t[o+1]:void 0;if(s&&l){if(oe(s,l)){o++,e=!0;continue}if(Po(s,r,l)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}a(ko,"simplifyPolylineOnce");function Ve(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!ft(s,r)&&!ht(s,r)){const l=e.length>=2?e[e.length-2]:void 0,u=(l?ft(l,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(u)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!oe(s,o))&&n.push(o)}return n}a(Ve,"orthogonalizePolyline");function ce(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=ko(e);if(e=o.points,!o.changed)break}return e}a(ce,"simplifyPolyline");var nt=.001,ar=.5,Mo=4;function oo(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?qt(s):void 0,dstRect:r?qt(r):void 0}}a(oo,"endpointContextFor");function Fo(t,e,n){if(ht(t,e,nt))return{x:t.x<n.left?n.left:n.right,y:t.y};if(ft(t,e,nt)){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))}}a(Fo,"segmentEnterPoint");function Mn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Jn(t[s],e,ar);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const l=Fo(t[s],t[r],e);return n?[l,...t.slice(s)]:[...t.slice(0,s+1),l]}a(Mn,"clipEndpoint");function _o(t,e){for(const n of t){const o=oo(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Mn(s,o.srcRect,!0)),o.dstRect&&(s=Mn(s,o.dstRect,!1)),s=ce(Ve(s)),s=so(s,o.srcRect,o.dstRect),o.edge.points=ce(Ve(s))}}a(_o,"clipEdgeEndpointsToNodeBoundaries");function Sn(t,e,n,o=!1){if(ht(t,e,nt)){if(e.y<n.top-nt||e.y>n.bottom+nt)return e;if(o){if(t.x<n.left-nt)return{x:n.left,y:t.y};if(t.x>n.right+nt)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(ft(t,e,nt)){if(e.x<n.left-nt||e.x>n.right+nt)return e;if(o){if(t.y<n.top-nt)return{x:t.x,y:n.top};if(t.y>n.bottom+nt)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}a(Sn,"snapEndpointToBoundary");function je(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!oe(r,o,nt))return r}return t[e+n]}a(je,"firstDistinctAdjacent");function Ue(t,e){const n=t+Mo,o=e-Mo;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}a(Ue,"cornerClearanceRange");function Cn(t,e,n){const{lo:o,hi:s}=Ue(e,n);return Math.min(s,Math.max(o,t))}a(Cn,"clampToCornerClearance");function Ho(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}}a(Ho,"intersectRanges");function vn(t,e){return e==="left"||e==="right"?Ue(t.top,t.bottom):Ue(t.left,t.right)}a(vn,"clearanceRangeForSide");function We(t,e,n){const o=t.y>=n.top-nt&&t.y<=n.bottom+nt,s=t.x>=n.left-nt&&t.x<=n.right+nt;if(ht(t,e,nt)&&o){if(Math.abs(t.x-n.left)<nt)return"left";if(Math.abs(t.x-n.right)<nt)return"right"}if(ft(t,e,nt)&&s){if(Math.abs(t.y-n.top)<nt)return"top";if(Math.abs(t.y-n.bottom)<nt)return"bottom"}}a(We,"terminalSideForSegment");function Re(t){return t==="left"||t==="right"}a(Re,"isHorizontalSide");function Do(t,e,n,o,s){const r=[],l=n?We(t,e,n):void 0,f=o?We(e,t,o):void 0;return n&&l&&Re(l)===s&&r.push(vn(n,l)),o&&f&&Re(f)===s&&r.push(vn(o,f)),r.length>0?Ho(r):void 0}a(Do,"straightClearanceRange");function Ln(t,e,n,o,s){const r=Do(t,e,n,o,s);if(!r)return;const l=s?t.y:t.x,f=Math.min(r.hi,Math.max(r.lo,l));if(!(Math.abs(f-l)<nt))return s?[{x:t.x,y:f},{x:e.x,y:f}]:[{x:f,y:t.y},{x:f,y:e.y}]}a(Ln,"clearStraightEndpointCornerAxis");function so(t,e,n){if(t.length!==2)return t;const[o,s]=t;return ht(o,s,nt)?Ln(o,s,e,n,!0)??t:ft(o,s,nt)?Ln(o,s,e,n,!1)??t:t}a(so,"clearStraightEndpointCornerConnections");function Xo(t,e,n){return Re(n)?{x:t.x,y:Cn(t.y,e.top,e.bottom)}:{x:Cn(t.x,e.left,e.right),y:t.y}}a(Xo,"cornerClearedEndpoint");function Yo(t,e,n,o,s,r){const l=t.map(f=>({...f}));for(let f=e;f>=0&&f<t.length;f+=n){const u=t[f];if(r&&!ht(u,o,nt)||!r&&!ft(u,o,nt))break;r?l[f].y=s.y:l[f].x=s.x}return l}a(Yo,"moveCollinearEndpointRun");function Tn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],l=je(t,o,s);if(!l)return t;const f=We(r,l,e);if(!f)return t;const u=Re(f),g=Xo(r,e,f);return oe(r,g,nt)?t:Yo(t,o,s,r,g,u)}a(Tn,"clearEndpointCornerConnection");function wn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-nt&&Math.max(t.x,e.x)<=n.right+nt,s=Math.min(t.y,e.y)>=n.top-nt&&Math.max(t.y,e.y)<=n.bottom+nt;if(Math.abs(t.y-n.top)<nt&&Math.abs(e.y-n.top)<nt&&o)return"top";if(Math.abs(t.y-n.bottom)<nt&&Math.abs(e.y-n.bottom)<nt&&o)return"bottom";if(Math.abs(t.x-n.left)<nt&&Math.abs(e.x-n.left)<nt&&s)return"left";if(Math.abs(t.x-n.right)<nt&&Math.abs(e.x-n.right)<nt&&s)return"right"}a(wn,"borderSideForSegment");function En(t,e,n,o){switch(t){case"top":return ft(e,n,nt)&&n.y<o.top-nt;case"bottom":return ft(e,n,nt)&&n.y>o.bottom+nt;case"left":return ht(e,n,nt)&&n.x<o.left-nt;case"right":return ht(e,n,nt)&&n.x>o.right+nt}}a(En,"leavesOutward");function An(t,e,n){if(t.length<3)return t;if(n){const r=wn(t[0],t[1],e);return r&&En(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=wn(t[o-1],t[o],e);return s&&En(s,t[o-1],t[o-2],e)?t.slice(0,o):t}a(An,"collapseOwnBorderStub");function Go(t,e,n){let o=t;if(e){const r=je(o,0,1);if(r){const l=Sn(r,o[0],e);l!==o[0]&&(o=[l,...o.slice(1)])}o=An(o,e,!0)}if(n){const r=o.length-1,l=je(o,r,-1);if(l){const f=Sn(l,o[r],n,!0);f!==o[r]&&(o=[...o.slice(0,r),f])}o=An(o,n,!1)}const s=so(o,e,n);return s!==o||o.length===2?s:(e&&(o=Tn(o,e,!0)),n&&(o=Tn(o,n,!1)),o)}a(Go,"snapAndCollapseEndpoints");function Rn(t,e){for(const n of t){const o=oo(n,e,2);if(!o)continue;const s=mt(o.points,nt),r=Go(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const l=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=l}}a(Rn,"prepareEdgeEndpointsForRenderer");function ro(t){return new Map(t.map(e=>[e.id,e]))}a(ro,"buildNodeMap");function zo(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!s?.isGroup)break;o=s.id,n=s.parentId}return o}a(zo,"resolveTopLevelGroupId");function Nn(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!s?.isGroup)break;n++,o=s.parentId}return n}a(Nn,"groupDepth");function io(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const l=r.x,f=r.y;if(typeof l!="number"||typeof f!="number")continue;const u=r.width??0,g=r.height??0;e=Math.min(e,l-u/2),n=Math.max(n,l+u/2),o=Math.min(o,f-g/2),s=Math.max(s,f+g/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}a(io,"boundsForChildren");function $o(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}a($o,"applyGroupBounds");function Vo(t){const e=ro(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>Nn(s,e)-Nn(o,e));for(const o of n){const s=t.filter(l=>l.parentId===o.id),r=io(s);r&&$o(o,r)}}a(Vo,"recomputeNestedGroupBounds");function Ke(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(u=>!u.isGroup);let r=1/0,l=-1/0;for(const u of s){const g=u[e];typeof g=="number"&&(r=Math.min(r,g),l=Math.max(l,g))}if(!Number.isFinite(r)||!Number.isFinite(l))return!1;const f=a(u=>r+l-u,"mirror");for(const u of n){const g=u[e];typeof g=="number"&&(u[e]=f(g));const b=u.groupTitleRect;b&&(u.groupTitleRect=e==="x"?{...b,left:f(b.right),right:f(b.left)}:{...b,top:f(b.bottom),bottom:f(b.top)})}for(const u of o)for(const g of u.points??[])g[e]=f(g[e]);return!0}a(Ke,"mirrorAxis");function jo(t){return(t.nodes??[]).some(n=>!n.isGroup)?Ke(t,"y"):!0}a(jo,"applyBtDirectionTransform");function Uo(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(B=>!B.isGroup);let r=1/0,l=1/0;for(const B of s){const G=B.x??0,j=B.y??0;G<r&&(r=G),j<l&&(l=j)}if(!Number.isFinite(r)||!Number.isFinite(l))return!1;const f=36;let u=0,g=0;for(const B of s)u+=B.width??0,g+=B.height??0;const b=u/s.length,p=g/s.length,v=p>0?Math.max(1,b/p):1;for(const B of s){const G=B.x??0,Z=((B.y??0)-l)*v+f,dt=G-r;B.x=Z,B.y=dt}for(const B of o)if(B.points)for(const G of B.points){const j=G.x,dt=(G.y-l)*v+f,pt=j-r;G.x=dt,G.y=pt}Vo(n);const d=n.filter(B=>B.isGroup&&!B.parentId);if(d.length===0)return e==="RL"&&Ke(t,"x"),!0;const h=ro(n),i=new Map;for(const B of n){if(B.isGroup)continue;const G=zo(B,h);if(!G)continue;const j=i.get(G)??[];j.push(B),i.set(G,j)}let y=0;for(const B of d){const G=B.padding??0;G>y&&(y=G)}const L=[];let I=1/0,E=-1/0;for(const B of d){const G=i.get(B.id)??[],j=io(G);j&&(I=Math.min(I,j.minX),E=Math.max(E,j.maxX),L.push({lane:B,contentTop:j.minY,contentBottom:j.maxY,centerY:(j.minY+j.maxY)/2}))}if(I===1/0||E===-1/0)return!0;const T=Math.max(0,E-I),m=Math.max(y,10),M=T+2*m,A=f+M,O=(I+E)/2-M/2-f,F=O+A/2,D=Math.max(y,f);L.sort((B,G)=>B.centerY-G.centerY);for(let B=0;B<L.length;B++){const G=L[B];let j,Z;if(B===0?j=G.contentTop-D:j=(L[B-1].contentBottom+G.contentTop)/2,B===L.length-1)Z=G.contentBottom+D;else{const kt=L[B+1];Z=(G.contentBottom+kt.contentTop)/2}const dt=Math.max(0,Z-j),pt=(j+Z)/2;G.lane.x=F,G.lane.y=pt,G.lane.width=A,G.lane.height=dt,G.lane.swimlaneContentTop=G.contentTop,G.lane.groupTitleRect={left:O,right:O+f,top:j,bottom:Z}}return e==="RL"&&Ke(t,"x"),!0}a(Uo,"applyLrDirectionTransform");var se=1e-6,lr=8,He=lr,fr=[0,He,-He,2*He,-2*He];function Wo(t,e){const{nodeInfoById:n,realNodeRects:o}=Qe(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const l=Zn(mt(r,se),se);if(!l)continue;const{p3:f}=l,u=l.kind==="HVH",g=eo(s,n,se);if(!g)continue;const{srcId:b,dstId:p,srcInfo:v,dstInfo:d,collinearX:h,collinearY:i}=g;if(h||i)continue;let y;const L=v.rect;for(const I of fr){let E,T,m;if(u){const F=d.cy>v.cy?L.bottom:L.top,D=v.cx+I;if(D<=L.left+se||D>=L.right-se)continue;E={x:D,y:F},T={x:D,y:f.y},m={x:f.x,y:f.y}}else{const F=d.cx>v.cx?L.right:L.left,D=v.cy+I;if(D<=L.top+se||D>=L.bottom-se)continue;E={x:F,y:D},T={x:f.x,y:D},m={x:f.x,y:f.y}}const M=oe(E,T,se),A=oe(T,m,se);if(M&&A||!M&&At(E,T,o,[b],1)||!A&&At(T,m,o,[p],1))continue;const R=!M&&$e(E,T,t,s,{epsilon:se,skipDegenerateOther:!0}),k=!A&&$e(T,m,t,s,{epsilon:se,skipDegenerateOther:!0});if(!(R||k)){M?y=[T,m]:A?y=[E,T]:y=[E,T,m];break}}y&&(s.points=y)}}a(Wo,"portSwapToLShape");function Ko(t,e){const{realNodeRects:r,labelNodeRects:l}=me(e.values());for(const f of t){if(f.isLayoutOnly)continue;const u=f.points;if(!u||u.length<4)continue;const g=mt(u,.001);if(g.length<4)continue;const b=g.length-1,p=g[b],v=g[b-1],d=g[b-2],h=p.x-v.x,i=p.y-v.y,y=Math.hypot(h,i);if(y>=10||y<.001)continue;const L=v.x-d.x,I=v.y-d.y;if(Math.hypot(L,I)<.001)continue;const T=wt(v,p,.001),m=Et(v,p,.001),M=wt(d,v,.001),A=Et(d,v,.001);if(!(T&&A||m&&M))continue;const R=f.end,k=f.start,O=R?e.get(R):void 0;if(!O)continue;const F=O.x??0,D=O.y??0,B=qt(O);if(!B)continue;let G,j;if(A){const W=I<0;G={x:F,y:d.y},j={x:F,y:W?B.bottom:B.top}}else{const W=L>0;G={x:d.x,y:D},j={x:W?B.right:B.left,y:D}}if(At(G,j,r,R?[R]:[],-2)||At(G,j,l,[],-2))continue;if(k){const W=e.get(k),et=W?qt(W):void 0;if(et&&Jn(G,et,2))continue}const Z=a((W,et)=>`${W.x.toFixed(3)},${W.y.toFixed(3)}|${et.x.toFixed(3)},${et.y.toFixed(3)}`,"ownSegmentKey"),dt=new Set;for(let W=0;W<g.length-1;W++)dt.add(Z(g[W],g[W+1]));const pt=a((W,et)=>{for(const at of t){if(at===f||at.isLayoutOnly)continue;const gt=at.points;if(!(!gt||gt.length<2))for(let xt=0;xt<gt.length-1;xt++){const vt=gt[xt],Vt=gt[xt+1];if(!dt.has(Z(vt,Vt))&&ae(W,et,vt,Vt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(pt(G,j))continue;if(b-3>=0){const W=g[b-3],et=[k,R].filter(at=>!!at);if(At(W,G,r,et,-2)||pt(W,G))continue}const Bt=[...g.slice(0,b-2),G,j];f.points=Bt;const Q=f.labelNodeId;if(Q){const W=e.get(Q);if(W){const et=W.width??0,at=W.height??0;if(et>0&&at>0){let gt,xt,vt=-1;for(let Vt=0;Vt<Bt.length-1;Vt++){const jt=Bt[Vt],Ut=Bt[Vt+1],te=Math.hypot(Ut.x-jt.x,Ut.y-jt.y),Me=ht(jt,Ut,.001),fe=ft(jt,Ut,.001);(Me&&te>=et+2||fe&&te>=at+2)&&te>vt&&(vt=te,gt=(jt.x+Ut.x)/2,xt=(jt.y+Ut.y)/2)}gt!==void 0&&xt!==void 0&&(W.x=gt,W.y=xt)}}}}}a(Ko,"collapseShortTerminalStub");var J=.001,Ft=8,it=Ee,gn=a((t,e)=>ft(t,e,J)||ht(t,e,J),"orthogonallyAligned");function qo(t,e){const s=a((d,h)=>{const i=d.x??0,y=d.y??0,L=h.x-i,I=h.y-y;let E=(d.width??0)/2,T=(d.height??0)/2;return Math.abs(I)*E>Math.abs(L)*T?(I<0&&(T=-T),{x:i+(I===0?0:T*L/I),y:y+T}):(L<0&&(E=-E),{x:i+E,y:y+(L===0?0:E*I/L)})},"rectIntersect"),r=a((d,h)=>{const i=mt(d.points??[]);if(i.length<2)return;const y=h?d.start:d.end,L=y?e.get(y):void 0,I=L?qt(L):void 0;if(!L||!y||!I)return;const E=h?i[0]:i[i.length-1],T=h?i[1]:i[i.length-2],m=s(L,E);let M=E;if(gn(T,m)&&(M=T),ft(m,M,J))return{edge:d,edgeId:String(d.id??""),nodeId:y,atStart:h,orientation:"V",coord:m.x,min:Math.min(m.y,M.y),max:Math.max(m.y,M.y),boundary:m,railEnd:M,rect:I};if(ht(m,M,J))return{edge:d,edgeId:String(d.id??""),nodeId:y,atStart:h,orientation:"H",coord:m.y,min:Math.min(m.x,M.x),max:Math.max(m.x,M.x),boundary:m,railEnd:M,rect:I}},"terminalLaneFor"),l=a((d,h)=>Math.max(0,Math.min(d.max,h.max)-Math.max(d.min,h.min)),"projectedOverlapLength"),f=a((d,h)=>d.nodeId!==h.nodeId||d.orientation!==h.orientation?!1:d.orientation==="H"?(Math.abs(d.boundary.x-d.rect.left)<1||Math.abs(d.boundary.x-d.rect.right)<1)&&ft(d.boundary,h.boundary,1):(Math.abs(d.boundary.y-d.rect.top)<1||Math.abs(d.boundary.y-d.rect.bottom)<1)&&ht(d.boundary,h.boundary,1),"sameTerminalFace"),u=a((d,h)=>d.nodeId!==h.nodeId||d.orientation!==h.orientation?!1:l(d,h)>=Ft&&Math.abs(d.coord-h.coord)<.5,"exactTerminalLaneConflict"),g=a((d,h)=>{if(d.nodeId!==h.nodeId||d.orientation!==h.orientation||d.orientation!=="H"||d.atStart===h.atStart)return!1;const i=l(d,h);if(i<Ft)return!1;const y=d.rect.bottom-d.rect.top;return i<y||i>2*y?!1:f(d,h)&&Math.abs(d.coord-h.coord)<16},"nearTerminalLaneConflict"),b=a((d,h)=>{const i=mt(d.edge.points??[]);if(i.length<2)return;const y=d.orientation==="V"?{x:d.boundary.x+h,y:d.boundary.y}:{x:d.boundary.x,y:d.boundary.y+h},L=d.orientation==="V"?{x:d.railEnd.x+h,y:d.railEnd.y}:{x:d.railEnd.x,y:d.railEnd.y+h};if(!a(()=>Math.abs(d.boundary.y-d.rect.top)<1||Math.abs(d.boundary.y-d.rect.bottom)<1?ht(y,d.boundary,J)&&y.x>=d.rect.left+1&&y.x<=d.rect.right-1:Math.abs(d.boundary.x-d.rect.left)<1||Math.abs(d.boundary.x-d.rect.right)<1?ft(y,d.boundary,J)&&y.y>=d.rect.top+1&&y.y<=d.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(d.atStart){const M=i.length>1&&oe(i[1],d.railEnd,J),A=i.slice(M?2:1),R=A[0];return R&&!gn(R,L)?void 0:[y,L,...A]}const E=i.length>1&&oe(i[i.length-2],d.railEnd,J),T=i.slice(0,E?-2:-1),m=T[T.length-1];if(!(m&&!gn(m,L)))return[...T,L,y]},"shiftedCandidate"),p=a(d=>{const h=d.edge,i=mt(h.points??[]);if(i.length!==2)return!1;const y=h.start,L=h.end,I=y?e.get(y):void 0,E=L?e.get(L):void 0;if(!I||!E)return!1;const T=I.x??0,m=I.y??0,M=E.x??0,A=E.y??0,[R,k]=i;return ht(R,k,J)&&Math.abs(m-A)<1&&Math.abs(T-M)>1||ft(R,k,J)&&Math.abs(T-M)<1&&Math.abs(m-A)>1},"laneIsStraightCollinearConnector"),v=[-7,7,-14,14,-21,21];for(let d=0;d<8;d++){const h=t.filter(y=>!y.isLayoutOnly).flatMap(y=>[r(y,!0),r(y,!1)]).filter(y=>!!y);let i=!1;for(let y=0;y<h.length&&!i;y++)for(let L=y+1;L<h.length&&!i;L++){const I=h[y],E=h[L];if(I.edge===E.edge||!(u(I,E)||g(I,E)))continue;const T=!u(I,E),m=[I,E].sort((M,A)=>{const R=p(M),k=p(A);return R!==k?Number(R)-Number(k):+!A.atStart-+!M.atStart});for(const M of m){for(const A of v){const R=b(M,A);if(!R)continue;const k=r({...M.edge,points:R},M.atStart);if(!(!k||h.some(O=>O.edge!==M.edge&&(u(k,O)||T&&g(k,O))))){M.edge.points=R,i=!0;break}}if(i)break}}if(!i)return}}a(qo,"separateSharedRenderedTerminalLanes");function Zo(t,e){const{realNodeRects:o,labelNodeRects:s}=me(e.values()),r=a((f,u)=>{const g=f.start,b=f.end,p=it(u);if(p.length!==u.length-1)return!1;const v=[g,b].filter(d=>!!d);for(const d of p)if(At(d.a,d.b,o,v,-2)||At(d.a,d.b,s,[],-2))return!1;for(const d of t){if(d===f||d.isLayoutOnly)continue;const h=d.points;if(!(!h||h.length<2)){for(const i of p)for(const y of it(mt(h)))if(ie(i,y,.5)>=Ft||ae(i.a,i.b,y.a,y.b,J))return!1}}return!0},"candidateIsSafe"),l=a((f,u)=>{if(u+4>=f.length)return;const g=f[u],b=f[u+1],p=f[u+2],v=f[u+3],d=f[u+4],h=wt(g,b)&&Et(b,p)&&wt(p,v)&&Et(v,d)&&ft(g,v,J)&&ft(g,d,J)&&ft(b,p,J)&&(b.x-g.x)*(v.x-p.x)<0,i=Et(g,b)&&wt(b,p)&&Et(p,v)&&wt(v,d)&&ht(g,v,J)&&ht(g,d,J)&&ht(b,p,J)&&(b.y-g.y)*(v.y-p.y)<0;if(h||i)return mt([...f.slice(0,u+1),d,...f.slice(u+5)]);if(u+5>=f.length)return;const y=f[u+5],L=Et(g,b)&&wt(b,p)&&Et(p,v)&&wt(v,d)&&Et(d,y)&&ft(g,d,J)&&ft(g,y,J)&&ft(p,v,J)&&(p.x-b.x)*(d.x-v.x)<0,I=wt(g,b)&&Et(b,p)&&wt(p,v)&&Et(v,d)&&wt(d,y)&&ht(g,d,J)&&ht(g,y,J)&&ht(p,v,J)&&(p.y-b.y)*(d.y-v.y)<0;if(!(!L&&!I))return mt([...f.slice(0,u+1),y,...f.slice(u+6)])},"withoutDogleg");for(let f=0;f<8;f++){let u=!1;for(const g of t){if(g.isLayoutOnly)continue;const b=mt(g.points??[]);for(let p=0;p<=b.length-5;p++){const v=l(b,p);if(!(!v||!r(g,v))){g.points=v,u=!0;break}}if(u)break}if(!u)return}}a(Zo,"collapseRedundantRectangularDoglegs");function On(t,e){const{realNodeRects:r,labelNodeRects:l}=me(e.values()),f=t.filter(h=>!h.isLayoutOnly),u=a((h,i,y)=>mt(h===i?y??[]:h.points??[]),"pointsFor"),g=a((h,i)=>{let y=0;for(let L=0;L<f.length;L++){const I=it(u(f[L],h,i));for(let E=L+1;E<f.length;E++){const T=it(u(f[E],h,i));for(const m of I)for(const M of T)ae(m.a,m.b,M.a,M.b,J)&&y++}}return y},"strictCrossingCount"),b=a(h=>{const i=it(h);if(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"),p=a((h,i)=>{const y=[h.start,h.end].filter(L=>!!L);return r.filter(L=>{if(y.includes(L.id))return!1;const I=L.rect;return i.horizontal?$t(i.a.x,i.b.x,I.left,I.right)>=Ft&&i.a.y>=I.top-2&&i.a.y<=I.bottom+2:$t(i.a.y,i.b.y,I.top,I.bottom)>=Ft&&i.a.x>=I.left-2&&i.a.x<=I.right+2})},"blockingRectsFor"),v=a((h,i,y)=>{const L=h.map(E=>({...E}));if(i.horizontal)L[i.index].y=y,L[i.index+1].y=y;else if(i.vertical)L[i.index].x=y,L[i.index+1].x=y;else return;const I=ce(mt(L));return it(I).length===I.length-1?I:void 0},"candidateByMovingRail"),d=a((h,i,y)=>{const L=[h.start,h.end].filter(E=>!!E),I=it(i);if(I.length!==i.length-1)return!1;for(const E of I)if(At(E.a,E.b,r,L,-2)||At(E.a,E.b,l,[],-2))return!1;for(const E of f)if(E!==h){for(const T of I)for(const m of it(u(E)))if(ie(T,m,.5)>=Ft)return!1}return g(h,i)<=y},"candidateIsSafe");for(let h=0;h<8;h++){const i=g();let y=!1;for(const L of f){const I=u(L),E=b(I);if(!E)continue;const T=p(L,E.segment);if(T.length===0)continue;const m=E.horizontal?[Math.min(...T.map(M=>M.rect.top))-20,Math.max(...T.map(M=>M.rect.bottom))+20]:[Math.min(...T.map(M=>M.rect.left))-20,Math.max(...T.map(M=>M.rect.right))+20];for(const M of m){const A=v(I,E.segment,M);if(!(!A||!d(L,A,i))){L.points=A,y=!0;break}}if(y)break}if(!y)return}}a(On,"liftObstacleHuggingSameSideRails");function Bn(t,e){const o=a(u=>{const g=u.groupTitleRect;if(!(!g||typeof g.left!="number"||typeof g.right!="number"||typeof g.top!="number"||typeof g.bottom!="number"||!Number.isFinite(g.left)||!Number.isFinite(g.right)||!Number.isFinite(g.top)||!Number.isFinite(g.bottom)||g.right<=g.left||g.bottom<=g.top))return{left:g.left,right:g.right,top:g.top,bottom:g.bottom}},"validTitleRect"),s=a(u=>{if(!u.isGroup||u.parentId)return;const g=u.direction,b=typeof g=="string"?g.toUpperCase():"";if(b==="LR"||b==="RL"||b==="BT")return;const p=o(u),v=u.y,d=u.height;if(!p||typeof v!="number"||typeof d!="number"||!Number.isFinite(v)||!Number.isFinite(d)||d<=0)return;const h=p.right-p.left,i=p.bottom-p.top;if(!(i<=0||h<i))return{node:u,rect:p}},"topLaneTitleFor"),r=a((u,g)=>{if(!u.horizontal)return!1;const b=u.a.y;return b<=g.top+J||b>=g.bottom-J?!1:$t(u.a.x,u.b.x,g.left,g.right)>=Ft},"horizontalSegmentIntersectsTitle"),l=[...e.values()].map(s).filter(u=>!!u);if(l.length===0)return;let f=0;for(const u of t){if(u.isLayoutOnly)continue;const g=mt(u.points??[]);for(const b of it(g))for(const p of l)r(b,p.rect)&&(f=Math.max(f,p.rect.bottom-b.a.y+4))}if(!(f<=J))for(const u of l){const g=u.node.y,b=u.node.height;typeof g!="number"||typeof b!="number"||!Number.isFinite(g)||!Number.isFinite(b)||b<=0||(u.node.y=g-f/2,u.node.height=b+f,u.node.groupTitleRect={...u.rect,top:u.rect.top-f,bottom:u.rect.bottom-f})}}a(Bn,"liftTopLaneTitleBandsAboveRails");function Pn(t,e){const o=a(g=>{const b=g.groupTitleRect;if(!(!b||typeof b.left!="number"||typeof b.right!="number"||typeof b.top!="number"||typeof b.bottom!="number"||!Number.isFinite(b.left)||!Number.isFinite(b.right)||!Number.isFinite(b.top)||!Number.isFinite(b.bottom)||b.right<=b.left||b.bottom<=b.top))return{left:b.left,right:b.right,top:b.top,bottom:b.bottom}},"validTitleRect"),s=a(g=>{if(!g.isGroup||g.parentId||g.direction!=="LR")return;const p=o(g),v=g.x,d=g.width;if(!p||typeof v!="number"||typeof d!="number"||!Number.isFinite(v)||!Number.isFinite(d)||d<=0)return;const h=p.right-p.left,i=p.bottom-p.top;if(!(h<=0||i<h))return{node:g,rect:p}},"leftLaneTitleFor"),r=a((g,b)=>{if(!g.vertical)return!1;const p=g.a.x;return p<=b.left+J||p>=b.right-J?!1:$t(g.a.y,g.b.y,b.top,b.bottom)>=Ft},"verticalSegmentIntersectsTitle"),l=a((g,b)=>{if(!g.horizontal)return!1;const p=g.a.y;return p<=b.top+J||p>=b.bottom-J?!1:$t(g.a.x,g.b.x,b.left,b.right)>=Ft},"horizontalSegmentIntersectsTitle"),f=[...e.values()].map(s).filter(g=>!!g);if(f.length===0)return;let u=0;for(const g of t){if(g.isLayoutOnly)continue;const b=mt(g.points??[]);for(const p of it(b))for(const v of f)if(r(p,v.rect))u=Math.max(u,v.rect.right-p.a.x+4);else if(l(p,v.rect)){const d=Math.min(p.a.x,p.b.x);u=Math.max(u,v.rect.right-d+4)}}if(!(u<=J))for(const g of f){const b=g.node.x,p=g.node.width;typeof b!="number"||typeof p!="number"||!Number.isFinite(b)||!Number.isFinite(p)||p<=0||(g.node.x=b-u/2,g.node.width=p+u,g.node.groupTitleRect={...g.rect,left:g.rect.left-u,right:g.rect.right-u})}}a(Pn,"shiftLeftLaneTitleBandsLeftOfRails");function Jo(t,e){const{realNodeRects:o}=me(e.values()),s=t.filter(h=>!h.isLayoutOnly),r=a((h,i=new Map)=>mt(i.get(h)??h.points??[]),"replacementPointsFor"),l=a((h=new Map)=>{let i=0;for(let y=0;y<s.length;y++){const L=it(r(s[y],h));for(let I=y+1;I<s.length;I++){const E=it(r(s[I],h));for(const T of L)for(const m of E)ae(T.a,T.b,m.a,m.b,J)&&i++}}return i},"crossingCount"),f=a((h=new Map)=>s.reduce((i,y)=>i+Qt(r(y,h)),0),"totalBends"),u=a(h=>{const i=r(h);if(i.length<4)return;const y=i[i.length-2],L=i[i.length-1];if(!(!wt(y,L,J)&&!Et(y,L,J)))return{tailStart:y,terminal:L}},"terminalTailFor"),g=a((h,i)=>{const y=r(h);if(y.length<3)return;const L=y[0],I=y[1];let E;if(wt(L,I,J))E={x:I.x,y:i.tailStart.y};else if(Et(L,I,J))E={x:i.tailStart.x,y:I.y};else return;const T=ce(mt([L,I,E,i.tailStart,i.terminal]));return it(T).length===T.length-1?T:void 0},"candidateWithDestinationTail"),b=a((h,i)=>{const y=[h.start,h.end].filter(L=>!!L);for(const L of it(i))if(At(L.a,L.b,o,y,-2))return!0;return!1},"pathHasNodeHit"),p=a((h,i,y)=>{for(const L of s)if(L!==h){for(const I of it(i))for(const E of it(r(L,y)))if(ie(I,E,.5)>=Ft)return!0}return!1},"pathHasSharedTrack"),v=a((h,i,y)=>!b(h,i)&&!p(h,i,y),"candidateIsSafe"),d=a(()=>{const h=new Map;for(const i of s){const y=i.end;if(!y||!e.has(y)||r(i).length<4)continue;const I=h.get(y)??[];I.push(i),h.set(y,I)}return h},"edgesByDestination");for(let h=0;h<4;h++){const i=l();if(i===0)return;const y=f();let L,I=i,E=y;for(const T of d().values())for(let m=0;m<T.length;m++)for(let M=m+1;M<T.length;M++){const A=T[m],R=T[M],k=u(A),O=u(R);if(!k||!O)continue;const F=g(A,O),D=g(R,k);if(!F||!D)continue;const B=new Map([[A,F],[R,D]]);if(!v(A,F,B)||!v(R,D,B))continue;const G=l(B),j=f(B);G>=i||G>I||G===I&&j>=E||(L=B,I=G,E=j)}if(!L)return;for(const[T,m]of L)T.points=m}}a(Jo,"swapDestinationTerminalTailsToReduceCrossings");function Qo(t,e){const{realNodeRects:r,labelNodeRects:l}=me(e.values()),f=t.filter(T=>!T.isLayoutOnly),u=a((T,m=new Map)=>mt(m.get(T)??T.points??[]),"replacementPointsFor"),g=a((T=new Map)=>{let m=0;for(let M=0;M<f.length;M++){const A=it(u(f[M],T));for(let R=M+1;R<f.length;R++){const k=it(u(f[R],T));for(const O of A)for(const F of k)ae(O.a,O.b,F.a,F.b,J)&&m++}}return m},"strictCrossingCount"),b=a((T=new Map)=>f.reduce((m,M)=>m+Qt(u(M,T)),0),"totalBends"),p=a(T=>{const m=T.start,M=T.end,A=m?e.get(m):void 0,R=M?e.get(M):void 0,k=A?qt(A):void 0,O=R?qt(R):void 0;return k&&O?{src:k,dst:O}:void 0},"endpointRectsFor"),v=a((T,m,M)=>{if(M.index<=0||M.index+1>=m.length-1)return;const A=p(T);if(A){if(M.vertical){const R=M.a.x,k=Math.min(A.src.left,A.dst.left),O=Math.max(A.src.right,A.dst.right),F=R<k-J?"left":R>O+J?"right":void 0;return F?{edge:T,points:m,segmentIndex:M.index,axis:"vertical",side:F,coord:R,min:Math.min(M.a.y,M.b.y),max:Math.max(M.a.y,M.b.y)}:void 0}if(M.horizontal){const R=M.a.y,k=Math.min(A.src.top,A.dst.top),O=Math.max(A.src.bottom,A.dst.bottom),F=R<k-J?"top":R>O+J?"bottom":void 0;return F?{edge:T,points:m,segmentIndex:M.index,axis:"horizontal",side:F,coord:R,min:Math.min(M.a.x,M.b.x),max:Math.max(M.a.x,M.b.x)}:void 0}}},"externalRailForSegment"),d=a(()=>{const T=[];for(const m of f){const M=u(m);for(const A of it(M)){const R=v(m,M,A);R&&T.push(R)}}return T},"collectExternalRails"),h=a((T,m)=>T.edge!==m.edge&&T.axis===m.axis&&T.side===m.side&&$t(T.min,T.max,m.min,m.max)>=Ft,"railsInteract"),i=a(T=>{const m=[],M=new Set;for(const A of T){if(M.has(A))continue;const R=[A],k=[];for(M.add(A);R.length>0;){const O=R.pop();k.push(O);for(const F of T)!M.has(F)&&h(O,F)&&(M.add(F),R.push(F))}k.length>1&&m.push(k)}return m},"connectedComponents"),y=a(T=>{const m=[];for(const M of T)m.some(A=>Math.abs(A-M.coord)<J)||m.push(M.coord);for(;m.length<T.length;){const M=Math.min(...m),A=Math.max(...m),R=T[0].side;m.push(R==="left"||R==="top"?M-12*(T.length-m.length):A+12*(T.length-m.length))}return m},"uniqueCoordsFor"),L=a(T=>{const m=T.map(R=>R.coord),M=y(T),A=[];if(T.length<=6){const R=new Array(M.length).fill(!1),k=[],O=a(()=>{if(k.length===T.length){k.some((F,D)=>Math.abs(F-m[D])>=J)&&A.push([...k]);return}for(const[F,D]of M.entries())R[F]||(R[F]=!0,k.push(D),O(),k.pop(),R[F]=!1)},"visit");return O(),A}for(let R=0;R<m.length;R++)for(let k=R+1;k<m.length;k++){const O=[...m];[O[R],O[k]]=[O[k],O[R]],A.push(O)}return A},"coordinateAssignmentsFor"),I=a((T,m)=>{const M=new Map;for(const[R,k]of T.entries()){const O=m[R],F=M.get(k.edge)??k.points.map(D=>({x:D.x,y:D.y}));k.axis==="vertical"?(F[k.segmentIndex].x=O,F[k.segmentIndex+1].x=O):(F[k.segmentIndex].y=O,F[k.segmentIndex+1].y=O),M.set(k.edge,F)}const A=new Map;for(const[R,k]of M){const O=ce(mt(k));if(it(O).length!==O.length-1)return;A.set(R,O)}return A},"replacementsForAssignment"),E=a(T=>{for(const[m,M]of T){const A=[m.start,m.end].filter(R=>!!R);for(const R of it(M))if(At(R.a,R.b,r,A,-2)||At(R.a,R.b,l,[],-2))return!1}for(let m=0;m<f.length;m++){const M=f[m],A=T.has(M),R=it(u(M,T));for(let k=m+1;k<f.length;k++){const O=f[k];if(!A&&!T.has(O))continue;const F=it(u(O,T));for(const D of R)for(const B of F)if(ie(D,B,.5)>=Ft)return!1}}return!0},"candidateIsSafe");for(let T=0;T<4;T++){const m=g();if(m===0)return;let M,A=m,R=b(),k=Number.POSITIVE_INFINITY;for(const O of i(d()))for(const F of L(O)){const D=I(O,F);if(!D||!E(D))continue;const B=g(D);if(B>=m)continue;const G=b(D),j=O.reduce((Z,dt,pt)=>Z+Math.abs(F[pt]-dt.coord),0);B>A||B===A&&(G>R||G===R&&j>=k)||(M=D,A=B,R=G,k=j)}if(!M)return;for(const[O,F]of M)O.points=F}}a(Qo,"reassignCrossingExternalRailChannels");function ts(t,e){const{realNodeRects:o,labelNodeRects:s}=me(e.values()),r=t.filter(d=>!d.isLayoutOnly),l=a((d,h,i)=>mt(d===h?i??[]:d.points??[]),"pointsFor"),f=a(d=>it(d).reduce((h,i)=>{const y=i.a.x-i.b.x,L=i.a.y-i.b.y;return h+Math.hypot(y,L)},0),"pathLength"),u=a((d,h)=>{let i=0;for(let y=0;y<r.length;y++){const L=it(l(r[y],d,h));for(let I=y+1;I<r.length;I++){const E=it(l(r[I],d,h));for(const T of L)for(const m of E)ae(T.a,T.b,m.a,m.b,J)&&i++}}return i},"strictCrossingCount"),g=a((d,h)=>{if(d.horizontal){const i=d.a.y;return(Math.abs(i-h.top)<1||Math.abs(i-h.bottom)<1)&&$t(d.a.x,d.b.x,h.left,h.right)>=Ft}if(d.vertical){const i=d.a.x;return(Math.abs(i-h.left)<1||Math.abs(i-h.right)<1)&&$t(d.a.y,d.b.y,h.top,h.bottom)>=Ft}return!1},"segmentRunsAlongRectBorder"),b=a(d=>{const h=[d.start,d.end].filter(y=>!!y),i=[];for(const y of h){const L=e.get(y),I=L?qt(L):void 0;I&&i.push(I)}return i},"endpointRectsFor"),p=a((d,h)=>{if(h+3>=d.length)return[];const i=d[h],y=d[h+1],L=d[h+2],I=d[h+3],E=wt(i,y,J)&&Et(y,L,J)&&wt(L,I,J),T=Et(i,y,J)&&wt(y,L,J)&&Et(L,I,J);if(!E&&!T)return[];if(!(E?Math.sign(y.x-i.x)!==Math.sign(I.x-L.x):Math.sign(y.y-i.y)!==Math.sign(I.y-L.y)))return[];const M=ft(i,I,J)||ht(i,I,J)?[]:[{x:i.x,y:I.y},{x:I.x,y:i.y}],A=M.length===0?[[...d.slice(0,h+1),...d.slice(h+3)]]:M.map(k=>[...d.slice(0,h+1),k,...d.slice(h+3)]),R=new Set;return A.map(k=>ce(mt(k))).filter(k=>{if(it(k).length!==k.length-1||!k.some(F=>oe(F,I,J)))return!1;const O=k.map(F=>`${F.x.toFixed(3)},${F.y.toFixed(3)}`).join("|");return R.has(O)?!1:(R.add(O),!0)})},"shortcutCandidatesAt"),v=a((d,h,i)=>{const y=[d.start,d.end].filter(I=>!!I),L=b(d);for(const I of it(h))if(At(I.a,I.b,o,y,-2)||At(I.a,I.b,s,[],-2)||L.some(E=>g(I,E)))return!1;for(const I of r)if(I!==d){for(const E of it(h))for(const T of it(l(I)))if(ie(E,T,.5)>=Ft)return!1}return u(d,h)<=i},"candidateIsSafe");for(let d=0;d<8;d++){const h=u();let i,y,L=h,I=Number.POSITIVE_INFINITY,E=Number.POSITIVE_INFINITY;for(const T of r){const m=l(T),M=Qt(m,J),A=f(m);for(let R=0;R<=m.length-4;R++)for(const k of p(m,R)){const O=Qt(k,J),F=f(k);if(!(O<M||O===M&&F<A-J)||!v(T,k,h))continue;const B=u(T,k);B>L||B===L&&(O>I||O===I&&F>=E)||(i=T,y=k,L=B,I=O,E=F)}}if(!i||!y)return;i.points=y}}a(ts,"shortcutRedundantOrthogonalJogs");function es(t,e){const l=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const _=N.x??0,H=N.y??0,V=qt(N);V&&l.push({id:String(N.id??""),cx:_,cy:H,rect:V})}if(l.length===0)return;const f=new Map(l.map(N=>[N.id,N])),u=l.map(N=>({id:N.id,rect:N.rect})),g=["top","bottom","left","right"],b={top:Math.min(...l.map(N=>N.rect.top))-20,bottom:Math.max(...l.map(N=>N.rect.bottom))+20,left:Math.min(...l.map(N=>N.rect.left))-20,right:Math.max(...l.map(N=>N.rect.right))+20},p=t.filter(N=>!N.isLayoutOnly),v=new Map(p.map((N,_)=>[N,_])),d=a(N=>{const _=N==="left"||N==="top"?-1:1,H=[];for(let V=0;V<=2;V++)H.push(b[N]+_*20*V);return H},"outwardTracksForSide"),h=a((N,_=new Map)=>mt(_.get(N)??N.points??[]),"replacementPointsFor"),i=a((N,_)=>{let H=0;for(const V of N)for(const c of _)ae(V.a,V.b,c.a,c.b,J)&&H++;return H},"crossingCountBetweenSegments"),y=a((N,_)=>i(it(N),it(_)),"crossingCountBetweenPaths"),L=a((N=new Map)=>{let _=0;const H=[],V=new Set,c=[],x=a(S=>{V.has(S)||(V.add(S),c.push(S))},"addEdge");for(let S=0;S<p.length;S++){const C=p[S],w=h(C,N);for(let P=S+1;P<p.length;P++){const U=p[P],q=y(w,h(U,N));q>0&&(_+=q,H.push({first:C,second:U,count:q}),x(C),x(U))}}return c.sort((S,C)=>(v.get(S)??0)-(v.get(C)??0)),{count:_,pairs:H,edgeSet:V,edges:c}},"crossingSnapshot"),I=a((N,_)=>{const H=new Set(_.keys());if(H.size===0)return N.count;let V=0;for(const x of N.pairs)(H.has(x.first)||H.has(x.second))&&(V+=x.count);let c=0;for(let x=0;x<p.length;x++){const S=p[x],C=H.has(S),w=h(S,_);for(let P=x+1;P<p.length;P++){const U=p[P];!C&&!H.has(U)||(c+=y(w,h(U,_)))}}return N.count-V+c},"crossingCountWithReplacements"),E=a(N=>{const _=new Map;for(const c of N.pairs){const x=_.get(c.first)??new Set;x.add(c.second),_.set(c.first,x);const S=_.get(c.second)??new Set;S.add(c.first),_.set(c.second,S)}const H=[],V=new Set;for(const c of N.edges){if(V.has(c))continue;const x=[c],S=[];for(V.add(c);x.length>0;){const C=x.pop();S.push(C);for(const w of _.get(C)??[])V.has(w)||(V.add(w),x.push(w))}S.sort((C,w)=>(v.get(C)??0)-(v.get(w)??0)),S.length>1&&H.push(S)}return H},"crossingComponents"),T=a(N=>[N.start,N.end].filter(_=>!!_),"endpointIdsFor"),m=a(N=>{const _=[];for(const H of E(N)){const V=new Set(H),c=new Set(H.flatMap(S=>T(S))),x=[...H];for(const S of p)V.has(S)||T(S).some(C=>c.has(C))&&x.push(S);x.sort((S,C)=>(v.get(S)??0)-(v.get(C)??0)),_.push(x)}return _},"pairSearchGroups"),M=a((N,_,H)=>I(N,new Map([[_,H]])),"crossingCountWithSingleReplacement"),A=a(N=>{const _=new Map;for(const H of N.pairs)_.set(H.first,(_.get(H.first)??0)+H.count),_.set(H.second,(_.get(H.second)??0)+H.count);return _},"currentCrossingsByEdge"),R=a(N=>N.slice(1).reduce((_,H,V)=>{const c=N[V];return _+Math.abs(H.x-c.x)+Math.abs(H.y-c.y)},0),"pathLength"),k=a((N=new Map)=>p.reduce((_,H)=>_+Qt(h(H,N)),0),"totalBends"),O=a((N=new Map)=>p.reduce((_,H)=>_+R(h(H,N)),0),"totalLength"),F=a((N,_,H=new Map)=>{const V=it(_);for(const c of p)if(c!==N){for(const x of V)for(const S of it(h(c,H)))if(ie(x,S,.5)>=Ft)return!0}return!1},"pathHasSegmentConflict"),D=a((N,_)=>{const H=[N.start,N.end].filter(V=>!!V);for(const V of it(_))if(At(V.a,V.b,u,H,-2))return!0;return!1},"pathHitsNode"),B=a((N,_)=>{const H=ce(mt(_));it(H).length===H.length-1&&N.push(H)},"pushOrthogonalCandidate"),G=a(N=>N==="left"||N==="right","sideIsHorizontal"),j=a((N,_,H)=>{switch(_){case"left":return Math.min(N.x,H.x)-20;case"right":return Math.max(N.x,H.x)+20;case"top":return Math.min(N.y,H.y)-20;case"bottom":return Math.max(N.y,H.y)+20}},"localTrackForSameSide"),Z=a((N,_,H,V)=>{const c=H==="left"||H==="top"?-1:1,x=[j(_,H,V),b[H]];for(const S of x)for(let C=0;C<=2;C++)B(N,to(_,H,V,S+c*20*C))},"addSameSideCandidates"),dt=a((N,_,H,V,c)=>{for(const x of d(H))for(const S of d(c))B(N,[_,{x,y:_.y},{x,y:S},{x:V.x,y:S},V])},"addHorizontalToVerticalCandidates"),pt=a((N,_,H,V,c)=>{for(const x of d(H))for(const S of d(c))B(N,[_,{x:_.x,y:x},{x:S,y:x},{x:S,y:V.y},V])},"addVerticalToHorizontalCandidates"),kt=a((N,_,H,V,c)=>{const x=[...d("top"),...d("bottom")];for(const S of d(H))for(const C of d(c))for(const w of x)B(N,[_,{x:S,y:_.y},{x:S,y:w},{x:C,y:w},{x:C,y:V.y},V])},"addHorizontalPairCandidates"),Bt=a((N,_,H,V,c)=>{const x=[...d("left"),...d("right")];for(const S of d(H))for(const C of d(c))for(const w of x)B(N,[_,{x:_.x,y:S},{x:w,y:S},{x:w,y:C},{x:V.x,y:C},V])},"addVerticalPairCandidates"),Q=a(N=>{const _=new Set;return N.map(H=>mt(H)).filter(H=>{const V=H.map(c=>`${c.x.toFixed(3)},${c.y.toFixed(3)}`).join("|");return _.has(V)||H.length<2?!1:(_.add(V),!0)})},"dedupeCandidatePaths"),W=a((N,_,H,V)=>{const c=[],x=Qn(N,_,H,V,20,J);x&&B(c,x),_===V&&Z(c,N,_,H);const S=G(_),C=G(V);return S&&!C?dt(c,N,_,H,V):!S&&C?pt(c,N,_,H,V):S?kt(c,N,_,H,V):Bt(c,N,_,H,V),Q(c)},"buildCandidatesForSides"),et=a((N,_,H,V)=>{const c=[...d("left"),...d("right")],x=[...d("top"),...d("bottom")];for(const S of g){const C=Ie(V,S),w=S==="top"||S==="bottom"?d(S):x;for(const P of c){B(N,[_,H,{x:P,y:H.y},{x:P,y:C.y},C]);for(const U of w)B(N,[_,H,{x:P,y:H.y},{x:P,y:U},{x:C.x,y:U},C])}}},"addVerticalDepartureOuterTrackCandidates"),at=a((N,_,H,V)=>{const c=[...d("left"),...d("right")],x=[...d("top"),...d("bottom")];for(const S of g){const C=Ie(V,S),w=S==="left"||S==="right"?d(S):c;for(const P of x){B(N,[_,H,{x:H.x,y:P},{x:C.x,y:P},C]);for(const U of w)B(N,[_,H,{x:H.x,y:P},{x:U,y:P},{x:U,y:C.y},C])}}},"addHorizontalDepartureOuterTrackCandidates"),gt=a(N=>{const _=N.start,H=N.end,V=H?f.get(H):void 0;if(!_||!V)return[];const c=mt(N.points??[]);if(c.length<4)return[];const x=c[0],S=c[1],C=[];return Et(x,S,J)?et(C,x,S,V):wt(x,S,J)&&at(C,x,S,V),C},"terminalPreservingOuterTrackCandidates"),xt=a(N=>{const _=N.start,H=N.end,V=_?f.get(_):void 0,c=H?f.get(H):void 0;if(!V||!c)return[];const x=[];for(const S of g){const C=Ie(V,S);for(const w of g)x.push(...W(C,S,Ie(c,w),w))}return x.push(...gt(N)),x},"candidatePathsFor"),vt=a(()=>new Map(p.map(N=>[N,it(h(N))])),"currentSegmentsByEdge"),Vt=a((N,_,H)=>{const V=new Set;for(const c of p){if(c===N)continue;const x=H.get(c)??it(h(c));_.some(S=>x.some(C=>ie(S,C,.5)>=Ft))&&V.add(c)}return V},"sharedTrackConflictsFor"),jt=a((N,_,H,V)=>{const c=new Set;return xt(N).map(S=>ce(mt(S))).filter(S=>{if(D(N,S))return!1;const C=S.map(w=>`${w.x.toFixed(3)},${w.y.toFixed(3)}`).join("|");return c.has(C)||S.length<2?!1:(c.add(C),!0)}).map(S=>{const C=it(S);let w=0;for(const P of p)P!==N&&(w+=i(C,H.get(P)??it(h(P))));return{candidate:S,candidateSegments:C,crossings:_.count-(V.get(N)??0)+w,bends:Qt(S,J),totalBends:Qt(S),length:R(S)}}).filter(({crossings:S})=>S<=_.count).sort((S,C)=>S.crossings-C.crossings||S.bends-C.bends||S.length-C.length).slice(0,48).map(S=>({path:S.candidate,segments:S.candidateSegments,sharedTrackConflicts:Vt(N,S.candidateSegments,H),totalBends:S.totalBends,length:S.length}))},"pairCandidatesFor"),Ut=a((N,_,H,V,c,x)=>{let S=0;for(const w of N.pairs)(w.first===_||w.second===_||w.first===V||w.second===V)&&(S+=w.count);let C=i(H.segments,c.segments);for(const w of p){if(w===_||w===V)continue;const P=x.get(w)??it(h(w));C+=i(H.segments,P)+i(c.segments,P)}return N.count-S+C},"pairCrossingCount"),te=a((N,_)=>{for(const H of N.sharedTrackConflicts)if(H!==_)return!1;return!0},"conflictsOnlyWith"),Me=a((N,_)=>N.segments.some(H=>_.segments.some(V=>ie(H,V,.5)>=Ft)),"candidatesShareTrack"),fe=a((N,_,H,V)=>te(_,H.edge)&&te(V,N.edge)&&!Me(_,V),"pairCandidatesAreCompatible"),Se=a((N,_,H,V,c)=>{const x=Ut(N.current,_.edge,H,V.edge,c,N.baseSegments);if(!(x>=N.current.count))return{replacements:new Map([[_.edge,H.path],[V.edge,c.path]]),crossings:x,bends:N.currentBends-(N.baseBendsByEdge.get(_.edge)??0)-(N.baseBendsByEdge.get(V.edge)??0)+H.totalBends+c.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(_.edge)??0)-(N.baseLengthByEdge.get(V.edge)??0)+H.length+c.length}},"scorePairReplacement"),on=a((N,_)=>N.crossings<_.crossings||N.crossings===_.crossings&&(N.bends<_.bends||N.bends===_.bends&&N.length<_.length),"pairScoreIsBetter"),sn=a((N,_,H,V)=>{let c=V;for(const x of _.candidates)for(const S of H.candidates){if(!fe(_,x,H,S))continue;const C=Se(N,_,x,H,S);C&&on(C,c)&&(c=C)}return c},"bestScoreForOptionPair"),rn=a(N=>{const _=k(),H=O(),V=vt(),c=A(N),x=new Map(p.map(q=>[q,Qt(h(q))])),S=new Map(p.map(q=>[q,R(h(q))])),C=new Map,w=m(N);for(const q of w)for(const $ of q){if(C.has($))continue;const Y=jt($,N,V,c);Y.length>0&&C.set($,{edge:$,candidates:Y})}let P={replacements:new Map,crossings:N.count,bends:_,length:H};const U={current:N,currentBends:_,currentLength:H,baseBendsByEdge:x,baseLengthByEdge:S,baseSegments:V};for(const q of w){const $=new Set(q.filter(ot=>N.edgeSet.has(ot))),Y=q.map(ot=>C.get(ot)).filter(ot=>!!ot);for(let ot=0;ot<Y.length;ot++){const rt=Y[ot];for(let st=ot+1;st<Y.length;st++){const tt=Y[st];!$.has(rt.edge)&&!$.has(tt.edge)||(P=sn(U,rt,tt,P))}}}return P.replacements.size>0?P.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const _=L(),H=_.count;if(H===0)return;let V,c,x=H,S=Number.POSITIVE_INFINITY;for(const w of _.edges){const P=Qt(h(w),J);for(const U of xt(w)){const q=D(w,U),$=!q&&F(w,U),Y=M(_,w,U),ot=Qt(U,J);q||$||!(Y<H||Y===H&&ot<P)||Y>x||Y===x&&ot>=S||(V=w,c=U,x=Y,S=ot)}}if(V&&c){V.points=c;continue}const C=rn(_);if(!C)return;for(const[w,P]of C)w.points=P}}a(es,"resolveRenderedOrthogonalCrossings");var ge=.001,dr=8;function ns(t,e){const{nodeInfoById:n,realNodeRects:o}=Qe(e),s=["top","bottom","left","right"],r=20,l={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},f=a((i,y,L,I)=>{const E=[],T=Qn(i,y,L,I,r,ge);return T&&E.push(T),y===I&&E.push(to(i,y,L,l[y])),E},"buildOrthogonalPathCandidates"),u=a((i,y)=>{for(let L=0;L<i.length-1;L++){const I=i[L],E=i[L+1];if(At(I,E,o,y,1))return!0}return!1},"pathHitsNode"),g=a((i,y,L=!1)=>{let I=0;const E=Ee(i,ge),T=y.start,m=y.end;for(const M of t){if(M===y||M.isLayoutOnly)continue;const A=M.start,R=M.end;if(!L&&T&&m&&(A===T||A===m||R===T||R===m))continue;const k=M.points;if(!(!k||k.length<2))for(const O of E)for(const F of Ee(k,ge)){if(no(O.a,O.b,F.a,F.b,ge,ge)){I++;continue}ie(O,F,ge)>=dr&&I++}}return I},"pathConflictCount"),b=4,p=a((i,y)=>{const L=Math.abs(i.y-y.rect.top),I=Math.abs(i.y-y.rect.bottom),E=Math.abs(i.x-y.rect.left),T=Math.abs(i.x-y.rect.right);let m="top",M=L;return I<M&&(m="bottom",M=I),E<M&&(m="left",M=E),T<M&&(m="right",M=T),m},"nearestSideOfRect"),v=new Map,d=a((i,y,L)=>{const I=v.get(i)??[];I.push({side:y,edgeId:L}),v.set(i,I)},"addFaceClaim");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points??[];if(y.length<1)continue;const L=i.id??"",I=i.start,E=i.end;if(I){const T=n.get(I);T&&d(I,p(y[0],T),L)}if(E){const T=n.get(E);T&&d(E,p(y[y.length-1],T),L)}}const h=a((i,y,L)=>v.get(i)?.some(I=>I.edgeId!==L&&I.side===y)??!1,"faceIsClaimed");for(const i of t){if(i.isLayoutOnly)continue;const y=i.points;if(!y||y.length<2)continue;const L=Qt(y,ge);if(L<b)continue;const I=i.start,E=i.end;if(!I||!E)continue;const T=n.get(I),m=n.get(E);if(!T||!m)continue;const M=i.id??"",A=g(y,i,!0),R=g(y,i);let k,O=A,F=L;for(const D of s){if(h(I,D,M))continue;const B=Ie(T,D);for(const G of s){if(h(E,G,M))continue;const j=Ie(m,G);for(const Z of f(B,D,j,G)){if(u(Z,[I,E]))continue;const dt=Qt(Z,ge);if(A>0){const pt=g(Z,i,!0);if(pt>O||pt===O&&dt>=F)continue;O=pt,F=dt,k=Z;continue}g(Z,i)>R||dt<F&&(F=dt,k=Z)}}}if(k){i.points=k;const D=v.get(I);D&&v.set(I,D.filter(G=>G.edgeId!==M));const B=v.get(E);B&&v.set(E,B.filter(G=>G.edgeId!==M)),d(I,p(k[0],T),M),d(E,p(k[k.length-1],m),M)}}}a(ns,"simplifyDetouredEdges");var Kt=.001,So=10,De=7;function kn(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 l=r.x-s.x,f=r.y-s.y;if(!(Math.abs(l)+Math.abs(f)<Kt)){if(Math.abs(f)<=Kt){const g=s.x+Math.sign(l)*So;return{left:Math.min(s.x,g),right:Math.max(s.x,g),top:s.y-De,bottom:s.y+De}}if(Math.abs(l)<=Kt){const g=s.y+Math.sign(f)*So;return{left:s.x-De,right:s.x+De,top:Math.min(s.y,g),bottom:Math.max(s.y,g)}}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)}}}a(kn,"markerClearanceRectFor");function os(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)}}a(os,"normalizeRect");function Fn(t,e){const n=mt(e),o=kn(n,!0),s=kn(n,!1);return[o,s].some(r=>r&&ze(t,os(r)))}a(Fn,"labelOverlapsOwnMarker");function Ye(t,e){const n=[];for(const h of t){if(h.isLayoutOnly)continue;const i=h.points;if(!(!i||i.length<2))for(let y=0;y<i.length-1;y++)n.push({edgeId:h.id,p1:i[y],p2:i[y+1]})}const o=[],s=[];for(const h of e.values()){const i=h.isGroup,y=h.parentId;if(i&&!y){const I=qt(h);I&&s.push({id:h.id,rect:I});continue}if(i||h.isEdgeLabel)continue;const L=qt(h);L&&o.push({nodeId:h.id,rect:L})}const r=3,l=1,f=12,u=a((h,i)=>{const y=bn(i,r);for(const{nodeId:L,rect:I}of o)if(L!==h&&ze(y,I))return!0;return!1},"labelOverlapsForeignNode"),g=a((h,i)=>{const y=bn(i,r);for(const L of n)if(L.edgeId!==h&&Je(L.p1,L.p2,y))return!0;return!1},"labelOverlapsForeignEdge"),b=a((h,i,y)=>u(h,y)||g(i,y),"labelOverlapsAnything"),p=[],v=a(h=>{for(const{id:i,rect:y}of s)if(No(y,h))return i},"findContainingLane"),d=a((h,i)=>p.some(y=>y.labelId!==h&&ze(i,y.rect)),"overlapsPlacedLabel");for(const h of t){if(h.isLayoutOnly)continue;const i=h.labelNodeId;if(!i)continue;const y=e.get(i);if(!y)continue;const L=h.points;if(!L||L.length<2)continue;const I=y.width??0,E=y.height??0;if(I<=0||E<=0)continue;const T=[];for(let Q=0;Q<L.length-1;Q++){const W=L[Q],et=L[Q+1],at=Math.abs(W.x-et.x),gt=Math.abs(W.y-et.y);at<Kt&&gt<Kt||at>=Kt&&gt>=Kt||T.push({idx:Q,length:at+gt,orientation:at>=Kt?"horizontal":"vertical",midX:(W.x+et.x)/2,midY:(W.y+et.y)/2})}if(T.length===0)continue;const m=T.length>=3?T.filter(Q=>Q.idx>0&&Q.idx<T.length-1):T,M=m.length>0?m:T,A=I>=E?"horizontal":"vertical",R=a(Q=>[...Q].sort((W,et)=>{const at=W.orientation===A,gt=et.orientation===A;if(at!==gt)return at?-1:1;const xt=W.length>=(W.orientation==="horizontal"?I:E)+2,vt=et.length>=(et.orientation==="horizontal"?I:E)+2;return xt!==vt?xt?-1:1:et.length-W.length}),"rankSegments"),k=T[0],O=T[T.length-1],F=[.5,.25,.75,.05,.95,.15,.85,.1,.9],D=a((Q,W)=>{const et=L[Q.idx],at=L[Q.idx+1];return{midX:et.x+(at.x-et.x)*W,midY:et.y+(at.y-et.y)*W}},"anchorAtT"),B=a((Q,W,et)=>Math.min(et,Math.max(W,Q)),"clamp"),G=a((Q,W)=>Q.midX>=W.left-Kt&&Q.midX<=W.right+Kt&&Q.midY>=W.top-Kt&&Q.midY<=W.bottom+Kt,"pointInsideRectInclusive"),j=a(Q=>{const W=we(Q.midX,Q.midY,I,E),et=v(W);if(et)return{laneId:et,anchor:Q,rect:W};const at=s.find(({rect:te})=>G(Q,te));if(!at)return;const gt=at.rect.left+I/2+l,xt=at.rect.right-I/2-l,vt=at.rect.top+E/2+l,Vt=at.rect.bottom-E/2-l;if(gt>xt||vt>Vt)return;const jt={midX:B(Q.midX,gt,xt),midY:B(Q.midY,vt,Vt)},Ut=we(jt.midX,jt.midY,I,E);return G(Q,Ut)?{laneId:at.id,anchor:jt,rect:Ut}:void 0},"placementForAnchor"),Z=a((Q,W,et)=>Q.orientation==="horizontal"?Math.abs(W.midX-et.x):Math.abs(W.midY-et.y),"distanceAlongSegment"),dt=a((Q,W)=>{const at=(Q.orientation==="horizontal"?I/2:E/2)+f;if(Q===k){const gt=L[Q.idx];if(Z(Q,W,gt)+Kt<at)return!1}if(Q===O){const gt=L[Q.idx+1];if(Z(Q,W,gt)+Kt<at)return!1}return!0},"labelClearsTerminalEndpoints"),pt=a(Q=>{const W=R(Q);for(const et of W)for(const at of F){const gt=D(et,at);if(!dt(et,gt))continue;const xt=j(gt);if(xt&&!Fn(xt.rect,L)&&!d(i,xt.rect)&&!b(i,h.id,xt.rect))return{laneId:xt.laneId,anchor:xt.anchor}}},"tryPool"),kt=a((Q,W,et=!1)=>{const at=R(Q);for(const gt of at){const xt={midX:gt.midX,midY:gt.midY};if(W&&!dt(gt,xt))continue;const vt=j(xt);if(vt&&!Fn(vt.rect,L)&&!d(i,vt.rect)&&!u(i,vt.rect)&&(et||!g(h.id,vt.rect)))return{laneId:vt.laneId,anchor:vt.anchor}}},"findLaneContainingFallback"),Bt=pt(M)??(M.length<T.length?pt(T):void 0)??kt(T,!0)??kt(T,!1)??kt(T,!1,!0);if(Bt){y.x=Bt.anchor.midX,y.y=Bt.anchor.midY,y.parentId=Bt.laneId;const Q=we(Bt.anchor.midX,Bt.anchor.midY,I,E),W=p.findIndex(et=>et.labelId===i);W>=0?p[W]={labelId:i,rect:Q}:p.push({labelId:i,rect:Q})}}}a(Ye,"anchorLabelsToPolyline");var mn=1e-6,ur=8,Co=ur/2,hr=3;function _n(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}a(_n,"pairKey");function ss(t,e){const{nodeInfoById:n,realNodeRects:o}=Qe(e),s=new Map;for(const l of e){const f=l.id;if(!l.isGroup&&l.isEdgeLabel){s.set(f,{w:l.width??0,h:l.height??0});continue}}const r=a((l,f,u,g)=>{const b=_n(f,u);let p=0;const v=a(d=>{if(!d)return;const h=s.get(d);if(!h)return;const i=g==="x"?h.w/2:h.h/2;i>p&&(p=i)},"consider");v(l.labelNodeId);for(const d of t){if(d===l||d.isLayoutOnly)continue;const h=d.start,i=d.end;!h||!i||_n(h,i)===b&&v(d.labelNodeId)}return p>0?p+hr:0},"labelClearanceFor");for(const l of t){if(l.isLayoutOnly)continue;const f=l.points;if(!Zn(f,mn))continue;const u=eo(l,n,mn);if(!u)continue;const{srcId:g,dstId:b,srcInfo:p,dstInfo:v,collinearX:d,collinearY:h}=u;if(d===h)continue;let i,y;if(d){const m=v.cy>p.cy;i={x:p.cx,y:m?p.rect.bottom:p.rect.top},y={x:v.cx,y:m?v.rect.top:v.rect.bottom}}else{const m=v.cx>p.cx;i={x:m?p.rect.right:p.rect.left,y:p.cy},y={x:m?v.rect.left:v.rect.right,y:v.cy}}if(At(i,y,o,[g,b],1))continue;const I=r(l,g,b,d?"x":"y"),E=I>Co?I:Co,T=[0,E,-E];for(const m of T){const M={...i},A={...y};if(d){if(M.x+=m,A.x+=m,M.x<=p.rect.left||M.x>=p.rect.right||A.x<=v.rect.left||A.x>=v.rect.right)continue}else if(M.y+=m,A.y+=m,M.y<=p.rect.top||M.y>=p.rect.bottom||A.y<=v.rect.top||A.y>=v.rect.bottom)continue;if(!At(M,A,o,[g,b],1)&&!$e(M,A,t,l,{epsilon:mn})){l.points=[M,A];break}}}}a(ss,"straightenCollinearSiblingDetours");function Hn(t,e){const{realNodeRects:u,labelNodeRects:g}=me(e.values()),b=a((m,M)=>Ee(M,.001).map(A=>({...A,edge:m,interior:A.index>=1&&A.index<=M.length-3})),"segmentsFor"),p=a(()=>{const m=[];for(const M of t){if(M.isLayoutOnly)continue;const A=M.points;!A||A.length<2||m.push(...b(M,mt(A)))}return m},"allSegments"),v=a((m,M)=>m.horizontal&&M.horizontal?$t(m.a.x,m.b.x,M.a.x,M.b.x)>=8&&Math.abs(m.a.y-M.a.y)<7:m.vertical&&M.vertical?$t(m.a.y,m.b.y,M.a.y,M.b.y)>=8&&Math.abs(m.a.x-M.a.x)<7:!1,"hasCrowdedParallelTrack"),d=a((m,M)=>{const A=m.start,R=m.end,k=b(m,M);if(k.length!==M.length-1)return!1;const O=[A,R].filter(D=>!!D),F=m.labelNodeId?[m.labelNodeId]:[];for(const D of k)if(At(D.a,D.b,u,O,-2)||At(D.a,D.b,g,F,-2))return!1;for(const D of t){if(D===m||D.isLayoutOnly)continue;const B=D.points;if(!(!B||B.length<2)){for(const G of k)for(const j of b(D,mt(B)))if(v(G,j)||ae(G.a,G.b,j.a,j.b,.001))return!1}}return!0},"candidateIsSafe"),h=a((m,M)=>{const A=mt(m.edge.points??[]);if(A.length<4||m.index>=A.length-1)return;const R=A.map(k=>({...k}));if(m.horizontal)R[m.index].y+=M,R[m.index+1].y+=M;else if(m.vertical)R[m.index].x+=M,R[m.index+1].x+=M;else return;return b(m.edge,R).length===R.length-1?R:void 0},"shiftedCandidate"),i=a((m,M)=>({x:m.x??(M.left+M.right)/2,y:m.y??(M.top+M.bottom)/2}),"nodeCenter"),y=a(m=>{const M=m.edge,A=mt(M.points??[]);if(A.length!==4||m.index!==1)return;const R=M.start?e.get(M.start):void 0,k=M.end?e.get(M.end):void 0,O=R?qt(R):void 0,F=k?qt(k):void 0,D=A.slice(m.index+2);if(!(!R||!k||!O||!F||D.length===0))return{sourceCenter:i(R,O),targetCenter:i(k,F),sourceRect:O,tail:D}},"sourceDetourContextFor"),L=a((m,M,A,R,k,O)=>{const F=R.y>=A.y,D=F?k.bottom:k.top,B=D+(F?20:-20);if(F&&m.b.y<=B+.001||!F&&m.b.y>=B-.001)return;const G=m.a.x+M;return mt([{x:A.x,y:D},{x:A.x,y:B},{x:G,y:B},{x:G,y:m.b.y},...O],.001)},"verticalSourceDetour"),I=a((m,M,A,R,k,O)=>{const F=R.x>=A.x,D=F?k.right:k.left,B=D+(F?20:-20);if(F&&m.b.x<=B+.001||!F&&m.b.x>=B-.001)return;const G=m.a.y+M;return mt([{x:D,y:A.y},{x:B,y:A.y},{x:B,y:G},{x:m.b.x,y:G},...O],.001)},"horizontalSourceDetour"),E=a((m,M)=>{const A=y(m);if(A){if(m.vertical)return L(m,M,A.sourceCenter,A.targetCenter,A.sourceRect,A.tail);if(m.horizontal)return I(m,M,A.sourceCenter,A.targetCenter,A.sourceRect,A.tail)}},"sourceDetourCandidate"),T=[-7,7,-14,14,-21,21];for(let m=0;m<12;m++){const M=p();let A=!1;for(let R=0;R<M.length&&!A;R++)for(let k=R+1;k<M.length&&!A;k++){const O=M[R],F=M[k];if(O.edge===F.edge||!v(O,F))continue;const D=[O,F].filter(B=>B.interior);for(const B of D){for(const G of T){const j=h(B,G);if(j&&d(B.edge,j)){B.edge.points=j,A=!0;break}const Z=E(B,G);if(Z&&d(B.edge,Z)){B.edge.points=Z,A=!0;break}}if(A)break}}if(!A)return}}a(Hn,"nudgeSharedInteriorSubpaths");function rs(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,l=o.x-n.x,f=o.y-n.y,u=s*f-r*l;if(Math.abs(u)<1e-10)return!1;const g=n.x-t.x,b=n.y-t.y,p=(g*f-b*l)/u,v=(g*r-b*s)/u,d=.01;return p>d&&p<1-d&&v>d&&v<1-d}a(rs,"segmentsIntersect");function is(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Oo(e),r=[];for(const f of n){if(f.isLayoutOnly)continue;const u=f.points;if(!u||u.length<2)continue;const g=f.start,b=f.end,p=f.labelNodeId,v=f.id??`${g}->${b}`;for(const d of s)if(!(d.nodeId===g||d.nodeId===b)&&!(p&&d.nodeId===p)){for(let h=0;h<u.length-1;h++)if(Je(u[h],u[h+1],d,-1)){o.push({type:"edge-node-overlap",edgeId:v,targetId:d.nodeId,detail:`segment ${h} passes through node "${d.nodeId}"`});break}}for(let d=0;d<u.length-1;d++)r.push({edgeId:v,start:g,end:b,p1:u[d],p2:u[d+1]})}const l=new Set;for(let f=0;f<r.length;f++)for(let u=f+1;u<r.length;u++){const g=r[f],b=r[u];if(g.edgeId!==b.edgeId&&!(g.start===b.start||g.start===b.end||g.end===b.start||g.end===b.end)&&rs(g.p1,g.p2,b.p1,b.p2)){const p=g.edgeId<b.edgeId?`${g.edgeId}|${b.edgeId}`:`${b.edgeId}|${g.edgeId}`;l.has(p)||(l.add(p),o.push({type:"edge-edge-crossing",edgeId:g.edgeId,targetId:b.edgeId,detail:`edges "${g.edgeId}" and "${b.edgeId}" cross`}))}}if(o.length>0){const f=o.filter(g=>g.type==="edge-node-overlap").length,u=o.filter(g=>g.type==="edge-edge-crossing").length;yn.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${f} edge-node overlap(s), ${u} edge crossing(s)`);for(const g of o)yn.warn(`[SWIMLANE_VALIDATE] ${g.type}: ${g.detail}`)}return o}a(is,"validateSwimlanesLayout");function cs(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(f=>!f.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Uo(t,e)||e==="BT"&&s.length>0&&!jo(t))return;for(const f of o){if(f.isLayoutOnly)continue;const u=f.points;!u||u.length<2||(f.points=ce(Ve(u)))}ns(o,n),ss(o,n),Wo(o,n);const r=new Map;for(const f of n)r.set(String(f.id),f);Ye(o,r),_o(o,r),Ko(o,r),Hn(o,r),qo(o,r),Zo(o,r),On(o,r),Jo(o,r);const l=a(()=>{es(o,r),Qo(o,r),ts(o,r),Ye(o,r),Rn(o,r),On(o,r),Ye(o,r),Rn(o,r)},"finalizeRenderedEdges");l(),Hn(o,r),l(),Bn(o,r),Pn(o,r),Bn(o,r),Pn(o,r)}a(cs,"postProcessSwimlaneLayout");function pe(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 l=`${r.id}:${r.src}->${r.dst}`;n.has(l)||(n.add(l),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}a(pe,"normalizeGraph");function co(t,e){return t.edges.filter(n=>n.dst===e)}a(co,"incoming");function as(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}a(as,"buildSuccessorMap");function ao(t){const e=as(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}a(ao,"buildSortedSuccessorMap");function tn(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}a(tn,"buildInDegreeMap");function lo(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}a(lo,"sortedZeroInDegreeNodes");function en(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));return{preds:n,succs:o}}a(en,"buildPredecessorSuccessorMaps");function fo(t,e,n,o){let s=0;for(const l of t.nodes)o?.skipGroups&&t.nodeById.get(l)?.isGroup||(s=Math.max(s,n[l]??0));const r=Array.from({length:s+1},()=>[]);for(const l of e)o?.skipGroups&&t.nodeById.get(l)?.isGroup||r[Math.max(0,n[l]??0)].push(l);return r}a(fo,"buildLayersFromRanks");function Ne(t){const e=tn(t),n=lo(e),o=[],s=ao(t);for(;n.length;){const r=n.shift();o.push(r);for(const l of s.get(r)??[])if(e.set(l,(e.get(l)??0)-1),(e.get(l)??0)===0){let f=0;for(;f<n.length&&n[f]<l;)f++;n.splice(f,0,l)}}return o.length===t.nodes.length?o:null}a(Ne,"topoSortIfAcyclic");function Ae(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}a(Ae,"buildLayerIndex");function uo(t){const e=new Array(t.length),n=a((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let l=n(o,r)+n(r,s),f=o,u=r,g=o;for(;f<r||u<s;)u>=s||f<r&&t[f]<=t[u]?e[g++]=t[f++]:(e[g++]=t[u++],l+=r-f);for(let b=o;b<s;b++)t[b]=e[b];return l},"count");return n(0,t.length)}a(uo,"countInversions");function ls(t){const e=pe(t),n=new Map;for(const p of e.nodes)n.set(p,[]);for(const p of e.edges)n.get(p.src).push(p);for(const p of n.values())p.sort((v,d)=>v.dst===d.dst?v.id.localeCompare(d.id):v.dst.localeCompare(d.dst));const o=Object.create(null);for(const p of e.nodes)o[p]=0;const s=[],r=a(p=>{o[p]=1;for(const v of n.get(p)??[]){const d=v.dst;o[d]===0?r(d):o[d]===1&&s.push(v)}o[p]=2},"dfs"),l=tn(e),f=[...e.nodes.filter(p=>(l.get(p)??0)===0),...e.nodes.filter(p=>(l.get(p)??0)!==0)];for(const p of f)o[p]===0&&r(p);const u=new Set(s.map(p=>`${p.id}:${p.src}->${p.dst}`)),g=e.edges.map(p=>u.has(`${p.id}:${p.src}->${p.dst}`)?{id:p.id,src:p.dst,dst:p.src,weight:p.weight,ref:p.ref}:p);return{acyclic:{nodes:[...e.nodes],edges:g,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}a(ls,"removeCycles_DFS");function fs(t){const e=new Map,n=a(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 f=n(r)??r;return e.set(o,f),f},"resolve");for(const o of t.nodes)n(o);return e}a(fs,"buildTopLaneMap");function le(t){const e=fs(t);return n=>e.get(n)??null}a(le,"createTopLaneResolver");function nn(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}a(nn,"buildTopLaneOrder");function ho(t,e){const n=nn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const l of e)!o.has(l)||s.has(l)||(s.add(l),r.push(l));for(const l of n)s.has(l)||r.push(l);return r}a(ho,"resolveTopLaneOrder");var gr={EPSILON:1e-6},qe={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},vo={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function ds(t,e){const n=pe(t),o=e?.laneOf??(()=>null),s=e?.rankHint,{preds:r}=en(n);for(const m of r.values())m.sort((M,A)=>M.localeCompare(A));const l=Ne(n)??[...n.nodes].sort((m,M)=>m.localeCompare(M)),f=new Map;for(const[m,M]of l.entries())f.set(M,m);const u=new Map,g=new Map;for(const m of n.nodes)g.set(m,[]);for(const m of l){const M=(r.get(m)??[]).filter(A=>u.has(A));if(M.length>0){const A=us(m,M,{laneOf:o,rankHint:s,topoIndex:f});u.set(m,A),g.get(A).push(m)}else u.has(m)||u.set(m,null)}for(const m of n.nodes)u.has(m)||u.set(m,null);const b=new Set;for(const m of n.nodes)(u.get(m)??null)===null&&b.add(m);const p=[...b].sort((m,M)=>{const A=f.get(m)??0,R=f.get(M)??0;return A===R?m.localeCompare(M):A-R}),v=hs(n),d=new Map;for(const[m,M]of v.entries())d.set(m,[...M].sort((A,R)=>A.localeCompare(R)));const h=gs(d),i=ms(d),y=new Map;for(const m of n.nodes)y.set(m,[]);for(const m of i)for(const M of m.nodes){const A=y.get(M);A?A.push(m.id):y.set(M,[m.id])}const L=[],I=[],E=new Set,T=a(m=>{if(!E.has(m)){E.add(m),L.push(m);for(const M of g.get(m)??[])T(M);I.push(m)}},"walk");for(const m of p)T(m);for(const m of l)T(m);return{parent:u,children:g,roots:p,componentOf:h,blocks:i,nodeBlocks:y,adjacency:d,preorder:L,postorder:I,topologicalOrder:l}}a(ds,"buildDrivingTree");function us(t,e,n){const o=n.laneOf(t);return[...e].sort((r,l)=>{const f=n.laneOf(r),u=n.laneOf(l),g=f!=null&&f===o,b=u!=null&&u===o;if(g!==b)return g?-1:1;const p=n.rankHint?.[r],v=n.rankHint?.[l];if(p!=null&&v!=null&&p!==v)return v-p;const d=n.topoIndex.get(r)??0,h=n.topoIndex.get(l)??0;return d!==h?d-h:r.localeCompare(l)})[0]}a(us,"chooseParent");function hs(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}a(hs,"buildAdjacency");function gs(t){const e=new Map;let n=0;for(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 l of t.get(r)??[])e.has(l)||s.push(l)}}n++}return e}a(gs,"assignComponents");function ms(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const l=a((f,u)=>{e.set(f,++r),n.set(f,r);for(const g of t.get(f)??[])g!==u&&(e.has(g)?(e.get(g)??0)<(e.get(f)??0)&&(o.push([f,g]),n.set(f,Math.min(n.get(f)??r,e.get(g)??r))):(o.push([f,g]),l(g,f),n.set(f,Math.min(n.get(f)??r,n.get(g)??r)),(n.get(g)??0)>=(e.get(f)??0)&&s.push(ps(f,g,o,s.length))))},"visit");for(const f of t.keys())e.has(f)||l(f,null);return s}a(ms,"computeBlocks");function ps(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const l=n.pop();if(s.push(l),r.add(l[0]),r.add(l[1]),l[0]===t&&l[1]===e||l[0]===e&&l[1]===t)break}return{id:o,edges:s,nodes:[...r]}}a(ps,"popBlock");function ys(t,e,n){const o=[...t.nodes],s=new Map;for(const[I,E]of o.entries())s.set(E,I);const r=o.length,l=new Array(r).fill(-1),f=new Array(r).fill(0),u=[],g=new Set;for(const I of o){const E=n.parent.get(I)??null,T=s.get(I);T!=null&&E==null&&(l[T]=-1,f[T]=0,g.has(I)||(g.add(I),u.push(I)))}for(;u.length>0;){const I=u.shift(),E=s.get(I);if(E==null)continue;const T=n.children.get(I)??[];for(const m of T){if(g.has(m))continue;const M=s.get(m);M!=null&&(l[M]=E,f[M]=f[E]+1,g.add(m),u.push(m))}}for(const I of o){if(g.has(I))continue;const E=s.get(I);E!=null&&(l[E]=-1,f[E]=0,g.add(I))}const b=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),p=Array.from({length:b},()=>new Array(r).fill(-1));for(let I=0;I<r;I++)p[0][I]=l[I];for(let I=1;I<b;I++)for(let E=0;E<r;E++){const T=p[I-1][E];p[I][E]=T===-1?-1:p[I-1][T]}const v=a((I,E)=>{if(I===-1||E===-1)return-1;f[I]<f[E]&&([I,E]=[E,I]);const T=f[I]-f[E];for(let m=0;m<b;m++)if(T>>m&1&&(I=p[m][I],I===-1))return-1;if(I===E)return I;for(let m=b-1;m>=0;m--){const M=p[m][I],A=p[m][E];M===-1||A===-1||M!==A&&(I=M,E=A)}return p[0][I]},"lcaIndex"),d=Array.from({length:r},()=>new Map);for(const I of t.edges){let E=I.src,T=I.dst,m=e[E],M=e[T];if(m==null||M==null||(m>M&&([E,T]=[T,E],[m,M]=[M,m]),m==null||M==null||m===M))continue;const A=s.get(E),R=s.get(T);if(A==null||R==null)continue;const k=v(A,R);if(k===-1)continue;const O=d[k];for(let F=m;F<M;F++)O.set(F,(O.get(F)??0)+1)}const h=new Map,i=a((I,E)=>{if(E.size!==0)for(const[T,m]of E)I.set(T,(I.get(T)??0)+m)},"mergeInto"),y=new Set,L=a(I=>{const E=s.get(I);y.add(I);const T=E==null?void 0:d[E],m=T?new Map(T):new Map,M=n.children.get(I)??[];for(const A of M){const R=L(A),k=e[I];if(k!=null){let O=h.get(I);O||(O=new Map,h.set(I,O));let F=R.get(k)??0;const D=e[A];D!=null&&D>k&&(F+=1),O.set(A,F)}i(m,R)}return m},"dfs");for(const I of n.roots)y.has(I)||L(I);for(const I of o)y.has(I)||L(I);return h}a(ys,"computeSubtreeCrossCounts");function xs(t,e,n){const o=new Map,s=a(r=>{let l=n[r]??0;const f=[...e.get(r)??[]];f.sort(go(n));for(const u of f){s(u);const g=o.get(u);g!=null&&(l=Math.min(l,g))}o.set(r,l)},"annotate");for(const r of t)s(r);return o}a(xs,"annotateMinimumLayers");function go(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}a(go,"compareByRankThenId");function bs(t,e,n,o){let s=0;for(const u of e){const g=n[u]??0;g>s&&(s=g)}const r=Array.from({length:s+1},()=>[]),l=new Set,f=a(u=>{if(l.has(u))return;l.add(u);const g=n[u]??0;r[g]||(r[g]=[]),r[g].push(u);for(const b of o(u))f(b)},"emit");for(const u of t)f(u);for(const u of e)if(!l.has(u)){const g=n[u]??0;r[g]||(r[g]=[]),r[g].push(u),l.add(u)}return r}a(bs,"emitNodesInTreeOrder");function Is(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}a(Is,"deduplicateLayers");function Ms(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const l=e[s]??0,f=[],u=[],g=n.get(s);for(const b of r){const p=o.get(b)??l;p>l?f.push({child:b,min:p}):u.push(b)}return f.sort((b,p)=>b.min===p.min?b.child.localeCompare(p.child):b.min-p.min),u.sort((b,p)=>{const v=g?.get(b)??0,d=g?.get(p)??0;if(v!==d)return v-d;const h=o.get(b)??l,i=o.get(p)??l;return h!==i?h-i:b.localeCompare(p)}),[...f.map(b=>b.child),...u]}}a(Ms,"createChildOrderer");function Ze(t,e,n){const o=ds(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const p of t.nodes)s.has(p)||s.set(p,[]);const l=ys(t,e,o),f=[...r].sort(go(e)),u=xs(f,s,e),g=Ms(s,e,l,u);let b=bs(f,t.nodes,e,g);return b=Is(b),b}a(Ze,"buildMultitreeLayerOrder");function Ss(t,e,n){const o=new Set(t),s=new Set(e),r=Ae(e),l=[];for(const f of n)o.has(f.src)&&s.has(f.dst)&&l.push(r.get(f.dst));return uo(l)}a(Ss,"countCrossingsBetweenAdjacent");function Dn(t,e,n){const o=[];for(const r of e){const l=n[r.src],f=n[r.dst];if(l==null||f==null||l===f)continue;let u=r.src,g=r.dst,b=l,p=f;l>f&&(u=r.dst,g=r.src,b=f,p=l);for(let v=b;v<p;v++)o.push({id:`${r.id}@${v}`,src:u,dst:g,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ss(t[r],t[r+1],o);return s}a(Dn,"totalCrossings");function Cs(t,e){const n={...e},{preds:o}=en(t),s=le(t),r=Ze(t,n,s);let l=Dn(r,t.edges,n);const f=qe.MAX_CROSSING_OPTIMIZATION_PASSES;for(let u=0;u<f;u++){let g=!1;const b=[...t.nodes].sort((p,v)=>(n[v]??0)-(n[p]??0));for(const p of b){const v=n[p]??0;if(v===0)continue;let d=0;for(const L of o.get(p)??[])d=Math.max(d,(n[L]??0)+1);if(d>=v)continue;const h=v;n[p]=d;const i=Ze(t,n,s),y=Dn(i,t.edges,n);y<l?(l=y,g=!0):n[p]=h}if(!g)break}return n}a(Cs,"optimizeRanksByCrossings");function vs(t,e){const n=le(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 l=t.edges.filter(i=>i.src===s);if(l.length===0)continue;let f=!1,u=0;for(const i of l){const y=n(i.dst);y==null||y===r?f=!0:u++}if(u===0||f)continue;let g=0,b=!1;for(const i of t.edges){if(i.dst!==s)continue;const y=n(i.src);y&&(y===r?b=!0:g++)}if(g>0||!b)continue;const p=e[s]??0,v=p+u;let d=0;for(const i of t.edges)i.dst===s&&(d=Math.max(d,(e[i.src]??0)+1));const h=Math.max(p,d,v);h!==p&&(e[s]=h)}}a(vs,"adjustCrossLaneSources");function Ls(t,e){const n=pe(t),o=Ne(n)??[...n.nodes].sort(),s=e?.compactSingleInput??!1,r=le(n);let l=Object.create(null);for(const u of o){const g=co(n,u),b=e?.ignoreCrossLaneEdges?g.filter(p=>{const v=r(p.src),d=r(u);return!v||!d?!0:v===d}):g;if(b.length===0)l[u]=0;else if(s&&b.length===1){const p=b[0].src,v=r(p),d=r(u);v!==d?l[u]=l[p]??0:l[u]=(l[p]??0)+1}else{let p=-1/0;for(const v of b)p=Math.max(p,(l[v.src]??0)+1);l[u]=p===-1/0?0:p}}return(e?.optimizeRanksByCrossings??!1)&&(l=Cs(n,l)),e?.ignoreCrossLaneEdges&&vs(n,l),{layers:Ze(n,l,r),rankOf:l,dummy:new Set}}a(Ls,"assignLayers_LongestPath");function Ts(t,e){const n=pe(t),s={...Ls(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=le(n),{preds:l,succs:f}=en(n,h=>{if(e?.ignoreCrossLaneEdges){const i=r(h.src),y=r(h.dst);if(i&&y&&i!==y)return!1}return!0}),u=Ne(n)??[...n.nodes],g=[...u].reverse(),b=a((h,i)=>{let y=0;for(const E of l.get(h)??[])y=Math.max(y,(s[E]??0)+1);let L=Number.POSITIVE_INFINITY;const I=f.get(h)??[];return I.length>0&&(L=Math.min(...I.map(E=>(s[E]??0)-1))),Number.isFinite(L)||(L=Math.max(y,i)),Math.min(Math.max(i,y),L)},"clampFeasible"),p=qe.GRAVITY_ITERATIONS,v=a(h=>{let i=!1;for(const y of h){const L=l.get(y)??[],I=f.get(y)??[];if(L.length===0&&I.length===0)continue;const E=L.length>0?L.reduce((A,R)=>A+(s[R]??0)+1,0)/L.length:s[y]??0,T=I.length>0?I.reduce((A,R)=>A+(s[R]??0)-1,0)/I.length:s[y]??0,m=Math.round((E+T)/2),M=b(y,m);M!==s[y]&&(s[y]=M,i=!0)}return i},"relaxOrder");for(let h=0;h<p;h++){const i=v(u),y=v(g);if(!i&&!y)break}for(const h of u){let i=0;for(const y of l.get(h)??[])i=Math.max(i,(s[y]??0)+1);(s[h]??0)<i&&(s[h]=i)}for(const h of g){const i=f.get(h)??[];if(i.length>0){const y=Math.min(...i.map(L=>(s[L]??0)-1));(s[h]??0)>y&&(s[h]=y)}}return{layers:fo(n,u,s),rankOf:s,dummy:new Set}}a(Ts,"assignLayers_Gravity");function ws(t){const e=tn(t),n=ao(t);let o=lo(e);const s=[];for(;o.length>0;){const r=[];for(const l of o){s.push(l);for(const f of n.get(l)??[])e.set(f,(e.get(f)??0)-1),(e.get(f)??0)===0&&r.push(f)}o=r.sort((l,f)=>l.localeCompare(f))}return s.length===t.nodes.length?s:null}a(ws,"topoSortByGenerationIfAcyclic");function Es(t,e){const n=pe(t),o=e?.direction==="LR"?ws(n)??[...n.nodes].sort():Ne(n)??[...n.nodes].sort(),s=le(n),r=a(b=>s(b)??b,"laneOf"),l=Object.create(null),f=new Map,u=a((b,p)=>e?.ignoreCrossLaneEdges??!0?r(b)===r(p)?1:0:1,"edgeWeight");for(const b of o){if(n.nodeById.get(b)?.isGroup)continue;const v=co(n,b);let d=0;if(v.length>0)for(const L of v){const I=L.src,E=l[I]??0;d=Math.max(d,E+u(I,b))}const h=r(b),i=f.get(h)??0,y=Math.max(d,i);l[b]=y,f.set(h,y+1)}return{layers:fo(n,o,l,{skipGroups:!0}),rankOf:l,dummy:new Set}}a(Es,"assignLayers_LaneAwareCompact");function As(t,e){const n=pe(e),{rankOf:o}=t,s=t.layers.map(d=>[...d]),r=new Set(t.dummy?[...t.dummy]:[]);let l=0;const f=new Map(n.nodeById),u=a(d=>{const h=`placeholder-${l++}`,i={id:h,isGroup:!1,isDummy:!0,width:0,height:0};for(f.set(h,i),r.add(h);s.length<=d;)s.push([]);return s[d].push(h),o[h]=d,h},"addDummyAt"),g=[...n.edges].sort((d,h)=>d.id===h.id?d.src===h.src?d.dst.localeCompare(h.dst):d.src.localeCompare(h.src):d.id.localeCompare(h.id)),b=[];for(const d of g){const h=o[d.src]??0,i=o[d.dst]??0;if(i-h<=1){b.push(d);continue}let y=d.src;for(let I=h+1,E=0;I<i;I++,E++){const T=u(I);b.push({id:`${d.id}#${E}`,src:y,dst:T,weight:d.weight,ref:d.ref}),y=T}const L=i-h-2;b.push({id:`${d.id}#${Math.max(L+1,0)}`,src:y,dst:d.dst,weight:d.weight,ref:d.ref})}const v={nodes:[...n.nodes,...[...r].filter(d=>!n.nodes.includes(d))],edges:b,layout:n.layout,nodeById:f};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:v}}a(As,"makeProperLayering");function Xn(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])}a(Xn,"median");function Yn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}a(Yn,"barycenter");function Rs(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}a(Rs,"neighborPositionsFor");function Ns(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}a(Ns,"currentOrderTieBreak");function Gn(t,e,n){const o=new Set(t),s=new Set(e),r=Ae(t),l=Ae(e),f=[];for(const g of n)o.has(g.src)&&s.has(g.dst)&&f.push({u:r.get(g.src),v:l.get(g.dst)});f.sort((g,b)=>g.u===b.u?g.v-b.v:g.u-b.u);const u=f.map(g=>g.v);return uo(u)}a(Gn,"countCrossingsBetweenAdjacent");function Ge(t,e,n){return[...t].sort((o,s)=>{const r=Xn(e.get(o)??[]),l=Xn(e.get(s)??[]);return r===l?Ns(o,s,n):isFinite(r)?isFinite(l)?r-l:-1:1})}a(Ge,"sortByHeuristic");function zn(t,e,n,o,s,r){const l=Ae(t),f=Ae(e),u=Rs(e,l,n,o);if(!s||!r||r.length===0)return Ge(e,u,f);const g=new Map;for(const v of e){const d=s(v),h=g.get(d)??[];h.push(v),g.set(d,h)}const b=[];for(const v of r){const d=g.get(v);if(!d||d.length===0)continue;const h=Ge(d,u,f);b.push(...h)}const p=g.get(null);if(p&&p.length>0){const v=Ge(p,u,f);for(const d of v){const h=Yn(u.get(d)??[]);let i=b.length;if(isFinite(h))for(const[y,L]of b.entries()){const I=Yn(u.get(L)??[]);if(h<I){i=y;break}}b.splice(i,0,d)}}return b}a(zn,"reorderLayer");function $n(t,e,n,o,s){const r=[...e],l=new Set(t),f=new Set(e),u=o?new Set(o):null,g=n.filter(i=>l.has(i.src)&&f.has(i.dst)),b=u?n.filter(i=>f.has(i.src)&&u.has(i.dst)):void 0,p=a(i=>{let y=Gn(t,i,g);return b&&o&&(y+=Gn(i,o,b)),y},"crossingScore"),v=s?new Map:null;if(s&&v)for(const i of e)v.set(i,s(i));let d=!0,h=p(r);for(;d;){d=!1;for(let i=0;i+1<r.length;i++){if(v){const I=v.get(r[i]),E=v.get(r[i+1]);if(I!==E)continue}const y=h;[r[i],r[i+1]]=[r[i+1],r[i]];const L=p(r);L<y?(h=L,d=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}}return r}a($n,"transposeImprove");function Os(t,e,n){const o=t.layers.map(f=>[...f]),s=e.edges,r=le(e),l=ho(e,n?.laneOrder);for(let f=0;f<3;f++){for(let u=1;u<o.length;u++)o[u]=zn(o[u-1],o[u],s,"down",r,l),o[u]=$n(o[u-1],o[u],s,o[u+1],r);for(let u=o.length-2;u>=0;u--)o[u]=zn(o[u+1],o[u],s,"up",r,l),o[u]=$n(o[u+1],o[u],s,o[u-1],r)}return{layers:o}}a(Os,"orderLayers");function Bs(t,e,n){const o=n?.layerGap??vo.DEFAULT_LAYER_GAP,s=n?.nodeGap??vo.DEFAULT_NODE_GAP,r=n?.laneGap??s*2,l=n?.direction??"TB",f=l==="LR"||l==="RL",u=t.layers,g=Object.create(null),b=Object.create(null),p=a(O=>e.nodeById.get(O),"getNode"),v=a(O=>p(O)?.width??0,"getWidth"),d=a(O=>p(O)?.height??0,"getHeight"),h=le(e),i=ho(e,n?.laneOrder),y=u.map(O=>O.reduce((F,D)=>Math.max(F,d(D)),0)),L=[];if(f)for(let O=0;O+1<u.length;O++){const F=u[O].reduce((pt,kt)=>Math.max(pt,v(kt)),0),D=u[O+1].reduce((pt,kt)=>Math.max(pt,v(kt)),0),B=y[O],G=y[O+1],j=B/2+G/2,Z=(F+D)/2,dt=Math.max(0,Z-j-o);L.push(dt)}const I=new Set;for(const O of u)for(const F of O)I.add(h(F));const E=I.has(null),T=i.filter(O=>I.has(O)),m=[...E?[null]:[],...T],M=Object.create(null);for(const O of T)M[O]=0;E&&(M.null=0);for(const O of u){const F=Object.create(null),D=[];for(const B of O){const G=h(B);G===null?D.push(B):(F[G]||=[]).push(B)}for(const[B,G]of Object.entries(F)){const j=G.reduce((Z,dt)=>Z+v(dt),0)+s*Math.max(0,G.length-1);M[B]=Math.max(M[B]??0,j)}if(E&&D.length){const B=D.reduce((G,j)=>G+v(j),0)+s*Math.max(0,D.length-1);M.null=Math.max(M.null??0,B)}}const A=new Map;{const O=m.map(B=>(B===null?M.null:M[B])??0);let D=-(O.reduce((B,G)=>B+G,0)+r*Math.max(0,m.length-1))/2;for(let B=0;B<m.length;B++){const G=m[B],j=O[B]??0,Z=D+j/2;A.set(G,Z),D+=j,B<m.length-1&&(D+=r)}}let R=0;for(const[O,F]of u.entries()){const D=y[O]??0,B=new Map;for(const j of F){const Z=h(j),dt=B.get(Z)??[];dt.push(j),B.set(Z,dt)}for(const j of m){const Z=B.get(j)??[];if(Z.length===0)continue;const dt=A.get(j);if(Z.length===1){const pt=Z[0];g[pt]=dt,b[pt]=R+D/2}else{const pt=Z.map(Q=>v(Q)),kt=pt.reduce((Q,W)=>Q+W,0)+s*(Z.length-1);let Bt=dt-kt/2;for(const[Q,W]of Z.entries()){const et=pt[Q];g[W]=Bt+et/2,b[W]=R+D/2,Bt+=et+s}}}const G=L[O]??0;R+=D+o+G}const k=new Map;for(const O of e.edges){const F=O.ref.id;k.has(F)||k.set(F,[]),k.get(F).push(O)}for(const[,O]of k){if(O.length===0)continue;const F=O[0].ref,D=F.start,B=F.end;if(D==null||B==null)continue;const G=Math.round(((g[D]??0)+(g[B]??0))/2),j=new Set;for(const Z of O)j.add(Z.src),j.add(Z.dst);for(const Z of j){if(Z===D||Z===B)continue;e.nodeById.get(Z)?.isDummy&&(g[Z]=G)}}return{x:g,y:b}}a(Bs,"assignCoordinates");var Ps=8;function ks(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}a(ks,"hashString");function Fs(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}}a(Fs,"mulberry32");function _s(t,e){const n=[...t],o=Fs(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}a(_s,"deterministicShuffle");function Hs(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}a(Hs,"sourceDistance");function Vn(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:l}of e){const f=n.get(s),u=n.get(r);f==null||u==null||(o+=l*Math.abs(f-u))}return o}a(Vn,"laneArrangementCost");function Ds(t){const e=nn(t);if(e.length<2)return[];const n=new Map(e.map((r,l)=>[r,l])),o=le(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const l=typeof r.start=="string"?r.start:void 0,f=typeof r.end=="string"?r.end:void 0;if(!l||!f||!t.nodeById.has(l)||!t.nodeById.has(f))continue;const u=o(l),g=o(f);if(!u||!g||u===g)continue;const b=n.get(u),p=n.get(g);if(b==null||p==null)continue;const[v,d]=b<=p?[u,g]:[g,u],h=`${v}\0${d}`,i=s.get(h);i?i.weight++:s.set(h,{a:v,b:d,weight:1})}return[...s.values()]}a(Ds,"buildWeightedLaneEdges");function jn(t,e,n){const o=[...t];let s=Vn(o,e),r=!0,l=0;const f=Math.max(1,o.length);for(;r&&l<f;){r=!1,l++;for(let u=0;u+1<o.length;u++){[o[u],o[u+1]]=[o[u+1],o[u]];const g=Vn(o,e);g<s?(s=g,r=!0):[o[u],o[u+1]]=[o[u+1],o[u]]}}return{order:o,cost:s,sourceDistance:Hs(o,n)}}a(jn,"greedySwitch");function Xs(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}a(Xs,"isBetterCandidate");function Ys(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:l})=>`${s}:${r}:${l}`).join("|");return ks(`${t.join("|")}#${o}#${n}`)}a(Ys,"seedForRestart");function Gs(t,e={}){const n=nn(t);if(n.length<2)return n;const o=Ds(t);if(o.length===0)return n;const s=new Map(n.map((f,u)=>[f,u]));let r=jn(n,o,s);const l=Math.max(0,e.restarts??Ps);for(let f=0;f<l;f++){const u=Ys(n,o,f),g=_s(n,u),b=jn(g,o,s);Xs(b,r)&&(r=b)}return r.order}a(Gs,"optimizeTopLaneOrder");function zs(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,s=pe(t),r=e?.automaticLaneOrdering?Gs(s,{restarts:Ps}):void 0,l=ls(s),f=l.acyclic,u=n?Es(f,{compactSingleInput:e?.compactSingleInput??qe.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Ts(f,{compactSingleInput:e?.compactSingleInput??qe.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:g,graphWithDummies:b}=As(u,f),p=Os(g,b,{laneOrder:r}),v=Bs(p,b,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:r});return{acyclic:f,reversed:l.reversed,layering:g,ordered:p,coordinates:v}}a(zs,"sugiyamaLayout");var ct=gr.EPSILON,mr=8,xe=15,Te=15,Xe=25,ne=20,pn=10;function Un(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,l=e.y-s,f=Math.abs(r),u=Math.abs(l);return f<ct&&u<ct?n:u>ct&&u*3>=f?l>0?"bottom":"top":f>ct?r>0?"right":"left":n}a(Un,"chooseOrthogonalSide");function Wn(t,e){return Math.abs(t.to-e.from)<ct||Math.abs(t.to-e.to)<ct?t.to:t.from}a(Wn,"sharedLineEndpointCoord");function be(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}a(be,"pointOnLine");function $s(t,e){const n=t.nodes??[],o=t.edges??[],s=[];for(const c of o)c.isLayoutOnly||s.push({...c,__originalEdge:c});const r=new Map,l=new Map,f=[],u=e==="LR";for(const c of n)r.set(c.id,c);const g=n.filter(c=>c.isGroup&&!c.parentId);for(const c of g){const x={id:c.id},S=a(C=>{l.set(C.id,x),n.filter(w=>w.parentId===C.id).forEach(S)},"assignLane");S(c)}const b=n.filter(c=>!c.isGroup&&!c.isEdgeLabel).map(c=>{const x=c.width??10,S=c.height??10,C=c.x??0,w=c.y??0,P=mr;return{nodeId:c.id,minX:C-x/2-P,maxX:C+x/2+P,minY:w-S/2-P,maxY:w+S/2+P,visualXHalfExtent:u?S/2+P:x/2+P}}),p=a((c,x,S,C)=>{let w=f.find(P=>P.orientation===c&&Math.abs(P.coord-x)<1);return w||(w={id:`pipe-${c}-${x.toFixed(0)}`,orientation:c,coord:x,spanMin:S,spanMax:C,tracks:[]},f.push(w)),w.spanMin=Math.min(w.spanMin,S),w.spanMax=Math.max(w.spanMax,C),w},"getOrAddPipe"),v=a((c,x)=>{const S=c.width??10,C=c.height??10,w=c.x??0,P=c.y??0;switch(x){case"top":return{x:w,y:P-C/2};case"bottom":return{x:w,y:P+C/2};case"left":return{x:w-S/2,y:P};case"right":return{x:w+S/2,y:P}}},"portForSide"),d=a((c,x,S)=>v(c,Un(c,x,S?"bottom":"top")),"getOrthogonalPort"),h=[],i=[],y=new Set,L=1e3,I=a((c,x,S)=>{if(h.length===0)return 0;const C=Math.abs(x.y-S.y)<ct,w=Math.abs(x.x-S.x)<ct;if(!C&&!w)return 0;let P=0;if(C){const U=x.y,q=Math.min(x.x,S.x)-ct,$=Math.max(x.x,S.x)+ct;if($<=q)return 0;for(const Y of h)Y.edgeIndex===c||Y.orientation!=="vertical"||Y.pipe.coord<q||Y.pipe.coord>$||Y.from-ct<=U&&Y.to+ct>=U&&(P+=L)}else if(w){const U=x.x,q=Math.min(x.y,S.y)-ct,$=Math.max(x.y,S.y)+ct;if($<=q)return 0;for(const Y of h)Y.edgeIndex===c||Y.orientation!=="horizontal"||Y.pipe.coord<q||Y.pipe.coord>$||Y.from-ct<=U&&Y.to+ct>=U&&(P+=L)}return P},"crossingPenalty"),E=s.map((c,x)=>{if(!c.start||!c.end)return{idx:x,crossLane:0,dx:0,dy:0};const S=r.get(c.start),C=r.get(c.end),w=l.get(c.start),P=l.get(c.end),U=w&&P&&w.id!==P.id?1:0,q=S&&C?Math.abs((C.x??0)-(S.x??0)):0,$=S&&C?Math.abs((C.y??0)-(S.y??0)):0;return{idx:x,crossLane:U,dx:q,dy:$}}).sort((c,x)=>{if(c.crossLane!==x.crossLane)return x.crossLane-c.crossLane;const S=c.dx+c.dy,C=x.dx+x.dy;return Math.abs(S-C)>1?S-C:c.idx-x.idx}).map(c=>c.idx),T=a((c,x,S,C)=>{const w=Math.min(c.x,x.x),P=Math.max(c.x,x.x),U=Math.min(c.y,x.y),q=Math.max(c.y,x.y);return!!b.find(Y=>S&&Y.nodeId===S||C&&Y.nodeId===C?!1:Math.abs(c.x-x.x)>ct?Y.minY<c.y&&Y.maxY>c.y&&Y.maxX>w&&Y.minX<P:Y.minX<c.x&&Y.maxX>c.x&&Y.maxY>U&&Y.minY<q)},"isSegmentBlocked"),m=new Map,M=new Map;for(const c of s)!c.start||!c.end||c.start===c.end||(M.set(c.start,(M.get(c.start)??0)+1),M.set(c.end,(M.get(c.end)??0)+1));const A=a((c,x)=>Un(c,x,"bottom"),"determineSide"),R=new Map;for(const[c,x]of s.entries()){if(!x.start||!x.end||x.start===x.end||x.points&&x.points.length>0)continue;const S=r.get(x.start),C=r.get(x.end);if(!S||!C)continue;const w=(C.x??0)-(S.x??0),P=(C.y??0)-(S.y??0);R.set(c,{edgeIdx:c,srcId:x.start,dstId:x.end,srcSide:A(S,{x:C.x??0,y:C.y??0}),dstSide:A(C,{x:S.x??0,y:S.y??0}),absDx:Math.abs(w),absDy:Math.abs(P),dxSign:Math.sign(w),dySign:Math.sign(P)})}const k=a(c=>c.srcSide==="top"||c.srcSide==="bottom"?c.absDx===0?1/0:c.absDy/c.absDx:c.absDy===0?1/0:c.absDx/c.absDy,"preferenceStrength"),O=a(c=>c.srcSide==="top"||c.srcSide==="bottom"?c.dxSign>=0?"right":"left":c.dySign>=0?"bottom":"top","secondarySide"),F=new Map;for(const c of R.values()){const x=`${c.srcId}:${c.srcSide}`;F.has(x)||F.set(x,[]),F.get(x).push(c)}const D=new Map,B=a((c,x)=>`${c}:${x}`,"loadKey");for(const c of R.values())D.set(B(c.srcId,c.srcSide),(D.get(B(c.srcId,c.srcSide))??0)+1),D.set(B(c.dstId,c.dstSide),(D.get(B(c.dstId,c.dstSide))??0)+1);for(const c of F.values())if(!(c.length<2)){c.sort((x,S)=>{const C=k(x),w=k(S);return Math.abs(C-w)>1e-9?w-C:x.edgeIdx-S.edgeIdx});for(let x=1;x<c.length;x++){const S=c[x],C=O(S),w=D.get(B(S.srcId,S.srcSide))??0,P=D.get(B(S.srcId,C))??0;P>=w||(D.set(B(S.srcId,S.srcSide),w-1),D.set(B(S.srcId,C),P+1),S.srcSide=C)}}const G=a(c=>{const x=c?.shape;return x==="question"||x==="diamond"},"isDiamondNode"),j=new Map;for(const c of R.values())j.has(c.dstId)||j.set(c.dstId,new Set),j.get(c.dstId).add(c.dstSide);for(const c of R.values()){if(!G(r.get(c.srcId)))continue;const x=j.get(c.srcId);if(!x?.has(c.srcSide))continue;const S=O(c);if(x.has(S)||(D.get(B(c.srcId,S))??0)>0)continue;const C=D.get(B(c.srcId,c.srcSide))??0;D.set(B(c.srcId,c.srcSide),Math.max(0,C-1)),D.set(B(c.srcId,S),1),c.srcSide=S}for(const c of R.values()){const{edgeIdx:x,srcId:S,dstId:C,srcSide:w,dstSide:P}=c,U=r.get(S),q=r.get(C),$=`${S}:${w}:src`,Y=w==="top"||w==="bottom"?q.x??0:q.y??0;m.has($)||m.set($,[]),m.get($).push({edgeIdx:x,oppositeCoord:Y});const ot=`${C}:${P}:dst`,rt=P==="top"||P==="bottom"?U.x??0:U.y??0;m.has(ot)||m.set(ot,[]),m.get(ot).push({edgeIdx:x,oppositeCoord:rt})}const Z=new Map,dt=8;for(const[c,x]of m){if(x.length<2)continue;x.sort((Lt,Ht)=>Lt.oppositeCoord-Ht.oppositeCoord);const S=c.split(":"),C=S.slice(0,-2).join(":"),w=S[S.length-2],P=S[S.length-1],U=r.get(C);if(!U)continue;const $=w==="left"||w==="right"?U.height??10:U.width??10,Y=U.shape,rt=Y==="question"||Y==="diamond"?$*.3:$,tt=Math.min(20,Math.max(dt,rt/(x.length+1))),Rt=-(tt*(x.length-1))/2;for(const[Lt,Ht]of x.entries()){const Zt=Rt+Lt*tt,cn=`${Ht.edgeIdx}:${P}`;Z.set(cn,Zt)}}const pt=a(c=>!!s[c]?.labelNodeId,"edgeHasLabelNode"),kt=a((c,x)=>c?(m.get(`${c}:${x}:src`)??[]).some(({edgeIdx:S})=>pt(S))||(m.get(`${c}:${x}:dst`)??[]).some(({edgeIdx:S})=>pt(S)):!1,"faceHasLabelNode"),Bt=a((c,x,S)=>x==="top"||x==="bottom"?{x:c.x+S,y:c.y}:{x:c.x,y:c.y+S},"applyPortOffset"),Q=a((c,x,S)=>{const C=R.get(c),w={x:S.x??0,y:S.y??0},P={x:x.x??0,y:x.y??0},U=C?.srcSide??A(x,w),q=C?.dstSide??A(S,P);let $=C?v(x,C.srcSide):d(x,w,!0),Y=C?v(S,C.dstSide):d(S,P,!1);const ot=Z.get(`${c}:src`),rt=Z.get(`${c}:dst`);return ot!==void 0&&($=Bt($,U,ot)),rt!==void 0&&(Y=Bt(Y,q,rt)),{pSrcPort:$,pDstPort:Y,srcSide:U,dstSide:q}},"portsForEdge");for(const c of E){const x=s[c];if(i[c]=[],!x.start||!x.end||x.points&&x.points.length>0||x.start===x.end)continue;const S=r.get(x.start),C=r.get(x.end);if(!S||!C)continue;const{pSrcPort:w,pDstPort:P,srcSide:U,dstSide:q}=Q(c,S,C),$={...w},Y={...P},ot=U==="top"||U==="bottom",rt=q==="top"||q==="bottom";if(ot){const X=w.y>(S.y??0);$.y=X?w.y+ne:w.y-ne}else{const X=w.x>(S.x??0);$.x=X?w.x+ne:w.x-ne}if(rt){const X=P.y>(C.y??0);Y.y=X?P.y+ne:P.y-ne}else{const X=P.x>(C.x??0);Y.x=X?P.x+ne:P.x-ne}const st=a((X,z)=>{for(const K of b)if(!z.includes(K.nodeId)&&X.x>K.minX&&X.x<K.maxX&&X.y>K.minY&&X.y<K.maxY)return{inside:!0,obstacle:K};return{inside:!1}},"isPointInObstacle"),tt=a((X,z,K,lt,Ct)=>{if(Ct){const Nt=X.y>(z.y??0);return{x:(K.x??0)>=X.x?lt.maxX+xe:lt.minX-xe,y:Nt?lt.maxY+Te:lt.minY-Te,leavesPositiveSide:Nt}}const bt=X.x>(z.x??0),Tt=(K.y??0)>=X.y;return{x:bt?lt.maxX+xe:lt.minX-xe,y:Tt?lt.maxY+Te:lt.minY-Te,leavesPositiveSide:bt}},"obstacleDetour");let yt=[];const Rt=[x.start,x.end],Lt=st($,Rt);if(Lt.inside&&Lt.obstacle){const X=Lt.obstacle;if(ot){const z=tt(w,S,C,X,!0);$.x=z.x,$.y=z.y;const K=z.leavesPositiveSide?Math.min(X.minY-2,w.y+ne):Math.max(X.maxY+2,w.y-ne);yt=[{x:w.x,y:K},{x:z.x,y:K},{x:z.x,y:z.y}]}else{const z=tt(w,S,C,X,!1),K=z.leavesPositiveSide?Math.min(X.minX-2,w.x+ne):Math.max(X.maxX+2,w.x-ne);$.x=z.x,$.y=z.y,yt=[{x:K,y:w.y},{x:K,y:z.y},{x:z.x,y:z.y}]}}let Ht=[];const Zt=st(Y,Rt);if(Zt.inside&&Zt.obstacle){const X=Zt.obstacle;if(rt){const z=tt(P,C,S,X,!0);Y.x=z.x,Y.y=z.y,Ht=[{x:z.x,y:z.y},{x:P.x,y:z.y}]}else{const z=tt(P,C,S,X,!1);Y.x=z.x,Y.y=z.y,Ht=[{x:z.x,y:z.y},{x:z.x,y:P.y}]}}if(yt.length===0&&Ht.length===0){const X=xe,z=Math.abs($.x-Y.x)<X,K=Math.abs($.y-Y.y)<X,lt=Z.get(`${c}:src`)!==void 0||Z.get(`${c}:dst`)!==void 0,Ct=(m.get(`${x.start??""}:${U}:src`)?.length??0)+(m.get(`${x.start??""}:${U}:dst`)?.length??0),bt=(m.get(`${x.end??""}:${q}:src`)?.length??0)+(m.get(`${x.end??""}:${q}:dst`)?.length??0),Tt=Ct>1||bt>1,Nt=M.get(x.start??"")??0,ut=M.get(x.end??"")??0,Yt=Ct>1&&kt(x.start,U)||bt>1&&kt(x.end,q),ee=Ct<=1||Nt<=2,Pt=bt<=1||ut<=2;if((z||K)&&!lt&&(!Tt||Tt&&!Yt&&ee&&Pt)&&!T(w,P,x.start,x.end)){x.points=[{...w},{...$},{...Y},{...P}],y.add(c);const It=K?"horizontal":"vertical",zt=K?w.y:w.x,Mt=K?Math.min(w.x,P.x):Math.min(w.y,P.y),St=K?Math.max(w.x,P.x):Math.max(w.y,P.y),Wt={id:`fast-path-${It}-${zt.toFixed(0)}-${c}`,orientation:It,coord:zt,spanMin:Mt,spanMax:St,tracks:[]};h.push({edgeIndex:c,segmentIndex:0,orientation:It,pipe:Wt,trackIndex:0,from:Mt,to:St});continue}}const cn=p("vertical",$.x,$.y,$.y);$.x=cn.coord;const Ws=p("vertical",Y.x,Y.y,Y.y);Y.x=Ws.coord;let de=Math.min($.x,Y.x)-50,ue=Math.max($.x,Y.x)+50,Ce=Math.min($.y,Y.y)-50,ve=Math.max($.y,Y.y)+50;for(const X of b){const z=Math.min($.x,Y.x),K=Math.max($.x,Y.x),lt=Math.min($.y,Y.y),Ct=Math.max($.y,Y.y);X.minX<K&&X.maxX>z&&X.minY<Ct&&X.maxY>lt&&(de=Math.min(de,X.minX-Xe),ue=Math.max(ue,X.maxX+Xe),Ce=Math.min(Ce,X.minY-Xe),ve=Math.max(ve,X.maxY+Xe))}for(const X of b){if(X.maxX<de||X.minX>ue||X.maxY<Ce||X.minY>ve)continue;const z=xe;p("horizontal",X.minY-z,de,ue),p("horizontal",X.maxY+z,de,ue);const K=Te;p("vertical",X.minX-K,Ce,ve),p("vertical",X.maxX+K,Ce,ve)}p("horizontal",$.y,de,ue),p("horizontal",Y.y,de,ue);const Ks=f.filter(X=>X.orientation==="horizontal"&&X.coord>=Ce&&X.coord<=ve),qs=f.filter(X=>X.orientation==="vertical"&&X.coord>=de&&X.coord<=ue),Oe=a((X,z)=>`${X.toFixed(1)},${z.toFixed(1)}`,"getKey"),Be=Oe($.x,$.y),mo=Oe(Y.x,Y.y),Pe=new Map,an=new Map,ln=new Map,ke=new Set,ye=[];Pe.set(Be,0),ln.set(Be,"n"),ye.push({key:Be,f:Math.hypot(Y.x-$.x,Y.y-$.y),pt:$}),ke.add(Be);let Dt=[];const he=a((X,z)=>T(X,z,x.start,x.end),"checkSegmentBlocked"),fn={x:Y.x,y:$.y},Zs=he($,fn),Js=he(fn,Y),Qs=Zs||Js,dn={x:$.x,y:Y.y},tr=he($,dn),er=he(dn,Y);if(Qs?tr||er||(Math.abs($.x-Y.x)<ct?Dt=[$,Y]:Dt=[$,dn,Y]):Math.abs($.y-Y.y)<ct||Math.abs($.x-Y.x)<ct?Dt=[$,Y]:Dt=[$,fn,Y],Dt.length===0)for(;ye.length>0;){ye.sort((ut,Yt)=>ut.f-Yt.f);const X=ye.shift();if(ke.delete(X.key),X.key===mo){let ut=mo,Yt=Y;for(Dt=[Yt];an.has(ut);){const ee=an.get(ut);Dt.unshift(ee),Yt=ee,ut=Oe(ee.x,ee.y)}break}const z=X.pt.x,K=X.pt.y,lt=qs.sort((ut,Yt)=>ut.coord-Yt.coord),Ct=lt.findIndex(ut=>Math.abs(ut.coord-z)<1),bt=Ks.sort((ut,Yt)=>ut.coord-Yt.coord),Tt=bt.findIndex(ut=>Math.abs(ut.coord-K)<1),Nt=[];Ct>0&&Nt.push({x:lt[Ct-1].coord,y:K}),Ct>=0&&Ct<lt.length-1&&Nt.push({x:lt[Ct+1].coord,y:K}),Tt>0&&Nt.push({x:z,y:bt[Tt-1].coord}),Tt>=0&&Tt<bt.length-1&&Nt.push({x:z,y:bt[Tt+1].coord});for(const ut of Nt){const Yt=Math.min(z,ut.x),ee=Math.max(z,ut.x),Pt=Math.min(K,ut.y),Gt=Math.max(K,ut.y);if(b.some(Jt=>Jt.nodeId===x.start||Jt.nodeId===x.end?!1:Yt!==ee?Jt.minY<K&&Jt.maxY>K&&Jt.maxX>Yt&&Jt.minX<ee:Jt.minX<z&&Jt.maxX>z&&Jt.maxY>Pt&&Jt.minY<Gt))continue;const It=Oe(ut.x,ut.y),zt=Math.abs(ut.x-z)+Math.abs(ut.y-K),Mt=I(c,X.pt,ut);let St=0;const Wt=Y.x-$.x,Le=Y.y-$.y,Fe=ut.x-z,un=ut.y-K;(Le>10&&un<-5||Le<-10&&un>5)&&(St=Math.abs(un)*100),(Wt>10&&Fe<-5||Wt<-10&&Fe>5)&&(St+=Math.abs(Fe)*50);let po=0;const yo=ln.get(X.key)??"n",xo=Math.abs(Fe)>ct?"h":"v";yo!=="n"&&yo!==xo&&(po=50);const nr=zt+Mt+St+po,_e=(Pe.get(X.key)??1/0)+nr,bo=Math.abs(Y.x-ut.x)+Math.abs(Y.y-ut.y);if(_e<(Pe.get(It)??1/0))if(an.set(It,X.pt),Pe.set(It,_e),ln.set(It,xo),!ke.has(It))ye.push({key:It,f:_e+bo,pt:ut}),ke.add(It);else{const Jt=ye.findIndex(or=>or.key===It);Jt!==-1&&(ye[Jt].f=_e+bo)}}}if(Dt.length===0&&(Dt=[$,{x:$.x,y:Y.y},Y]),Dt.length>4){const X=Dt[0],z=Dt[Dt.length-1];let K=Math.min(X.x,z.x),lt=Math.max(X.x,z.x),Ct=Math.min(X.y,z.y),bt=Math.max(X.y,z.y);for(const Pt of Dt)K=Math.min(K,Pt.x),lt=Math.max(lt,Pt.x),Ct=Math.min(Ct,Pt.y),bt=Math.max(bt,Pt.y);const Tt=lt>Math.max(X.x,z.x),Nt=K<Math.min(X.x,z.x);if(u){const Pt=Te;if(Tt){const Gt=Math.max(X.x,z.x),Ot=Math.min(X.y,z.y),It=Math.max(X.y,z.y),zt=b.filter(Mt=>Mt.minX<Gt&&Mt.maxX>Gt&&Mt.minY<It&&Mt.maxY>Ot);if(zt.length>0){let Mt=Math.max(X.x,z.x);for(const St of zt){const Wt=(St.minX+St.maxX)/2;if(St.visualXHalfExtent===void 0||isNaN(St.visualXHalfExtent))continue;const Le=Wt+St.visualXHalfExtent+Pt;Mt=Math.max(Mt,Le)}isNaN(Mt)||(lt=Mt)}}if(Nt){const Gt=b.filter(Ot=>Ot.minX<Math.min(X.x,z.x)+Pt&&Ot.minY<Math.max(X.y,z.y)&&Ot.maxY>Math.min(X.y,z.y));if(Gt.length>0){let Ot=Math.min(X.x,z.x);for(const It of Gt){const Mt=(It.minX+It.maxX)/2-It.visualXHalfExtent-Pt;Ot=Math.min(Ot,Mt)}K=Ot}}}const ut=a(Pt=>{const Gt=z.y>X.y,Ot=b.filter(Mt=>{const St=Math.min(X.x,z.x)<Mt.maxX&&Math.max(X.x,z.x)>Mt.minX,Wt=Math.min(X.y,z.y)<Mt.maxY&&Math.max(X.y,z.y)>Mt.minY;return St&&Wt});let It=Ot;if(u&&Ot.length>0){const Mt=Ot.filter(St=>St.minX<Pt&&St.maxX>Pt);Mt.length>0&&(It=Mt)}if(It.length===0)return z.y;const zt=xe;if(Gt){const St=Math.max(...It.map(Wt=>Wt.maxY))+zt;if(St<z.y-ct)return St}else{const St=Math.min(...It.map(Wt=>Wt.minY))-zt;if(St>z.y+ct)return St}return z.y},"findBestReturnY"),Yt=a(Pt=>{const Gt=ut(Pt),Ot={x:Pt,y:X.y},It={x:Pt,y:Gt},zt={x:z.x,y:Gt},Mt=he(X,Ot),St=he(Ot,It),Wt=he(It,zt),Le=Gt!==z.y?he(zt,z):!1;return!Mt&&!St&&!Wt&&!Le?Math.abs(Gt-z.y)<ct?[X,Ot,It,z]:[X,Ot,It,zt,z]:null},"trySimplifyWithDetourX"),ee=Tt&&!Nt?Yt(lt):Nt&&!Tt?Yt(K):null;ee&&(Dt=ee)}const Xt=[w,...yt,...Dt,...Ht.reverse(),P];if(Xt.length>=3){const X=Xt[Xt.length-1],z=Xt[Xt.length-2],K=Xt[Xt.length-3],lt=Math.abs(K.y-z.y)<ct&&Math.abs(z.y-X.y)<ct,Ct=Math.abs(K.x-z.x)<ct&&Math.abs(z.x-X.x)<ct;if(lt){const bt=Math.sign(z.x-K.x),Tt=Math.sign(X.x-K.x);bt!==0&&bt===Tt&&Math.abs(z.x-K.x)>Math.abs(X.x-K.x)&&Xt.splice(-2,1)}else if(Ct){const bt=Math.sign(z.y-K.y),Tt=Math.sign(X.y-K.y);bt!==0&&bt===Tt&&Math.abs(z.y-K.y)>Math.abs(X.y-K.y)&&Xt.splice(-2,1)}}const re=[Xt[0]];for(let X=1;X<Xt.length-1;X++){if(X===1){re.push(Xt[X]);continue}const z=re[re.length-1],K=Xt[X],lt=Xt[X+1];if(Math.abs(z.y-K.y)<ct&&Math.abs(K.y-lt.y)<ct){const Ct=K.x>z.x,bt=lt.x>K.x;if(Ct!==bt){re.push(K);continue}continue}if(Math.abs(z.x-K.x)<ct&&Math.abs(K.x-lt.x)<ct){const Ct=K.y>z.y,bt=lt.y>K.y;if(Ct!==bt){re.push(K);continue}continue}re.push(K)}re.push(Xt[Xt.length-1]);for(let X=0;X<re.length-1;X++){const z=re[X],K=re[X+1],lt=Math.abs(z.x-K.x)<ct?"vertical":"horizontal",Ct=lt==="vertical"?z.x:z.y,bt=lt==="vertical"?Math.min(z.y,K.y):Math.min(z.x,K.x),Tt=lt==="vertical"?Math.max(z.y,K.y):Math.max(z.x,K.x),Nt=p(lt,Ct,bt,Tt),ut={edgeIndex:c,segmentIndex:X,orientation:lt,pipe:Nt,trackIndex:0,from:bt,to:Tt};h.push(ut),i[c].push(h.length-1),Nt.tracks[0]||(Nt.tracks[0]={index:0,coord:Nt.coord,segments:[]}),Nt.tracks[0].segments.push({edgeIndex:c,segmentIndex:X,from:bt,to:Tt})}}const W=a((c,x)=>c.from<x.to&&x.from<c.to,"segmentsOverlap"),et=a((c,x,S,C)=>{const w=!C.segments.some(U=>(U.edgeIndex!==x.edgeIndex||U.segmentIndex!==x.segmentIndex)&&W(U,c)),P=!S.segments.some(U=>(U.edgeIndex!==c.edgeIndex||U.segmentIndex!==c.segmentIndex)&&W(U,x));return w&&P?(c.trackIndex=C.index,x.trackIndex=S.index,S.segments=[...S.segments.filter(U=>U.edgeIndex!==c.edgeIndex||U.segmentIndex!==c.segmentIndex),{edgeIndex:x.edgeIndex,segmentIndex:x.segmentIndex,from:x.from,to:x.to}],C.segments=[...C.segments.filter(U=>U.edgeIndex!==x.edgeIndex||U.segmentIndex!==x.segmentIndex),{edgeIndex:c.edgeIndex,segmentIndex:c.segmentIndex,from:c.from,to:c.to}],!0):!1},"trySwapSegmentsAcrossTracks"),at=a(c=>{const x=c.tracks.length;return c.tracks[x]={index:x,coord:c.coord,segments:[]},x},"createNewTrack"),gt=a((c,x)=>{const S=c.pipe.tracks[c.trackIndex];S.segments=S.segments.filter(w=>w.edgeIndex!==c.edgeIndex||w.segmentIndex!==c.segmentIndex),c.trackIndex=x,c.pipe.tracks[x].segments.push({edgeIndex:c.edgeIndex,segmentIndex:c.segmentIndex,from:c.from,to:c.to})},"moveSegmentToTrack"),xt=a((c,x)=>{const S=i[c.edgeIndex];for(const C of S){const w=h[C];w.pipe===c.pipe&&gt(w,x)}},"moveSegmentChainToTrack"),vt=a(c=>{const x=i[c.edgeIndex],S=x.indexOf(h.indexOf(c)),C=[];return S>0&&C.push(h[x[S-1]]),S<x.length-1&&C.push(h[x[S+1]]),C},"getAdjacentSegmentsAlongEdge"),Vt=a((c,x)=>{if(c.orientation===x.orientation)return!1;const S=c.orientation==="horizontal"?c:x,C=c.orientation==="horizontal"?x:c;return C.pipe.coord>S.from&&C.pipe.coord<S.to&&S.pipe.coord>C.from&&S.pipe.coord<C.to},"haveAnyCrossing"),jt=a((c,x)=>{for(const S of c.tracks)if(!S.segments.some(w=>(w.edgeIndex!==x.edgeIndex||w.segmentIndex!==x.segmentIndex)&&W(w,x)))return S.index;return-1},"findAvailableTrack"),Ut=a((c,x)=>{if(c.trackIndex===x.trackIndex)return W(c,x);const S=vt(c),C=vt(x);return S.some(w=>C.some(P=>Vt(w,P)))},"segmentsConflict"),te=a((c,x,S)=>{if(et(c,x,c.pipe.tracks[c.trackIndex],x.pipe.tracks[x.trackIndex]))return;const C=jt(c.pipe,x);S(x,C!==-1?C:at(c.pipe))},"resolveTrackConflict"),Me=a(c=>{let x=0;for(let S=0;S<c.length;S++)for(let C=S+1;C<c.length;C++){const w=c[S],P=c[C];w.pipe===P.pipe&&Ut(w,P)&&(x++,te(w,P,xt))}return x},"resolveHandleConflicts"),fe=new Map,Se=a(c=>{if(fe.has(c))return fe.get(c);const x=i[c];if(x.length===0){const q={dest:0,deviation:0,base:0,delta:0};return fe.set(c,q),q}const C=h[x[0]].pipe.coord;let w=C;for(let q=1;q<x.length;q++){const $=h[x[q]];if($.orientation==="horizontal"){const Y=$.from,ot=$.to;w=Math.abs(Y-C)>Math.abs(ot-C)?Y:ot;break}}const P=Math.abs(w-C),U={dest:w,deviation:P,base:C,delta:w-C};return fe.set(c,U),U},"getDestInfo"),on=a(()=>{let c=0;const x=new Map;for(const[C,w]of s.entries())i[C].length!==0&&w.start&&(x.has(w.start)||x.set(w.start,[]),x.get(w.start).push(C));const S=a(C=>{const w=s[C];if(!w.start||!w.end)return 0;const P=r.get(w.start),U=r.get(w.end);if(!P||!U)return 0;const q=(U.x??0)-(P.x??0),$=(U.y??0)-(P.y??0);return Math.abs(q)+Math.abs($)},"getEdgeDistance");for(const C of x.values()){C.sort((P,U)=>{const q=Se(P),$=Se(U);if(Math.abs(q.deviation-$.deviation)>1)return q.deviation-$.deviation;if(Math.abs(q.dest-$.dest)>1)return q.dest-$.dest;const Y=S(P),ot=S(U);if(Math.abs(Y-ot)>1)return ot-Y;const rt=i[P].length,st=i[U].length;if(rt!==st)return rt-st;if(rt===1){const tt=i[P][0],yt=i[U][0];if(h[tt]&&h[yt]){const Rt=h[tt],Lt=h[yt],Ht=Math.abs(Rt.to-Rt.from),Zt=Math.abs(Lt.to-Lt.from);if(Math.abs(Ht-Zt)>1)return Ht-Zt}}return 0});const w=C.map(P=>h[i[P][0]]);c+=Me(w)}return c},"fixSourceHandleCrossings"),sn=a(()=>{let c=0;const x=new Map;for(const[S,C]of s.entries())i[S].length!==0&&C.end&&(x.has(C.end)||x.set(C.end,[]),x.get(C.end).push(S));for(const S of x.values()){S.sort((w,P)=>{const U=a(Y=>{const ot=i[Y];if(ot.length<2)return 0;const rt=h[ot[ot.length-2]];return Math.abs(rt.to-rt.from)},"getDist"),q=U(w),$=U(P);return Math.abs(q-$)>.1?q-$:w-P});const C=S.map(w=>h[i[w][i[w].length-1]]);c+=Me(C)}return c},"fixTargetHandleCrossings"),rn=a(()=>{let c=0;for(const x of f){const S=[];for(const C of x.tracks)for(const w of C.segments){const P=i[w.edgeIndex].find(U=>h[U].segmentIndex===w.segmentIndex);P!==void 0&&S.push(h[P])}S.sort((C,w)=>C.edgeIndex-w.edgeIndex||C.segmentIndex-w.segmentIndex);for(let C=0;C<S.length;C++)for(let w=C+1;w<S.length;w++){const P=S[C],U=S[w];Ut(P,U)&&(c++,te(P,U,gt))}}return c},"fixPipeCrossings");let N=0;const _=10;for(;N<_;){let c=0;if(c+=on(),c+=sn(),c+=rn(),c===0)break;N++}const H=new Map;for(const c of f){const x=[];c.tracks.forEach(C=>{C.segments.forEach(w=>{x.push({edgeIndex:w.edgeIndex,segmentIndex:w.segmentIndex,trackIndex:C.index,from:w.from,to:w.to})})}),x.sort((C,w)=>C.from-w.from);const S=[];if(x.length>0){let C=[x[0]],w=x[0].to;for(let P=1;P<x.length;P++){const U=x[P];U.from<w?(C.push(U),w=Math.max(w,U.to)):(S.push(C),C=[U],w=U.to)}S.push(C)}for(const C of S){const w=new Set;C.forEach(tt=>w.add(tt.trackIndex));const P=new Map;C.forEach(tt=>{const yt=Se(tt.edgeIndex);P.set(tt.trackIndex,(P.get(tt.trackIndex)??0)+yt.delta)});const U=[...w].filter(tt=>(P.get(tt)??0)<-1),q=[...w].filter(tt=>(P.get(tt)??0)>1),$=[...w].filter(tt=>Math.abs(P.get(tt)??0)<=1);U.sort((tt,yt)=>(P.get(yt)??0)-(P.get(tt)??0)),q.sort((tt,yt)=>(P.get(tt)??0)-(P.get(yt)??0));const Y=a((tt,yt)=>{C.filter(Rt=>Rt.trackIndex===tt).forEach(Rt=>{const Lt=y.has(Rt.edgeIndex)?c.coord:yt;H.set(`${Rt.edgeIndex}-${Rt.segmentIndex}`,Lt)})},"assignCoord");let ot=0;for(const tt of U)ot++,Y(tt,c.coord-ot*pn);if($.length===0&&w.size>0){const tt=[...w].sort((Lt,Ht)=>Math.abs(P.get(Lt)??0)-Math.abs(P.get(Ht)??0))[0],yt=U.indexOf(tt);yt!==-1&&U.splice(yt,1);const Rt=q.indexOf(tt);Rt!==-1&&q.splice(Rt,1),$.push(tt)}let rt=0;for(const tt of $){if(rt===0)Y(tt,c.coord);else{const yt=rt%2===1?1:-1,Rt=Math.ceil(rt/2);Y(tt,c.coord+yt*Rt*pn*.5)}rt++}let st=0;for(const tt of q)st++,Y(tt,c.coord+st*pn)}}for(const[c,x]of s.entries()){const S=i[c]??[];if(S.length===0)continue;const C=[],w=r.get(x.start),P=r.get(x.end),{pSrcPort:U,pDstPort:q}=Q(c,w,P),$=S.map(rt=>{const st=h[rt],tt=H.get(`${st.edgeIndex}-${st.segmentIndex}`)??st.pipe.coord;return{orient:st.orientation,coord:tt,from:st.from,to:st.to}});C.push(U);for(let rt=0;rt<$.length;rt++){const st=$[rt],tt=C[C.length-1],yt=st.orient==="vertical"?tt.y:tt.x,Rt=st.orient==="vertical"?tt.x:tt.y,Lt=$[rt+1],Ht=rt<$.length-1;if(Math.abs(Rt-st.coord)>ct&&C.push(be(st,yt)),Ht&&Lt.orient===st.orient)if(Math.abs(st.coord-Lt.coord)>ct){const Zt=st.orient==="vertical"?(yt+Lt.from)/2:Wn(st,Lt);C.push(be(st,Zt),be(Lt,Zt))}else(rt===0||rt===$.length-2)&&C.push(be(st,Wn(st,Lt)));else if(Ht)C.push(be(st,Lt.coord));else{const Zt=Math.abs(st.from-yt)<Math.abs(st.to-yt)?st.to:st.from;C.push(be(st,Zt))}}const Y=C[C.length-1];(Math.abs(Y.x-q.x)>ct||Math.abs(Y.y-q.y)>ct)&&C.push(q);const ot=[];C.length>0&&ot.push(C[0]);for(let rt=1;rt<C.length;rt++){const st=C[rt],tt=ot[ot.length-1];(Math.abs(st.x-tt.x)>ct||Math.abs(st.y-tt.y)>ct)&&ot.push(st)}x.points=ot}for(const c of s){const x=c.__originalEdge;x&&c.points&&(x.points=c.points)}t.edges=(t.edges??[]).filter(c=>!c.isLayoutOnly);const V=a((c,x)=>{const S=x.x??0,C=x.y??0,w=x.width??0,P=x.height??0;if(w<=0||P<=0)return c;const U=S-w/2,q=S+w/2,$=C-P/2,Y=C+P/2;if(c.x<U||c.x>q||c.y<$||c.y>Y)return c;const ot=c.x-U,rt=q-c.x,st=c.y-$,tt=Y-c.y,yt=Math.min(ot,rt,st,tt);return yt===ot?{x:U,y:c.y}:yt===rt?{x:q,y:c.y}:yt===st?{x:c.x,y:$}:{x:c.x,y:Y}},"nodeBoundaryClamp");for(const c of t.edges){const x=c.points;if(!x||x.length<2)continue;const S=c.start,C=c.end,w=S?r.get(S):void 0,P=C?r.get(C):void 0;w&&(x[0]=V(x[0],w)),P&&(x[x.length-1]=V(x[x.length-1],P))}return t}a($s,"routeEdgesOrthogonal");function Vs(t){return t.direction??"TB"}a(Vs,"getSwimlaneDirection");function js(t){const e=Eo(t),n=t.config.flowchart?.nodeSpacing??40,o=t.config.flowchart?.rankSpacing??100,s=t.config.swimlane?.ignoreCrossLaneEdges??!0,r=t.config.swimlane?.optimizeRanksByCrossings??!0,l=t.config.swimlane?.automaticLaneOrdering??!1,f=Vs(t),{ordered:u,coordinates:g}=zs(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:l,direction:f});Ao(e,u,g,{nodeGap:n,layerGap:o});for(const b of t.edges??[])delete b.points;$s(t,f);for(const b of t.edges??[])(!b.curve||b.curve==="basis")&&(b.curve="rounded");return cs(t,f),is(t),f}a(js,"runSwimlaneLayoutCore");function Us(t){wo(t);const e=Ro(t);t.nodes=e.nodes,t.edges=e.edges}a(Us,"prepareSwimlaneLayout");var vr=rr({prepareLayout:Us,runLayoutCore:js,afterPaint:Lo});export{vr as render};
@@ -1,8 +0,0 @@
1
- import{c as r,s as e}from"./flowDiagram-KWPJA3E3-CRR5EuoG.js";import{_ as o}from"./index-DqFyJdiT.js";import"./chunk-5VM5RSS4-3Lib-uGP.js";import"./chunk-XXDRQBXY-w71UKmME.js";import"./chunk-WEXAMYUT-Bv_MfOEM.js";import"./chunk-GWA4HPMP-CwHQm4wS.js";import"./channel-CI4_doFA.js";import"./vendor-editor-core-D-5q2tVX.js";import"./vendor-editor-languages-B6WRt0aC.js";var a=o(t=>`${e(t)}
2
- .swimlane.cluster:not([data-color-id]) rect {
3
- stroke: ${t.clusterBorder} !important;
4
- }
5
- [data-look="neo"].cluster rect {
6
- filter: none;
7
- }
8
- `,"getStyles"),m=a,y=r({styles:m});export{y as diagram};