@hamak/smart-data-dico 1.14.1 → 1.16.0

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 (97) hide show
  1. package/backend/dist/server.mjs +10983 -4000
  2. package/frontend/dist/assets/{abnfDiagram-VRR7QNED-70fc3d21.js → abnfDiagram-VRR7QNED-345e4d0b.js} +1 -1
  3. package/frontend/dist/assets/{arc-603e8de6.js → arc-6cdfdcfa.js} +1 -1
  4. package/frontend/dist/assets/architecture-TIHT7OUA-7e025e91.js +1 -0
  5. package/frontend/dist/assets/{architectureDiagram-ZJ3FMSHR-7423317d.js → architectureDiagram-ZJ3FMSHR-841ff116.js} +1 -1
  6. package/frontend/dist/assets/{blockDiagram-677ZJIJ3-70e39d4b.js → blockDiagram-677ZJIJ3-313b3a0f.js} +1 -1
  7. package/frontend/dist/assets/{c4Diagram-LMCZKHZV-363658e1.js → c4Diagram-LMCZKHZV-ae7b5915.js} +1 -1
  8. package/frontend/dist/assets/channel-668c2256.js +1 -0
  9. package/frontend/dist/assets/{chunk-2Q5K7J3B-3ac20838.js → chunk-2Q5K7J3B-9207ac62.js} +1 -1
  10. package/frontend/dist/assets/{chunk-32BRIVSS-5f6cd67c.js → chunk-32BRIVSS-2b813a7f.js} +1 -1
  11. package/frontend/dist/assets/{chunk-5VM5RSS4-453e1bf0.js → chunk-5VM5RSS4-e13d9c38.js} +1 -1
  12. package/frontend/dist/assets/{chunk-EX3LRPZG-5fab1640.js → chunk-EX3LRPZG-cf2858ae.js} +1 -1
  13. package/frontend/dist/assets/{chunk-JWPE2WC7-171800a5.js → chunk-JWPE2WC7-5963eae9.js} +1 -1
  14. package/frontend/dist/assets/{chunk-MOJQB5TN-b4699227.js → chunk-MOJQB5TN-8fed6f00.js} +1 -1
  15. package/frontend/dist/assets/{chunk-PUDLZKDR-714a5a96.js → chunk-PUDLZKDR-f81b8d43.js} +1 -1
  16. package/frontend/dist/assets/{chunk-RYQCIY6F-0304211a.js → chunk-RYQCIY6F-e7692d7b.js} +1 -1
  17. package/frontend/dist/assets/{chunk-V7JOEXUC-c7e3acef.js → chunk-V7JOEXUC-d0d95128.js} +1 -1
  18. package/frontend/dist/assets/{chunk-VR4S4FIN-6df67b0e.js → chunk-VR4S4FIN-9b0b88a1.js} +1 -1
  19. package/frontend/dist/assets/{chunk-XXDRQBXY-78399895.js → chunk-XXDRQBXY-ba3383f4.js} +1 -1
  20. package/frontend/dist/assets/classDiagram-OUVF2IWQ-9bbf6f54.js +1 -0
  21. package/frontend/dist/assets/classDiagram-v2-EOCWNBFH-9bbf6f54.js +1 -0
  22. package/frontend/dist/assets/{cose-bilkent-JH36ORCC-5dfb032f.js → cose-bilkent-JH36ORCC-f4424166.js} +1 -1
  23. package/frontend/dist/assets/cynefin-VYW2F7L2-dc466e04.js +1 -0
  24. package/frontend/dist/assets/{cynefinDiagram-TSTJHNR4-85050760.js → cynefinDiagram-TSTJHNR4-c7ea27ae.js} +1 -1
  25. package/frontend/dist/assets/{dagre-VKFMJZFB-b10fa223.js → dagre-VKFMJZFB-e6ba6307.js} +1 -1
  26. package/frontend/dist/assets/{diagram-FQU43EPY-a67f0419.js → diagram-FQU43EPY-3c665615.js} +1 -1
  27. package/frontend/dist/assets/{diagram-G47NLZAW-9d70f0c6.js → diagram-G47NLZAW-ba4965ff.js} +1 -1
  28. package/frontend/dist/assets/{diagram-NH7WQ7WH-ff1fb9bc.js → diagram-NH7WQ7WH-d9819f03.js} +1 -1
  29. package/frontend/dist/assets/{diagram-OA4YK3LP-9af92be3.js → diagram-OA4YK3LP-2288500e.js} +1 -1
  30. package/frontend/dist/assets/{diagram-WEI45ONY-0f05126c.js → diagram-WEI45ONY-4da00136.js} +1 -1
  31. package/frontend/dist/assets/{ebnfDiagram-CCIWWBDH-9a42df74.js → ebnfDiagram-CCIWWBDH-6721fc43.js} +1 -1
  32. package/frontend/dist/assets/{erDiagram-Q63AITRT-1a036d2c.js → erDiagram-Q63AITRT-6bc74a60.js} +1 -1
  33. package/frontend/dist/assets/eventmodeling-45OFAUF4-9f0de2b1.js +1 -0
  34. package/frontend/dist/assets/flowDiagram-23GEKE2U-832a820a.js +1 -0
  35. package/frontend/dist/assets/{ganttDiagram-NO4QXBWP-ea1e8d6a.js → ganttDiagram-NO4QXBWP-7ad7eab1.js} +1 -1
  36. package/frontend/dist/assets/gitGraph-TEB2WS4Q-4cf08115.js +1 -0
  37. package/frontend/dist/assets/{gitGraphDiagram-IHSO6WYX-1d038664.js → gitGraphDiagram-IHSO6WYX-915b2424.js} +1 -1
  38. package/frontend/dist/assets/{index-042bd23d.css → index-8f7bf650.css} +1 -1
  39. package/frontend/dist/assets/{index-67d0461e.js → index-ca784d3e.js} +133 -129
  40. package/frontend/dist/assets/info-DKCQHKI2-634496e2.js +1 -0
  41. package/frontend/dist/assets/{infoDiagram-FWYZ7A6U-a77c504b.js → infoDiagram-FWYZ7A6U-a4208f32.js} +1 -1
  42. package/frontend/dist/assets/{ishikawaDiagram-FXEZZL3T-25ad2319.js → ishikawaDiagram-FXEZZL3T-bd0ba7d8.js} +1 -1
  43. package/frontend/dist/assets/{journeyDiagram-5HDEW3XC-1326ed77.js → journeyDiagram-5HDEW3XC-3e68c993.js} +1 -1
  44. package/frontend/dist/assets/{kanban-definition-HUTT4EX6-773deb40.js → kanban-definition-HUTT4EX6-7ed911fe.js} +1 -1
  45. package/frontend/dist/assets/{linear-c6bca77a.js → linear-5d959d99.js} +1 -1
  46. package/frontend/dist/assets/{mermaid-parser.core-d7e77279.js → mermaid-parser.core-47d17681.js} +2 -2
  47. package/frontend/dist/assets/{mermaid.core-441ab06d.js → mermaid.core-da5e1357.js} +3 -3
  48. package/frontend/dist/assets/{mindmap-definition-LN4V7U3C-894fceb9.js → mindmap-definition-LN4V7U3C-e46495de.js} +1 -1
  49. package/frontend/dist/assets/packet-7NZHBO7P-69205dd0.js +1 -0
  50. package/frontend/dist/assets/{pegDiagram-2B236MQR-7d480941.js → pegDiagram-2B236MQR-7e56f05f.js} +1 -1
  51. package/frontend/dist/assets/pie-RZYD4A2V-4e4cffd5.js +1 -0
  52. package/frontend/dist/assets/{pieDiagram-ENE6RG2P-e367c012.js → pieDiagram-ENE6RG2P-a43019cb.js} +1 -1
  53. package/frontend/dist/assets/{quadrantDiagram-ABIIQ3AL-01c7204b.js → quadrantDiagram-ABIIQ3AL-62345aac.js} +1 -1
  54. package/frontend/dist/assets/radar-I7S5WNFK-8451de53.js +1 -0
  55. package/frontend/dist/assets/railroad-3IZDKUUU-35726752.js +1 -0
  56. package/frontend/dist/assets/railroad-abnf-AHOZXSZD-aeb23d40.js +1 -0
  57. package/frontend/dist/assets/railroad-ebnf-EBAXGLYW-c13df05d.js +1 -0
  58. package/frontend/dist/assets/railroad-peg-LSFZ7HO6-4194648a.js +1 -0
  59. package/frontend/dist/assets/{railroadDiagram-RFXS5EU6-514ec967.js → railroadDiagram-RFXS5EU6-58fc57a1.js} +1 -1
  60. package/frontend/dist/assets/{requirementDiagram-TGXJPOKE-4e594139.js → requirementDiagram-TGXJPOKE-86bbc2ad.js} +1 -1
  61. package/frontend/dist/assets/{sankeyDiagram-HTMAVEWB-14be14a2.js → sankeyDiagram-HTMAVEWB-a4a9fa5e.js} +1 -1
  62. package/frontend/dist/assets/{sequenceDiagram-DBY2YBRQ-a0eb53f7.js → sequenceDiagram-DBY2YBRQ-107c625d.js} +1 -1
  63. package/frontend/dist/assets/{sizeCapture-X5ZJPWSS-5730f7e3.js → sizeCapture-X5ZJPWSS-9120b239.js} +1 -1
  64. package/frontend/dist/assets/{stateDiagram-2N3HPSRC-9c66b34e.js → stateDiagram-2N3HPSRC-86d8d1b7.js} +1 -1
  65. package/frontend/dist/assets/stateDiagram-v2-6OUMAXLB-99836850.js +1 -0
  66. package/frontend/dist/assets/{swimlanes-5IMT3BWC-c6e518b2.js → swimlanes-5IMT3BWC-bf7e8552.js} +1 -1
  67. package/frontend/dist/assets/swimlanesDiagram-G3AALYLV-f1b3226d.js +8 -0
  68. package/frontend/dist/assets/{timeline-definition-FHXFAJF6-1a63b00e.js → timeline-definition-FHXFAJF6-142f766b.js} +1 -1
  69. package/frontend/dist/assets/treeView-QDETBFTQ-4c7da9ed.js +1 -0
  70. package/frontend/dist/assets/treemap-6X3UGDF4-870159d1.js +1 -0
  71. package/frontend/dist/assets/{vennDiagram-L72KCM5P-a2983d62.js → vennDiagram-L72KCM5P-592701fb.js} +1 -1
  72. package/frontend/dist/assets/wardley-OPB4EBWU-5bac06e4.js +1 -0
  73. package/frontend/dist/assets/{wardleyDiagram-EHGQE667-d7e8c3d4.js → wardleyDiagram-EHGQE667-a01b3060.js} +1 -1
  74. package/frontend/dist/assets/{xychartDiagram-FW5EYKEG-cacf6bc4.js → xychartDiagram-FW5EYKEG-e1de06fe.js} +1 -1
  75. package/frontend/dist/index.html +2 -2
  76. package/package.json +2 -2
  77. package/frontend/dist/assets/architecture-TIHT7OUA-d5d177f8.js +0 -1
  78. package/frontend/dist/assets/channel-7a5a812f.js +0 -1
  79. package/frontend/dist/assets/classDiagram-OUVF2IWQ-a02d7b45.js +0 -1
  80. package/frontend/dist/assets/classDiagram-v2-EOCWNBFH-a02d7b45.js +0 -1
  81. package/frontend/dist/assets/cynefin-VYW2F7L2-69957a6c.js +0 -1
  82. package/frontend/dist/assets/eventmodeling-45OFAUF4-bf8d119c.js +0 -1
  83. package/frontend/dist/assets/flowDiagram-23GEKE2U-6512167a.js +0 -1
  84. package/frontend/dist/assets/gitGraph-TEB2WS4Q-9ae1b586.js +0 -1
  85. package/frontend/dist/assets/info-DKCQHKI2-80cda47a.js +0 -1
  86. package/frontend/dist/assets/packet-7NZHBO7P-210a82b7.js +0 -1
  87. package/frontend/dist/assets/pie-RZYD4A2V-73eec97d.js +0 -1
  88. package/frontend/dist/assets/radar-I7S5WNFK-c5c9960b.js +0 -1
  89. package/frontend/dist/assets/railroad-3IZDKUUU-feac18dd.js +0 -1
  90. package/frontend/dist/assets/railroad-abnf-AHOZXSZD-4c0ebd35.js +0 -1
  91. package/frontend/dist/assets/railroad-ebnf-EBAXGLYW-ff768dd6.js +0 -1
  92. package/frontend/dist/assets/railroad-peg-LSFZ7HO6-1635744c.js +0 -1
  93. package/frontend/dist/assets/stateDiagram-v2-6OUMAXLB-4d44c9c9.js +0 -1
  94. package/frontend/dist/assets/swimlanesDiagram-G3AALYLV-fef29b15.js +0 -8
  95. package/frontend/dist/assets/treeView-QDETBFTQ-43fc69f6.js +0 -1
  96. package/frontend/dist/assets/treemap-6X3UGDF4-d8139088.js +0 -1
  97. package/frontend/dist/assets/wardley-OPB4EBWU-39974587.js +0 -1
@@ -1 +1 @@
1
- import{_ as Rr}from"./index-67d0461e.js";import{c as Nr}from"./chunk-RYQCIY6F-0304211a.js";import{_ as f,ar as Or,as as Br,at as Pr,au as Fr,d as kr,ah as _r,aB as Bo,ag as Dr,ai as Hr,ay as Xr,aA as Yr,G as Gr,ax as $r,aC as zr,u as ke,l as Qe,aD as Ve}from"./mermaid.core-441ab06d.js";import{G as Vr}from"./graph-7008991d.js";import"./map-338884f0.js";async function Xo(t,e){const n=new Vr({multigraph:!0,compound:!0}),o=[...e.edges],s=kr(),r=t.insert("g").attr("class","root"),i=r.insert("g").attr("class","clusters"),d=r.insert("g").attr("class","edges edgePath"),c=r.insert("g").attr("class","edgeLabels"),l=r.insert("g").attr("class","nodes"),h=new Map,m=t.node()!=null;await Promise.all(e.nodes.map(async b=>{var y;if(b.isGroup)n.setNode(b.id,{...b});else{if(m){const u=await _r(l,b,{config:s,dir:b.dir}),a=((y=u.node())==null?void 0:y.getBBox())??{width:0,height:0};h.set(b.id,u),b.width=a.width,b.height=a.height}n.setNode(b.id,{...b})}}));for(const b of o)n.setEdge(b.start,b.end,{...b},b.id),e.edges.some(u=>u.id===b.id)||e.edges.push(b);if(globalThis.mermaidCaptureSizes){const{captureNodeSizes:b}=await Rr(()=>import("./sizeCapture-X5ZJPWSS-5730f7e3.js"),["assets/sizeCapture-X5ZJPWSS-5730f7e3.js","assets/mermaid.core-441ab06d.js","assets/index-67d0461e.js","assets/index-042bd23d.css"]);b(t,e)}return{graph:n,groups:{clusters:i,edgePaths:d,edgeLabels:c,nodes:l,rootGroups:r},nodeElements:h}}f(Xo,"createGraphWithElements");var Po=5,je=1e-5,Ue=1e-6;function tn(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}f(tn,"buildSegmentList");function Yo(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=o.x-n.x,d=o.y-n.y,c=s*d-r*i;if(c===0)return null;const l=n.x-t.x,h=n.y-t.y,m=(l*d-h*i)/c,b=(l*r-h*s)/c;return m<=Ue||m>=1-Ue||b<=Ue||b>=1-Ue?null:{point:{x:t.x+m*s,y:t.y+m*r},tA:m,tB:b}}f(Yo,"segmentIntersection");function wn(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}f(wn,"isHorizontalSeg");function Go(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=tn(o.points);for(let r=n+1;r<t.length;r++){const i=t[r],d=tn(i.points);for(const[c,l]of s.entries())for(const[h,m]of d.entries()){const b=Yo(l.a,l.b,m.a,m.b);if(!b)continue;const y=wn(l),u=wn(m);(y!==u?y:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:i.id,segIndex:c,t:b.tA,point:b.point}):e.push({jumpEdgeId:i.id,otherEdgeId:o.id,segIndex:h,t:b.tB,point:b.point})}}}return e}f(Go,"findEdgeIntersections");function le(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}f(le,"fmt");function Oe(t){return`${le(t.x)},${le(t.y)}`}f(Oe,"pointToString");function $o(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}f($o,"getArcSweepFlag");var jr=.001;function zo(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&Bo[e.arrowTypeStart];if(o){const r=t[0],i=t[1],d=Math.atan2(i.y-r.y,i.x-r.x);n[0].x=r.x+o*Math.cos(d),n[0].y=r.y+o*Math.sin(d)}const s=e.arrowTypeEnd&&Bo[e.arrowTypeEnd];if(s){const r=t.length,i=t[r-2],d=t[r-1],c=Math.atan2(d.y-i.y,d.x-i.x);n[r-1].x=d.x-s*Math.cos(c),n[r-1].y=d.y-s*Math.sin(c)}return n}f(zo,"applyMarkerOffsets");function Vo(t,e,n,o,s){const r=t.point.x,i=t.point.y,d={x:r-e*t.r,y:i-n*t.r},c={x:r+e*t.r,y:i+n*t.r},l=[`L${Oe(d)}`];return s==="arc"?l.push(`A${le(t.r)},${le(t.r)} 0 0 ${o} ${Oe(c)}`):l.push(`M${Oe(c)}`),l}f(Vo,"emitJump");function An(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=n.x-e.x,d=n.y-e.y,c=Math.hypot(s,r),l=Math.hypot(i,d);if(c<je||l<je)return null;const h=s/c,m=r/c,b=i/l,y=d/l,u=h*b+m*y,a=Math.max(-1,Math.min(1,u)),p=Math.acos(a);if(p<je||Math.abs(Math.PI-p)<je)return null;const C=Math.min(o/Math.sin(p/2),c/2,l/2);return{startX:e.x-h*C,startY:e.y-m*C,endX:e.x+b*C,endY:e.y+y*C,ctrlX:e.x,ctrlY:e.y,cutLen:C}}f(An,"computeRoundedCorner");function jo(t,e,n){const o=t.points;if(o.length<2)return"";const s=zo(o,t),r=t.curve==="rounded",i=tn(s),d=new Map;for(const l of e){const h=i[l.segIndex];if(!h)continue;const m=Math.hypot(h.b.x-h.a.x,h.b.y-h.a.y),b=d.get(l.segIndex)??[];b.push({t:l.t,point:l.point,d:l.t*m,r:n.jumpRadius}),d.set(l.segIndex,b)}const c=[`M${Oe(s[0])}`];for(let l=0;l<i.length;l++){const h=i[l],m=Math.hypot(h.b.x-h.a.x,h.b.y-h.a.y),b=m===0?0:(h.b.x-h.a.x)/m,y=m===0?0:(h.b.y-h.a.y)/m,u=$o(h);let a=0;if(r&&l>0){const S=An(s[l-1],s[l],s[l+1]??s[l],Po);S&&(a=S.cutLen)}let p=m,C=null;r&&l<i.length-1&&(C=An(s[l],s[l+1],s[l+2]??s[l+1],Po),C&&(p=m-C.cutLen));const M=[...d.get(l)??[]].sort((S,A)=>S.t-A.t);for(const S of M)S.r=Math.min(S.r,S.d-a,p-S.d);for(let S=0;S<M.length-1;S++){const A=M[S+1].d-M[S].d;if(M[S].r+M[S+1].r>A){const I=A/2;M[S].r=Math.min(M[S].r,I),M[S+1].r=Math.min(M[S+1].r,I)}}for(const S of M)S.r<jr||c.push(...Vo(S,b,y,u,n.jumpStyle));r&&C?(c.push(`L${le(C.startX)},${le(C.startY)}`),c.push(`Q${le(C.ctrlX)},${le(C.ctrlY)} ${le(C.endX)},${le(C.endY)}`)):c.push(`L${Oe(h.b)}`)}return c.join(" ")}f(jo,"rewriteEdgePath");function Uo(t){return/^[\d\s+,.LMelm-]*$/.test(t)}f(Uo,"isStraightPath");function Wo(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}f(Wo,"curveSupportsLineHops");function Ko(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}f(Ko,"decodeDataPoints");function qo(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const l of e)s.set(l.id,l);const r=[],i=new Map;for(const l of e){const h=typeof CSS<"u"&&CSS.escape?CSS.escape(l.id):l.id,m=o.querySelector(`path[data-id="${h}"]`);if(!m)continue;i.set(l.id,m);const y=Ko(m.getAttribute("data-points"))??l.points;r.push({...l,points:y})}const d=Go(r);if(d.length===0)return;const c=new Map;for(const l of d){const h=c.get(l.jumpEdgeId)??[];h.push(l),c.set(l.jumpEdgeId,h)}for(const l of r){const h=c.get(l.id);if(!h||h.length===0)continue;const m=s.get(l.id),b=m==null?void 0:m.curve;if(b!==void 0&&!Wo(b))continue;const y=i.get(l.id);if(!y)continue;if(b===void 0){const S=y.getAttribute("d")??"";if(!Uo(S))continue}const u=y.getAttribute("style")??"",a=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(u),p=a?Number.parseFloat(a[1]):null,C=a?Number.parseFloat(a[2]):null,M=jo(l,h,n);if(y.setAttribute("d",M),p!==null&&C!==null&&typeof y.getTotalLength=="function"){const S=y.getTotalLength(),A=Math.max(0,S-p-C),I=`0 ${p} ${A} ${C}`,x=u.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${I};`).replace(/;\s*;+/g,";");y.setAttribute("style",x)}}}f(qo,"applyLineJumpsToSvg");async function Jo(t,e){var s,r;for(const i of t.nodes)i.isGroup?await Dr(e.clusters,i):Hr(i);const n=new Map;for(const i of t.nodes)i!=null&&i.id&&n.set(i.id,i);for(const i of t.edges){const d=i.start?n.get(i.start)??{}:{},c=i.end?n.get(i.end)??{}:{},l=Xr(e.edgePaths,{...i},{},t.type,d,c,t.diagramId);i.label&&await Yr(e.rootGroups,i),i.label&&Zo(i,l)}const o=(r=(s=t.config)==null?void 0:s.swimlane)==null?void 0:r.lineHops;if(o!==!1){const i=o==="gap"?"gap":"arc",d=t.edges.filter(c=>Array.isArray(c.points)&&c.points.length>=2).map(c=>({id:c.id,points:c.points,curve:c.curve,arrowTypeStart:c.arrowTypeStart,arrowTypeEnd:c.arrowTypeEnd}));qo(e.edgePaths,d,{enabled:!0,jumpRadius:6,jumpStyle:i})}}f(Jo,"adjustLayout");function Zo(t,e){const n=(e==null?void 0:e.updatedPath)??(e==null?void 0:e.originalPath),o=Gr(),{subGraphTitleTotalMargin:s}=$r({flowchart:o.flowchart??{}});if(t.label){const r=zr.get(t.id);let i=t.x,d=t.y;if(n){const c=ke.calcLabelPosition(n);Qe.debug("Moving label "+t.label+" from (",i,",",d,") to (",c.x,",",c.y,") abc88"),e&&(i=c.x,d=c.y)}r.attr("transform",`translate(${i}, ${d+s/2})`)}if(t!=null&&t.startLabelLeft){const r=Ve.get(t.id).startLeft;let i=t==null?void 0:t.x,d=t==null?void 0:t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_left",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}if(t.startLabelRight){const r=Ve.get(t.id).startRight;let i=t.x,d=t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_right",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}if(t.endLabelLeft){const r=Ve.get(t.id).endLeft;let i=t.x,d=t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_left",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}if(t.endLabelRight){const r=Ve.get(t.id).endRight;let i=t.x,d=t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_right",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}}f(Zo,"positionEdgeLabel");var vn="__swimlane_default__",Ur=21,Fo=20;function Rn(t){return Math.max(t.padding??Fo,Fo)}f(Rn,"topLaneHorizontalPadding");function Qo(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 i=n-s/2,d=Math.min(r,n+s/2),c=Math.min(Ur,Math.max(0,d-i)),l=i+c;if(l<=i){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:i,bottom:l}}f(Qo,"assignTopLaneTitleRect");function ts(t){const e=t.direction,n=t.nodes??(t.nodes=[]);for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===vn);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:vn,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=vn}f(ts,"prepareLayoutForSwimlanes");function es(t){const e=new Map;for(const c of t.nodes??[])e.set(c.id,c);const n=[];for(const c of t.edges??[]){const l=typeof c.start=="string"?c.start:void 0,h=typeof c.end=="string"?c.end:void 0;!l||!h||c.labelNodeId||n.push({id:c.id,src:l,dst:h,ref:c})}const o=t.nodes??[],s=o.filter(c=>c.isGroup),r=o.filter(c=>!c.isGroup);return{nodes:[...[...s].reverse(),...r].map(c=>c.id),edges:n,layout:t,nodeById:e}}f(es,"toGraphView");function ns(t,e,n,o){const{layout:s}=t,r=t.nodeById,i=(o==null?void 0:o.layerGap)??100,d=(o==null?void 0:o.nodeGap)??40;let c=0;for(const b of e.layers){let y=0;for(const u of b){const a=r.get(u);if(!a){y++;continue}a.layer=c,a.order=y;const p=n.x[u]??y*d,C=n.y[u]??c*i;a.x=p,a.y=C,y++}c++}const l=s.nodes??[],h=new Map,m=[];for(const b of l){if(!(b!=null&&b.isGroup))continue;b.parentId||m.push(b);const y=l.filter(M=>M.parentId===b.id);let u=1/0,a=-1/0,p=1/0,C=-1/0;for(const M of y){const S=M.x??n.x[M.id],A=M.y??n.y[M.id],I=M.width??0,x=M.height??0;S!=null&&A!=null&&(u=Math.min(u,S-I/2),a=Math.max(a,S+I/2),p=Math.min(p,A-x/2),C=Math.max(C,A+x/2))}if(u===1/0||p===1/0)b.x=b.x??0,b.y=b.y??0,b.width=b.width??0,b.height=b.height??0;else{const M=b.padding??20,S=b.parentId?M:2*Rn(b),A=M,I=Math.max(0,a-u)+S,x=Math.max(0,C-p)+A,L=(u+a)/2,R=(p+C)/2;b.x=L,b.y=R,b.width=I,b.height=x,h.set(b.id,{minX:u,maxX:a,minY:p,maxY:C})}}if(m.length>0&&h.size>0){let b=1/0,y=-1/0,u=0;for(const a of m){const p=a.padding??20;p>u&&(u=p);const C=h.get(a.id);C&&(b=Math.min(b,C.minY),y=Math.max(y,C.maxY))}if(b!==1/0&&y!==-1/0){const a=Math.max(0,y-b),C=Math.max(u,36),M=a+2*C,S=(b+y)/2;for(const P of m)P.y=S,P.height=M,P.swimlaneContentTop=b;const A=[...m].sort((P,w)=>{const F=P.x??0,k=w.x??0;return F-k}),I=[],x=[],L=[];for(const P of A){const w=h.get(P.id);if(!w)continue;const F=Math.max(0,w.maxX-w.minX)+2*Rn(P),k=(w.minX+w.maxX)/2;I.push(P.id),x.push(k),L.push(F)}const R=I.length;if(R>0){const P=new Map;if(R===1)P.set(I[0],L[0]);else{const w=[];for(let G=0;G<R-1;G++)w.push(x[G+1]-x[G]);const F=new Array(R);F[0]=0;for(let G=0;G<R-1;G++)F[G+1]=2*w[G]-F[G];let k=0,B=Number.POSITIVE_INFINITY;for(let G=0;G<R;G++){const Z=L[G];G%2===0?k=Math.max(k,Z-F[G]):B=Math.min(B,F[G]-Z)}let X=k;k<=B?X=(k+B)/2:X=k;for(let G=0;G<R;G++){const Z=F[G]+(G%2===0?X:-X),ct=Math.max(L[G],Z);P.set(I[G],ct)}}for(const w of m){const F=P.get(w.id);F!=null&&(w.width=F),Qo(w)}}}}}f(ns,"writeBackToLayoutData");var Wr="[EdgeLabelNodes]";function os(t){const e=[],n=[],o=new Map;for(const i of t.nodes)o.set(i.id,i);for(const i of t.edges){if(!i.label||i.label.length===0||i.isLayoutOnly||i.labelNodeId)continue;const d=i.start?o.get(i.start):void 0,c=i.end?o.get(i.end):void 0;if(!d||!c){Qe.warn(Wr,`Edge ${i.id} has missing source or target node`);continue}const l=`edge-label-${i.start}-${i.end}-${i.id}`,m=d.parentId!==c.parentId?c.parentId:d.parentId,b={id:l,label:i.label,edgeStart:i.start??"",edgeEnd:i.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:m,isGroup:!1,labelStyle:Array.isArray(i.labelStyle)?i.labelStyle[0]:i.labelStyle??"",...d.dir?{dir:d.dir}:{}};e.push(b),i.labelNodeId=l,i.label=void 0,i.text=void 0;const y={id:`${i.id}-to-label`,start:i.start,end:l,type:"normal",isLayoutOnly:!0},u={id:`${i.id}-from-label`,start:l,end:i.end,type:"normal",isLayoutOnly:!0};n.push(y,u)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}f(os,"createEdgeLabelNodes");var Yt=.001;function co(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:Be(e,n,o,s)}:void 0}f(co,"measuredNodeRect");function ao(t){if(t.isGroup)return;const e=co(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}f(ao,"nodeBoundsInfoFor");function ce(t,e,n=Yt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}f(ce,"samePoint");function gt(t,e,n=Yt){return Math.abs(t.x-e.x)<n}f(gt,"sameX");function yt(t,e,n=Yt){return Math.abs(t.y-e.y)<n}f(yt,"sameY");function Nt(t,e,n=Yt){return yt(t,e,n)&&Math.abs(t.x-e.x)>n}f(Nt,"isHorizontalSegment");function Ot(t,e,n=Yt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}f(Ot,"isVerticalSegment");function Wt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}f(Wt,"overlapLength");function de(t,e,n=Yt){return t.horizontal&&e.horizontal&&yt(t.a,e.a,n)?Wt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&gt(t.a,e.a,n)?Wt(t.a.y,t.b.y,e.a.y,e.b.y):0}f(de,"sameAxisSegmentOverlapLength");function Pe(t,e=Yt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],i=Nt(s,r,e),d=Ot(s,r,e);(i||d)&&n.push({index:o,a:s,b:r,horizontal:i,vertical:d})}return n}f(Pe,"orthogonalSegmentsForPoints");function oe(t,e=Yt){const n=Pe(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}f(oe,"countOrthogonalBends");function xt(t,e=Yt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ce(s,o,e))&&n.push({x:o.x,y:o.y})}return n}f(xt,"dedupeConsecutivePoints");function lo(t,e=Yt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Nt(n,o,e)&&Ot(o,s,e)&&Nt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&Nt(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}f(lo,"classifyThreeSegmentRoute");function dn(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),i=Math.min(t.y,e.y),d=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&d>n.top-o&&i<n.bottom+o}f(dn,"segmentBoundsOverlapRect");function fo(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}f(fo,"pointInsideRect");function ss(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}f(ss,"rectContainsRect");function en(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}f(en,"rectsOverlap");function Nn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}f(Nn,"inflateRect");function Be(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}f(Be,"rectFromCenterSize");function te(t){var e;return(e=co(t))==null?void 0:e.rect}f(te,"rectOfNodeBounds");function Le(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}f(Le,"portForRectSide");function uo(t,e,n,o,s,r=Yt){const i=e==="left"||e==="right",d=o==="left"||o==="right";if(i&&d){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(yt(t,n,r))return[t,n];const m=(t.x+n.x)/2;return[t,{x:m,y:t.y},{x:m,y:n.y},n]}if(e===o){if(yt(t,n,r))return;const m=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:m,y:t.y},{x:m,y:n.y},n]}return}if(!i&&!d){if(e===o){if(gt(t,n,r))return;const b=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:b},{x:n.x,y:b},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const m=(t.y+n.y)/2;return[t,{x:t.x,y:m},{x:n.x,y:m},n]}if(i&&!d){const h=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,m=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return h&&m?[t,{x:n.x,y:t.y},n]:void 0}const c=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,l=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return c&&l?[t,{x:t.x,y:n.y},n]:void 0}f(uo,"buildOrthogonalPortPath");function ho(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}f(ho,"buildSameSideTrackPath");function un(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=ao(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}f(un,"collectRealNodeBounds");function Me(t){const e=[],n=[];for(const o of t){const s=ao(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}f(Me,"collectNodeRectEntries");function rs(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,i=o.width??0,d=o.height??0;n.push({nodeId:o.id,...Be(s,r,i,d)})}return n}f(rs,"collectLayoutNodeRects");function go(t,e,n=Yt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),i=e.get(s);if(!(!r||!i))return{srcId:o,dstId:s,srcInfo:r,dstInfo:i,collinearX:Math.abs(r.cx-i.cx)<n,collinearY:Math.abs(r.cy-i.cy)<n}}f(go,"getNodePairGeometry");function Bt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&dn(t,e,r.rect,-s))return!0;return!1}f(Bt,"segmentHitsAnyRect");function mo(t,e,n,o,s=Yt,r=1e-6){const i=yt(t,e,s),d=gt(t,e,s),c=yt(n,o,s),l=gt(n,o,s);if(i&&c||d&&l||!(i||d)||!(c||l))return!1;const h=i?{a:t,b:e}:{a:n,b:o},m=d?{a:t,b:e}:{a:n,b:o},b=h.a.y,y=Math.min(h.a.x,h.b.x),u=Math.max(h.a.x,h.b.x),a=m.a.x,p=Math.min(m.a.y,m.b.y),C=Math.max(m.a.y,m.b.y);if(a<y||a>u||b<p||b>C)return!1;const M=Math.abs(a-h.a.x)<r&&Math.abs(b-h.a.y)<r||Math.abs(a-h.b.x)<r&&Math.abs(b-h.b.y)<r,S=Math.abs(a-m.a.x)<r&&Math.abs(b-m.a.y)<r||Math.abs(a-m.b.x)<r&&Math.abs(b-m.b.y)<r;return!(M&&S)}f(mo,"orthogonalSegmentsCross");function is(t,e,n,o,s=Yt){const r=yt(t,e,s),i=gt(t,e,s),d=yt(n,o,s),c=gt(n,o,s);return i&&c&&gt(t,n,s)?Wt(t.y,e.y,n.y,o.y)>s:r&&d&&yt(t,n,s)?Wt(t.x,e.x,n.x,o.x)>s:!1}f(is,"sameAxisSegmentsOverlap");function nn(t,e,n,o,{epsilon:s=Yt,skipDegenerateOther:r=!1}={}){for(const i of n){if(i===o||i.isLayoutOnly)continue;const d=i.points;if(!(!d||d.length<2))for(let c=0;c<d.length-1;c++){const l=d[c],h=d[c+1];if(!(r&&ce(l,h,s))&&(mo(t,e,l,h,s)||is(t,e,l,h,s)))return!0}}return!1}f(nn,"segmentConflictsWithAnyEdge");function he(t,e,n,o,s=Yt){const r=yt(t,e,s),i=gt(t,e,s),d=yt(n,o,s),c=gt(n,o,s);if(!(r&&c||i&&d))return!1;const l=r?{a:t,b:e}:{a:n,b:o},h=r?{a:n,b:o}:{a:t,b:e},m=l.a.y,b=Math.min(l.a.x,l.b.x),y=Math.max(l.a.x,l.b.x),u=h.a.x,a=Math.min(h.a.y,h.b.y),p=Math.max(h.a.y,h.b.y);return u>b+s&&u<y-s&&m>a+s&&m<p-s}f(he,"orthogonalSegmentsStrictlyCross");function On(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Yt&&t<s-Yt}f(On,"strictlyBetween");function cs(t,e,n){return gt(t,e)&&gt(e,n)?On(e.y,t.y,n.y):yt(t,e)&&yt(e,n)?On(e.x,t.x,n.x):!1}f(cs,"isCollinearIntermediate");function as(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],i=o+1<t.length?t[o+1]:void 0;if(s&&i){if(ce(s,i)){o++,e=!0;continue}if(cs(s,r,i)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}f(as,"simplifyPolylineOnce");function on(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!yt(s,r)){const i=e.length>=2?e[e.length-2]:void 0,c=(i?gt(i,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(c)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ce(s,o))&&n.push(o)}return n}f(on,"orthogonalizePolyline");function ue(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=as(e);if(e=o.points,!o.changed)break}return e}f(ue,"simplifyPolyline");var it=.001,Kr=.5,ko=4;function yo(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?te(s):void 0,dstRect:r?te(r):void 0}}f(yo,"endpointContextFor");function ls(t,e,n){if(yt(t,e,it))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,it)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}f(ls,"segmentEnterPoint");function Bn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&fo(t[s],e,Kr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const i=ls(t[s],t[r],e);return n?[i,...t.slice(s)]:[...t.slice(0,s+1),i]}f(Bn,"clipEndpoint");function fs(t,e){for(const n of t){const o=yo(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Bn(s,o.srcRect,!0)),o.dstRect&&(s=Bn(s,o.dstRect,!1)),s=ue(on(s)),s=po(s,o.srcRect,o.dstRect),o.edge.points=ue(on(s))}}f(fs,"clipEdgeEndpointsToNodeBoundaries");function Pn(t,e,n,o=!1){if(yt(t,e,it)){if(e.y<n.top-it||e.y>n.bottom+it)return e;if(o){if(t.x<n.left-it)return{x:n.left,y:t.y};if(t.x>n.right+it)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,it)){if(e.x<n.left-it||e.x>n.right+it)return e;if(o){if(t.y<n.top-it)return{x:t.x,y:n.top};if(t.y>n.bottom+it)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}f(Pn,"snapEndpointToBoundary");function sn(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ce(r,o,it))return r}return t[e+n]}f(sn,"firstDistinctAdjacent");function rn(t,e){const n=t+ko,o=e-ko;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}f(rn,"cornerClearanceRange");function Fn(t,e,n){const{lo:o,hi:s}=rn(e,n);return Math.min(s,Math.max(o,t))}f(Fn,"clampToCornerClearance");function ds(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}f(ds,"intersectRanges");function kn(t,e){return e==="left"||e==="right"?rn(t.top,t.bottom):rn(t.left,t.right)}f(kn,"clearanceRangeForSide");function cn(t,e,n){const o=t.y>=n.top-it&&t.y<=n.bottom+it,s=t.x>=n.left-it&&t.x<=n.right+it;if(yt(t,e,it)&&o){if(Math.abs(t.x-n.left)<it)return"left";if(Math.abs(t.x-n.right)<it)return"right"}if(gt(t,e,it)&&s){if(Math.abs(t.y-n.top)<it)return"top";if(Math.abs(t.y-n.bottom)<it)return"bottom"}}f(cn,"terminalSideForSegment");function _e(t){return t==="left"||t==="right"}f(_e,"isHorizontalSide");function us(t,e,n,o,s){const r=[],i=n?cn(t,e,n):void 0,d=o?cn(e,t,o):void 0;return n&&i&&_e(i)===s&&r.push(kn(n,i)),o&&d&&_e(d)===s&&r.push(kn(o,d)),r.length>0?ds(r):void 0}f(us,"straightClearanceRange");function _n(t,e,n,o,s){const r=us(t,e,n,o,s);if(!r)return;const i=s?t.y:t.x,d=Math.min(r.hi,Math.max(r.lo,i));if(!(Math.abs(d-i)<it))return s?[{x:t.x,y:d},{x:e.x,y:d}]:[{x:d,y:t.y},{x:d,y:e.y}]}f(_n,"clearStraightEndpointCornerAxis");function po(t,e,n){if(t.length!==2)return t;const[o,s]=t;return yt(o,s,it)?_n(o,s,e,n,!0)??t:gt(o,s,it)?_n(o,s,e,n,!1)??t:t}f(po,"clearStraightEndpointCornerConnections");function hs(t,e,n){return _e(n)?{x:t.x,y:Fn(t.y,e.top,e.bottom)}:{x:Fn(t.x,e.left,e.right),y:t.y}}f(hs,"cornerClearedEndpoint");function gs(t,e,n,o,s,r){const i=t.map(d=>({...d}));for(let d=e;d>=0&&d<t.length;d+=n){const c=t[d];if(r&&!yt(c,o,it)||!r&&!gt(c,o,it))break;r?i[d].y=s.y:i[d].x=s.x}return i}f(gs,"moveCollinearEndpointRun");function Dn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],i=sn(t,o,s);if(!i)return t;const d=cn(r,i,e);if(!d)return t;const c=_e(d),l=hs(r,e,d);return ce(r,l,it)?t:gs(t,o,s,r,l,c)}f(Dn,"clearEndpointCornerConnection");function Hn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-it&&Math.max(t.x,e.x)<=n.right+it,s=Math.min(t.y,e.y)>=n.top-it&&Math.max(t.y,e.y)<=n.bottom+it;if(Math.abs(t.y-n.top)<it&&Math.abs(e.y-n.top)<it&&o)return"top";if(Math.abs(t.y-n.bottom)<it&&Math.abs(e.y-n.bottom)<it&&o)return"bottom";if(Math.abs(t.x-n.left)<it&&Math.abs(e.x-n.left)<it&&s)return"left";if(Math.abs(t.x-n.right)<it&&Math.abs(e.x-n.right)<it&&s)return"right"}f(Hn,"borderSideForSegment");function Xn(t,e,n,o){switch(t){case"top":return gt(e,n,it)&&n.y<o.top-it;case"bottom":return gt(e,n,it)&&n.y>o.bottom+it;case"left":return yt(e,n,it)&&n.x<o.left-it;case"right":return yt(e,n,it)&&n.x>o.right+it}}f(Xn,"leavesOutward");function Yn(t,e,n){if(t.length<3)return t;if(n){const r=Hn(t[0],t[1],e);return r&&Xn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Hn(t[o-1],t[o],e);return s&&Xn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}f(Yn,"collapseOwnBorderStub");function ms(t,e,n){let o=t;if(e){const r=sn(o,0,1);if(r){const i=Pn(r,o[0],e);i!==o[0]&&(o=[i,...o.slice(1)])}o=Yn(o,e,!0)}if(n){const r=o.length-1,i=sn(o,r,-1);if(i){const d=Pn(i,o[r],n,!0);d!==o[r]&&(o=[...o.slice(0,r),d])}o=Yn(o,n,!1)}const s=po(o,e,n);return s!==o||o.length===2?s:(e&&(o=Dn(o,e,!0)),n&&(o=Dn(o,n,!1)),o)}f(ms,"snapAndCollapseEndpoints");function Gn(t,e){for(const n of t){const o=yo(n,e,2);if(!o)continue;const s=xt(o.points,it),r=ms(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const i=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=i}}f(Gn,"prepareEdgeEndpointsForRenderer");function xo(t){return new Map(t.map(e=>[e.id,e]))}f(xo,"buildNodeMap");function ys(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}f(ys,"resolveTopLevelGroupId");function $n(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}f($n,"groupDepth");function bo(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const i=r.x,d=r.y;if(typeof i!="number"||typeof d!="number")continue;const c=r.width??0,l=r.height??0;e=Math.min(e,i-c/2),n=Math.max(n,i+c/2),o=Math.min(o,d-l/2),s=Math.max(s,d+l/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}f(bo,"boundsForChildren");function ps(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}f(ps,"applyGroupBounds");function xs(t){const e=xo(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>$n(s,e)-$n(o,e));for(const o of n){const s=t.filter(i=>i.parentId===o.id),r=bo(s);r&&ps(o,r)}}f(xs,"recomputeNestedGroupBounds");function an(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(c=>!c.isGroup);let r=1/0,i=-1/0;for(const c of s){const l=c[e];typeof l=="number"&&(r=Math.min(r,l),i=Math.max(i,l))}if(!Number.isFinite(r)||!Number.isFinite(i))return!1;const d=f(c=>r+i-c,"mirror");for(const c of n){const l=c[e];typeof l=="number"&&(c[e]=d(l));const h=c.groupTitleRect;h&&(c.groupTitleRect=e==="x"?{...h,left:d(h.right),right:d(h.left)}:{...h,top:d(h.bottom),bottom:d(h.top)})}for(const c of o)for(const l of c.points??[])l[e]=d(l[e]);return!0}f(an,"mirrorAxis");function bs(t){return(t.nodes??[]).some(n=>!n.isGroup)?an(t,"y"):!0}f(bs,"applyBtDirectionTransform");function Ms(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(B=>!B.isGroup);let r=1/0,i=1/0;for(const B of s){const X=B.x??0,G=B.y??0;X<r&&(r=X),G<i&&(i=G)}if(!Number.isFinite(r)||!Number.isFinite(i))return!1;const d=36;let c=0,l=0;for(const B of s)c+=B.width??0,l+=B.height??0;const h=c/s.length,m=l/s.length,b=m>0?Math.max(1,h/m):1;for(const B of s){const X=B.x??0,Z=((B.y??0)-i)*b+d,ct=X-r;B.x=Z,B.y=ct}for(const B of o)if(B.points)for(const X of B.points){const G=X.x,ct=(X.y-i)*b+d,Mt=G-r;X.x=ct,X.y=Mt}xs(n);const y=n.filter(B=>B.isGroup&&!B.parentId);if(y.length===0)return e==="RL"&&an(t,"x"),!0;const u=xo(n),a=new Map;for(const B of n){if(B.isGroup)continue;const X=ys(B,u);if(!X)continue;const G=a.get(X)??[];G.push(B),a.set(X,G)}let p=0;for(const B of y){const X=B.padding??0;X>p&&(p=X)}const C=[];let M=1/0,S=-1/0;for(const B of y){const X=a.get(B.id)??[],G=bo(X);G&&(M=Math.min(M,G.minX),S=Math.max(S,G.maxX),C.push({lane:B,contentTop:G.minY,contentBottom:G.maxY,centerY:(G.minY+G.maxY)/2}))}if(M===1/0||S===-1/0)return!0;const A=Math.max(0,S-M),I=Math.max(p,10),x=A+2*I,L=d+x,w=(M+S)/2-x/2-d,F=w+L/2,k=Math.max(p,d);C.sort((B,X)=>B.centerY-X.centerY);for(let B=0;B<C.length;B++){const X=C[B];let G,Z;if(B===0?G=X.contentTop-k:G=(C[B-1].contentBottom+X.contentTop)/2,B===C.length-1)Z=X.contentBottom+k;else{const Pt=C[B+1];Z=(X.contentBottom+Pt.contentTop)/2}const ct=Math.max(0,Z-G),Mt=(G+Z)/2;X.lane.x=F,X.lane.y=Mt,X.lane.width=L,X.lane.height=ct,X.lane.swimlaneContentTop=X.contentTop,X.lane.groupTitleRect={left:w,right:w+d,top:G,bottom:Z}}return e==="RL"&&an(t,"x"),!0}f(Ms,"applyLrDirectionTransform");var ae=1e-6,qr=8,We=qr,Jr=[0,We,-We,2*We,-2*We];function Is(t,e){const{nodeInfoById:n,realNodeRects:o}=un(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const i=lo(xt(r,ae),ae);if(!i)continue;const{p3:d}=i,c=i.kind==="HVH",l=go(s,n,ae);if(!l)continue;const{srcId:h,dstId:m,srcInfo:b,dstInfo:y,collinearX:u,collinearY:a}=l;if(u||a)continue;let p;const C=b.rect;for(const M of Jr){let S,A,I;if(c){const F=y.cy>b.cy?C.bottom:C.top,k=b.cx+M;if(k<=C.left+ae||k>=C.right-ae)continue;S={x:k,y:F},A={x:k,y:d.y},I={x:d.x,y:d.y}}else{const F=y.cx>b.cx?C.right:C.left,k=b.cy+M;if(k<=C.top+ae||k>=C.bottom-ae)continue;S={x:F,y:k},A={x:d.x,y:k},I={x:d.x,y:d.y}}const x=ce(S,A,ae),L=ce(A,I,ae);if(x&&L||!x&&Bt(S,A,o,[h],1)||!L&&Bt(A,I,o,[m],1))continue;const R=!x&&nn(S,A,t,s,{epsilon:ae,skipDegenerateOther:!0}),P=!L&&nn(A,I,t,s,{epsilon:ae,skipDegenerateOther:!0});if(!(R||P)){x?p=[A,I]:L?p=[S,A]:p=[S,A,I];break}}p&&(s.points=p)}}f(Is,"portSwapToLShape");function Ss(t,e){const{realNodeRects:r,labelNodeRects:i}=Me(e.values());for(const d of t){if(d.isLayoutOnly)continue;const c=d.points;if(!c||c.length<4)continue;const l=xt(c,.001);if(l.length<4)continue;const h=l.length-1,m=l[h],b=l[h-1],y=l[h-2],u=m.x-b.x,a=m.y-b.y,p=Math.hypot(u,a);if(p>=10||p<.001)continue;const C=b.x-y.x,M=b.y-y.y;if(Math.hypot(C,M)<.001)continue;const A=Nt(b,m,.001),I=Ot(b,m,.001),x=Nt(y,b,.001),L=Ot(y,b,.001);if(!(A&&L||I&&x))continue;const R=d.end,P=d.start,w=R?e.get(R):void 0;if(!w)continue;const F=w.x??0,k=w.y??0,B=te(w);if(!B)continue;let X,G;if(L){const J=M<0;X={x:F,y:y.y},G={x:F,y:J?B.bottom:B.top}}else{const J=C>0;X={x:y.x,y:k},G={x:J?B.right:B.left,y:k}}if(Bt(X,G,r,R?[R]:[],-2)||Bt(X,G,i,[],-2))continue;if(P){const J=e.get(P),rt=J?te(J):void 0;if(rt&&fo(X,rt,2))continue}const Z=f((J,rt)=>`${J.x.toFixed(3)},${J.y.toFixed(3)}|${rt.x.toFixed(3)},${rt.y.toFixed(3)}`,"ownSegmentKey"),ct=new Set;for(let J=0;J<l.length-1;J++)ct.add(Z(l[J],l[J+1]));const Mt=f((J,rt)=>{for(const ut of t){if(ut===d||ut.isLayoutOnly)continue;const pt=ut.points;if(!(!pt||pt.length<2))for(let St=0;St<pt.length-1;St++){const wt=pt[St],Kt=pt[St+1];if(!ct.has(Z(wt,Kt))&&he(J,rt,wt,Kt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(Mt(X,G))continue;if(h-3>=0){const J=l[h-3],rt=[P,R].filter(ut=>!!ut);if(Bt(J,X,r,rt,-2)||Mt(J,X))continue}const Dt=[...l.slice(0,h-2),X,G];d.points=Dt;const nt=d.labelNodeId;if(nt){const J=e.get(nt);if(J){const rt=J.width??0,ut=J.height??0;if(rt>0&&ut>0){let pt,St,wt=-1;for(let Kt=0;Kt<Dt.length-1;Kt++){const qt=Dt[Kt],Jt=Dt[Kt+1],se=Math.hypot(Jt.x-qt.x,Jt.y-qt.y),Ee=yt(qt,Jt,.001),me=gt(qt,Jt,.001);(Ee&&se>=rt+2||me&&se>=ut+2)&&se>wt&&(wt=se,pt=(qt.x+Jt.x)/2,St=(qt.y+Jt.y)/2)}pt!==void 0&&St!==void 0&&(J.x=pt,J.y=St)}}}}}f(Ss,"collapseShortTerminalStub");var et=.001,Xt=8,lt=Pe,Ln=f((t,e)=>gt(t,e,et)||yt(t,e,et),"orthogonallyAligned");function Cs(t,e){const s=f((y,u)=>{const a=y.x??0,p=y.y??0,C=u.x-a,M=u.y-p;let S=(y.width??0)/2,A=(y.height??0)/2;return Math.abs(M)*S>Math.abs(C)*A?(M<0&&(A=-A),{x:a+(M===0?0:A*C/M),y:p+A}):(C<0&&(S=-S),{x:a+S,y:p+(C===0?0:S*M/C)})},"rectIntersect"),r=f((y,u)=>{const a=xt(y.points??[]);if(a.length<2)return;const p=u?y.start:y.end,C=p?e.get(p):void 0,M=C?te(C):void 0;if(!C||!p||!M)return;const S=u?a[0]:a[a.length-1],A=u?a[1]:a[a.length-2],I=s(C,S);let x=S;if(Ln(A,I)&&(x=A),gt(I,x,et))return{edge:y,edgeId:String(y.id??""),nodeId:p,atStart:u,orientation:"V",coord:I.x,min:Math.min(I.y,x.y),max:Math.max(I.y,x.y),boundary:I,railEnd:x,rect:M};if(yt(I,x,et))return{edge:y,edgeId:String(y.id??""),nodeId:p,atStart:u,orientation:"H",coord:I.y,min:Math.min(I.x,x.x),max:Math.max(I.x,x.x),boundary:I,railEnd:x,rect:M}},"terminalLaneFor"),i=f((y,u)=>Math.max(0,Math.min(y.max,u.max)-Math.max(y.min,u.min)),"projectedOverlapLength"),d=f((y,u)=>y.nodeId!==u.nodeId||y.orientation!==u.orientation?!1:y.orientation==="H"?(Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1)&&gt(y.boundary,u.boundary,1):(Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1)&&yt(y.boundary,u.boundary,1),"sameTerminalFace"),c=f((y,u)=>y.nodeId!==u.nodeId||y.orientation!==u.orientation?!1:i(y,u)>=Xt&&Math.abs(y.coord-u.coord)<.5,"exactTerminalLaneConflict"),l=f((y,u)=>{if(y.nodeId!==u.nodeId||y.orientation!==u.orientation||y.orientation!=="H"||y.atStart===u.atStart)return!1;const a=i(y,u);if(a<Xt)return!1;const p=y.rect.bottom-y.rect.top;return a<p||a>2*p?!1:d(y,u)&&Math.abs(y.coord-u.coord)<16},"nearTerminalLaneConflict"),h=f((y,u)=>{const a=xt(y.edge.points??[]);if(a.length<2)return;const p=y.orientation==="V"?{x:y.boundary.x+u,y:y.boundary.y}:{x:y.boundary.x,y:y.boundary.y+u},C=y.orientation==="V"?{x:y.railEnd.x+u,y:y.railEnd.y}:{x:y.railEnd.x,y:y.railEnd.y+u};if(!f(()=>Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1?yt(p,y.boundary,et)&&p.x>=y.rect.left+1&&p.x<=y.rect.right-1:Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1?gt(p,y.boundary,et)&&p.y>=y.rect.top+1&&p.y<=y.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(y.atStart){const x=a.length>1&&ce(a[1],y.railEnd,et),L=a.slice(x?2:1),R=L[0];return R&&!Ln(R,C)?void 0:[p,C,...L]}const S=a.length>1&&ce(a[a.length-2],y.railEnd,et),A=a.slice(0,S?-2:-1),I=A[A.length-1];if(!(I&&!Ln(I,C)))return[...A,C,p]},"shiftedCandidate"),m=f(y=>{const u=y.edge,a=xt(u.points??[]);if(a.length!==2)return!1;const p=u.start,C=u.end,M=p?e.get(p):void 0,S=C?e.get(C):void 0;if(!M||!S)return!1;const A=M.x??0,I=M.y??0,x=S.x??0,L=S.y??0,[R,P]=a;return yt(R,P,et)&&Math.abs(I-L)<1&&Math.abs(A-x)>1||gt(R,P,et)&&Math.abs(A-x)<1&&Math.abs(I-L)>1},"laneIsStraightCollinearConnector"),b=[-7,7,-2*7,2*7,-3*7,3*7];for(let y=0;y<8;y++){const u=t.filter(p=>!p.isLayoutOnly).flatMap(p=>[r(p,!0),r(p,!1)]).filter(p=>!!p);let a=!1;for(let p=0;p<u.length&&!a;p++)for(let C=p+1;C<u.length&&!a;C++){const M=u[p],S=u[C];if(M.edge===S.edge||!(c(M,S)||l(M,S)))continue;const A=!c(M,S),I=[M,S].sort((x,L)=>{const R=m(x),P=m(L);return R!==P?Number(R)-Number(P):+!L.atStart-+!x.atStart});for(const x of I){for(const L of b){const R=h(x,L);if(!R)continue;const P=r({...x.edge,points:R},x.atStart);if(!(!P||u.some(w=>w.edge!==x.edge&&(c(P,w)||A&&l(P,w))))){x.edge.points=R,a=!0;break}}if(a)break}}if(!a)return}}f(Cs,"separateSharedRenderedTerminalLanes");function vs(t,e){const{realNodeRects:s,labelNodeRects:r}=Me(e.values()),i=f((c,l)=>{const h=c.start,m=c.end,b=lt(l);if(b.length!==l.length-1)return!1;const y=[h,m].filter(u=>!!u);for(const u of b)if(Bt(u.a,u.b,s,y,-2)||Bt(u.a,u.b,r,[],-2))return!1;for(const u of t){if(u===c||u.isLayoutOnly)continue;const a=u.points;if(!(!a||a.length<2)){for(const p of b)for(const C of lt(xt(a)))if(de(p,C,.5)>=Xt||he(p.a,p.b,C.a,C.b,et))return!1}}return!0},"candidateIsSafe"),d=f((c,l)=>{if(l+4>=c.length)return;const h=c[l],m=c[l+1],b=c[l+2],y=c[l+3],u=c[l+4],a=Nt(h,m)&&Ot(m,b)&&Nt(b,y)&&Ot(y,u)&&gt(h,y,et)&&gt(h,u,et)&&gt(m,b,et)&&(m.x-h.x)*(y.x-b.x)<0,p=Ot(h,m)&&Nt(m,b)&&Ot(b,y)&&Nt(y,u)&&yt(h,y,et)&&yt(h,u,et)&&yt(m,b,et)&&(m.y-h.y)*(y.y-b.y)<0;if(a||p)return xt([...c.slice(0,l+1),u,...c.slice(l+5)]);if(l+5>=c.length)return;const C=c[l+5],M=Ot(h,m)&&Nt(m,b)&&Ot(b,y)&&Nt(y,u)&&Ot(u,C)&&gt(h,u,et)&&gt(h,C,et)&&gt(b,y,et)&&(b.x-m.x)*(u.x-y.x)<0,S=Nt(h,m)&&Ot(m,b)&&Nt(b,y)&&Ot(y,u)&&Nt(u,C)&&yt(h,u,et)&&yt(h,C,et)&&yt(b,y,et)&&(b.y-m.y)*(u.y-y.y)<0;if(!(!M&&!S))return xt([...c.slice(0,l+1),C,...c.slice(l+6)])},"withoutDogleg");for(let c=0;c<8;c++){let l=!1;for(const h of t){if(h.isLayoutOnly)continue;const m=xt(h.points??[]);for(let b=0;b<=m.length-5;b++){const y=d(m,b);if(!(!y||!i(h,y))){h.points=y,l=!0;break}}if(l)break}if(!l)return}}f(vs,"collapseRedundantRectangularDoglegs");function zn(t,e){const{realNodeRects:r,labelNodeRects:i}=Me(e.values()),d=t.filter(u=>!u.isLayoutOnly),c=f((u,a,p)=>xt(u===a?p??[]:u.points??[]),"pointsFor"),l=f((u,a)=>{let p=0;for(let C=0;C<d.length;C++){const M=lt(c(d[C],u,a));for(let S=C+1;S<d.length;S++){const A=lt(c(d[S],u,a));for(const I of M)for(const x of A)he(I.a,I.b,x.a,x.b,et)&&p++}}return p},"strictCrossingCount"),h=f(u=>{const a=lt(u);if(a.length!==3)return;const p=a[1];if(!(a[0].horizontal===p.horizontal||a[2].horizontal===p.horizontal))return{index:p.index,horizontal:p.horizontal,vertical:p.vertical,segment:p}},"middleRail"),m=f((u,a)=>{const p=[u.start,u.end].filter(C=>!!C);return r.filter(C=>{if(p.includes(C.id))return!1;const M=C.rect;return a.horizontal?Wt(a.a.x,a.b.x,M.left,M.right)>=Xt&&a.a.y>=M.top-2&&a.a.y<=M.bottom+2:Wt(a.a.y,a.b.y,M.top,M.bottom)>=Xt&&a.a.x>=M.left-2&&a.a.x<=M.right+2})},"blockingRectsFor"),b=f((u,a,p)=>{const C=u.map(S=>({...S}));if(a.horizontal)C[a.index].y=p,C[a.index+1].y=p;else if(a.vertical)C[a.index].x=p,C[a.index+1].x=p;else return;const M=ue(xt(C));return lt(M).length===M.length-1?M:void 0},"candidateByMovingRail"),y=f((u,a,p)=>{const C=[u.start,u.end].filter(S=>!!S),M=lt(a);if(M.length!==a.length-1)return!1;for(const S of M)if(Bt(S.a,S.b,r,C,-2)||Bt(S.a,S.b,i,[],-2))return!1;for(const S of d)if(S!==u){for(const A of M)for(const I of lt(c(S)))if(de(A,I,.5)>=Xt)return!1}return l(u,a)<=p},"candidateIsSafe");for(let u=0;u<8;u++){const a=l();let p=!1;for(const C of d){const M=c(C),S=h(M);if(!S)continue;const A=m(C,S.segment);if(A.length===0)continue;const I=S.horizontal?[Math.min(...A.map(x=>x.rect.top))-20,Math.max(...A.map(x=>x.rect.bottom))+20]:[Math.min(...A.map(x=>x.rect.left))-20,Math.max(...A.map(x=>x.rect.right))+20];for(const x of I){const L=b(M,S.segment,x);if(!(!L||!y(C,L,a))){C.points=L,p=!0;break}}if(p)break}if(!p)return}}f(zn,"liftObstacleHuggingSameSideRails");function Vn(t,e){const o=f(c=>{const l=c.groupTitleRect;if(!(!l||typeof l.left!="number"||typeof l.right!="number"||typeof l.top!="number"||typeof l.bottom!="number"||!Number.isFinite(l.left)||!Number.isFinite(l.right)||!Number.isFinite(l.top)||!Number.isFinite(l.bottom)||l.right<=l.left||l.bottom<=l.top))return{left:l.left,right:l.right,top:l.top,bottom:l.bottom}},"validTitleRect"),s=f(c=>{if(!c.isGroup||c.parentId)return;const l=c.direction,h=typeof l=="string"?l.toUpperCase():"";if(h==="LR"||h==="RL"||h==="BT")return;const m=o(c),b=c.y,y=c.height;if(!m||typeof b!="number"||typeof y!="number"||!Number.isFinite(b)||!Number.isFinite(y)||y<=0)return;const u=m.right-m.left,a=m.bottom-m.top;if(!(a<=0||u<a))return{node:c,rect:m}},"topLaneTitleFor"),r=f((c,l)=>{if(!c.horizontal)return!1;const h=c.a.y;return h<=l.top+et||h>=l.bottom-et?!1:Wt(c.a.x,c.b.x,l.left,l.right)>=Xt},"horizontalSegmentIntersectsTitle"),i=[...e.values()].map(s).filter(c=>!!c);if(i.length===0)return;let d=0;for(const c of t){if(c.isLayoutOnly)continue;const l=xt(c.points??[]);for(const h of lt(l))for(const m of i)r(h,m.rect)&&(d=Math.max(d,m.rect.bottom-h.a.y+4))}if(!(d<=et))for(const c of i){const l=c.node.y,h=c.node.height;typeof l!="number"||typeof h!="number"||!Number.isFinite(l)||!Number.isFinite(h)||h<=0||(c.node.y=l-d/2,c.node.height=h+d,c.node.groupTitleRect={...c.rect,top:c.rect.top-d,bottom:c.rect.bottom-d})}}f(Vn,"liftTopLaneTitleBandsAboveRails");function jn(t,e){const o=f(l=>{const h=l.groupTitleRect;if(!(!h||typeof h.left!="number"||typeof h.right!="number"||typeof h.top!="number"||typeof h.bottom!="number"||!Number.isFinite(h.left)||!Number.isFinite(h.right)||!Number.isFinite(h.top)||!Number.isFinite(h.bottom)||h.right<=h.left||h.bottom<=h.top))return{left:h.left,right:h.right,top:h.top,bottom:h.bottom}},"validTitleRect"),s=f(l=>{if(!l.isGroup||l.parentId||l.direction!=="LR")return;const m=o(l),b=l.x,y=l.width;if(!m||typeof b!="number"||typeof y!="number"||!Number.isFinite(b)||!Number.isFinite(y)||y<=0)return;const u=m.right-m.left,a=m.bottom-m.top;if(!(u<=0||a<u))return{node:l,rect:m}},"leftLaneTitleFor"),r=f((l,h)=>{if(!l.vertical)return!1;const m=l.a.x;return m<=h.left+et||m>=h.right-et?!1:Wt(l.a.y,l.b.y,h.top,h.bottom)>=Xt},"verticalSegmentIntersectsTitle"),i=f((l,h)=>{if(!l.horizontal)return!1;const m=l.a.y;return m<=h.top+et||m>=h.bottom-et?!1:Wt(l.a.x,l.b.x,h.left,h.right)>=Xt},"horizontalSegmentIntersectsTitle"),d=[...e.values()].map(s).filter(l=>!!l);if(d.length===0)return;let c=0;for(const l of t){if(l.isLayoutOnly)continue;const h=xt(l.points??[]);for(const m of lt(h))for(const b of d)if(r(m,b.rect))c=Math.max(c,b.rect.right-m.a.x+4);else if(i(m,b.rect)){const y=Math.min(m.a.x,m.b.x);c=Math.max(c,b.rect.right-y+4)}}if(!(c<=et))for(const l of d){const h=l.node.x,m=l.node.width;typeof h!="number"||typeof m!="number"||!Number.isFinite(h)||!Number.isFinite(m)||m<=0||(l.node.x=h-c/2,l.node.width=m+c,l.node.groupTitleRect={...l.rect,left:l.rect.left-c,right:l.rect.right-c})}}f(jn,"shiftLeftLaneTitleBandsLeftOfRails");function Ls(t,e){const{realNodeRects:s}=Me(e.values()),r=t.filter(a=>!a.isLayoutOnly),i=f((a,p=new Map)=>xt(p.get(a)??a.points??[]),"replacementPointsFor"),d=f((a=new Map)=>{let p=0;for(let C=0;C<r.length;C++){const M=lt(i(r[C],a));for(let S=C+1;S<r.length;S++){const A=lt(i(r[S],a));for(const I of M)for(const x of A)he(I.a,I.b,x.a,x.b,et)&&p++}}return p},"crossingCount"),c=f((a=new Map)=>r.reduce((p,C)=>p+oe(i(C,a)),0),"totalBends"),l=f(a=>{const p=i(a);if(p.length<4)return;const C=p[p.length-2],M=p[p.length-1];if(!(!Nt(C,M,et)&&!Ot(C,M,et)))return{tailStart:C,terminal:M}},"terminalTailFor"),h=f((a,p)=>{const C=i(a);if(C.length<3)return;const M=C[0],S=C[1];let A;if(Nt(M,S,et))A={x:S.x,y:p.tailStart.y};else if(Ot(M,S,et))A={x:p.tailStart.x,y:S.y};else return;const I=ue(xt([M,S,A,p.tailStart,p.terminal]));return lt(I).length===I.length-1?I:void 0},"candidateWithDestinationTail"),m=f((a,p)=>{const C=[a.start,a.end].filter(M=>!!M);for(const M of lt(p))if(Bt(M.a,M.b,s,C,-2))return!0;return!1},"pathHasNodeHit"),b=f((a,p,C)=>{for(const M of r)if(M!==a){for(const S of lt(p))for(const A of lt(i(M,C)))if(de(S,A,.5)>=Xt)return!0}return!1},"pathHasSharedTrack"),y=f((a,p,C)=>!m(a,p)&&!b(a,p,C),"candidateIsSafe"),u=f(()=>{const a=new Map;for(const p of r){const C=p.end;if(!C||!e.has(C)||i(p).length<4)continue;const S=a.get(C)??[];S.push(p),a.set(C,S)}return a},"edgesByDestination");for(let a=0;a<4;a++){const p=d();if(p===0)return;const C=c();let M,S=p,A=C;for(const I of u().values())for(let x=0;x<I.length;x++)for(let L=x+1;L<I.length;L++){const R=I[x],P=I[L],w=l(R),F=l(P);if(!w||!F)continue;const k=h(R,F),B=h(P,w);if(!k||!B)continue;const X=new Map([[R,k],[P,B]]);if(!y(R,k,X)||!y(P,B,X))continue;const G=d(X),Z=c(X);G>=p||G>S||G===S&&Z>=A||(M=X,S=G,A=Z)}if(!M)return;for(const[I,x]of M)I.points=x}}f(Ls,"swapDestinationTerminalTailsToReduceCrossings");function Es(t,e){const{realNodeRects:i,labelNodeRects:d}=Me(e.values()),c=t.filter(I=>!I.isLayoutOnly),l=f((I,x=new Map)=>xt(x.get(I)??I.points??[]),"replacementPointsFor"),h=f((I=new Map)=>{let x=0;for(let L=0;L<c.length;L++){const R=lt(l(c[L],I));for(let P=L+1;P<c.length;P++){const w=lt(l(c[P],I));for(const F of R)for(const k of w)he(F.a,F.b,k.a,k.b,et)&&x++}}return x},"strictCrossingCount"),m=f((I=new Map)=>c.reduce((x,L)=>x+oe(l(L,I)),0),"totalBends"),b=f(I=>{const x=I.start,L=I.end,R=x?e.get(x):void 0,P=L?e.get(L):void 0,w=R?te(R):void 0,F=P?te(P):void 0;return w&&F?{src:w,dst:F}:void 0},"endpointRectsFor"),y=f((I,x,L)=>{if(L.index<=0||L.index+1>=x.length-1)return;const R=b(I);if(R){if(L.vertical){const P=L.a.x,w=Math.min(R.src.left,R.dst.left),F=Math.max(R.src.right,R.dst.right),k=P<w-et?"left":P>F+et?"right":void 0;return k?{edge:I,points:x,segmentIndex:L.index,axis:"vertical",side:k,coord:P,min:Math.min(L.a.y,L.b.y),max:Math.max(L.a.y,L.b.y)}:void 0}if(L.horizontal){const P=L.a.y,w=Math.min(R.src.top,R.dst.top),F=Math.max(R.src.bottom,R.dst.bottom),k=P<w-et?"top":P>F+et?"bottom":void 0;return k?{edge:I,points:x,segmentIndex:L.index,axis:"horizontal",side:k,coord:P,min:Math.min(L.a.x,L.b.x),max:Math.max(L.a.x,L.b.x)}:void 0}}},"externalRailForSegment"),u=f(()=>{const I=[];for(const x of c){const L=l(x);for(const R of lt(L)){const P=y(x,L,R);P&&I.push(P)}}return I},"collectExternalRails"),a=f((I,x)=>I.edge!==x.edge&&I.axis===x.axis&&I.side===x.side&&Wt(I.min,I.max,x.min,x.max)>=Xt,"railsInteract"),p=f(I=>{const x=[],L=new Set;for(const R of I){if(L.has(R))continue;const P=[R],w=[];for(L.add(R);P.length>0;){const F=P.pop();w.push(F);for(const k of I)!L.has(k)&&a(F,k)&&(L.add(k),P.push(k))}w.length>1&&x.push(w)}return x},"connectedComponents"),C=f(I=>{const x=[];for(const L of I)x.some(R=>Math.abs(R-L.coord)<et)||x.push(L.coord);for(;x.length<I.length;){const L=Math.min(...x),R=Math.max(...x),P=I[0].side;x.push(P==="left"||P==="top"?L-12*(I.length-x.length):R+12*(I.length-x.length))}return x},"uniqueCoordsFor"),M=f(I=>{const x=I.map(P=>P.coord),L=C(I),R=[];if(I.length<=6){const P=new Array(L.length).fill(!1),w=[],F=f(()=>{if(w.length===I.length){w.some((k,B)=>Math.abs(k-x[B])>=et)&&R.push([...w]);return}for(const[k,B]of L.entries())P[k]||(P[k]=!0,w.push(B),F(),w.pop(),P[k]=!1)},"visit");return F(),R}for(let P=0;P<x.length;P++)for(let w=P+1;w<x.length;w++){const F=[...x];[F[P],F[w]]=[F[w],F[P]],R.push(F)}return R},"coordinateAssignmentsFor"),S=f((I,x)=>{const L=new Map;for(const[P,w]of I.entries()){const F=x[P],k=L.get(w.edge)??w.points.map(B=>({x:B.x,y:B.y}));w.axis==="vertical"?(k[w.segmentIndex].x=F,k[w.segmentIndex+1].x=F):(k[w.segmentIndex].y=F,k[w.segmentIndex+1].y=F),L.set(w.edge,k)}const R=new Map;for(const[P,w]of L){const F=ue(xt(w));if(lt(F).length!==F.length-1)return;R.set(P,F)}return R},"replacementsForAssignment"),A=f(I=>{for(const[x,L]of I){const R=[x.start,x.end].filter(P=>!!P);for(const P of lt(L))if(Bt(P.a,P.b,i,R,-2)||Bt(P.a,P.b,d,[],-2))return!1}for(let x=0;x<c.length;x++){const L=c[x],R=I.has(L),P=lt(l(L,I));for(let w=x+1;w<c.length;w++){const F=c[w];if(!R&&!I.has(F))continue;const k=lt(l(F,I));for(const B of P)for(const X of k)if(de(B,X,.5)>=Xt)return!1}}return!0},"candidateIsSafe");for(let I=0;I<4;I++){const x=h();if(x===0)return;let L,R=x,P=m(),w=Number.POSITIVE_INFINITY;for(const F of p(u()))for(const k of M(F)){const B=S(F,k);if(!B||!A(B))continue;const X=h(B);if(X>=x)continue;const G=m(B),Z=F.reduce((ct,Mt,Pt)=>ct+Math.abs(k[Pt]-Mt.coord),0);X>R||X===R&&(G>P||G===P&&Z>=w)||(L=B,R=X,P=G,w=Z)}if(!L)return;for(const[F,k]of L)F.points=k}}f(Es,"reassignCrossingExternalRailChannels");function Ts(t,e){const{realNodeRects:s,labelNodeRects:r}=Me(e.values()),i=t.filter(u=>!u.isLayoutOnly),d=f((u,a,p)=>xt(u===a?p??[]:u.points??[]),"pointsFor"),c=f(u=>lt(u).reduce((a,p)=>{const C=p.a.x-p.b.x,M=p.a.y-p.b.y;return a+Math.hypot(C,M)},0),"pathLength"),l=f((u,a)=>{let p=0;for(let C=0;C<i.length;C++){const M=lt(d(i[C],u,a));for(let S=C+1;S<i.length;S++){const A=lt(d(i[S],u,a));for(const I of M)for(const x of A)he(I.a,I.b,x.a,x.b,et)&&p++}}return p},"strictCrossingCount"),h=f((u,a)=>{if(u.horizontal){const p=u.a.y;return(Math.abs(p-a.top)<1||Math.abs(p-a.bottom)<1)&&Wt(u.a.x,u.b.x,a.left,a.right)>=Xt}if(u.vertical){const p=u.a.x;return(Math.abs(p-a.left)<1||Math.abs(p-a.right)<1)&&Wt(u.a.y,u.b.y,a.top,a.bottom)>=Xt}return!1},"segmentRunsAlongRectBorder"),m=f(u=>{const a=[u.start,u.end].filter(C=>!!C),p=[];for(const C of a){const M=e.get(C),S=M?te(M):void 0;S&&p.push(S)}return p},"endpointRectsFor"),b=f((u,a)=>{if(a+3>=u.length)return[];const p=u[a],C=u[a+1],M=u[a+2],S=u[a+3],A=Nt(p,C,et)&&Ot(C,M,et)&&Nt(M,S,et),I=Ot(p,C,et)&&Nt(C,M,et)&&Ot(M,S,et);if(!A&&!I)return[];if(!(A?Math.sign(C.x-p.x)!==Math.sign(S.x-M.x):Math.sign(C.y-p.y)!==Math.sign(S.y-M.y)))return[];const L=gt(p,S,et)||yt(p,S,et)?[]:[{x:p.x,y:S.y},{x:S.x,y:p.y}],R=L.length===0?[[...u.slice(0,a+1),...u.slice(a+3)]]:L.map(w=>[...u.slice(0,a+1),w,...u.slice(a+3)]),P=new Set;return R.map(w=>ue(xt(w))).filter(w=>{if(lt(w).length!==w.length-1||!w.some(k=>ce(k,S,et)))return!1;const F=w.map(k=>`${k.x.toFixed(3)},${k.y.toFixed(3)}`).join("|");return P.has(F)?!1:(P.add(F),!0)})},"shortcutCandidatesAt"),y=f((u,a,p)=>{const C=[u.start,u.end].filter(S=>!!S),M=m(u);for(const S of lt(a))if(Bt(S.a,S.b,s,C,-2)||Bt(S.a,S.b,r,[],-2)||M.some(A=>h(S,A)))return!1;for(const S of i)if(S!==u){for(const A of lt(a))for(const I of lt(d(S)))if(de(A,I,.5)>=Xt)return!1}return l(u,a)<=p},"candidateIsSafe");for(let u=0;u<8;u++){const a=l();let p,C,M=a,S=Number.POSITIVE_INFINITY,A=Number.POSITIVE_INFINITY;for(const I of i){const x=d(I),L=oe(x,et),R=c(x);for(let P=0;P<=x.length-4;P++)for(const w of b(x,P)){const F=oe(w,et),k=c(w);if(!(F<L||F===L&&k<R-et)||!y(I,w,a))continue;const X=l(I,w);X>M||X===M&&(F>S||F===S&&k>=A)||(p=I,C=w,M=X,S=F,A=k)}}if(!p||!C)return;p.points=C}}f(Ts,"shortcutRedundantOrthogonalJogs");function ws(t,e){const i=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const _=N.x??0,D=N.y??0,j=te(N);j&&i.push({id:String(N.id??""),cx:_,cy:D,rect:j})}if(i.length===0)return;const d=new Map(i.map(N=>[N.id,N])),c=i.map(N=>({id:N.id,rect:N.rect})),l=["top","bottom","left","right"],h={top:Math.min(...i.map(N=>N.rect.top))-20,bottom:Math.max(...i.map(N=>N.rect.bottom))+20,left:Math.min(...i.map(N=>N.rect.left))-20,right:Math.max(...i.map(N=>N.rect.right))+20},m=t.filter(N=>!N.isLayoutOnly),b=new Map(m.map((N,_)=>[N,_])),y=f(N=>{const _=N==="left"||N==="top"?-1:1,D=[];for(let j=0;j<=2;j++)D.push(h[N]+_*20*j);return D},"outwardTracksForSide"),u=f((N,_=new Map)=>xt(_.get(N)??N.points??[]),"replacementPointsFor"),a=f((N,_)=>{let D=0;for(const j of N)for(const K of _)he(j.a,j.b,K.a,K.b,et)&&D++;return D},"crossingCountBetweenSegments"),p=f((N,_)=>a(lt(N),lt(_)),"crossingCountBetweenPaths"),C=f((N=new Map)=>{let _=0;const D=[],j=new Set,K=[],Q=f($=>{j.has($)||(j.add($),K.push($))},"addEdge");for(let $=0;$<m.length;$++){const q=m[$],g=u(q,N);for(let v=$+1;v<m.length;v++){const T=m[v],E=p(g,u(T,N));E>0&&(_+=E,D.push({first:q,second:T,count:E}),Q(q),Q(T))}}return K.sort(($,q)=>(b.get($)??0)-(b.get(q)??0)),{count:_,pairs:D,edgeSet:j,edges:K}},"crossingSnapshot"),M=f((N,_)=>{const D=new Set(_.keys());if(D.size===0)return N.count;let j=0;for(const Q of N.pairs)(D.has(Q.first)||D.has(Q.second))&&(j+=Q.count);let K=0;for(let Q=0;Q<m.length;Q++){const $=m[Q],q=D.has($),g=u($,_);for(let v=Q+1;v<m.length;v++){const T=m[v];!q&&!D.has(T)||(K+=p(g,u(T,_)))}}return N.count-j+K},"crossingCountWithReplacements"),S=f(N=>{const _=new Map;for(const K of N.pairs){const Q=_.get(K.first)??new Set;Q.add(K.second),_.set(K.first,Q);const $=_.get(K.second)??new Set;$.add(K.first),_.set(K.second,$)}const D=[],j=new Set;for(const K of N.edges){if(j.has(K))continue;const Q=[K],$=[];for(j.add(K);Q.length>0;){const q=Q.pop();$.push(q);for(const g of _.get(q)??[])j.has(g)||(j.add(g),Q.push(g))}$.sort((q,g)=>(b.get(q)??0)-(b.get(g)??0)),$.length>1&&D.push($)}return D},"crossingComponents"),A=f(N=>[N.start,N.end].filter(_=>!!_),"endpointIdsFor"),I=f(N=>{const _=[];for(const D of S(N)){const j=new Set(D),K=new Set(D.flatMap($=>A($))),Q=[...D];for(const $ of m)j.has($)||A($).some(q=>K.has(q))&&Q.push($);Q.sort(($,q)=>(b.get($)??0)-(b.get(q)??0)),_.push(Q)}return _},"pairSearchGroups"),x=f((N,_,D)=>M(N,new Map([[_,D]])),"crossingCountWithSingleReplacement"),L=f(N=>{const _=new Map;for(const D of N.pairs)_.set(D.first,(_.get(D.first)??0)+D.count),_.set(D.second,(_.get(D.second)??0)+D.count);return _},"currentCrossingsByEdge"),R=f(N=>N.slice(1).reduce((_,D,j)=>{const K=N[j];return _+Math.abs(D.x-K.x)+Math.abs(D.y-K.y)},0),"pathLength"),P=f((N=new Map)=>m.reduce((_,D)=>_+oe(u(D,N)),0),"totalBends"),w=f((N=new Map)=>m.reduce((_,D)=>_+R(u(D,N)),0),"totalLength"),F=f((N,_,D=new Map)=>{const j=lt(_);for(const K of m)if(K!==N){for(const Q of j)for(const $ of lt(u(K,D)))if(de(Q,$,.5)>=Xt)return!0}return!1},"pathHasSegmentConflict"),k=f((N,_)=>{const D=[N.start,N.end].filter(j=>!!j);for(const j of lt(_))if(Bt(j.a,j.b,c,D,-2))return!0;return!1},"pathHitsNode"),B=f((N,_)=>{const D=ue(xt(_));lt(D).length===D.length-1&&N.push(D)},"pushOrthogonalCandidate"),X=f(N=>N==="left"||N==="right","sideIsHorizontal"),G=f((N,_,D)=>{switch(_){case"left":return Math.min(N.x,D.x)-20;case"right":return Math.max(N.x,D.x)+20;case"top":return Math.min(N.y,D.y)-20;case"bottom":return Math.max(N.y,D.y)+20}},"localTrackForSameSide"),Z=f((N,_,D,j)=>{const K=D==="left"||D==="top"?-1:1,Q=[G(_,D,j),h[D]];for(const $ of Q)for(let q=0;q<=2;q++)B(N,ho(_,D,j,$+K*20*q))},"addSameSideCandidates"),ct=f((N,_,D,j,K)=>{for(const Q of y(D))for(const $ of y(K))B(N,[_,{x:Q,y:_.y},{x:Q,y:$},{x:j.x,y:$},j])},"addHorizontalToVerticalCandidates"),Mt=f((N,_,D,j,K)=>{for(const Q of y(D))for(const $ of y(K))B(N,[_,{x:_.x,y:Q},{x:$,y:Q},{x:$,y:j.y},j])},"addVerticalToHorizontalCandidates"),Pt=f((N,_,D,j,K)=>{const Q=[...y("top"),...y("bottom")];for(const $ of y(D))for(const q of y(K))for(const g of Q)B(N,[_,{x:$,y:_.y},{x:$,y:g},{x:q,y:g},{x:q,y:j.y},j])},"addHorizontalPairCandidates"),Dt=f((N,_,D,j,K)=>{const Q=[...y("left"),...y("right")];for(const $ of y(D))for(const q of y(K))for(const g of Q)B(N,[_,{x:_.x,y:$},{x:g,y:$},{x:g,y:q},{x:j.x,y:q},j])},"addVerticalPairCandidates"),nt=f(N=>{const _=new Set;return N.map(D=>xt(D)).filter(D=>{const j=D.map(K=>`${K.x.toFixed(3)},${K.y.toFixed(3)}`).join("|");return _.has(j)||D.length<2?!1:(_.add(j),!0)})},"dedupeCandidatePaths"),J=f((N,_,D,j)=>{const K=[],Q=uo(N,_,D,j,20,et);Q&&B(K,Q),_===j&&Z(K,N,_,D);const $=X(_),q=X(j);return $&&!q?ct(K,N,_,D,j):!$&&q?Mt(K,N,_,D,j):$?Pt(K,N,_,D,j):Dt(K,N,_,D,j),nt(K)},"buildCandidatesForSides"),rt=f((N,_,D,j)=>{const K=[...y("left"),...y("right")],Q=[...y("top"),...y("bottom")];for(const $ of l){const q=Le(j,$),g=$==="top"||$==="bottom"?y($):Q;for(const v of K){B(N,[_,D,{x:v,y:D.y},{x:v,y:q.y},q]);for(const T of g)B(N,[_,D,{x:v,y:D.y},{x:v,y:T},{x:q.x,y:T},q])}}},"addVerticalDepartureOuterTrackCandidates"),ut=f((N,_,D,j)=>{const K=[...y("left"),...y("right")],Q=[...y("top"),...y("bottom")];for(const $ of l){const q=Le(j,$),g=$==="left"||$==="right"?y($):K;for(const v of Q){B(N,[_,D,{x:D.x,y:v},{x:q.x,y:v},q]);for(const T of g)B(N,[_,D,{x:D.x,y:v},{x:T,y:v},{x:T,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),pt=f(N=>{const _=N.start,D=N.end,j=D?d.get(D):void 0;if(!_||!j)return[];const K=xt(N.points??[]);if(K.length<4)return[];const Q=K[0],$=K[1],q=[];return Ot(Q,$,et)?rt(q,Q,$,j):Nt(Q,$,et)&&ut(q,Q,$,j),q},"terminalPreservingOuterTrackCandidates"),St=f(N=>{const _=N.start,D=N.end,j=_?d.get(_):void 0,K=D?d.get(D):void 0;if(!j||!K)return[];const Q=[];for(const $ of l){const q=Le(j,$);for(const g of l)Q.push(...J(q,$,Le(K,g),g))}return Q.push(...pt(N)),Q},"candidatePathsFor"),wt=f(()=>new Map(m.map(N=>[N,lt(u(N))])),"currentSegmentsByEdge"),Kt=f((N,_,D)=>{const j=new Set;for(const K of m){if(K===N)continue;const Q=D.get(K)??lt(u(K));_.some($=>Q.some(q=>de($,q,.5)>=Xt))&&j.add(K)}return j},"sharedTrackConflictsFor"),qt=f((N,_,D,j)=>{const K=new Set;return St(N).map($=>ue(xt($))).filter($=>{if(k(N,$))return!1;const q=$.map(g=>`${g.x.toFixed(3)},${g.y.toFixed(3)}`).join("|");return K.has(q)||$.length<2?!1:(K.add(q),!0)}).map($=>{const q=lt($);let g=0;for(const v of m)v!==N&&(g+=a(q,D.get(v)??lt(u(v))));return{candidate:$,candidateSegments:q,crossings:_.count-(j.get(N)??0)+g,bends:oe($,et),totalBends:oe($),length:R($)}}).filter(({crossings:$})=>$<=_.count).sort(($,q)=>$.crossings-q.crossings||$.bends-q.bends||$.length-q.length).slice(0,48).map($=>({path:$.candidate,segments:$.candidateSegments,sharedTrackConflicts:Kt(N,$.candidateSegments,D),totalBends:$.totalBends,length:$.length}))},"pairCandidatesFor"),Jt=f((N,_,D,j,K,Q)=>{let $=0;for(const g of N.pairs)(g.first===_||g.second===_||g.first===j||g.second===j)&&($+=g.count);let q=a(D.segments,K.segments);for(const g of m){if(g===_||g===j)continue;const v=Q.get(g)??lt(u(g));q+=a(D.segments,v)+a(K.segments,v)}return N.count-$+q},"pairCrossingCount"),se=f((N,_)=>{for(const D of N.sharedTrackConflicts)if(D!==_)return!1;return!0},"conflictsOnlyWith"),Ee=f((N,_)=>N.segments.some(D=>_.segments.some(j=>de(D,j,.5)>=Xt)),"candidatesShareTrack"),me=f((N,_,D,j)=>se(_,D.edge)&&se(j,N.edge)&&!Ee(_,j),"pairCandidatesAreCompatible"),Te=f((N,_,D,j,K)=>{const Q=Jt(N.current,_.edge,D,j.edge,K,N.baseSegments);if(!(Q>=N.current.count))return{replacements:new Map([[_.edge,D.path],[j.edge,K.path]]),crossings:Q,bends:N.currentBends-(N.baseBendsByEdge.get(_.edge)??0)-(N.baseBendsByEdge.get(j.edge)??0)+D.totalBends+K.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(_.edge)??0)-(N.baseLengthByEdge.get(j.edge)??0)+D.length+K.length}},"scorePairReplacement"),mn=f((N,_)=>N.crossings<_.crossings||N.crossings===_.crossings&&(N.bends<_.bends||N.bends===_.bends&&N.length<_.length),"pairScoreIsBetter"),yn=f((N,_,D,j)=>{let K=j;for(const Q of _.candidates)for(const $ of D.candidates){if(!me(_,Q,D,$))continue;const q=Te(N,_,Q,D,$);q&&mn(q,K)&&(K=q)}return K},"bestScoreForOptionPair"),pn=f(N=>{const _=P(),D=w(),j=wt(),K=L(N),Q=new Map(m.map(E=>[E,oe(u(E))])),$=new Map(m.map(E=>[E,R(u(E))])),q=new Map,g=I(N);for(const E of g)for(const O of E){if(q.has(O))continue;const H=qt(O,N,j,K);H.length>0&&q.set(O,{edge:O,candidates:H})}let v={replacements:new Map,crossings:N.count,bends:_,length:D};const T={current:N,currentBends:_,currentLength:D,baseBendsByEdge:Q,baseLengthByEdge:$,baseSegments:j};for(const E of g){const O=new Set(E.filter(W=>N.edgeSet.has(W))),H=E.map(W=>q.get(W)).filter(W=>!!W);for(let W=0;W<H.length;W++){const ot=H[W];for(let U=W+1;U<H.length;U++){const V=H[U];!O.has(ot.edge)&&!O.has(V.edge)||(v=yn(T,ot,V,v))}}}return v.replacements.size>0?v.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const _=C(),D=_.count;if(D===0)return;let j,K,Q=D,$=Number.POSITIVE_INFINITY;for(const g of _.edges){const v=oe(u(g),et);for(const T of St(g)){const E=k(g,T),O=!E&&F(g,T),H=x(_,g,T),W=oe(T,et);E||O||!(H<D||H===D&&W<v)||H>Q||H===Q&&W>=$||(j=g,K=T,Q=H,$=W)}}if(j&&K){j.points=K;continue}const q=pn(_);if(!q)return;for(const[g,v]of q)g.points=v}}f(ws,"resolveRenderedOrthogonalCrossings");var be=.001,Zr=8;function As(t,e){const{nodeInfoById:n,realNodeRects:o}=un(e),s=["top","bottom","left","right"],r=20,i={top:Math.min(...o.map(a=>a.rect.top))-r,bottom:Math.max(...o.map(a=>a.rect.bottom))+r,left:Math.min(...o.map(a=>a.rect.left))-r,right:Math.max(...o.map(a=>a.rect.right))+r},d=f((a,p,C,M)=>{const S=[],A=uo(a,p,C,M,r,be);return A&&S.push(A),p===M&&S.push(ho(a,p,C,i[p])),S},"buildOrthogonalPathCandidates"),c=f((a,p)=>{for(let C=0;C<a.length-1;C++){const M=a[C],S=a[C+1];if(Bt(M,S,o,p,1))return!0}return!1},"pathHitsNode"),l=f((a,p,C=!1)=>{let M=0;const S=Pe(a,be),A=p.start,I=p.end;for(const x of t){if(x===p||x.isLayoutOnly)continue;const L=x.start,R=x.end;if(!C&&A&&I&&(L===A||L===I||R===A||R===I))continue;const P=x.points;if(!(!P||P.length<2))for(const w of S)for(const F of Pe(P,be)){if(mo(w.a,w.b,F.a,F.b,be,be)){M++;continue}de(w,F,be)>=Zr&&M++}}return M},"pathConflictCount"),h=4,m=f((a,p)=>{const C=Math.abs(a.y-p.rect.top),M=Math.abs(a.y-p.rect.bottom),S=Math.abs(a.x-p.rect.left),A=Math.abs(a.x-p.rect.right);let I="top",x=C;return M<x&&(I="bottom",x=M),S<x&&(I="left",x=S),A<x&&(I="right",x=A),I},"nearestSideOfRect"),b=new Map,y=f((a,p,C)=>{const M=b.get(a)??[];M.push({side:p,edgeId:C}),b.set(a,M)},"addFaceClaim");for(const a of t){if(a.isLayoutOnly)continue;const p=a.points??[];if(p.length<1)continue;const C=a.id??"",M=a.start,S=a.end;if(M){const A=n.get(M);A&&y(M,m(p[0],A),C)}if(S){const A=n.get(S);A&&y(S,m(p[p.length-1],A),C)}}const u=f((a,p,C)=>{var M;return((M=b.get(a))==null?void 0:M.some(S=>S.edgeId!==C&&S.side===p))??!1},"faceIsClaimed");for(const a of t){if(a.isLayoutOnly)continue;const p=a.points;if(!p||p.length<2)continue;const C=oe(p,be);if(C<h)continue;const M=a.start,S=a.end;if(!M||!S)continue;const A=n.get(M),I=n.get(S);if(!A||!I)continue;const x=a.id??"",L=l(p,a,!0),R=l(p,a);let P,w=L,F=C;for(const k of s){if(u(M,k,x))continue;const B=Le(A,k);for(const X of s){if(u(S,X,x))continue;const G=Le(I,X);for(const Z of d(B,k,G,X)){if(c(Z,[M,S]))continue;const ct=oe(Z,be);if(L>0){const Mt=l(Z,a,!0);if(Mt>w||Mt===w&&ct>=F)continue;w=Mt,F=ct,P=Z;continue}l(Z,a)>R||ct<F&&(F=ct,P=Z)}}}if(P){a.points=P;const k=b.get(M);k&&b.set(M,k.filter(X=>X.edgeId!==x));const B=b.get(S);B&&b.set(S,B.filter(X=>X.edgeId!==x)),y(M,m(P[0],A),x),y(S,m(P[P.length-1],I),x)}}}f(As,"simplifyDetouredEdges");var Qt=.001,_o=10,Ke=7;function Un(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 i=r.x-s.x,d=r.y-s.y;if(!(Math.abs(i)+Math.abs(d)<Qt)){if(Math.abs(d)<=Qt){const l=s.x+Math.sign(i)*_o;return{left:Math.min(s.x,l),right:Math.max(s.x,l),top:s.y-Ke,bottom:s.y+Ke}}if(Math.abs(i)<=Qt){const l=s.y+Math.sign(d)*_o;return{left:s.x-Ke,right:s.x+Ke,top:Math.min(s.y,l),bottom:Math.max(s.y,l)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}f(Un,"markerClearanceRectFor");function Rs(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}f(Rs,"normalizeRect");function Wn(t,e){const n=xt(e),o=Un(n,!0),s=Un(n,!1);return[o,s].some(r=>r&&en(t,Rs(r)))}f(Wn,"labelOverlapsOwnMarker");function Je(t,e){const n=[];for(const u of t){if(u.isLayoutOnly)continue;const a=u.points;if(!(!a||a.length<2))for(let p=0;p<a.length-1;p++)n.push({edgeId:u.id,p1:a[p],p2:a[p+1]})}const o=[],s=[];for(const u of e.values()){const a=u.isGroup,p=u.parentId;if(a&&!p){const M=te(u);M&&s.push({id:u.id,rect:M});continue}if(a||u.isEdgeLabel)continue;const C=te(u);C&&o.push({nodeId:u.id,rect:C})}const r=3,i=1,d=12,c=f((u,a)=>{const p=Nn(a,r);for(const{nodeId:C,rect:M}of o)if(C!==u&&en(p,M))return!0;return!1},"labelOverlapsForeignNode"),l=f((u,a)=>{const p=Nn(a,r);for(const C of n)if(C.edgeId!==u&&dn(C.p1,C.p2,p))return!0;return!1},"labelOverlapsForeignEdge"),h=f((u,a,p)=>c(u,p)||l(a,p),"labelOverlapsAnything"),m=[],b=f(u=>{for(const{id:a,rect:p}of s)if(ss(p,u))return a},"findContainingLane"),y=f((u,a)=>m.some(p=>p.labelId!==u&&en(a,p.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const a=u.labelNodeId;if(!a)continue;const p=e.get(a);if(!p)continue;const C=u.points;if(!C||C.length<2)continue;const M=p.width??0,S=p.height??0;if(M<=0||S<=0)continue;const A=[];for(let nt=0;nt<C.length-1;nt++){const J=C[nt],rt=C[nt+1],ut=Math.abs(J.x-rt.x),pt=Math.abs(J.y-rt.y);ut<Qt&&pt<Qt||ut>=Qt&&pt>=Qt||A.push({idx:nt,length:ut+pt,orientation:ut>=Qt?"horizontal":"vertical",midX:(J.x+rt.x)/2,midY:(J.y+rt.y)/2})}if(A.length===0)continue;const I=A.length>=3?A.filter(nt=>nt.idx>0&&nt.idx<A.length-1):A,x=I.length>0?I:A,L=M>=S?"horizontal":"vertical",R=f(nt=>[...nt].sort((J,rt)=>{const ut=J.orientation===L,pt=rt.orientation===L;if(ut!==pt)return ut?-1:1;const St=J.length>=(J.orientation==="horizontal"?M:S)+2,wt=rt.length>=(rt.orientation==="horizontal"?M:S)+2;return St!==wt?St?-1:1:rt.length-J.length}),"rankSegments"),P=A[0],w=A[A.length-1],F=[.5,.25,.75,.05,.95,.15,.85,.1,.9],k=f((nt,J)=>{const rt=C[nt.idx],ut=C[nt.idx+1];return{midX:rt.x+(ut.x-rt.x)*J,midY:rt.y+(ut.y-rt.y)*J}},"anchorAtT"),B=f((nt,J,rt)=>Math.min(rt,Math.max(J,nt)),"clamp"),X=f((nt,J)=>nt.midX>=J.left-Qt&&nt.midX<=J.right+Qt&&nt.midY>=J.top-Qt&&nt.midY<=J.bottom+Qt,"pointInsideRectInclusive"),G=f(nt=>{const J=Be(nt.midX,nt.midY,M,S),rt=b(J);if(rt)return{laneId:rt,anchor:nt,rect:J};const ut=s.find(({rect:se})=>X(nt,se));if(!ut)return;const pt=ut.rect.left+M/2+i,St=ut.rect.right-M/2-i,wt=ut.rect.top+S/2+i,Kt=ut.rect.bottom-S/2-i;if(pt>St||wt>Kt)return;const qt={midX:B(nt.midX,pt,St),midY:B(nt.midY,wt,Kt)},Jt=Be(qt.midX,qt.midY,M,S);return X(nt,Jt)?{laneId:ut.id,anchor:qt,rect:Jt}:void 0},"placementForAnchor"),Z=f((nt,J,rt)=>nt.orientation==="horizontal"?Math.abs(J.midX-rt.x):Math.abs(J.midY-rt.y),"distanceAlongSegment"),ct=f((nt,J)=>{const ut=(nt.orientation==="horizontal"?M/2:S/2)+d;if(nt===P){const pt=C[nt.idx];if(Z(nt,J,pt)+Qt<ut)return!1}if(nt===w){const pt=C[nt.idx+1];if(Z(nt,J,pt)+Qt<ut)return!1}return!0},"labelClearsTerminalEndpoints"),Mt=f(nt=>{const J=R(nt);for(const rt of J)for(const ut of F){const pt=k(rt,ut);if(!ct(rt,pt))continue;const St=G(pt);if(St&&!Wn(St.rect,C)&&!y(a,St.rect)&&!h(a,u.id,St.rect))return{laneId:St.laneId,anchor:St.anchor}}},"tryPool"),Pt=f((nt,J,rt=!1)=>{const ut=R(nt);for(const pt of ut){const St={midX:pt.midX,midY:pt.midY};if(J&&!ct(pt,St))continue;const wt=G(St);if(wt&&!Wn(wt.rect,C)&&!y(a,wt.rect)&&!c(a,wt.rect)&&(rt||!l(u.id,wt.rect)))return{laneId:wt.laneId,anchor:wt.anchor}}},"findLaneContainingFallback"),Dt=Mt(x)??(x.length<A.length?Mt(A):void 0)??Pt(A,!0)??Pt(A,!1)??Pt(A,!1,!0);if(Dt){p.x=Dt.anchor.midX,p.y=Dt.anchor.midY,p.parentId=Dt.laneId;const nt=Be(Dt.anchor.midX,Dt.anchor.midY,M,S),J=m.findIndex(rt=>rt.labelId===a);J>=0?m[J]={labelId:a,rect:nt}:m.push({labelId:a,rect:nt})}}}f(Je,"anchorLabelsToPolyline");var En=1e-6,Qr=8,Do=Qr/2,ti=3;function Kn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}f(Kn,"pairKey");function Ns(t,e){const{nodeInfoById:n,realNodeRects:o}=un(e),s=new Map;for(const i of e){const d=i.id;if(!i.isGroup&&i.isEdgeLabel){s.set(d,{w:i.width??0,h:i.height??0});continue}}const r=f((i,d,c,l)=>{const h=Kn(d,c);let m=0;const b=f(y=>{if(!y)return;const u=s.get(y);if(!u)return;const a=l==="x"?u.w/2:u.h/2;a>m&&(m=a)},"consider");b(i.labelNodeId);for(const y of t){if(y===i||y.isLayoutOnly)continue;const u=y.start,a=y.end;!u||!a||Kn(u,a)===h&&b(y.labelNodeId)}return m>0?m+ti:0},"labelClearanceFor");for(const i of t){if(i.isLayoutOnly)continue;const d=i.points;if(!lo(d,En))continue;const c=go(i,n,En);if(!c)continue;const{srcId:l,dstId:h,srcInfo:m,dstInfo:b,collinearX:y,collinearY:u}=c;if(y===u)continue;let a,p;if(y){const I=b.cy>m.cy;a={x:m.cx,y:I?m.rect.bottom:m.rect.top},p={x:b.cx,y:I?b.rect.top:b.rect.bottom}}else{const I=b.cx>m.cx;a={x:I?m.rect.right:m.rect.left,y:m.cy},p={x:I?b.rect.left:b.rect.right,y:b.cy}}if(Bt(a,p,o,[l,h],1))continue;const M=r(i,l,h,y?"x":"y"),S=M>Do?M:Do,A=[0,S,-S];for(const I of A){const x={...a},L={...p};if(y){if(x.x+=I,L.x+=I,x.x<=m.rect.left||x.x>=m.rect.right||L.x<=b.rect.left||L.x>=b.rect.right)continue}else if(x.y+=I,L.y+=I,x.y<=m.rect.top||x.y>=m.rect.bottom||L.y<=b.rect.top||L.y>=b.rect.bottom)continue;if(!Bt(x,L,o,[l,h],1)&&!nn(x,L,t,i,{epsilon:En})){i.points=[x,L];break}}}}f(Ns,"straightenCollinearSiblingDetours");function qn(t,e){const{realNodeRects:l,labelNodeRects:h}=Me(e.values()),m=f((x,L)=>Pe(L,.001).map(R=>({...R,edge:x,interior:R.index>=1&&R.index<=L.length-3})),"segmentsFor"),b=f(()=>{const x=[];for(const L of t){if(L.isLayoutOnly)continue;const R=L.points;!R||R.length<2||x.push(...m(L,xt(R)))}return x},"allSegments"),y=f((x,L)=>x.horizontal&&L.horizontal?Wt(x.a.x,x.b.x,L.a.x,L.b.x)>=8&&Math.abs(x.a.y-L.a.y)<7:x.vertical&&L.vertical?Wt(x.a.y,x.b.y,L.a.y,L.b.y)>=8&&Math.abs(x.a.x-L.a.x)<7:!1,"hasCrowdedParallelTrack"),u=f((x,L)=>{const R=x.start,P=x.end,w=m(x,L);if(w.length!==L.length-1)return!1;const F=[R,P].filter(B=>!!B),k=x.labelNodeId?[x.labelNodeId]:[];for(const B of w)if(Bt(B.a,B.b,l,F,-2)||Bt(B.a,B.b,h,k,-2))return!1;for(const B of t){if(B===x||B.isLayoutOnly)continue;const X=B.points;if(!(!X||X.length<2)){for(const G of w)for(const Z of m(B,xt(X)))if(y(G,Z)||he(G.a,G.b,Z.a,Z.b,.001))return!1}}return!0},"candidateIsSafe"),a=f((x,L)=>{const R=xt(x.edge.points??[]);if(R.length<4||x.index>=R.length-1)return;const P=R.map(w=>({...w}));if(x.horizontal)P[x.index].y+=L,P[x.index+1].y+=L;else if(x.vertical)P[x.index].x+=L,P[x.index+1].x+=L;else return;return m(x.edge,P).length===P.length-1?P:void 0},"shiftedCandidate"),p=f((x,L)=>({x:x.x??(L.left+L.right)/2,y:x.y??(L.top+L.bottom)/2}),"nodeCenter"),C=f(x=>{const L=x.edge,R=xt(L.points??[]);if(R.length!==4||x.index!==1)return;const P=L.start?e.get(L.start):void 0,w=L.end?e.get(L.end):void 0,F=P?te(P):void 0,k=w?te(w):void 0,B=R.slice(x.index+2);if(!(!P||!w||!F||!k||B.length===0))return{sourceCenter:p(P,F),targetCenter:p(w,k),sourceRect:F,tail:B}},"sourceDetourContextFor"),M=f((x,L,R,P,w,F)=>{const k=P.y>=R.y,B=k?w.bottom:w.top,X=B+(k?20:-20);if(k&&x.b.y<=X+.001||!k&&x.b.y>=X-.001)return;const G=x.a.x+L;return xt([{x:R.x,y:B},{x:R.x,y:X},{x:G,y:X},{x:G,y:x.b.y},...F],.001)},"verticalSourceDetour"),S=f((x,L,R,P,w,F)=>{const k=P.x>=R.x,B=k?w.right:w.left,X=B+(k?20:-20);if(k&&x.b.x<=X+.001||!k&&x.b.x>=X-.001)return;const G=x.a.y+L;return xt([{x:B,y:R.y},{x:X,y:R.y},{x:X,y:G},{x:x.b.x,y:G},...F],.001)},"horizontalSourceDetour"),A=f((x,L)=>{const R=C(x);if(R){if(x.vertical)return M(x,L,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail);if(x.horizontal)return S(x,L,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail)}},"sourceDetourCandidate"),I=[-7,7,-2*7,2*7,-3*7,3*7];for(let x=0;x<12;x++){const L=b();let R=!1;for(let P=0;P<L.length&&!R;P++)for(let w=P+1;w<L.length&&!R;w++){const F=L[P],k=L[w];if(F.edge===k.edge||!y(F,k))continue;const B=[F,k].filter(X=>X.interior);for(const X of B){for(const G of I){const Z=a(X,G);if(Z&&u(X.edge,Z)){X.edge.points=Z,R=!0;break}const ct=A(X,G);if(ct&&u(X.edge,ct)){X.edge.points=ct,R=!0;break}}if(R)break}}if(!R)return}}f(qn,"nudgeSharedInteriorSubpaths");function Os(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=o.x-n.x,d=o.y-n.y,c=s*d-r*i;if(Math.abs(c)<1e-10)return!1;const l=n.x-t.x,h=n.y-t.y,m=(l*d-h*i)/c,b=(l*r-h*s)/c,y=.01;return m>y&&m<1-y&&b>y&&b<1-y}f(Os,"segmentsIntersect");function Bs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=rs(e),r=1,i=[];for(const c of n){if(c.isLayoutOnly)continue;const l=c.points;if(!l||l.length<2)continue;const h=c.start,m=c.end,b=c.labelNodeId,y=c.id??`${h}->${m}`;for(const u of s)if(!(u.nodeId===h||u.nodeId===m)&&!(b&&u.nodeId===b)){for(let a=0;a<l.length-1;a++)if(dn(l[a],l[a+1],u,-r)){o.push({type:"edge-node-overlap",edgeId:y,targetId:u.nodeId,detail:`segment ${a} passes through node "${u.nodeId}"`});break}}for(let u=0;u<l.length-1;u++)i.push({edgeId:y,start:h,end:m,p1:l[u],p2:l[u+1]})}const d=new Set;for(let c=0;c<i.length;c++)for(let l=c+1;l<i.length;l++){const h=i[c],m=i[l];if(h.edgeId!==m.edgeId&&!(h.start===m.start||h.start===m.end||h.end===m.start||h.end===m.end)&&Os(h.p1,h.p2,m.p1,m.p2)){const b=h.edgeId<m.edgeId?`${h.edgeId}|${m.edgeId}`:`${m.edgeId}|${h.edgeId}`;d.has(b)||(d.add(b),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:m.edgeId,detail:`edges "${h.edgeId}" and "${m.edgeId}" cross`}))}}if(o.length>0){const c=o.filter(h=>h.type==="edge-node-overlap").length,l=o.filter(h=>h.type==="edge-edge-crossing").length;Qe.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${c} edge-node overlap(s), ${l} edge crossing(s)`);for(const h of o)Qe.warn(`[SWIMLANE_VALIDATE] ${h.type}: ${h.detail}`)}return o}f(Bs,"validateSwimlanesLayout");function Ps(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(d=>!d.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Ms(t,e)||e==="BT"&&s.length>0&&!bs(t))return;for(const d of o){if(d.isLayoutOnly)continue;const c=d.points;!c||c.length<2||(d.points=ue(on(c)))}As(o,n),Ns(o,n),Is(o,n);const r=new Map;for(const d of n)r.set(String(d.id),d);Je(o,r),fs(o,r),Ss(o,r),qn(o,r),Cs(o,r),vs(o,r),zn(o,r),Ls(o,r);const i=f(()=>{ws(o,r),Es(o,r),Ts(o,r),Je(o,r),Gn(o,r),zn(o,r),Je(o,r),Gn(o,r)},"finalizeRenderedEdges");i(),qn(o,r),i(),Vn(o,r),jn(o,r),Vn(o,r),jn(o,r)}f(Ps,"postProcessSwimlaneLayout");function Ie(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const i=`${r.id}:${r.src}->${r.dst}`;n.has(i)||(n.add(i),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}f(Ie,"normalizeGraph");function Mo(t,e){return t.edges.filter(n=>n.dst===e)}f(Mo,"incoming");function Fs(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}f(Fs,"buildSuccessorMap");function Io(t){const e=Fs(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}f(Io,"buildSortedSuccessorMap");function So(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}f(So,"buildInDegreeMap");function Co(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}f(Co,"sortedZeroInDegreeNodes");function hn(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}}f(hn,"buildPredecessorSuccessorMaps");function vo(t,e,n,o){var i,d;let s=0;for(const c of t.nodes)o!=null&&o.skipGroups&&((i=t.nodeById.get(c))!=null&&i.isGroup)||(s=Math.max(s,n[c]??0));const r=Array.from({length:s+1},()=>[]);for(const c of e)o!=null&&o.skipGroups&&((d=t.nodeById.get(c))!=null&&d.isGroup)||r[Math.max(0,n[c]??0)].push(c);return r}f(vo,"buildLayersFromRanks");function De(t){const e=So(t),n=Co(e),o=[],s=Io(t);for(;n.length;){const r=n.shift();o.push(r);for(const i of s.get(r)??[])if(e.set(i,(e.get(i)??0)-1),(e.get(i)??0)===0){let d=0;for(;d<n.length&&n[d]<i;)d++;n.splice(d,0,i)}}return o.length===t.nodes.length?o:null}f(De,"topoSortIfAcyclic");function Fe(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}f(Fe,"buildLayerIndex");function Lo(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let i=n(o,r)+n(r,s),d=o,c=r,l=o;for(;d<r||c<s;)c>=s||d<r&&t[d]<=t[c]?e[l++]=t[d++]:(e[l++]=t[c++],i+=r-d);for(let h=o;h<s;h++)t[h]=e[h];return i},"count");return n(0,t.length)}f(Lo,"countInversions");function ks(t){const e=Ie(t),n=new Map;for(const h of e.nodes)n.set(h,[]);for(const h of e.edges)n.get(h.src).push(h);for(const h of n.values())h.sort((m,b)=>m.dst===b.dst?m.id.localeCompare(b.id):m.dst.localeCompare(b.dst));const o=Object.create(null);for(const h of e.nodes)o[h]=0;const s=[],r=f(h=>{o[h]=1;for(const m of n.get(h)??[]){const b=m.dst;o[b]===0?r(b):o[b]===1&&s.push(m)}o[h]=2},"dfs"),i=[...e.nodes].sort((h,m)=>h.localeCompare(m));for(const h of i)o[h]===0&&r(h);const d=new Set(s.map(h=>`${h.id}:${h.src}->${h.dst}`)),c=e.edges.map(h=>d.has(`${h.id}:${h.src}->${h.dst}`)?{id:h.id,src:h.dst,dst:h.src,weight:h.weight,ref:h.ref}:h);return{acyclic:{nodes:[...e.nodes],edges:c,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}f(ks,"removeCycles_DFS");function _s(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const d=n(r)??r;return e.set(o,d),d},"resolve");for(const o of t.nodes)n(o);return e}f(_s,"buildTopLaneMap");function ge(t){const e=_s(t);return n=>e.get(n)??null}f(ge,"createTopLaneResolver");function gn(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}f(gn,"buildTopLaneOrder");function Eo(t,e){const n=gn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const i of e)!o.has(i)||s.has(i)||(s.add(i),r.push(i));for(const i of n)s.has(i)||r.push(i);return r}f(Eo,"resolveTopLaneOrder");var ei={EPSILON:1e-6},ln={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Ho={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Ds(t,e){const n=Ie(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=hn(n);for(const I of r.values())I.sort((x,L)=>x.localeCompare(L));const i=De(n)??[...n.nodes].sort((I,x)=>I.localeCompare(x)),d=new Map;for(const[I,x]of i.entries())d.set(x,I);const c=new Map,l=new Map;for(const I of n.nodes)l.set(I,[]);for(const I of i){const x=(r.get(I)??[]).filter(L=>c.has(L));if(x.length>0){const L=Hs(I,x,{laneOf:o,rankHint:s,topoIndex:d});c.set(I,L),l.get(L).push(I)}else c.has(I)||c.set(I,null)}for(const I of n.nodes)c.has(I)||c.set(I,null);const h=new Set;for(const I of n.nodes)(c.get(I)??null)===null&&h.add(I);const m=[...h].sort((I,x)=>{const L=d.get(I)??0,R=d.get(x)??0;return L===R?I.localeCompare(x):L-R}),b=Xs(n),y=new Map;for(const[I,x]of b.entries())y.set(I,[...x].sort((L,R)=>L.localeCompare(R)));const u=Ys(y),a=Gs(y),p=new Map;for(const I of n.nodes)p.set(I,[]);for(const I of a)for(const x of I.nodes){const L=p.get(x);L?L.push(I.id):p.set(x,[I.id])}const C=[],M=[],S=new Set,A=f(I=>{if(!S.has(I)){S.add(I),C.push(I);for(const x of l.get(I)??[])A(x);M.push(I)}},"walk");for(const I of m)A(I);for(const I of i)A(I);return{parent:c,children:l,roots:m,componentOf:u,blocks:a,nodeBlocks:p,adjacency:y,preorder:C,postorder:M,topologicalOrder:i}}f(Ds,"buildDrivingTree");function Hs(t,e,n){const o=n.laneOf(t);return[...e].sort((r,i)=>{var a,p;const d=n.laneOf(r),c=n.laneOf(i),l=d!=null&&d===o,h=c!=null&&c===o;if(l!==h)return l?-1:1;const m=(a=n.rankHint)==null?void 0:a[r],b=(p=n.rankHint)==null?void 0:p[i];if(m!=null&&b!=null&&m!==b)return b-m;const y=n.topoIndex.get(r)??0,u=n.topoIndex.get(i)??0;return y!==u?y-u:r.localeCompare(i)})[0]}f(Hs,"chooseParent");function Xs(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}f(Xs,"buildAdjacency");function Ys(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 i of t.get(r)??[])e.has(i)||s.push(i)}}n++}return e}f(Ys,"assignComponents");function Gs(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const i=f((d,c)=>{e.set(d,++r),n.set(d,r);for(const l of t.get(d)??[])l!==c&&(e.has(l)?(e.get(l)??0)<(e.get(d)??0)&&(o.push([d,l]),n.set(d,Math.min(n.get(d)??r,e.get(l)??r))):(o.push([d,l]),i(l,d),n.set(d,Math.min(n.get(d)??r,n.get(l)??r)),(n.get(l)??0)>=(e.get(d)??0)&&s.push($s(d,l,o,s.length))))},"visit");for(const d of t.keys())e.has(d)||i(d,null);return s}f(Gs,"computeBlocks");function $s(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const i=n.pop();if(s.push(i),r.add(i[0]),r.add(i[1]),i[0]===t&&i[1]===e||i[0]===e&&i[1]===t)break}return{id:o,edges:s,nodes:[...r]}}f($s,"popBlock");function zs(t,e,n){const o=[...t.nodes],s=new Map;for(const[M,S]of o.entries())s.set(S,M);const r=o.length,i=new Array(r).fill(-1),d=new Array(r).fill(0),c=[],l=new Set;for(const M of o){const S=n.parent.get(M)??null,A=s.get(M);A!=null&&S==null&&(i[A]=-1,d[A]=0,l.has(M)||(l.add(M),c.push(M)))}for(;c.length>0;){const M=c.shift(),S=s.get(M);if(S==null)continue;const A=n.children.get(M)??[];for(const I of A){if(l.has(I))continue;const x=s.get(I);x!=null&&(i[x]=S,d[x]=d[S]+1,l.add(I),c.push(I))}}for(const M of o){if(l.has(M))continue;const S=s.get(M);S!=null&&(i[S]=-1,d[S]=0,l.add(M))}const h=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),m=Array.from({length:h},()=>new Array(r).fill(-1));for(let M=0;M<r;M++)m[0][M]=i[M];for(let M=1;M<h;M++)for(let S=0;S<r;S++){const A=m[M-1][S];m[M][S]=A===-1?-1:m[M-1][A]}const b=f((M,S)=>{if(M===-1||S===-1)return-1;d[M]<d[S]&&([M,S]=[S,M]);const A=d[M]-d[S];for(let I=0;I<h;I++)if(A>>I&1&&(M=m[I][M],M===-1))return-1;if(M===S)return M;for(let I=h-1;I>=0;I--){const x=m[I][M],L=m[I][S];x===-1||L===-1||x!==L&&(M=x,S=L)}return m[0][M]},"lcaIndex"),y=Array.from({length:r},()=>new Map);for(const M of t.edges){let S=M.src,A=M.dst,I=e[S],x=e[A];if(I==null||x==null||(I>x&&([S,A]=[A,S],[I,x]=[x,I]),I==null||x==null||I===x))continue;const L=s.get(S),R=s.get(A);if(L==null||R==null)continue;const P=b(L,R);if(P===-1)continue;const w=y[P];for(let F=I;F<x;F++)w.set(F,(w.get(F)??0)+1)}const u=new Map,a=f((M,S)=>{if(S.size!==0)for(const[A,I]of S)M.set(A,(M.get(A)??0)+I)},"mergeInto"),p=new Set,C=f(M=>{const S=s.get(M);p.add(M);const A=S==null?void 0:y[S],I=A?new Map(A):new Map,x=n.children.get(M)??[];for(const L of x){const R=C(L),P=e[M];if(P!=null){let w=u.get(M);w||(w=new Map,u.set(M,w));let F=R.get(P)??0;const k=e[L];k!=null&&k>P&&(F+=1),w.set(L,F)}a(I,R)}return I},"dfs");for(const M of n.roots)p.has(M)||C(M);for(const M of o)p.has(M)||C(M);return u}f(zs,"computeSubtreeCrossCounts");function Vs(t,e,n){const o=new Map,s=f(r=>{let i=n[r]??0;const d=[...e.get(r)??[]];d.sort(To(n));for(const c of d){s(c);const l=o.get(c);l!=null&&(i=Math.min(i,l))}o.set(r,i)},"annotate");for(const r of t)s(r);return o}f(Vs,"annotateMinimumLayers");function To(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}f(To,"compareByRankThenId");function js(t,e,n,o){let s=0;for(const c of e){const l=n[c]??0;l>s&&(s=l)}const r=Array.from({length:s+1},()=>[]),i=new Set,d=f(c=>{if(i.has(c))return;i.add(c);const l=n[c]??0;r[l]||(r[l]=[]),r[l].push(c);for(const h of o(c))d(h)},"emit");for(const c of t)d(c);for(const c of e)if(!i.has(c)){const l=n[c]??0;r[l]||(r[l]=[]),r[l].push(c),i.add(c)}return r}f(js,"emitNodesInTreeOrder");function Us(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}f(Us,"deduplicateLayers");function Ws(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const i=e[s]??0,d=[],c=[],l=n.get(s);for(const h of r){const m=o.get(h)??i;m>i?d.push({child:h,min:m}):c.push(h)}return d.sort((h,m)=>h.min===m.min?h.child.localeCompare(m.child):h.min-m.min),c.sort((h,m)=>{const b=(l==null?void 0:l.get(h))??0,y=(l==null?void 0:l.get(m))??0;if(b!==y)return b-y;const u=o.get(h)??i,a=o.get(m)??i;return u!==a?u-a:h.localeCompare(m)}),[...d.map(h=>h.child),...c]}}f(Ws,"createChildOrderer");function fn(t,e,n){const o=Ds(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const m of t.nodes)s.has(m)||s.set(m,[]);const i=zs(t,e,o),d=[...r].sort(To(e)),c=Vs(d,s,e),l=Ws(s,e,i,c);let h=js(d,t.nodes,e,l);return h=Us(h),h}f(fn,"buildMultitreeLayerOrder");function Ks(t,e,n){const o=new Set(t),s=new Set(e),r=Fe(e),i=[];for(const d of n)o.has(d.src)&&s.has(d.dst)&&i.push(r.get(d.dst));return Lo(i)}f(Ks,"countCrossingsBetweenAdjacent");function Jn(t,e,n){const o=[];for(const r of e){const i=n[r.src],d=n[r.dst];if(i==null||d==null||i===d)continue;let c=r.src,l=r.dst,h=i,m=d;i>d&&(c=r.dst,l=r.src,h=d,m=i);for(let b=h;b<m;b++)o.push({id:`${r.id}@${b}`,src:c,dst:l,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ks(t[r],t[r+1],o);return s}f(Jn,"totalCrossings");function qs(t,e){const n={...e},{preds:o}=hn(t),s=ge(t),r=fn(t,n,s);let i=Jn(r,t.edges,n);const d=ln.MAX_CROSSING_OPTIMIZATION_PASSES;for(let c=0;c<d;c++){let l=!1;const h=[...t.nodes].sort((m,b)=>(n[b]??0)-(n[m]??0));for(const m of h){const b=n[m]??0;if(b===0)continue;let y=0;for(const C of o.get(m)??[])y=Math.max(y,(n[C]??0)+1);if(y>=b)continue;const u=b;n[m]=y;const a=fn(t,n,s),p=Jn(a,t.edges,n);p<i?(i=p,l=!0):n[m]=u}if(!l)break}return n}f(qs,"optimizeRanksByCrossings");function Js(t,e){const n=ge(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const i=t.edges.filter(a=>a.src===s);if(i.length===0)continue;let d=!1,c=0;for(const a of i){const p=n(a.dst);p==null||p===r?d=!0:c++}if(c===0||d)continue;let l=0,h=!1;for(const a of t.edges){if(a.dst!==s)continue;const p=n(a.src);p&&(p===r?h=!0:l++)}if(l>0||!h)continue;const m=e[s]??0,b=m+c;let y=0;for(const a of t.edges)a.dst===s&&(y=Math.max(y,(e[a.src]??0)+1));const u=Math.max(m,y,b);u!==m&&(e[s]=u)}}f(Js,"adjustCrossLaneSources");function Zs(t,e){const n=Ie(t),o=De(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=ge(n);let i=Object.create(null);for(const c of o){const l=Mo(n,c),h=e!=null&&e.ignoreCrossLaneEdges?l.filter(m=>{const b=r(m.src),y=r(c);return!b||!y?!0:b===y}):l;if(h.length===0)i[c]=0;else if(s&&h.length===1){const m=h[0].src,b=r(m),y=r(c);b!==y?i[c]=i[m]??0:i[c]=(i[m]??0)+1}else{let m=-1/0;for(const b of h)m=Math.max(m,(i[b.src]??0)+1);i[c]=m===-1/0?0:m}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(i=qs(n,i)),e!=null&&e.ignoreCrossLaneEdges&&Js(n,i),{layers:fn(n,i,r),rankOf:i,dummy:new Set}}f(Zs,"assignLayers_LongestPath");function Qs(t,e){const n=Ie(t),s={...Zs(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=ge(n),{preds:i,succs:d}=hn(n,u=>{if(e!=null&&e.ignoreCrossLaneEdges){const a=r(u.src),p=r(u.dst);if(a&&p&&a!==p)return!1}return!0}),c=De(n)??[...n.nodes],l=[...c].reverse(),h=f((u,a)=>{let p=0;for(const S of i.get(u)??[])p=Math.max(p,(s[S]??0)+1);let C=Number.POSITIVE_INFINITY;const M=d.get(u)??[];return M.length>0&&(C=Math.min(...M.map(S=>(s[S]??0)-1))),Number.isFinite(C)||(C=Math.max(p,a)),Math.min(Math.max(a,p),C)},"clampFeasible"),m=ln.GRAVITY_ITERATIONS,b=f(u=>{let a=!1;for(const p of u){const C=i.get(p)??[],M=d.get(p)??[];if(C.length===0&&M.length===0)continue;const S=C.length>0?C.reduce((L,R)=>L+(s[R]??0)+1,0)/C.length:s[p]??0,A=M.length>0?M.reduce((L,R)=>L+(s[R]??0)-1,0)/M.length:s[p]??0,I=Math.round((S+A)/2),x=h(p,I);x!==s[p]&&(s[p]=x,a=!0)}return a},"relaxOrder");for(let u=0;u<m;u++){const a=b(c),p=b(l);if(!a&&!p)break}for(const u of c){let a=0;for(const p of i.get(u)??[])a=Math.max(a,(s[p]??0)+1);(s[u]??0)<a&&(s[u]=a)}for(const u of l){const a=d.get(u)??[];if(a.length>0){const p=Math.min(...a.map(C=>(s[C]??0)-1));(s[u]??0)>p&&(s[u]=p)}}return{layers:vo(n,c,s),rankOf:s,dummy:new Set}}f(Qs,"assignLayers_Gravity");function tr(t){const e=So(t),n=Io(t);let o=Co(e);const s=[];for(;o.length>0;){const r=[];for(const i of o){s.push(i);for(const d of n.get(i)??[])e.set(d,(e.get(d)??0)-1),(e.get(d)??0)===0&&r.push(d)}o=r.sort((i,d)=>i.localeCompare(d))}return s.length===t.nodes.length?s:null}f(tr,"topoSortByGenerationIfAcyclic");function er(t,e){const n=Ie(t),o=(e==null?void 0:e.direction)==="LR"?tr(n)??[...n.nodes].sort():De(n)??[...n.nodes].sort(),s=ge(n),r=f(h=>s(h)??h,"laneOf"),i=Object.create(null),d=new Map,c=f((h,m)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(h)===r(m)?1:0:1,"edgeWeight");for(const h of o){const m=n.nodeById.get(h);if(m!=null&&m.isGroup)continue;const b=Mo(n,h);let y=0;if(b.length>0)for(const C of b){const M=C.src,S=i[M]??0;y=Math.max(y,S+c(M,h))}const u=r(h),a=d.get(u)??0,p=Math.max(y,a);i[h]=p,d.set(u,p+1)}return{layers:vo(n,o,i,{skipGroups:!0}),rankOf:i,dummy:new Set}}f(er,"assignLayers_LaneAwareCompact");function nr(t,e){const n=Ie(e),{rankOf:o}=t,s=t.layers.map(y=>[...y]),r=new Set(t.dummy?[...t.dummy]:[]);let i=0;const d=new Map(n.nodeById),c=f(y=>{const u=`placeholder-${i++}`,a={id:u,isGroup:!1,isDummy:!0,width:0,height:0};for(d.set(u,a),r.add(u);s.length<=y;)s.push([]);return s[y].push(u),o[u]=y,u},"addDummyAt"),l=[...n.edges].sort((y,u)=>y.id===u.id?y.src===u.src?y.dst.localeCompare(u.dst):y.src.localeCompare(u.src):y.id.localeCompare(u.id)),h=[];for(const y of l){const u=o[y.src]??0,a=o[y.dst]??0;if(a-u<=1){h.push(y);continue}let p=y.src;for(let M=u+1,S=0;M<a;M++,S++){const A=c(M);h.push({id:`${y.id}#${S}`,src:p,dst:A,weight:y.weight,ref:y.ref}),p=A}const C=a-u-2;h.push({id:`${y.id}#${Math.max(C+1,0)}`,src:p,dst:y.dst,weight:y.weight,ref:y.ref})}const b={nodes:[...n.nodes,...[...r].filter(y=>!n.nodes.includes(y))],edges:h,layout:n.layout,nodeById:d};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:b}}f(nr,"makeProperLayering");function Zn(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}f(Zn,"median");function Qn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}f(Qn,"barycenter");function or(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}f(or,"neighborPositionsFor");function sr(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}f(sr,"currentOrderTieBreak");function to(t,e,n){const o=new Set(t),s=new Set(e),r=Fe(t),i=Fe(e),d=[];for(const l of n)o.has(l.src)&&s.has(l.dst)&&d.push({u:r.get(l.src),v:i.get(l.dst)});d.sort((l,h)=>l.u===h.u?l.v-h.v:l.u-h.u);const c=d.map(l=>l.v);return Lo(c)}f(to,"countCrossingsBetweenAdjacent");function Ze(t,e,n){return[...t].sort((o,s)=>{const r=Zn(e.get(o)??[]),i=Zn(e.get(s)??[]);return r===i?sr(o,s,n):isFinite(r)?isFinite(i)?r-i:-1:1})}f(Ze,"sortByHeuristic");function eo(t,e,n,o,s,r){const i=Fe(t),d=Fe(e),c=or(e,i,n,o);if(!s||!r||r.length===0)return Ze(e,c,d);const l=new Map;for(const b of e){const y=s(b),u=l.get(y)??[];u.push(b),l.set(y,u)}const h=[];for(const b of r){const y=l.get(b);if(!y||y.length===0)continue;const u=Ze(y,c,d);h.push(...u)}const m=l.get(null);if(m&&m.length>0){const b=Ze(m,c,d);for(const y of b){const u=Qn(c.get(y)??[]);let a=h.length;if(isFinite(u))for(const[p,C]of h.entries()){const M=Qn(c.get(C)??[]);if(u<M){a=p;break}}h.splice(a,0,y)}}return h}f(eo,"reorderLayer");function no(t,e,n,o,s){const r=[...e],i=new Set(t),d=new Set(e),c=o?new Set(o):null,l=n.filter(a=>i.has(a.src)&&d.has(a.dst)),h=c?n.filter(a=>d.has(a.src)&&c.has(a.dst)):void 0,m=f(a=>{let p=to(t,a,l);return h&&o&&(p+=to(a,o,h)),p},"crossingScore"),b=s?new Map:null;if(s&&b)for(const a of e)b.set(a,s(a));let y=!0,u=m(r);for(;y;){y=!1;for(let a=0;a+1<r.length;a++){if(b){const M=b.get(r[a]),S=b.get(r[a+1]);if(M!==S)continue}const p=u;[r[a],r[a+1]]=[r[a+1],r[a]];const C=m(r);C<p?(u=C,y=!0):[r[a],r[a+1]]=[r[a+1],r[a]]}}return r}f(no,"transposeImprove");function rr(t,e,n){const o=t.layers.map(d=>[...d]),s=e.edges,r=ge(e),i=Eo(e,n==null?void 0:n.laneOrder);for(let d=0;d<3;d++){for(let c=1;c<o.length;c++)o[c]=eo(o[c-1],o[c],s,"down",r,i),o[c]=no(o[c-1],o[c],s,o[c+1],r);for(let c=o.length-2;c>=0;c--)o[c]=eo(o[c+1],o[c],s,"up",r,i),o[c]=no(o[c+1],o[c],s,o[c-1],r)}return{layers:o}}f(rr,"orderLayers");function ir(t,e,n){const o=(n==null?void 0:n.layerGap)??Ho.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??Ho.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,i=(n==null?void 0:n.direction)??"TB",d=i==="LR"||i==="RL",c=t.layers,l=Object.create(null),h=Object.create(null),m=f(w=>e.nodeById.get(w),"getNode"),b=f(w=>{var F;return((F=m(w))==null?void 0:F.width)??0},"getWidth"),y=f(w=>{var F;return((F=m(w))==null?void 0:F.height)??0},"getHeight"),u=ge(e),a=Eo(e,n==null?void 0:n.laneOrder),p=c.map(w=>w.reduce((F,k)=>Math.max(F,y(k)),0)),C=[];if(d)for(let w=0;w+1<c.length;w++){const F=c[w].reduce((Mt,Pt)=>Math.max(Mt,b(Pt)),0),k=c[w+1].reduce((Mt,Pt)=>Math.max(Mt,b(Pt)),0),B=p[w],X=p[w+1],G=B/2+X/2,Z=(F+k)/2,ct=Math.max(0,Z-G-o);C.push(ct)}const M=new Set;for(const w of c)for(const F of w)M.add(u(F));const S=M.has(null),A=a.filter(w=>M.has(w)),I=[...S?[null]:[],...A],x=Object.create(null);for(const w of A)x[w]=0;S&&(x.null=0);for(const w of c){const F=Object.create(null),k=[];for(const B of w){const X=u(B);X===null?k.push(B):(F[X]||(F[X]=[])).push(B)}for(const[B,X]of Object.entries(F)){const G=X.reduce((Z,ct)=>Z+b(ct),0)+s*Math.max(0,X.length-1);x[B]=Math.max(x[B]??0,G)}if(S&&k.length){const B=k.reduce((X,G)=>X+b(G),0)+s*Math.max(0,k.length-1);x.null=Math.max(x.null??0,B)}}const L=new Map;{const w=I.map(B=>(B===null?x.null:x[B])??0);let k=-(w.reduce((B,X)=>B+X,0)+r*Math.max(0,I.length-1))/2;for(let B=0;B<I.length;B++){const X=I[B],G=w[B]??0,Z=k+G/2;L.set(X,Z),k+=G,B<I.length-1&&(k+=r)}}let R=0;for(const[w,F]of c.entries()){const k=p[w]??0,B=new Map;for(const G of F){const Z=u(G),ct=B.get(Z)??[];ct.push(G),B.set(Z,ct)}for(const G of I){const Z=B.get(G)??[];if(Z.length===0)continue;const ct=L.get(G);if(Z.length===1){const Mt=Z[0];l[Mt]=ct,h[Mt]=R+k/2}else{const Mt=Z.map(nt=>b(nt)),Pt=Mt.reduce((nt,J)=>nt+J,0)+s*(Z.length-1);let Dt=ct-Pt/2;for(const[nt,J]of Z.entries()){const rt=Mt[nt];l[J]=Dt+rt/2,h[J]=R+k/2,Dt+=rt+s}}}const X=C[w]??0;R+=k+o+X}const P=new Map;for(const w of e.edges){const F=w.ref.id;P.has(F)||P.set(F,[]),P.get(F).push(w)}for(const[,w]of P){if(w.length===0)continue;const F=w[0].ref,k=F.start,B=F.end;if(k==null||B==null)continue;const X=Math.round(((l[k]??0)+(l[B]??0))/2),G=new Set;for(const Z of w)G.add(Z.src),G.add(Z.dst);for(const Z of G){if(Z===k||Z===B)continue;const ct=e.nodeById.get(Z);ct!=null&&ct.isDummy&&(l[Z]=X)}}return{x:l,y:h}}f(ir,"assignCoordinates");var cr=8;function ar(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}f(ar,"hashString");function lr(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}f(lr,"mulberry32");function fr(t,e){const n=[...t],o=lr(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}f(fr,"deterministicShuffle");function dr(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}f(dr,"sourceDistance");function oo(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:i}of e){const d=n.get(s),c=n.get(r);d==null||c==null||(o+=i*Math.abs(d-c))}return o}f(oo,"laneArrangementCost");function ur(t){const e=gn(t);if(e.length<2)return[];const n=new Map(e.map((r,i)=>[r,i])),o=ge(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const i=typeof r.start=="string"?r.start:void 0,d=typeof r.end=="string"?r.end:void 0;if(!i||!d||!t.nodeById.has(i)||!t.nodeById.has(d))continue;const c=o(i),l=o(d);if(!c||!l||c===l)continue;const h=n.get(c),m=n.get(l);if(h==null||m==null)continue;const[b,y]=h<=m?[c,l]:[l,c],u=`${b}\0${y}`,a=s.get(u);a?a.weight++:s.set(u,{a:b,b:y,weight:1})}return[...s.values()]}f(ur,"buildWeightedLaneEdges");function so(t,e,n){const o=[...t];let s=oo(o,e),r=!0,i=0;const d=Math.max(1,o.length);for(;r&&i<d;){r=!1,i++;for(let c=0;c+1<o.length;c++){[o[c],o[c+1]]=[o[c+1],o[c]];const l=oo(o,e);l<s?(s=l,r=!0):[o[c],o[c+1]]=[o[c+1],o[c]]}}return{order:o,cost:s,sourceDistance:dr(o,n)}}f(so,"greedySwitch");function hr(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}f(hr,"isBetterCandidate");function gr(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:i})=>`${s}:${r}:${i}`).join("|");return ar(`${t.join("|")}#${o}#${n}`)}f(gr,"seedForRestart");function mr(t,e={}){const n=gn(t);if(n.length<2)return n;const o=ur(t);if(o.length===0)return n;const s=new Map(n.map((d,c)=>[d,c]));let r=so(n,o,s);const i=Math.max(0,e.restarts??cr);for(let d=0;d<i;d++){const c=gr(n,o,d),l=fr(n,c),h=so(l,o,s);hr(h,r)&&(r=h)}return r.order}f(mr,"optimizeTopLaneOrder");function yr(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=Ie(t),r=e!=null&&e.automaticLaneOrdering?mr(s,{restarts:cr}):void 0,i=ks(s),d=i.acyclic,c=n?er(d,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??ln.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Qs(d,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??ln.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:l,graphWithDummies:h}=nr(c,d),m=rr(l,h,{laneOrder:r}),b=ir(m,h,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:d,reversed:i.reversed,layering:l,ordered:m,coordinates:b}}f(yr,"sugiyamaLayout");var ft=ei.EPSILON,ni=8,Ce=15,Ne=15,qe=25,ie=20,Tn=10;function ro(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,i=e.y-s,d=Math.abs(r),c=Math.abs(i);if(d<ft&&c<ft)return n;const l=3;return c>ft&&c*l>=d?i>0?"bottom":"top":d>ft?r>0?"right":"left":n}f(ro,"chooseOrthogonalSide");function io(t,e){return Math.abs(t.to-e.from)<ft||Math.abs(t.to-e.to)<ft?t.to:t.from}f(io,"sharedLineEndpointCoord");function ve(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}f(ve,"pointOnLine");function pr(t,e){var K,Q,$,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const g of o)g.isLayoutOnly||s.push({...g,__originalEdge:g});const r=new Map,i=new Map,d=[],c=e==="LR";for(const g of n)r.set(g.id,g);const l=n.filter(g=>g.isGroup&&!g.parentId);for(const g of l){const v={id:g.id},T=f(E=>{i.set(E.id,v),n.filter(O=>O.parentId===E.id).forEach(T)},"assignLane");T(g)}const h=n.filter(g=>!g.isGroup&&!g.isEdgeLabel).map(g=>{const v=g.width??10,T=g.height??10,E=g.x??0,O=g.y??0,H=ni;return{nodeId:g.id,minX:E-v/2-H,maxX:E+v/2+H,minY:O-T/2-H,maxY:O+T/2+H,visualXHalfExtent:c?T/2+H:v/2+H}}),m=f((g,v,T,E)=>{let O=d.find(H=>H.orientation===g&&Math.abs(H.coord-v)<1);return O||(O={id:`pipe-${g}-${v.toFixed(0)}`,orientation:g,coord:v,spanMin:T,spanMax:E,tracks:[]},d.push(O)),O.spanMin=Math.min(O.spanMin,T),O.spanMax=Math.max(O.spanMax,E),O},"getOrAddPipe"),b=f((g,v)=>{const T=g.width??10,E=g.height??10,O=g.x??0,H=g.y??0;switch(v){case"top":return{x:O,y:H-E/2};case"bottom":return{x:O,y:H+E/2};case"left":return{x:O-T/2,y:H};case"right":return{x:O+T/2,y:H}}},"portForSide"),y=f((g,v,T)=>b(g,ro(g,v,T?"bottom":"top")),"getOrthogonalPort"),u=[],a=[],p=new Set,C=1e3,M=f((g,v,T)=>{if(u.length===0)return 0;const E=Math.abs(v.y-T.y)<ft,O=Math.abs(v.x-T.x)<ft;if(!E&&!O)return 0;let H=0;if(E){const W=v.y,ot=Math.min(v.x,T.x)-ft,U=Math.max(v.x,T.x)+ft;if(U<=ot)return 0;for(const V of u)V.edgeIndex===g||V.orientation!=="vertical"||V.pipe.coord<ot||V.pipe.coord>U||V.from-ft<=W&&V.to+ft>=W&&(H+=C)}else if(O){const W=v.x,ot=Math.min(v.y,T.y)-ft,U=Math.max(v.y,T.y)+ft;if(U<=ot)return 0;for(const V of u)V.edgeIndex===g||V.orientation!=="horizontal"||V.pipe.coord<ot||V.pipe.coord>U||V.from-ft<=W&&V.to+ft>=W&&(H+=C)}return H},"crossingPenalty"),S=s.map((g,v)=>{if(!g.start||!g.end)return{idx:v,crossLane:0,dx:0,dy:0};const T=r.get(g.start),E=r.get(g.end),O=i.get(g.start),H=i.get(g.end),W=O&&H&&O.id!==H.id?1:0,ot=T&&E?Math.abs((E.x??0)-(T.x??0)):0,U=T&&E?Math.abs((E.y??0)-(T.y??0)):0;return{idx:v,crossLane:W,dx:ot,dy:U}}).sort((g,v)=>{if(g.crossLane!==v.crossLane)return v.crossLane-g.crossLane;const T=g.dx+g.dy,E=v.dx+v.dy;return Math.abs(T-E)>1?T-E:g.idx-v.idx}).map(g=>g.idx),A=f((g,v,T,E)=>{const O=Math.min(g.x,v.x),H=Math.max(g.x,v.x),W=Math.min(g.y,v.y),ot=Math.max(g.y,v.y);return!!h.find(V=>T&&V.nodeId===T||E&&V.nodeId===E?!1:Math.abs(g.x-v.x)>ft?V.minY<g.y&&V.maxY>g.y&&V.maxX>O&&V.minX<H:V.minX<g.x&&V.maxX>g.x&&V.maxY>W&&V.minY<ot)},"isSegmentBlocked"),I=new Map,x=new Map;for(const g of s)!g.start||!g.end||g.start===g.end||(x.set(g.start,(x.get(g.start)??0)+1),x.set(g.end,(x.get(g.end)??0)+1));const L=f((g,v)=>ro(g,v,"bottom"),"determineSide"),R=new Map;for(const[g,v]of s.entries()){if(!v.start||!v.end||v.start===v.end||v.points&&v.points.length>0)continue;const T=r.get(v.start),E=r.get(v.end);if(!T||!E)continue;const O=(E.x??0)-(T.x??0),H=(E.y??0)-(T.y??0);R.set(g,{edgeIdx:g,srcId:v.start,dstId:v.end,srcSide:L(T,{x:E.x??0,y:E.y??0}),dstSide:L(E,{x:T.x??0,y:T.y??0}),absDx:Math.abs(O),absDy:Math.abs(H),dxSign:Math.sign(O),dySign:Math.sign(H)})}const P=f(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.absDx===0?1/0:g.absDy/g.absDx:g.absDy===0?1/0:g.absDx/g.absDy,"preferenceStrength"),w=f(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.dxSign>=0?"right":"left":g.dySign>=0?"bottom":"top","secondarySide"),F=new Map;for(const g of R.values()){const v=`${g.srcId}:${g.srcSide}`;F.has(v)||F.set(v,[]),F.get(v).push(g)}const k=new Map,B=f((g,v)=>`${g}:${v}`,"loadKey");for(const g of R.values())k.set(B(g.srcId,g.srcSide),(k.get(B(g.srcId,g.srcSide))??0)+1),k.set(B(g.dstId,g.dstSide),(k.get(B(g.dstId,g.dstSide))??0)+1);for(const g of F.values())if(!(g.length<2)){g.sort((v,T)=>{const E=P(v),O=P(T);return Math.abs(E-O)>1e-9?O-E:v.edgeIdx-T.edgeIdx});for(let v=1;v<g.length;v++){const T=g[v],E=w(T),O=k.get(B(T.srcId,T.srcSide))??0,H=k.get(B(T.srcId,E))??0;H>=O||(k.set(B(T.srcId,T.srcSide),O-1),k.set(B(T.srcId,E),H+1),T.srcSide=E)}}const X=f(g=>{const v=g==null?void 0:g.shape;return v==="question"||v==="diamond"},"isDiamondNode"),G=new Map;for(const g of R.values())G.has(g.dstId)||G.set(g.dstId,new Set),G.get(g.dstId).add(g.dstSide);for(const g of R.values()){if(!X(r.get(g.srcId)))continue;const v=G.get(g.srcId);if(!(v!=null&&v.has(g.srcSide)))continue;const T=w(g);if(v.has(T)||(k.get(B(g.srcId,T))??0)>0)continue;const E=k.get(B(g.srcId,g.srcSide))??0;k.set(B(g.srcId,g.srcSide),Math.max(0,E-1)),k.set(B(g.srcId,T),1),g.srcSide=T}for(const g of R.values()){const{edgeIdx:v,srcId:T,dstId:E,srcSide:O,dstSide:H}=g,W=r.get(T),ot=r.get(E),U=`${T}:${O}:src`,V=O==="top"||O==="bottom"?ot.x??0:ot.y??0;I.has(U)||I.set(U,[]),I.get(U).push({edgeIdx:v,oppositeCoord:V});const bt=`${E}:${H}:dst`,dt=H==="top"||H==="bottom"?W.x??0:W.y??0;I.has(bt)||I.set(bt,[]),I.get(bt).push({edgeIdx:v,oppositeCoord:dt})}const Z=new Map,ct=8;for(const[g,v]of I){if(v.length<2)continue;v.sort((At,Gt)=>At.oppositeCoord-Gt.oppositeCoord);const T=g.split(":"),E=T.slice(0,-2).join(":"),O=T[T.length-2],H=T[T.length-1],W=r.get(E);if(!W)continue;const U=O==="left"||O==="right"?W.height??10:W.width??10,V=W.shape,dt=V==="question"||V==="diamond"?U*.3:U,st=Math.min(20,Math.max(ct,dt/(v.length+1))),Ft=-(st*(v.length-1))/2;for(const[At,Gt]of v.entries()){const ee=Ft+At*st,xn=`${Gt.edgeIdx}:${H}`;Z.set(xn,ee)}}const Mt=f(g=>{var v;return!!((v=s[g])!=null&&v.labelNodeId)},"edgeHasLabelNode"),Pt=f((g,v)=>g?(I.get(`${g}:${v}:src`)??[]).some(({edgeIdx:T})=>Mt(T))||(I.get(`${g}:${v}:dst`)??[]).some(({edgeIdx:T})=>Mt(T)):!1,"faceHasLabelNode"),Dt=f((g,v,T)=>v==="top"||v==="bottom"?{x:g.x+T,y:g.y}:{x:g.x,y:g.y+T},"applyPortOffset"),nt=f((g,v,T)=>{const E=R.get(g),O={x:T.x??0,y:T.y??0},H={x:v.x??0,y:v.y??0},W=(E==null?void 0:E.srcSide)??L(v,O),ot=(E==null?void 0:E.dstSide)??L(T,H);let U=E?b(v,E.srcSide):y(v,O,!0),V=E?b(T,E.dstSide):y(T,H,!1);const bt=Z.get(`${g}:src`),dt=Z.get(`${g}:dst`);return bt!==void 0&&(U=Dt(U,W,bt)),dt!==void 0&&(V=Dt(V,ot,dt)),{pSrcPort:U,pDstPort:V,srcSide:W,dstSide:ot}},"portsForEdge");for(const g of S){const v=s[g];if(a[g]=[],!v.start||!v.end||v.points&&v.points.length>0||v.start===v.end)continue;const T=r.get(v.start),E=r.get(v.end);if(!T||!E)continue;const{pSrcPort:O,pDstPort:H,srcSide:W,dstSide:ot}=nt(g,T,E),U={...O},V={...H},bt=W==="top"||W==="bottom",dt=ot==="top"||ot==="bottom";if(bt){const Y=O.y>(T.y??0);U.y=Y?O.y+ie:O.y-ie}else{const Y=O.x>(T.x??0);U.x=Y?O.x+ie:O.x-ie}if(dt){const Y=H.y>(E.y??0);V.y=Y?H.y+ie:H.y-ie}else{const Y=H.x>(E.x??0);V.x=Y?H.x+ie:H.x-ie}const at=f((Y,z)=>{for(const tt of h)if(!z.includes(tt.nodeId)&&Y.x>tt.minX&&Y.x<tt.maxX&&Y.y>tt.minY&&Y.y<tt.maxY)return{inside:!0,obstacle:tt};return{inside:!1}},"isPointInObstacle"),st=f((Y,z,tt,ht,Tt)=>{if(Tt){const kt=Y.y>(z.y??0);return{x:(tt.x??0)>=Y.x?ht.maxX+Ce:ht.minX-Ce,y:kt?ht.maxY+Ne:ht.minY-Ne,leavesPositiveSide:kt}}const Ct=Y.x>(z.x??0),Rt=(tt.y??0)>=Y.y;return{x:Ct?ht.maxX+Ce:ht.minX-Ce,y:Rt?ht.maxY+Ne:ht.minY-Ne,leavesPositiveSide:Ct}},"obstacleDetour");let It=[];const Ft=[v.start,v.end],At=at(U,Ft);if(At.inside&&At.obstacle){const Y=At.obstacle;if(bt){const z=st(O,T,E,Y,!0);U.x=z.x,U.y=z.y;const tt=z.leavesPositiveSide?Math.min(Y.minY-2,O.y+ie):Math.max(Y.maxY+2,O.y-ie);It=[{x:O.x,y:tt},{x:z.x,y:tt},{x:z.x,y:z.y}]}else{const z=st(O,T,E,Y,!1),tt=z.leavesPositiveSide?Math.min(Y.minX-2,O.x+ie):Math.max(Y.maxX+2,O.x-ie);U.x=z.x,U.y=z.y,It=[{x:tt,y:O.y},{x:tt,y:z.y},{x:z.x,y:z.y}]}}let Gt=[];const ee=at(V,Ft);if(ee.inside&&ee.obstacle){const Y=ee.obstacle;if(dt){const z=st(H,E,T,Y,!0);V.x=z.x,V.y=z.y,Gt=[{x:z.x,y:z.y},{x:H.x,y:z.y}]}else{const z=st(H,E,T,Y,!1);V.x=z.x,V.y=z.y,Gt=[{x:z.x,y:z.y},{x:z.x,y:H.y}]}}if(It.length===0&&Gt.length===0){const Y=Ce,z=Math.abs(U.x-V.x)<Y,tt=Math.abs(U.y-V.y)<Y,ht=Z.get(`${g}:src`)!==void 0||Z.get(`${g}:dst`)!==void 0,Tt=(((K=I.get(`${v.start??""}:${W}:src`))==null?void 0:K.length)??0)+(((Q=I.get(`${v.start??""}:${W}:dst`))==null?void 0:Q.length)??0),Ct=((($=I.get(`${v.end??""}:${ot}:src`))==null?void 0:$.length)??0)+(((q=I.get(`${v.end??""}:${ot}:dst`))==null?void 0:q.length)??0),Rt=Tt>1||Ct>1,kt=x.get(v.start??"")??0,mt=x.get(v.end??"")??0,Vt=Tt>1&&Pt(v.start,W)||Ct>1&&Pt(v.end,ot),re=Tt<=1||kt<=2,Ht=Ct<=1||mt<=2;if((z||tt)&&!ht&&(!Rt||Rt&&!Vt&&re&&Ht)&&!A(O,H,v.start,v.end)){v.points=[{...O},{...U},{...V},{...H}],p.add(g);const vt=tt?"horizontal":"vertical",Ut=tt?O.y:O.x,Lt=tt?Math.min(O.x,H.x):Math.min(O.y,H.y),Et=tt?Math.max(O.x,H.x):Math.max(O.y,H.y),Zt={id:`fast-path-${vt}-${Ut.toFixed(0)}-${g}`,orientation:vt,coord:Ut,spanMin:Lt,spanMax:Et,tracks:[]};u.push({edgeIndex:g,segmentIndex:0,orientation:vt,pipe:Zt,trackIndex:0,from:Lt,to:Et});continue}}const xn=m("vertical",U.x,U.y,U.y);U.x=xn.coord;const Mr=m("vertical",V.x,V.y,V.y);V.x=Mr.coord;let ye=Math.min(U.x,V.x)-50,pe=Math.max(U.x,V.x)+50,we=Math.min(U.y,V.y)-50,Ae=Math.max(U.y,V.y)+50;for(const Y of h){const z=Math.min(U.x,V.x),tt=Math.max(U.x,V.x),ht=Math.min(U.y,V.y),Tt=Math.max(U.y,V.y);Y.minX<tt&&Y.maxX>z&&Y.minY<Tt&&Y.maxY>ht&&(ye=Math.min(ye,Y.minX-qe),pe=Math.max(pe,Y.maxX+qe),we=Math.min(we,Y.minY-qe),Ae=Math.max(Ae,Y.maxY+qe))}for(const Y of h){if(Y.maxX<ye||Y.minX>pe||Y.maxY<we||Y.minY>Ae)continue;const z=Ce;m("horizontal",Y.minY-z,ye,pe),m("horizontal",Y.maxY+z,ye,pe);const tt=Ne;m("vertical",Y.minX-tt,we,Ae),m("vertical",Y.maxX+tt,we,Ae)}m("horizontal",U.y,ye,pe),m("horizontal",V.y,ye,pe);const Ir=d.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=we&&Y.coord<=Ae),Sr=d.filter(Y=>Y.orientation==="vertical"&&Y.coord>=ye&&Y.coord<=pe),He=f((Y,z)=>`${Y.toFixed(1)},${z.toFixed(1)}`,"getKey"),Xe=He(U.x,U.y),wo=He(V.x,V.y),Ye=new Map,bn=new Map,Mn=new Map,Ge=new Set,Se=[];Ye.set(Xe,0),Mn.set(Xe,"n"),Se.push({key:Xe,f:Math.hypot(V.x-U.x,V.y-U.y),pt:U}),Ge.add(Xe);let $t=[];const xe=f((Y,z)=>A(Y,z,v.start,v.end),"checkSegmentBlocked"),In={x:V.x,y:U.y},Cr=xe(U,In),vr=xe(In,V),Lr=Cr||vr,Sn={x:U.x,y:V.y},Er=xe(U,Sn),Tr=xe(Sn,V);if(Lr?Er||Tr||(Math.abs(U.x-V.x)<ft?$t=[U,V]:$t=[U,Sn,V]):Math.abs(U.y-V.y)<ft||Math.abs(U.x-V.x)<ft?$t=[U,V]:$t=[U,In,V],$t.length===0)for(;Se.length>0;){Se.sort((mt,Vt)=>mt.f-Vt.f);const Y=Se.shift();if(Ge.delete(Y.key),Y.key===wo){let mt=wo,Vt=V;for($t=[Vt];bn.has(mt);){const re=bn.get(mt);$t.unshift(re),Vt=re,mt=He(re.x,re.y)}break}const z=Y.pt.x,tt=Y.pt.y,ht=Sr.sort((mt,Vt)=>mt.coord-Vt.coord),Tt=ht.findIndex(mt=>Math.abs(mt.coord-z)<1),Ct=Ir.sort((mt,Vt)=>mt.coord-Vt.coord),Rt=Ct.findIndex(mt=>Math.abs(mt.coord-tt)<1),kt=[];Tt>0&&kt.push({x:ht[Tt-1].coord,y:tt}),Tt>=0&&Tt<ht.length-1&&kt.push({x:ht[Tt+1].coord,y:tt}),Rt>0&&kt.push({x:z,y:Ct[Rt-1].coord}),Rt>=0&&Rt<Ct.length-1&&kt.push({x:z,y:Ct[Rt+1].coord});for(const mt of kt){const Vt=Math.min(z,mt.x),re=Math.max(z,mt.x),Ht=Math.min(tt,mt.y),jt=Math.max(tt,mt.y);if(h.some(ne=>ne.nodeId===v.start||ne.nodeId===v.end?!1:Vt!==re?ne.minY<tt&&ne.maxY>tt&&ne.maxX>Vt&&ne.minX<re:ne.minX<z&&ne.maxX>z&&ne.maxY>Ht&&ne.minY<jt))continue;const vt=He(mt.x,mt.y),Ut=Math.abs(mt.x-z)+Math.abs(mt.y-tt),Lt=M(g,Y.pt,mt);let Et=0;const Zt=V.x-U.x,Re=V.y-U.y,$e=mt.x-z,Cn=mt.y-tt;(Re>10&&Cn<-5||Re<-10&&Cn>5)&&(Et=Math.abs(Cn)*100),(Zt>10&&$e<-5||Zt<-10&&$e>5)&&(Et+=Math.abs($e)*50);let Ao=0;const Ro=Mn.get(Y.key)??"n",No=Math.abs($e)>ft?"h":"v";Ro!=="n"&&Ro!==No&&(Ao=50);const wr=Ut+Lt+Et+Ao,ze=(Ye.get(Y.key)??1/0)+wr,Oo=Math.abs(V.x-mt.x)+Math.abs(V.y-mt.y);if(ze<(Ye.get(vt)??1/0))if(bn.set(vt,Y.pt),Ye.set(vt,ze),Mn.set(vt,No),!Ge.has(vt))Se.push({key:vt,f:ze+Oo,pt:mt}),Ge.add(vt);else{const ne=Se.findIndex(Ar=>Ar.key===vt);ne!==-1&&(Se[ne].f=ze+Oo)}}}if($t.length===0&&($t=[U,{x:U.x,y:V.y},V]),$t.length>4){const Y=$t[0],z=$t[$t.length-1];let tt=Math.min(Y.x,z.x),ht=Math.max(Y.x,z.x),Tt=Math.min(Y.y,z.y),Ct=Math.max(Y.y,z.y);for(const Ht of $t)tt=Math.min(tt,Ht.x),ht=Math.max(ht,Ht.x),Tt=Math.min(Tt,Ht.y),Ct=Math.max(Ct,Ht.y);const Rt=ht>Math.max(Y.x,z.x),kt=tt<Math.min(Y.x,z.x);if(c){const Ht=Ne;if(Rt){const jt=Math.max(Y.x,z.x),_t=Math.min(Y.y,z.y),vt=Math.max(Y.y,z.y),Ut=h.filter(Lt=>Lt.minX<jt&&Lt.maxX>jt&&Lt.minY<vt&&Lt.maxY>_t);if(Ut.length>0){let Lt=Math.max(Y.x,z.x);for(const Et of Ut){const Zt=(Et.minX+Et.maxX)/2;if(Et.visualXHalfExtent===void 0||isNaN(Et.visualXHalfExtent))continue;const Re=Zt+Et.visualXHalfExtent+Ht;Lt=Math.max(Lt,Re)}isNaN(Lt)||(ht=Lt)}}if(kt){const jt=h.filter(_t=>_t.minX<Math.min(Y.x,z.x)+Ht&&_t.minY<Math.max(Y.y,z.y)&&_t.maxY>Math.min(Y.y,z.y));if(jt.length>0){let _t=Math.min(Y.x,z.x);for(const vt of jt){const Lt=(vt.minX+vt.maxX)/2-vt.visualXHalfExtent-Ht;_t=Math.min(_t,Lt)}tt=_t}}}const mt=f(Ht=>{const jt=z.y>Y.y,_t=h.filter(Lt=>{const Et=Math.min(Y.x,z.x)<Lt.maxX&&Math.max(Y.x,z.x)>Lt.minX,Zt=Math.min(Y.y,z.y)<Lt.maxY&&Math.max(Y.y,z.y)>Lt.minY;return Et&&Zt});let vt=_t;if(c&&_t.length>0){const Lt=_t.filter(Et=>Et.minX<Ht&&Et.maxX>Ht);Lt.length>0&&(vt=Lt)}if(vt.length===0)return z.y;const Ut=Ce;if(jt){const Et=Math.max(...vt.map(Zt=>Zt.maxY))+Ut;if(Et<z.y-ft)return Et}else{const Et=Math.min(...vt.map(Zt=>Zt.minY))-Ut;if(Et>z.y+ft)return Et}return z.y},"findBestReturnY"),Vt=f(Ht=>{const jt=mt(Ht),_t={x:Ht,y:Y.y},vt={x:Ht,y:jt},Ut={x:z.x,y:jt},Lt=xe(Y,_t),Et=xe(_t,vt),Zt=xe(vt,Ut),Re=jt!==z.y?xe(Ut,z):!1;return!Lt&&!Et&&!Zt&&!Re?Math.abs(jt-z.y)<ft?[Y,_t,vt,z]:[Y,_t,vt,Ut,z]:null},"trySimplifyWithDetourX"),re=Rt&&!kt?Vt(ht):kt&&!Rt?Vt(tt):null;re&&($t=re)}const zt=[O,...It,...$t,...Gt.reverse(),H];if(zt.length>=3){const Y=zt[zt.length-1],z=zt[zt.length-2],tt=zt[zt.length-3],ht=Math.abs(tt.y-z.y)<ft&&Math.abs(z.y-Y.y)<ft,Tt=Math.abs(tt.x-z.x)<ft&&Math.abs(z.x-Y.x)<ft;if(ht){const Ct=Math.sign(z.x-tt.x),Rt=Math.sign(Y.x-tt.x);Ct!==0&&Ct===Rt&&Math.abs(z.x-tt.x)>Math.abs(Y.x-tt.x)&&zt.splice(-2,1)}else if(Tt){const Ct=Math.sign(z.y-tt.y),Rt=Math.sign(Y.y-tt.y);Ct!==0&&Ct===Rt&&Math.abs(z.y-tt.y)>Math.abs(Y.y-tt.y)&&zt.splice(-2,1)}}const fe=[zt[0]];for(let Y=1;Y<zt.length-1;Y++){if(Y===1){fe.push(zt[Y]);continue}const z=fe[fe.length-1],tt=zt[Y],ht=zt[Y+1];if(Math.abs(z.y-tt.y)<ft&&Math.abs(tt.y-ht.y)<ft){const Tt=tt.x>z.x,Ct=ht.x>tt.x;if(Tt!==Ct){fe.push(tt);continue}continue}if(Math.abs(z.x-tt.x)<ft&&Math.abs(tt.x-ht.x)<ft){const Tt=tt.y>z.y,Ct=ht.y>tt.y;if(Tt!==Ct){fe.push(tt);continue}continue}fe.push(tt)}fe.push(zt[zt.length-1]);for(let Y=0;Y<fe.length-1;Y++){const z=fe[Y],tt=fe[Y+1],ht=Math.abs(z.x-tt.x)<ft?"vertical":"horizontal",Tt=ht==="vertical"?z.x:z.y,Ct=ht==="vertical"?Math.min(z.y,tt.y):Math.min(z.x,tt.x),Rt=ht==="vertical"?Math.max(z.y,tt.y):Math.max(z.x,tt.x),kt=m(ht,Tt,Ct,Rt),mt={edgeIndex:g,segmentIndex:Y,orientation:ht,pipe:kt,trackIndex:0,from:Ct,to:Rt};u.push(mt),a[g].push(u.length-1),kt.tracks[0]||(kt.tracks[0]={index:0,coord:kt.coord,segments:[]}),kt.tracks[0].segments.push({edgeIndex:g,segmentIndex:Y,from:Ct,to:Rt})}}const J=f((g,v)=>g.from<v.to&&v.from<g.to,"segmentsOverlap"),rt=f((g,v,T,E)=>{const O=!E.segments.some(W=>(W.edgeIndex!==v.edgeIndex||W.segmentIndex!==v.segmentIndex)&&J(W,g)),H=!T.segments.some(W=>(W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex)&&J(W,v));return O&&H?(g.trackIndex=E.index,v.trackIndex=T.index,T.segments=[...T.segments.filter(W=>W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex),{edgeIndex:v.edgeIndex,segmentIndex:v.segmentIndex,from:v.from,to:v.to}],E.segments=[...E.segments.filter(W=>W.edgeIndex!==v.edgeIndex||W.segmentIndex!==v.segmentIndex),{edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ut=f(g=>{const v=g.tracks.length;return g.tracks[v]={index:v,coord:g.coord,segments:[]},v},"createNewTrack"),pt=f((g,v)=>{const T=g.pipe.tracks[g.trackIndex];T.segments=T.segments.filter(O=>O.edgeIndex!==g.edgeIndex||O.segmentIndex!==g.segmentIndex),g.trackIndex=v,g.pipe.tracks[v].segments.push({edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to})},"moveSegmentToTrack"),St=f((g,v)=>{const T=a[g.edgeIndex];for(const E of T){const O=u[E];O.pipe===g.pipe&&pt(O,v)}},"moveSegmentChainToTrack"),wt=f(g=>{const v=a[g.edgeIndex],T=v.indexOf(u.indexOf(g)),E=[];return T>0&&E.push(u[v[T-1]]),T<v.length-1&&E.push(u[v[T+1]]),E},"getAdjacentSegmentsAlongEdge"),Kt=f((g,v)=>{if(g.orientation===v.orientation)return!1;const T=g.orientation==="horizontal"?g:v,E=g.orientation==="horizontal"?v:g;return E.pipe.coord>T.from&&E.pipe.coord<T.to&&T.pipe.coord>E.from&&T.pipe.coord<E.to},"haveAnyCrossing"),qt=f((g,v)=>{for(const T of g.tracks)if(!T.segments.some(O=>(O.edgeIndex!==v.edgeIndex||O.segmentIndex!==v.segmentIndex)&&J(O,v)))return T.index;return-1},"findAvailableTrack"),Jt=f((g,v)=>{if(g.trackIndex===v.trackIndex)return J(g,v);const T=wt(g),E=wt(v);return T.some(O=>E.some(H=>Kt(O,H)))},"segmentsConflict"),se=f((g,v,T)=>{if(rt(g,v,g.pipe.tracks[g.trackIndex],v.pipe.tracks[v.trackIndex]))return;const E=qt(g.pipe,v);T(v,E!==-1?E:ut(g.pipe))},"resolveTrackConflict"),Ee=f(g=>{let v=0;for(let T=0;T<g.length;T++)for(let E=T+1;E<g.length;E++){const O=g[T],H=g[E];O.pipe===H.pipe&&Jt(O,H)&&(v++,se(O,H,St))}return v},"resolveHandleConflicts"),me=new Map,Te=f(g=>{if(me.has(g))return me.get(g);const v=a[g];if(v.length===0){const ot={dest:0,deviation:0,base:0,delta:0};return me.set(g,ot),ot}const E=u[v[0]].pipe.coord;let O=E;for(let ot=1;ot<v.length;ot++){const U=u[v[ot]];if(U.orientation==="horizontal"){const V=U.from,bt=U.to;O=Math.abs(V-E)>Math.abs(bt-E)?V:bt;break}}const H=Math.abs(O-E),W={dest:O,deviation:H,base:E,delta:O-E};return me.set(g,W),W},"getDestInfo"),mn=f(()=>{let g=0;const v=new Map;for(const[E,O]of s.entries())a[E].length!==0&&O.start&&(v.has(O.start)||v.set(O.start,[]),v.get(O.start).push(E));const T=f(E=>{const O=s[E];if(!O.start||!O.end)return 0;const H=r.get(O.start),W=r.get(O.end);if(!H||!W)return 0;const ot=(W.x??0)-(H.x??0),U=(W.y??0)-(H.y??0);return Math.abs(ot)+Math.abs(U)},"getEdgeDistance");for(const E of v.values()){E.sort((H,W)=>{const ot=Te(H),U=Te(W);if(Math.abs(ot.deviation-U.deviation)>1)return ot.deviation-U.deviation;if(Math.abs(ot.dest-U.dest)>1)return ot.dest-U.dest;const V=T(H),bt=T(W);if(Math.abs(V-bt)>1)return bt-V;const dt=a[H].length,at=a[W].length;if(dt!==at)return dt-at;if(dt===1){const st=a[H][0],It=a[W][0];if(u[st]&&u[It]){const Ft=u[st],At=u[It],Gt=Math.abs(Ft.to-Ft.from),ee=Math.abs(At.to-At.from);if(Math.abs(Gt-ee)>1)return Gt-ee}}return 0});const O=E.map(H=>u[a[H][0]]);g+=Ee(O)}return g},"fixSourceHandleCrossings"),yn=f(()=>{let g=0;const v=new Map;for(const[T,E]of s.entries())a[T].length!==0&&E.end&&(v.has(E.end)||v.set(E.end,[]),v.get(E.end).push(T));for(const T of v.values()){T.sort((O,H)=>{const W=f(V=>{const bt=a[V];if(bt.length<2)return 0;const dt=u[bt[bt.length-2]];return Math.abs(dt.to-dt.from)},"getDist"),ot=W(O),U=W(H);return Math.abs(ot-U)>.1?ot-U:O-H});const E=T.map(O=>u[a[O][a[O].length-1]]);g+=Ee(E)}return g},"fixTargetHandleCrossings"),pn=f(()=>{let g=0;for(const v of d){const T=[];for(const E of v.tracks)for(const O of E.segments){const H=a[O.edgeIndex].find(W=>u[W].segmentIndex===O.segmentIndex);H!==void 0&&T.push(u[H])}T.sort((E,O)=>E.edgeIndex-O.edgeIndex||E.segmentIndex-O.segmentIndex);for(let E=0;E<T.length;E++)for(let O=E+1;O<T.length;O++){const H=T[E],W=T[O];Jt(H,W)&&(g++,se(H,W,pt))}}return g},"fixPipeCrossings");let N=0;const _=10;for(;N<_;){let g=0;if(g+=mn(),g+=yn(),g+=pn(),g===0)break;N++}const D=new Map;for(const g of d){const v=[];g.tracks.forEach(E=>{E.segments.forEach(O=>{v.push({edgeIndex:O.edgeIndex,segmentIndex:O.segmentIndex,trackIndex:E.index,from:O.from,to:O.to})})}),v.sort((E,O)=>E.from-O.from);const T=[];if(v.length>0){let E=[v[0]],O=v[0].to;for(let H=1;H<v.length;H++){const W=v[H];W.from<O?(E.push(W),O=Math.max(O,W.to)):(T.push(E),E=[W],O=W.to)}T.push(E)}for(const E of T){const O=new Set;E.forEach(st=>O.add(st.trackIndex));const H=new Map;E.forEach(st=>{const It=Te(st.edgeIndex);H.set(st.trackIndex,(H.get(st.trackIndex)??0)+It.delta)});const W=[...O].filter(st=>(H.get(st)??0)<-1),ot=[...O].filter(st=>(H.get(st)??0)>1),U=[...O].filter(st=>Math.abs(H.get(st)??0)<=1);W.sort((st,It)=>(H.get(It)??0)-(H.get(st)??0)),ot.sort((st,It)=>(H.get(st)??0)-(H.get(It)??0));const V=f((st,It)=>{E.filter(Ft=>Ft.trackIndex===st).forEach(Ft=>{const At=p.has(Ft.edgeIndex)?g.coord:It;D.set(`${Ft.edgeIndex}-${Ft.segmentIndex}`,At)})},"assignCoord");let bt=0;for(const st of W)bt++,V(st,g.coord-bt*Tn);if(U.length===0&&O.size>0){const st=[...O].sort((At,Gt)=>Math.abs(H.get(At)??0)-Math.abs(H.get(Gt)??0))[0],It=W.indexOf(st);It!==-1&&W.splice(It,1);const Ft=ot.indexOf(st);Ft!==-1&&ot.splice(Ft,1),U.push(st)}let dt=0;for(const st of U){if(dt===0)V(st,g.coord);else{const It=dt%2===1?1:-1,Ft=Math.ceil(dt/2);V(st,g.coord+It*Ft*Tn*.5)}dt++}let at=0;for(const st of ot)at++,V(st,g.coord+at*Tn)}}for(const[g,v]of s.entries()){const T=a[g]??[];if(T.length===0)continue;const E=[],O=r.get(v.start),H=r.get(v.end),{pSrcPort:W,pDstPort:ot}=nt(g,O,H),U=T.map(dt=>{const at=u[dt],st=D.get(`${at.edgeIndex}-${at.segmentIndex}`)??at.pipe.coord;return{orient:at.orientation,coord:st,from:at.from,to:at.to}});E.push(W);for(let dt=0;dt<U.length;dt++){const at=U[dt],st=E[E.length-1],It=at.orient==="vertical"?st.y:st.x,Ft=at.orient==="vertical"?st.x:st.y,At=U[dt+1],Gt=dt<U.length-1;if(Math.abs(Ft-at.coord)>ft&&E.push(ve(at,It)),Gt&&At.orient===at.orient)if(Math.abs(at.coord-At.coord)>ft){const ee=at.orient==="vertical"?(It+At.from)/2:io(at,At);E.push(ve(at,ee),ve(At,ee))}else(dt===0||dt===U.length-2)&&E.push(ve(at,io(at,At)));else if(Gt)E.push(ve(at,At.coord));else{const ee=Math.abs(at.from-It)<Math.abs(at.to-It)?at.to:at.from;E.push(ve(at,ee))}}const V=E[E.length-1];(Math.abs(V.x-ot.x)>ft||Math.abs(V.y-ot.y)>ft)&&E.push(ot);const bt=[];E.length>0&&bt.push(E[0]);for(let dt=1;dt<E.length;dt++){const at=E[dt],st=bt[bt.length-1];(Math.abs(at.x-st.x)>ft||Math.abs(at.y-st.y)>ft)&&bt.push(at)}v.points=bt}for(const g of s){const v=g.__originalEdge;v&&g.points&&(v.points=g.points)}t.edges=(t.edges??[]).filter(g=>!g.isLayoutOnly);const j=f((g,v)=>{const T=v.x??0,E=v.y??0,O=v.width??0,H=v.height??0;if(O<=0||H<=0)return g;const W=T-O/2,ot=T+O/2,U=E-H/2,V=E+H/2;if(g.x<W||g.x>ot||g.y<U||g.y>V)return g;const bt=g.x-W,dt=ot-g.x,at=g.y-U,st=V-g.y,It=Math.min(bt,dt,at,st);return It===bt?{x:W,y:g.y}:It===dt?{x:ot,y:g.y}:It===at?{x:g.x,y:U}:{x:g.x,y:V}},"nodeBoundaryClamp");for(const g of t.edges){const v=g.points;if(!v||v.length<2)continue;const T=g.start,E=g.end,O=T?r.get(T):void 0,H=E?r.get(E):void 0;O&&(v[0]=j(v[0],O)),H&&(v[v.length-1]=j(v[v.length-1],H))}return t}f(pr,"routeEdgesOrthogonal");function xr(t){return t.direction??"TB"}f(xr,"getSwimlaneDirection");function br(t){var h,m,b,y,u;const e=es(t),n=((h=t.config.flowchart)==null?void 0:h.nodeSpacing)??40,o=((m=t.config.flowchart)==null?void 0:m.rankSpacing)??100,s=((b=t.config.swimlane)==null?void 0:b.ignoreCrossLaneEdges)??!0,r=((y=t.config.swimlane)==null?void 0:y.optimizeRanksByCrossings)??!0,i=((u=t.config.swimlane)==null?void 0:u.automaticLaneOrdering)??!1,d=xr(t),{ordered:c,coordinates:l}=yr(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:i,direction:d});ns(e,c,l,{nodeGap:n,layerGap:o});for(const a of t.edges??[])delete a.points;pr(t,d);for(const a of t.edges??[])(!a.curve||a.curve==="basis")&&(a.curve="rounded");return Ps(t,d),Bs(t),d}f(br,"runSwimlaneLayoutCore");async function oi(t,e){const n=e.select("g");Or(n,t.markers,t.type,t.diagramId),Br(),Pr(),Fr(),Nr(),ts(t);const o=os(t);t.nodes=o.nodes,t.edges=o.edges;const{groups:s}=await Xo(n,t);br(t),await Jo(t,s)}f(oi,"render");export{oi as render};
1
+ import{_ as Rr}from"./index-ca784d3e.js";import{c as Nr}from"./chunk-RYQCIY6F-e7692d7b.js";import{_ as f,ar as Or,as as Br,at as Pr,au as Fr,d as kr,ah as _r,aB as Bo,ag as Dr,ai as Hr,ay as Xr,aA as Yr,G as Gr,ax as $r,aC as zr,u as ke,l as Qe,aD as Ve}from"./mermaid.core-da5e1357.js";import{G as Vr}from"./graph-7008991d.js";import"./map-338884f0.js";async function Xo(t,e){const n=new Vr({multigraph:!0,compound:!0}),o=[...e.edges],s=kr(),r=t.insert("g").attr("class","root"),i=r.insert("g").attr("class","clusters"),d=r.insert("g").attr("class","edges edgePath"),c=r.insert("g").attr("class","edgeLabels"),l=r.insert("g").attr("class","nodes"),h=new Map,m=t.node()!=null;await Promise.all(e.nodes.map(async b=>{var y;if(b.isGroup)n.setNode(b.id,{...b});else{if(m){const u=await _r(l,b,{config:s,dir:b.dir}),a=((y=u.node())==null?void 0:y.getBBox())??{width:0,height:0};h.set(b.id,u),b.width=a.width,b.height=a.height}n.setNode(b.id,{...b})}}));for(const b of o)n.setEdge(b.start,b.end,{...b},b.id),e.edges.some(u=>u.id===b.id)||e.edges.push(b);if(globalThis.mermaidCaptureSizes){const{captureNodeSizes:b}=await Rr(()=>import("./sizeCapture-X5ZJPWSS-9120b239.js"),["assets/sizeCapture-X5ZJPWSS-9120b239.js","assets/mermaid.core-da5e1357.js","assets/index-ca784d3e.js","assets/index-8f7bf650.css"]);b(t,e)}return{graph:n,groups:{clusters:i,edgePaths:d,edgeLabels:c,nodes:l,rootGroups:r},nodeElements:h}}f(Xo,"createGraphWithElements");var Po=5,je=1e-5,Ue=1e-6;function tn(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}f(tn,"buildSegmentList");function Yo(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=o.x-n.x,d=o.y-n.y,c=s*d-r*i;if(c===0)return null;const l=n.x-t.x,h=n.y-t.y,m=(l*d-h*i)/c,b=(l*r-h*s)/c;return m<=Ue||m>=1-Ue||b<=Ue||b>=1-Ue?null:{point:{x:t.x+m*s,y:t.y+m*r},tA:m,tB:b}}f(Yo,"segmentIntersection");function wn(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}f(wn,"isHorizontalSeg");function Go(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=tn(o.points);for(let r=n+1;r<t.length;r++){const i=t[r],d=tn(i.points);for(const[c,l]of s.entries())for(const[h,m]of d.entries()){const b=Yo(l.a,l.b,m.a,m.b);if(!b)continue;const y=wn(l),u=wn(m);(y!==u?y:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:i.id,segIndex:c,t:b.tA,point:b.point}):e.push({jumpEdgeId:i.id,otherEdgeId:o.id,segIndex:h,t:b.tB,point:b.point})}}}return e}f(Go,"findEdgeIntersections");function le(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}f(le,"fmt");function Oe(t){return`${le(t.x)},${le(t.y)}`}f(Oe,"pointToString");function $o(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}f($o,"getArcSweepFlag");var jr=.001;function zo(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&Bo[e.arrowTypeStart];if(o){const r=t[0],i=t[1],d=Math.atan2(i.y-r.y,i.x-r.x);n[0].x=r.x+o*Math.cos(d),n[0].y=r.y+o*Math.sin(d)}const s=e.arrowTypeEnd&&Bo[e.arrowTypeEnd];if(s){const r=t.length,i=t[r-2],d=t[r-1],c=Math.atan2(d.y-i.y,d.x-i.x);n[r-1].x=d.x-s*Math.cos(c),n[r-1].y=d.y-s*Math.sin(c)}return n}f(zo,"applyMarkerOffsets");function Vo(t,e,n,o,s){const r=t.point.x,i=t.point.y,d={x:r-e*t.r,y:i-n*t.r},c={x:r+e*t.r,y:i+n*t.r},l=[`L${Oe(d)}`];return s==="arc"?l.push(`A${le(t.r)},${le(t.r)} 0 0 ${o} ${Oe(c)}`):l.push(`M${Oe(c)}`),l}f(Vo,"emitJump");function An(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=n.x-e.x,d=n.y-e.y,c=Math.hypot(s,r),l=Math.hypot(i,d);if(c<je||l<je)return null;const h=s/c,m=r/c,b=i/l,y=d/l,u=h*b+m*y,a=Math.max(-1,Math.min(1,u)),p=Math.acos(a);if(p<je||Math.abs(Math.PI-p)<je)return null;const C=Math.min(o/Math.sin(p/2),c/2,l/2);return{startX:e.x-h*C,startY:e.y-m*C,endX:e.x+b*C,endY:e.y+y*C,ctrlX:e.x,ctrlY:e.y,cutLen:C}}f(An,"computeRoundedCorner");function jo(t,e,n){const o=t.points;if(o.length<2)return"";const s=zo(o,t),r=t.curve==="rounded",i=tn(s),d=new Map;for(const l of e){const h=i[l.segIndex];if(!h)continue;const m=Math.hypot(h.b.x-h.a.x,h.b.y-h.a.y),b=d.get(l.segIndex)??[];b.push({t:l.t,point:l.point,d:l.t*m,r:n.jumpRadius}),d.set(l.segIndex,b)}const c=[`M${Oe(s[0])}`];for(let l=0;l<i.length;l++){const h=i[l],m=Math.hypot(h.b.x-h.a.x,h.b.y-h.a.y),b=m===0?0:(h.b.x-h.a.x)/m,y=m===0?0:(h.b.y-h.a.y)/m,u=$o(h);let a=0;if(r&&l>0){const S=An(s[l-1],s[l],s[l+1]??s[l],Po);S&&(a=S.cutLen)}let p=m,C=null;r&&l<i.length-1&&(C=An(s[l],s[l+1],s[l+2]??s[l+1],Po),C&&(p=m-C.cutLen));const M=[...d.get(l)??[]].sort((S,A)=>S.t-A.t);for(const S of M)S.r=Math.min(S.r,S.d-a,p-S.d);for(let S=0;S<M.length-1;S++){const A=M[S+1].d-M[S].d;if(M[S].r+M[S+1].r>A){const I=A/2;M[S].r=Math.min(M[S].r,I),M[S+1].r=Math.min(M[S+1].r,I)}}for(const S of M)S.r<jr||c.push(...Vo(S,b,y,u,n.jumpStyle));r&&C?(c.push(`L${le(C.startX)},${le(C.startY)}`),c.push(`Q${le(C.ctrlX)},${le(C.ctrlY)} ${le(C.endX)},${le(C.endY)}`)):c.push(`L${Oe(h.b)}`)}return c.join(" ")}f(jo,"rewriteEdgePath");function Uo(t){return/^[\d\s+,.LMelm-]*$/.test(t)}f(Uo,"isStraightPath");function Wo(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}f(Wo,"curveSupportsLineHops");function Ko(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}f(Ko,"decodeDataPoints");function qo(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const l of e)s.set(l.id,l);const r=[],i=new Map;for(const l of e){const h=typeof CSS<"u"&&CSS.escape?CSS.escape(l.id):l.id,m=o.querySelector(`path[data-id="${h}"]`);if(!m)continue;i.set(l.id,m);const y=Ko(m.getAttribute("data-points"))??l.points;r.push({...l,points:y})}const d=Go(r);if(d.length===0)return;const c=new Map;for(const l of d){const h=c.get(l.jumpEdgeId)??[];h.push(l),c.set(l.jumpEdgeId,h)}for(const l of r){const h=c.get(l.id);if(!h||h.length===0)continue;const m=s.get(l.id),b=m==null?void 0:m.curve;if(b!==void 0&&!Wo(b))continue;const y=i.get(l.id);if(!y)continue;if(b===void 0){const S=y.getAttribute("d")??"";if(!Uo(S))continue}const u=y.getAttribute("style")??"",a=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(u),p=a?Number.parseFloat(a[1]):null,C=a?Number.parseFloat(a[2]):null,M=jo(l,h,n);if(y.setAttribute("d",M),p!==null&&C!==null&&typeof y.getTotalLength=="function"){const S=y.getTotalLength(),A=Math.max(0,S-p-C),I=`0 ${p} ${A} ${C}`,x=u.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${I};`).replace(/;\s*;+/g,";");y.setAttribute("style",x)}}}f(qo,"applyLineJumpsToSvg");async function Jo(t,e){var s,r;for(const i of t.nodes)i.isGroup?await Dr(e.clusters,i):Hr(i);const n=new Map;for(const i of t.nodes)i!=null&&i.id&&n.set(i.id,i);for(const i of t.edges){const d=i.start?n.get(i.start)??{}:{},c=i.end?n.get(i.end)??{}:{},l=Xr(e.edgePaths,{...i},{},t.type,d,c,t.diagramId);i.label&&await Yr(e.rootGroups,i),i.label&&Zo(i,l)}const o=(r=(s=t.config)==null?void 0:s.swimlane)==null?void 0:r.lineHops;if(o!==!1){const i=o==="gap"?"gap":"arc",d=t.edges.filter(c=>Array.isArray(c.points)&&c.points.length>=2).map(c=>({id:c.id,points:c.points,curve:c.curve,arrowTypeStart:c.arrowTypeStart,arrowTypeEnd:c.arrowTypeEnd}));qo(e.edgePaths,d,{enabled:!0,jumpRadius:6,jumpStyle:i})}}f(Jo,"adjustLayout");function Zo(t,e){const n=(e==null?void 0:e.updatedPath)??(e==null?void 0:e.originalPath),o=Gr(),{subGraphTitleTotalMargin:s}=$r({flowchart:o.flowchart??{}});if(t.label){const r=zr.get(t.id);let i=t.x,d=t.y;if(n){const c=ke.calcLabelPosition(n);Qe.debug("Moving label "+t.label+" from (",i,",",d,") to (",c.x,",",c.y,") abc88"),e&&(i=c.x,d=c.y)}r.attr("transform",`translate(${i}, ${d+s/2})`)}if(t!=null&&t.startLabelLeft){const r=Ve.get(t.id).startLeft;let i=t==null?void 0:t.x,d=t==null?void 0:t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_left",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}if(t.startLabelRight){const r=Ve.get(t.id).startRight;let i=t.x,d=t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_right",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}if(t.endLabelLeft){const r=Ve.get(t.id).endLeft;let i=t.x,d=t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_left",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}if(t.endLabelRight){const r=Ve.get(t.id).endRight;let i=t.x,d=t.y;if(n){const c=ke.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_right",n);i=c.x,d=c.y}r.attr("transform",`translate(${i}, ${d})`)}}f(Zo,"positionEdgeLabel");var vn="__swimlane_default__",Ur=21,Fo=20;function Rn(t){return Math.max(t.padding??Fo,Fo)}f(Rn,"topLaneHorizontalPadding");function Qo(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 i=n-s/2,d=Math.min(r,n+s/2),c=Math.min(Ur,Math.max(0,d-i)),l=i+c;if(l<=i){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:i,bottom:l}}f(Qo,"assignTopLaneTitleRect");function ts(t){const e=t.direction,n=t.nodes??(t.nodes=[]);for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===vn);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:vn,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=vn}f(ts,"prepareLayoutForSwimlanes");function es(t){const e=new Map;for(const c of t.nodes??[])e.set(c.id,c);const n=[];for(const c of t.edges??[]){const l=typeof c.start=="string"?c.start:void 0,h=typeof c.end=="string"?c.end:void 0;!l||!h||c.labelNodeId||n.push({id:c.id,src:l,dst:h,ref:c})}const o=t.nodes??[],s=o.filter(c=>c.isGroup),r=o.filter(c=>!c.isGroup);return{nodes:[...[...s].reverse(),...r].map(c=>c.id),edges:n,layout:t,nodeById:e}}f(es,"toGraphView");function ns(t,e,n,o){const{layout:s}=t,r=t.nodeById,i=(o==null?void 0:o.layerGap)??100,d=(o==null?void 0:o.nodeGap)??40;let c=0;for(const b of e.layers){let y=0;for(const u of b){const a=r.get(u);if(!a){y++;continue}a.layer=c,a.order=y;const p=n.x[u]??y*d,C=n.y[u]??c*i;a.x=p,a.y=C,y++}c++}const l=s.nodes??[],h=new Map,m=[];for(const b of l){if(!(b!=null&&b.isGroup))continue;b.parentId||m.push(b);const y=l.filter(M=>M.parentId===b.id);let u=1/0,a=-1/0,p=1/0,C=-1/0;for(const M of y){const S=M.x??n.x[M.id],A=M.y??n.y[M.id],I=M.width??0,x=M.height??0;S!=null&&A!=null&&(u=Math.min(u,S-I/2),a=Math.max(a,S+I/2),p=Math.min(p,A-x/2),C=Math.max(C,A+x/2))}if(u===1/0||p===1/0)b.x=b.x??0,b.y=b.y??0,b.width=b.width??0,b.height=b.height??0;else{const M=b.padding??20,S=b.parentId?M:2*Rn(b),A=M,I=Math.max(0,a-u)+S,x=Math.max(0,C-p)+A,L=(u+a)/2,R=(p+C)/2;b.x=L,b.y=R,b.width=I,b.height=x,h.set(b.id,{minX:u,maxX:a,minY:p,maxY:C})}}if(m.length>0&&h.size>0){let b=1/0,y=-1/0,u=0;for(const a of m){const p=a.padding??20;p>u&&(u=p);const C=h.get(a.id);C&&(b=Math.min(b,C.minY),y=Math.max(y,C.maxY))}if(b!==1/0&&y!==-1/0){const a=Math.max(0,y-b),C=Math.max(u,36),M=a+2*C,S=(b+y)/2;for(const P of m)P.y=S,P.height=M,P.swimlaneContentTop=b;const A=[...m].sort((P,w)=>{const F=P.x??0,k=w.x??0;return F-k}),I=[],x=[],L=[];for(const P of A){const w=h.get(P.id);if(!w)continue;const F=Math.max(0,w.maxX-w.minX)+2*Rn(P),k=(w.minX+w.maxX)/2;I.push(P.id),x.push(k),L.push(F)}const R=I.length;if(R>0){const P=new Map;if(R===1)P.set(I[0],L[0]);else{const w=[];for(let G=0;G<R-1;G++)w.push(x[G+1]-x[G]);const F=new Array(R);F[0]=0;for(let G=0;G<R-1;G++)F[G+1]=2*w[G]-F[G];let k=0,B=Number.POSITIVE_INFINITY;for(let G=0;G<R;G++){const Z=L[G];G%2===0?k=Math.max(k,Z-F[G]):B=Math.min(B,F[G]-Z)}let X=k;k<=B?X=(k+B)/2:X=k;for(let G=0;G<R;G++){const Z=F[G]+(G%2===0?X:-X),ct=Math.max(L[G],Z);P.set(I[G],ct)}}for(const w of m){const F=P.get(w.id);F!=null&&(w.width=F),Qo(w)}}}}}f(ns,"writeBackToLayoutData");var Wr="[EdgeLabelNodes]";function os(t){const e=[],n=[],o=new Map;for(const i of t.nodes)o.set(i.id,i);for(const i of t.edges){if(!i.label||i.label.length===0||i.isLayoutOnly||i.labelNodeId)continue;const d=i.start?o.get(i.start):void 0,c=i.end?o.get(i.end):void 0;if(!d||!c){Qe.warn(Wr,`Edge ${i.id} has missing source or target node`);continue}const l=`edge-label-${i.start}-${i.end}-${i.id}`,m=d.parentId!==c.parentId?c.parentId:d.parentId,b={id:l,label:i.label,edgeStart:i.start??"",edgeEnd:i.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:m,isGroup:!1,labelStyle:Array.isArray(i.labelStyle)?i.labelStyle[0]:i.labelStyle??"",...d.dir?{dir:d.dir}:{}};e.push(b),i.labelNodeId=l,i.label=void 0,i.text=void 0;const y={id:`${i.id}-to-label`,start:i.start,end:l,type:"normal",isLayoutOnly:!0},u={id:`${i.id}-from-label`,start:l,end:i.end,type:"normal",isLayoutOnly:!0};n.push(y,u)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}f(os,"createEdgeLabelNodes");var Yt=.001;function co(t){const e=t.x??0,n=t.y??0,o=t.width??0,s=t.height??0;return o>0&&s>0?{cx:e,cy:n,rect:Be(e,n,o,s)}:void 0}f(co,"measuredNodeRect");function ao(t){if(t.isGroup)return;const e=co(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}f(ao,"nodeBoundsInfoFor");function ce(t,e,n=Yt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}f(ce,"samePoint");function gt(t,e,n=Yt){return Math.abs(t.x-e.x)<n}f(gt,"sameX");function yt(t,e,n=Yt){return Math.abs(t.y-e.y)<n}f(yt,"sameY");function Nt(t,e,n=Yt){return yt(t,e,n)&&Math.abs(t.x-e.x)>n}f(Nt,"isHorizontalSegment");function Ot(t,e,n=Yt){return gt(t,e,n)&&Math.abs(t.y-e.y)>n}f(Ot,"isVerticalSegment");function Wt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}f(Wt,"overlapLength");function de(t,e,n=Yt){return t.horizontal&&e.horizontal&&yt(t.a,e.a,n)?Wt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&gt(t.a,e.a,n)?Wt(t.a.y,t.b.y,e.a.y,e.b.y):0}f(de,"sameAxisSegmentOverlapLength");function Pe(t,e=Yt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],i=Nt(s,r,e),d=Ot(s,r,e);(i||d)&&n.push({index:o,a:s,b:r,horizontal:i,vertical:d})}return n}f(Pe,"orthogonalSegmentsForPoints");function oe(t,e=Yt){const n=Pe(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}f(oe,"countOrthogonalBends");function xt(t,e=Yt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ce(s,o,e))&&n.push({x:o.x,y:o.y})}return n}f(xt,"dedupeConsecutivePoints");function lo(t,e=Yt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Nt(n,o,e)&&Ot(o,s,e)&&Nt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Ot(n,o,e)&&Nt(o,s,e)&&Ot(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}f(lo,"classifyThreeSegmentRoute");function dn(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),i=Math.min(t.y,e.y),d=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&d>n.top-o&&i<n.bottom+o}f(dn,"segmentBoundsOverlapRect");function fo(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}f(fo,"pointInsideRect");function ss(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}f(ss,"rectContainsRect");function en(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}f(en,"rectsOverlap");function Nn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}f(Nn,"inflateRect");function Be(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}f(Be,"rectFromCenterSize");function te(t){var e;return(e=co(t))==null?void 0:e.rect}f(te,"rectOfNodeBounds");function Le(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}f(Le,"portForRectSide");function uo(t,e,n,o,s,r=Yt){const i=e==="left"||e==="right",d=o==="left"||o==="right";if(i&&d){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(yt(t,n,r))return[t,n];const m=(t.x+n.x)/2;return[t,{x:m,y:t.y},{x:m,y:n.y},n]}if(e===o){if(yt(t,n,r))return;const m=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:m,y:t.y},{x:m,y:n.y},n]}return}if(!i&&!d){if(e===o){if(gt(t,n,r))return;const b=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:b},{x:n.x,y:b},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(gt(t,n,r))return[t,n];const m=(t.y+n.y)/2;return[t,{x:t.x,y:m},{x:n.x,y:m},n]}if(i&&!d){const h=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,m=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return h&&m?[t,{x:n.x,y:t.y},n]:void 0}const c=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,l=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return c&&l?[t,{x:t.x,y:n.y},n]:void 0}f(uo,"buildOrthogonalPortPath");function ho(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}f(ho,"buildSameSideTrackPath");function un(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=ao(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}f(un,"collectRealNodeBounds");function Me(t){const e=[],n=[];for(const o of t){const s=ao(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}f(Me,"collectNodeRectEntries");function rs(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,i=o.width??0,d=o.height??0;n.push({nodeId:o.id,...Be(s,r,i,d)})}return n}f(rs,"collectLayoutNodeRects");function go(t,e,n=Yt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),i=e.get(s);if(!(!r||!i))return{srcId:o,dstId:s,srcInfo:r,dstInfo:i,collinearX:Math.abs(r.cx-i.cx)<n,collinearY:Math.abs(r.cy-i.cy)<n}}f(go,"getNodePairGeometry");function Bt(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&dn(t,e,r.rect,-s))return!0;return!1}f(Bt,"segmentHitsAnyRect");function mo(t,e,n,o,s=Yt,r=1e-6){const i=yt(t,e,s),d=gt(t,e,s),c=yt(n,o,s),l=gt(n,o,s);if(i&&c||d&&l||!(i||d)||!(c||l))return!1;const h=i?{a:t,b:e}:{a:n,b:o},m=d?{a:t,b:e}:{a:n,b:o},b=h.a.y,y=Math.min(h.a.x,h.b.x),u=Math.max(h.a.x,h.b.x),a=m.a.x,p=Math.min(m.a.y,m.b.y),C=Math.max(m.a.y,m.b.y);if(a<y||a>u||b<p||b>C)return!1;const M=Math.abs(a-h.a.x)<r&&Math.abs(b-h.a.y)<r||Math.abs(a-h.b.x)<r&&Math.abs(b-h.b.y)<r,S=Math.abs(a-m.a.x)<r&&Math.abs(b-m.a.y)<r||Math.abs(a-m.b.x)<r&&Math.abs(b-m.b.y)<r;return!(M&&S)}f(mo,"orthogonalSegmentsCross");function is(t,e,n,o,s=Yt){const r=yt(t,e,s),i=gt(t,e,s),d=yt(n,o,s),c=gt(n,o,s);return i&&c&&gt(t,n,s)?Wt(t.y,e.y,n.y,o.y)>s:r&&d&&yt(t,n,s)?Wt(t.x,e.x,n.x,o.x)>s:!1}f(is,"sameAxisSegmentsOverlap");function nn(t,e,n,o,{epsilon:s=Yt,skipDegenerateOther:r=!1}={}){for(const i of n){if(i===o||i.isLayoutOnly)continue;const d=i.points;if(!(!d||d.length<2))for(let c=0;c<d.length-1;c++){const l=d[c],h=d[c+1];if(!(r&&ce(l,h,s))&&(mo(t,e,l,h,s)||is(t,e,l,h,s)))return!0}}return!1}f(nn,"segmentConflictsWithAnyEdge");function he(t,e,n,o,s=Yt){const r=yt(t,e,s),i=gt(t,e,s),d=yt(n,o,s),c=gt(n,o,s);if(!(r&&c||i&&d))return!1;const l=r?{a:t,b:e}:{a:n,b:o},h=r?{a:n,b:o}:{a:t,b:e},m=l.a.y,b=Math.min(l.a.x,l.b.x),y=Math.max(l.a.x,l.b.x),u=h.a.x,a=Math.min(h.a.y,h.b.y),p=Math.max(h.a.y,h.b.y);return u>b+s&&u<y-s&&m>a+s&&m<p-s}f(he,"orthogonalSegmentsStrictlyCross");function On(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Yt&&t<s-Yt}f(On,"strictlyBetween");function cs(t,e,n){return gt(t,e)&&gt(e,n)?On(e.y,t.y,n.y):yt(t,e)&&yt(e,n)?On(e.x,t.x,n.x):!1}f(cs,"isCollinearIntermediate");function as(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],i=o+1<t.length?t[o+1]:void 0;if(s&&i){if(ce(s,i)){o++,e=!0;continue}if(cs(s,r,i)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}f(as,"simplifyPolylineOnce");function on(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!gt(s,r)&&!yt(s,r)){const i=e.length>=2?e[e.length-2]:void 0,c=(i?gt(i,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(c)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ce(s,o))&&n.push(o)}return n}f(on,"orthogonalizePolyline");function ue(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=as(e);if(e=o.points,!o.changed)break}return e}f(ue,"simplifyPolyline");var it=.001,Kr=.5,ko=4;function yo(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?te(s):void 0,dstRect:r?te(r):void 0}}f(yo,"endpointContextFor");function ls(t,e,n){if(yt(t,e,it))return{x:t.x<n.left?n.left:n.right,y:t.y};if(gt(t,e,it)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}f(ls,"segmentEnterPoint");function Bn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&fo(t[s],e,Kr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const i=ls(t[s],t[r],e);return n?[i,...t.slice(s)]:[...t.slice(0,s+1),i]}f(Bn,"clipEndpoint");function fs(t,e){for(const n of t){const o=yo(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=Bn(s,o.srcRect,!0)),o.dstRect&&(s=Bn(s,o.dstRect,!1)),s=ue(on(s)),s=po(s,o.srcRect,o.dstRect),o.edge.points=ue(on(s))}}f(fs,"clipEdgeEndpointsToNodeBoundaries");function Pn(t,e,n,o=!1){if(yt(t,e,it)){if(e.y<n.top-it||e.y>n.bottom+it)return e;if(o){if(t.x<n.left-it)return{x:n.left,y:t.y};if(t.x>n.right+it)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(gt(t,e,it)){if(e.x<n.left-it||e.x>n.right+it)return e;if(o){if(t.y<n.top-it)return{x:t.x,y:n.top};if(t.y>n.bottom+it)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}f(Pn,"snapEndpointToBoundary");function sn(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ce(r,o,it))return r}return t[e+n]}f(sn,"firstDistinctAdjacent");function rn(t,e){const n=t+ko,o=e-ko;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}f(rn,"cornerClearanceRange");function Fn(t,e,n){const{lo:o,hi:s}=rn(e,n);return Math.min(s,Math.max(o,t))}f(Fn,"clampToCornerClearance");function ds(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}f(ds,"intersectRanges");function kn(t,e){return e==="left"||e==="right"?rn(t.top,t.bottom):rn(t.left,t.right)}f(kn,"clearanceRangeForSide");function cn(t,e,n){const o=t.y>=n.top-it&&t.y<=n.bottom+it,s=t.x>=n.left-it&&t.x<=n.right+it;if(yt(t,e,it)&&o){if(Math.abs(t.x-n.left)<it)return"left";if(Math.abs(t.x-n.right)<it)return"right"}if(gt(t,e,it)&&s){if(Math.abs(t.y-n.top)<it)return"top";if(Math.abs(t.y-n.bottom)<it)return"bottom"}}f(cn,"terminalSideForSegment");function _e(t){return t==="left"||t==="right"}f(_e,"isHorizontalSide");function us(t,e,n,o,s){const r=[],i=n?cn(t,e,n):void 0,d=o?cn(e,t,o):void 0;return n&&i&&_e(i)===s&&r.push(kn(n,i)),o&&d&&_e(d)===s&&r.push(kn(o,d)),r.length>0?ds(r):void 0}f(us,"straightClearanceRange");function _n(t,e,n,o,s){const r=us(t,e,n,o,s);if(!r)return;const i=s?t.y:t.x,d=Math.min(r.hi,Math.max(r.lo,i));if(!(Math.abs(d-i)<it))return s?[{x:t.x,y:d},{x:e.x,y:d}]:[{x:d,y:t.y},{x:d,y:e.y}]}f(_n,"clearStraightEndpointCornerAxis");function po(t,e,n){if(t.length!==2)return t;const[o,s]=t;return yt(o,s,it)?_n(o,s,e,n,!0)??t:gt(o,s,it)?_n(o,s,e,n,!1)??t:t}f(po,"clearStraightEndpointCornerConnections");function hs(t,e,n){return _e(n)?{x:t.x,y:Fn(t.y,e.top,e.bottom)}:{x:Fn(t.x,e.left,e.right),y:t.y}}f(hs,"cornerClearedEndpoint");function gs(t,e,n,o,s,r){const i=t.map(d=>({...d}));for(let d=e;d>=0&&d<t.length;d+=n){const c=t[d];if(r&&!yt(c,o,it)||!r&&!gt(c,o,it))break;r?i[d].y=s.y:i[d].x=s.x}return i}f(gs,"moveCollinearEndpointRun");function Dn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],i=sn(t,o,s);if(!i)return t;const d=cn(r,i,e);if(!d)return t;const c=_e(d),l=hs(r,e,d);return ce(r,l,it)?t:gs(t,o,s,r,l,c)}f(Dn,"clearEndpointCornerConnection");function Hn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-it&&Math.max(t.x,e.x)<=n.right+it,s=Math.min(t.y,e.y)>=n.top-it&&Math.max(t.y,e.y)<=n.bottom+it;if(Math.abs(t.y-n.top)<it&&Math.abs(e.y-n.top)<it&&o)return"top";if(Math.abs(t.y-n.bottom)<it&&Math.abs(e.y-n.bottom)<it&&o)return"bottom";if(Math.abs(t.x-n.left)<it&&Math.abs(e.x-n.left)<it&&s)return"left";if(Math.abs(t.x-n.right)<it&&Math.abs(e.x-n.right)<it&&s)return"right"}f(Hn,"borderSideForSegment");function Xn(t,e,n,o){switch(t){case"top":return gt(e,n,it)&&n.y<o.top-it;case"bottom":return gt(e,n,it)&&n.y>o.bottom+it;case"left":return yt(e,n,it)&&n.x<o.left-it;case"right":return yt(e,n,it)&&n.x>o.right+it}}f(Xn,"leavesOutward");function Yn(t,e,n){if(t.length<3)return t;if(n){const r=Hn(t[0],t[1],e);return r&&Xn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Hn(t[o-1],t[o],e);return s&&Xn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}f(Yn,"collapseOwnBorderStub");function ms(t,e,n){let o=t;if(e){const r=sn(o,0,1);if(r){const i=Pn(r,o[0],e);i!==o[0]&&(o=[i,...o.slice(1)])}o=Yn(o,e,!0)}if(n){const r=o.length-1,i=sn(o,r,-1);if(i){const d=Pn(i,o[r],n,!0);d!==o[r]&&(o=[...o.slice(0,r),d])}o=Yn(o,n,!1)}const s=po(o,e,n);return s!==o||o.length===2?s:(e&&(o=Dn(o,e,!0)),n&&(o=Dn(o,n,!1)),o)}f(ms,"snapAndCollapseEndpoints");function Gn(t,e){for(const n of t){const o=yo(n,e,2);if(!o)continue;const s=xt(o.points,it),r=ms(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const i=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=i}}f(Gn,"prepareEdgeEndpointsForRenderer");function xo(t){return new Map(t.map(e=>[e.id,e]))}f(xo,"buildNodeMap");function ys(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!(s!=null&&s.isGroup))break;o=s.id,n=s.parentId}return o}f(ys,"resolveTopLevelGroupId");function $n(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!(s!=null&&s.isGroup))break;n++,o=s.parentId}return n}f($n,"groupDepth");function bo(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const i=r.x,d=r.y;if(typeof i!="number"||typeof d!="number")continue;const c=r.width??0,l=r.height??0;e=Math.min(e,i-c/2),n=Math.max(n,i+c/2),o=Math.min(o,d-l/2),s=Math.max(s,d+l/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}f(bo,"boundsForChildren");function ps(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}f(ps,"applyGroupBounds");function xs(t){const e=xo(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>$n(s,e)-$n(o,e));for(const o of n){const s=t.filter(i=>i.parentId===o.id),r=bo(s);r&&ps(o,r)}}f(xs,"recomputeNestedGroupBounds");function an(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(c=>!c.isGroup);let r=1/0,i=-1/0;for(const c of s){const l=c[e];typeof l=="number"&&(r=Math.min(r,l),i=Math.max(i,l))}if(!Number.isFinite(r)||!Number.isFinite(i))return!1;const d=f(c=>r+i-c,"mirror");for(const c of n){const l=c[e];typeof l=="number"&&(c[e]=d(l));const h=c.groupTitleRect;h&&(c.groupTitleRect=e==="x"?{...h,left:d(h.right),right:d(h.left)}:{...h,top:d(h.bottom),bottom:d(h.top)})}for(const c of o)for(const l of c.points??[])l[e]=d(l[e]);return!0}f(an,"mirrorAxis");function bs(t){return(t.nodes??[]).some(n=>!n.isGroup)?an(t,"y"):!0}f(bs,"applyBtDirectionTransform");function Ms(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(B=>!B.isGroup);let r=1/0,i=1/0;for(const B of s){const X=B.x??0,G=B.y??0;X<r&&(r=X),G<i&&(i=G)}if(!Number.isFinite(r)||!Number.isFinite(i))return!1;const d=36;let c=0,l=0;for(const B of s)c+=B.width??0,l+=B.height??0;const h=c/s.length,m=l/s.length,b=m>0?Math.max(1,h/m):1;for(const B of s){const X=B.x??0,Z=((B.y??0)-i)*b+d,ct=X-r;B.x=Z,B.y=ct}for(const B of o)if(B.points)for(const X of B.points){const G=X.x,ct=(X.y-i)*b+d,Mt=G-r;X.x=ct,X.y=Mt}xs(n);const y=n.filter(B=>B.isGroup&&!B.parentId);if(y.length===0)return e==="RL"&&an(t,"x"),!0;const u=xo(n),a=new Map;for(const B of n){if(B.isGroup)continue;const X=ys(B,u);if(!X)continue;const G=a.get(X)??[];G.push(B),a.set(X,G)}let p=0;for(const B of y){const X=B.padding??0;X>p&&(p=X)}const C=[];let M=1/0,S=-1/0;for(const B of y){const X=a.get(B.id)??[],G=bo(X);G&&(M=Math.min(M,G.minX),S=Math.max(S,G.maxX),C.push({lane:B,contentTop:G.minY,contentBottom:G.maxY,centerY:(G.minY+G.maxY)/2}))}if(M===1/0||S===-1/0)return!0;const A=Math.max(0,S-M),I=Math.max(p,10),x=A+2*I,L=d+x,w=(M+S)/2-x/2-d,F=w+L/2,k=Math.max(p,d);C.sort((B,X)=>B.centerY-X.centerY);for(let B=0;B<C.length;B++){const X=C[B];let G,Z;if(B===0?G=X.contentTop-k:G=(C[B-1].contentBottom+X.contentTop)/2,B===C.length-1)Z=X.contentBottom+k;else{const Pt=C[B+1];Z=(X.contentBottom+Pt.contentTop)/2}const ct=Math.max(0,Z-G),Mt=(G+Z)/2;X.lane.x=F,X.lane.y=Mt,X.lane.width=L,X.lane.height=ct,X.lane.swimlaneContentTop=X.contentTop,X.lane.groupTitleRect={left:w,right:w+d,top:G,bottom:Z}}return e==="RL"&&an(t,"x"),!0}f(Ms,"applyLrDirectionTransform");var ae=1e-6,qr=8,We=qr,Jr=[0,We,-We,2*We,-2*We];function Is(t,e){const{nodeInfoById:n,realNodeRects:o}=un(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const i=lo(xt(r,ae),ae);if(!i)continue;const{p3:d}=i,c=i.kind==="HVH",l=go(s,n,ae);if(!l)continue;const{srcId:h,dstId:m,srcInfo:b,dstInfo:y,collinearX:u,collinearY:a}=l;if(u||a)continue;let p;const C=b.rect;for(const M of Jr){let S,A,I;if(c){const F=y.cy>b.cy?C.bottom:C.top,k=b.cx+M;if(k<=C.left+ae||k>=C.right-ae)continue;S={x:k,y:F},A={x:k,y:d.y},I={x:d.x,y:d.y}}else{const F=y.cx>b.cx?C.right:C.left,k=b.cy+M;if(k<=C.top+ae||k>=C.bottom-ae)continue;S={x:F,y:k},A={x:d.x,y:k},I={x:d.x,y:d.y}}const x=ce(S,A,ae),L=ce(A,I,ae);if(x&&L||!x&&Bt(S,A,o,[h],1)||!L&&Bt(A,I,o,[m],1))continue;const R=!x&&nn(S,A,t,s,{epsilon:ae,skipDegenerateOther:!0}),P=!L&&nn(A,I,t,s,{epsilon:ae,skipDegenerateOther:!0});if(!(R||P)){x?p=[A,I]:L?p=[S,A]:p=[S,A,I];break}}p&&(s.points=p)}}f(Is,"portSwapToLShape");function Ss(t,e){const{realNodeRects:r,labelNodeRects:i}=Me(e.values());for(const d of t){if(d.isLayoutOnly)continue;const c=d.points;if(!c||c.length<4)continue;const l=xt(c,.001);if(l.length<4)continue;const h=l.length-1,m=l[h],b=l[h-1],y=l[h-2],u=m.x-b.x,a=m.y-b.y,p=Math.hypot(u,a);if(p>=10||p<.001)continue;const C=b.x-y.x,M=b.y-y.y;if(Math.hypot(C,M)<.001)continue;const A=Nt(b,m,.001),I=Ot(b,m,.001),x=Nt(y,b,.001),L=Ot(y,b,.001);if(!(A&&L||I&&x))continue;const R=d.end,P=d.start,w=R?e.get(R):void 0;if(!w)continue;const F=w.x??0,k=w.y??0,B=te(w);if(!B)continue;let X,G;if(L){const J=M<0;X={x:F,y:y.y},G={x:F,y:J?B.bottom:B.top}}else{const J=C>0;X={x:y.x,y:k},G={x:J?B.right:B.left,y:k}}if(Bt(X,G,r,R?[R]:[],-2)||Bt(X,G,i,[],-2))continue;if(P){const J=e.get(P),rt=J?te(J):void 0;if(rt&&fo(X,rt,2))continue}const Z=f((J,rt)=>`${J.x.toFixed(3)},${J.y.toFixed(3)}|${rt.x.toFixed(3)},${rt.y.toFixed(3)}`,"ownSegmentKey"),ct=new Set;for(let J=0;J<l.length-1;J++)ct.add(Z(l[J],l[J+1]));const Mt=f((J,rt)=>{for(const ut of t){if(ut===d||ut.isLayoutOnly)continue;const pt=ut.points;if(!(!pt||pt.length<2))for(let St=0;St<pt.length-1;St++){const wt=pt[St],Kt=pt[St+1];if(!ct.has(Z(wt,Kt))&&he(J,rt,wt,Kt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(Mt(X,G))continue;if(h-3>=0){const J=l[h-3],rt=[P,R].filter(ut=>!!ut);if(Bt(J,X,r,rt,-2)||Mt(J,X))continue}const Dt=[...l.slice(0,h-2),X,G];d.points=Dt;const nt=d.labelNodeId;if(nt){const J=e.get(nt);if(J){const rt=J.width??0,ut=J.height??0;if(rt>0&&ut>0){let pt,St,wt=-1;for(let Kt=0;Kt<Dt.length-1;Kt++){const qt=Dt[Kt],Jt=Dt[Kt+1],se=Math.hypot(Jt.x-qt.x,Jt.y-qt.y),Ee=yt(qt,Jt,.001),me=gt(qt,Jt,.001);(Ee&&se>=rt+2||me&&se>=ut+2)&&se>wt&&(wt=se,pt=(qt.x+Jt.x)/2,St=(qt.y+Jt.y)/2)}pt!==void 0&&St!==void 0&&(J.x=pt,J.y=St)}}}}}f(Ss,"collapseShortTerminalStub");var et=.001,Xt=8,lt=Pe,Ln=f((t,e)=>gt(t,e,et)||yt(t,e,et),"orthogonallyAligned");function Cs(t,e){const s=f((y,u)=>{const a=y.x??0,p=y.y??0,C=u.x-a,M=u.y-p;let S=(y.width??0)/2,A=(y.height??0)/2;return Math.abs(M)*S>Math.abs(C)*A?(M<0&&(A=-A),{x:a+(M===0?0:A*C/M),y:p+A}):(C<0&&(S=-S),{x:a+S,y:p+(C===0?0:S*M/C)})},"rectIntersect"),r=f((y,u)=>{const a=xt(y.points??[]);if(a.length<2)return;const p=u?y.start:y.end,C=p?e.get(p):void 0,M=C?te(C):void 0;if(!C||!p||!M)return;const S=u?a[0]:a[a.length-1],A=u?a[1]:a[a.length-2],I=s(C,S);let x=S;if(Ln(A,I)&&(x=A),gt(I,x,et))return{edge:y,edgeId:String(y.id??""),nodeId:p,atStart:u,orientation:"V",coord:I.x,min:Math.min(I.y,x.y),max:Math.max(I.y,x.y),boundary:I,railEnd:x,rect:M};if(yt(I,x,et))return{edge:y,edgeId:String(y.id??""),nodeId:p,atStart:u,orientation:"H",coord:I.y,min:Math.min(I.x,x.x),max:Math.max(I.x,x.x),boundary:I,railEnd:x,rect:M}},"terminalLaneFor"),i=f((y,u)=>Math.max(0,Math.min(y.max,u.max)-Math.max(y.min,u.min)),"projectedOverlapLength"),d=f((y,u)=>y.nodeId!==u.nodeId||y.orientation!==u.orientation?!1:y.orientation==="H"?(Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1)&&gt(y.boundary,u.boundary,1):(Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1)&&yt(y.boundary,u.boundary,1),"sameTerminalFace"),c=f((y,u)=>y.nodeId!==u.nodeId||y.orientation!==u.orientation?!1:i(y,u)>=Xt&&Math.abs(y.coord-u.coord)<.5,"exactTerminalLaneConflict"),l=f((y,u)=>{if(y.nodeId!==u.nodeId||y.orientation!==u.orientation||y.orientation!=="H"||y.atStart===u.atStart)return!1;const a=i(y,u);if(a<Xt)return!1;const p=y.rect.bottom-y.rect.top;return a<p||a>2*p?!1:d(y,u)&&Math.abs(y.coord-u.coord)<16},"nearTerminalLaneConflict"),h=f((y,u)=>{const a=xt(y.edge.points??[]);if(a.length<2)return;const p=y.orientation==="V"?{x:y.boundary.x+u,y:y.boundary.y}:{x:y.boundary.x,y:y.boundary.y+u},C=y.orientation==="V"?{x:y.railEnd.x+u,y:y.railEnd.y}:{x:y.railEnd.x,y:y.railEnd.y+u};if(!f(()=>Math.abs(y.boundary.y-y.rect.top)<1||Math.abs(y.boundary.y-y.rect.bottom)<1?yt(p,y.boundary,et)&&p.x>=y.rect.left+1&&p.x<=y.rect.right-1:Math.abs(y.boundary.x-y.rect.left)<1||Math.abs(y.boundary.x-y.rect.right)<1?gt(p,y.boundary,et)&&p.y>=y.rect.top+1&&p.y<=y.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(y.atStart){const x=a.length>1&&ce(a[1],y.railEnd,et),L=a.slice(x?2:1),R=L[0];return R&&!Ln(R,C)?void 0:[p,C,...L]}const S=a.length>1&&ce(a[a.length-2],y.railEnd,et),A=a.slice(0,S?-2:-1),I=A[A.length-1];if(!(I&&!Ln(I,C)))return[...A,C,p]},"shiftedCandidate"),m=f(y=>{const u=y.edge,a=xt(u.points??[]);if(a.length!==2)return!1;const p=u.start,C=u.end,M=p?e.get(p):void 0,S=C?e.get(C):void 0;if(!M||!S)return!1;const A=M.x??0,I=M.y??0,x=S.x??0,L=S.y??0,[R,P]=a;return yt(R,P,et)&&Math.abs(I-L)<1&&Math.abs(A-x)>1||gt(R,P,et)&&Math.abs(A-x)<1&&Math.abs(I-L)>1},"laneIsStraightCollinearConnector"),b=[-7,7,-2*7,2*7,-3*7,3*7];for(let y=0;y<8;y++){const u=t.filter(p=>!p.isLayoutOnly).flatMap(p=>[r(p,!0),r(p,!1)]).filter(p=>!!p);let a=!1;for(let p=0;p<u.length&&!a;p++)for(let C=p+1;C<u.length&&!a;C++){const M=u[p],S=u[C];if(M.edge===S.edge||!(c(M,S)||l(M,S)))continue;const A=!c(M,S),I=[M,S].sort((x,L)=>{const R=m(x),P=m(L);return R!==P?Number(R)-Number(P):+!L.atStart-+!x.atStart});for(const x of I){for(const L of b){const R=h(x,L);if(!R)continue;const P=r({...x.edge,points:R},x.atStart);if(!(!P||u.some(w=>w.edge!==x.edge&&(c(P,w)||A&&l(P,w))))){x.edge.points=R,a=!0;break}}if(a)break}}if(!a)return}}f(Cs,"separateSharedRenderedTerminalLanes");function vs(t,e){const{realNodeRects:s,labelNodeRects:r}=Me(e.values()),i=f((c,l)=>{const h=c.start,m=c.end,b=lt(l);if(b.length!==l.length-1)return!1;const y=[h,m].filter(u=>!!u);for(const u of b)if(Bt(u.a,u.b,s,y,-2)||Bt(u.a,u.b,r,[],-2))return!1;for(const u of t){if(u===c||u.isLayoutOnly)continue;const a=u.points;if(!(!a||a.length<2)){for(const p of b)for(const C of lt(xt(a)))if(de(p,C,.5)>=Xt||he(p.a,p.b,C.a,C.b,et))return!1}}return!0},"candidateIsSafe"),d=f((c,l)=>{if(l+4>=c.length)return;const h=c[l],m=c[l+1],b=c[l+2],y=c[l+3],u=c[l+4],a=Nt(h,m)&&Ot(m,b)&&Nt(b,y)&&Ot(y,u)&&gt(h,y,et)&&gt(h,u,et)&&gt(m,b,et)&&(m.x-h.x)*(y.x-b.x)<0,p=Ot(h,m)&&Nt(m,b)&&Ot(b,y)&&Nt(y,u)&&yt(h,y,et)&&yt(h,u,et)&&yt(m,b,et)&&(m.y-h.y)*(y.y-b.y)<0;if(a||p)return xt([...c.slice(0,l+1),u,...c.slice(l+5)]);if(l+5>=c.length)return;const C=c[l+5],M=Ot(h,m)&&Nt(m,b)&&Ot(b,y)&&Nt(y,u)&&Ot(u,C)&&gt(h,u,et)&&gt(h,C,et)&&gt(b,y,et)&&(b.x-m.x)*(u.x-y.x)<0,S=Nt(h,m)&&Ot(m,b)&&Nt(b,y)&&Ot(y,u)&&Nt(u,C)&&yt(h,u,et)&&yt(h,C,et)&&yt(b,y,et)&&(b.y-m.y)*(u.y-y.y)<0;if(!(!M&&!S))return xt([...c.slice(0,l+1),C,...c.slice(l+6)])},"withoutDogleg");for(let c=0;c<8;c++){let l=!1;for(const h of t){if(h.isLayoutOnly)continue;const m=xt(h.points??[]);for(let b=0;b<=m.length-5;b++){const y=d(m,b);if(!(!y||!i(h,y))){h.points=y,l=!0;break}}if(l)break}if(!l)return}}f(vs,"collapseRedundantRectangularDoglegs");function zn(t,e){const{realNodeRects:r,labelNodeRects:i}=Me(e.values()),d=t.filter(u=>!u.isLayoutOnly),c=f((u,a,p)=>xt(u===a?p??[]:u.points??[]),"pointsFor"),l=f((u,a)=>{let p=0;for(let C=0;C<d.length;C++){const M=lt(c(d[C],u,a));for(let S=C+1;S<d.length;S++){const A=lt(c(d[S],u,a));for(const I of M)for(const x of A)he(I.a,I.b,x.a,x.b,et)&&p++}}return p},"strictCrossingCount"),h=f(u=>{const a=lt(u);if(a.length!==3)return;const p=a[1];if(!(a[0].horizontal===p.horizontal||a[2].horizontal===p.horizontal))return{index:p.index,horizontal:p.horizontal,vertical:p.vertical,segment:p}},"middleRail"),m=f((u,a)=>{const p=[u.start,u.end].filter(C=>!!C);return r.filter(C=>{if(p.includes(C.id))return!1;const M=C.rect;return a.horizontal?Wt(a.a.x,a.b.x,M.left,M.right)>=Xt&&a.a.y>=M.top-2&&a.a.y<=M.bottom+2:Wt(a.a.y,a.b.y,M.top,M.bottom)>=Xt&&a.a.x>=M.left-2&&a.a.x<=M.right+2})},"blockingRectsFor"),b=f((u,a,p)=>{const C=u.map(S=>({...S}));if(a.horizontal)C[a.index].y=p,C[a.index+1].y=p;else if(a.vertical)C[a.index].x=p,C[a.index+1].x=p;else return;const M=ue(xt(C));return lt(M).length===M.length-1?M:void 0},"candidateByMovingRail"),y=f((u,a,p)=>{const C=[u.start,u.end].filter(S=>!!S),M=lt(a);if(M.length!==a.length-1)return!1;for(const S of M)if(Bt(S.a,S.b,r,C,-2)||Bt(S.a,S.b,i,[],-2))return!1;for(const S of d)if(S!==u){for(const A of M)for(const I of lt(c(S)))if(de(A,I,.5)>=Xt)return!1}return l(u,a)<=p},"candidateIsSafe");for(let u=0;u<8;u++){const a=l();let p=!1;for(const C of d){const M=c(C),S=h(M);if(!S)continue;const A=m(C,S.segment);if(A.length===0)continue;const I=S.horizontal?[Math.min(...A.map(x=>x.rect.top))-20,Math.max(...A.map(x=>x.rect.bottom))+20]:[Math.min(...A.map(x=>x.rect.left))-20,Math.max(...A.map(x=>x.rect.right))+20];for(const x of I){const L=b(M,S.segment,x);if(!(!L||!y(C,L,a))){C.points=L,p=!0;break}}if(p)break}if(!p)return}}f(zn,"liftObstacleHuggingSameSideRails");function Vn(t,e){const o=f(c=>{const l=c.groupTitleRect;if(!(!l||typeof l.left!="number"||typeof l.right!="number"||typeof l.top!="number"||typeof l.bottom!="number"||!Number.isFinite(l.left)||!Number.isFinite(l.right)||!Number.isFinite(l.top)||!Number.isFinite(l.bottom)||l.right<=l.left||l.bottom<=l.top))return{left:l.left,right:l.right,top:l.top,bottom:l.bottom}},"validTitleRect"),s=f(c=>{if(!c.isGroup||c.parentId)return;const l=c.direction,h=typeof l=="string"?l.toUpperCase():"";if(h==="LR"||h==="RL"||h==="BT")return;const m=o(c),b=c.y,y=c.height;if(!m||typeof b!="number"||typeof y!="number"||!Number.isFinite(b)||!Number.isFinite(y)||y<=0)return;const u=m.right-m.left,a=m.bottom-m.top;if(!(a<=0||u<a))return{node:c,rect:m}},"topLaneTitleFor"),r=f((c,l)=>{if(!c.horizontal)return!1;const h=c.a.y;return h<=l.top+et||h>=l.bottom-et?!1:Wt(c.a.x,c.b.x,l.left,l.right)>=Xt},"horizontalSegmentIntersectsTitle"),i=[...e.values()].map(s).filter(c=>!!c);if(i.length===0)return;let d=0;for(const c of t){if(c.isLayoutOnly)continue;const l=xt(c.points??[]);for(const h of lt(l))for(const m of i)r(h,m.rect)&&(d=Math.max(d,m.rect.bottom-h.a.y+4))}if(!(d<=et))for(const c of i){const l=c.node.y,h=c.node.height;typeof l!="number"||typeof h!="number"||!Number.isFinite(l)||!Number.isFinite(h)||h<=0||(c.node.y=l-d/2,c.node.height=h+d,c.node.groupTitleRect={...c.rect,top:c.rect.top-d,bottom:c.rect.bottom-d})}}f(Vn,"liftTopLaneTitleBandsAboveRails");function jn(t,e){const o=f(l=>{const h=l.groupTitleRect;if(!(!h||typeof h.left!="number"||typeof h.right!="number"||typeof h.top!="number"||typeof h.bottom!="number"||!Number.isFinite(h.left)||!Number.isFinite(h.right)||!Number.isFinite(h.top)||!Number.isFinite(h.bottom)||h.right<=h.left||h.bottom<=h.top))return{left:h.left,right:h.right,top:h.top,bottom:h.bottom}},"validTitleRect"),s=f(l=>{if(!l.isGroup||l.parentId||l.direction!=="LR")return;const m=o(l),b=l.x,y=l.width;if(!m||typeof b!="number"||typeof y!="number"||!Number.isFinite(b)||!Number.isFinite(y)||y<=0)return;const u=m.right-m.left,a=m.bottom-m.top;if(!(u<=0||a<u))return{node:l,rect:m}},"leftLaneTitleFor"),r=f((l,h)=>{if(!l.vertical)return!1;const m=l.a.x;return m<=h.left+et||m>=h.right-et?!1:Wt(l.a.y,l.b.y,h.top,h.bottom)>=Xt},"verticalSegmentIntersectsTitle"),i=f((l,h)=>{if(!l.horizontal)return!1;const m=l.a.y;return m<=h.top+et||m>=h.bottom-et?!1:Wt(l.a.x,l.b.x,h.left,h.right)>=Xt},"horizontalSegmentIntersectsTitle"),d=[...e.values()].map(s).filter(l=>!!l);if(d.length===0)return;let c=0;for(const l of t){if(l.isLayoutOnly)continue;const h=xt(l.points??[]);for(const m of lt(h))for(const b of d)if(r(m,b.rect))c=Math.max(c,b.rect.right-m.a.x+4);else if(i(m,b.rect)){const y=Math.min(m.a.x,m.b.x);c=Math.max(c,b.rect.right-y+4)}}if(!(c<=et))for(const l of d){const h=l.node.x,m=l.node.width;typeof h!="number"||typeof m!="number"||!Number.isFinite(h)||!Number.isFinite(m)||m<=0||(l.node.x=h-c/2,l.node.width=m+c,l.node.groupTitleRect={...l.rect,left:l.rect.left-c,right:l.rect.right-c})}}f(jn,"shiftLeftLaneTitleBandsLeftOfRails");function Ls(t,e){const{realNodeRects:s}=Me(e.values()),r=t.filter(a=>!a.isLayoutOnly),i=f((a,p=new Map)=>xt(p.get(a)??a.points??[]),"replacementPointsFor"),d=f((a=new Map)=>{let p=0;for(let C=0;C<r.length;C++){const M=lt(i(r[C],a));for(let S=C+1;S<r.length;S++){const A=lt(i(r[S],a));for(const I of M)for(const x of A)he(I.a,I.b,x.a,x.b,et)&&p++}}return p},"crossingCount"),c=f((a=new Map)=>r.reduce((p,C)=>p+oe(i(C,a)),0),"totalBends"),l=f(a=>{const p=i(a);if(p.length<4)return;const C=p[p.length-2],M=p[p.length-1];if(!(!Nt(C,M,et)&&!Ot(C,M,et)))return{tailStart:C,terminal:M}},"terminalTailFor"),h=f((a,p)=>{const C=i(a);if(C.length<3)return;const M=C[0],S=C[1];let A;if(Nt(M,S,et))A={x:S.x,y:p.tailStart.y};else if(Ot(M,S,et))A={x:p.tailStart.x,y:S.y};else return;const I=ue(xt([M,S,A,p.tailStart,p.terminal]));return lt(I).length===I.length-1?I:void 0},"candidateWithDestinationTail"),m=f((a,p)=>{const C=[a.start,a.end].filter(M=>!!M);for(const M of lt(p))if(Bt(M.a,M.b,s,C,-2))return!0;return!1},"pathHasNodeHit"),b=f((a,p,C)=>{for(const M of r)if(M!==a){for(const S of lt(p))for(const A of lt(i(M,C)))if(de(S,A,.5)>=Xt)return!0}return!1},"pathHasSharedTrack"),y=f((a,p,C)=>!m(a,p)&&!b(a,p,C),"candidateIsSafe"),u=f(()=>{const a=new Map;for(const p of r){const C=p.end;if(!C||!e.has(C)||i(p).length<4)continue;const S=a.get(C)??[];S.push(p),a.set(C,S)}return a},"edgesByDestination");for(let a=0;a<4;a++){const p=d();if(p===0)return;const C=c();let M,S=p,A=C;for(const I of u().values())for(let x=0;x<I.length;x++)for(let L=x+1;L<I.length;L++){const R=I[x],P=I[L],w=l(R),F=l(P);if(!w||!F)continue;const k=h(R,F),B=h(P,w);if(!k||!B)continue;const X=new Map([[R,k],[P,B]]);if(!y(R,k,X)||!y(P,B,X))continue;const G=d(X),Z=c(X);G>=p||G>S||G===S&&Z>=A||(M=X,S=G,A=Z)}if(!M)return;for(const[I,x]of M)I.points=x}}f(Ls,"swapDestinationTerminalTailsToReduceCrossings");function Es(t,e){const{realNodeRects:i,labelNodeRects:d}=Me(e.values()),c=t.filter(I=>!I.isLayoutOnly),l=f((I,x=new Map)=>xt(x.get(I)??I.points??[]),"replacementPointsFor"),h=f((I=new Map)=>{let x=0;for(let L=0;L<c.length;L++){const R=lt(l(c[L],I));for(let P=L+1;P<c.length;P++){const w=lt(l(c[P],I));for(const F of R)for(const k of w)he(F.a,F.b,k.a,k.b,et)&&x++}}return x},"strictCrossingCount"),m=f((I=new Map)=>c.reduce((x,L)=>x+oe(l(L,I)),0),"totalBends"),b=f(I=>{const x=I.start,L=I.end,R=x?e.get(x):void 0,P=L?e.get(L):void 0,w=R?te(R):void 0,F=P?te(P):void 0;return w&&F?{src:w,dst:F}:void 0},"endpointRectsFor"),y=f((I,x,L)=>{if(L.index<=0||L.index+1>=x.length-1)return;const R=b(I);if(R){if(L.vertical){const P=L.a.x,w=Math.min(R.src.left,R.dst.left),F=Math.max(R.src.right,R.dst.right),k=P<w-et?"left":P>F+et?"right":void 0;return k?{edge:I,points:x,segmentIndex:L.index,axis:"vertical",side:k,coord:P,min:Math.min(L.a.y,L.b.y),max:Math.max(L.a.y,L.b.y)}:void 0}if(L.horizontal){const P=L.a.y,w=Math.min(R.src.top,R.dst.top),F=Math.max(R.src.bottom,R.dst.bottom),k=P<w-et?"top":P>F+et?"bottom":void 0;return k?{edge:I,points:x,segmentIndex:L.index,axis:"horizontal",side:k,coord:P,min:Math.min(L.a.x,L.b.x),max:Math.max(L.a.x,L.b.x)}:void 0}}},"externalRailForSegment"),u=f(()=>{const I=[];for(const x of c){const L=l(x);for(const R of lt(L)){const P=y(x,L,R);P&&I.push(P)}}return I},"collectExternalRails"),a=f((I,x)=>I.edge!==x.edge&&I.axis===x.axis&&I.side===x.side&&Wt(I.min,I.max,x.min,x.max)>=Xt,"railsInteract"),p=f(I=>{const x=[],L=new Set;for(const R of I){if(L.has(R))continue;const P=[R],w=[];for(L.add(R);P.length>0;){const F=P.pop();w.push(F);for(const k of I)!L.has(k)&&a(F,k)&&(L.add(k),P.push(k))}w.length>1&&x.push(w)}return x},"connectedComponents"),C=f(I=>{const x=[];for(const L of I)x.some(R=>Math.abs(R-L.coord)<et)||x.push(L.coord);for(;x.length<I.length;){const L=Math.min(...x),R=Math.max(...x),P=I[0].side;x.push(P==="left"||P==="top"?L-12*(I.length-x.length):R+12*(I.length-x.length))}return x},"uniqueCoordsFor"),M=f(I=>{const x=I.map(P=>P.coord),L=C(I),R=[];if(I.length<=6){const P=new Array(L.length).fill(!1),w=[],F=f(()=>{if(w.length===I.length){w.some((k,B)=>Math.abs(k-x[B])>=et)&&R.push([...w]);return}for(const[k,B]of L.entries())P[k]||(P[k]=!0,w.push(B),F(),w.pop(),P[k]=!1)},"visit");return F(),R}for(let P=0;P<x.length;P++)for(let w=P+1;w<x.length;w++){const F=[...x];[F[P],F[w]]=[F[w],F[P]],R.push(F)}return R},"coordinateAssignmentsFor"),S=f((I,x)=>{const L=new Map;for(const[P,w]of I.entries()){const F=x[P],k=L.get(w.edge)??w.points.map(B=>({x:B.x,y:B.y}));w.axis==="vertical"?(k[w.segmentIndex].x=F,k[w.segmentIndex+1].x=F):(k[w.segmentIndex].y=F,k[w.segmentIndex+1].y=F),L.set(w.edge,k)}const R=new Map;for(const[P,w]of L){const F=ue(xt(w));if(lt(F).length!==F.length-1)return;R.set(P,F)}return R},"replacementsForAssignment"),A=f(I=>{for(const[x,L]of I){const R=[x.start,x.end].filter(P=>!!P);for(const P of lt(L))if(Bt(P.a,P.b,i,R,-2)||Bt(P.a,P.b,d,[],-2))return!1}for(let x=0;x<c.length;x++){const L=c[x],R=I.has(L),P=lt(l(L,I));for(let w=x+1;w<c.length;w++){const F=c[w];if(!R&&!I.has(F))continue;const k=lt(l(F,I));for(const B of P)for(const X of k)if(de(B,X,.5)>=Xt)return!1}}return!0},"candidateIsSafe");for(let I=0;I<4;I++){const x=h();if(x===0)return;let L,R=x,P=m(),w=Number.POSITIVE_INFINITY;for(const F of p(u()))for(const k of M(F)){const B=S(F,k);if(!B||!A(B))continue;const X=h(B);if(X>=x)continue;const G=m(B),Z=F.reduce((ct,Mt,Pt)=>ct+Math.abs(k[Pt]-Mt.coord),0);X>R||X===R&&(G>P||G===P&&Z>=w)||(L=B,R=X,P=G,w=Z)}if(!L)return;for(const[F,k]of L)F.points=k}}f(Es,"reassignCrossingExternalRailChannels");function Ts(t,e){const{realNodeRects:s,labelNodeRects:r}=Me(e.values()),i=t.filter(u=>!u.isLayoutOnly),d=f((u,a,p)=>xt(u===a?p??[]:u.points??[]),"pointsFor"),c=f(u=>lt(u).reduce((a,p)=>{const C=p.a.x-p.b.x,M=p.a.y-p.b.y;return a+Math.hypot(C,M)},0),"pathLength"),l=f((u,a)=>{let p=0;for(let C=0;C<i.length;C++){const M=lt(d(i[C],u,a));for(let S=C+1;S<i.length;S++){const A=lt(d(i[S],u,a));for(const I of M)for(const x of A)he(I.a,I.b,x.a,x.b,et)&&p++}}return p},"strictCrossingCount"),h=f((u,a)=>{if(u.horizontal){const p=u.a.y;return(Math.abs(p-a.top)<1||Math.abs(p-a.bottom)<1)&&Wt(u.a.x,u.b.x,a.left,a.right)>=Xt}if(u.vertical){const p=u.a.x;return(Math.abs(p-a.left)<1||Math.abs(p-a.right)<1)&&Wt(u.a.y,u.b.y,a.top,a.bottom)>=Xt}return!1},"segmentRunsAlongRectBorder"),m=f(u=>{const a=[u.start,u.end].filter(C=>!!C),p=[];for(const C of a){const M=e.get(C),S=M?te(M):void 0;S&&p.push(S)}return p},"endpointRectsFor"),b=f((u,a)=>{if(a+3>=u.length)return[];const p=u[a],C=u[a+1],M=u[a+2],S=u[a+3],A=Nt(p,C,et)&&Ot(C,M,et)&&Nt(M,S,et),I=Ot(p,C,et)&&Nt(C,M,et)&&Ot(M,S,et);if(!A&&!I)return[];if(!(A?Math.sign(C.x-p.x)!==Math.sign(S.x-M.x):Math.sign(C.y-p.y)!==Math.sign(S.y-M.y)))return[];const L=gt(p,S,et)||yt(p,S,et)?[]:[{x:p.x,y:S.y},{x:S.x,y:p.y}],R=L.length===0?[[...u.slice(0,a+1),...u.slice(a+3)]]:L.map(w=>[...u.slice(0,a+1),w,...u.slice(a+3)]),P=new Set;return R.map(w=>ue(xt(w))).filter(w=>{if(lt(w).length!==w.length-1||!w.some(k=>ce(k,S,et)))return!1;const F=w.map(k=>`${k.x.toFixed(3)},${k.y.toFixed(3)}`).join("|");return P.has(F)?!1:(P.add(F),!0)})},"shortcutCandidatesAt"),y=f((u,a,p)=>{const C=[u.start,u.end].filter(S=>!!S),M=m(u);for(const S of lt(a))if(Bt(S.a,S.b,s,C,-2)||Bt(S.a,S.b,r,[],-2)||M.some(A=>h(S,A)))return!1;for(const S of i)if(S!==u){for(const A of lt(a))for(const I of lt(d(S)))if(de(A,I,.5)>=Xt)return!1}return l(u,a)<=p},"candidateIsSafe");for(let u=0;u<8;u++){const a=l();let p,C,M=a,S=Number.POSITIVE_INFINITY,A=Number.POSITIVE_INFINITY;for(const I of i){const x=d(I),L=oe(x,et),R=c(x);for(let P=0;P<=x.length-4;P++)for(const w of b(x,P)){const F=oe(w,et),k=c(w);if(!(F<L||F===L&&k<R-et)||!y(I,w,a))continue;const X=l(I,w);X>M||X===M&&(F>S||F===S&&k>=A)||(p=I,C=w,M=X,S=F,A=k)}}if(!p||!C)return;p.points=C}}f(Ts,"shortcutRedundantOrthogonalJogs");function ws(t,e){const i=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const _=N.x??0,D=N.y??0,j=te(N);j&&i.push({id:String(N.id??""),cx:_,cy:D,rect:j})}if(i.length===0)return;const d=new Map(i.map(N=>[N.id,N])),c=i.map(N=>({id:N.id,rect:N.rect})),l=["top","bottom","left","right"],h={top:Math.min(...i.map(N=>N.rect.top))-20,bottom:Math.max(...i.map(N=>N.rect.bottom))+20,left:Math.min(...i.map(N=>N.rect.left))-20,right:Math.max(...i.map(N=>N.rect.right))+20},m=t.filter(N=>!N.isLayoutOnly),b=new Map(m.map((N,_)=>[N,_])),y=f(N=>{const _=N==="left"||N==="top"?-1:1,D=[];for(let j=0;j<=2;j++)D.push(h[N]+_*20*j);return D},"outwardTracksForSide"),u=f((N,_=new Map)=>xt(_.get(N)??N.points??[]),"replacementPointsFor"),a=f((N,_)=>{let D=0;for(const j of N)for(const K of _)he(j.a,j.b,K.a,K.b,et)&&D++;return D},"crossingCountBetweenSegments"),p=f((N,_)=>a(lt(N),lt(_)),"crossingCountBetweenPaths"),C=f((N=new Map)=>{let _=0;const D=[],j=new Set,K=[],Q=f($=>{j.has($)||(j.add($),K.push($))},"addEdge");for(let $=0;$<m.length;$++){const q=m[$],g=u(q,N);for(let v=$+1;v<m.length;v++){const T=m[v],E=p(g,u(T,N));E>0&&(_+=E,D.push({first:q,second:T,count:E}),Q(q),Q(T))}}return K.sort(($,q)=>(b.get($)??0)-(b.get(q)??0)),{count:_,pairs:D,edgeSet:j,edges:K}},"crossingSnapshot"),M=f((N,_)=>{const D=new Set(_.keys());if(D.size===0)return N.count;let j=0;for(const Q of N.pairs)(D.has(Q.first)||D.has(Q.second))&&(j+=Q.count);let K=0;for(let Q=0;Q<m.length;Q++){const $=m[Q],q=D.has($),g=u($,_);for(let v=Q+1;v<m.length;v++){const T=m[v];!q&&!D.has(T)||(K+=p(g,u(T,_)))}}return N.count-j+K},"crossingCountWithReplacements"),S=f(N=>{const _=new Map;for(const K of N.pairs){const Q=_.get(K.first)??new Set;Q.add(K.second),_.set(K.first,Q);const $=_.get(K.second)??new Set;$.add(K.first),_.set(K.second,$)}const D=[],j=new Set;for(const K of N.edges){if(j.has(K))continue;const Q=[K],$=[];for(j.add(K);Q.length>0;){const q=Q.pop();$.push(q);for(const g of _.get(q)??[])j.has(g)||(j.add(g),Q.push(g))}$.sort((q,g)=>(b.get(q)??0)-(b.get(g)??0)),$.length>1&&D.push($)}return D},"crossingComponents"),A=f(N=>[N.start,N.end].filter(_=>!!_),"endpointIdsFor"),I=f(N=>{const _=[];for(const D of S(N)){const j=new Set(D),K=new Set(D.flatMap($=>A($))),Q=[...D];for(const $ of m)j.has($)||A($).some(q=>K.has(q))&&Q.push($);Q.sort(($,q)=>(b.get($)??0)-(b.get(q)??0)),_.push(Q)}return _},"pairSearchGroups"),x=f((N,_,D)=>M(N,new Map([[_,D]])),"crossingCountWithSingleReplacement"),L=f(N=>{const _=new Map;for(const D of N.pairs)_.set(D.first,(_.get(D.first)??0)+D.count),_.set(D.second,(_.get(D.second)??0)+D.count);return _},"currentCrossingsByEdge"),R=f(N=>N.slice(1).reduce((_,D,j)=>{const K=N[j];return _+Math.abs(D.x-K.x)+Math.abs(D.y-K.y)},0),"pathLength"),P=f((N=new Map)=>m.reduce((_,D)=>_+oe(u(D,N)),0),"totalBends"),w=f((N=new Map)=>m.reduce((_,D)=>_+R(u(D,N)),0),"totalLength"),F=f((N,_,D=new Map)=>{const j=lt(_);for(const K of m)if(K!==N){for(const Q of j)for(const $ of lt(u(K,D)))if(de(Q,$,.5)>=Xt)return!0}return!1},"pathHasSegmentConflict"),k=f((N,_)=>{const D=[N.start,N.end].filter(j=>!!j);for(const j of lt(_))if(Bt(j.a,j.b,c,D,-2))return!0;return!1},"pathHitsNode"),B=f((N,_)=>{const D=ue(xt(_));lt(D).length===D.length-1&&N.push(D)},"pushOrthogonalCandidate"),X=f(N=>N==="left"||N==="right","sideIsHorizontal"),G=f((N,_,D)=>{switch(_){case"left":return Math.min(N.x,D.x)-20;case"right":return Math.max(N.x,D.x)+20;case"top":return Math.min(N.y,D.y)-20;case"bottom":return Math.max(N.y,D.y)+20}},"localTrackForSameSide"),Z=f((N,_,D,j)=>{const K=D==="left"||D==="top"?-1:1,Q=[G(_,D,j),h[D]];for(const $ of Q)for(let q=0;q<=2;q++)B(N,ho(_,D,j,$+K*20*q))},"addSameSideCandidates"),ct=f((N,_,D,j,K)=>{for(const Q of y(D))for(const $ of y(K))B(N,[_,{x:Q,y:_.y},{x:Q,y:$},{x:j.x,y:$},j])},"addHorizontalToVerticalCandidates"),Mt=f((N,_,D,j,K)=>{for(const Q of y(D))for(const $ of y(K))B(N,[_,{x:_.x,y:Q},{x:$,y:Q},{x:$,y:j.y},j])},"addVerticalToHorizontalCandidates"),Pt=f((N,_,D,j,K)=>{const Q=[...y("top"),...y("bottom")];for(const $ of y(D))for(const q of y(K))for(const g of Q)B(N,[_,{x:$,y:_.y},{x:$,y:g},{x:q,y:g},{x:q,y:j.y},j])},"addHorizontalPairCandidates"),Dt=f((N,_,D,j,K)=>{const Q=[...y("left"),...y("right")];for(const $ of y(D))for(const q of y(K))for(const g of Q)B(N,[_,{x:_.x,y:$},{x:g,y:$},{x:g,y:q},{x:j.x,y:q},j])},"addVerticalPairCandidates"),nt=f(N=>{const _=new Set;return N.map(D=>xt(D)).filter(D=>{const j=D.map(K=>`${K.x.toFixed(3)},${K.y.toFixed(3)}`).join("|");return _.has(j)||D.length<2?!1:(_.add(j),!0)})},"dedupeCandidatePaths"),J=f((N,_,D,j)=>{const K=[],Q=uo(N,_,D,j,20,et);Q&&B(K,Q),_===j&&Z(K,N,_,D);const $=X(_),q=X(j);return $&&!q?ct(K,N,_,D,j):!$&&q?Mt(K,N,_,D,j):$?Pt(K,N,_,D,j):Dt(K,N,_,D,j),nt(K)},"buildCandidatesForSides"),rt=f((N,_,D,j)=>{const K=[...y("left"),...y("right")],Q=[...y("top"),...y("bottom")];for(const $ of l){const q=Le(j,$),g=$==="top"||$==="bottom"?y($):Q;for(const v of K){B(N,[_,D,{x:v,y:D.y},{x:v,y:q.y},q]);for(const T of g)B(N,[_,D,{x:v,y:D.y},{x:v,y:T},{x:q.x,y:T},q])}}},"addVerticalDepartureOuterTrackCandidates"),ut=f((N,_,D,j)=>{const K=[...y("left"),...y("right")],Q=[...y("top"),...y("bottom")];for(const $ of l){const q=Le(j,$),g=$==="left"||$==="right"?y($):K;for(const v of Q){B(N,[_,D,{x:D.x,y:v},{x:q.x,y:v},q]);for(const T of g)B(N,[_,D,{x:D.x,y:v},{x:T,y:v},{x:T,y:q.y},q])}}},"addHorizontalDepartureOuterTrackCandidates"),pt=f(N=>{const _=N.start,D=N.end,j=D?d.get(D):void 0;if(!_||!j)return[];const K=xt(N.points??[]);if(K.length<4)return[];const Q=K[0],$=K[1],q=[];return Ot(Q,$,et)?rt(q,Q,$,j):Nt(Q,$,et)&&ut(q,Q,$,j),q},"terminalPreservingOuterTrackCandidates"),St=f(N=>{const _=N.start,D=N.end,j=_?d.get(_):void 0,K=D?d.get(D):void 0;if(!j||!K)return[];const Q=[];for(const $ of l){const q=Le(j,$);for(const g of l)Q.push(...J(q,$,Le(K,g),g))}return Q.push(...pt(N)),Q},"candidatePathsFor"),wt=f(()=>new Map(m.map(N=>[N,lt(u(N))])),"currentSegmentsByEdge"),Kt=f((N,_,D)=>{const j=new Set;for(const K of m){if(K===N)continue;const Q=D.get(K)??lt(u(K));_.some($=>Q.some(q=>de($,q,.5)>=Xt))&&j.add(K)}return j},"sharedTrackConflictsFor"),qt=f((N,_,D,j)=>{const K=new Set;return St(N).map($=>ue(xt($))).filter($=>{if(k(N,$))return!1;const q=$.map(g=>`${g.x.toFixed(3)},${g.y.toFixed(3)}`).join("|");return K.has(q)||$.length<2?!1:(K.add(q),!0)}).map($=>{const q=lt($);let g=0;for(const v of m)v!==N&&(g+=a(q,D.get(v)??lt(u(v))));return{candidate:$,candidateSegments:q,crossings:_.count-(j.get(N)??0)+g,bends:oe($,et),totalBends:oe($),length:R($)}}).filter(({crossings:$})=>$<=_.count).sort(($,q)=>$.crossings-q.crossings||$.bends-q.bends||$.length-q.length).slice(0,48).map($=>({path:$.candidate,segments:$.candidateSegments,sharedTrackConflicts:Kt(N,$.candidateSegments,D),totalBends:$.totalBends,length:$.length}))},"pairCandidatesFor"),Jt=f((N,_,D,j,K,Q)=>{let $=0;for(const g of N.pairs)(g.first===_||g.second===_||g.first===j||g.second===j)&&($+=g.count);let q=a(D.segments,K.segments);for(const g of m){if(g===_||g===j)continue;const v=Q.get(g)??lt(u(g));q+=a(D.segments,v)+a(K.segments,v)}return N.count-$+q},"pairCrossingCount"),se=f((N,_)=>{for(const D of N.sharedTrackConflicts)if(D!==_)return!1;return!0},"conflictsOnlyWith"),Ee=f((N,_)=>N.segments.some(D=>_.segments.some(j=>de(D,j,.5)>=Xt)),"candidatesShareTrack"),me=f((N,_,D,j)=>se(_,D.edge)&&se(j,N.edge)&&!Ee(_,j),"pairCandidatesAreCompatible"),Te=f((N,_,D,j,K)=>{const Q=Jt(N.current,_.edge,D,j.edge,K,N.baseSegments);if(!(Q>=N.current.count))return{replacements:new Map([[_.edge,D.path],[j.edge,K.path]]),crossings:Q,bends:N.currentBends-(N.baseBendsByEdge.get(_.edge)??0)-(N.baseBendsByEdge.get(j.edge)??0)+D.totalBends+K.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(_.edge)??0)-(N.baseLengthByEdge.get(j.edge)??0)+D.length+K.length}},"scorePairReplacement"),mn=f((N,_)=>N.crossings<_.crossings||N.crossings===_.crossings&&(N.bends<_.bends||N.bends===_.bends&&N.length<_.length),"pairScoreIsBetter"),yn=f((N,_,D,j)=>{let K=j;for(const Q of _.candidates)for(const $ of D.candidates){if(!me(_,Q,D,$))continue;const q=Te(N,_,Q,D,$);q&&mn(q,K)&&(K=q)}return K},"bestScoreForOptionPair"),pn=f(N=>{const _=P(),D=w(),j=wt(),K=L(N),Q=new Map(m.map(E=>[E,oe(u(E))])),$=new Map(m.map(E=>[E,R(u(E))])),q=new Map,g=I(N);for(const E of g)for(const O of E){if(q.has(O))continue;const H=qt(O,N,j,K);H.length>0&&q.set(O,{edge:O,candidates:H})}let v={replacements:new Map,crossings:N.count,bends:_,length:D};const T={current:N,currentBends:_,currentLength:D,baseBendsByEdge:Q,baseLengthByEdge:$,baseSegments:j};for(const E of g){const O=new Set(E.filter(W=>N.edgeSet.has(W))),H=E.map(W=>q.get(W)).filter(W=>!!W);for(let W=0;W<H.length;W++){const ot=H[W];for(let U=W+1;U<H.length;U++){const V=H[U];!O.has(ot.edge)&&!O.has(V.edge)||(v=yn(T,ot,V,v))}}}return v.replacements.size>0?v.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const _=C(),D=_.count;if(D===0)return;let j,K,Q=D,$=Number.POSITIVE_INFINITY;for(const g of _.edges){const v=oe(u(g),et);for(const T of St(g)){const E=k(g,T),O=!E&&F(g,T),H=x(_,g,T),W=oe(T,et);E||O||!(H<D||H===D&&W<v)||H>Q||H===Q&&W>=$||(j=g,K=T,Q=H,$=W)}}if(j&&K){j.points=K;continue}const q=pn(_);if(!q)return;for(const[g,v]of q)g.points=v}}f(ws,"resolveRenderedOrthogonalCrossings");var be=.001,Zr=8;function As(t,e){const{nodeInfoById:n,realNodeRects:o}=un(e),s=["top","bottom","left","right"],r=20,i={top:Math.min(...o.map(a=>a.rect.top))-r,bottom:Math.max(...o.map(a=>a.rect.bottom))+r,left:Math.min(...o.map(a=>a.rect.left))-r,right:Math.max(...o.map(a=>a.rect.right))+r},d=f((a,p,C,M)=>{const S=[],A=uo(a,p,C,M,r,be);return A&&S.push(A),p===M&&S.push(ho(a,p,C,i[p])),S},"buildOrthogonalPathCandidates"),c=f((a,p)=>{for(let C=0;C<a.length-1;C++){const M=a[C],S=a[C+1];if(Bt(M,S,o,p,1))return!0}return!1},"pathHitsNode"),l=f((a,p,C=!1)=>{let M=0;const S=Pe(a,be),A=p.start,I=p.end;for(const x of t){if(x===p||x.isLayoutOnly)continue;const L=x.start,R=x.end;if(!C&&A&&I&&(L===A||L===I||R===A||R===I))continue;const P=x.points;if(!(!P||P.length<2))for(const w of S)for(const F of Pe(P,be)){if(mo(w.a,w.b,F.a,F.b,be,be)){M++;continue}de(w,F,be)>=Zr&&M++}}return M},"pathConflictCount"),h=4,m=f((a,p)=>{const C=Math.abs(a.y-p.rect.top),M=Math.abs(a.y-p.rect.bottom),S=Math.abs(a.x-p.rect.left),A=Math.abs(a.x-p.rect.right);let I="top",x=C;return M<x&&(I="bottom",x=M),S<x&&(I="left",x=S),A<x&&(I="right",x=A),I},"nearestSideOfRect"),b=new Map,y=f((a,p,C)=>{const M=b.get(a)??[];M.push({side:p,edgeId:C}),b.set(a,M)},"addFaceClaim");for(const a of t){if(a.isLayoutOnly)continue;const p=a.points??[];if(p.length<1)continue;const C=a.id??"",M=a.start,S=a.end;if(M){const A=n.get(M);A&&y(M,m(p[0],A),C)}if(S){const A=n.get(S);A&&y(S,m(p[p.length-1],A),C)}}const u=f((a,p,C)=>{var M;return((M=b.get(a))==null?void 0:M.some(S=>S.edgeId!==C&&S.side===p))??!1},"faceIsClaimed");for(const a of t){if(a.isLayoutOnly)continue;const p=a.points;if(!p||p.length<2)continue;const C=oe(p,be);if(C<h)continue;const M=a.start,S=a.end;if(!M||!S)continue;const A=n.get(M),I=n.get(S);if(!A||!I)continue;const x=a.id??"",L=l(p,a,!0),R=l(p,a);let P,w=L,F=C;for(const k of s){if(u(M,k,x))continue;const B=Le(A,k);for(const X of s){if(u(S,X,x))continue;const G=Le(I,X);for(const Z of d(B,k,G,X)){if(c(Z,[M,S]))continue;const ct=oe(Z,be);if(L>0){const Mt=l(Z,a,!0);if(Mt>w||Mt===w&&ct>=F)continue;w=Mt,F=ct,P=Z;continue}l(Z,a)>R||ct<F&&(F=ct,P=Z)}}}if(P){a.points=P;const k=b.get(M);k&&b.set(M,k.filter(X=>X.edgeId!==x));const B=b.get(S);B&&b.set(S,B.filter(X=>X.edgeId!==x)),y(M,m(P[0],A),x),y(S,m(P[P.length-1],I),x)}}}f(As,"simplifyDetouredEdges");var Qt=.001,_o=10,Ke=7;function Un(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 i=r.x-s.x,d=r.y-s.y;if(!(Math.abs(i)+Math.abs(d)<Qt)){if(Math.abs(d)<=Qt){const l=s.x+Math.sign(i)*_o;return{left:Math.min(s.x,l),right:Math.max(s.x,l),top:s.y-Ke,bottom:s.y+Ke}}if(Math.abs(i)<=Qt){const l=s.y+Math.sign(d)*_o;return{left:s.x-Ke,right:s.x+Ke,top:Math.min(s.y,l),bottom:Math.max(s.y,l)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}f(Un,"markerClearanceRectFor");function Rs(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}f(Rs,"normalizeRect");function Wn(t,e){const n=xt(e),o=Un(n,!0),s=Un(n,!1);return[o,s].some(r=>r&&en(t,Rs(r)))}f(Wn,"labelOverlapsOwnMarker");function Je(t,e){const n=[];for(const u of t){if(u.isLayoutOnly)continue;const a=u.points;if(!(!a||a.length<2))for(let p=0;p<a.length-1;p++)n.push({edgeId:u.id,p1:a[p],p2:a[p+1]})}const o=[],s=[];for(const u of e.values()){const a=u.isGroup,p=u.parentId;if(a&&!p){const M=te(u);M&&s.push({id:u.id,rect:M});continue}if(a||u.isEdgeLabel)continue;const C=te(u);C&&o.push({nodeId:u.id,rect:C})}const r=3,i=1,d=12,c=f((u,a)=>{const p=Nn(a,r);for(const{nodeId:C,rect:M}of o)if(C!==u&&en(p,M))return!0;return!1},"labelOverlapsForeignNode"),l=f((u,a)=>{const p=Nn(a,r);for(const C of n)if(C.edgeId!==u&&dn(C.p1,C.p2,p))return!0;return!1},"labelOverlapsForeignEdge"),h=f((u,a,p)=>c(u,p)||l(a,p),"labelOverlapsAnything"),m=[],b=f(u=>{for(const{id:a,rect:p}of s)if(ss(p,u))return a},"findContainingLane"),y=f((u,a)=>m.some(p=>p.labelId!==u&&en(a,p.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const a=u.labelNodeId;if(!a)continue;const p=e.get(a);if(!p)continue;const C=u.points;if(!C||C.length<2)continue;const M=p.width??0,S=p.height??0;if(M<=0||S<=0)continue;const A=[];for(let nt=0;nt<C.length-1;nt++){const J=C[nt],rt=C[nt+1],ut=Math.abs(J.x-rt.x),pt=Math.abs(J.y-rt.y);ut<Qt&&pt<Qt||ut>=Qt&&pt>=Qt||A.push({idx:nt,length:ut+pt,orientation:ut>=Qt?"horizontal":"vertical",midX:(J.x+rt.x)/2,midY:(J.y+rt.y)/2})}if(A.length===0)continue;const I=A.length>=3?A.filter(nt=>nt.idx>0&&nt.idx<A.length-1):A,x=I.length>0?I:A,L=M>=S?"horizontal":"vertical",R=f(nt=>[...nt].sort((J,rt)=>{const ut=J.orientation===L,pt=rt.orientation===L;if(ut!==pt)return ut?-1:1;const St=J.length>=(J.orientation==="horizontal"?M:S)+2,wt=rt.length>=(rt.orientation==="horizontal"?M:S)+2;return St!==wt?St?-1:1:rt.length-J.length}),"rankSegments"),P=A[0],w=A[A.length-1],F=[.5,.25,.75,.05,.95,.15,.85,.1,.9],k=f((nt,J)=>{const rt=C[nt.idx],ut=C[nt.idx+1];return{midX:rt.x+(ut.x-rt.x)*J,midY:rt.y+(ut.y-rt.y)*J}},"anchorAtT"),B=f((nt,J,rt)=>Math.min(rt,Math.max(J,nt)),"clamp"),X=f((nt,J)=>nt.midX>=J.left-Qt&&nt.midX<=J.right+Qt&&nt.midY>=J.top-Qt&&nt.midY<=J.bottom+Qt,"pointInsideRectInclusive"),G=f(nt=>{const J=Be(nt.midX,nt.midY,M,S),rt=b(J);if(rt)return{laneId:rt,anchor:nt,rect:J};const ut=s.find(({rect:se})=>X(nt,se));if(!ut)return;const pt=ut.rect.left+M/2+i,St=ut.rect.right-M/2-i,wt=ut.rect.top+S/2+i,Kt=ut.rect.bottom-S/2-i;if(pt>St||wt>Kt)return;const qt={midX:B(nt.midX,pt,St),midY:B(nt.midY,wt,Kt)},Jt=Be(qt.midX,qt.midY,M,S);return X(nt,Jt)?{laneId:ut.id,anchor:qt,rect:Jt}:void 0},"placementForAnchor"),Z=f((nt,J,rt)=>nt.orientation==="horizontal"?Math.abs(J.midX-rt.x):Math.abs(J.midY-rt.y),"distanceAlongSegment"),ct=f((nt,J)=>{const ut=(nt.orientation==="horizontal"?M/2:S/2)+d;if(nt===P){const pt=C[nt.idx];if(Z(nt,J,pt)+Qt<ut)return!1}if(nt===w){const pt=C[nt.idx+1];if(Z(nt,J,pt)+Qt<ut)return!1}return!0},"labelClearsTerminalEndpoints"),Mt=f(nt=>{const J=R(nt);for(const rt of J)for(const ut of F){const pt=k(rt,ut);if(!ct(rt,pt))continue;const St=G(pt);if(St&&!Wn(St.rect,C)&&!y(a,St.rect)&&!h(a,u.id,St.rect))return{laneId:St.laneId,anchor:St.anchor}}},"tryPool"),Pt=f((nt,J,rt=!1)=>{const ut=R(nt);for(const pt of ut){const St={midX:pt.midX,midY:pt.midY};if(J&&!ct(pt,St))continue;const wt=G(St);if(wt&&!Wn(wt.rect,C)&&!y(a,wt.rect)&&!c(a,wt.rect)&&(rt||!l(u.id,wt.rect)))return{laneId:wt.laneId,anchor:wt.anchor}}},"findLaneContainingFallback"),Dt=Mt(x)??(x.length<A.length?Mt(A):void 0)??Pt(A,!0)??Pt(A,!1)??Pt(A,!1,!0);if(Dt){p.x=Dt.anchor.midX,p.y=Dt.anchor.midY,p.parentId=Dt.laneId;const nt=Be(Dt.anchor.midX,Dt.anchor.midY,M,S),J=m.findIndex(rt=>rt.labelId===a);J>=0?m[J]={labelId:a,rect:nt}:m.push({labelId:a,rect:nt})}}}f(Je,"anchorLabelsToPolyline");var En=1e-6,Qr=8,Do=Qr/2,ti=3;function Kn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}f(Kn,"pairKey");function Ns(t,e){const{nodeInfoById:n,realNodeRects:o}=un(e),s=new Map;for(const i of e){const d=i.id;if(!i.isGroup&&i.isEdgeLabel){s.set(d,{w:i.width??0,h:i.height??0});continue}}const r=f((i,d,c,l)=>{const h=Kn(d,c);let m=0;const b=f(y=>{if(!y)return;const u=s.get(y);if(!u)return;const a=l==="x"?u.w/2:u.h/2;a>m&&(m=a)},"consider");b(i.labelNodeId);for(const y of t){if(y===i||y.isLayoutOnly)continue;const u=y.start,a=y.end;!u||!a||Kn(u,a)===h&&b(y.labelNodeId)}return m>0?m+ti:0},"labelClearanceFor");for(const i of t){if(i.isLayoutOnly)continue;const d=i.points;if(!lo(d,En))continue;const c=go(i,n,En);if(!c)continue;const{srcId:l,dstId:h,srcInfo:m,dstInfo:b,collinearX:y,collinearY:u}=c;if(y===u)continue;let a,p;if(y){const I=b.cy>m.cy;a={x:m.cx,y:I?m.rect.bottom:m.rect.top},p={x:b.cx,y:I?b.rect.top:b.rect.bottom}}else{const I=b.cx>m.cx;a={x:I?m.rect.right:m.rect.left,y:m.cy},p={x:I?b.rect.left:b.rect.right,y:b.cy}}if(Bt(a,p,o,[l,h],1))continue;const M=r(i,l,h,y?"x":"y"),S=M>Do?M:Do,A=[0,S,-S];for(const I of A){const x={...a},L={...p};if(y){if(x.x+=I,L.x+=I,x.x<=m.rect.left||x.x>=m.rect.right||L.x<=b.rect.left||L.x>=b.rect.right)continue}else if(x.y+=I,L.y+=I,x.y<=m.rect.top||x.y>=m.rect.bottom||L.y<=b.rect.top||L.y>=b.rect.bottom)continue;if(!Bt(x,L,o,[l,h],1)&&!nn(x,L,t,i,{epsilon:En})){i.points=[x,L];break}}}}f(Ns,"straightenCollinearSiblingDetours");function qn(t,e){const{realNodeRects:l,labelNodeRects:h}=Me(e.values()),m=f((x,L)=>Pe(L,.001).map(R=>({...R,edge:x,interior:R.index>=1&&R.index<=L.length-3})),"segmentsFor"),b=f(()=>{const x=[];for(const L of t){if(L.isLayoutOnly)continue;const R=L.points;!R||R.length<2||x.push(...m(L,xt(R)))}return x},"allSegments"),y=f((x,L)=>x.horizontal&&L.horizontal?Wt(x.a.x,x.b.x,L.a.x,L.b.x)>=8&&Math.abs(x.a.y-L.a.y)<7:x.vertical&&L.vertical?Wt(x.a.y,x.b.y,L.a.y,L.b.y)>=8&&Math.abs(x.a.x-L.a.x)<7:!1,"hasCrowdedParallelTrack"),u=f((x,L)=>{const R=x.start,P=x.end,w=m(x,L);if(w.length!==L.length-1)return!1;const F=[R,P].filter(B=>!!B),k=x.labelNodeId?[x.labelNodeId]:[];for(const B of w)if(Bt(B.a,B.b,l,F,-2)||Bt(B.a,B.b,h,k,-2))return!1;for(const B of t){if(B===x||B.isLayoutOnly)continue;const X=B.points;if(!(!X||X.length<2)){for(const G of w)for(const Z of m(B,xt(X)))if(y(G,Z)||he(G.a,G.b,Z.a,Z.b,.001))return!1}}return!0},"candidateIsSafe"),a=f((x,L)=>{const R=xt(x.edge.points??[]);if(R.length<4||x.index>=R.length-1)return;const P=R.map(w=>({...w}));if(x.horizontal)P[x.index].y+=L,P[x.index+1].y+=L;else if(x.vertical)P[x.index].x+=L,P[x.index+1].x+=L;else return;return m(x.edge,P).length===P.length-1?P:void 0},"shiftedCandidate"),p=f((x,L)=>({x:x.x??(L.left+L.right)/2,y:x.y??(L.top+L.bottom)/2}),"nodeCenter"),C=f(x=>{const L=x.edge,R=xt(L.points??[]);if(R.length!==4||x.index!==1)return;const P=L.start?e.get(L.start):void 0,w=L.end?e.get(L.end):void 0,F=P?te(P):void 0,k=w?te(w):void 0,B=R.slice(x.index+2);if(!(!P||!w||!F||!k||B.length===0))return{sourceCenter:p(P,F),targetCenter:p(w,k),sourceRect:F,tail:B}},"sourceDetourContextFor"),M=f((x,L,R,P,w,F)=>{const k=P.y>=R.y,B=k?w.bottom:w.top,X=B+(k?20:-20);if(k&&x.b.y<=X+.001||!k&&x.b.y>=X-.001)return;const G=x.a.x+L;return xt([{x:R.x,y:B},{x:R.x,y:X},{x:G,y:X},{x:G,y:x.b.y},...F],.001)},"verticalSourceDetour"),S=f((x,L,R,P,w,F)=>{const k=P.x>=R.x,B=k?w.right:w.left,X=B+(k?20:-20);if(k&&x.b.x<=X+.001||!k&&x.b.x>=X-.001)return;const G=x.a.y+L;return xt([{x:B,y:R.y},{x:X,y:R.y},{x:X,y:G},{x:x.b.x,y:G},...F],.001)},"horizontalSourceDetour"),A=f((x,L)=>{const R=C(x);if(R){if(x.vertical)return M(x,L,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail);if(x.horizontal)return S(x,L,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail)}},"sourceDetourCandidate"),I=[-7,7,-2*7,2*7,-3*7,3*7];for(let x=0;x<12;x++){const L=b();let R=!1;for(let P=0;P<L.length&&!R;P++)for(let w=P+1;w<L.length&&!R;w++){const F=L[P],k=L[w];if(F.edge===k.edge||!y(F,k))continue;const B=[F,k].filter(X=>X.interior);for(const X of B){for(const G of I){const Z=a(X,G);if(Z&&u(X.edge,Z)){X.edge.points=Z,R=!0;break}const ct=A(X,G);if(ct&&u(X.edge,ct)){X.edge.points=ct,R=!0;break}}if(R)break}}if(!R)return}}f(qn,"nudgeSharedInteriorSubpaths");function Os(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,i=o.x-n.x,d=o.y-n.y,c=s*d-r*i;if(Math.abs(c)<1e-10)return!1;const l=n.x-t.x,h=n.y-t.y,m=(l*d-h*i)/c,b=(l*r-h*s)/c,y=.01;return m>y&&m<1-y&&b>y&&b<1-y}f(Os,"segmentsIntersect");function Bs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=rs(e),r=1,i=[];for(const c of n){if(c.isLayoutOnly)continue;const l=c.points;if(!l||l.length<2)continue;const h=c.start,m=c.end,b=c.labelNodeId,y=c.id??`${h}->${m}`;for(const u of s)if(!(u.nodeId===h||u.nodeId===m)&&!(b&&u.nodeId===b)){for(let a=0;a<l.length-1;a++)if(dn(l[a],l[a+1],u,-r)){o.push({type:"edge-node-overlap",edgeId:y,targetId:u.nodeId,detail:`segment ${a} passes through node "${u.nodeId}"`});break}}for(let u=0;u<l.length-1;u++)i.push({edgeId:y,start:h,end:m,p1:l[u],p2:l[u+1]})}const d=new Set;for(let c=0;c<i.length;c++)for(let l=c+1;l<i.length;l++){const h=i[c],m=i[l];if(h.edgeId!==m.edgeId&&!(h.start===m.start||h.start===m.end||h.end===m.start||h.end===m.end)&&Os(h.p1,h.p2,m.p1,m.p2)){const b=h.edgeId<m.edgeId?`${h.edgeId}|${m.edgeId}`:`${m.edgeId}|${h.edgeId}`;d.has(b)||(d.add(b),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:m.edgeId,detail:`edges "${h.edgeId}" and "${m.edgeId}" cross`}))}}if(o.length>0){const c=o.filter(h=>h.type==="edge-node-overlap").length,l=o.filter(h=>h.type==="edge-edge-crossing").length;Qe.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${c} edge-node overlap(s), ${l} edge crossing(s)`);for(const h of o)Qe.warn(`[SWIMLANE_VALIDATE] ${h.type}: ${h.detail}`)}return o}f(Bs,"validateSwimlanesLayout");function Ps(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(d=>!d.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Ms(t,e)||e==="BT"&&s.length>0&&!bs(t))return;for(const d of o){if(d.isLayoutOnly)continue;const c=d.points;!c||c.length<2||(d.points=ue(on(c)))}As(o,n),Ns(o,n),Is(o,n);const r=new Map;for(const d of n)r.set(String(d.id),d);Je(o,r),fs(o,r),Ss(o,r),qn(o,r),Cs(o,r),vs(o,r),zn(o,r),Ls(o,r);const i=f(()=>{ws(o,r),Es(o,r),Ts(o,r),Je(o,r),Gn(o,r),zn(o,r),Je(o,r),Gn(o,r)},"finalizeRenderedEdges");i(),qn(o,r),i(),Vn(o,r),jn(o,r),Vn(o,r),jn(o,r)}f(Ps,"postProcessSwimlaneLayout");function Ie(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const i=`${r.id}:${r.src}->${r.dst}`;n.has(i)||(n.add(i),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}f(Ie,"normalizeGraph");function Mo(t,e){return t.edges.filter(n=>n.dst===e)}f(Mo,"incoming");function Fs(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}f(Fs,"buildSuccessorMap");function Io(t){const e=Fs(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}f(Io,"buildSortedSuccessorMap");function So(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}f(So,"buildInDegreeMap");function Co(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}f(Co,"sortedZeroInDegreeNodes");function hn(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}}f(hn,"buildPredecessorSuccessorMaps");function vo(t,e,n,o){var i,d;let s=0;for(const c of t.nodes)o!=null&&o.skipGroups&&((i=t.nodeById.get(c))!=null&&i.isGroup)||(s=Math.max(s,n[c]??0));const r=Array.from({length:s+1},()=>[]);for(const c of e)o!=null&&o.skipGroups&&((d=t.nodeById.get(c))!=null&&d.isGroup)||r[Math.max(0,n[c]??0)].push(c);return r}f(vo,"buildLayersFromRanks");function De(t){const e=So(t),n=Co(e),o=[],s=Io(t);for(;n.length;){const r=n.shift();o.push(r);for(const i of s.get(r)??[])if(e.set(i,(e.get(i)??0)-1),(e.get(i)??0)===0){let d=0;for(;d<n.length&&n[d]<i;)d++;n.splice(d,0,i)}}return o.length===t.nodes.length?o:null}f(De,"topoSortIfAcyclic");function Fe(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}f(Fe,"buildLayerIndex");function Lo(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let i=n(o,r)+n(r,s),d=o,c=r,l=o;for(;d<r||c<s;)c>=s||d<r&&t[d]<=t[c]?e[l++]=t[d++]:(e[l++]=t[c++],i+=r-d);for(let h=o;h<s;h++)t[h]=e[h];return i},"count");return n(0,t.length)}f(Lo,"countInversions");function ks(t){const e=Ie(t),n=new Map;for(const h of e.nodes)n.set(h,[]);for(const h of e.edges)n.get(h.src).push(h);for(const h of n.values())h.sort((m,b)=>m.dst===b.dst?m.id.localeCompare(b.id):m.dst.localeCompare(b.dst));const o=Object.create(null);for(const h of e.nodes)o[h]=0;const s=[],r=f(h=>{o[h]=1;for(const m of n.get(h)??[]){const b=m.dst;o[b]===0?r(b):o[b]===1&&s.push(m)}o[h]=2},"dfs"),i=[...e.nodes].sort((h,m)=>h.localeCompare(m));for(const h of i)o[h]===0&&r(h);const d=new Set(s.map(h=>`${h.id}:${h.src}->${h.dst}`)),c=e.edges.map(h=>d.has(`${h.id}:${h.src}->${h.dst}`)?{id:h.id,src:h.dst,dst:h.src,weight:h.weight,ref:h.ref}:h);return{acyclic:{nodes:[...e.nodes],edges:c,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}f(ks,"removeCycles_DFS");function _s(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const d=n(r)??r;return e.set(o,d),d},"resolve");for(const o of t.nodes)n(o);return e}f(_s,"buildTopLaneMap");function ge(t){const e=_s(t);return n=>e.get(n)??null}f(ge,"createTopLaneResolver");function gn(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}f(gn,"buildTopLaneOrder");function Eo(t,e){const n=gn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const i of e)!o.has(i)||s.has(i)||(s.add(i),r.push(i));for(const i of n)s.has(i)||r.push(i);return r}f(Eo,"resolveTopLaneOrder");var ei={EPSILON:1e-6},ln={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Ho={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function Ds(t,e){const n=Ie(t),o=(e==null?void 0:e.laneOf)??(()=>null),s=e==null?void 0:e.rankHint,{preds:r}=hn(n);for(const I of r.values())I.sort((x,L)=>x.localeCompare(L));const i=De(n)??[...n.nodes].sort((I,x)=>I.localeCompare(x)),d=new Map;for(const[I,x]of i.entries())d.set(x,I);const c=new Map,l=new Map;for(const I of n.nodes)l.set(I,[]);for(const I of i){const x=(r.get(I)??[]).filter(L=>c.has(L));if(x.length>0){const L=Hs(I,x,{laneOf:o,rankHint:s,topoIndex:d});c.set(I,L),l.get(L).push(I)}else c.has(I)||c.set(I,null)}for(const I of n.nodes)c.has(I)||c.set(I,null);const h=new Set;for(const I of n.nodes)(c.get(I)??null)===null&&h.add(I);const m=[...h].sort((I,x)=>{const L=d.get(I)??0,R=d.get(x)??0;return L===R?I.localeCompare(x):L-R}),b=Xs(n),y=new Map;for(const[I,x]of b.entries())y.set(I,[...x].sort((L,R)=>L.localeCompare(R)));const u=Ys(y),a=Gs(y),p=new Map;for(const I of n.nodes)p.set(I,[]);for(const I of a)for(const x of I.nodes){const L=p.get(x);L?L.push(I.id):p.set(x,[I.id])}const C=[],M=[],S=new Set,A=f(I=>{if(!S.has(I)){S.add(I),C.push(I);for(const x of l.get(I)??[])A(x);M.push(I)}},"walk");for(const I of m)A(I);for(const I of i)A(I);return{parent:c,children:l,roots:m,componentOf:u,blocks:a,nodeBlocks:p,adjacency:y,preorder:C,postorder:M,topologicalOrder:i}}f(Ds,"buildDrivingTree");function Hs(t,e,n){const o=n.laneOf(t);return[...e].sort((r,i)=>{var a,p;const d=n.laneOf(r),c=n.laneOf(i),l=d!=null&&d===o,h=c!=null&&c===o;if(l!==h)return l?-1:1;const m=(a=n.rankHint)==null?void 0:a[r],b=(p=n.rankHint)==null?void 0:p[i];if(m!=null&&b!=null&&m!==b)return b-m;const y=n.topoIndex.get(r)??0,u=n.topoIndex.get(i)??0;return y!==u?y-u:r.localeCompare(i)})[0]}f(Hs,"chooseParent");function Xs(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}f(Xs,"buildAdjacency");function Ys(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 i of t.get(r)??[])e.has(i)||s.push(i)}}n++}return e}f(Ys,"assignComponents");function Gs(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const i=f((d,c)=>{e.set(d,++r),n.set(d,r);for(const l of t.get(d)??[])l!==c&&(e.has(l)?(e.get(l)??0)<(e.get(d)??0)&&(o.push([d,l]),n.set(d,Math.min(n.get(d)??r,e.get(l)??r))):(o.push([d,l]),i(l,d),n.set(d,Math.min(n.get(d)??r,n.get(l)??r)),(n.get(l)??0)>=(e.get(d)??0)&&s.push($s(d,l,o,s.length))))},"visit");for(const d of t.keys())e.has(d)||i(d,null);return s}f(Gs,"computeBlocks");function $s(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const i=n.pop();if(s.push(i),r.add(i[0]),r.add(i[1]),i[0]===t&&i[1]===e||i[0]===e&&i[1]===t)break}return{id:o,edges:s,nodes:[...r]}}f($s,"popBlock");function zs(t,e,n){const o=[...t.nodes],s=new Map;for(const[M,S]of o.entries())s.set(S,M);const r=o.length,i=new Array(r).fill(-1),d=new Array(r).fill(0),c=[],l=new Set;for(const M of o){const S=n.parent.get(M)??null,A=s.get(M);A!=null&&S==null&&(i[A]=-1,d[A]=0,l.has(M)||(l.add(M),c.push(M)))}for(;c.length>0;){const M=c.shift(),S=s.get(M);if(S==null)continue;const A=n.children.get(M)??[];for(const I of A){if(l.has(I))continue;const x=s.get(I);x!=null&&(i[x]=S,d[x]=d[S]+1,l.add(I),c.push(I))}}for(const M of o){if(l.has(M))continue;const S=s.get(M);S!=null&&(i[S]=-1,d[S]=0,l.add(M))}const h=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),m=Array.from({length:h},()=>new Array(r).fill(-1));for(let M=0;M<r;M++)m[0][M]=i[M];for(let M=1;M<h;M++)for(let S=0;S<r;S++){const A=m[M-1][S];m[M][S]=A===-1?-1:m[M-1][A]}const b=f((M,S)=>{if(M===-1||S===-1)return-1;d[M]<d[S]&&([M,S]=[S,M]);const A=d[M]-d[S];for(let I=0;I<h;I++)if(A>>I&1&&(M=m[I][M],M===-1))return-1;if(M===S)return M;for(let I=h-1;I>=0;I--){const x=m[I][M],L=m[I][S];x===-1||L===-1||x!==L&&(M=x,S=L)}return m[0][M]},"lcaIndex"),y=Array.from({length:r},()=>new Map);for(const M of t.edges){let S=M.src,A=M.dst,I=e[S],x=e[A];if(I==null||x==null||(I>x&&([S,A]=[A,S],[I,x]=[x,I]),I==null||x==null||I===x))continue;const L=s.get(S),R=s.get(A);if(L==null||R==null)continue;const P=b(L,R);if(P===-1)continue;const w=y[P];for(let F=I;F<x;F++)w.set(F,(w.get(F)??0)+1)}const u=new Map,a=f((M,S)=>{if(S.size!==0)for(const[A,I]of S)M.set(A,(M.get(A)??0)+I)},"mergeInto"),p=new Set,C=f(M=>{const S=s.get(M);p.add(M);const A=S==null?void 0:y[S],I=A?new Map(A):new Map,x=n.children.get(M)??[];for(const L of x){const R=C(L),P=e[M];if(P!=null){let w=u.get(M);w||(w=new Map,u.set(M,w));let F=R.get(P)??0;const k=e[L];k!=null&&k>P&&(F+=1),w.set(L,F)}a(I,R)}return I},"dfs");for(const M of n.roots)p.has(M)||C(M);for(const M of o)p.has(M)||C(M);return u}f(zs,"computeSubtreeCrossCounts");function Vs(t,e,n){const o=new Map,s=f(r=>{let i=n[r]??0;const d=[...e.get(r)??[]];d.sort(To(n));for(const c of d){s(c);const l=o.get(c);l!=null&&(i=Math.min(i,l))}o.set(r,i)},"annotate");for(const r of t)s(r);return o}f(Vs,"annotateMinimumLayers");function To(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}f(To,"compareByRankThenId");function js(t,e,n,o){let s=0;for(const c of e){const l=n[c]??0;l>s&&(s=l)}const r=Array.from({length:s+1},()=>[]),i=new Set,d=f(c=>{if(i.has(c))return;i.add(c);const l=n[c]??0;r[l]||(r[l]=[]),r[l].push(c);for(const h of o(c))d(h)},"emit");for(const c of t)d(c);for(const c of e)if(!i.has(c)){const l=n[c]??0;r[l]||(r[l]=[]),r[l].push(c),i.add(c)}return r}f(js,"emitNodesInTreeOrder");function Us(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}f(Us,"deduplicateLayers");function Ws(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const i=e[s]??0,d=[],c=[],l=n.get(s);for(const h of r){const m=o.get(h)??i;m>i?d.push({child:h,min:m}):c.push(h)}return d.sort((h,m)=>h.min===m.min?h.child.localeCompare(m.child):h.min-m.min),c.sort((h,m)=>{const b=(l==null?void 0:l.get(h))??0,y=(l==null?void 0:l.get(m))??0;if(b!==y)return b-y;const u=o.get(h)??i,a=o.get(m)??i;return u!==a?u-a:h.localeCompare(m)}),[...d.map(h=>h.child),...c]}}f(Ws,"createChildOrderer");function fn(t,e,n){const o=Ds(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const m of t.nodes)s.has(m)||s.set(m,[]);const i=zs(t,e,o),d=[...r].sort(To(e)),c=Vs(d,s,e),l=Ws(s,e,i,c);let h=js(d,t.nodes,e,l);return h=Us(h),h}f(fn,"buildMultitreeLayerOrder");function Ks(t,e,n){const o=new Set(t),s=new Set(e),r=Fe(e),i=[];for(const d of n)o.has(d.src)&&s.has(d.dst)&&i.push(r.get(d.dst));return Lo(i)}f(Ks,"countCrossingsBetweenAdjacent");function Jn(t,e,n){const o=[];for(const r of e){const i=n[r.src],d=n[r.dst];if(i==null||d==null||i===d)continue;let c=r.src,l=r.dst,h=i,m=d;i>d&&(c=r.dst,l=r.src,h=d,m=i);for(let b=h;b<m;b++)o.push({id:`${r.id}@${b}`,src:c,dst:l,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Ks(t[r],t[r+1],o);return s}f(Jn,"totalCrossings");function qs(t,e){const n={...e},{preds:o}=hn(t),s=ge(t),r=fn(t,n,s);let i=Jn(r,t.edges,n);const d=ln.MAX_CROSSING_OPTIMIZATION_PASSES;for(let c=0;c<d;c++){let l=!1;const h=[...t.nodes].sort((m,b)=>(n[b]??0)-(n[m]??0));for(const m of h){const b=n[m]??0;if(b===0)continue;let y=0;for(const C of o.get(m)??[])y=Math.max(y,(n[C]??0)+1);if(y>=b)continue;const u=b;n[m]=y;const a=fn(t,n,s),p=Jn(a,t.edges,n);p<i?(i=p,l=!0):n[m]=u}if(!l)break}return n}f(qs,"optimizeRanksByCrossings");function Js(t,e){const n=ge(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const i=t.edges.filter(a=>a.src===s);if(i.length===0)continue;let d=!1,c=0;for(const a of i){const p=n(a.dst);p==null||p===r?d=!0:c++}if(c===0||d)continue;let l=0,h=!1;for(const a of t.edges){if(a.dst!==s)continue;const p=n(a.src);p&&(p===r?h=!0:l++)}if(l>0||!h)continue;const m=e[s]??0,b=m+c;let y=0;for(const a of t.edges)a.dst===s&&(y=Math.max(y,(e[a.src]??0)+1));const u=Math.max(m,y,b);u!==m&&(e[s]=u)}}f(Js,"adjustCrossLaneSources");function Zs(t,e){const n=Ie(t),o=De(n)??[...n.nodes].sort(),s=(e==null?void 0:e.compactSingleInput)??!1,r=ge(n);let i=Object.create(null);for(const c of o){const l=Mo(n,c),h=e!=null&&e.ignoreCrossLaneEdges?l.filter(m=>{const b=r(m.src),y=r(c);return!b||!y?!0:b===y}):l;if(h.length===0)i[c]=0;else if(s&&h.length===1){const m=h[0].src,b=r(m),y=r(c);b!==y?i[c]=i[m]??0:i[c]=(i[m]??0)+1}else{let m=-1/0;for(const b of h)m=Math.max(m,(i[b.src]??0)+1);i[c]=m===-1/0?0:m}}return((e==null?void 0:e.optimizeRanksByCrossings)??!1)&&(i=qs(n,i)),e!=null&&e.ignoreCrossLaneEdges&&Js(n,i),{layers:fn(n,i,r),rankOf:i,dummy:new Set}}f(Zs,"assignLayers_LongestPath");function Qs(t,e){const n=Ie(t),s={...Zs(n,{compactSingleInput:e==null?void 0:e.compactSingleInput,ignoreCrossLaneEdges:e==null?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:e==null?void 0:e.optimizeRanksByCrossings}).rankOf},r=ge(n),{preds:i,succs:d}=hn(n,u=>{if(e!=null&&e.ignoreCrossLaneEdges){const a=r(u.src),p=r(u.dst);if(a&&p&&a!==p)return!1}return!0}),c=De(n)??[...n.nodes],l=[...c].reverse(),h=f((u,a)=>{let p=0;for(const S of i.get(u)??[])p=Math.max(p,(s[S]??0)+1);let C=Number.POSITIVE_INFINITY;const M=d.get(u)??[];return M.length>0&&(C=Math.min(...M.map(S=>(s[S]??0)-1))),Number.isFinite(C)||(C=Math.max(p,a)),Math.min(Math.max(a,p),C)},"clampFeasible"),m=ln.GRAVITY_ITERATIONS,b=f(u=>{let a=!1;for(const p of u){const C=i.get(p)??[],M=d.get(p)??[];if(C.length===0&&M.length===0)continue;const S=C.length>0?C.reduce((L,R)=>L+(s[R]??0)+1,0)/C.length:s[p]??0,A=M.length>0?M.reduce((L,R)=>L+(s[R]??0)-1,0)/M.length:s[p]??0,I=Math.round((S+A)/2),x=h(p,I);x!==s[p]&&(s[p]=x,a=!0)}return a},"relaxOrder");for(let u=0;u<m;u++){const a=b(c),p=b(l);if(!a&&!p)break}for(const u of c){let a=0;for(const p of i.get(u)??[])a=Math.max(a,(s[p]??0)+1);(s[u]??0)<a&&(s[u]=a)}for(const u of l){const a=d.get(u)??[];if(a.length>0){const p=Math.min(...a.map(C=>(s[C]??0)-1));(s[u]??0)>p&&(s[u]=p)}}return{layers:vo(n,c,s),rankOf:s,dummy:new Set}}f(Qs,"assignLayers_Gravity");function tr(t){const e=So(t),n=Io(t);let o=Co(e);const s=[];for(;o.length>0;){const r=[];for(const i of o){s.push(i);for(const d of n.get(i)??[])e.set(d,(e.get(d)??0)-1),(e.get(d)??0)===0&&r.push(d)}o=r.sort((i,d)=>i.localeCompare(d))}return s.length===t.nodes.length?s:null}f(tr,"topoSortByGenerationIfAcyclic");function er(t,e){const n=Ie(t),o=(e==null?void 0:e.direction)==="LR"?tr(n)??[...n.nodes].sort():De(n)??[...n.nodes].sort(),s=ge(n),r=f(h=>s(h)??h,"laneOf"),i=Object.create(null),d=new Map,c=f((h,m)=>(e==null?void 0:e.ignoreCrossLaneEdges)??!0?r(h)===r(m)?1:0:1,"edgeWeight");for(const h of o){const m=n.nodeById.get(h);if(m!=null&&m.isGroup)continue;const b=Mo(n,h);let y=0;if(b.length>0)for(const C of b){const M=C.src,S=i[M]??0;y=Math.max(y,S+c(M,h))}const u=r(h),a=d.get(u)??0,p=Math.max(y,a);i[h]=p,d.set(u,p+1)}return{layers:vo(n,o,i,{skipGroups:!0}),rankOf:i,dummy:new Set}}f(er,"assignLayers_LaneAwareCompact");function nr(t,e){const n=Ie(e),{rankOf:o}=t,s=t.layers.map(y=>[...y]),r=new Set(t.dummy?[...t.dummy]:[]);let i=0;const d=new Map(n.nodeById),c=f(y=>{const u=`placeholder-${i++}`,a={id:u,isGroup:!1,isDummy:!0,width:0,height:0};for(d.set(u,a),r.add(u);s.length<=y;)s.push([]);return s[y].push(u),o[u]=y,u},"addDummyAt"),l=[...n.edges].sort((y,u)=>y.id===u.id?y.src===u.src?y.dst.localeCompare(u.dst):y.src.localeCompare(u.src):y.id.localeCompare(u.id)),h=[];for(const y of l){const u=o[y.src]??0,a=o[y.dst]??0;if(a-u<=1){h.push(y);continue}let p=y.src;for(let M=u+1,S=0;M<a;M++,S++){const A=c(M);h.push({id:`${y.id}#${S}`,src:p,dst:A,weight:y.weight,ref:y.ref}),p=A}const C=a-u-2;h.push({id:`${y.id}#${Math.max(C+1,0)}`,src:p,dst:y.dst,weight:y.weight,ref:y.ref})}const b={nodes:[...n.nodes,...[...r].filter(y=>!n.nodes.includes(y))],edges:h,layout:n.layout,nodeById:d};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:b}}f(nr,"makeProperLayering");function Zn(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}f(Zn,"median");function Qn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}f(Qn,"barycenter");function or(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}f(or,"neighborPositionsFor");function sr(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}f(sr,"currentOrderTieBreak");function to(t,e,n){const o=new Set(t),s=new Set(e),r=Fe(t),i=Fe(e),d=[];for(const l of n)o.has(l.src)&&s.has(l.dst)&&d.push({u:r.get(l.src),v:i.get(l.dst)});d.sort((l,h)=>l.u===h.u?l.v-h.v:l.u-h.u);const c=d.map(l=>l.v);return Lo(c)}f(to,"countCrossingsBetweenAdjacent");function Ze(t,e,n){return[...t].sort((o,s)=>{const r=Zn(e.get(o)??[]),i=Zn(e.get(s)??[]);return r===i?sr(o,s,n):isFinite(r)?isFinite(i)?r-i:-1:1})}f(Ze,"sortByHeuristic");function eo(t,e,n,o,s,r){const i=Fe(t),d=Fe(e),c=or(e,i,n,o);if(!s||!r||r.length===0)return Ze(e,c,d);const l=new Map;for(const b of e){const y=s(b),u=l.get(y)??[];u.push(b),l.set(y,u)}const h=[];for(const b of r){const y=l.get(b);if(!y||y.length===0)continue;const u=Ze(y,c,d);h.push(...u)}const m=l.get(null);if(m&&m.length>0){const b=Ze(m,c,d);for(const y of b){const u=Qn(c.get(y)??[]);let a=h.length;if(isFinite(u))for(const[p,C]of h.entries()){const M=Qn(c.get(C)??[]);if(u<M){a=p;break}}h.splice(a,0,y)}}return h}f(eo,"reorderLayer");function no(t,e,n,o,s){const r=[...e],i=new Set(t),d=new Set(e),c=o?new Set(o):null,l=n.filter(a=>i.has(a.src)&&d.has(a.dst)),h=c?n.filter(a=>d.has(a.src)&&c.has(a.dst)):void 0,m=f(a=>{let p=to(t,a,l);return h&&o&&(p+=to(a,o,h)),p},"crossingScore"),b=s?new Map:null;if(s&&b)for(const a of e)b.set(a,s(a));let y=!0,u=m(r);for(;y;){y=!1;for(let a=0;a+1<r.length;a++){if(b){const M=b.get(r[a]),S=b.get(r[a+1]);if(M!==S)continue}const p=u;[r[a],r[a+1]]=[r[a+1],r[a]];const C=m(r);C<p?(u=C,y=!0):[r[a],r[a+1]]=[r[a+1],r[a]]}}return r}f(no,"transposeImprove");function rr(t,e,n){const o=t.layers.map(d=>[...d]),s=e.edges,r=ge(e),i=Eo(e,n==null?void 0:n.laneOrder);for(let d=0;d<3;d++){for(let c=1;c<o.length;c++)o[c]=eo(o[c-1],o[c],s,"down",r,i),o[c]=no(o[c-1],o[c],s,o[c+1],r);for(let c=o.length-2;c>=0;c--)o[c]=eo(o[c+1],o[c],s,"up",r,i),o[c]=no(o[c+1],o[c],s,o[c-1],r)}return{layers:o}}f(rr,"orderLayers");function ir(t,e,n){const o=(n==null?void 0:n.layerGap)??Ho.DEFAULT_LAYER_GAP,s=(n==null?void 0:n.nodeGap)??Ho.DEFAULT_NODE_GAP,r=(n==null?void 0:n.laneGap)??s*2,i=(n==null?void 0:n.direction)??"TB",d=i==="LR"||i==="RL",c=t.layers,l=Object.create(null),h=Object.create(null),m=f(w=>e.nodeById.get(w),"getNode"),b=f(w=>{var F;return((F=m(w))==null?void 0:F.width)??0},"getWidth"),y=f(w=>{var F;return((F=m(w))==null?void 0:F.height)??0},"getHeight"),u=ge(e),a=Eo(e,n==null?void 0:n.laneOrder),p=c.map(w=>w.reduce((F,k)=>Math.max(F,y(k)),0)),C=[];if(d)for(let w=0;w+1<c.length;w++){const F=c[w].reduce((Mt,Pt)=>Math.max(Mt,b(Pt)),0),k=c[w+1].reduce((Mt,Pt)=>Math.max(Mt,b(Pt)),0),B=p[w],X=p[w+1],G=B/2+X/2,Z=(F+k)/2,ct=Math.max(0,Z-G-o);C.push(ct)}const M=new Set;for(const w of c)for(const F of w)M.add(u(F));const S=M.has(null),A=a.filter(w=>M.has(w)),I=[...S?[null]:[],...A],x=Object.create(null);for(const w of A)x[w]=0;S&&(x.null=0);for(const w of c){const F=Object.create(null),k=[];for(const B of w){const X=u(B);X===null?k.push(B):(F[X]||(F[X]=[])).push(B)}for(const[B,X]of Object.entries(F)){const G=X.reduce((Z,ct)=>Z+b(ct),0)+s*Math.max(0,X.length-1);x[B]=Math.max(x[B]??0,G)}if(S&&k.length){const B=k.reduce((X,G)=>X+b(G),0)+s*Math.max(0,k.length-1);x.null=Math.max(x.null??0,B)}}const L=new Map;{const w=I.map(B=>(B===null?x.null:x[B])??0);let k=-(w.reduce((B,X)=>B+X,0)+r*Math.max(0,I.length-1))/2;for(let B=0;B<I.length;B++){const X=I[B],G=w[B]??0,Z=k+G/2;L.set(X,Z),k+=G,B<I.length-1&&(k+=r)}}let R=0;for(const[w,F]of c.entries()){const k=p[w]??0,B=new Map;for(const G of F){const Z=u(G),ct=B.get(Z)??[];ct.push(G),B.set(Z,ct)}for(const G of I){const Z=B.get(G)??[];if(Z.length===0)continue;const ct=L.get(G);if(Z.length===1){const Mt=Z[0];l[Mt]=ct,h[Mt]=R+k/2}else{const Mt=Z.map(nt=>b(nt)),Pt=Mt.reduce((nt,J)=>nt+J,0)+s*(Z.length-1);let Dt=ct-Pt/2;for(const[nt,J]of Z.entries()){const rt=Mt[nt];l[J]=Dt+rt/2,h[J]=R+k/2,Dt+=rt+s}}}const X=C[w]??0;R+=k+o+X}const P=new Map;for(const w of e.edges){const F=w.ref.id;P.has(F)||P.set(F,[]),P.get(F).push(w)}for(const[,w]of P){if(w.length===0)continue;const F=w[0].ref,k=F.start,B=F.end;if(k==null||B==null)continue;const X=Math.round(((l[k]??0)+(l[B]??0))/2),G=new Set;for(const Z of w)G.add(Z.src),G.add(Z.dst);for(const Z of G){if(Z===k||Z===B)continue;const ct=e.nodeById.get(Z);ct!=null&&ct.isDummy&&(l[Z]=X)}}return{x:l,y:h}}f(ir,"assignCoordinates");var cr=8;function ar(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}f(ar,"hashString");function lr(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}f(lr,"mulberry32");function fr(t,e){const n=[...t],o=lr(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}f(fr,"deterministicShuffle");function dr(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}f(dr,"sourceDistance");function oo(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:i}of e){const d=n.get(s),c=n.get(r);d==null||c==null||(o+=i*Math.abs(d-c))}return o}f(oo,"laneArrangementCost");function ur(t){const e=gn(t);if(e.length<2)return[];const n=new Map(e.map((r,i)=>[r,i])),o=ge(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const i=typeof r.start=="string"?r.start:void 0,d=typeof r.end=="string"?r.end:void 0;if(!i||!d||!t.nodeById.has(i)||!t.nodeById.has(d))continue;const c=o(i),l=o(d);if(!c||!l||c===l)continue;const h=n.get(c),m=n.get(l);if(h==null||m==null)continue;const[b,y]=h<=m?[c,l]:[l,c],u=`${b}\0${y}`,a=s.get(u);a?a.weight++:s.set(u,{a:b,b:y,weight:1})}return[...s.values()]}f(ur,"buildWeightedLaneEdges");function so(t,e,n){const o=[...t];let s=oo(o,e),r=!0,i=0;const d=Math.max(1,o.length);for(;r&&i<d;){r=!1,i++;for(let c=0;c+1<o.length;c++){[o[c],o[c+1]]=[o[c+1],o[c]];const l=oo(o,e);l<s?(s=l,r=!0):[o[c],o[c+1]]=[o[c+1],o[c]]}}return{order:o,cost:s,sourceDistance:dr(o,n)}}f(so,"greedySwitch");function hr(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}f(hr,"isBetterCandidate");function gr(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:i})=>`${s}:${r}:${i}`).join("|");return ar(`${t.join("|")}#${o}#${n}`)}f(gr,"seedForRestart");function mr(t,e={}){const n=gn(t);if(n.length<2)return n;const o=ur(t);if(o.length===0)return n;const s=new Map(n.map((d,c)=>[d,c]));let r=so(n,o,s);const i=Math.max(0,e.restarts??cr);for(let d=0;d<i;d++){const c=gr(n,o,d),l=fr(n,c),h=so(l,o,s);hr(h,r)&&(r=h)}return r.order}f(mr,"optimizeTopLaneOrder");function yr(t,e){const n=(e==null?void 0:e.ignoreCrossLaneEdges)??!0,o=(e==null?void 0:e.optimizeRanksByCrossings)??!0,s=Ie(t),r=e!=null&&e.automaticLaneOrdering?mr(s,{restarts:cr}):void 0,i=ks(s),d=i.acyclic,c=n?er(d,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??ln.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e==null?void 0:e.direction}):Qs(d,{compactSingleInput:(e==null?void 0:e.compactSingleInput)??ln.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:l,graphWithDummies:h}=nr(c,d),m=rr(l,h,{laneOrder:r}),b=ir(m,h,{layerGap:e==null?void 0:e.layerGap,nodeGap:e==null?void 0:e.nodeGap,direction:e==null?void 0:e.direction,laneOrder:r});return{acyclic:d,reversed:i.reversed,layering:l,ordered:m,coordinates:b}}f(yr,"sugiyamaLayout");var ft=ei.EPSILON,ni=8,Ce=15,Ne=15,qe=25,ie=20,Tn=10;function ro(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,i=e.y-s,d=Math.abs(r),c=Math.abs(i);if(d<ft&&c<ft)return n;const l=3;return c>ft&&c*l>=d?i>0?"bottom":"top":d>ft?r>0?"right":"left":n}f(ro,"chooseOrthogonalSide");function io(t,e){return Math.abs(t.to-e.from)<ft||Math.abs(t.to-e.to)<ft?t.to:t.from}f(io,"sharedLineEndpointCoord");function ve(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}f(ve,"pointOnLine");function pr(t,e){var K,Q,$,q;const n=t.nodes??[],o=t.edges??[],s=[];for(const g of o)g.isLayoutOnly||s.push({...g,__originalEdge:g});const r=new Map,i=new Map,d=[],c=e==="LR";for(const g of n)r.set(g.id,g);const l=n.filter(g=>g.isGroup&&!g.parentId);for(const g of l){const v={id:g.id},T=f(E=>{i.set(E.id,v),n.filter(O=>O.parentId===E.id).forEach(T)},"assignLane");T(g)}const h=n.filter(g=>!g.isGroup&&!g.isEdgeLabel).map(g=>{const v=g.width??10,T=g.height??10,E=g.x??0,O=g.y??0,H=ni;return{nodeId:g.id,minX:E-v/2-H,maxX:E+v/2+H,minY:O-T/2-H,maxY:O+T/2+H,visualXHalfExtent:c?T/2+H:v/2+H}}),m=f((g,v,T,E)=>{let O=d.find(H=>H.orientation===g&&Math.abs(H.coord-v)<1);return O||(O={id:`pipe-${g}-${v.toFixed(0)}`,orientation:g,coord:v,spanMin:T,spanMax:E,tracks:[]},d.push(O)),O.spanMin=Math.min(O.spanMin,T),O.spanMax=Math.max(O.spanMax,E),O},"getOrAddPipe"),b=f((g,v)=>{const T=g.width??10,E=g.height??10,O=g.x??0,H=g.y??0;switch(v){case"top":return{x:O,y:H-E/2};case"bottom":return{x:O,y:H+E/2};case"left":return{x:O-T/2,y:H};case"right":return{x:O+T/2,y:H}}},"portForSide"),y=f((g,v,T)=>b(g,ro(g,v,T?"bottom":"top")),"getOrthogonalPort"),u=[],a=[],p=new Set,C=1e3,M=f((g,v,T)=>{if(u.length===0)return 0;const E=Math.abs(v.y-T.y)<ft,O=Math.abs(v.x-T.x)<ft;if(!E&&!O)return 0;let H=0;if(E){const W=v.y,ot=Math.min(v.x,T.x)-ft,U=Math.max(v.x,T.x)+ft;if(U<=ot)return 0;for(const V of u)V.edgeIndex===g||V.orientation!=="vertical"||V.pipe.coord<ot||V.pipe.coord>U||V.from-ft<=W&&V.to+ft>=W&&(H+=C)}else if(O){const W=v.x,ot=Math.min(v.y,T.y)-ft,U=Math.max(v.y,T.y)+ft;if(U<=ot)return 0;for(const V of u)V.edgeIndex===g||V.orientation!=="horizontal"||V.pipe.coord<ot||V.pipe.coord>U||V.from-ft<=W&&V.to+ft>=W&&(H+=C)}return H},"crossingPenalty"),S=s.map((g,v)=>{if(!g.start||!g.end)return{idx:v,crossLane:0,dx:0,dy:0};const T=r.get(g.start),E=r.get(g.end),O=i.get(g.start),H=i.get(g.end),W=O&&H&&O.id!==H.id?1:0,ot=T&&E?Math.abs((E.x??0)-(T.x??0)):0,U=T&&E?Math.abs((E.y??0)-(T.y??0)):0;return{idx:v,crossLane:W,dx:ot,dy:U}}).sort((g,v)=>{if(g.crossLane!==v.crossLane)return v.crossLane-g.crossLane;const T=g.dx+g.dy,E=v.dx+v.dy;return Math.abs(T-E)>1?T-E:g.idx-v.idx}).map(g=>g.idx),A=f((g,v,T,E)=>{const O=Math.min(g.x,v.x),H=Math.max(g.x,v.x),W=Math.min(g.y,v.y),ot=Math.max(g.y,v.y);return!!h.find(V=>T&&V.nodeId===T||E&&V.nodeId===E?!1:Math.abs(g.x-v.x)>ft?V.minY<g.y&&V.maxY>g.y&&V.maxX>O&&V.minX<H:V.minX<g.x&&V.maxX>g.x&&V.maxY>W&&V.minY<ot)},"isSegmentBlocked"),I=new Map,x=new Map;for(const g of s)!g.start||!g.end||g.start===g.end||(x.set(g.start,(x.get(g.start)??0)+1),x.set(g.end,(x.get(g.end)??0)+1));const L=f((g,v)=>ro(g,v,"bottom"),"determineSide"),R=new Map;for(const[g,v]of s.entries()){if(!v.start||!v.end||v.start===v.end||v.points&&v.points.length>0)continue;const T=r.get(v.start),E=r.get(v.end);if(!T||!E)continue;const O=(E.x??0)-(T.x??0),H=(E.y??0)-(T.y??0);R.set(g,{edgeIdx:g,srcId:v.start,dstId:v.end,srcSide:L(T,{x:E.x??0,y:E.y??0}),dstSide:L(E,{x:T.x??0,y:T.y??0}),absDx:Math.abs(O),absDy:Math.abs(H),dxSign:Math.sign(O),dySign:Math.sign(H)})}const P=f(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.absDx===0?1/0:g.absDy/g.absDx:g.absDy===0?1/0:g.absDx/g.absDy,"preferenceStrength"),w=f(g=>g.srcSide==="top"||g.srcSide==="bottom"?g.dxSign>=0?"right":"left":g.dySign>=0?"bottom":"top","secondarySide"),F=new Map;for(const g of R.values()){const v=`${g.srcId}:${g.srcSide}`;F.has(v)||F.set(v,[]),F.get(v).push(g)}const k=new Map,B=f((g,v)=>`${g}:${v}`,"loadKey");for(const g of R.values())k.set(B(g.srcId,g.srcSide),(k.get(B(g.srcId,g.srcSide))??0)+1),k.set(B(g.dstId,g.dstSide),(k.get(B(g.dstId,g.dstSide))??0)+1);for(const g of F.values())if(!(g.length<2)){g.sort((v,T)=>{const E=P(v),O=P(T);return Math.abs(E-O)>1e-9?O-E:v.edgeIdx-T.edgeIdx});for(let v=1;v<g.length;v++){const T=g[v],E=w(T),O=k.get(B(T.srcId,T.srcSide))??0,H=k.get(B(T.srcId,E))??0;H>=O||(k.set(B(T.srcId,T.srcSide),O-1),k.set(B(T.srcId,E),H+1),T.srcSide=E)}}const X=f(g=>{const v=g==null?void 0:g.shape;return v==="question"||v==="diamond"},"isDiamondNode"),G=new Map;for(const g of R.values())G.has(g.dstId)||G.set(g.dstId,new Set),G.get(g.dstId).add(g.dstSide);for(const g of R.values()){if(!X(r.get(g.srcId)))continue;const v=G.get(g.srcId);if(!(v!=null&&v.has(g.srcSide)))continue;const T=w(g);if(v.has(T)||(k.get(B(g.srcId,T))??0)>0)continue;const E=k.get(B(g.srcId,g.srcSide))??0;k.set(B(g.srcId,g.srcSide),Math.max(0,E-1)),k.set(B(g.srcId,T),1),g.srcSide=T}for(const g of R.values()){const{edgeIdx:v,srcId:T,dstId:E,srcSide:O,dstSide:H}=g,W=r.get(T),ot=r.get(E),U=`${T}:${O}:src`,V=O==="top"||O==="bottom"?ot.x??0:ot.y??0;I.has(U)||I.set(U,[]),I.get(U).push({edgeIdx:v,oppositeCoord:V});const bt=`${E}:${H}:dst`,dt=H==="top"||H==="bottom"?W.x??0:W.y??0;I.has(bt)||I.set(bt,[]),I.get(bt).push({edgeIdx:v,oppositeCoord:dt})}const Z=new Map,ct=8;for(const[g,v]of I){if(v.length<2)continue;v.sort((At,Gt)=>At.oppositeCoord-Gt.oppositeCoord);const T=g.split(":"),E=T.slice(0,-2).join(":"),O=T[T.length-2],H=T[T.length-1],W=r.get(E);if(!W)continue;const U=O==="left"||O==="right"?W.height??10:W.width??10,V=W.shape,dt=V==="question"||V==="diamond"?U*.3:U,st=Math.min(20,Math.max(ct,dt/(v.length+1))),Ft=-(st*(v.length-1))/2;for(const[At,Gt]of v.entries()){const ee=Ft+At*st,xn=`${Gt.edgeIdx}:${H}`;Z.set(xn,ee)}}const Mt=f(g=>{var v;return!!((v=s[g])!=null&&v.labelNodeId)},"edgeHasLabelNode"),Pt=f((g,v)=>g?(I.get(`${g}:${v}:src`)??[]).some(({edgeIdx:T})=>Mt(T))||(I.get(`${g}:${v}:dst`)??[]).some(({edgeIdx:T})=>Mt(T)):!1,"faceHasLabelNode"),Dt=f((g,v,T)=>v==="top"||v==="bottom"?{x:g.x+T,y:g.y}:{x:g.x,y:g.y+T},"applyPortOffset"),nt=f((g,v,T)=>{const E=R.get(g),O={x:T.x??0,y:T.y??0},H={x:v.x??0,y:v.y??0},W=(E==null?void 0:E.srcSide)??L(v,O),ot=(E==null?void 0:E.dstSide)??L(T,H);let U=E?b(v,E.srcSide):y(v,O,!0),V=E?b(T,E.dstSide):y(T,H,!1);const bt=Z.get(`${g}:src`),dt=Z.get(`${g}:dst`);return bt!==void 0&&(U=Dt(U,W,bt)),dt!==void 0&&(V=Dt(V,ot,dt)),{pSrcPort:U,pDstPort:V,srcSide:W,dstSide:ot}},"portsForEdge");for(const g of S){const v=s[g];if(a[g]=[],!v.start||!v.end||v.points&&v.points.length>0||v.start===v.end)continue;const T=r.get(v.start),E=r.get(v.end);if(!T||!E)continue;const{pSrcPort:O,pDstPort:H,srcSide:W,dstSide:ot}=nt(g,T,E),U={...O},V={...H},bt=W==="top"||W==="bottom",dt=ot==="top"||ot==="bottom";if(bt){const Y=O.y>(T.y??0);U.y=Y?O.y+ie:O.y-ie}else{const Y=O.x>(T.x??0);U.x=Y?O.x+ie:O.x-ie}if(dt){const Y=H.y>(E.y??0);V.y=Y?H.y+ie:H.y-ie}else{const Y=H.x>(E.x??0);V.x=Y?H.x+ie:H.x-ie}const at=f((Y,z)=>{for(const tt of h)if(!z.includes(tt.nodeId)&&Y.x>tt.minX&&Y.x<tt.maxX&&Y.y>tt.minY&&Y.y<tt.maxY)return{inside:!0,obstacle:tt};return{inside:!1}},"isPointInObstacle"),st=f((Y,z,tt,ht,Tt)=>{if(Tt){const kt=Y.y>(z.y??0);return{x:(tt.x??0)>=Y.x?ht.maxX+Ce:ht.minX-Ce,y:kt?ht.maxY+Ne:ht.minY-Ne,leavesPositiveSide:kt}}const Ct=Y.x>(z.x??0),Rt=(tt.y??0)>=Y.y;return{x:Ct?ht.maxX+Ce:ht.minX-Ce,y:Rt?ht.maxY+Ne:ht.minY-Ne,leavesPositiveSide:Ct}},"obstacleDetour");let It=[];const Ft=[v.start,v.end],At=at(U,Ft);if(At.inside&&At.obstacle){const Y=At.obstacle;if(bt){const z=st(O,T,E,Y,!0);U.x=z.x,U.y=z.y;const tt=z.leavesPositiveSide?Math.min(Y.minY-2,O.y+ie):Math.max(Y.maxY+2,O.y-ie);It=[{x:O.x,y:tt},{x:z.x,y:tt},{x:z.x,y:z.y}]}else{const z=st(O,T,E,Y,!1),tt=z.leavesPositiveSide?Math.min(Y.minX-2,O.x+ie):Math.max(Y.maxX+2,O.x-ie);U.x=z.x,U.y=z.y,It=[{x:tt,y:O.y},{x:tt,y:z.y},{x:z.x,y:z.y}]}}let Gt=[];const ee=at(V,Ft);if(ee.inside&&ee.obstacle){const Y=ee.obstacle;if(dt){const z=st(H,E,T,Y,!0);V.x=z.x,V.y=z.y,Gt=[{x:z.x,y:z.y},{x:H.x,y:z.y}]}else{const z=st(H,E,T,Y,!1);V.x=z.x,V.y=z.y,Gt=[{x:z.x,y:z.y},{x:z.x,y:H.y}]}}if(It.length===0&&Gt.length===0){const Y=Ce,z=Math.abs(U.x-V.x)<Y,tt=Math.abs(U.y-V.y)<Y,ht=Z.get(`${g}:src`)!==void 0||Z.get(`${g}:dst`)!==void 0,Tt=(((K=I.get(`${v.start??""}:${W}:src`))==null?void 0:K.length)??0)+(((Q=I.get(`${v.start??""}:${W}:dst`))==null?void 0:Q.length)??0),Ct=((($=I.get(`${v.end??""}:${ot}:src`))==null?void 0:$.length)??0)+(((q=I.get(`${v.end??""}:${ot}:dst`))==null?void 0:q.length)??0),Rt=Tt>1||Ct>1,kt=x.get(v.start??"")??0,mt=x.get(v.end??"")??0,Vt=Tt>1&&Pt(v.start,W)||Ct>1&&Pt(v.end,ot),re=Tt<=1||kt<=2,Ht=Ct<=1||mt<=2;if((z||tt)&&!ht&&(!Rt||Rt&&!Vt&&re&&Ht)&&!A(O,H,v.start,v.end)){v.points=[{...O},{...U},{...V},{...H}],p.add(g);const vt=tt?"horizontal":"vertical",Ut=tt?O.y:O.x,Lt=tt?Math.min(O.x,H.x):Math.min(O.y,H.y),Et=tt?Math.max(O.x,H.x):Math.max(O.y,H.y),Zt={id:`fast-path-${vt}-${Ut.toFixed(0)}-${g}`,orientation:vt,coord:Ut,spanMin:Lt,spanMax:Et,tracks:[]};u.push({edgeIndex:g,segmentIndex:0,orientation:vt,pipe:Zt,trackIndex:0,from:Lt,to:Et});continue}}const xn=m("vertical",U.x,U.y,U.y);U.x=xn.coord;const Mr=m("vertical",V.x,V.y,V.y);V.x=Mr.coord;let ye=Math.min(U.x,V.x)-50,pe=Math.max(U.x,V.x)+50,we=Math.min(U.y,V.y)-50,Ae=Math.max(U.y,V.y)+50;for(const Y of h){const z=Math.min(U.x,V.x),tt=Math.max(U.x,V.x),ht=Math.min(U.y,V.y),Tt=Math.max(U.y,V.y);Y.minX<tt&&Y.maxX>z&&Y.minY<Tt&&Y.maxY>ht&&(ye=Math.min(ye,Y.minX-qe),pe=Math.max(pe,Y.maxX+qe),we=Math.min(we,Y.minY-qe),Ae=Math.max(Ae,Y.maxY+qe))}for(const Y of h){if(Y.maxX<ye||Y.minX>pe||Y.maxY<we||Y.minY>Ae)continue;const z=Ce;m("horizontal",Y.minY-z,ye,pe),m("horizontal",Y.maxY+z,ye,pe);const tt=Ne;m("vertical",Y.minX-tt,we,Ae),m("vertical",Y.maxX+tt,we,Ae)}m("horizontal",U.y,ye,pe),m("horizontal",V.y,ye,pe);const Ir=d.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=we&&Y.coord<=Ae),Sr=d.filter(Y=>Y.orientation==="vertical"&&Y.coord>=ye&&Y.coord<=pe),He=f((Y,z)=>`${Y.toFixed(1)},${z.toFixed(1)}`,"getKey"),Xe=He(U.x,U.y),wo=He(V.x,V.y),Ye=new Map,bn=new Map,Mn=new Map,Ge=new Set,Se=[];Ye.set(Xe,0),Mn.set(Xe,"n"),Se.push({key:Xe,f:Math.hypot(V.x-U.x,V.y-U.y),pt:U}),Ge.add(Xe);let $t=[];const xe=f((Y,z)=>A(Y,z,v.start,v.end),"checkSegmentBlocked"),In={x:V.x,y:U.y},Cr=xe(U,In),vr=xe(In,V),Lr=Cr||vr,Sn={x:U.x,y:V.y},Er=xe(U,Sn),Tr=xe(Sn,V);if(Lr?Er||Tr||(Math.abs(U.x-V.x)<ft?$t=[U,V]:$t=[U,Sn,V]):Math.abs(U.y-V.y)<ft||Math.abs(U.x-V.x)<ft?$t=[U,V]:$t=[U,In,V],$t.length===0)for(;Se.length>0;){Se.sort((mt,Vt)=>mt.f-Vt.f);const Y=Se.shift();if(Ge.delete(Y.key),Y.key===wo){let mt=wo,Vt=V;for($t=[Vt];bn.has(mt);){const re=bn.get(mt);$t.unshift(re),Vt=re,mt=He(re.x,re.y)}break}const z=Y.pt.x,tt=Y.pt.y,ht=Sr.sort((mt,Vt)=>mt.coord-Vt.coord),Tt=ht.findIndex(mt=>Math.abs(mt.coord-z)<1),Ct=Ir.sort((mt,Vt)=>mt.coord-Vt.coord),Rt=Ct.findIndex(mt=>Math.abs(mt.coord-tt)<1),kt=[];Tt>0&&kt.push({x:ht[Tt-1].coord,y:tt}),Tt>=0&&Tt<ht.length-1&&kt.push({x:ht[Tt+1].coord,y:tt}),Rt>0&&kt.push({x:z,y:Ct[Rt-1].coord}),Rt>=0&&Rt<Ct.length-1&&kt.push({x:z,y:Ct[Rt+1].coord});for(const mt of kt){const Vt=Math.min(z,mt.x),re=Math.max(z,mt.x),Ht=Math.min(tt,mt.y),jt=Math.max(tt,mt.y);if(h.some(ne=>ne.nodeId===v.start||ne.nodeId===v.end?!1:Vt!==re?ne.minY<tt&&ne.maxY>tt&&ne.maxX>Vt&&ne.minX<re:ne.minX<z&&ne.maxX>z&&ne.maxY>Ht&&ne.minY<jt))continue;const vt=He(mt.x,mt.y),Ut=Math.abs(mt.x-z)+Math.abs(mt.y-tt),Lt=M(g,Y.pt,mt);let Et=0;const Zt=V.x-U.x,Re=V.y-U.y,$e=mt.x-z,Cn=mt.y-tt;(Re>10&&Cn<-5||Re<-10&&Cn>5)&&(Et=Math.abs(Cn)*100),(Zt>10&&$e<-5||Zt<-10&&$e>5)&&(Et+=Math.abs($e)*50);let Ao=0;const Ro=Mn.get(Y.key)??"n",No=Math.abs($e)>ft?"h":"v";Ro!=="n"&&Ro!==No&&(Ao=50);const wr=Ut+Lt+Et+Ao,ze=(Ye.get(Y.key)??1/0)+wr,Oo=Math.abs(V.x-mt.x)+Math.abs(V.y-mt.y);if(ze<(Ye.get(vt)??1/0))if(bn.set(vt,Y.pt),Ye.set(vt,ze),Mn.set(vt,No),!Ge.has(vt))Se.push({key:vt,f:ze+Oo,pt:mt}),Ge.add(vt);else{const ne=Se.findIndex(Ar=>Ar.key===vt);ne!==-1&&(Se[ne].f=ze+Oo)}}}if($t.length===0&&($t=[U,{x:U.x,y:V.y},V]),$t.length>4){const Y=$t[0],z=$t[$t.length-1];let tt=Math.min(Y.x,z.x),ht=Math.max(Y.x,z.x),Tt=Math.min(Y.y,z.y),Ct=Math.max(Y.y,z.y);for(const Ht of $t)tt=Math.min(tt,Ht.x),ht=Math.max(ht,Ht.x),Tt=Math.min(Tt,Ht.y),Ct=Math.max(Ct,Ht.y);const Rt=ht>Math.max(Y.x,z.x),kt=tt<Math.min(Y.x,z.x);if(c){const Ht=Ne;if(Rt){const jt=Math.max(Y.x,z.x),_t=Math.min(Y.y,z.y),vt=Math.max(Y.y,z.y),Ut=h.filter(Lt=>Lt.minX<jt&&Lt.maxX>jt&&Lt.minY<vt&&Lt.maxY>_t);if(Ut.length>0){let Lt=Math.max(Y.x,z.x);for(const Et of Ut){const Zt=(Et.minX+Et.maxX)/2;if(Et.visualXHalfExtent===void 0||isNaN(Et.visualXHalfExtent))continue;const Re=Zt+Et.visualXHalfExtent+Ht;Lt=Math.max(Lt,Re)}isNaN(Lt)||(ht=Lt)}}if(kt){const jt=h.filter(_t=>_t.minX<Math.min(Y.x,z.x)+Ht&&_t.minY<Math.max(Y.y,z.y)&&_t.maxY>Math.min(Y.y,z.y));if(jt.length>0){let _t=Math.min(Y.x,z.x);for(const vt of jt){const Lt=(vt.minX+vt.maxX)/2-vt.visualXHalfExtent-Ht;_t=Math.min(_t,Lt)}tt=_t}}}const mt=f(Ht=>{const jt=z.y>Y.y,_t=h.filter(Lt=>{const Et=Math.min(Y.x,z.x)<Lt.maxX&&Math.max(Y.x,z.x)>Lt.minX,Zt=Math.min(Y.y,z.y)<Lt.maxY&&Math.max(Y.y,z.y)>Lt.minY;return Et&&Zt});let vt=_t;if(c&&_t.length>0){const Lt=_t.filter(Et=>Et.minX<Ht&&Et.maxX>Ht);Lt.length>0&&(vt=Lt)}if(vt.length===0)return z.y;const Ut=Ce;if(jt){const Et=Math.max(...vt.map(Zt=>Zt.maxY))+Ut;if(Et<z.y-ft)return Et}else{const Et=Math.min(...vt.map(Zt=>Zt.minY))-Ut;if(Et>z.y+ft)return Et}return z.y},"findBestReturnY"),Vt=f(Ht=>{const jt=mt(Ht),_t={x:Ht,y:Y.y},vt={x:Ht,y:jt},Ut={x:z.x,y:jt},Lt=xe(Y,_t),Et=xe(_t,vt),Zt=xe(vt,Ut),Re=jt!==z.y?xe(Ut,z):!1;return!Lt&&!Et&&!Zt&&!Re?Math.abs(jt-z.y)<ft?[Y,_t,vt,z]:[Y,_t,vt,Ut,z]:null},"trySimplifyWithDetourX"),re=Rt&&!kt?Vt(ht):kt&&!Rt?Vt(tt):null;re&&($t=re)}const zt=[O,...It,...$t,...Gt.reverse(),H];if(zt.length>=3){const Y=zt[zt.length-1],z=zt[zt.length-2],tt=zt[zt.length-3],ht=Math.abs(tt.y-z.y)<ft&&Math.abs(z.y-Y.y)<ft,Tt=Math.abs(tt.x-z.x)<ft&&Math.abs(z.x-Y.x)<ft;if(ht){const Ct=Math.sign(z.x-tt.x),Rt=Math.sign(Y.x-tt.x);Ct!==0&&Ct===Rt&&Math.abs(z.x-tt.x)>Math.abs(Y.x-tt.x)&&zt.splice(-2,1)}else if(Tt){const Ct=Math.sign(z.y-tt.y),Rt=Math.sign(Y.y-tt.y);Ct!==0&&Ct===Rt&&Math.abs(z.y-tt.y)>Math.abs(Y.y-tt.y)&&zt.splice(-2,1)}}const fe=[zt[0]];for(let Y=1;Y<zt.length-1;Y++){if(Y===1){fe.push(zt[Y]);continue}const z=fe[fe.length-1],tt=zt[Y],ht=zt[Y+1];if(Math.abs(z.y-tt.y)<ft&&Math.abs(tt.y-ht.y)<ft){const Tt=tt.x>z.x,Ct=ht.x>tt.x;if(Tt!==Ct){fe.push(tt);continue}continue}if(Math.abs(z.x-tt.x)<ft&&Math.abs(tt.x-ht.x)<ft){const Tt=tt.y>z.y,Ct=ht.y>tt.y;if(Tt!==Ct){fe.push(tt);continue}continue}fe.push(tt)}fe.push(zt[zt.length-1]);for(let Y=0;Y<fe.length-1;Y++){const z=fe[Y],tt=fe[Y+1],ht=Math.abs(z.x-tt.x)<ft?"vertical":"horizontal",Tt=ht==="vertical"?z.x:z.y,Ct=ht==="vertical"?Math.min(z.y,tt.y):Math.min(z.x,tt.x),Rt=ht==="vertical"?Math.max(z.y,tt.y):Math.max(z.x,tt.x),kt=m(ht,Tt,Ct,Rt),mt={edgeIndex:g,segmentIndex:Y,orientation:ht,pipe:kt,trackIndex:0,from:Ct,to:Rt};u.push(mt),a[g].push(u.length-1),kt.tracks[0]||(kt.tracks[0]={index:0,coord:kt.coord,segments:[]}),kt.tracks[0].segments.push({edgeIndex:g,segmentIndex:Y,from:Ct,to:Rt})}}const J=f((g,v)=>g.from<v.to&&v.from<g.to,"segmentsOverlap"),rt=f((g,v,T,E)=>{const O=!E.segments.some(W=>(W.edgeIndex!==v.edgeIndex||W.segmentIndex!==v.segmentIndex)&&J(W,g)),H=!T.segments.some(W=>(W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex)&&J(W,v));return O&&H?(g.trackIndex=E.index,v.trackIndex=T.index,T.segments=[...T.segments.filter(W=>W.edgeIndex!==g.edgeIndex||W.segmentIndex!==g.segmentIndex),{edgeIndex:v.edgeIndex,segmentIndex:v.segmentIndex,from:v.from,to:v.to}],E.segments=[...E.segments.filter(W=>W.edgeIndex!==v.edgeIndex||W.segmentIndex!==v.segmentIndex),{edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to}],!0):!1},"trySwapSegmentsAcrossTracks"),ut=f(g=>{const v=g.tracks.length;return g.tracks[v]={index:v,coord:g.coord,segments:[]},v},"createNewTrack"),pt=f((g,v)=>{const T=g.pipe.tracks[g.trackIndex];T.segments=T.segments.filter(O=>O.edgeIndex!==g.edgeIndex||O.segmentIndex!==g.segmentIndex),g.trackIndex=v,g.pipe.tracks[v].segments.push({edgeIndex:g.edgeIndex,segmentIndex:g.segmentIndex,from:g.from,to:g.to})},"moveSegmentToTrack"),St=f((g,v)=>{const T=a[g.edgeIndex];for(const E of T){const O=u[E];O.pipe===g.pipe&&pt(O,v)}},"moveSegmentChainToTrack"),wt=f(g=>{const v=a[g.edgeIndex],T=v.indexOf(u.indexOf(g)),E=[];return T>0&&E.push(u[v[T-1]]),T<v.length-1&&E.push(u[v[T+1]]),E},"getAdjacentSegmentsAlongEdge"),Kt=f((g,v)=>{if(g.orientation===v.orientation)return!1;const T=g.orientation==="horizontal"?g:v,E=g.orientation==="horizontal"?v:g;return E.pipe.coord>T.from&&E.pipe.coord<T.to&&T.pipe.coord>E.from&&T.pipe.coord<E.to},"haveAnyCrossing"),qt=f((g,v)=>{for(const T of g.tracks)if(!T.segments.some(O=>(O.edgeIndex!==v.edgeIndex||O.segmentIndex!==v.segmentIndex)&&J(O,v)))return T.index;return-1},"findAvailableTrack"),Jt=f((g,v)=>{if(g.trackIndex===v.trackIndex)return J(g,v);const T=wt(g),E=wt(v);return T.some(O=>E.some(H=>Kt(O,H)))},"segmentsConflict"),se=f((g,v,T)=>{if(rt(g,v,g.pipe.tracks[g.trackIndex],v.pipe.tracks[v.trackIndex]))return;const E=qt(g.pipe,v);T(v,E!==-1?E:ut(g.pipe))},"resolveTrackConflict"),Ee=f(g=>{let v=0;for(let T=0;T<g.length;T++)for(let E=T+1;E<g.length;E++){const O=g[T],H=g[E];O.pipe===H.pipe&&Jt(O,H)&&(v++,se(O,H,St))}return v},"resolveHandleConflicts"),me=new Map,Te=f(g=>{if(me.has(g))return me.get(g);const v=a[g];if(v.length===0){const ot={dest:0,deviation:0,base:0,delta:0};return me.set(g,ot),ot}const E=u[v[0]].pipe.coord;let O=E;for(let ot=1;ot<v.length;ot++){const U=u[v[ot]];if(U.orientation==="horizontal"){const V=U.from,bt=U.to;O=Math.abs(V-E)>Math.abs(bt-E)?V:bt;break}}const H=Math.abs(O-E),W={dest:O,deviation:H,base:E,delta:O-E};return me.set(g,W),W},"getDestInfo"),mn=f(()=>{let g=0;const v=new Map;for(const[E,O]of s.entries())a[E].length!==0&&O.start&&(v.has(O.start)||v.set(O.start,[]),v.get(O.start).push(E));const T=f(E=>{const O=s[E];if(!O.start||!O.end)return 0;const H=r.get(O.start),W=r.get(O.end);if(!H||!W)return 0;const ot=(W.x??0)-(H.x??0),U=(W.y??0)-(H.y??0);return Math.abs(ot)+Math.abs(U)},"getEdgeDistance");for(const E of v.values()){E.sort((H,W)=>{const ot=Te(H),U=Te(W);if(Math.abs(ot.deviation-U.deviation)>1)return ot.deviation-U.deviation;if(Math.abs(ot.dest-U.dest)>1)return ot.dest-U.dest;const V=T(H),bt=T(W);if(Math.abs(V-bt)>1)return bt-V;const dt=a[H].length,at=a[W].length;if(dt!==at)return dt-at;if(dt===1){const st=a[H][0],It=a[W][0];if(u[st]&&u[It]){const Ft=u[st],At=u[It],Gt=Math.abs(Ft.to-Ft.from),ee=Math.abs(At.to-At.from);if(Math.abs(Gt-ee)>1)return Gt-ee}}return 0});const O=E.map(H=>u[a[H][0]]);g+=Ee(O)}return g},"fixSourceHandleCrossings"),yn=f(()=>{let g=0;const v=new Map;for(const[T,E]of s.entries())a[T].length!==0&&E.end&&(v.has(E.end)||v.set(E.end,[]),v.get(E.end).push(T));for(const T of v.values()){T.sort((O,H)=>{const W=f(V=>{const bt=a[V];if(bt.length<2)return 0;const dt=u[bt[bt.length-2]];return Math.abs(dt.to-dt.from)},"getDist"),ot=W(O),U=W(H);return Math.abs(ot-U)>.1?ot-U:O-H});const E=T.map(O=>u[a[O][a[O].length-1]]);g+=Ee(E)}return g},"fixTargetHandleCrossings"),pn=f(()=>{let g=0;for(const v of d){const T=[];for(const E of v.tracks)for(const O of E.segments){const H=a[O.edgeIndex].find(W=>u[W].segmentIndex===O.segmentIndex);H!==void 0&&T.push(u[H])}T.sort((E,O)=>E.edgeIndex-O.edgeIndex||E.segmentIndex-O.segmentIndex);for(let E=0;E<T.length;E++)for(let O=E+1;O<T.length;O++){const H=T[E],W=T[O];Jt(H,W)&&(g++,se(H,W,pt))}}return g},"fixPipeCrossings");let N=0;const _=10;for(;N<_;){let g=0;if(g+=mn(),g+=yn(),g+=pn(),g===0)break;N++}const D=new Map;for(const g of d){const v=[];g.tracks.forEach(E=>{E.segments.forEach(O=>{v.push({edgeIndex:O.edgeIndex,segmentIndex:O.segmentIndex,trackIndex:E.index,from:O.from,to:O.to})})}),v.sort((E,O)=>E.from-O.from);const T=[];if(v.length>0){let E=[v[0]],O=v[0].to;for(let H=1;H<v.length;H++){const W=v[H];W.from<O?(E.push(W),O=Math.max(O,W.to)):(T.push(E),E=[W],O=W.to)}T.push(E)}for(const E of T){const O=new Set;E.forEach(st=>O.add(st.trackIndex));const H=new Map;E.forEach(st=>{const It=Te(st.edgeIndex);H.set(st.trackIndex,(H.get(st.trackIndex)??0)+It.delta)});const W=[...O].filter(st=>(H.get(st)??0)<-1),ot=[...O].filter(st=>(H.get(st)??0)>1),U=[...O].filter(st=>Math.abs(H.get(st)??0)<=1);W.sort((st,It)=>(H.get(It)??0)-(H.get(st)??0)),ot.sort((st,It)=>(H.get(st)??0)-(H.get(It)??0));const V=f((st,It)=>{E.filter(Ft=>Ft.trackIndex===st).forEach(Ft=>{const At=p.has(Ft.edgeIndex)?g.coord:It;D.set(`${Ft.edgeIndex}-${Ft.segmentIndex}`,At)})},"assignCoord");let bt=0;for(const st of W)bt++,V(st,g.coord-bt*Tn);if(U.length===0&&O.size>0){const st=[...O].sort((At,Gt)=>Math.abs(H.get(At)??0)-Math.abs(H.get(Gt)??0))[0],It=W.indexOf(st);It!==-1&&W.splice(It,1);const Ft=ot.indexOf(st);Ft!==-1&&ot.splice(Ft,1),U.push(st)}let dt=0;for(const st of U){if(dt===0)V(st,g.coord);else{const It=dt%2===1?1:-1,Ft=Math.ceil(dt/2);V(st,g.coord+It*Ft*Tn*.5)}dt++}let at=0;for(const st of ot)at++,V(st,g.coord+at*Tn)}}for(const[g,v]of s.entries()){const T=a[g]??[];if(T.length===0)continue;const E=[],O=r.get(v.start),H=r.get(v.end),{pSrcPort:W,pDstPort:ot}=nt(g,O,H),U=T.map(dt=>{const at=u[dt],st=D.get(`${at.edgeIndex}-${at.segmentIndex}`)??at.pipe.coord;return{orient:at.orientation,coord:st,from:at.from,to:at.to}});E.push(W);for(let dt=0;dt<U.length;dt++){const at=U[dt],st=E[E.length-1],It=at.orient==="vertical"?st.y:st.x,Ft=at.orient==="vertical"?st.x:st.y,At=U[dt+1],Gt=dt<U.length-1;if(Math.abs(Ft-at.coord)>ft&&E.push(ve(at,It)),Gt&&At.orient===at.orient)if(Math.abs(at.coord-At.coord)>ft){const ee=at.orient==="vertical"?(It+At.from)/2:io(at,At);E.push(ve(at,ee),ve(At,ee))}else(dt===0||dt===U.length-2)&&E.push(ve(at,io(at,At)));else if(Gt)E.push(ve(at,At.coord));else{const ee=Math.abs(at.from-It)<Math.abs(at.to-It)?at.to:at.from;E.push(ve(at,ee))}}const V=E[E.length-1];(Math.abs(V.x-ot.x)>ft||Math.abs(V.y-ot.y)>ft)&&E.push(ot);const bt=[];E.length>0&&bt.push(E[0]);for(let dt=1;dt<E.length;dt++){const at=E[dt],st=bt[bt.length-1];(Math.abs(at.x-st.x)>ft||Math.abs(at.y-st.y)>ft)&&bt.push(at)}v.points=bt}for(const g of s){const v=g.__originalEdge;v&&g.points&&(v.points=g.points)}t.edges=(t.edges??[]).filter(g=>!g.isLayoutOnly);const j=f((g,v)=>{const T=v.x??0,E=v.y??0,O=v.width??0,H=v.height??0;if(O<=0||H<=0)return g;const W=T-O/2,ot=T+O/2,U=E-H/2,V=E+H/2;if(g.x<W||g.x>ot||g.y<U||g.y>V)return g;const bt=g.x-W,dt=ot-g.x,at=g.y-U,st=V-g.y,It=Math.min(bt,dt,at,st);return It===bt?{x:W,y:g.y}:It===dt?{x:ot,y:g.y}:It===at?{x:g.x,y:U}:{x:g.x,y:V}},"nodeBoundaryClamp");for(const g of t.edges){const v=g.points;if(!v||v.length<2)continue;const T=g.start,E=g.end,O=T?r.get(T):void 0,H=E?r.get(E):void 0;O&&(v[0]=j(v[0],O)),H&&(v[v.length-1]=j(v[v.length-1],H))}return t}f(pr,"routeEdgesOrthogonal");function xr(t){return t.direction??"TB"}f(xr,"getSwimlaneDirection");function br(t){var h,m,b,y,u;const e=es(t),n=((h=t.config.flowchart)==null?void 0:h.nodeSpacing)??40,o=((m=t.config.flowchart)==null?void 0:m.rankSpacing)??100,s=((b=t.config.swimlane)==null?void 0:b.ignoreCrossLaneEdges)??!0,r=((y=t.config.swimlane)==null?void 0:y.optimizeRanksByCrossings)??!0,i=((u=t.config.swimlane)==null?void 0:u.automaticLaneOrdering)??!1,d=xr(t),{ordered:c,coordinates:l}=yr(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:i,direction:d});ns(e,c,l,{nodeGap:n,layerGap:o});for(const a of t.edges??[])delete a.points;pr(t,d);for(const a of t.edges??[])(!a.curve||a.curve==="basis")&&(a.curve="rounded");return Ps(t,d),Bs(t),d}f(br,"runSwimlaneLayoutCore");async function oi(t,e){const n=e.select("g");Or(n,t.markers,t.type,t.diagramId),Br(),Pr(),Fr(),Nr(),ts(t);const o=os(t);t.nodes=o.nodes,t.edges=o.edges;const{groups:s}=await Xo(n,t);br(t),await Jo(t,s)}f(oi,"render");export{oi as render};