@codexhost/cli-win32-x64 0.31.0 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +225 -20
  4. package/app/console-web.js +285 -25
  5. package/app/desktop-controller.mjs +534 -143
  6. package/app/host-runtime.mjs +2651 -913
  7. package/app/plugins/antigravity/plugin.mjs +20 -22
  8. package/app/plugins/claude-code/plugin.mjs +21 -0
  9. package/app/plugins/codebuddy/plugin.mjs +29 -2
  10. package/app/plugins/codex-usage/plugin.mjs +18 -0
  11. package/app/plugins/copilot/plugin.mjs +18 -0
  12. package/app/plugins/cursor-cli/plugin.mjs +18 -0
  13. package/app/plugins/deepseek-harness/plugin.mjs +18 -0
  14. package/app/plugins/devin/plugin.mjs +18 -0
  15. package/app/plugins/grok/plugin.mjs +18 -0
  16. package/app/plugins/hermes/plugin.mjs +18 -0
  17. package/app/plugins/kimi-code/plugin.mjs +18 -0
  18. package/app/plugins/kiro-cli/plugin.mjs +18 -0
  19. package/app/plugins/omp/plugin.mjs +18 -0
  20. package/app/plugins/opencode/plugin.mjs +18 -0
  21. package/app/plugins/pi/plugin.mjs +18 -0
  22. package/app/plugins/qoder/plugin.mjs +18 -0
  23. package/app/plugins/qoder-cn/plugin.mjs +18 -0
  24. package/app/plugins/qwen-code/plugin.mjs +18 -0
  25. package/app/plugins/workbuddy/plugin.mjs +29 -2
  26. package/app/plugins/zcode/plugin.mjs +18 -0
  27. package/app/renderer-extension.js +424 -129
  28. package/app/web/assets/{abnfDiagram-XWFEHMT6-Bqy7uOSy.js → abnfDiagram-XWFEHMT6-7XITZmBH.js} +1 -1
  29. package/app/web/assets/{architectureDiagram-CSQXQB3N-6aaP1YoM.js → architectureDiagram-CSQXQB3N-C8Usdzd8.js} +1 -1
  30. package/app/web/assets/{blockDiagram-BEDRHYPZ-B4QSFXe0.js → blockDiagram-BEDRHYPZ-CyN9yE_Q.js} +1 -1
  31. package/app/web/assets/{c4Diagram-M2UUVUY5-BYE-C8Gq.js → c4Diagram-M2UUVUY5-CjhY1l3g.js} +1 -1
  32. package/app/web/assets/{chunk-2Q5K7J3B-CiEM-GTd.js → chunk-2Q5K7J3B-o24_rh4_.js} +1 -1
  33. package/app/web/assets/{chunk-3GCGMST5-hzY9BiB1.js → chunk-3GCGMST5-D7bw3E1a.js} +1 -1
  34. package/app/web/assets/{chunk-5VM5RSS4-DYXznY0H.js → chunk-5VM5RSS4-D0v4acf7.js} +1 -1
  35. package/app/web/assets/{chunk-7U7NFRK5-Bzw5MDPr.js → chunk-7U7NFRK5-CYJxP4rV.js} +1 -1
  36. package/app/web/assets/{chunk-CNRTWJTD-DMbxMfi3.js → chunk-CNRTWJTD-DTgCtcCl.js} +1 -1
  37. package/app/web/assets/{chunk-D5HYT7QG-By0ZVBtD.js → chunk-D5HYT7QG-qRNelehW.js} +1 -1
  38. package/app/web/assets/{chunk-EBZ3SEQC-Yyu_sMV7.js → chunk-EBZ3SEQC-BgJPPYdu.js} +2 -2
  39. package/app/web/assets/{chunk-JWPE2WC7-DDzqxIPT.js → chunk-JWPE2WC7-C50ZnSQQ.js} +1 -1
  40. package/app/web/assets/{chunk-KTR4FSNJ-GlKqhtpl.js → chunk-KTR4FSNJ-Cifh4XHc.js} +1 -1
  41. package/app/web/assets/{chunk-XXDRQBXY-DNc-CvYu.js → chunk-XXDRQBXY-D23WAHPW.js} +1 -1
  42. package/app/web/assets/{classDiagram-v2-KXABOMEV-4_PFS2N_.js → classDiagram-v2-KXABOMEV-B3cezFGj.js} +1 -1
  43. package/app/web/assets/{cose-bilkent-JH36ORCC-BE3foHUY.js → cose-bilkent-JH36ORCC-VSMi4La2.js} +1 -1
  44. package/app/web/assets/{cynefin-EF2NZ3EQ-D2PqrYZ3.js → cynefin-EF2NZ3EQ-qQnfHq16.js} +1 -1
  45. package/app/web/assets/{cynefinDiagram-NJNITYFG-DOObpTbq.js → cynefinDiagram-NJNITYFG-BJELApXD.js} +1 -1
  46. package/app/web/assets/{dagre-KIHZ2IZ3-Znm2jin9.js → dagre-KIHZ2IZ3-C8B5ZMVs.js} +1 -1
  47. package/app/web/assets/{diagram-7YQZDPLS-ByZMD-uA.js → diagram-7YQZDPLS-HIWoNpzV.js} +1 -1
  48. package/app/web/assets/{diagram-QBROCOUO-BiRShpnN.js → diagram-QBROCOUO-3_vS1jbp.js} +1 -1
  49. package/app/web/assets/{diagram-RJJCUUZO-D9wLVoK2.js → diagram-RJJCUUZO-C_Kndn_e.js} +1 -1
  50. package/app/web/assets/{diagram-WERXNKYE-BSbIh-yC.js → diagram-WERXNKYE-BLWdOwya.js} +1 -1
  51. package/app/web/assets/{diagram-YHHI257C-DMWrHMc8.js → diagram-YHHI257C-DJeOs6eS.js} +1 -1
  52. package/app/web/assets/{diagram-YR4HJLHV-C4sBAFb1.js → diagram-YR4HJLHV-BKNULu-g.js} +1 -1
  53. package/app/web/assets/{ebnfDiagram-N527522P-BZLloaoQ.js → ebnfDiagram-N527522P-Bu8aReoF.js} +1 -1
  54. package/app/web/assets/{elk-O5DQBFGD-Da3e5tn5.js → elk-O5DQBFGD-CIp7Z0ER.js} +1 -1
  55. package/app/web/assets/{erDiagram-K3K3BIDK-B2lKAIZF.js → erDiagram-K3K3BIDK-BTsor1Lp.js} +1 -1
  56. package/app/web/assets/{flowDiagram-Z6JWZHQI-q2EY_kmB.js → flowDiagram-Z6JWZHQI-p_h5PKQr.js} +1 -1
  57. package/app/web/assets/{ganttDiagram-3PRQTZWP-BGrNZ20b.js → ganttDiagram-3PRQTZWP-DKjfPPJ1.js} +1 -1
  58. package/app/web/assets/{gitGraphDiagram-VXDFKS5L-DIZNXREy.js → gitGraphDiagram-VXDFKS5L-RnPOf2fj.js} +1 -1
  59. package/app/web/assets/{grid-E2QIVN74-0cUkPG69.js → grid-E2QIVN74-C96GnBO1.js} +1 -1
  60. package/app/web/assets/{index-PN7K-15_.js → index-CDRWzs-u.js} +99 -99
  61. package/app/web/assets/index-Dwdnvinl.css +1 -0
  62. package/app/web/assets/{infoDiagram-EZ3ZOAHP-BHhUTQCn.js → infoDiagram-EZ3ZOAHP-B68eZHsb.js} +1 -1
  63. package/app/web/assets/{ishikawaDiagram-S3EKX5GW-DPOxtl4c.js → ishikawaDiagram-S3EKX5GW-BLj7PFLt.js} +1 -1
  64. package/app/web/assets/{journeyDiagram-POQNLL5X-D8RyXckG.js → journeyDiagram-POQNLL5X-Bo-_In0d.js} +1 -1
  65. package/app/web/assets/{kanban-definition-BH5XI6FM-COJv3Hyh.js → kanban-definition-BH5XI6FM-BpHvxprW.js} +1 -1
  66. package/app/web/assets/{mermaid.core-DYdcDKIt.js → mermaid.core-COb9i2Gl.js} +4 -4
  67. package/app/web/assets/{mindmap-definition-WVAN44T4-DnYIM4ja.js → mindmap-definition-WVAN44T4-DG15AlXd.js} +1 -1
  68. package/app/web/assets/{pegDiagram-D4NLKWP3-Ds3GAEJ6.js → pegDiagram-D4NLKWP3-GMBk8RM6.js} +1 -1
  69. package/app/web/assets/{pieDiagram-36ENHN4W-BhLUJGEB.js → pieDiagram-36ENHN4W-BzeJgVnn.js} +1 -1
  70. package/app/web/assets/{quadrantDiagram-ZQUDMS73-DwtX-IxK.js → quadrantDiagram-ZQUDMS73-C--Kif6a.js} +1 -1
  71. package/app/web/assets/{railroadDiagram-JIZHGYPL-D2vmTTnJ.js → railroadDiagram-JIZHGYPL-NPLVu_R7.js} +1 -1
  72. package/app/web/assets/{render-VIF2ZAQL-DGU1ql-Z.js → render-VIF2ZAQL-DdpQ8E0J.js} +2 -2
  73. package/app/web/assets/{requirementDiagram-AXW2TVFA-u3j1sKkI.js → requirementDiagram-AXW2TVFA-WWRwRbkA.js} +1 -1
  74. package/app/web/assets/{sankeyDiagram-FBCJTAIF-k-An9VHW.js → sankeyDiagram-FBCJTAIF-hBr6pZ0V.js} +1 -1
  75. package/app/web/assets/{sequenceDiagram-3LA2ROMG-DUjbYb4R.js → sequenceDiagram-3LA2ROMG-DvzZWy5J.js} +1 -1
  76. package/app/web/assets/{sizeCapture-2Q2CQKSF-DATTL7FZ.js → sizeCapture-2Q2CQKSF-C2B86W70.js} +1 -1
  77. package/app/web/assets/{stateDiagram-v2-ATKHQDJO-cCJX5M2u.js → stateDiagram-v2-ATKHQDJO-Jwj3XqMx.js} +1 -1
  78. package/app/web/assets/{swimlanes-YQL5WMAO-B7grWEWt.js → swimlanes-YQL5WMAO-DxI0hC09.js} +1 -1
  79. package/app/web/assets/swimlanesDiagram-UCCPES4V-CR0nv8kJ.js +8 -0
  80. package/app/web/assets/{timeline-definition-7Z437IG3-BhsLa6l1.js → timeline-definition-7Z437IG3-m8Ew8iuN.js} +1 -1
  81. package/app/web/assets/{usecaseDiagram-RDK6N6HP-CkPQYmQw.js → usecaseDiagram-RDK6N6HP-BsiPSzIT.js} +1 -1
  82. package/app/web/assets/{vennDiagram-SHRQU5PJ-CufZSwvw.js → vennDiagram-SHRQU5PJ-yYfXhiGp.js} +1 -1
  83. package/app/web/assets/{wardleyDiagram-F3OXNVQS-CSkfpFOA.js → wardleyDiagram-F3OXNVQS-DHLEfnsg.js} +1 -1
  84. package/app/web/assets/{xychartDiagram-GDYJKCDI-BhZf9scK.js → xychartDiagram-GDYJKCDI-Drn_UxYt.js} +1 -1
  85. package/app/web/codexhost-settings.js +123 -55
  86. package/app/web/index.html +2 -2
  87. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +1 -1
  88. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  89. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  90. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +1 -1
  91. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  92. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
  93. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -65
  94. package/app/web/plugins/deepseek-ai__dsh-client-ui-commands/client.js +1 -1
  95. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +18 -18
  96. package/app/web/plugins/deepseek-ai__dsh-client-ui-plan/client.js +1 -1
  97. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  98. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +7 -7
  99. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +2 -2
  100. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  101. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  102. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +69 -69
  103. package/app/web/sw.js +230 -16
  104. package/app/web-modules/node_modules/@deepseek-ai/dsh-client-modules/index.js +7 -7
  105. package/app/web-modules/server.mjs +1144 -185
  106. package/bin/codexhost.exe +0 -0
  107. package/libexec/codexhost-node-repl.exe +0 -0
  108. package/libexec/codexhost-screenshot.exe +0 -0
  109. package/libexec/codexhost-shell.exe +0 -0
  110. package/libexec/codexhost-shim.exe +0 -0
  111. package/libexec/codexhost-updater.exe +0 -0
  112. package/package.json +1 -1
  113. package/app/web/assets/index-BbmB5VLj.css +0 -1
  114. package/app/web/assets/swimlanesDiagram-UCCPES4V-B8Jem9gq.js +0 -8
@@ -1 +1 @@
1
- import{n as mi,a as yi}from"./chunk-3GCGMST5-hzY9BiB1.js";import{c as xi}from"./chunk-EBZ3SEQC-Yyu_sMV7.js";import{_ as i,l as ze}from"./mermaid.core-DYdcDKIt.js";import"./index-PN7K-15_.js";import"./vendor-BKfNgqAm.js";import"./graph-D8UmR1vK.js";function es(t,{measure:e}){const n=mi(t.config?.swimlane?.lineHops);if(n===!1)return;const o=t.edges.filter(s=>Array.isArray(s.points)&&s.points.length>=2).map(s=>({id:s.id,points:s.points,curve:s.curve,cornerRadius:s.cornerRadius,arrowTypeStart:s.arrowTypeStart,arrowTypeEnd:s.arrowTypeEnd}));yi(e.groups.edgePaths,o,{enabled:!0,jumpRadius:6,jumpStyle:n})}i(es,"applySwimlaneLineJumps");function ns(t){const e=t?.metadata?.laneRole;return e==="pool"||e==="lane"?e:void 0}i(ns,"readLaneRole");function sn(t){const e=t?.metadata?.laneIndex;return typeof e=="number"&&Number.isFinite(e)?e:void 0}i(sn,"readLaneIndex");function pe(t){const e=new Map,n=new Map;for(const h of t)e.set(h.id,h),h.isGroup&&h.parentId&&n.set(h.parentId,(n.get(h.parentId)??0)+1);const o=new Set;for(const h of t)h.isGroup&&ns(h)==="pool"&&(n.get(h.id)??0)>0&&o.add(h.id);const s=new Set,r=new Map;for(const h of t)if(!(!h.isGroup||o.has(h.id)))if(h.parentId&&o.has(h.parentId)){s.add(h.id);const y=r.get(h.parentId)??[];y.push(h.id),r.set(h.parentId,y)}else h.parentId||s.add(h.id);const c=i((h,y)=>{const l=new Set([h]);let I=e.get(h)?.parentId;for(;I&&!l.has(I);){if(y.has(I))return I;l.add(I),I=e.get(I)?.parentId}return null},"walk"),a=new Map;return{isPool:i(h=>o.has(h),"isPool"),isLane:i(h=>s.has(h),"isLane"),laneIdOf:i(h=>{const y=a.get(h);if(y!==void 0)return y;const l=c(h,s);return a.set(h,l),l},"laneIdOf"),poolIdOf:i(h=>o.has(h)?h:c(h,o),"poolIdOf"),lanesByPool:r,hasPools:o.size>0}}i(pe,"buildLaneModel");var bi=new Set(["top","right","bottom","left"]),Hn=8,Ii=1e4;function $e(t){const e=t?.metadata?.anchorTo;if(!e||typeof e!="object")return;const{hostId:n,side:o,slot:s,gap:r}=e;if(!(typeof n!="string"||n.length===0||n===t?.id))return{hostId:n,...typeof o=="string"&&bi.has(o)?{side:o}:{},...typeof s=="number"&&Number.isFinite(s)?{slot:s}:{},...typeof r=="number"&&Number.isFinite(r)&&r>0?{gap:Math.min(r,Ii)}:{}}}i($e,"readAnchor");function In(t,e){const n=new Set([t]);let o=$e(e.get(t))?.hostId;for(;o&&!n.has(o);){const s=e.get(o);if(!s)return;const r=$e(s)?.hostId;if(!r)return o;n.add(o),o=r}}i(In,"resolveAnchorHostId");function Ge(t){const e=new Map(t.map(o=>[o.id,o])),n=new Set;for(const o of t)$e(o)&&In(o.id,e)&&n.add(o.id);return n}i(Ge,"collectAnchoredIds");function os(t,e){return t==="canonical"?"right":e==="LR"||e==="RL"?"bottom":"right"}i(os,"defaultAnchorSide");function ss(t,e){const n=t.anchor.slot,o=e.anchor.slot;return n!==void 0&&o!==void 0&&n!==o?n-o:n!==void 0&&o===void 0?-1:n===void 0&&o!==void 0?1:t.index-e.index}i(ss,"compareBucketEntries");function rs(t){const e=t.reduce((s,r)=>s+r,0)+Hn*Math.max(0,t.length-1),n=[];let o=-e/2;for(const s of t)n.push(o+s/2),o+=s+Hn;return{offsets:n,total:e}}i(rs,"packAlongBorder");var Mi=i(t=>[t.width,t.height].every(e=>e===void 0||Number.isFinite(e)),"hasUsableSize");function is(t,e){const n=new Map(t.map(s=>[s.id,s])),o=new Map;t.forEach((s,r)=>{const c=$e(s);if(!c||!Mi(s))return;const a=In(s.id,n);if(!a)return;const f=e(c),h=`${f}:${a}`,y=o.get(h)??[];y.push({node:s,anchor:c,index:r,side:f,hostId:a}),o.set(h,y)});for(const s of o.values())s.sort(ss);return o}i(is,"bucketByHostAndSide");function cs(t,e,n,o){const s=!e&&n>0?-(o+Hn):0;return t+s}i(cs,"centreAlongBorder");function as(t,e){const n=e==="top"||e==="bottom",o=i(h=>n?h.width??0:h.height??0,"alongBorder"),s=i(h=>n?h.height??0:h.width??0,"reach"),{offsets:r}=rs(t.map(h=>o(h.node)));let c=0,a=0,f=0;return t.forEach((h,y)=>{const l=h.anchor.gap??0,I=o(h.node)/2,m=cs(r[y],n,l,I);c=Math.max(c,I-m),a=Math.max(a,m+I),f=Math.max(f,l>0?l+s(h.node):0)}),{before:c,after:a,beyond:f}}i(as,"footprintOf");function ls(t,e){const n=os("final",e??"TB"),o=new Map;for(const s of is(t,r=>r.side??n).values()){if(!s.some(a=>a.anchor.gap))continue;const{hostId:r,side:c}=s[0];o.set(r,{...o.get(r),[c]:as(s,c)})}return o}i(ls,"anchorFootprints");var Bn="__swimlane_default__",Si=21,Ko=20;function Dn(t){return Math.max(t.padding??Ko,Ko)}i(Dn,"topLaneHorizontalPadding");function fs(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const c=n-s/2,a=Math.min(r,n+s/2),f=Math.min(Si,Math.max(0,a-c)),h=c+f;if(h<=c){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:c,bottom:h}}i(fs,"assignTopLaneTitleRect");function ds(t){const e=t.other?.droppedSubGraphMembers;return Array.isArray(e)?e:[]}i(ds,"sharedMembers");var vi=i((t,e,n)=>!e.some(o=>o.parentId===n)&&!(t.edges??[]).some(o=>o.start===n||o.end===n),"isEmptyLane");function us(t,e){return t.isLane(e)?e:t.laneIdOf(e)??void 0}i(us,"laneIdOrSelf");function hs(t,e,n){for(const o of n){const s=e.findIndex(r=>r.id===o);s>=0&&vi(t,e,o)&&e.splice(s,1)}}i(hs,"removeEmptyLanes");function gs(t,e){const n=pe(e),o=new Set(e.filter(r=>n.isLane(r.id)).map(r=>r.id)),s=new Set;for(const{node:r,keptBy:c,droppedFrom:a}of ds(t)){const f=us(n,c);f&&f!==a&&o.has(a)&&(ze.warn(`Swimlane node "${r}" is listed in lanes "${f}" and "${a}"; it is drawn in "${f}" only.`),s.add(a))}hs(t,e,s)}i(gs,"dropLanesEmptiedBySharedNodes");function ps(t,e){for(const n of t)n.isGroup&&!e.isLane(n.id)&&!e.isPool(n.id)&&ze.warn(`Swimlane subgraph "${n.id}" is nested in "${n.parentId}"; only top-level subgraphs are lanes, so it is drawn as a plain box.`)}i(ps,"warnAboutNestedGroups");function ms(t){const e=t.direction,n=t.nodes??=[];gs(t,n);const o=pe(n);ps(n,o);for(const c of n){const a=o.isLane(c.id);!a&&!o.isPool(c.id)||(c.shape=a?"swimlane":"pool",e&&(c.direction=e))}const s=n.filter(c=>!c.isGroup&&!c.parentId);if(s.length===0)return;let r=n.find(c=>c.id===Bn);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:Bn,label:"",isGroup:!0,shape:"swimlane",padding:20,look:t.config?.look,colorIndex:n.reduce((c,a)=>Math.max(c,a.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(r));for(const c of s)c.parentId=Bn}i(ms,"prepareLayoutForSwimlanes");function ys(t){const e=(t.nodes??[]).filter(l=>!l.isEdgeLabel),n=new Map(e.map(l=>[l.id,l])),o=Ge(e),s=i(l=>o.has(l)?In(l,n)??l:l,"hostOf"),r=new Map;for(const l of e)o.has(l.id)||r.set(l.id,l);const c=[];for(const l of t.edges??[]){const I=typeof l.start=="string"?l.start:void 0,m=typeof l.end=="string"?l.end:void 0;if(!I||!m||l.isLayoutOnly)continue;const x=s(I),g=s(m);x!==g&&c.push({id:l.id,src:x,dst:g,ref:l})}const a=e.filter(l=>l.isGroup&&!o.has(l.id)),f=e.filter(l=>!l.isGroup&&!o.has(l.id));return{nodes:[...[...a].reverse(),...f].map(l=>l.id),edges:c,layout:t,nodeById:r}}i(ys,"toGraphView");function xs(t){const e=new Map(t.map(o=>[o.id,o])),n=i(o=>{let s=0,r=o.parentId;const c=new Set([o.id]);for(;r!=null&&!c.has(r);)c.add(r),s++,r=e.get(r)?.parentId;return s},"depthOf");return t.filter(o=>o?.isGroup).map(o=>({node:o,depth:n(o)})).sort((o,s)=>s.depth-o.depth).map(o=>o.node)}i(xs,"groupsDeepestFirst");function bs(t,e,n,o){const{layout:s}=t,r=t.nodeById,c=o?.layerGap??100,a=o?.nodeGap??40;let f=0;for(const x of e.layers){let g=0;for(const b of x){const L=r.get(b);if(!L){g++;continue}L.layer=f,L.order=g;const u=n.x[b]??g*a,C=n.y[b]??f*c;L.x=u,L.y=C,g++}f++}const h=s.nodes??[],y=Ge(h);for(const x of h)x.isEdgeLabel&&n.x[x.id]!=null&&n.y[x.id]!=null&&(x.x=n.x[x.id],x.y=n.y[x.id]);const l=new Map,I=pe(h),m=[];for(const x of xs(h)){I.isLane(x.id)&&m.push(x);const g=h.filter(S=>S.parentId===x.id&&!y.has(S.id));let b=1/0,L=-1/0,u=1/0,C=-1/0;for(const S of g){const p=S.x??n.x[S.id],M=S.y??n.y[S.id],w=S.width??0,A=S.height??0;p!=null&&M!=null&&(S.isEdgeLabel||(b=Math.min(b,p-w/2),L=Math.max(L,p+w/2)),u=Math.min(u,M-A/2),C=Math.max(C,M+A/2))}if(b===1/0||u===1/0)x.x=x.x??0,x.y=x.y??0,x.width=x.width??0,x.height=x.height??0;else{const S=x.padding??20,p=x.parentId?S:2*Dn(x),M=S,w=Math.max(0,L-b)+p,A=Math.max(0,C-u)+M,B=(b+L)/2,P=(u+C)/2;x.x=B,x.y=P,x.width=w,x.height=A,l.set(x.id,{minX:b,maxX:L,minY:u,maxY:C})}}if(m.length>0&&l.size>0){let x=1/0,g=-1/0,b=0;for(const L of m){const u=L.padding??20;u>b&&(b=u);const C=l.get(L.id);C&&(x=Math.min(x,C.minY),g=Math.max(g,C.maxY))}if(x!==1/0&&g!==-1/0){const L=Math.max(0,g-x),C=Math.max(b,36),S=L+2*C,p=(x+g)/2;for(const E of m)E.y=p,E.height=S,E.swimlaneContentTop=x;const M=[...m].sort((E,k)=>{const Y=E.x??0,K=k.x??0;return Y-K}),w=[],A=[],B=[];for(const E of M){const k=l.get(E.id);if(!k)continue;const Y=Math.max(0,k.maxX-k.minX)+2*Dn(E),K=(k.minX+k.maxX)/2;w.push(E.id),A.push(K),B.push(Y)}const P=w.length;if(P>0){const E=new Map;if(P===1)E.set(w[0],B[0]);else{const k=[];for(let at=0;at<P-1;at++)k.push(A[at+1]-A[at]);const Y=new Array(P);Y[0]=0;for(let at=0;at<P-1;at++)Y[at+1]=2*k[at]-Y[at];let K=0,z=Number.POSITIVE_INFINITY;for(let at=0;at<P;at++){const xt=B[at];at%2===0?K=Math.max(K,xt-Y[at]):z=Math.min(z,Y[at]-xt)}let et=K;K<=z?et=(K+z)/2:et=K;for(let at=0;at<P;at++){const xt=Y[at]+(at%2===0?et:-et),Kt=Math.max(B[at],xt);E.set(w[at],Kt)}}for(const k of m){const Y=E.get(k.id);Y!=null&&(k.width=Y),fs(k)}}}}}i(bs,"writeBackToLayoutData");var Ci="[EdgeLabelNodes]";function Is(t){const e=[],n=[],o=new Map;for(const c of t.nodes)o.set(c.id,c);for(const c of t.edges){if(!c.label||c.label.length===0||c.isLayoutOnly||c.labelNodeId)continue;const a=c.start?o.get(c.start):void 0,f=c.end?o.get(c.end):void 0;if(!a||!f){ze.warn(Ci,`Edge ${c.id} has missing source or target node`);continue}const h=`edge-label-${c.start}-${c.end}-${c.id}`,l=a.parentId!==f.parentId?f.parentId:a.parentId,I={id:h,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:l,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(I),c.labelNodeId=h,c.label=void 0,c.text=void 0;const m={id:`${c.id}-to-label`,start:c.start,end:h,type:"normal",isLayoutOnly:!0},x={id:`${c.id}-from-label`,start:h,end:c.end,type:"normal",isLayoutOnly:!0};n.push(m,x)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}i(Is,"createEdgeLabelNodes");var Wt=.001;function Mo(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:De(e,n,o,s)}:void 0}i(Mo,"measuredNodeRect");function So(t){if(t.isGroup)return;const e=Mo(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}i(So,"nodeBoundsInfoFor");function ue(t,e,n=Wt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}i(ue,"samePoint");function St(t,e,n=Wt){return Math.abs(t.x-e.x)<n}i(St,"sameX");function Ct(t,e,n=Wt){return Math.abs(t.y-e.y)<n}i(Ct,"sameY");function Dt(t,e,n=Wt){return Ct(t,e,n)&&Math.abs(t.x-e.x)>n}i(Dt,"isHorizontalSegment");function Xt(t,e,n=Wt){return St(t,e,n)&&Math.abs(t.y-e.y)>n}i(Xt,"isVerticalSegment");function ne(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)))}i(ne,"overlapLength");function ye(t,e,n=Wt){return t.horizontal&&e.horizontal&&Ct(t.a,e.a,n)?ne(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&St(t.a,e.a,n)?ne(t.a.y,t.b.y,e.a.y,e.b.y):0}i(ye,"sameAxisSegmentOverlapLength");function le(t,e=Wt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],c=Dt(s,r,e),a=Xt(s,r,e);(c||a)&&n.push({index:o,a:s,b:r,horizontal:c,vertical:a})}return n}i(le,"orthogonalSegmentsForPoints");function ae(t,e=Wt){const n=le(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}i(ae,"countOrthogonalBends");function Ms(t){const e=le(It(t));return e.slice(1).flatMap((n,o)=>e[o].horizontal===n.horizontal?[]:[n.a])}i(Ms,"bendPoints");function Ss(t,e){const n=Math.max(Math.min(e.a.x,e.b.x)-t.x,0,t.x-Math.max(e.a.x,e.b.x)),o=Math.max(Math.min(e.a.y,e.b.y)-t.y,0,t.y-Math.max(e.a.y,e.b.y));return Math.hypot(n,o)}i(Ss,"distanceToSegment");function an(t,e,n){const o=i((s,r)=>{const c=le(It(r));return Ms(s).some(a=>c.some(f=>Ss(a,f)<n))},"touches");return o(t,e)||o(e,t)}i(an,"routesTouchAtBend");function It(t,e=Wt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ue(s,o,e))&&n.push({x:o.x,y:o.y})}return n}i(It,"dedupeConsecutivePoints");function vo(t,e=Wt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Dt(n,o,e)&&Xt(o,s,e)&&Dt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Xt(n,o,e)&&Dt(o,s,e)&&Xt(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}i(vo,"classifyThreeSegmentRoute");function Mn(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),c=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&a>n.top-o&&c<n.bottom+o}i(Mn,"segmentBoundsOverlapRect");function Co(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}i(Co,"pointInsideRect");function vs(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}i(vs,"rectContainsRect");function ln(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}i(ln,"rectsOverlap");function Xn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}i(Xn,"inflateRect");function De(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}i(De,"rectFromCenterSize");function Qt(t){return Mo(t)?.rect}i(Qt,"rectOfNodeBounds");function Pe(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}}}i(Pe,"portForRectSide");function Lo(t,e,n,o,s,r=Wt){const c=e==="left"||e==="right",a=o==="left"||o==="right";if(c&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(Ct(t,n,r))return[t,n];const l=(t.x+n.x)/2;return[t,{x:l,y:t.y},{x:l,y:n.y},n]}if(e===o){if(Ct(t,n,r))return;const l=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:l,y:t.y},{x:l,y:n.y},n]}return}if(!c&&!a){if(e===o){if(St(t,n,r))return;const I=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:I},{x:n.x,y:I},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(St(t,n,r))return[t,n];const l=(t.y+n.y)/2;return[t,{x:t.x,y:l},{x:n.x,y:l},n]}if(c&&!a){const y=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,l=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return y&&l?[t,{x:n.x,y:t.y},n]:void 0}const f=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,h=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return f&&h?[t,{x:t.x,y:n.y},n]:void 0}i(Lo,"buildOrthogonalPortPath");function wo(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]}i(wo,"buildSameSideTrackPath");function Sn(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=So(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}i(Sn,"collectRealNodeBounds");function xe(t){const e=[],n=[];for(const o of t){const s=So(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}}i(xe,"collectNodeRectEntries");function Cs(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,c=o.width??0,a=o.height??0;n.push({nodeId:o.id,...De(s,r,c,a)})}return n}i(Cs,"collectLayoutNodeRects");function Ao(t,e,n=Wt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),c=e.get(s);if(!(!r||!c))return{srcId:o,dstId:s,srcInfo:r,dstInfo:c,collinearX:Math.abs(r.cx-c.cx)<n,collinearY:Math.abs(r.cy-c.cy)<n}}i(Ao,"getNodePairGeometry");function Ft(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&Mn(t,e,r.rect,-s))return!0;return!1}i(Ft,"segmentHitsAnyRect");function Eo(t,e,n,o,s=Wt,r=1e-6){const c=Ct(t,e,s),a=St(t,e,s),f=Ct(n,o,s),h=St(n,o,s);if(c&&f||a&&h||!(c||a)||!(f||h))return!1;const y=c?{a:t,b:e}:{a:n,b:o},l=a?{a:t,b:e}:{a:n,b:o},I=y.a.y,m=Math.min(y.a.x,y.b.x),x=Math.max(y.a.x,y.b.x),g=l.a.x,b=Math.min(l.a.y,l.b.y),L=Math.max(l.a.y,l.b.y);if(g<m||g>x||I<b||I>L)return!1;const u=Math.abs(g-y.a.x)<r&&Math.abs(I-y.a.y)<r||Math.abs(g-y.b.x)<r&&Math.abs(I-y.b.y)<r,C=Math.abs(g-l.a.x)<r&&Math.abs(I-l.a.y)<r||Math.abs(g-l.b.x)<r&&Math.abs(I-l.b.y)<r;return!(u&&C)}i(Eo,"orthogonalSegmentsCross");function To(t,e,n,o,s=Wt){const r=Ct(t,e,s),c=St(t,e,s),a=Ct(n,o,s),f=St(n,o,s);return c&&f&&St(t,n,s)?ne(t.y,e.y,n.y,o.y)>s:r&&a&&Ct(t,n,s)?ne(t.x,e.x,n.x,o.x)>s:!1}i(To,"sameAxisSegmentsOverlap");function fn(t,e,n,o,{epsilon:s=Wt,skipDegenerateOther:r=!1}={}){for(const c of n){if(c===o||c.isLayoutOnly)continue;const a=c.points;if(!(!a||a.length<2))for(let f=0;f<a.length-1;f++){const h=a[f],y=a[f+1];if(!(r&&ue(h,y,s))&&(Eo(t,e,h,y,s)||To(t,e,h,y,s)))return!0}}return!1}i(fn,"segmentConflictsWithAnyEdge");function be(t,e,n,o,s=Wt){const r=Ct(t,e,s),c=St(t,e,s),a=Ct(n,o,s),f=St(n,o,s);if(!(r&&f||c&&a))return!1;const h=r?{a:t,b:e}:{a:n,b:o},y=r?{a:n,b:o}:{a:t,b:e},l=h.a.y,I=Math.min(h.a.x,h.b.x),m=Math.max(h.a.x,h.b.x),x=y.a.x,g=Math.min(y.a.y,y.b.y),b=Math.max(y.a.y,y.b.y);return x>I+s&&x<m-s&&l>g+s&&l<b-s}i(be,"orthogonalSegmentsStrictlyCross");function Gn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Wt&&t<s-Wt}i(Gn,"strictlyBetween");function Ls(t,e,n){return St(t,e)&&St(e,n)?Gn(e.y,t.y,n.y):Ct(t,e)&&Ct(e,n)?Gn(e.x,t.x,n.x):!1}i(Ls,"isCollinearIntermediate");function ws(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],c=o+1<t.length?t[o+1]:void 0;if(s&&c){if(ue(s,c)){o++,e=!0;continue}if(Ls(s,r,c)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}i(ws,"simplifyPolylineOnce");function dn(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!St(s,r)&&!Ct(s,r)){const c=e.length>=2?e[e.length-2]:void 0,f=(c?St(c,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(f)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ue(s,o))&&n.push(o)}return n}i(dn,"orthogonalizePolyline");function ge(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=ws(e);if(e=o.points,!o.changed)break}return e}i(ge,"simplifyPolyline");var ht=.001,Li=.5,Yn=4;function Ro(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?Qt(s):void 0,dstRect:r?Qt(r):void 0}}i(Ro,"endpointContextFor");function As(t,e,n){if(Ct(t,e,ht))return{x:t.x<n.left?n.left:n.right,y:t.y};if(St(t,e,ht)){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))}}i(As,"segmentEnterPoint");function zn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Co(t[s],e,Li);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const c=As(t[s],t[r],e);return n?[c,...t.slice(s)]:[...t.slice(0,s+1),c]}i(zn,"clipEndpoint");function Es(t,e){for(const n of t){const o=Ro(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=zn(s,o.srcRect,!0)),o.dstRect&&(s=zn(s,o.dstRect,!1)),s=ge(dn(s)),s=Oo(s,o.srcRect,o.dstRect),o.edge.points=ge(dn(s))}}i(Es,"clipEdgeEndpointsToNodeBoundaries");function $n(t,e,n,o=!1){if(Ct(t,e,ht)){if(e.y<n.top-ht||e.y>n.bottom+ht)return e;if(o){if(t.x<n.left-ht)return{x:n.left,y:t.y};if(t.x>n.right+ht)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(St(t,e,ht)){if(e.x<n.left-ht||e.x>n.right+ht)return e;if(o){if(t.y<n.top-ht)return{x:t.x,y:n.top};if(t.y>n.bottom+ht)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}i($n,"snapEndpointToBoundary");function un(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ue(r,o,ht))return r}return t[e+n]}i(un,"firstDistinctAdjacent");function hn(t,e){const n=t+Yn,o=e-Yn;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}i(hn,"cornerClearanceRange");function Vn(t,e,n){const{lo:o,hi:s}=hn(e,n);return Math.min(s,Math.max(o,t))}i(Vn,"clampToCornerClearance");function Ts(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}}i(Ts,"intersectRanges");function Un(t,e){return e==="left"||e==="right"?hn(t.top,t.bottom):hn(t.left,t.right)}i(Un,"clearanceRangeForSide");function gn(t,e,n){const o=t.y>=n.top-ht&&t.y<=n.bottom+ht,s=t.x>=n.left-ht&&t.x<=n.right+ht;if(Ct(t,e,ht)&&o){if(Math.abs(t.x-n.left)<ht)return"left";if(Math.abs(t.x-n.right)<ht)return"right"}if(St(t,e,ht)&&s){if(Math.abs(t.y-n.top)<ht)return"top";if(Math.abs(t.y-n.bottom)<ht)return"bottom"}}i(gn,"terminalSideForSegment");function Ve(t){return t==="left"||t==="right"}i(Ve,"isHorizontalSide");function Rs(t,e,n,o,s){const r=[],c=n?gn(t,e,n):void 0,a=o?gn(e,t,o):void 0;return n&&c&&Ve(c)===s&&r.push(Un(n,c)),o&&a&&Ve(a)===s&&r.push(Un(o,a)),r.length>0?Ts(r):void 0}i(Rs,"straightClearanceRange");function jn(t,e,n,o,s){const r=Rs(t,e,n,o,s);if(!r)return;const c=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,c));if(!(Math.abs(a-c)<ht))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}i(jn,"clearStraightEndpointCornerAxis");function Oo(t,e,n){if(t.length!==2)return t;const[o,s]=t;return Ct(o,s,ht)?jn(o,s,e,n,!0)??t:St(o,s,ht)?jn(o,s,e,n,!1)??t:t}i(Oo,"clearStraightEndpointCornerConnections");function Os(t,e,n){return Ve(n)?{x:t.x,y:Vn(t.y,e.top,e.bottom)}:{x:Vn(t.x,e.left,e.right),y:t.y}}i(Os,"cornerClearedEndpoint");function Ns(t,e,n,o,s,r){const c=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const f=t[a];if(r&&!Ct(f,o,ht)||!r&&!St(f,o,ht))break;r?c[a].y=s.y:c[a].x=s.x}return c}i(Ns,"moveCollinearEndpointRun");function Wn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],c=un(t,o,s);if(!c)return t;const a=gn(r,c,e);if(!a)return t;const f=Ve(a),h=Os(r,e,a);return ue(r,h,ht)?t:Ns(t,o,s,r,h,f)}i(Wn,"clearEndpointCornerConnection");function Kn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ht&&Math.max(t.x,e.x)<=n.right+ht,s=Math.min(t.y,e.y)>=n.top-ht&&Math.max(t.y,e.y)<=n.bottom+ht;if(Math.abs(t.y-n.top)<ht&&Math.abs(e.y-n.top)<ht&&o)return"top";if(Math.abs(t.y-n.bottom)<ht&&Math.abs(e.y-n.bottom)<ht&&o)return"bottom";if(Math.abs(t.x-n.left)<ht&&Math.abs(e.x-n.left)<ht&&s)return"left";if(Math.abs(t.x-n.right)<ht&&Math.abs(e.x-n.right)<ht&&s)return"right"}i(Kn,"borderSideForSegment");function qn(t,e,n,o){switch(t){case"top":return St(e,n,ht)&&n.y<o.top-ht;case"bottom":return St(e,n,ht)&&n.y>o.bottom+ht;case"left":return Ct(e,n,ht)&&n.x<o.left-ht;case"right":return Ct(e,n,ht)&&n.x>o.right+ht}}i(qn,"leavesOutward");function Zn(t,e,n){if(t.length<3)return t;if(n){const r=Kn(t[0],t[1],e);return r&&qn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Kn(t[o-1],t[o],e);return s&&qn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}i(Zn,"collapseOwnBorderStub");function Bs(t,e,n){let o=t;if(e){const r=un(o,0,1);if(r){const c=$n(r,o[0],e);c!==o[0]&&(o=[c,...o.slice(1)])}o=Zn(o,e,!0)}if(n){const r=o.length-1,c=un(o,r,-1);if(c){const a=$n(c,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=Zn(o,n,!1)}const s=Oo(o,e,n);return s!==o||o.length===2?s:(e&&(o=Wn(o,e,!0)),n&&(o=Wn(o,n,!1)),o)}i(Bs,"snapAndCollapseEndpoints");function pn(t,e){for(const n of t){const o=Ro(n,e,2);if(!o)continue;const s=It(o.points,ht),r=Bs(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const c=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=c}}i(pn,"prepareEdgeEndpointsForRenderer");function Ps(t){return new Map(t.map(e=>[e.id,e]))}i(Ps,"buildNodeMap");function Jn(t,e){const n=new Set([t.id]);let o=0,s=t.parentId;for(;s&&!n.has(s);){const r=e.get(s);if(!r?.isGroup)break;n.add(s),o++,s=r.parentId}return o}i(Jn,"groupDepth");function No(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const c=r.x,a=r.y;if(typeof c!="number"||typeof a!="number")continue;const f=r.width??0,h=r.height??0;e=Math.min(e,c-f/2),n=Math.max(n,c+f/2),o=Math.min(o,a-h/2),s=Math.max(s,a+h/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}i(No,"boundsForChildren");function Fs(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}i(Fs,"applyGroupBounds");function ks(t){const e=Ps(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>Jn(s,e)-Jn(o,e));for(const o of n){const s=t.filter(c=>c.parentId===o.id),r=No(s);r&&Fs(o,r)}}i(ks,"recomputeNestedGroupBounds");function mn(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(f=>!f.isGroup);let r=1/0,c=-1/0;for(const f of s){const h=f[e];typeof h=="number"&&(r=Math.min(r,h),c=Math.max(c,h))}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const a=i(f=>r+c-f,"mirror");for(const f of n){const h=f[e];typeof h=="number"&&(f[e]=a(h));const y=f.groupTitleRect;y&&(f.groupTitleRect=e==="x"?{...y,left:a(y.right),right:a(y.left)}:{...y,top:a(y.bottom),bottom:a(y.top)})}for(const f of o)for(const h of f.points??[])h[e]=a(h[e]);return!0}i(mn,"mirrorAxis");function _s(t){return(t.nodes??[]).some(n=>!n.isGroup)?mn(t,"y"):!0}i(_s,"applyBtDirectionTransform");function Bo(t){const e=Ge(t),n=t.filter(a=>!a.isGroup&&!a.isEdgeLabel&&!e.has(a.id));if(n.length===0)return 1;let o=0,s=0;for(const a of n)o+=a.width??0,s+=a.height??0;const r=o/n.length,c=s/n.length;return c>0?Math.max(1,r/c):1}i(Bo,"flowAxisStretch");var wi=36,Ai=["top","right","bottom","left"];function Hs(t){return t==="left"?"right":t==="right"?"left":t}i(Hs,"mirroredSide");function Ds(t,e,n,o,s){if(n==="top"||n==="bottom"){const c=(e.left+e.right)/2,[a,f]=s?[o.after,o.before]:[o.before,o.after];t.left=Math.min(t.left,c-a),t.right=Math.max(t.right,c+f);return}const r=(e.top+e.bottom)/2;t.top=Math.min(t.top,r-o.before),t.bottom=Math.max(t.bottom,r+o.after)}i(Ds,"growAlongBorder");var Ei={top:i((t,e,n)=>{t.top=Math.min(t.top,e.top-n)},"top"),bottom:i((t,e,n)=>{t.bottom=Math.max(t.bottom,e.bottom+n)},"bottom"),left:i((t,e,n)=>{t.left=Math.min(t.left,e.left-n)},"left"),right:i((t,e,n)=>{t.right=Math.max(t.right,e.right+n)},"right")};function Xs(t,e,n,o,s){Ds(t,e,n,o,s),Ei[n](t,e,o.beyond)}i(Xs,"reserveOnSide");function Gs(t,e,n){const o=t.x??0,s=t.y??0,r=(t.width??0)/2,c=(t.height??0)/2,a={left:o-r,right:o+r,top:s-c,bottom:s+c},f={...a},h=n==="RL";for(const y of Ai){const l=e[y];l&&Xs(f,a,h?Hs(y):y,l,h)}return{...t,x:(f.left+f.right)/2,y:(f.top+f.bottom)/2,width:f.right-f.left,height:f.bottom-f.top}}i(Gs,"withAnchorFootprints");function Ys(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=Ge(n),r=n.filter(E=>!E.isGroup&&!s.has(E.id));let c=1/0,a=1/0;for(const E of r){const k=E.x??0,Y=E.y??0;k<c&&(c=k),Y<a&&(a=Y)}if(!Number.isFinite(c)||!Number.isFinite(a))return!1;const f=wi,h=Bo(n);for(const E of r){const k=E.x??0,K=((E.y??0)-a)*h+f,z=k-c;E.x=K,E.y=z}for(const E of o)if(E.points)for(const k of E.points){const Y=k.x,z=(k.y-a)*h+f,et=Y-c;k.x=z,k.y=et}ks(n);const y=pe(n),l=n.filter(E=>y.isLane(E.id));if(l.length===0)return e==="RL"&&mn(t,"x"),!0;const I=new Map,m=ls(n,e);for(const E of n){if(y.isLane(E.id)||y.isPool(E.id)||s.has(E.id))continue;const k=y.laneIdOf(E.id);if(!k)continue;const Y=I.get(k)??[],K=m.get(E.id);Y.push(K?Gs(E,K,e):E),I.set(k,Y)}let x=0;for(const E of l){const k=E.padding??0;k>x&&(x=k)}const g=[];let b=1/0,L=-1/0;for(const E of l){const k=I.get(E.id)??[],Y=No(k);Y&&(b=Math.min(b,Y.minX),L=Math.max(L,Y.maxX),g.push({lane:E,contentTop:Y.minY,contentBottom:Y.maxY,centerY:(Y.minY+Y.maxY)/2}))}if(b===1/0||L===-1/0)return!0;const u=Math.max(0,L-b),C=Math.max(x,10),S=u+2*C,p=f+S,A=(b+L)/2-S/2-f,B=A+p/2,P=Math.max(x,f);g.sort((E,k)=>E.centerY-k.centerY);for(let E=0;E<g.length;E++){const k=g[E];let Y,K;if(E===0?Y=k.contentTop-P:Y=(g[E-1].contentBottom+k.contentTop)/2,E===g.length-1)K=k.contentBottom+P;else{const at=g[E+1];K=(k.contentBottom+at.contentTop)/2}const z=Math.max(0,K-Y),et=(Y+K)/2;k.lane.x=B,k.lane.y=et,k.lane.width=p,k.lane.height=z,k.lane.swimlaneContentTop=k.contentTop,k.lane.groupTitleRect={left:A,right:A+f,top:Y,bottom:K}}return e==="RL"&&mn(t,"x"),!0}i(Ys,"applyLrDirectionTransform");var he=1e-6,Ti=8,en=Ti,Ri=[0,en,-en,2*en,-2*en];function zs(t,e){const{nodeInfoById:n,realNodeRects:o}=Sn(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const c=vo(It(r,he),he);if(!c)continue;const{p3:a}=c,f=c.kind==="HVH",h=Ao(s,n,he);if(!h)continue;const{srcId:y,dstId:l,srcInfo:I,dstInfo:m,collinearX:x,collinearY:g}=h;if(x||g)continue;let b;const L=I.rect;for(const u of Ri){let C,S,p;if(f){const E=m.cy>I.cy?L.bottom:L.top,k=I.cx+u;if(k<=L.left+he||k>=L.right-he)continue;C={x:k,y:E},S={x:k,y:a.y},p={x:a.x,y:a.y}}else{const E=m.cx>I.cx?L.right:L.left,k=I.cy+u;if(k<=L.top+he||k>=L.bottom-he)continue;C={x:E,y:k},S={x:a.x,y:k},p={x:a.x,y:a.y}}const M=ue(C,S,he),w=ue(S,p,he);if(M&&w||!M&&Ft(C,S,o,[y],1)||!w&&Ft(S,p,o,[l],1))continue;const A=!M&&fn(C,S,t,s,{epsilon:he,skipDegenerateOther:!0}),B=!w&&fn(S,p,t,s,{epsilon:he,skipDegenerateOther:!0});if(!(A||B)){M?b=[S,p]:w?b=[C,S]:b=[C,S,p];break}}b&&(s.points=b)}}i(zs,"portSwapToLShape");function $s(t,e){const{realNodeRects:r,labelNodeRects:c}=xe(e.values());for(const a of t){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<4)continue;const h=It(f,.001);if(h.length<4)continue;const y=h.length-1,l=h[y],I=h[y-1],m=h[y-2],x=l.x-I.x,g=l.y-I.y,b=Math.hypot(x,g);if(b>=10||b<.001)continue;const L=I.x-m.x,u=I.y-m.y;if(Math.hypot(L,u)<.001)continue;const S=Dt(I,l,.001),p=Xt(I,l,.001),M=Dt(m,I,.001),w=Xt(m,I,.001);if(!(S&&w||p&&M))continue;const A=a.end,B=a.start,P=A?e.get(A):void 0;if(!P)continue;const E=P.x??0,k=P.y??0,Y=Qt(P);if(!Y)continue;let K,z;if(w){const Q=u<0;K={x:E,y:m.y},z={x:E,y:Q?Y.bottom:Y.top}}else{const Q=L>0;K={x:m.x,y:k},z={x:Q?Y.right:Y.left,y:k}}if(Ft(K,z,r,A?[A]:[],-2)||Ft(K,z,c,[],-2))continue;if(B){const Q=e.get(B),ft=Q?Qt(Q):void 0;if(ft&&Co(K,ft,2))continue}const et=i((Q,ft)=>`${Q.x.toFixed(3)},${Q.y.toFixed(3)}|${ft.x.toFixed(3)},${ft.y.toFixed(3)}`,"ownSegmentKey"),at=new Set;for(let Q=0;Q<h.length-1;Q++)at.add(et(h[Q],h[Q+1]));const xt=i((Q,ft)=>{for(const _ of t){if(_===a||_.isLayoutOnly)continue;const $=_.points;if(!(!$||$.length<2))for(let tt=0;tt<$.length-1;tt++){const Z=$[tt],rt=$[tt+1];if(!at.has(et(Z,rt))&&be(Q,ft,Z,rt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(xt(K,z))continue;if(y-3>=0){const Q=h[y-3],ft=[B,A].filter(_=>!!_);if(Ft(Q,K,r,ft,-2)||xt(Q,K))continue}const Ut=[...h.slice(0,y-2),K,z];a.points=Ut;const jt=a.labelNodeId;if(jt){const Q=e.get(jt);if(Q){const ft=Q.width??0,_=Q.height??0;if(ft>0&&_>0){let $,tt,Z=-1;for(let rt=0;rt<Ut.length-1;rt++){const ut=Ut[rt],gt=Ut[rt+1],pt=Math.hypot(gt.x-ut.x,gt.y-ut.y),bt=Ct(ut,gt,.001),Pt=St(ut,gt,.001);(bt&&pt>=ft+2||Pt&&pt>=_+2)&&pt>Z&&(Z=pt,$=(ut.x+gt.x)/2,tt=(ut.y+gt.y)/2)}$!==void 0&&tt!==void 0&&(Q.x=$,Q.y=tt)}}}}}i($s,"collapseShortTerminalStub");var Oi=4,Ni=2,Po={MIN_ARROWHEAD_SPACING:12,ROUTE_TOUCH_TOLERANCE:Oi+Ni},Bi={EPSILON:1e-6},yn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Pn={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40,EDGE_LABEL_CLEARANCE:16},ct=.001,Vt=8,Vs=i(t=>typeof t=="string"?t.toUpperCase():"","upperCaseDirection"),yt=le,Fn=i((t,e)=>St(t,e,ct)||Ct(t,e,ct),"orthogonallyAligned");function Qn(t,e){const r=i((u,C)=>{const S=Math.min(8,(C-u)/4);return{low:u+S,high:C-S}},"usableFace"),c=i((u,C)=>{const S=u.x??0,p=u.y??0,M=C.x-S,w=C.y-p;let A=(u.width??0)/2,B=(u.height??0)/2;return Math.abs(w)*A>Math.abs(M)*B?(w<0&&(B=-B),{x:S+(w===0?0:B*M/w),y:p+B}):(M<0&&(A=-A),{x:S+A,y:p+(M===0?0:A*w/M)})},"rectIntersect"),a=i((u,C)=>{const S=It(u.points??[]);if(S.length<2)return;const p=C?u.start:u.end,M=p?e.get(p):void 0,w=M?Qt(M):void 0;if(!M||!p||!w)return;const A=C?S[0]:S[S.length-1],B=C?S[1]:S[S.length-2],P=c(M,A);let E=A;if(Fn(B,P)&&(E=B),St(P,E,ct))return{edge:u,edgeId:String(u.id??""),nodeId:p,atStart:C,orientation:"V",coord:P.x,min:Math.min(P.y,E.y),max:Math.max(P.y,E.y),boundary:P,railEnd:E,rect:w};if(Ct(P,E,ct))return{edge:u,edgeId:String(u.id??""),nodeId:p,atStart:C,orientation:"H",coord:P.y,min:Math.min(P.x,E.x),max:Math.max(P.x,E.x),boundary:P,railEnd:E,rect:w}},"terminalLaneFor"),f=i((u,C)=>Math.max(0,Math.min(u.max,C.max)-Math.max(u.min,C.min)),"projectedOverlapLength"),h=i((u,C)=>u.nodeId!==C.nodeId||u.orientation!==C.orientation?!1:u.orientation==="H"?(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1)&&St(u.boundary,C.boundary,1):(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1)&&Ct(u.boundary,C.boundary,1),"sameTerminalFace"),y=i((u,C)=>u.nodeId!==C.nodeId||u.orientation!==C.orientation?!1:f(u,C)>=Vt&&Math.abs(u.coord-C.coord)<.5,"exactTerminalLaneConflict"),l=i((u,C)=>{if(u.nodeId!==C.nodeId||u.orientation!==C.orientation||u.orientation!=="H"||u.atStart===C.atStart)return!1;const S=f(u,C);if(S<Vt)return!1;const p=u.rect.bottom-u.rect.top;return S<p||S>2*p?!1:h(u,C)&&Math.abs(u.coord-C.coord)<16},"nearTerminalLaneConflict"),I=i((u,C)=>{const S=It(u.edge.points??[]);if(S.length<2)return;const p=u.orientation==="V"?{x:u.boundary.x+C,y:u.boundary.y}:{x:u.boundary.x,y:u.boundary.y+C},M=u.orientation==="V"?{x:u.railEnd.x+C,y:u.railEnd.y}:{x:u.railEnd.x,y:u.railEnd.y+C};if(!i(()=>{if(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1){const E=r(u.rect.left,u.rect.right);return Ct(p,u.boundary,ct)&&p.x>=E.low&&p.x<=E.high}if(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1){const E=r(u.rect.top,u.rect.bottom);return St(p,u.boundary,ct)&&p.y>=E.low&&p.y<=E.high}return!1},"boundaryStaysOnSameFace")())return;if(u.atStart){const E=S.length>1&&ue(S[1],u.railEnd,ct),k=S.slice(E?2:1),Y=k[0];return Y&&!Fn(Y,M)?void 0:[p,M,...k]}const A=S.length>1&&ue(S[S.length-2],u.railEnd,ct),B=S.slice(0,A?-2:-1),P=B[B.length-1];if(!(P&&!Fn(P,M)))return[...B,M,p]},"shiftedCandidate"),m=i(u=>{const C=u.edge,S=It(C.points??[]);if(S.length!==2)return!1;const p=C.start,M=C.end,w=p?e.get(p):void 0,A=M?e.get(M):void 0;if(!w||!A)return!1;const B=w.x??0,P=w.y??0,E=A.x??0,k=A.y??0,[Y,K]=S;return Ct(Y,K,ct)&&Math.abs(P-k)<1&&Math.abs(B-E)>1||St(Y,K,ct)&&Math.abs(B-E)<1&&Math.abs(P-k)>1},"laneIsStraightCollinearConnector"),x=i(u=>u.orientation==="H"?r(u.rect.top,u.rect.bottom):r(u.rect.left,u.rect.right),"usableSpanOf"),g=i((u,C)=>{const S=x(u),p=u.coord<C.coord?S.low-u.coord:S.high-u.coord;return Math.sign(p)===Math.sign(u.coord-C.coord)?p:0},"shiftToFaceLimit"),b=i(u=>{const C=x(u);return[C.low-u.coord,C.high-u.coord]},"shiftsToFaceEnds"),L=[-7,7,-14,14,-21,21];for(let u=0;u<8;u++){const C=t.filter(p=>!p.isLayoutOnly).flatMap(p=>[a(p,!0),a(p,!1)]).filter(p=>!!p);let S=!1;for(let p=0;p<C.length&&!S;p++)for(let M=p+1;M<C.length&&!S;M++){const w=C[p],A=C[M];if(w.edge===A.edge||!(y(w,A)||l(w,A)))continue;const B=!y(w,A),P=[w,A].sort((z,et)=>{const at=m(z),xt=m(et);return at!==xt?Number(at)-Number(xt):+!et.atStart-+!z.atStart}),E=i((z,et,at)=>C.some(xt=>xt.edge!==z.edge&&(y(et,xt)||at&&l(et,xt))),"conflictsWith"),k=i((z,et)=>Math.min(...C.filter(at=>at.edge!==z.edge&&at.nodeId===et.nodeId&&at.orientation===et.orientation&&f(et,at)>=Vt).map(at=>Math.abs(et.coord-at.coord))),"closestTrackGap"),Y=i((z,et,at,xt=!1)=>{const Kt=et?a({...z.edge,points:et},z.atStart):void 0;return!et||!Kt||E(z,Kt,at)||xt&&k(z,Kt)<k(z,z)?!1:(z.edge.points=et,!0)},"accept"),K=B?P.filter(z=>!m(z)):P;for(const z of K)if(S=L.some(et=>Y(z,I(z,et),B)),S)break;if(!S){for(const z of K)if(S=(B?[g(z,z===w?A:w)]:b(z)).some(xt=>Math.abs(xt)>ct&&Y(z,I(z,xt),!1,!0)),S)break}}if(!S)return}}i(Qn,"separateSharedRenderedTerminalLanes");function Us(t,e){const{realNodeRects:o,labelNodeRects:s}=xe(e.values()),r=i((a,f)=>{const h=a.start,y=a.end,l=yt(f);if(l.length!==f.length-1)return!1;const I=[h,y].filter(m=>!!m);for(const m of l)if(Ft(m.a,m.b,o,I,-2)||Ft(m.a,m.b,s,[],-2))return!1;for(const m of t){if(m===a||m.isLayoutOnly)continue;const x=m.points;if(!(!x||x.length<2)){for(const g of l)for(const b of yt(It(x)))if(ye(g,b,.5)>=Vt||be(g.a,g.b,b.a,b.b,ct))return!1}}return!0},"candidateIsSafe"),c=i((a,f)=>{if(f+4>=a.length)return;const h=a[f],y=a[f+1],l=a[f+2],I=a[f+3],m=a[f+4],x=Dt(h,y)&&Xt(y,l)&&Dt(l,I)&&Xt(I,m)&&St(h,I,ct)&&St(h,m,ct)&&St(y,l,ct)&&(y.x-h.x)*(I.x-l.x)<0,g=Xt(h,y)&&Dt(y,l)&&Xt(l,I)&&Dt(I,m)&&Ct(h,I,ct)&&Ct(h,m,ct)&&Ct(y,l,ct)&&(y.y-h.y)*(I.y-l.y)<0;if(x||g)return It([...a.slice(0,f+1),m,...a.slice(f+5)]);if(f+5>=a.length)return;const b=a[f+5],L=Xt(h,y)&&Dt(y,l)&&Xt(l,I)&&Dt(I,m)&&Xt(m,b)&&St(h,m,ct)&&St(h,b,ct)&&St(l,I,ct)&&(l.x-y.x)*(m.x-I.x)<0,u=Dt(h,y)&&Xt(y,l)&&Dt(l,I)&&Xt(I,m)&&Dt(m,b)&&Ct(h,m,ct)&&Ct(h,b,ct)&&Ct(l,I,ct)&&(l.y-y.y)*(m.y-I.y)<0;if(!(!L&&!u))return It([...a.slice(0,f+1),b,...a.slice(f+6)])},"withoutDogleg");for(let a=0;a<8;a++){let f=!1;for(const h of t){if(h.isLayoutOnly)continue;const y=It(h.points??[]);for(let l=0;l<=y.length-5;l++){const I=c(y,l);if(!(!I||!r(h,I))){h.points=I,f=!0;break}}if(f)break}if(!f)return}}i(Us,"collapseRedundantRectangularDoglegs");function to(t,e){const{realNodeRects:r,labelNodeRects:c}=xe(e.values()),a=t.filter(x=>!x.isLayoutOnly),f=i((x,g,b)=>It(x===g?b??[]:x.points??[]),"pointsFor"),h=i((x,g)=>{let b=0;for(let L=0;L<a.length;L++){const u=yt(f(a[L],x,g));for(let C=L+1;C<a.length;C++){const S=yt(f(a[C],x,g));for(const p of u)for(const M of S)be(p.a,p.b,M.a,M.b,ct)&&b++}}return b},"strictCrossingCount"),y=i(x=>{const g=yt(x);if(g.length!==3)return;const b=g[1];if(!(g[0].horizontal===b.horizontal||g[2].horizontal===b.horizontal))return{index:b.index,horizontal:b.horizontal,vertical:b.vertical,segment:b}},"middleRail"),l=i((x,g)=>{const b=[x.start,x.end].filter(L=>!!L);return r.filter(L=>{if(b.includes(L.id))return!1;const u=L.rect;return g.horizontal?ne(g.a.x,g.b.x,u.left,u.right)>=Vt&&g.a.y>=u.top-2&&g.a.y<=u.bottom+2:ne(g.a.y,g.b.y,u.top,u.bottom)>=Vt&&g.a.x>=u.left-2&&g.a.x<=u.right+2})},"blockingRectsFor"),I=i((x,g,b)=>{const L=x.map(C=>({...C}));if(g.horizontal)L[g.index].y=b,L[g.index+1].y=b;else if(g.vertical)L[g.index].x=b,L[g.index+1].x=b;else return;const u=ge(It(L));return yt(u).length===u.length-1?u:void 0},"candidateByMovingRail"),m=i((x,g,b)=>{const L=[x.start,x.end].filter(C=>!!C),u=yt(g);if(u.length!==g.length-1)return!1;for(const C of u)if(Ft(C.a,C.b,r,L,-2)||Ft(C.a,C.b,c,[],-2))return!1;for(const C of a)if(C!==x){for(const S of u)for(const p of yt(f(C)))if(ye(S,p,.5)>=Vt)return!1}return h(x,g)<=b},"candidateIsSafe");for(let x=0;x<8;x++){const g=h();let b=!1;for(const L of a){const u=f(L),C=y(u);if(!C)continue;const S=l(L,C.segment);if(S.length===0)continue;const p=C.horizontal?[Math.min(...S.map(M=>M.rect.top))-20,Math.max(...S.map(M=>M.rect.bottom))+20]:[Math.min(...S.map(M=>M.rect.left))-20,Math.max(...S.map(M=>M.rect.right))+20];for(const M of p){const w=I(u,C.segment,M);if(!(!w||!m(L,w,g))){L.points=w,b=!0;break}}if(b)break}if(!b)return}}i(to,"liftObstacleHuggingSameSideRails");function eo(t,e,n){const s=i(y=>{const l=y.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"),r=pe([...e.values()]),c=i(y=>{if(!r.isLane(y.id))return;const l=Vs(y.direction??n);if(l==="LR"||l==="RL"||l==="BT")return;const I=s(y),m=y.y,x=y.height;if(!I||typeof m!="number"||typeof x!="number"||!Number.isFinite(m)||!Number.isFinite(x)||x<=0)return;const g=I.right-I.left,b=I.bottom-I.top;if(!(b<=0||g<b))return{node:y,rect:I}},"topLaneTitleFor"),a=i((y,l)=>{if(!y.horizontal)return!1;const I=y.a.y;return I<l.top-ct||I>l.bottom+ct?!1:ne(y.a.x,y.b.x,l.left,l.right)>=Vt},"horizontalSegmentIntersectsTitle"),f=[...e.values()].map(c).filter(y=>!!y);if(f.length===0)return;let h=0;for(const y of t){if(y.isLayoutOnly)continue;const l=It(y.points??[]);for(const I of yt(l))for(const m of f)a(I,m.rect)&&(h=Math.max(h,m.rect.bottom-I.a.y+4))}if(!(h<=ct))for(const y of f){const l=y.node.y,I=y.node.height;typeof l!="number"||typeof I!="number"||!Number.isFinite(l)||!Number.isFinite(I)||I<=0||(y.node.y=l-h/2,y.node.height=I+h,y.node.groupTitleRect={...y.rect,top:y.rect.top-h,bottom:y.rect.bottom-h})}}i(eo,"liftTopLaneTitleBandsAboveRails");function no(t,e,n){const s=i(l=>{const I=l.groupTitleRect;if(!(!I||typeof I.left!="number"||typeof I.right!="number"||typeof I.top!="number"||typeof I.bottom!="number"||!Number.isFinite(I.left)||!Number.isFinite(I.right)||!Number.isFinite(I.top)||!Number.isFinite(I.bottom)||I.right<=I.left||I.bottom<=I.top))return{left:I.left,right:I.right,top:I.top,bottom:I.bottom}},"validTitleRect"),r=pe([...e.values()]),c=i(l=>{if(!r.isLane(l.id)||Vs(l.direction??n)!=="LR")return;const m=s(l),x=l.x,g=l.width;if(!m||typeof x!="number"||typeof g!="number"||!Number.isFinite(x)||!Number.isFinite(g)||g<=0)return;const b=m.right-m.left,L=m.bottom-m.top;if(!(b<=0||L<b))return{node:l,rect:m}},"leftLaneTitleFor"),a=i((l,I)=>{if(!l.vertical)return!1;const m=l.a.x;return m<I.left-ct||m>I.right+ct?!1:ne(l.a.y,l.b.y,I.top,I.bottom)>=Vt},"verticalSegmentIntersectsTitle"),f=i((l,I)=>{if(!l.horizontal)return!1;const m=l.a.y;return m<I.top-ct||m>I.bottom+ct?!1:ne(l.a.x,l.b.x,I.left,I.right)>=Vt},"horizontalSegmentIntersectsTitle"),h=[...e.values()].map(c).filter(l=>!!l);if(h.length===0)return;let y=0;for(const l of t){if(l.isLayoutOnly)continue;const I=It(l.points??[]);for(const m of yt(I))for(const x of h)if(a(m,x.rect))y=Math.max(y,x.rect.right-m.a.x+4);else if(f(m,x.rect)){const g=Math.min(m.a.x,m.b.x);y=Math.max(y,x.rect.right-g+4)}}if(!(y<=ct))for(const l of h){const I=l.node.x,m=l.node.width;typeof I!="number"||typeof m!="number"||!Number.isFinite(I)||!Number.isFinite(m)||m<=0||(l.node.x=I-y/2,l.node.width=m+y,l.node.groupTitleRect={...l.rect,left:l.rect.left-y,right:l.rect.right-y})}}i(no,"shiftLeftLaneTitleBandsLeftOfRails");function js(t,e){const{realNodeRects:o}=xe(e.values()),s=t.filter(x=>!x.isLayoutOnly),r=i((x,g=new Map)=>It(g.get(x)??x.points??[]),"replacementPointsFor"),c=i((x=new Map)=>{let g=0;for(let b=0;b<s.length;b++){const L=yt(r(s[b],x));for(let u=b+1;u<s.length;u++){const C=yt(r(s[u],x));for(const S of L)for(const p of C)be(S.a,S.b,p.a,p.b,ct)&&g++}}return g},"crossingCount"),a=i((x=new Map)=>s.reduce((g,b)=>g+ae(r(b,x)),0),"totalBends"),f=i(x=>{const g=r(x);if(g.length<4)return;const b=g[g.length-2],L=g[g.length-1];if(!(!Dt(b,L,ct)&&!Xt(b,L,ct)))return{tailStart:b,terminal:L}},"terminalTailFor"),h=i((x,g)=>{const b=r(x);if(b.length<3)return;const L=b[0],u=b[1];let C;if(Dt(L,u,ct))C={x:u.x,y:g.tailStart.y};else if(Xt(L,u,ct))C={x:g.tailStart.x,y:u.y};else return;const S=ge(It([L,u,C,g.tailStart,g.terminal]));return yt(S).length===S.length-1?S:void 0},"candidateWithDestinationTail"),y=i((x,g)=>{const b=[x.start,x.end].filter(L=>!!L);for(const L of yt(g))if(Ft(L.a,L.b,o,b,-2))return!0;return!1},"pathHasNodeHit"),l=i((x,g,b)=>{for(const L of s)if(L!==x){for(const u of yt(g))for(const C of yt(r(L,b)))if(ye(u,C,.5)>=Vt)return!0}return!1},"pathHasSharedTrack"),I=i((x,g,b)=>!y(x,g)&&!l(x,g,b),"candidateIsSafe"),m=i(()=>{const x=new Map;for(const g of s){const b=g.end;if(!b||!e.has(b)||r(g).length<4)continue;const u=x.get(b)??[];u.push(g),x.set(b,u)}return x},"edgesByDestination");for(let x=0;x<4;x++){const g=c();if(g===0)return;const b=a();let L,u=g,C=b;for(const S of m().values())for(let p=0;p<S.length;p++)for(let M=p+1;M<S.length;M++){const w=S[p],A=S[M],B=f(w),P=f(A);if(!B||!P)continue;const E=h(w,P),k=h(A,B);if(!E||!k)continue;const Y=new Map([[w,E],[A,k]]);if(!I(w,E,Y)||!I(A,k,Y))continue;const K=c(Y),z=a(Y);K>=g||K>u||K===u&&z>=C||(L=Y,u=K,C=z)}if(!L)return;for(const[S,p]of L)S.points=p}}i(js,"swapDestinationTerminalTailsToReduceCrossings");function Ws(t,e){const{realNodeRects:r,labelNodeRects:c}=xe(e.values()),a=t.filter(S=>!S.isLayoutOnly),f=i((S,p=new Map)=>It(p.get(S)??S.points??[]),"replacementPointsFor"),h=i((S=new Map)=>{let p=0;for(let M=0;M<a.length;M++){const w=yt(f(a[M],S));for(let A=M+1;A<a.length;A++){const B=yt(f(a[A],S));for(const P of w)for(const E of B)be(P.a,P.b,E.a,E.b,ct)&&p++}}return p},"strictCrossingCount"),y=i((S=new Map)=>a.reduce((p,M)=>p+ae(f(M,S)),0),"totalBends"),l=i(S=>{const p=S.start,M=S.end,w=p?e.get(p):void 0,A=M?e.get(M):void 0,B=w?Qt(w):void 0,P=A?Qt(A):void 0;return B&&P?{src:B,dst:P}:void 0},"endpointRectsFor"),I=i((S,p,M)=>{if(M.index<=0||M.index+1>=p.length-1)return;const w=l(S);if(w){if(M.vertical){const A=M.a.x,B=Math.min(w.src.left,w.dst.left),P=Math.max(w.src.right,w.dst.right),E=A<B-ct?"left":A>P+ct?"right":void 0;return E?{edge:S,points:p,segmentIndex:M.index,axis:"vertical",side:E,coord:A,min:Math.min(M.a.y,M.b.y),max:Math.max(M.a.y,M.b.y)}:void 0}if(M.horizontal){const A=M.a.y,B=Math.min(w.src.top,w.dst.top),P=Math.max(w.src.bottom,w.dst.bottom),E=A<B-ct?"top":A>P+ct?"bottom":void 0;return E?{edge:S,points:p,segmentIndex:M.index,axis:"horizontal",side:E,coord:A,min:Math.min(M.a.x,M.b.x),max:Math.max(M.a.x,M.b.x)}:void 0}}},"externalRailForSegment"),m=i(()=>{const S=[];for(const p of a){const M=f(p);for(const w of yt(M)){const A=I(p,M,w);A&&S.push(A)}}return S},"collectExternalRails"),x=i((S,p)=>S.edge!==p.edge&&S.axis===p.axis&&S.side===p.side&&ne(S.min,S.max,p.min,p.max)>=Vt,"railsInteract"),g=i(S=>{const p=[],M=new Set;for(const w of S){if(M.has(w))continue;const A=[w],B=[];for(M.add(w);A.length>0;){const P=A.pop();B.push(P);for(const E of S)!M.has(E)&&x(P,E)&&(M.add(E),A.push(E))}B.length>1&&p.push(B)}return p},"connectedComponents"),b=i(S=>{const p=[];for(const M of S)p.some(w=>Math.abs(w-M.coord)<ct)||p.push(M.coord);for(;p.length<S.length;){const M=Math.min(...p),w=Math.max(...p),A=S[0].side;p.push(A==="left"||A==="top"?M-12*(S.length-p.length):w+12*(S.length-p.length))}return p},"uniqueCoordsFor"),L=i(S=>{const p=S.map(A=>A.coord),M=b(S),w=[];if(S.length<=6){const A=new Array(M.length).fill(!1),B=[],P=i(()=>{if(B.length===S.length){B.some((E,k)=>Math.abs(E-p[k])>=ct)&&w.push([...B]);return}for(const[E,k]of M.entries())A[E]||(A[E]=!0,B.push(k),P(),B.pop(),A[E]=!1)},"visit");return P(),w}for(let A=0;A<p.length;A++)for(let B=A+1;B<p.length;B++){const P=[...p];[P[A],P[B]]=[P[B],P[A]],w.push(P)}return w},"coordinateAssignmentsFor"),u=i((S,p)=>{const M=new Map;for(const[A,B]of S.entries()){const P=p[A],E=M.get(B.edge)??B.points.map(k=>({x:k.x,y:k.y}));B.axis==="vertical"?(E[B.segmentIndex].x=P,E[B.segmentIndex+1].x=P):(E[B.segmentIndex].y=P,E[B.segmentIndex+1].y=P),M.set(B.edge,E)}const w=new Map;for(const[A,B]of M){const P=ge(It(B));if(yt(P).length!==P.length-1)return;w.set(A,P)}return w},"replacementsForAssignment"),C=i(S=>{for(const[p,M]of S){const w=[p.start,p.end].filter(A=>!!A);for(const A of yt(M))if(Ft(A.a,A.b,r,w,-2)||Ft(A.a,A.b,c,[],-2))return!1}for(let p=0;p<a.length;p++){const M=a[p],w=S.has(M),A=yt(f(M,S));for(let B=p+1;B<a.length;B++){const P=a[B];if(!w&&!S.has(P))continue;const E=yt(f(P,S));for(const k of A)for(const Y of E)if(ye(k,Y,.5)>=Vt)return!1}}return!0},"candidateIsSafe");for(let S=0;S<4;S++){const p=h();if(p===0)return;let M,w=p,A=y(),B=Number.POSITIVE_INFINITY;for(const P of g(m()))for(const E of L(P)){const k=u(P,E);if(!k||!C(k))continue;const Y=h(k);if(Y>=p)continue;const K=y(k),z=P.reduce((et,at,xt)=>et+Math.abs(E[xt]-at.coord),0);Y>w||Y===w&&(K>A||K===A&&z>=B)||(M=k,w=Y,A=K,B=z)}if(!M)return;for(const[P,E]of M)P.points=E}}i(Ws,"reassignCrossingExternalRailChannels");function Ks(t,e){const{realNodeRects:o,labelNodeRects:s}=xe(e.values()),r=t.filter(m=>!m.isLayoutOnly),c=i((m,x,g)=>It(m===x?g??[]:m.points??[]),"pointsFor"),a=i(m=>yt(m).reduce((x,g)=>{const b=g.a.x-g.b.x,L=g.a.y-g.b.y;return x+Math.hypot(b,L)},0),"pathLength"),f=i((m,x)=>{let g=0;for(let b=0;b<r.length;b++){const L=yt(c(r[b],m,x));for(let u=b+1;u<r.length;u++){const C=yt(c(r[u],m,x));for(const S of L)for(const p of C)be(S.a,S.b,p.a,p.b,ct)&&g++}}return g},"strictCrossingCount"),h=i((m,x)=>{if(m.horizontal){const g=m.a.y;return(Math.abs(g-x.top)<1||Math.abs(g-x.bottom)<1)&&ne(m.a.x,m.b.x,x.left,x.right)>=Vt}if(m.vertical){const g=m.a.x;return(Math.abs(g-x.left)<1||Math.abs(g-x.right)<1)&&ne(m.a.y,m.b.y,x.top,x.bottom)>=Vt}return!1},"segmentRunsAlongRectBorder"),y=i(m=>{const x=[m.start,m.end].filter(b=>!!b),g=[];for(const b of x){const L=e.get(b),u=L?Qt(L):void 0;u&&g.push(u)}return g},"endpointRectsFor"),l=i((m,x)=>{if(x+3>=m.length)return[];const g=m[x],b=m[x+1],L=m[x+2],u=m[x+3],C=Dt(g,b,ct)&&Xt(b,L,ct)&&Dt(L,u,ct),S=Xt(g,b,ct)&&Dt(b,L,ct)&&Xt(L,u,ct);if(!C&&!S)return[];if(!(C?Math.sign(b.x-g.x)!==Math.sign(u.x-L.x):Math.sign(b.y-g.y)!==Math.sign(u.y-L.y)))return[];const M=St(g,u,ct)||Ct(g,u,ct)?[]:[{x:g.x,y:u.y},{x:u.x,y:g.y}],w=M.length===0?[[...m.slice(0,x+1),...m.slice(x+3)]]:M.map(B=>[...m.slice(0,x+1),B,...m.slice(x+3)]),A=new Set;return w.map(B=>ge(It(B))).filter(B=>{if(yt(B).length!==B.length-1||!B.some(E=>ue(E,u,ct)))return!1;const P=B.map(E=>`${E.x.toFixed(3)},${E.y.toFixed(3)}`).join("|");return A.has(P)?!1:(A.add(P),!0)})},"shortcutCandidatesAt"),I=i((m,x,g)=>{const b=[m.start,m.end].filter(u=>!!u),L=y(m);for(const u of yt(x))if(Ft(u.a,u.b,o,b,-2)||Ft(u.a,u.b,s,[],-2)||L.some(C=>h(u,C)))return!1;for(const u of r)if(u!==m){for(const C of yt(x))for(const S of yt(c(u)))if(ye(C,S,.5)>=Vt)return!1}return f(m,x)<=g},"candidateIsSafe");for(let m=0;m<8;m++){const x=f();let g,b,L=x,u=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY;for(const S of r){const p=c(S),M=ae(p,ct),w=a(p);for(let A=0;A<=p.length-4;A++)for(const B of l(p,A)){const P=ae(B,ct),E=a(B);if(!(P<M||P===M&&E<w-ct)||!I(S,B,x))continue;const Y=f(S,B);Y>L||Y===L&&(P>u||P===u&&E>=C)||(g=S,b=B,L=Y,u=P,C=E)}}if(!g||!b)return;g.points=b}}i(Ks,"shortcutRedundantOrthogonalJogs");function qs(t,e){const c=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const F=N.x??0,D=N.y??0,j=Qt(N);j&&c.push({id:String(N.id??""),cx:F,cy:D,rect:j})}if(c.length===0)return;const a=new Map(c.map(N=>[N.id,N])),f=c.map(N=>({id:N.id,rect:N.rect})),h=["top","bottom","left","right"],y={top:Math.min(...c.map(N=>N.rect.top))-20,bottom:Math.max(...c.map(N=>N.rect.bottom))+20,left:Math.min(...c.map(N=>N.rect.left))-20,right:Math.max(...c.map(N=>N.rect.right))+20},l=t.filter(N=>!N.isLayoutOnly),I=new Map(l.map((N,F)=>[N,F])),m=i(N=>{const F=N==="left"||N==="top"?-1:1,D=[];for(let j=0;j<=2;j++)D.push(y[N]+F*20*j);return D},"outwardTracksForSide"),x=i((N,F=new Map)=>It(F.get(N)??N.points??[]),"replacementPointsFor"),g=i((N,F)=>{let D=0;for(const j of N)for(const q of F)be(j.a,j.b,q.a,q.b,ct)&&D++;return D},"crossingCountBetweenSegments"),b=i((N,F)=>g(yt(N),yt(F)),"crossingCountBetweenPaths"),L=i((N=new Map)=>{let F=0;const D=[],j=new Set,q=[],nt=i(G=>{j.has(G)||(j.add(G),q.push(G))},"addEdge");for(let G=0;G<l.length;G++){const ot=l[G],dt=x(ot,N);for(let d=G+1;d<l.length;d++){const v=l[d],T=b(dt,x(v,N));T>0&&(F+=T,D.push({first:ot,second:v,count:T}),nt(ot),nt(v))}}return q.sort((G,ot)=>(I.get(G)??0)-(I.get(ot)??0)),{count:F,pairs:D,edgeSet:j,edges:q}},"crossingSnapshot"),u=i((N,F)=>{const D=new Set(F.keys());if(D.size===0)return N.count;let j=0;for(const nt of N.pairs)(D.has(nt.first)||D.has(nt.second))&&(j+=nt.count);let q=0;for(let nt=0;nt<l.length;nt++){const G=l[nt],ot=D.has(G),dt=x(G,F);for(let d=nt+1;d<l.length;d++){const v=l[d];!ot&&!D.has(v)||(q+=b(dt,x(v,F)))}}return N.count-j+q},"crossingCountWithReplacements"),C=i(N=>{const F=new Map;for(const q of N.pairs){const nt=F.get(q.first)??new Set;nt.add(q.second),F.set(q.first,nt);const G=F.get(q.second)??new Set;G.add(q.first),F.set(q.second,G)}const D=[],j=new Set;for(const q of N.edges){if(j.has(q))continue;const nt=[q],G=[];for(j.add(q);nt.length>0;){const ot=nt.pop();G.push(ot);for(const dt of F.get(ot)??[])j.has(dt)||(j.add(dt),nt.push(dt))}G.sort((ot,dt)=>(I.get(ot)??0)-(I.get(dt)??0)),G.length>1&&D.push(G)}return D},"crossingComponents"),S=i(N=>[N.start,N.end].filter(F=>!!F),"endpointIdsFor"),p=i(N=>{const F=[];for(const D of C(N)){const j=new Set(D),q=new Set(D.flatMap(G=>S(G))),nt=[...D];for(const G of l)j.has(G)||S(G).some(ot=>q.has(ot))&&nt.push(G);nt.sort((G,ot)=>(I.get(G)??0)-(I.get(ot)??0)),F.push(nt)}return F},"pairSearchGroups"),M=i((N,F,D)=>u(N,new Map([[F,D]])),"crossingCountWithSingleReplacement"),w=i(N=>{const F=new Map;for(const D of N.pairs)F.set(D.first,(F.get(D.first)??0)+D.count),F.set(D.second,(F.get(D.second)??0)+D.count);return F},"currentCrossingsByEdge"),A=i(N=>N.slice(1).reduce((F,D,j)=>{const q=N[j];return F+Math.abs(D.x-q.x)+Math.abs(D.y-q.y)},0),"pathLength"),B=i((N=new Map)=>l.reduce((F,D)=>F+ae(x(D,N)),0),"totalBends"),P=i((N=new Map)=>l.reduce((F,D)=>F+A(x(D,N)),0),"totalLength"),E=i((N,F)=>an(N,F,Po.ROUTE_TOUCH_TOLERANCE),"touchesAtBend"),k=i((N,F,D=new Map)=>{const j=yt(F);for(const q of l)if(q!==N){for(const nt of j)for(const G of yt(x(q,D)))if(ye(nt,G,.5)>=Vt)return!0;if(E(F,x(q,D)))return!0}return!1},"pathHasSegmentConflict"),Y=i((N,F)=>{const D=[N.start,N.end].filter(j=>!!j);for(const j of yt(F))if(Ft(j.a,j.b,f,D,-2))return!0;return!1},"pathHitsNode"),K=i((N,F)=>{const D=ge(It(F));yt(D).length===D.length-1&&N.push(D)},"pushOrthogonalCandidate"),z=i(N=>N==="left"||N==="right","sideIsHorizontal"),et=i((N,F,D)=>{switch(F){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"),at=i((N,F,D,j)=>{const q=D==="left"||D==="top"?-1:1,nt=[et(F,D,j),y[D]];for(const G of nt)for(let ot=0;ot<=2;ot++)K(N,wo(F,D,j,G+q*20*ot))},"addSameSideCandidates"),xt=i((N,F,D,j,q)=>{for(const nt of m(D))for(const G of m(q))K(N,[F,{x:nt,y:F.y},{x:nt,y:G},{x:j.x,y:G},j])},"addHorizontalToVerticalCandidates"),Kt=i((N,F,D,j,q)=>{for(const nt of m(D))for(const G of m(q))K(N,[F,{x:F.x,y:nt},{x:G,y:nt},{x:G,y:j.y},j])},"addVerticalToHorizontalCandidates"),Ut=i((N,F,D,j,q)=>{const nt=[...m("top"),...m("bottom")];for(const G of m(D))for(const ot of m(q))for(const dt of nt)K(N,[F,{x:G,y:F.y},{x:G,y:dt},{x:ot,y:dt},{x:ot,y:j.y},j])},"addHorizontalPairCandidates"),jt=i((N,F,D,j,q)=>{const nt=[...m("left"),...m("right")];for(const G of m(D))for(const ot of m(q))for(const dt of nt)K(N,[F,{x:F.x,y:G},{x:dt,y:G},{x:dt,y:ot},{x:j.x,y:ot},j])},"addVerticalPairCandidates"),Q=i(N=>{const F=new Set;return N.map(D=>It(D)).filter(D=>{const j=D.map(q=>`${q.x.toFixed(3)},${q.y.toFixed(3)}`).join("|");return F.has(j)||D.length<2?!1:(F.add(j),!0)})},"dedupeCandidatePaths"),ft=i((N,F,D,j)=>{const q=[],nt=Lo(N,F,D,j,20,ct);nt&&K(q,nt),F===j&&at(q,N,F,D);const G=z(F),ot=z(j);return G&&!ot?xt(q,N,F,D,j):!G&&ot?Kt(q,N,F,D,j):G?Ut(q,N,F,D,j):jt(q,N,F,D,j),Q(q)},"buildCandidatesForSides"),_=i((N,F,D,j)=>{const q=[...m("left"),...m("right")],nt=[...m("top"),...m("bottom")];for(const G of h){const ot=Pe(j,G),dt=G==="top"||G==="bottom"?m(G):nt;for(const d of q){z(G)&&K(N,[F,D,{x:d,y:D.y},{x:d,y:ot.y},ot]);for(const v of dt)K(N,[F,D,{x:d,y:D.y},{x:d,y:v},{x:ot.x,y:v},ot])}}},"addVerticalDepartureOuterTrackCandidates"),$=i((N,F,D,j)=>{const q=[...m("left"),...m("right")],nt=[...m("top"),...m("bottom")];for(const G of h){const ot=Pe(j,G),dt=G==="left"||G==="right"?m(G):q;for(const d of nt){z(G)||K(N,[F,D,{x:D.x,y:d},{x:ot.x,y:d},ot]);for(const v of dt)K(N,[F,D,{x:D.x,y:d},{x:v,y:d},{x:v,y:ot.y},ot])}}},"addHorizontalDepartureOuterTrackCandidates"),tt=i(N=>{const F=N.start,D=N.end,j=D?a.get(D):void 0;if(!F||!j)return[];const q=It(N.points??[]);if(q.length<4)return[];const nt=q[0],G=q[1],ot=[];return Xt(nt,G,ct)?_(ot,nt,G,j):Dt(nt,G,ct)&&$(ot,nt,G,j),ot},"terminalPreservingOuterTrackCandidates"),Z=i(N=>{const F=N.start,D=N.end,j=F?a.get(F):void 0,q=D?a.get(D):void 0;if(!j||!q)return[];const nt=[];for(const G of h){const ot=Pe(j,G);for(const dt of h)nt.push(...ft(ot,G,Pe(q,dt),dt))}return nt.push(...tt(N)),nt},"candidatePathsFor"),rt=i(()=>new Map(l.map(N=>[N,yt(x(N))])),"currentSegmentsByEdge"),ut=i((N,F,D,j)=>{const q=new Set;for(const nt of l){if(nt===N)continue;const G=j.get(nt)??yt(x(nt));(D.some(ot=>G.some(dt=>ye(ot,dt,.5)>=Vt))||E(F,x(nt)))&&q.add(nt)}return q},"sharedTrackConflictsFor"),gt=i((N,F,D,j)=>{const q=new Set;return Z(N).map(G=>ge(It(G))).filter(G=>{if(Y(N,G))return!1;const ot=G.map(dt=>`${dt.x.toFixed(3)},${dt.y.toFixed(3)}`).join("|");return q.has(ot)||G.length<2?!1:(q.add(ot),!0)}).map(G=>{const ot=yt(G);let dt=0;for(const d of l)d!==N&&(dt+=g(ot,D.get(d)??yt(x(d))));return{candidate:G,candidateSegments:ot,crossings:F.count-(j.get(N)??0)+dt,bends:ae(G,ct),totalBends:ae(G),length:A(G)}}).filter(({crossings:G})=>G<=F.count).sort((G,ot)=>G.crossings-ot.crossings||G.bends-ot.bends||G.length-ot.length).slice(0,48).map(G=>({path:G.candidate,segments:G.candidateSegments,sharedTrackConflicts:ut(N,G.candidate,G.candidateSegments,D),totalBends:G.totalBends,length:G.length}))},"pairCandidatesFor"),pt=i((N,F,D,j,q,nt)=>{let G=0;for(const dt of N.pairs)(dt.first===F||dt.second===F||dt.first===j||dt.second===j)&&(G+=dt.count);let ot=g(D.segments,q.segments);for(const dt of l){if(dt===F||dt===j)continue;const d=nt.get(dt)??yt(x(dt));ot+=g(D.segments,d)+g(q.segments,d)}return N.count-G+ot},"pairCrossingCount"),bt=i((N,F)=>{for(const D of N.sharedTrackConflicts)if(D!==F)return!1;return!0},"conflictsOnlyWith"),Pt=i((N,F)=>N.segments.some(D=>F.segments.some(j=>ye(D,j,.5)>=Vt))||E(N.path,F.path),"candidatesShareTrack"),Te=i((N,F,D,j)=>bt(F,D.edge)&&bt(j,N.edge)&&!Pt(F,j),"pairCandidatesAreCompatible"),Ie=i((N,F,D,j,q)=>{const nt=pt(N.current,F.edge,D,j.edge,q,N.baseSegments);if(!(nt>=N.current.count))return{replacements:new Map([[F.edge,D.path],[j.edge,q.path]]),crossings:nt,bends:N.currentBends-(N.baseBendsByEdge.get(F.edge)??0)-(N.baseBendsByEdge.get(j.edge)??0)+D.totalBends+q.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(F.edge)??0)-(N.baseLengthByEdge.get(j.edge)??0)+D.length+q.length}},"scorePairReplacement"),Me=i((N,F)=>N.crossings<F.crossings||N.crossings===F.crossings&&(N.bends<F.bends||N.bends===F.bends&&N.length<F.length),"pairScoreIsBetter"),Re=i((N,F,D,j)=>{let q=j;for(const nt of F.candidates)for(const G of D.candidates){if(!Te(F,nt,D,G))continue;const ot=Ie(N,F,nt,D,G);ot&&Me(ot,q)&&(q=ot)}return q},"bestScoreForOptionPair"),We=i(N=>{const F=B(),D=P(),j=rt(),q=w(N),nt=new Map(l.map(T=>[T,ae(x(T))])),G=new Map(l.map(T=>[T,A(x(T))])),ot=new Map,dt=p(N);for(const T of dt)for(const R of T){if(ot.has(R))continue;const O=gt(R,N,j,q);O.length>0&&ot.set(R,{edge:R,candidates:O})}let d={replacements:new Map,crossings:N.count,bends:F,length:D};const v={current:N,currentBends:F,currentLength:D,baseBendsByEdge:nt,baseLengthByEdge:G,baseSegments:j};for(const T of dt){const R=new Set(T.filter(H=>N.edgeSet.has(H))),O=T.map(H=>ot.get(H)).filter(H=>!!H);for(let H=0;H<O.length;H++){const J=O[H];for(let lt=H+1;lt<O.length;lt++){const W=O[lt];!R.has(J.edge)&&!R.has(W.edge)||(d=Re(v,J,W,d))}}}return d.replacements.size>0?d.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const F=L(),D=F.count;if(D===0)return;let j,q,nt=D,G=Number.POSITIVE_INFINITY;for(const dt of F.edges){const d=ae(x(dt),ct);for(const v of Z(dt)){const T=Y(dt,v),R=!T&&k(dt,v),O=M(F,dt,v),H=ae(v,ct);T||R||!(O<D||O===D&&H<d)||O>nt||O===nt&&H>=G||(j=dt,q=v,nt=O,G=H)}}if(j&&q){j.points=q;continue}const ot=We(F);if(!ot)return;for(const[dt,d]of ot)dt.points=d}}i(qs,"resolveRenderedOrthogonalCrossings");var Ae=.001,Pi=8;function Zs(t,e){const{nodeInfoById:n,realNodeRects:o}=Sn(e),s=["top","bottom","left","right"],r=20,c={top:Math.min(...o.map(g=>g.rect.top))-r,bottom:Math.max(...o.map(g=>g.rect.bottom))+r,left:Math.min(...o.map(g=>g.rect.left))-r,right:Math.max(...o.map(g=>g.rect.right))+r},a=i((g,b,L,u)=>{const C=[],S=Lo(g,b,L,u,r,Ae);return S&&C.push(S),b===u&&C.push(wo(g,b,L,c[b])),C},"buildOrthogonalPathCandidates"),f=i((g,b)=>{for(let L=0;L<g.length-1;L++){const u=g[L],C=g[L+1];if(Ft(u,C,o,b,1))return!0}return!1},"pathHitsNode"),h=i((g,b,L=!1)=>{let u=0;const C=le(g,Ae),S=b.start,p=b.end;for(const M of t){if(M===b||M.isLayoutOnly)continue;const w=M.start,A=M.end;if(!L&&S&&p&&(w===S||w===p||A===S||A===p))continue;const B=M.points;if(!(!B||B.length<2))for(const P of C)for(const E of le(B,Ae)){if(Eo(P.a,P.b,E.a,E.b,Ae,Ae)){u++;continue}ye(P,E,Ae)>=Pi&&u++}}return u},"pathConflictCount"),y=4,l=i((g,b)=>{const L=Math.abs(g.y-b.rect.top),u=Math.abs(g.y-b.rect.bottom),C=Math.abs(g.x-b.rect.left),S=Math.abs(g.x-b.rect.right);let p="top",M=L;return u<M&&(p="bottom",M=u),C<M&&(p="left",M=C),S<M&&(p="right",M=S),p},"nearestSideOfRect"),I=new Map,m=i((g,b,L)=>{const u=I.get(g)??[];u.push({side:b,edgeId:L}),I.set(g,u)},"addFaceClaim");for(const g of t){if(g.isLayoutOnly)continue;const b=g.points??[];if(b.length<1)continue;const L=g.id??"",u=g.start,C=g.end;if(u){const S=n.get(u);S&&m(u,l(b[0],S),L)}if(C){const S=n.get(C);S&&m(C,l(b[b.length-1],S),L)}}const x=i((g,b,L)=>I.get(g)?.some(u=>u.edgeId!==L&&u.side===b)??!1,"faceIsClaimed");for(const g of t){if(g.isLayoutOnly)continue;const b=g.points;if(!b||b.length<2)continue;const L=ae(b,Ae);if(L<y)continue;const u=g.start,C=g.end;if(!u||!C)continue;const S=n.get(u),p=n.get(C);if(!S||!p)continue;const M=g.id??"",w=h(b,g,!0),A=h(b,g);let B,P=w,E=L;for(const k of s){if(x(u,k,M))continue;const Y=Pe(S,k);for(const K of s){if(x(C,K,M))continue;const z=Pe(p,K);for(const et of a(Y,k,z,K)){if(f(et,[u,C]))continue;const at=ae(et,Ae);if(w>0){const xt=h(et,g,!0);if(xt>P||xt===P&&at>=E)continue;P=xt,E=at,B=et;continue}h(et,g)>A||at<E&&(E=at,B=et)}}}if(B){g.points=B;const k=I.get(u);k&&I.set(u,k.filter(K=>K.edgeId!==M));const Y=I.get(C);Y&&I.set(C,Y.filter(K=>K.edgeId!==M)),m(u,l(B[0],S),M),m(C,l(B[B.length-1],p),M)}}}i(Zs,"simplifyDetouredEdges");var re=.001,qo=10,nn=7;function oo(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const c=r.x-s.x,a=r.y-s.y;if(!(Math.abs(c)+Math.abs(a)<re)){if(Math.abs(a)<=re){const h=s.x+Math.sign(c)*qo;return{left:Math.min(s.x,h),right:Math.max(s.x,h),top:s.y-nn,bottom:s.y+nn}}if(Math.abs(c)<=re){const h=s.y+Math.sign(a)*qo;return{left:s.x-nn,right:s.x+nn,top:Math.min(s.y,h),bottom:Math.max(s.y,h)}}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)}}}i(oo,"markerClearanceRectFor");function Js(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)}}i(Js,"normalizeRect");function so(t,e){const n=It(e),o=oo(n,!0),s=oo(n,!1);return[o,s].some(r=>r&&ln(t,Js(r)))}i(so,"labelOverlapsOwnMarker");function Ye(t,e){const n=[];for(const g of t){if(g.isLayoutOnly)continue;const b=g.points;if(!(!b||b.length<2))for(let L=0;L<b.length-1;L++)n.push({edgeId:g.id,p1:b[L],p2:b[L+1]})}const o=[],s=[],r=pe([...e.values()]);for(const g of e.values()){const b=g.isGroup;if(r.isLane(g.id)){const u=Qt(g);u&&s.push({id:g.id,rect:u});continue}if(b||g.isEdgeLabel)continue;const L=Qt(g);L&&o.push({nodeId:g.id,rect:L})}const c=3,a=1,f=12,h=i((g,b)=>{const L=Xn(b,c);for(const{nodeId:u,rect:C}of o)if(u!==g&&ln(L,C))return!0;return!1},"labelOverlapsForeignNode"),y=i((g,b)=>{const L=Xn(b,c);for(const u of n)if(u.edgeId!==g&&Mn(u.p1,u.p2,L))return!0;return!1},"labelOverlapsForeignEdge"),l=i((g,b,L)=>h(g,L)||y(b,L),"labelOverlapsAnything"),I=[],m=i(g=>{for(const{id:b,rect:L}of s)if(vs(L,g))return b},"findContainingLane"),x=i((g,b)=>I.some(L=>L.labelId!==g&&ln(b,L.rect)),"overlapsPlacedLabel");for(const g of t){if(g.isLayoutOnly)continue;const b=g.labelNodeId;if(!b)continue;const L=e.get(b);if(!L)continue;const u=g.points;if(!u||u.length<2)continue;const C=L.width??0,S=L.height??0;if(C<=0||S<=0)continue;const p=[];for(let Q=0;Q<u.length-1;Q++){const ft=u[Q],_=u[Q+1],$=Math.abs(ft.x-_.x),tt=Math.abs(ft.y-_.y);$<re&&tt<re||$>=re&&tt>=re||p.push({idx:Q,length:$+tt,orientation:$>=re?"horizontal":"vertical",midX:(ft.x+_.x)/2,midY:(ft.y+_.y)/2})}if(p.length===0)continue;const M=p.length>=3?p.filter(Q=>Q.idx>0&&Q.idx<p.length-1):p,w=M.length>0?M:p,A=C>=S?"horizontal":"vertical",B=i(Q=>[...Q].sort((ft,_)=>{const $=ft.orientation===A,tt=_.orientation===A;if($!==tt)return $?-1:1;const Z=ft.length>=(ft.orientation==="horizontal"?C:S)+2,rt=_.length>=(_.orientation==="horizontal"?C:S)+2;return Z!==rt?Z?-1:1:_.length-ft.length}),"rankSegments"),P=p[0],E=p[p.length-1],k=[.5,.25,.75,.05,.95,.15,.85,.1,.9],Y=i((Q,ft)=>{const _=u[Q.idx],$=u[Q.idx+1];return{midX:_.x+($.x-_.x)*ft,midY:_.y+($.y-_.y)*ft}},"anchorAtT"),K=i((Q,ft,_)=>Math.min(_,Math.max(ft,Q)),"clamp"),z=i((Q,ft)=>Q.midX>=ft.left-re&&Q.midX<=ft.right+re&&Q.midY>=ft.top-re&&Q.midY<=ft.bottom+re,"pointInsideRectInclusive"),et=i(Q=>{const ft=De(Q.midX,Q.midY,C,S),_=m(ft);if(_)return{laneId:_,anchor:Q,rect:ft};const $=s.find(({rect:bt})=>z(Q,bt));if(!$)return;const tt=$.rect.left+C/2+a,Z=$.rect.right-C/2-a,rt=$.rect.top+S/2+a,ut=$.rect.bottom-S/2-a;if(tt>Z||rt>ut)return;const gt={midX:K(Q.midX,tt,Z),midY:K(Q.midY,rt,ut)},pt=De(gt.midX,gt.midY,C,S);return z(Q,pt)?{laneId:$.id,anchor:gt,rect:pt}:void 0},"placementForAnchor"),at=i((Q,ft,_)=>Q.orientation==="horizontal"?Math.abs(ft.midX-_.x):Math.abs(ft.midY-_.y),"distanceAlongSegment"),xt=i((Q,ft)=>{const $=(Q.orientation==="horizontal"?C/2:S/2)+f;if(Q===P){const tt=u[Q.idx];if(at(Q,ft,tt)+re<$)return!1}if(Q===E){const tt=u[Q.idx+1];if(at(Q,ft,tt)+re<$)return!1}return!0},"labelClearsTerminalEndpoints"),Kt=i(Q=>{const ft=B(Q);for(const _ of ft)for(const $ of k){const tt=Y(_,$);if(!xt(_,tt))continue;const Z=et(tt);if(Z&&!so(Z.rect,u)&&!x(b,Z.rect)&&!l(b,g.id,Z.rect))return{laneId:Z.laneId,anchor:Z.anchor}}},"tryPool"),Ut=i((Q,ft,_=!1)=>{const $=B(Q);for(const tt of $){const Z={midX:tt.midX,midY:tt.midY};if(ft&&!xt(tt,Z))continue;const rt=et(Z);if(rt&&!so(rt.rect,u)&&!x(b,rt.rect)&&!h(b,rt.rect)&&(_||!y(g.id,rt.rect)))return{laneId:rt.laneId,anchor:rt.anchor}}},"findLaneContainingFallback"),jt=Kt(w)??(w.length<p.length?Kt(p):void 0)??Ut(p,!0)??Ut(p,!1)??Ut(p,!1,!0);if(jt){L.x=jt.anchor.midX,L.y=jt.anchor.midY,L.parentId=jt.laneId;const Q=De(jt.anchor.midX,jt.anchor.midY,C,S),ft=I.findIndex(_=>_.labelId===b);ft>=0?I[ft]={labelId:b,rect:Q}:I.push({labelId:b,rect:Q})}}}i(Ye,"anchorLabelsToPolyline");var kn=1e-6,Fi=8,Zo=Fi/2,ki=3;function ro(t,e,n,{cx:o,cy:s},r,c){const a={x:o,y:s},f=c==="x"?"y":"x",h=Math.sign(r[f]-a[f]);for(const y of t){if(y===e||y.isLayoutOnly||!y.points?.length)continue;if([...y.end===n?[y.points.at(-1)]:[],...y.start===n?[y.points[0]]:[]].some(I=>Math.sign(I[f]-a[f])===h&&Math.abs(I[c]-r[c])<Po.MIN_ARROWHEAD_SPACING))return!0}return!1}i(ro,"crowdsFaceNeighbour");function io(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}i(io,"pairKey");function Qs(t,e){const{nodeInfoById:n,realNodeRects:o}=Sn(e),s=new Map;for(const c of e){const a=c.id;if(!c.isGroup&&c.isEdgeLabel){s.set(a,{w:c.width??0,h:c.height??0});continue}}const r=i((c,a,f,h)=>{const y=io(a,f);let l=0;const I=i(m=>{if(!m)return;const x=s.get(m);if(!x)return;const g=h==="x"?x.w/2:x.h/2;g>l&&(l=g)},"consider");I(c.labelNodeId);for(const m of t){if(m===c||m.isLayoutOnly)continue;const x=m.start,g=m.end;!x||!g||io(x,g)===y&&I(m.labelNodeId)}return l>0?l+ki:0},"labelClearanceFor");for(const c of t){if(c.isLayoutOnly)continue;const a=c.points;if(!vo(a,kn))continue;const f=Ao(c,n,kn);if(!f)continue;const{srcId:h,dstId:y,srcInfo:l,dstInfo:I,collinearX:m,collinearY:x}=f;if(m===x)continue;let g,b;if(m){const M=I.cy>l.cy;g={x:l.cx,y:M?l.rect.bottom:l.rect.top},b={x:I.cx,y:M?I.rect.top:I.rect.bottom}}else{const M=I.cx>l.cx;g={x:M?l.rect.right:l.rect.left,y:l.cy},b={x:M?I.rect.left:I.rect.right,y:I.cy}}if(Ft(g,b,o,[h,y],1))continue;const L=m?"x":"y",u=r(c,h,y,L),C=u>Zo?u:Zo,S=[0,C,-C];let p;for(const M of S){const w={...g},A={...b};if(m){if(w.x+=M,A.x+=M,w.x<=l.rect.left||w.x>=l.rect.right||A.x<=I.rect.left||A.x>=I.rect.right)continue}else if(w.y+=M,A.y+=M,w.y<=l.rect.top||w.y>=l.rect.bottom||A.y<=I.rect.top||A.y>=I.rect.bottom)continue;if(Ft(w,A,o,[h,y],1)||fn(w,A,t,c,{epsilon:kn}))continue;const B=[w,A];if(ro(t,c,h,l,w,L)||ro(t,c,y,I,A,L)){p??=B;continue}c.points=B,p=void 0;break}p&&(c.points=p)}}i(Qs,"straightenCollinearSiblingDetours");function co(t,e){const{realNodeRects:f,labelNodeRects:h}=xe(e.values()),y=i((p,M)=>le(M,.001).map(w=>({...w,edge:p,interior:w.index>=1&&w.index<=M.length-3})),"segmentsFor"),l=i(()=>{const p=[];for(const M of t){if(M.isLayoutOnly)continue;const w=M.points;!w||w.length<2||p.push(...y(M,It(w)))}return p},"allSegments"),I=i((p,M)=>p.horizontal&&M.horizontal?ne(p.a.x,p.b.x,M.a.x,M.b.x)>=8&&Math.abs(p.a.y-M.a.y)<7:p.vertical&&M.vertical?ne(p.a.y,p.b.y,M.a.y,M.b.y)>=8&&Math.abs(p.a.x-M.a.x)<7:!1,"hasCrowdedParallelTrack"),m=i((p,M)=>{const w=p.start,A=p.end,B=y(p,M);if(B.length!==M.length-1)return!1;const P=[w,A].filter(k=>!!k),E=p.labelNodeId?[p.labelNodeId]:[];for(const k of B)if(Ft(k.a,k.b,f,P,-2)||Ft(k.a,k.b,h,E,-2))return!1;for(const k of t){if(k===p||k.isLayoutOnly)continue;const Y=k.points;if(!(!Y||Y.length<2)){for(const K of B)for(const z of y(k,It(Y)))if(I(K,z)||be(K.a,K.b,z.a,z.b,.001))return!1}}return!0},"candidateIsSafe"),x=i((p,M)=>{const w=It(p.edge.points??[]);if(w.length<4||p.index>=w.length-1)return;const A=w.map(B=>({...B}));if(p.horizontal)A[p.index].y+=M,A[p.index+1].y+=M;else if(p.vertical)A[p.index].x+=M,A[p.index+1].x+=M;else return;return y(p.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),g=i((p,M)=>({x:p.x??(M.left+M.right)/2,y:p.y??(M.top+M.bottom)/2}),"nodeCenter"),b=i(p=>{const M=p.edge,w=It(M.points??[]);if(w.length!==4||p.index!==1)return;const A=M.start?e.get(M.start):void 0,B=M.end?e.get(M.end):void 0,P=A?Qt(A):void 0,E=B?Qt(B):void 0,k=w.slice(p.index+2);if(!(!A||!B||!P||!E||k.length===0))return{sourceCenter:g(A,P),targetCenter:g(B,E),sourceRect:P,tail:k}},"sourceDetourContextFor"),L=i((p,M,w,A,B,P)=>{const E=A.y>=w.y,k=E?B.bottom:B.top,Y=k+(E?20:-20);if(E&&p.b.y<=Y+.001||!E&&p.b.y>=Y-.001)return;const K=p.a.x+M;return It([{x:w.x,y:k},{x:w.x,y:Y},{x:K,y:Y},{x:K,y:p.b.y},...P],.001)},"verticalSourceDetour"),u=i((p,M,w,A,B,P)=>{const E=A.x>=w.x,k=E?B.right:B.left,Y=k+(E?20:-20);if(E&&p.b.x<=Y+.001||!E&&p.b.x>=Y-.001)return;const K=p.a.y+M;return It([{x:k,y:w.y},{x:Y,y:w.y},{x:Y,y:K},{x:p.b.x,y:K},...P],.001)},"horizontalSourceDetour"),C=i((p,M)=>{const w=b(p);if(w){if(p.vertical)return L(p,M,w.sourceCenter,w.targetCenter,w.sourceRect,w.tail);if(p.horizontal)return u(p,M,w.sourceCenter,w.targetCenter,w.sourceRect,w.tail)}},"sourceDetourCandidate"),S=[-7,7,-14,14,-21,21];for(let p=0;p<12;p++){const M=l();let w=!1;for(let A=0;A<M.length&&!w;A++)for(let B=A+1;B<M.length&&!w;B++){const P=M[A],E=M[B];if(P.edge===E.edge||!I(P,E))continue;const k=[P,E].filter(Y=>Y.interior);for(const Y of k){for(const K of S){const z=x(Y,K);if(z&&m(Y.edge,z)){Y.edge.points=z,w=!0;break}const et=C(Y,K);if(et&&m(Y.edge,et)){Y.edge.points=et,w=!0;break}}if(w)break}}if(!w)return}}i(co,"nudgeSharedInteriorSubpaths");var kt=.001,Jo=2,vn=i(t=>t==="top"||t==="bottom"?"x":"y","runsAlongFace");function tr(t,e,n){const o=vn(n),[s,r]=o==="x"?[e.left,e.right]:[e.top,e.bottom];return{top:e.top-t.y,bottom:t.y-e.bottom,left:e.left-t.x,right:t.x-e.right}[n]>-kt&&t[o]>=s-kt&&t[o]<=r+kt}i(tr,"endpointThroughFace");function xn(t,e,n){const o=t.node.id;return n.every(s=>{if(s===e||s.isLayoutOnly)return!0;const r=s.points??[];return[[s.start,r.at(0)],[s.end,r.at(-1)]].every(([a,f])=>a!==o||!f||!tr(f,t.rect,t.side))})}i(xn,"faceIsOwn");function ao(t,e){const n=le(e,kt);return le(t,kt).reduce((o,s)=>o+n.filter(r=>be(s.a,s.b,r.a,r.b,kt)).length,0)}i(ao,"strictCrossings");function er(t,e){const n=le(e,kt);return le(t,kt).some(o=>n.some(s=>To(o.a,o.b,s.a,s.b,kt)))}i(er,"overlapsAny");function Fo(t,e,n,o){const s=Po.ROUTE_TOUCH_TOLERANCE;return o.every(r=>{const c=It(r.points??[],kt);return r===t||r.isLayoutOnly||c.length<2?!0:!er(n,c)&&ao(n,c)<=ao(e,c)&&(!an(n,c,s)||an(e,c,s))})}i(Fo,"clearOfOtherEdges");function ko(t,e,n){const o=t.labelNodeId,s=[t.start,t.end].filter(c=>!!c),r=le(e,kt);return r.every(c=>{const f=c.index===0||c.index===r.length-1?s:[];return!Ft(c.a,c.b,n.realNodeRects,f,Jo)&&!Ft(c.a,c.b,n.labelNodeRects,o?[o]:[],Jo)})}i(ko,"clearOfNodes");var Qo=1;function lo(t){const e=t&&!t.isGroup?Qt(t):void 0;return t&&e?{node:t,rect:e,cx:t.x??0,cy:t.y??0}:void 0}i(lo,"placed");function nr(t,e){const n=e.rect.top>t.rect.bottom;if(!n&&e.rect.bottom>=t.rect.top)return;const[o,s]=n?["bottom","top"]:["top","bottom"];return{from:{node:t.node,rect:t.rect,side:o},to:{node:e.node,rect:e.rect,side:s},points:[{x:t.cx,y:n?t.rect.bottom:t.rect.top},{x:t.cx,y:n?e.rect.top:e.rect.bottom}]}}i(nr,"verticalLine");function or(t,e){const n=e.rect.left>t.rect.right;if(!n&&e.rect.right>=t.rect.left)return;const[o,s]=n?["right","left"]:["left","right"];return{from:{node:t.node,rect:t.rect,side:o},to:{node:e.node,rect:e.rect,side:s},points:[{x:n?t.rect.right:t.rect.left,y:t.cy},{x:n?e.rect.left:e.rect.right,y:t.cy}]}}i(or,"horizontalLine");function sr(t,e){const n=lo(e.get(t.start??"")),o=lo(e.get(t.end??""));if(!(!n||!o||n.node===o.node))return n.node.parentId===o.node.parentId?void 0:[n,o]}i(sr,"crossGroupPair");function rr(t,e){const n=sr(t,e);if(!n)return;const[o,s]=n;return Math.abs(o.cx-s.cx)<=Qo?nr(o,s):Math.abs(o.cy-s.cy)<=Qo?or(o,s):void 0}i(rr,"straightLineFor");var _i=i((t,e)=>t.length===e.length&&t.every((n,o)=>Math.abs(n.x-e[o].x)<kt&&Math.abs(n.y-e[o].y)<kt),"isAlready");function ir(t,e,n,o,s){return xn(e.from,t,o)&&xn(e.to,t,o)&&ko(t,e.points,s)&&Fo(t,n,e.points,o)}i(ir,"lineIsClear");function cr(t,e,n,o){const s=rr(t,n),r=It(t.points??[],kt);return!s||r.length<2||_i(r,s.points)||!ir(t,s,r,e,o)?!1:(t.points=s.points,!0)}i(cr,"straighten");function ar(t,e){const n=xe(e.values());let o=!1;for(const s of t)!s.isLayoutOnly&&cr(s,t,e,n)&&(o=!0);return o}i(ar,"straightenAlignedCrossLaneEdges");var Hi=new Set(["question","diamond","diam","decision"]),Di=i(t=>Hi.has(t.shape??""),"isDiamond"),Ue=i((t,e)=>Math.abs(t-e)<kt,"near"),lr=i((t,e,n)=>t>=e-kt&&t<=n+kt,"within");function fr(t,e,n){if(!(!St(t,e,kt)||!lr(t.x,n.left,n.right)))return Ue(t.y,n.bottom)&&e.y>t.y?"bottom":Ue(t.y,n.top)&&e.y<t.y?"top":void 0}i(fr,"verticalLegFace");function dr(t,e,n){if(!(!Ct(t,e,kt)||!lr(t.y,n.top,n.bottom)))return Ue(t.x,n.right)&&e.x>t.x?"right":Ue(t.x,n.left)&&e.x<t.x?"left":void 0}i(dr,"horizontalLegFace");var Xi=i((t,e,n)=>fr(t,e,n)??dr(t,e,n),"faceOfLeg");function ur(t,e,n,o){const s=Xi(o[0],o[1],n);if(!s)return;const r=vn(s);return Ue(o[1][r],o[2][r])?void 0:{edge:t,node:e,rect:n,side:s,route:o}}i(ur,"terminalFrom");var Gi=i((t,e)=>(e?t.start:t.end)??"","endpointId");function hr(t,e,n){const o=It(t.points??[],kt),s=n.get(Gi(t,e)),r=s?Qt(s):void 0;if(!(!s||!r||o.length<3))return ur(t,s,r,e?o:o.reverse())}i(hr,"terminalAt");function gr({node:t,rect:e,side:n,route:o}){const s=vn(n),r=(s==="x"?t.x:t.y)??0,c=o[0][s];if(Math.abs(c-r)<kt)return;if(Di(t))return r;const[a,f]=s==="x"?[e.left,e.right]:[e.top,e.bottom];return Math.min(c-a,f-c)<=Yn+kt?r:void 0}i(gr,"alignedCoord");function pr(t,e,n,o){const s=gr(t);if(s===void 0||!xn(t,t.edge,e))return!1;const r=vn(t.side),[c,a,...f]=t.route,h=ge(It([{...c,[r]:s},{...a,[r]:s},...f],kt)),y=o?t.route:[...t.route].reverse(),l=o?h:[...h].reverse();return!ko(t.edge,l,n)||!Fo(t.edge,y,l,e)?!1:(t.edge.points=l,!0)}i(pr,"alignTerminal");function mr(t,e){const n=xe(e.values());let o=!1;for(const s of t)if(!s.isLayoutOnly)for(const r of[!0,!1]){const c=hr(s,r,e);c&&pr(c,t,n,r)&&(o=!0)}return o}i(mr,"alignTerminalLegsToPorts");function yr(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=o.x-n.x,a=o.y-n.y,f=s*a-r*c;if(Math.abs(f)<1e-10)return!1;const h=n.x-t.x,y=n.y-t.y,l=(h*a-y*c)/f,I=(h*r-y*s)/f,m=.01;return l>m&&l<1-m&&I>m&&I<1-m}i(yr,"segmentsIntersect");function xr(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Cs(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<2)continue;const h=a.start,y=a.end,l=a.labelNodeId,I=a.id??`${h}->${y}`;for(const m of s)if(!(m.nodeId===h||m.nodeId===y)&&!(l&&m.nodeId===l)){for(let x=0;x<f.length-1;x++)if(Mn(f[x],f[x+1],m,-1)){o.push({type:"edge-node-overlap",edgeId:I,targetId:m.nodeId,detail:`segment ${x} passes through node "${m.nodeId}"`});break}}for(let m=0;m<f.length-1;m++)r.push({edgeId:I,start:h,end:y,p1:f[m],p2:f[m+1]})}const c=new Set;for(let a=0;a<r.length;a++)for(let f=a+1;f<r.length;f++){const h=r[a],y=r[f];if(h.edgeId!==y.edgeId&&!(h.start===y.start||h.start===y.end||h.end===y.start||h.end===y.end)&&yr(h.p1,h.p2,y.p1,y.p2)){const l=h.edgeId<y.edgeId?`${h.edgeId}|${y.edgeId}`:`${y.edgeId}|${h.edgeId}`;c.has(l)||(c.add(l),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:y.edgeId,detail:`edges "${h.edgeId}" and "${y.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(h=>h.type==="edge-node-overlap").length,f=o.filter(h=>h.type==="edge-edge-crossing").length;ze.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${f} edge crossing(s)`);for(const h of o)ze.warn(`[SWIMLANE_VALIDATE] ${h.type}: ${h.detail}`)}return o}i(xr,"validateSwimlanesLayout");function br(t,e){const n=ar(t,e);(mr(t,e)||n)&&(Ye(t,e),pn(t,e))}i(br,"alignTerminalLegsAndRefresh");function Ir(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Ys(t,e)||e==="BT"&&s.length>0&&!_s(t))return;for(const a of o){if(a.isLayoutOnly)continue;const f=a.points;!f||f.length<2||(a.points=ge(dn(f)))}Zs(o,n),Qs(o,n),zs(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);Ye(o,r),Es(o,r),$s(o,r),co(o,r),Qn(o,r),Us(o,r),to(o,r),js(o,r);const c=i(()=>{qs(o,r),Qn(o,r),Ws(o,r),Ks(o,r),Ye(o,r),pn(o,r),to(o,r),Ye(o,r),pn(o,r)},"finalizeRenderedEdges");c(),co(o,r),c(),br(o,r),eo(o,r,e),no(o,r,e),eo(o,r,e),no(o,r,e)}i(Ir,"postProcessSwimlaneLayout");function Ee(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const c=`${r.id}:${r.src}->${r.dst}`;n.has(c)||(n.add(c),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}i(Ee,"normalizeGraph");function _o(t,e){return t.edges.filter(n=>n.dst===e)}i(_o,"incoming");function Mr(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}i(Mr,"buildSuccessorMap");function Ho(t){const e=Mr(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}i(Ho,"buildSortedSuccessorMap");function Cn(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}i(Cn,"buildInDegreeMap");function Do(t,e){const n=[...e.entries()].filter(([,a])=>a===0).map(([a])=>a).sort((a,f)=>a.localeCompare(f)),o=new Set(t.edges.flatMap(a=>[a.src,a.dst])),s=i(a=>!o.has(a)&&!t.nodeById.get(a)?.isGroup,"isUnconnected"),r=[...e.keys()].filter(a=>e.get(a)===0&&s(a));let c=0;return n.map(a=>s(a)?r[c++]:a)}i(Do,"sortedZeroInDegreeNodes");function Ln(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}}i(Ln,"buildPredecessorSuccessorMaps");function Xo(t,e,n,o){let s=0;for(const c of t.nodes)o?.skipGroups&&t.nodeById.get(c)?.isGroup||(s=Math.max(s,n[c]??0));const r=Array.from({length:s+1},()=>[]);for(const c of e)o?.skipGroups&&t.nodeById.get(c)?.isGroup||r[Math.max(0,n[c]??0)].push(c);return r}i(Xo,"buildLayersFromRanks");function je(t){const e=Cn(t),n=Do(t,e),o=[],s=Ho(t);for(;n.length;){const r=n.shift();o.push(r);for(const c of s.get(r)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let a=0;for(;a<n.length&&n[a]<c;)a++;n.splice(a,0,c)}}return o.length===t.nodes.length?o:null}i(je,"topoSortIfAcyclic");function Xe(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}i(Xe,"buildLayerIndex");function Go(t){const e=new Array(t.length),n=i((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let c=n(o,r)+n(r,s),a=o,f=r,h=o;for(;a<r||f<s;)f>=s||a<r&&t[a]<=t[f]?e[h++]=t[a++]:(e[h++]=t[f++],c+=r-a);for(let y=o;y<s;y++)t[y]=e[y];return c},"count");return n(0,t.length)}i(Go,"countInversions");function Sr(t){const e=Ee(t),n=new Map;for(const l of e.nodes)n.set(l,[]);for(const l of e.edges)n.get(l.src).push(l);for(const l of n.values())l.sort((I,m)=>I.dst===m.dst?I.id.localeCompare(m.id):I.dst.localeCompare(m.dst));const o=Object.create(null);for(const l of e.nodes)o[l]=0;const s=[],r=i(l=>{o[l]=1;for(const I of n.get(l)??[]){const m=I.dst;o[m]===0?r(m):o[m]===1&&s.push(I)}o[l]=2},"dfs"),c=Cn(e),a=[...e.nodes.filter(l=>(c.get(l)??0)===0),...e.nodes.filter(l=>(c.get(l)??0)!==0)];for(const l of a)o[l]===0&&r(l);const f=new Set(s.map(l=>`${l.id}:${l.src}->${l.dst}`)),h=e.edges.map(l=>f.has(`${l.id}:${l.src}->${l.dst}`)?{id:l.id,src:l.dst,dst:l.src,weight:l.weight,ref:l.ref}:l);return{acyclic:{nodes:[...e.nodes],edges:h,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}i(Sr,"removeCycles_DFS");function vr(t){const e=pe(t.layout.nodes??[]),n=new Map;for(const o of t.nodes)n.set(o,e.laneIdOf(o));return n}i(vr,"buildTopLaneMap");function Se(t){const e=vr(t);return n=>e.get(n)??null}i(Se,"createTopLaneResolver");function wn(t){const e=t.layout.nodes??[],n=pe(e),o=e.filter(c=>n.isLane(c.id)),s=o.filter(c=>sn(c)!==void 0);if(s.length>0&&s.length===o.length)return[...s].sort((c,a)=>(sn(c)??0)-(sn(a)??0)).map(c=>c.id);if(!n.hasPools)return[...new Set(o.map(c=>c.id))].reverse();const r=[];for(const c of e)c.parentId||(n.isPool(c.id)?r.push(...n.lanesByPool.get(c.id)??[]):n.isLane(c.id)&&r.push(c.id));return[...new Set(r)].reverse()}i(wn,"buildTopLaneOrder");function Yo(t,e){const n=wn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const c of e)!o.has(c)||s.has(c)||(s.add(c),r.push(c));for(const c of n)s.has(c)||r.push(c);return r}i(Yo,"resolveTopLaneOrder");function Cr(t,e){const n=Ee(t),o=e?.laneOf??(()=>null),s=e?.rankHint,{preds:r}=Ln(n);for(const p of r.values())p.sort((M,w)=>M.localeCompare(w));const c=je(n)??[...n.nodes].sort((p,M)=>p.localeCompare(M)),a=new Map;for(const[p,M]of c.entries())a.set(M,p);const f=new Map,h=new Map;for(const p of n.nodes)h.set(p,[]);for(const p of c){const M=(r.get(p)??[]).filter(w=>f.has(w));if(M.length>0){const w=Lr(p,M,{laneOf:o,rankHint:s,topoIndex:a});f.set(p,w),h.get(w).push(p)}else f.has(p)||f.set(p,null)}for(const p of n.nodes)f.has(p)||f.set(p,null);const y=new Set;for(const p of n.nodes)(f.get(p)??null)===null&&y.add(p);const l=[...y].sort((p,M)=>{const w=a.get(p)??0,A=a.get(M)??0;return w===A?p.localeCompare(M):w-A}),I=wr(n),m=new Map;for(const[p,M]of I.entries())m.set(p,[...M].sort((w,A)=>w.localeCompare(A)));const x=Ar(m),g=Er(m),b=new Map;for(const p of n.nodes)b.set(p,[]);for(const p of g)for(const M of p.nodes){const w=b.get(M);w?w.push(p.id):b.set(M,[p.id])}const L=[],u=[],C=new Set,S=i(p=>{if(!C.has(p)){C.add(p),L.push(p);for(const M of h.get(p)??[])S(M);u.push(p)}},"walk");for(const p of l)S(p);for(const p of c)S(p);return{parent:f,children:h,roots:l,componentOf:x,blocks:g,nodeBlocks:b,adjacency:m,preorder:L,postorder:u,topologicalOrder:c}}i(Cr,"buildDrivingTree");function Lr(t,e,n){const o=n.laneOf(t);return[...e].sort((r,c)=>{const a=n.laneOf(r),f=n.laneOf(c),h=a!=null&&a===o,y=f!=null&&f===o;if(h!==y)return h?-1:1;const l=n.rankHint?.[r],I=n.rankHint?.[c];if(l!=null&&I!=null&&l!==I)return I-l;const m=n.topoIndex.get(r)??0,x=n.topoIndex.get(c)??0;return m!==x?m-x:r.localeCompare(c)})[0]}i(Lr,"chooseParent");function wr(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}i(wr,"buildAdjacency");function Ar(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 c of t.get(r)??[])e.has(c)||s.push(c)}}n++}return e}i(Ar,"assignComponents");function Er(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const c=i((a,f)=>{e.set(a,++r),n.set(a,r);for(const h of t.get(a)??[])h!==f&&(e.has(h)?(e.get(h)??0)<(e.get(a)??0)&&(o.push([a,h]),n.set(a,Math.min(n.get(a)??r,e.get(h)??r))):(o.push([a,h]),c(h,a),n.set(a,Math.min(n.get(a)??r,n.get(h)??r)),(n.get(h)??0)>=(e.get(a)??0)&&s.push(Tr(a,h,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||c(a,null);return s}i(Er,"computeBlocks");function Tr(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const c=n.pop();if(s.push(c),r.add(c[0]),r.add(c[1]),c[0]===t&&c[1]===e||c[0]===e&&c[1]===t)break}return{id:o,edges:s,nodes:[...r]}}i(Tr,"popBlock");function Rr(t,e,n){const o=[...t.nodes],s=new Map;for(const[u,C]of o.entries())s.set(C,u);const r=o.length,c=new Array(r).fill(-1),a=new Array(r).fill(0),f=[],h=new Set;for(const u of o){const C=n.parent.get(u)??null,S=s.get(u);S!=null&&C==null&&(c[S]=-1,a[S]=0,h.has(u)||(h.add(u),f.push(u)))}for(;f.length>0;){const u=f.shift(),C=s.get(u);if(C==null)continue;const S=n.children.get(u)??[];for(const p of S){if(h.has(p))continue;const M=s.get(p);M!=null&&(c[M]=C,a[M]=a[C]+1,h.add(p),f.push(p))}}for(const u of o){if(h.has(u))continue;const C=s.get(u);C!=null&&(c[C]=-1,a[C]=0,h.add(u))}const y=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),l=Array.from({length:y},()=>new Array(r).fill(-1));for(let u=0;u<r;u++)l[0][u]=c[u];for(let u=1;u<y;u++)for(let C=0;C<r;C++){const S=l[u-1][C];l[u][C]=S===-1?-1:l[u-1][S]}const I=i((u,C)=>{if(u===-1||C===-1)return-1;a[u]<a[C]&&([u,C]=[C,u]);const S=a[u]-a[C];for(let p=0;p<y;p++)if(S>>p&1&&(u=l[p][u],u===-1))return-1;if(u===C)return u;for(let p=y-1;p>=0;p--){const M=l[p][u],w=l[p][C];M===-1||w===-1||M!==w&&(u=M,C=w)}return l[0][u]},"lcaIndex"),m=Array.from({length:r},()=>new Map);for(const u of t.edges){let C=u.src,S=u.dst,p=e[C],M=e[S];if(p==null||M==null||(p>M&&([C,S]=[S,C],[p,M]=[M,p]),p==null||M==null||p===M))continue;const w=s.get(C),A=s.get(S);if(w==null||A==null)continue;const B=I(w,A);if(B===-1)continue;const P=m[B];for(let E=p;E<M;E++)P.set(E,(P.get(E)??0)+1)}const x=new Map,g=i((u,C)=>{if(C.size!==0)for(const[S,p]of C)u.set(S,(u.get(S)??0)+p)},"mergeInto"),b=new Set,L=i(u=>{const C=s.get(u);b.add(u);const S=C==null?void 0:m[C],p=S?new Map(S):new Map,M=n.children.get(u)??[];for(const w of M){const A=L(w),B=e[u];if(B!=null){let P=x.get(u);P||(P=new Map,x.set(u,P));let E=A.get(B)??0;const k=e[w];k!=null&&k>B&&(E+=1),P.set(w,E)}g(p,A)}return p},"dfs");for(const u of n.roots)b.has(u)||L(u);for(const u of o)b.has(u)||L(u);return x}i(Rr,"computeSubtreeCrossCounts");function Or(t,e,n){const o=new Map,s=i(r=>{let c=n[r]??0;const a=[...e.get(r)??[]];a.sort(zo(n));for(const f of a){s(f);const h=o.get(f);h!=null&&(c=Math.min(c,h))}o.set(r,c)},"annotate");for(const r of t)s(r);return o}i(Or,"annotateMinimumLayers");function zo(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}i(zo,"compareByRankThenId");function Nr(t,e,n,o){let s=0;for(const f of e){const h=n[f]??0;h>s&&(s=h)}const r=Array.from({length:s+1},()=>[]),c=new Set,a=i(f=>{if(c.has(f))return;c.add(f);const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f);for(const y of o(f))a(y)},"emit");for(const f of t)a(f);for(const f of e)if(!c.has(f)){const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f),c.add(f)}return r}i(Nr,"emitNodesInTreeOrder");function Br(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}i(Br,"deduplicateLayers");function Pr(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const c=e[s]??0,a=[],f=[],h=n.get(s);for(const y of r){const l=o.get(y)??c;l>c?a.push({child:y,min:l}):f.push(y)}return a.sort((y,l)=>y.min===l.min?y.child.localeCompare(l.child):y.min-l.min),f.sort((y,l)=>{const I=h?.get(y)??0,m=h?.get(l)??0;if(I!==m)return I-m;const x=o.get(y)??c,g=o.get(l)??c;return x!==g?x-g:y.localeCompare(l)}),[...a.map(y=>y.child),...f]}}i(Pr,"createChildOrderer");function bn(t,e,n){const o=Cr(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const l of t.nodes)s.has(l)||s.set(l,[]);const c=Rr(t,e,o),a=[...r].sort(zo(e)),f=Or(a,s,e),h=Pr(s,e,c,f);let y=Nr(a,t.nodes,e,h);return y=Br(y),y}i(bn,"buildMultitreeLayerOrder");function Fr(t,e,n){const o=new Set(t),s=new Set(e),r=Xe(e),c=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&c.push(r.get(a.dst));return Go(c)}i(Fr,"countCrossingsBetweenAdjacent");function fo(t,e,n){const o=[];for(const r of e){const c=n[r.src],a=n[r.dst];if(c==null||a==null||c===a)continue;let f=r.src,h=r.dst,y=c,l=a;c>a&&(f=r.dst,h=r.src,y=a,l=c);for(let I=y;I<l;I++)o.push({id:`${r.id}@${I}`,src:f,dst:h,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Fr(t[r],t[r+1],o);return s}i(fo,"totalCrossings");function kr(t,e){const n={...e},{preds:o}=Ln(t),s=Se(t),r=bn(t,n,s);let c=fo(r,t.edges,n);const a=yn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let f=0;f<a;f++){let h=!1;const y=[...t.nodes].sort((l,I)=>(n[I]??0)-(n[l]??0));for(const l of y){const I=n[l]??0;if(I===0)continue;let m=0;for(const L of o.get(l)??[])m=Math.max(m,(n[L]??0)+1);if(m>=I)continue;const x=I;n[l]=m;const g=bn(t,n,s),b=fo(g,t.edges,n);b<c?(c=b,h=!0):n[l]=x}if(!h)break}return n}i(kr,"optimizeRanksByCrossings");function _r(t,e){const n=Se(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const c=t.edges.filter(g=>g.src===s);if(c.length===0)continue;let a=!1,f=0;for(const g of c){const b=n(g.dst);b==null||b===r?a=!0:f++}if(f===0||a)continue;let h=0,y=!1;for(const g of t.edges){if(g.dst!==s)continue;const b=n(g.src);b&&(b===r?y=!0:h++)}if(h>0||!y)continue;const l=e[s]??0,I=l+f;let m=0;for(const g of t.edges)g.dst===s&&(m=Math.max(m,(e[g.src]??0)+1));const x=Math.max(l,m,I);x!==l&&(e[s]=x)}}i(_r,"adjustCrossLaneSources");function Hr(t,e){const n=Ee(t),o=je(n)??[...n.nodes].sort(),s=e?.compactSingleInput??!1,r=Se(n);let c=Object.create(null);for(const f of o){const h=_o(n,f),y=e?.ignoreCrossLaneEdges?h.filter(l=>{const I=r(l.src),m=r(f);return!I||!m?!0:I===m}):h;if(y.length===0)c[f]=0;else if(s&&y.length===1){const l=y[0].src,I=r(l),m=r(f);I!==m?c[f]=c[l]??0:c[f]=(c[l]??0)+1}else{let l=-1/0;for(const I of y)l=Math.max(l,(c[I.src]??0)+1);c[f]=l===-1/0?0:l}}return(e?.optimizeRanksByCrossings??!1)&&(c=kr(n,c)),e?.ignoreCrossLaneEdges&&_r(n,c),{layers:bn(n,c,r),rankOf:c,dummy:new Set}}i(Hr,"assignLayers_LongestPath");function Dr(t,e){const n=Ee(t),s={...Hr(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=Se(n),{preds:c,succs:a}=Ln(n,x=>{if(e?.ignoreCrossLaneEdges){const g=r(x.src),b=r(x.dst);if(g&&b&&g!==b)return!1}return!0}),f=je(n)??[...n.nodes],h=[...f].reverse(),y=i((x,g)=>{let b=0;for(const C of c.get(x)??[])b=Math.max(b,(s[C]??0)+1);let L=Number.POSITIVE_INFINITY;const u=a.get(x)??[];return u.length>0&&(L=Math.min(...u.map(C=>(s[C]??0)-1))),Number.isFinite(L)||(L=Math.max(b,g)),Math.min(Math.max(g,b),L)},"clampFeasible"),l=yn.GRAVITY_ITERATIONS,I=i(x=>{let g=!1;for(const b of x){const L=c.get(b)??[],u=a.get(b)??[];if(L.length===0&&u.length===0)continue;const C=L.length>0?L.reduce((w,A)=>w+(s[A]??0)+1,0)/L.length:s[b]??0,S=u.length>0?u.reduce((w,A)=>w+(s[A]??0)-1,0)/u.length:s[b]??0,p=Math.round((C+S)/2),M=y(b,p);M!==s[b]&&(s[b]=M,g=!0)}return g},"relaxOrder");for(let x=0;x<l;x++){const g=I(f),b=I(h);if(!g&&!b)break}for(const x of f){let g=0;for(const b of c.get(x)??[])g=Math.max(g,(s[b]??0)+1);(s[x]??0)<g&&(s[x]=g)}for(const x of h){const g=a.get(x)??[];if(g.length>0){const b=Math.min(...g.map(L=>(s[L]??0)-1));(s[x]??0)>b&&(s[x]=b)}}return{layers:Xo(n,f,s),rankOf:s,dummy:new Set}}i(Dr,"assignLayers_Gravity");function Xr(t){const e=Cn(t),n=Ho(t);let o=Do(t,e);const s=[];for(;o.length>0;){const r=[];for(const c of o){s.push(c);for(const a of n.get(c)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((c,a)=>c.localeCompare(a))}return s.length===t.nodes.length?s:null}i(Xr,"topoSortByGenerationIfAcyclic");function Gr(t,e){const n=Ee(t),o=e?.direction==="LR"?Xr(n)??[...n.nodes].sort():je(n)??[...n.nodes].sort(),s=Se(n),r=i(y=>s(y)??y,"laneOf"),c=Object.create(null),a=new Map,f=i((y,l)=>e?.ignoreCrossLaneEdges??!0?r(y)===r(l)?1:0:1,"edgeWeight");for(const y of o){if(n.nodeById.get(y)?.isGroup)continue;const I=_o(n,y);let m=0;if(I.length>0)for(const L of I){const u=L.src,C=c[u]??0;m=Math.max(m,C+f(u,y))}const x=r(y),g=a.get(x)??0,b=Math.max(m,g);c[y]=b,a.set(x,b+1)}return{layers:Xo(n,o,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}i(Gr,"assignLayers_LaneAwareCompact");function Yr(t,e){const n=Ee(e),{rankOf:o}=t,s=t.layers.map(m=>[...m]),r=new Set(t.dummy?[...t.dummy]:[]);let c=0;const a=new Map(n.nodeById),f=i(m=>{const x=`placeholder-${c++}`,g={id:x,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(x,g),r.add(x);s.length<=m;)s.push([]);return s[m].push(x),o[x]=m,x},"addDummyAt"),h=[...n.edges].sort((m,x)=>m.id===x.id?m.src===x.src?m.dst.localeCompare(x.dst):m.src.localeCompare(x.src):m.id.localeCompare(x.id)),y=[];for(const m of h){const x=o[m.src]??0,g=o[m.dst]??0;if(g-x<=1){y.push(m);continue}let b=m.src;for(let u=x+1,C=0;u<g;u++,C++){const S=f(u);y.push({id:`${m.id}#${C}`,src:b,dst:S,weight:m.weight,ref:m.ref}),b=S}const L=g-x-2;y.push({id:`${m.id}#${Math.max(L+1,0)}`,src:b,dst:m.dst,weight:m.weight,ref:m.ref})}const I={nodes:[...n.nodes,...[...r].filter(m=>!n.nodes.includes(m))],edges:y,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:I}}i(Yr,"makeProperLayering");function uo(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])}i(uo,"median");function ho(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}i(ho,"barycenter");function zr(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}i(zr,"neighborPositionsFor");function $r(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}i($r,"currentOrderTieBreak");function go(t,e,n){const o=new Set(t),s=new Set(e),r=Xe(t),c=Xe(e),a=[];for(const h of n)o.has(h.src)&&s.has(h.dst)&&a.push({u:r.get(h.src),v:c.get(h.dst)});a.sort((h,y)=>h.u===y.u?h.v-y.v:h.u-y.u);const f=a.map(h=>h.v);return Go(f)}i(go,"countCrossingsBetweenAdjacent");function rn(t,e,n){return[...t].sort((o,s)=>{const r=uo(e.get(o)??[]),c=uo(e.get(s)??[]);return r===c?$r(o,s,n):isFinite(r)?isFinite(c)?r-c:-1:1})}i(rn,"sortByHeuristic");function po(t,e,n,o,s,r){const c=Xe(t),a=Xe(e),f=zr(e,c,n,o);if(!s||!r||r.length===0)return rn(e,f,a);const h=new Map;for(const I of e){const m=s(I),x=h.get(m)??[];x.push(I),h.set(m,x)}const y=[];for(const I of r){const m=h.get(I);if(!m||m.length===0)continue;const x=rn(m,f,a);y.push(...x)}const l=h.get(null);if(l&&l.length>0){const I=rn(l,f,a);for(const m of I){const x=ho(f.get(m)??[]);let g=y.length;if(isFinite(x))for(const[b,L]of y.entries()){const u=ho(f.get(L)??[]);if(x<u){g=b;break}}y.splice(g,0,m)}}return y}i(po,"reorderLayer");function mo(t,e,n,o,s){const r=[...e],c=new Set(t),a=new Set(e),f=o?new Set(o):null,h=n.filter(g=>c.has(g.src)&&a.has(g.dst)),y=f?n.filter(g=>a.has(g.src)&&f.has(g.dst)):void 0,l=i(g=>{let b=go(t,g,h);return y&&o&&(b+=go(g,o,y)),b},"crossingScore"),I=s?new Map:null;if(s&&I)for(const g of e)I.set(g,s(g));let m=!0,x=l(r);for(;m;){m=!1;for(let g=0;g+1<r.length;g++){if(I){const u=I.get(r[g]),C=I.get(r[g+1]);if(u!==C)continue}const b=x;[r[g],r[g+1]]=[r[g+1],r[g]];const L=l(r);L<b?(x=L,m=!0):[r[g],r[g+1]]=[r[g+1],r[g]]}}return r}i(mo,"transposeImprove");function Vr(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=Se(e),c=Yo(e,n?.laneOrder);for(let a=0;a<3;a++){for(let f=1;f<o.length;f++)o[f]=po(o[f-1],o[f],s,"down",r,c),o[f]=mo(o[f-1],o[f],s,o[f+1],r);for(let f=o.length-2;f>=0;f--)o[f]=po(o[f+1],o[f],s,"up",r,c),o[f]=mo(o[f+1],o[f],s,o[f-1],r)}return{layers:o}}i(Vr,"orderLayers");function Ur(t,e,n){const o=n?.layerGap??Pn.DEFAULT_LAYER_GAP,s=n?.nodeGap??Pn.DEFAULT_NODE_GAP,r=n?.laneGap??s*2,c=n?.direction??"TB",a=c==="LR"||c==="RL",f=Object.create(null),h=Object.create(null),y=new Map((e.layout?.nodes??[]).filter(_=>_.isEdgeLabel).map(_=>[_.id,_])),l=i(_=>y.get(_)??e.nodeById.get(_),"getNode"),I=i(_=>l(_)?.width??0,"getWidth"),m=i(_=>l(_)?.height??0,"getHeight"),x=Se(e),g=new Map,b=i(_=>g.has(_)?g.get(_)??null:x(_),"topLaneOf"),L=Yo(e,n?.laneOrder),u=new Set;for(const _ of t.layers)for(const $ of _)u.add(x($));const C=u.has(null),S=L.filter(_=>u.has(_)),p=[...C?[null]:[],...S],M=t.layers,w=new Map;for(const[_,$]of M.entries())for(const tt of $)w.set(tt,_);const A=[],B=[],P=[];for(const _ of e.layout?.edges??[]){const $=_.labelNodeId,tt=_.start,Z=_.end;if(!$||!y.has($)||tt==null||Z==null)continue;const rt=w.get(tt),ut=w.get(Z);if(rt==null||ut==null){P.push({labelId:$,near:rt==null?Z:tt});continue}if(g.set($,x(Z)),rt===ut){const bt=i(Pt=>p.indexOf(x(Pt)),"column");A.push({labelId:$,rank:ut,lane:x(Z),side:tt!==Z&&bt(tt)<bt(Z)?"before":"after"});continue}const gt=Math.min(rt,ut),pt=Math.max(rt,ut);B.push({labelId:$,start:tt,end:Z,gap:gt+Math.floor((pt-gt-1)/2),crossesLanes:x(tt)!==x(Z)})}const E=M.map(_=>_.reduce(($,tt)=>Math.max($,m(tt)),0));for(const{labelId:_,rank:$}of A)E[$]=Math.max(E[$],m(_));const k=M.map(()=>0);if(a)for(let _=0;_+1<M.length;_++){const $=M[_].reduce((pt,bt)=>Math.max(pt,I(bt)),0),tt=M[_+1].reduce((pt,bt)=>Math.max(pt,I(bt)),0),Z=E[_],rt=E[_+1],ut=Z/2+rt/2,gt=($+tt)/2;k[_]=Math.max(0,gt-ut-o)}const Y=a?Bo(e.layout?.nodes??[]):1,K=M.map(()=>0);for(const{labelId:_,gap:$}of B){const Z=((a?I(_):m(_))+2*Pn.EDGE_LABEL_CLEARANCE)/Y;K[$]=Math.max(K[$],Z)}for(const[_,$]of K.entries())k[_]+=$;const z=Object.create(null);for(const _ of S)z[_]=0;C&&(z.null=0);for(const _ of M){const $=Object.create(null),tt=[];for(const Z of _){const rt=b(Z);rt===null?tt.push(Z):($[rt]||=[]).push(Z)}for(const[Z,rt]of Object.entries($)){const ut=rt.reduce((gt,pt)=>gt+I(pt),0)+s*Math.max(0,rt.length-1);z[Z]=Math.max(z[Z]??0,ut)}if(C&&tt.length){const Z=tt.reduce((rt,ut)=>rt+I(ut),0)+s*Math.max(0,tt.length-1);z.null=Math.max(z.null??0,Z)}}const et=new Map;for(const _ of B){const $=`${_.gap}:${b(_.labelId)}`,tt=et.get($);tt?tt.push(_):et.set($,[_])}for(const _ of et.values()){const $=b(_[0].labelId);if($!==null){const tt=_.reduce((Z,rt,ut)=>Z+I(rt.labelId)+(ut>0?s:0),0);z[$]=Math.max(z[$]??0,tt)}}const at=new Map;for(const{labelId:_,rank:$,lane:tt,side:Z}of A){const rt=`${$}:${tt}:${Z}`;at.set(rt,(at.get(rt)??0)+s+I(_))}const xt=i((_,$,tt)=>at.get(`${_}:${$}:${tt}`)??0,"rowLabelSpan");for(const{rank:_,lane:$}of A){const tt=M[_].filter(ut=>b(ut)===$).reduce((ut,gt,pt)=>ut+I(gt)+(pt>0?s:0),0),Z=Math.max(xt(_,$,"before"),xt(_,$,"after")),rt=$??"null";z[rt]=Math.max(z[rt]??0,tt+2*Z)}const Kt=new Map;{const _=p.map(Z=>(Z===null?z.null:z[Z])??0);let tt=-(_.reduce((Z,rt)=>Z+rt,0)+r*Math.max(0,p.length-1))/2;for(let Z=0;Z<p.length;Z++){const rt=p[Z],ut=_[Z]??0,gt=tt+ut/2;Kt.set(rt,gt),tt+=ut,Z<p.length-1&&(tt+=r)}}const Ut=[];let jt=0;for(const[_,$]of M.entries()){const tt=E[_]??0,Z=new Map;for(const ut of $){const gt=b(ut),pt=Z.get(gt)??[];pt.push(ut),Z.set(gt,pt)}for(const ut of p){const gt=Z.get(ut)??[];if(gt.length===0)continue;const pt=Kt.get(ut);if(gt.length===1){const bt=gt[0];f[bt]=pt,h[bt]=jt+tt/2}else{const bt=gt.map(Ie=>I(Ie)),Pt=bt.reduce((Ie,Me)=>Ie+Me,0)+s*(gt.length-1);let Te=pt-Pt/2;for(const[Ie,Me]of gt.entries()){const Re=bt[Ie];f[Me]=Te+Re/2,h[Me]=jt+tt/2,Te+=Re+s}}}const rt=o+(k[_]??0);Ut[_]=jt+tt+rt/2,jt+=tt+rt}const Q=new Map;for(const{labelId:_,rank:$,lane:tt,side:Z}of A){const rt=`${$}:${tt}:${Z}`;if(!Q.has(rt)){const bt=M[$].filter(Pt=>b(Pt)===tt).map(Pt=>Z==="before"?f[Pt]-I(Pt)/2:f[Pt]+I(Pt)/2);Q.set(rt,Z==="before"?Math.min(...bt):Math.max(...bt))}const ut=I(_),gt=Q.get(rt)+(Z==="before"?-1:1)*(s+ut/2);f[_]=gt,h[_]=h[M[$].find(pt=>b(pt)===tt)],Q.set(rt,gt+(Z==="before"?-1:1)*(ut/2))}for(const _ of et.values()){const $=_.map(({start:pt,end:bt,crossesLanes:Pt})=>Pt?f[bt]:((f[pt]??0)+(f[bt]??0))/2),tt=_.map((pt,bt)=>bt).sort((pt,bt)=>$[pt]-$[bt]||pt-bt),Z=[];let rt=-1/0;for(const pt of tt){const bt=I(_[pt].labelId);Z[pt]=Math.max($[pt],rt+s+bt/2),rt=Z[pt]+bt/2}const ut=i(pt=>pt.reduce((bt,Pt)=>bt+Pt,0)/pt.length,"mean"),gt=ut($)-ut(Z);for(const[pt,{labelId:bt,gap:Pt}]of _.entries())f[bt]=Z[pt]+gt,h[bt]=Ut[Pt]}for(const{labelId:_,near:$}of P)f[_]=f[$]??0,h[_]=h[$]??0;const ft=new Map;for(const _ of e.edges){const $=_.ref.id;ft.has($)||ft.set($,[]),ft.get($).push(_)}for(const[,_]of ft){if(_.length===0)continue;const $=_[0].ref,tt=$.start,Z=$.end;if(tt==null||Z==null)continue;const rt=Math.round(((f[tt]??0)+(f[Z]??0))/2),ut=new Set;for(const gt of _)ut.add(gt.src),ut.add(gt.dst);for(const gt of ut){if(gt===tt||gt===Z)continue;e.nodeById.get(gt)?.isDummy&&(f[gt]=rt)}}return{x:f,y:h}}i(Ur,"assignCoordinates");var jr=8;function Wr(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}i(Wr,"hashString");function Kr(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}}i(Kr,"mulberry32");function qr(t,e){const n=[...t],o=Kr(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}i(qr,"deterministicShuffle");function Zr(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}i(Zr,"sourceDistance");function yo(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:c}of e){const a=n.get(s),f=n.get(r);a==null||f==null||(o+=c*Math.abs(a-f))}return o}i(yo,"laneArrangementCost");function Jr(t){const e=wn(t);if(e.length<2)return[];const n=new Map(e.map((r,c)=>[r,c])),o=Se(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const c=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!c||!a||!t.nodeById.has(c)||!t.nodeById.has(a))continue;const f=o(c),h=o(a);if(!f||!h||f===h)continue;const y=n.get(f),l=n.get(h);if(y==null||l==null)continue;const[I,m]=y<=l?[f,h]:[h,f],x=`${I}\0${m}`,g=s.get(x);g?g.weight++:s.set(x,{a:I,b:m,weight:1})}return[...s.values()]}i(Jr,"buildWeightedLaneEdges");function xo(t,e,n){const o=[...t];let s=yo(o,e),r=!0,c=0;const a=Math.max(1,o.length);for(;r&&c<a;){r=!1,c++;for(let f=0;f+1<o.length;f++){[o[f],o[f+1]]=[o[f+1],o[f]];const h=yo(o,e);h<s?(s=h,r=!0):[o[f],o[f+1]]=[o[f+1],o[f]]}}return{order:o,cost:s,sourceDistance:Zr(o,n)}}i(xo,"greedySwitch");function Qr(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}i(Qr,"isBetterCandidate");function ti(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:c})=>`${s}:${r}:${c}`).join("|");return Wr(`${t.join("|")}#${o}#${n}`)}i(ti,"seedForRestart");function ei(t,e={}){const n=wn(t);if(n.length<2)return n;const o=Jr(t);if(o.length===0)return n;const s=new Map(n.map((a,f)=>[a,f]));let r=xo(n,o,s);const c=Math.max(0,e.restarts??jr);for(let a=0;a<c;a++){const f=ti(n,o,a),h=qr(n,f),y=xo(h,o,s);Qr(y,r)&&(r=y)}return r.order}i(ei,"optimizeTopLaneOrder");function ni(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,s=Ee(t),r=e?.automaticLaneOrdering?ei(s,{restarts:jr}):void 0,c=Sr(s),a=c.acyclic,f=n?Gr(a,{compactSingleInput:e?.compactSingleInput??yn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Dr(a,{compactSingleInput:e?.compactSingleInput??yn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:h,graphWithDummies:y}=Yr(f,a),l=Vr(h,y,{laneOrder:r}),I=Ur(l,y,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:r});return{acyclic:a,reversed:c.reversed,layering:h,ordered:l,coordinates:I}}i(ni,"sugiyamaLayout");var mt=Bi.EPSILON,Yi=8,Ne=15,He=15,on=25,de=20,_n=10;function bo(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,c=e.y-s,a=Math.abs(r),f=Math.abs(c);return a<mt&&f<mt?n:f>mt&&f*3>=a?c>0?"bottom":"top":a>mt?r>0?"right":"left":n}i(bo,"chooseOrthogonalSide");var ts=i(t=>typeof t=="number"&&Number.isFinite(t)&&t>0,"isDrawableSize");function cn(t,e){const n=t.metadata?.drawnExtent;return{w:ts(n?.width)?n.width:t.width??e,h:ts(n?.height)?n.height:t.height??e}}i(cn,"drawnSize");function Io(t,e){return Math.abs(t.to-e.from)<mt||Math.abs(t.to-e.to)<mt?t.to:t.from}i(Io,"sharedLineEndpointCoord");function Be(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}i(Be,"pointOnLine");function oi(t,e){const n=t.nodes??[],o=t.edges??[],s=[];for(const d of o)d.isLayoutOnly||s.push({...d,__originalEdge:d});const r=new Map,c=new Map,a=[],f=e==="LR";for(const d of n)r.set(d.id,d);const h=pe(n),y=n.filter(d=>h.isLane(d.id));for(const d of y){const v={id:d.id},T=i(R=>{c.set(R.id,v),n.filter(O=>O.parentId===R.id).forEach(T)},"assignLane");T(d)}const l=Ge(n),I=n.filter(d=>!d.isGroup&&!d.isEdgeLabel&&!l.has(d.id)).map(d=>{const v=d.width??10,T=d.height??10,R=d.x??0,O=d.y??0,H=Yi;return{nodeId:d.id,minX:R-v/2-H,maxX:R+v/2+H,minY:O-T/2-H,maxY:O+T/2+H,visualXHalfExtent:f?T/2+H:v/2+H}}),m=i((d,v,T,R)=>{let O=a.find(H=>H.orientation===d&&Math.abs(H.coord-v)<1);return O||(O={id:`pipe-${d}-${v.toFixed(0)}`,orientation:d,coord:v,spanMin:T,spanMax:R,tracks:[]},a.push(O)),O.spanMin=Math.min(O.spanMin,T),O.spanMax=Math.max(O.spanMax,R),O},"getOrAddPipe"),x=i((d,v)=>{const{w:T,h:R}=cn(d,10),O=d.x??0,H=d.y??0;switch(v){case"top":return{x:O,y:H-R/2};case"bottom":return{x:O,y:H+R/2};case"left":return{x:O-T/2,y:H};case"right":return{x:O+T/2,y:H}}},"portForSide"),g=i((d,v,T)=>x(d,bo(d,v,T?"bottom":"top")),"getOrthogonalPort"),b=[],L=[],u=new Set,C=1e3,S=i((d,v,T)=>{if(b.length===0)return 0;const R=Math.abs(v.y-T.y)<mt,O=Math.abs(v.x-T.x)<mt;if(!R&&!O)return 0;let H=0;if(R){const J=v.y,lt=Math.min(v.x,T.x)-mt,W=Math.max(v.x,T.x)+mt;if(W<=lt)return 0;for(const U of b)U.edgeIndex===d||U.orientation!=="vertical"||U.pipe.coord<lt||U.pipe.coord>W||U.from-mt<=J&&U.to+mt>=J&&(H+=C)}else if(O){const J=v.x,lt=Math.min(v.y,T.y)-mt,W=Math.max(v.y,T.y)+mt;if(W<=lt)return 0;for(const U of b)U.edgeIndex===d||U.orientation!=="horizontal"||U.pipe.coord<lt||U.pipe.coord>W||U.from-mt<=J&&U.to+mt>=J&&(H+=C)}return H},"crossingPenalty"),p=s.map((d,v)=>{if(!d.start||!d.end)return{idx:v,crossLane:0,dx:0,dy:0};const T=r.get(d.start),R=r.get(d.end),O=c.get(d.start),H=c.get(d.end),J=O&&H&&O.id!==H.id?1:0,lt=T&&R?Math.abs((R.x??0)-(T.x??0)):0,W=T&&R?Math.abs((R.y??0)-(T.y??0)):0;return{idx:v,crossLane:J,dx:lt,dy:W}}).sort((d,v)=>{if(d.crossLane!==v.crossLane)return v.crossLane-d.crossLane;const T=d.dx+d.dy,R=v.dx+v.dy;return Math.abs(T-R)>1?T-R:d.idx-v.idx}).map(d=>d.idx),M=i((d,v,T,R)=>{const O=Math.min(d.x,v.x),H=Math.max(d.x,v.x),J=Math.min(d.y,v.y),lt=Math.max(d.y,v.y);return!!I.find(U=>T&&U.nodeId===T||R&&U.nodeId===R?!1:Math.abs(d.x-v.x)>mt?U.minY<d.y&&U.maxY>d.y&&U.maxX>O&&U.minX<H:U.minX<d.x&&U.maxX>d.x&&U.maxY>J&&U.minY<lt)},"isSegmentBlocked"),w=new Map,A=new Map;for(const d of s)!d.start||!d.end||d.start===d.end||(A.set(d.start,(A.get(d.start)??0)+1),A.set(d.end,(A.get(d.end)??0)+1));const B=i((d,v)=>bo(d,v,"bottom"),"determineSide"),P=new Map;for(const[d,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),R=r.get(v.end);if(!T||!R)continue;const O=(R.x??0)-(T.x??0),H=(R.y??0)-(T.y??0);P.set(d,{edgeIdx:d,srcId:v.start,dstId:v.end,srcSide:B(T,{x:R.x??0,y:R.y??0}),dstSide:B(R,{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 E=i(d=>d.srcSide==="top"||d.srcSide==="bottom"?d.absDx===0?1/0:d.absDy/d.absDx:d.absDy===0?1/0:d.absDx/d.absDy,"preferenceStrength"),k=i(d=>d.srcSide==="top"||d.srcSide==="bottom"?d.dxSign===0?["right","left"]:[d.dxSign>0?"right":"left"]:d.dySign===0?["bottom","top"]:[d.dySign>0?"bottom":"top"],"secondarySides"),Y=i(d=>k(d)[0],"secondarySide"),K=new Map;for(const d of P.values()){const v=`${d.srcId}:${d.srcSide}`;K.has(v)||K.set(v,[]),K.get(v).push(d)}const z=new Map,et=i((d,v)=>`${d}:${v}`,"loadKey");for(const d of P.values())z.set(et(d.srcId,d.srcSide),(z.get(et(d.srcId,d.srcSide))??0)+1),z.set(et(d.dstId,d.dstSide),(z.get(et(d.dstId,d.dstSide))??0)+1);for(const d of K.values())if(!(d.length<2)){d.sort((v,T)=>{const R=E(v),O=E(T);return Math.abs(R-O)>1e-9?O-R:v.edgeIdx-T.edgeIdx});for(let v=1;v<d.length;v++){const T=d[v],R=z.get(et(T.srcId,T.srcSide))??0,O=k(T).reduce((J,lt)=>(z.get(et(T.srcId,lt))??0)<(z.get(et(T.srcId,J))??0)?lt:J),H=z.get(et(T.srcId,O))??0;H>=R||(z.set(et(T.srcId,T.srcSide),R-1),z.set(et(T.srcId,O),H+1),T.srcSide=O)}}const at=i(d=>{const v=d?.shape;return v==="question"||v==="diamond"},"isDiamondNode"),xt=new Map;for(const d of P.values())xt.has(d.dstId)||xt.set(d.dstId,new Set),xt.get(d.dstId).add(d.dstSide);for(const d of P.values()){if(!at(r.get(d.srcId)))continue;const v=xt.get(d.srcId);if(!v?.has(d.srcSide))continue;const T=Y(d);if(v.has(T)||(z.get(et(d.srcId,T))??0)>0)continue;const R=z.get(et(d.srcId,d.srcSide))??0;z.set(et(d.srcId,d.srcSide),Math.max(0,R-1)),z.set(et(d.srcId,T),1),d.srcSide=T}const Kt=i(d=>{const v=d?.shape;return v==="hexagon"||v==="notch-pent"},"hasVertexFaces"),Ut=new Map;for(const d of P.values())Ut.has(d.srcId)||Ut.set(d.srcId,new Set),Ut.get(d.srcId).add(d.srcSide);const jt=i(d=>d.dstSide==="top"||d.dstSide==="bottom"?d.dxSign>=0?"left":"right":d.dySign>=0?"top":"bottom","secondaryDstSide");for(const d of P.values()){if(!Kt(r.get(d.dstId)))continue;const v=Ut.get(d.dstId);if(!v?.has(d.dstSide))continue;const T=jt(d);if(v.has(T)||(z.get(et(d.dstId,T))??0)>0)continue;const R=z.get(et(d.dstId,d.dstSide))??0;z.set(et(d.dstId,d.dstSide),Math.max(0,R-1)),z.set(et(d.dstId,T),1),d.dstSide=T;const O=d.dySign>=0?"bottom":"top";if((T==="top"||T==="bottom")&&xt.get(d.srcId)?.has(d.srcSide)&&!xt.get(d.srcId)?.has(O)&&(z.get(et(d.srcId,O))??0)===0){const H=z.get(et(d.srcId,d.srcSide))??0;z.set(et(d.srcId,d.srcSide),Math.max(0,H-1)),z.set(et(d.srcId,O),1),d.srcSide=O}}for(const d of P.values()){const{edgeIdx:v,srcId:T,dstId:R,srcSide:O,dstSide:H}=d,J=r.get(T),lt=r.get(R),W=`${T}:${O}:src`,U=O==="top"||O==="bottom"?lt.x??0:lt.y??0;w.has(W)||w.set(W,[]),w.get(W).push({edgeIdx:v,oppositeCoord:U});const wt=`${R}:${H}:dst`,At=H==="top"||H==="bottom"?J.x??0:J.y??0;w.has(wt)||w.set(wt,[]),w.get(wt).push({edgeIdx:v,oppositeCoord:At})}const Q=new Map,ft=8;for(const[d,v]of w){if(v.length<2)continue;v.sort((Gt,ie)=>Gt.oppositeCoord-ie.oppositeCoord);const T=d.split(":"),R=T.slice(0,-2).join(":"),O=T[T.length-2],H=T[T.length-1],J=r.get(R);if(!J)continue;const lt=O==="left"||O==="right",W=cn(J,10),U=lt?W.h:W.w,wt=J.shape,Tt=wt==="question"||wt==="diamond"?U*.3:U,Mt=Math.min(20,Tt/(v.length-1),Math.max(ft,Tt/(v.length+1))),oe=-(Mt*(v.length-1))/2;for(const[Gt,ie]of v.entries()){const ve=oe+Gt*Mt,An=`${ie.edgeIdx}:${H}`;Q.set(An,ve)}}const _=i(d=>!!s[d]?.labelNodeId,"edgeHasLabelNode"),$=i((d,v)=>d?(w.get(`${d}:${v}:src`)??[]).some(({edgeIdx:T})=>_(T))||(w.get(`${d}:${v}:dst`)??[]).some(({edgeIdx:T})=>_(T)):!1,"faceHasLabelNode"),tt=i((d,v,T)=>v==="top"||v==="bottom"?{x:d.x+T,y:d.y}:{x:d.x,y:d.y+T},"applyPortOffset"),Z=i((d,v,T)=>{const R=P.get(d),O={x:T.x??0,y:T.y??0},H={x:v.x??0,y:v.y??0},J=R?.srcSide??B(v,O),lt=R?.dstSide??B(T,H);let W=R?x(v,R.srcSide):g(v,O,!0),U=R?x(T,R.dstSide):g(T,H,!1);const wt=Q.get(`${d}:src`),At=Q.get(`${d}:dst`);return wt!==void 0&&(W=tt(W,J,wt)),At!==void 0&&(U=tt(U,lt,At)),{pSrcPort:W,pDstPort:U,srcSide:J,dstSide:lt}},"portsForEdge");for(const d of p){const v=s[d];if(L[d]=[],!v.start||!v.end||v.points&&v.points.length>0||v.start===v.end)continue;const T=r.get(v.start),R=r.get(v.end);if(!T||!R)continue;const{pSrcPort:O,pDstPort:H,srcSide:J,dstSide:lt}=Z(d,T,R),W={...O},U={...H},wt=J==="top"||J==="bottom",At=lt==="top"||lt==="bottom";if(wt){const X=O.y>(T.y??0);W.y=X?O.y+de:O.y-de}else{const X=O.x>(T.x??0);W.x=X?O.x+de:O.x-de}if(At){const X=H.y>(R.y??0);U.y=X?H.y+de:H.y-de}else{const X=H.x>(R.x??0);U.x=X?H.x+de:H.x-de}const Tt=i((X,V)=>{for(const st of I)if(!V.includes(st.nodeId)&&X.x>st.minX&&X.x<st.maxX&&X.y>st.minY&&X.y<st.maxY)return{inside:!0,obstacle:st};return{inside:!1}},"isPointInObstacle"),it=i((X,V,st,vt,Bt)=>{if(Bt){const Yt=X.y>(V.y??0);return{x:(st.x??0)>=X.x?vt.maxX+Ne:vt.minX-Ne,y:Yt?vt.maxY+He:vt.minY-He,leavesPositiveSide:Yt}}const Et=X.x>(V.x??0),Ht=(st.y??0)>=X.y;return{x:Et?vt.maxX+Ne:vt.minX-Ne,y:Ht?vt.maxY+He:vt.minY-He,leavesPositiveSide:Et}},"obstacleDetour");let Mt=[];const _t=[v.start,v.end],oe=Tt(W,_t);if(oe.inside&&oe.obstacle){const X=oe.obstacle;if(wt){const V=it(O,T,R,X,!0);W.x=V.x,W.y=V.y;const st=V.leavesPositiveSide?Math.min(X.minY-2,O.y+de):Math.max(X.maxY+2,O.y-de);Mt=[{x:O.x,y:st},{x:V.x,y:st},{x:V.x,y:V.y}]}else{const V=it(O,T,R,X,!1),st=V.leavesPositiveSide?Math.min(X.minX-2,O.x+de):Math.max(X.maxX+2,O.x-de);W.x=V.x,W.y=V.y,Mt=[{x:st,y:O.y},{x:st,y:V.y},{x:V.x,y:V.y}]}}let Gt=[];const ie=Tt(U,_t);if(ie.inside&&ie.obstacle){const X=ie.obstacle;if(At){const V=it(H,R,T,X,!0);U.x=V.x,U.y=V.y,Gt=[{x:V.x,y:V.y},{x:H.x,y:V.y}]}else{const V=it(H,R,T,X,!1);U.x=V.x,U.y=V.y,Gt=[{x:V.x,y:V.y},{x:V.x,y:H.y}]}}if(Mt.length===0&&Gt.length===0){const X=Ne,V=Math.abs(W.x-U.x)<X,st=Math.abs(W.y-U.y)<X,vt=Q.get(`${d}:src`)!==void 0||Q.get(`${d}:dst`)!==void 0,Bt=(w.get(`${v.start??""}:${J}:src`)?.length??0)+(w.get(`${v.start??""}:${J}:dst`)?.length??0),Et=(w.get(`${v.end??""}:${lt}:src`)?.length??0)+(w.get(`${v.end??""}:${lt}:dst`)?.length??0),Ht=Bt>1||Et>1,Yt=A.get(v.start??"")??0,Lt=A.get(v.end??"")??0,Jt=Bt>1&&$(v.start,J)||Et>1&&$(v.end,lt),fe=Bt<=1||Yt<=2,$t=Et<=1||Lt<=2;if((V||st)&&!vt&&(!Ht||Ht&&!Jt&&fe&&$t)&&!M(O,H,v.start,v.end)){v.points=[{...O},{...W},{...U},{...H}],u.add(d);const Rt=st?"horizontal":"vertical",ee=st?O.y:O.x,Ot=st?Math.min(O.x,H.x):Math.min(O.y,H.y),Nt=st?Math.max(O.x,H.x):Math.max(O.y,H.y),se={id:`fast-path-${Rt}-${ee.toFixed(0)}-${d}`,orientation:Rt,coord:ee,spanMin:Ot,spanMax:Nt,tracks:[]};b.push({edgeIndex:d,segmentIndex:0,orientation:Rt,pipe:se,trackIndex:0,from:Ot,to:Nt});continue}}const ve=m("vertical",W.x,W.y,W.y);W.x=ve.coord;const An=m("vertical",U.x,U.y,U.y);U.x=An.coord;let Ce=Math.min(W.x,U.x)-50,Le=Math.max(W.x,U.x)+50,Fe=Math.min(W.y,U.y)-50,ke=Math.max(W.y,U.y)+50;for(const X of I){const V=Math.min(W.x,U.x),st=Math.max(W.x,U.x),vt=Math.min(W.y,U.y),Bt=Math.max(W.y,U.y);X.minX<st&&X.maxX>V&&X.minY<Bt&&X.maxY>vt&&(Ce=Math.min(Ce,X.minX-on),Le=Math.max(Le,X.maxX+on),Fe=Math.min(Fe,X.minY-on),ke=Math.max(ke,X.maxY+on))}for(const X of I){if(X.maxX<Ce||X.minX>Le||X.maxY<Fe||X.minY>ke)continue;const V=Ne;m("horizontal",X.minY-V,Ce,Le),m("horizontal",X.maxY+V,Ce,Le);const st=He;m("vertical",X.minX-st,Fe,ke),m("vertical",X.maxX+st,Fe,ke)}m("horizontal",W.y,Ce,Le),m("horizontal",U.y,Ce,Le);const ci=a.filter(X=>X.orientation==="horizontal"&&X.coord>=Fe&&X.coord<=ke),ai=a.filter(X=>X.orientation==="vertical"&&X.coord>=Ce&&X.coord<=Le),Ke=i((X,V)=>`${X.toFixed(1)},${V.toFixed(1)}`,"getKey"),qe=Ke(W.x,W.y),$o=Ke(U.x,U.y),Ze=new Map,En=new Map,Tn=new Map,Je=new Set,Oe=[];Ze.set(qe,0),Tn.set(qe,"n"),Oe.push({key:qe,f:Math.hypot(U.x-W.x,U.y-W.y),pt:W}),Je.add(qe);let qt=[];const we=i((X,V)=>M(X,V,v.start,v.end),"checkSegmentBlocked"),Rn={x:U.x,y:W.y},li=we(W,Rn),fi=we(Rn,U),di=li||fi,On={x:W.x,y:U.y},ui=we(W,On),hi=we(On,U);if(di?ui||hi||(Math.abs(W.x-U.x)<mt?qt=[W,U]:qt=[W,On,U]):Math.abs(W.y-U.y)<mt||Math.abs(W.x-U.x)<mt?qt=[W,U]:qt=[W,Rn,U],qt.length===0)for(;Oe.length>0;){Oe.sort((Lt,Jt)=>Lt.f-Jt.f);const X=Oe.shift();if(Je.delete(X.key),X.key===$o){let Lt=$o,Jt=U;for(qt=[Jt];En.has(Lt);){const fe=En.get(Lt);qt.unshift(fe),Jt=fe,Lt=Ke(fe.x,fe.y)}break}const V=X.pt.x,st=X.pt.y,vt=ai.sort((Lt,Jt)=>Lt.coord-Jt.coord),Bt=vt.findIndex(Lt=>Math.abs(Lt.coord-V)<1),Et=ci.sort((Lt,Jt)=>Lt.coord-Jt.coord),Ht=Et.findIndex(Lt=>Math.abs(Lt.coord-st)<1),Yt=[];Bt>0&&Yt.push({x:vt[Bt-1].coord,y:st}),Bt>=0&&Bt<vt.length-1&&Yt.push({x:vt[Bt+1].coord,y:st}),Ht>0&&Yt.push({x:V,y:Et[Ht-1].coord}),Ht>=0&&Ht<Et.length-1&&Yt.push({x:V,y:Et[Ht+1].coord});for(const Lt of Yt){const Jt=Math.min(V,Lt.x),fe=Math.max(V,Lt.x),$t=Math.min(st,Lt.y),te=Math.max(st,Lt.y);if(I.some(ce=>ce.nodeId===v.start||ce.nodeId===v.end?!1:Jt!==fe?ce.minY<st&&ce.maxY>st&&ce.maxX>Jt&&ce.minX<fe:ce.minX<V&&ce.maxX>V&&ce.maxY>$t&&ce.minY<te))continue;const Rt=Ke(Lt.x,Lt.y),ee=Math.abs(Lt.x-V)+Math.abs(Lt.y-st),Ot=S(d,X.pt,Lt);let Nt=0;const se=U.x-W.x,_e=U.y-W.y,Qe=Lt.x-V,Nn=Lt.y-st;(_e>10&&Nn<-5||_e<-10&&Nn>5)&&(Nt=Math.abs(Nn)*100),(se>10&&Qe<-5||se<-10&&Qe>5)&&(Nt+=Math.abs(Qe)*50);let Vo=0;const Uo=Tn.get(X.key)??"n",jo=Math.abs(Qe)>mt?"h":"v";Uo!=="n"&&Uo!==jo&&(Vo=50);const gi=ee+Ot+Nt+Vo,tn=(Ze.get(X.key)??1/0)+gi,Wo=Math.abs(U.x-Lt.x)+Math.abs(U.y-Lt.y);if(tn<(Ze.get(Rt)??1/0))if(En.set(Rt,X.pt),Ze.set(Rt,tn),Tn.set(Rt,jo),!Je.has(Rt))Oe.push({key:Rt,f:tn+Wo,pt:Lt}),Je.add(Rt);else{const ce=Oe.findIndex(pi=>pi.key===Rt);ce!==-1&&(Oe[ce].f=tn+Wo)}}}if(qt.length===0&&(qt=[W,{x:W.x,y:U.y},U]),qt.length>4){const X=qt[0],V=qt[qt.length-1];let st=Math.min(X.x,V.x),vt=Math.max(X.x,V.x),Bt=Math.min(X.y,V.y),Et=Math.max(X.y,V.y);for(const $t of qt)st=Math.min(st,$t.x),vt=Math.max(vt,$t.x),Bt=Math.min(Bt,$t.y),Et=Math.max(Et,$t.y);const Ht=vt>Math.max(X.x,V.x),Yt=st<Math.min(X.x,V.x);if(f){const $t=He;if(Ht){const te=Math.max(X.x,V.x),zt=Math.min(X.y,V.y),Rt=Math.max(X.y,V.y),ee=I.filter(Ot=>Ot.minX<te&&Ot.maxX>te&&Ot.minY<Rt&&Ot.maxY>zt);if(ee.length>0){let Ot=Math.max(X.x,V.x);for(const Nt of ee){const se=(Nt.minX+Nt.maxX)/2;if(Nt.visualXHalfExtent===void 0||isNaN(Nt.visualXHalfExtent))continue;const _e=se+Nt.visualXHalfExtent+$t;Ot=Math.max(Ot,_e)}isNaN(Ot)||(vt=Ot)}}if(Yt){const te=I.filter(zt=>zt.minX<Math.min(X.x,V.x)+$t&&zt.minY<Math.max(X.y,V.y)&&zt.maxY>Math.min(X.y,V.y));if(te.length>0){let zt=Math.min(X.x,V.x);for(const Rt of te){const Ot=(Rt.minX+Rt.maxX)/2-Rt.visualXHalfExtent-$t;zt=Math.min(zt,Ot)}st=zt}}}const Lt=i($t=>{const te=V.y>X.y,zt=I.filter(Ot=>{const Nt=Math.min(X.x,V.x)<Ot.maxX&&Math.max(X.x,V.x)>Ot.minX,se=Math.min(X.y,V.y)<Ot.maxY&&Math.max(X.y,V.y)>Ot.minY;return Nt&&se});let Rt=zt;if(f&&zt.length>0){const Ot=zt.filter(Nt=>Nt.minX<$t&&Nt.maxX>$t);Ot.length>0&&(Rt=Ot)}if(Rt.length===0)return V.y;const ee=Ne;if(te){const Nt=Math.max(...Rt.map(se=>se.maxY))+ee;if(Nt<V.y-mt)return Nt}else{const Nt=Math.min(...Rt.map(se=>se.minY))-ee;if(Nt>V.y+mt)return Nt}return V.y},"findBestReturnY"),Jt=i($t=>{const te=Lt($t),zt={x:$t,y:X.y},Rt={x:$t,y:te},ee={x:V.x,y:te},Ot=we(X,zt),Nt=we(zt,Rt),se=we(Rt,ee),_e=te!==V.y?we(ee,V):!1;return!Ot&&!Nt&&!se&&!_e?Math.abs(te-V.y)<mt?[X,zt,Rt,V]:[X,zt,Rt,ee,V]:null},"trySimplifyWithDetourX"),fe=Ht&&!Yt?Jt(vt):Yt&&!Ht?Jt(st):null;fe&&(qt=fe)}const Zt=[O,...Mt,...qt,...Gt.reverse(),H];if(Zt.length>=3){const X=Zt[Zt.length-1],V=Zt[Zt.length-2],st=Zt[Zt.length-3],vt=Math.abs(st.y-V.y)<mt&&Math.abs(V.y-X.y)<mt,Bt=Math.abs(st.x-V.x)<mt&&Math.abs(V.x-X.x)<mt;if(vt){const Et=Math.sign(V.x-st.x),Ht=Math.sign(X.x-st.x);Et!==0&&Et===Ht&&Math.abs(V.x-st.x)>Math.abs(X.x-st.x)&&Zt.splice(-2,1)}else if(Bt){const Et=Math.sign(V.y-st.y),Ht=Math.sign(X.y-st.y);Et!==0&&Et===Ht&&Math.abs(V.y-st.y)>Math.abs(X.y-st.y)&&Zt.splice(-2,1)}}const me=[Zt[0]];for(let X=1;X<Zt.length-1;X++){if(X===1){me.push(Zt[X]);continue}const V=me[me.length-1],st=Zt[X],vt=Zt[X+1];if(Math.abs(V.y-st.y)<mt&&Math.abs(st.y-vt.y)<mt){const Bt=st.x>V.x,Et=vt.x>st.x;if(Bt!==Et){me.push(st);continue}continue}if(Math.abs(V.x-st.x)<mt&&Math.abs(st.x-vt.x)<mt){const Bt=st.y>V.y,Et=vt.y>st.y;if(Bt!==Et){me.push(st);continue}continue}me.push(st)}me.push(Zt[Zt.length-1]);for(let X=0;X<me.length-1;X++){const V=me[X],st=me[X+1],vt=Math.abs(V.x-st.x)<mt?"vertical":"horizontal",Bt=vt==="vertical"?V.x:V.y,Et=vt==="vertical"?Math.min(V.y,st.y):Math.min(V.x,st.x),Ht=vt==="vertical"?Math.max(V.y,st.y):Math.max(V.x,st.x),Yt=m(vt,Bt,Et,Ht),Lt={edgeIndex:d,segmentIndex:X,orientation:vt,pipe:Yt,trackIndex:0,from:Et,to:Ht};b.push(Lt),L[d].push(b.length-1),Yt.tracks[0]||(Yt.tracks[0]={index:0,coord:Yt.coord,segments:[]}),Yt.tracks[0].segments.push({edgeIndex:d,segmentIndex:X,from:Et,to:Ht})}}const rt=i((d,v)=>d.from<v.to&&v.from<d.to,"segmentsOverlap"),ut=i((d,v,T,R)=>{const O=!R.segments.some(J=>(J.edgeIndex!==v.edgeIndex||J.segmentIndex!==v.segmentIndex)&&rt(J,d)),H=!T.segments.some(J=>(J.edgeIndex!==d.edgeIndex||J.segmentIndex!==d.segmentIndex)&&rt(J,v));return O&&H?(d.trackIndex=R.index,v.trackIndex=T.index,T.segments=[...T.segments.filter(J=>J.edgeIndex!==d.edgeIndex||J.segmentIndex!==d.segmentIndex),{edgeIndex:v.edgeIndex,segmentIndex:v.segmentIndex,from:v.from,to:v.to}],R.segments=[...R.segments.filter(J=>J.edgeIndex!==v.edgeIndex||J.segmentIndex!==v.segmentIndex),{edgeIndex:d.edgeIndex,segmentIndex:d.segmentIndex,from:d.from,to:d.to}],!0):!1},"trySwapSegmentsAcrossTracks"),gt=i(d=>{const v=d.tracks.length;return d.tracks[v]={index:v,coord:d.coord,segments:[]},v},"createNewTrack"),pt=i((d,v)=>{const T=d.pipe.tracks[d.trackIndex];T.segments=T.segments.filter(O=>O.edgeIndex!==d.edgeIndex||O.segmentIndex!==d.segmentIndex),d.trackIndex=v,d.pipe.tracks[v].segments.push({edgeIndex:d.edgeIndex,segmentIndex:d.segmentIndex,from:d.from,to:d.to})},"moveSegmentToTrack"),bt=i((d,v)=>{const T=L[d.edgeIndex];for(const R of T){const O=b[R];O.pipe===d.pipe&&pt(O,v)}},"moveSegmentChainToTrack"),Pt=i(d=>{const v=L[d.edgeIndex],T=v.indexOf(b.indexOf(d)),R=[];return T>0&&R.push(b[v[T-1]]),T<v.length-1&&R.push(b[v[T+1]]),R},"getAdjacentSegmentsAlongEdge"),Te=i((d,v)=>{if(d.orientation===v.orientation)return!1;const T=d.orientation==="horizontal"?d:v,R=d.orientation==="horizontal"?v:d;return R.pipe.coord>T.from&&R.pipe.coord<T.to&&T.pipe.coord>R.from&&T.pipe.coord<R.to},"haveAnyCrossing"),Ie=i((d,v)=>{for(const T of d.tracks)if(!T.segments.some(O=>(O.edgeIndex!==v.edgeIndex||O.segmentIndex!==v.segmentIndex)&&rt(O,v)))return T.index;return-1},"findAvailableTrack"),Me=i((d,v)=>{if(d.trackIndex===v.trackIndex)return rt(d,v);const T=Pt(d),R=Pt(v);return T.some(O=>R.some(H=>Te(O,H)))},"segmentsConflict"),Re=i((d,v,T)=>{if(ut(d,v,d.pipe.tracks[d.trackIndex],v.pipe.tracks[v.trackIndex]))return;const R=Ie(d.pipe,v);T(v,R!==-1?R:gt(d.pipe))},"resolveTrackConflict"),We=i(d=>{let v=0;for(let T=0;T<d.length;T++)for(let R=T+1;R<d.length;R++){const O=d[T],H=d[R];O.pipe===H.pipe&&Me(O,H)&&(v++,Re(O,H,bt))}return v},"resolveHandleConflicts"),N=new Map,F=i(d=>{if(N.has(d))return N.get(d);const v=L[d];if(v.length===0){const lt={dest:0,deviation:0,base:0,delta:0};return N.set(d,lt),lt}const R=b[v[0]].pipe.coord;let O=R;for(let lt=1;lt<v.length;lt++){const W=b[v[lt]];if(W.orientation==="horizontal"){const U=W.from,wt=W.to;O=Math.abs(U-R)>Math.abs(wt-R)?U:wt;break}}const H=Math.abs(O-R),J={dest:O,deviation:H,base:R,delta:O-R};return N.set(d,J),J},"getDestInfo"),D=i(()=>{let d=0;const v=new Map;for(const[R,O]of s.entries())L[R].length!==0&&O.start&&(v.has(O.start)||v.set(O.start,[]),v.get(O.start).push(R));const T=i(R=>{const O=s[R];if(!O.start||!O.end)return 0;const H=r.get(O.start),J=r.get(O.end);if(!H||!J)return 0;const lt=(J.x??0)-(H.x??0),W=(J.y??0)-(H.y??0);return Math.abs(lt)+Math.abs(W)},"getEdgeDistance");for(const R of v.values()){R.sort((H,J)=>{const lt=F(H),W=F(J);if(Math.abs(lt.deviation-W.deviation)>1)return lt.deviation-W.deviation;if(Math.abs(lt.dest-W.dest)>1)return lt.dest-W.dest;const U=T(H),wt=T(J);if(Math.abs(U-wt)>1)return wt-U;const At=L[H].length,Tt=L[J].length;if(At!==Tt)return At-Tt;if(At===1){const it=L[H][0],Mt=L[J][0];if(b[it]&&b[Mt]){const _t=b[it],oe=b[Mt],Gt=Math.abs(_t.to-_t.from),ie=Math.abs(oe.to-oe.from);if(Math.abs(Gt-ie)>1)return Gt-ie}}return 0});const O=R.map(H=>b[L[H][0]]);d+=We(O)}return d},"fixSourceHandleCrossings"),j=i(()=>{let d=0;const v=new Map;for(const[T,R]of s.entries())L[T].length!==0&&R.end&&(v.has(R.end)||v.set(R.end,[]),v.get(R.end).push(T));for(const T of v.values()){T.sort((O,H)=>{const J=i(U=>{const wt=L[U];if(wt.length<2)return 0;const At=b[wt[wt.length-2]];return Math.abs(At.to-At.from)},"getDist"),lt=J(O),W=J(H);return Math.abs(lt-W)>.1?lt-W:O-H});const R=T.map(O=>b[L[O][L[O].length-1]]);d+=We(R)}return d},"fixTargetHandleCrossings"),q=i(()=>{let d=0;for(const v of a){const T=[];for(const R of v.tracks)for(const O of R.segments){const H=L[O.edgeIndex].find(J=>b[J].segmentIndex===O.segmentIndex);H!==void 0&&T.push(b[H])}T.sort((R,O)=>R.edgeIndex-O.edgeIndex||R.segmentIndex-O.segmentIndex);for(let R=0;R<T.length;R++)for(let O=R+1;O<T.length;O++){const H=T[R],J=T[O];Me(H,J)&&(d++,Re(H,J,pt))}}return d},"fixPipeCrossings");let nt=0;const G=10;for(;nt<G;){let d=0;if(d+=D(),d+=j(),d+=q(),d===0)break;nt++}const ot=new Map;for(const d of a){const v=[];d.tracks.forEach(R=>{R.segments.forEach(O=>{v.push({edgeIndex:O.edgeIndex,segmentIndex:O.segmentIndex,trackIndex:R.index,from:O.from,to:O.to})})}),v.sort((R,O)=>R.from-O.from);const T=[];if(v.length>0){let R=[v[0]],O=v[0].to;for(let H=1;H<v.length;H++){const J=v[H];J.from<O?(R.push(J),O=Math.max(O,J.to)):(T.push(R),R=[J],O=J.to)}T.push(R)}for(const R of T){const O=new Set;R.forEach(it=>O.add(it.trackIndex));const H=new Map;R.forEach(it=>{const Mt=F(it.edgeIndex);H.set(it.trackIndex,(H.get(it.trackIndex)??0)+Mt.delta)});const J=[...O].filter(it=>(H.get(it)??0)<-1),lt=[...O].filter(it=>(H.get(it)??0)>1),W=[...O].filter(it=>Math.abs(H.get(it)??0)<=1);J.sort((it,Mt)=>(H.get(Mt)??0)-(H.get(it)??0)),lt.sort((it,Mt)=>(H.get(it)??0)-(H.get(Mt)??0));const U=i((it,Mt)=>{R.filter(_t=>_t.trackIndex===it).forEach(_t=>{const oe=u.has(_t.edgeIndex)?d.coord:Mt;ot.set(`${_t.edgeIndex}-${_t.segmentIndex}`,oe)})},"assignCoord");let wt=0;for(const it of J)wt++,U(it,d.coord-wt*_n);if(W.length===0&&O.size>0){const it=[...O].sort((oe,Gt)=>Math.abs(H.get(oe)??0)-Math.abs(H.get(Gt)??0))[0],Mt=J.indexOf(it);Mt!==-1&&J.splice(Mt,1);const _t=lt.indexOf(it);_t!==-1&&lt.splice(_t,1),W.push(it)}let At=0;for(const it of W){if(At===0)U(it,d.coord);else{const Mt=At%2===1?1:-1,_t=Math.ceil(At/2);U(it,d.coord+Mt*_t*_n*.5)}At++}let Tt=0;for(const it of lt)Tt++,U(it,d.coord+Tt*_n)}}for(const[d,v]of s.entries()){const T=L[d]??[];if(T.length===0)continue;const R=[],O=r.get(v.start),H=r.get(v.end),{pSrcPort:J,pDstPort:lt}=Z(d,O,H),W=T.map(Tt=>{const it=b[Tt],Mt=ot.get(`${it.edgeIndex}-${it.segmentIndex}`)??it.pipe.coord;return{orient:it.orientation,coord:Mt,from:it.from,to:it.to}});R.push(J);for(let Tt=0;Tt<W.length;Tt++){const it=W[Tt],Mt=R[R.length-1],_t=it.orient==="vertical"?Mt.y:Mt.x,oe=it.orient==="vertical"?Mt.x:Mt.y,Gt=W[Tt+1],ie=Tt<W.length-1;if(Math.abs(oe-it.coord)>mt&&R.push(Be(it,_t)),ie&&Gt.orient===it.orient)if(Math.abs(it.coord-Gt.coord)>mt){const ve=it.orient==="vertical"?(_t+Gt.from)/2:Io(it,Gt);R.push(Be(it,ve),Be(Gt,ve))}else(Tt===0||Tt===W.length-2)&&R.push(Be(it,Io(it,Gt)));else if(ie)R.push(Be(it,Gt.coord));else{const ve=Math.abs(it.from-_t)<Math.abs(it.to-_t)?it.to:it.from;R.push(Be(it,ve))}}const U=R[R.length-1];(Math.abs(U.x-lt.x)>mt||Math.abs(U.y-lt.y)>mt)&&R.push(lt);const wt=R[0];wt&&(Math.abs(wt.x-J.x)>mt||Math.abs(wt.y-J.y)>mt)&&R.unshift(J);const At=[];R.length>0&&At.push(R[0]);for(let Tt=1;Tt<R.length;Tt++){const it=R[Tt],Mt=At[At.length-1];(Math.abs(it.x-Mt.x)>mt||Math.abs(it.y-Mt.y)>mt)&&At.push(it)}v.points=At}for(const d of s){const v=d.__originalEdge;v&&d.points&&(v.points=d.points)}t.edges=(t.edges??[]).filter(d=>!d.isLayoutOnly);const dt=i((d,v)=>{const T=v.x??0,R=v.y??0,{w:O,h:H}=cn(v,0);if(O<=0||H<=0)return d;const J=T-O/2,lt=T+O/2,W=R-H/2,U=R+H/2;if(d.x<J||d.x>lt||d.y<W||d.y>U)return d;const wt=d.x-J,At=lt-d.x,Tt=d.y-W,it=U-d.y,Mt=Math.min(wt,At,Tt,it);return Mt===wt?{x:J,y:d.y}:Mt===At?{x:lt,y:d.y}:Mt===Tt?{x:d.x,y:W}:{x:d.x,y:U}},"nodeBoundaryClamp");for(const d of t.edges){const v=d.points;if(!v||v.length<2)continue;const T=d.start,R=d.end,O=T?r.get(T):void 0,H=R?r.get(R):void 0;O&&(v[0]=dt(v[0],O)),H&&(v[v.length-1]=dt(v[v.length-1],H))}return t}i(oi,"routeEdgesOrthogonal");function si(t){return t.direction??"TB"}i(si,"getSwimlaneDirection");function ri(t){const e=ys(t),n=t.config.flowchart?.nodeSpacing??40,o=t.config.flowchart?.rankSpacing??100,s=t.config.swimlane?.ignoreCrossLaneEdges??!0,r=t.config.swimlane?.optimizeRanksByCrossings??!0,c=t.config.swimlane?.automaticLaneOrdering??!1,a=si(t),{ordered:f,coordinates:h}=ni(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:c,direction:a});bs(e,f,h,{nodeGap:n,layerGap:o});for(const y of t.edges??[])delete y.points;oi(t,a);for(const y of t.edges??[])(!y.curve||y.curve==="basis")&&(y.curve="rounded");return Ir(t,a),xr(t),a}i(ri,"runSwimlaneLayoutCore");function ii(t){ms(t);const e=Is(t);t.nodes=e.nodes,t.edges=e.edges}i(ii,"prepareSwimlaneLayout");var qi=xi({prepareLayout:ii,runLayoutCore:ri,afterPaint:es});export{qi as render};
1
+ import{n as mi,a as yi}from"./chunk-3GCGMST5-D7bw3E1a.js";import{c as xi}from"./chunk-EBZ3SEQC-BgJPPYdu.js";import{_ as i,l as ze}from"./mermaid.core-COb9i2Gl.js";import"./index-CDRWzs-u.js";import"./vendor-BKfNgqAm.js";import"./graph-D8UmR1vK.js";function es(t,{measure:e}){const n=mi(t.config?.swimlane?.lineHops);if(n===!1)return;const o=t.edges.filter(s=>Array.isArray(s.points)&&s.points.length>=2).map(s=>({id:s.id,points:s.points,curve:s.curve,cornerRadius:s.cornerRadius,arrowTypeStart:s.arrowTypeStart,arrowTypeEnd:s.arrowTypeEnd}));yi(e.groups.edgePaths,o,{enabled:!0,jumpRadius:6,jumpStyle:n})}i(es,"applySwimlaneLineJumps");function ns(t){const e=t?.metadata?.laneRole;return e==="pool"||e==="lane"?e:void 0}i(ns,"readLaneRole");function sn(t){const e=t?.metadata?.laneIndex;return typeof e=="number"&&Number.isFinite(e)?e:void 0}i(sn,"readLaneIndex");function pe(t){const e=new Map,n=new Map;for(const h of t)e.set(h.id,h),h.isGroup&&h.parentId&&n.set(h.parentId,(n.get(h.parentId)??0)+1);const o=new Set;for(const h of t)h.isGroup&&ns(h)==="pool"&&(n.get(h.id)??0)>0&&o.add(h.id);const s=new Set,r=new Map;for(const h of t)if(!(!h.isGroup||o.has(h.id)))if(h.parentId&&o.has(h.parentId)){s.add(h.id);const y=r.get(h.parentId)??[];y.push(h.id),r.set(h.parentId,y)}else h.parentId||s.add(h.id);const c=i((h,y)=>{const l=new Set([h]);let I=e.get(h)?.parentId;for(;I&&!l.has(I);){if(y.has(I))return I;l.add(I),I=e.get(I)?.parentId}return null},"walk"),a=new Map;return{isPool:i(h=>o.has(h),"isPool"),isLane:i(h=>s.has(h),"isLane"),laneIdOf:i(h=>{const y=a.get(h);if(y!==void 0)return y;const l=c(h,s);return a.set(h,l),l},"laneIdOf"),poolIdOf:i(h=>o.has(h)?h:c(h,o),"poolIdOf"),lanesByPool:r,hasPools:o.size>0}}i(pe,"buildLaneModel");var bi=new Set(["top","right","bottom","left"]),Hn=8,Ii=1e4;function $e(t){const e=t?.metadata?.anchorTo;if(!e||typeof e!="object")return;const{hostId:n,side:o,slot:s,gap:r}=e;if(!(typeof n!="string"||n.length===0||n===t?.id))return{hostId:n,...typeof o=="string"&&bi.has(o)?{side:o}:{},...typeof s=="number"&&Number.isFinite(s)?{slot:s}:{},...typeof r=="number"&&Number.isFinite(r)&&r>0?{gap:Math.min(r,Ii)}:{}}}i($e,"readAnchor");function In(t,e){const n=new Set([t]);let o=$e(e.get(t))?.hostId;for(;o&&!n.has(o);){const s=e.get(o);if(!s)return;const r=$e(s)?.hostId;if(!r)return o;n.add(o),o=r}}i(In,"resolveAnchorHostId");function Ge(t){const e=new Map(t.map(o=>[o.id,o])),n=new Set;for(const o of t)$e(o)&&In(o.id,e)&&n.add(o.id);return n}i(Ge,"collectAnchoredIds");function os(t,e){return t==="canonical"?"right":e==="LR"||e==="RL"?"bottom":"right"}i(os,"defaultAnchorSide");function ss(t,e){const n=t.anchor.slot,o=e.anchor.slot;return n!==void 0&&o!==void 0&&n!==o?n-o:n!==void 0&&o===void 0?-1:n===void 0&&o!==void 0?1:t.index-e.index}i(ss,"compareBucketEntries");function rs(t){const e=t.reduce((s,r)=>s+r,0)+Hn*Math.max(0,t.length-1),n=[];let o=-e/2;for(const s of t)n.push(o+s/2),o+=s+Hn;return{offsets:n,total:e}}i(rs,"packAlongBorder");var Mi=i(t=>[t.width,t.height].every(e=>e===void 0||Number.isFinite(e)),"hasUsableSize");function is(t,e){const n=new Map(t.map(s=>[s.id,s])),o=new Map;t.forEach((s,r)=>{const c=$e(s);if(!c||!Mi(s))return;const a=In(s.id,n);if(!a)return;const f=e(c),h=`${f}:${a}`,y=o.get(h)??[];y.push({node:s,anchor:c,index:r,side:f,hostId:a}),o.set(h,y)});for(const s of o.values())s.sort(ss);return o}i(is,"bucketByHostAndSide");function cs(t,e,n,o){const s=!e&&n>0?-(o+Hn):0;return t+s}i(cs,"centreAlongBorder");function as(t,e){const n=e==="top"||e==="bottom",o=i(h=>n?h.width??0:h.height??0,"alongBorder"),s=i(h=>n?h.height??0:h.width??0,"reach"),{offsets:r}=rs(t.map(h=>o(h.node)));let c=0,a=0,f=0;return t.forEach((h,y)=>{const l=h.anchor.gap??0,I=o(h.node)/2,m=cs(r[y],n,l,I);c=Math.max(c,I-m),a=Math.max(a,m+I),f=Math.max(f,l>0?l+s(h.node):0)}),{before:c,after:a,beyond:f}}i(as,"footprintOf");function ls(t,e){const n=os("final",e??"TB"),o=new Map;for(const s of is(t,r=>r.side??n).values()){if(!s.some(a=>a.anchor.gap))continue;const{hostId:r,side:c}=s[0];o.set(r,{...o.get(r),[c]:as(s,c)})}return o}i(ls,"anchorFootprints");var Bn="__swimlane_default__",Si=21,Ko=20;function Dn(t){return Math.max(t.padding??Ko,Ko)}i(Dn,"topLaneHorizontalPadding");function fs(t){const{x:e,y:n,width:o,height:s}=t,r=t.swimlaneContentTop;if(typeof e!="number"||typeof n!="number"||typeof o!="number"||typeof s!="number"||typeof r!="number"||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(r)||o<=0||s<=0){delete t.groupTitleRect;return}const c=n-s/2,a=Math.min(r,n+s/2),f=Math.min(Si,Math.max(0,a-c)),h=c+f;if(h<=c){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:c,bottom:h}}i(fs,"assignTopLaneTitleRect");function ds(t){const e=t.other?.droppedSubGraphMembers;return Array.isArray(e)?e:[]}i(ds,"sharedMembers");var vi=i((t,e,n)=>!e.some(o=>o.parentId===n)&&!(t.edges??[]).some(o=>o.start===n||o.end===n),"isEmptyLane");function us(t,e){return t.isLane(e)?e:t.laneIdOf(e)??void 0}i(us,"laneIdOrSelf");function hs(t,e,n){for(const o of n){const s=e.findIndex(r=>r.id===o);s>=0&&vi(t,e,o)&&e.splice(s,1)}}i(hs,"removeEmptyLanes");function gs(t,e){const n=pe(e),o=new Set(e.filter(r=>n.isLane(r.id)).map(r=>r.id)),s=new Set;for(const{node:r,keptBy:c,droppedFrom:a}of ds(t)){const f=us(n,c);f&&f!==a&&o.has(a)&&(ze.warn(`Swimlane node "${r}" is listed in lanes "${f}" and "${a}"; it is drawn in "${f}" only.`),s.add(a))}hs(t,e,s)}i(gs,"dropLanesEmptiedBySharedNodes");function ps(t,e){for(const n of t)n.isGroup&&!e.isLane(n.id)&&!e.isPool(n.id)&&ze.warn(`Swimlane subgraph "${n.id}" is nested in "${n.parentId}"; only top-level subgraphs are lanes, so it is drawn as a plain box.`)}i(ps,"warnAboutNestedGroups");function ms(t){const e=t.direction,n=t.nodes??=[];gs(t,n);const o=pe(n);ps(n,o);for(const c of n){const a=o.isLane(c.id);!a&&!o.isPool(c.id)||(c.shape=a?"swimlane":"pool",e&&(c.direction=e))}const s=n.filter(c=>!c.isGroup&&!c.parentId);if(s.length===0)return;let r=n.find(c=>c.id===Bn);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:Bn,label:"",isGroup:!0,shape:"swimlane",padding:20,look:t.config?.look,colorIndex:n.reduce((c,a)=>Math.max(c,a.colorIndex??-1),-1)+1,...e?{direction:e}:{}},n.push(r));for(const c of s)c.parentId=Bn}i(ms,"prepareLayoutForSwimlanes");function ys(t){const e=(t.nodes??[]).filter(l=>!l.isEdgeLabel),n=new Map(e.map(l=>[l.id,l])),o=Ge(e),s=i(l=>o.has(l)?In(l,n)??l:l,"hostOf"),r=new Map;for(const l of e)o.has(l.id)||r.set(l.id,l);const c=[];for(const l of t.edges??[]){const I=typeof l.start=="string"?l.start:void 0,m=typeof l.end=="string"?l.end:void 0;if(!I||!m||l.isLayoutOnly)continue;const x=s(I),g=s(m);x!==g&&c.push({id:l.id,src:x,dst:g,ref:l})}const a=e.filter(l=>l.isGroup&&!o.has(l.id)),f=e.filter(l=>!l.isGroup&&!o.has(l.id));return{nodes:[...[...a].reverse(),...f].map(l=>l.id),edges:c,layout:t,nodeById:r}}i(ys,"toGraphView");function xs(t){const e=new Map(t.map(o=>[o.id,o])),n=i(o=>{let s=0,r=o.parentId;const c=new Set([o.id]);for(;r!=null&&!c.has(r);)c.add(r),s++,r=e.get(r)?.parentId;return s},"depthOf");return t.filter(o=>o?.isGroup).map(o=>({node:o,depth:n(o)})).sort((o,s)=>s.depth-o.depth).map(o=>o.node)}i(xs,"groupsDeepestFirst");function bs(t,e,n,o){const{layout:s}=t,r=t.nodeById,c=o?.layerGap??100,a=o?.nodeGap??40;let f=0;for(const x of e.layers){let g=0;for(const b of x){const L=r.get(b);if(!L){g++;continue}L.layer=f,L.order=g;const u=n.x[b]??g*a,C=n.y[b]??f*c;L.x=u,L.y=C,g++}f++}const h=s.nodes??[],y=Ge(h);for(const x of h)x.isEdgeLabel&&n.x[x.id]!=null&&n.y[x.id]!=null&&(x.x=n.x[x.id],x.y=n.y[x.id]);const l=new Map,I=pe(h),m=[];for(const x of xs(h)){I.isLane(x.id)&&m.push(x);const g=h.filter(S=>S.parentId===x.id&&!y.has(S.id));let b=1/0,L=-1/0,u=1/0,C=-1/0;for(const S of g){const p=S.x??n.x[S.id],M=S.y??n.y[S.id],w=S.width??0,A=S.height??0;p!=null&&M!=null&&(S.isEdgeLabel||(b=Math.min(b,p-w/2),L=Math.max(L,p+w/2)),u=Math.min(u,M-A/2),C=Math.max(C,M+A/2))}if(b===1/0||u===1/0)x.x=x.x??0,x.y=x.y??0,x.width=x.width??0,x.height=x.height??0;else{const S=x.padding??20,p=x.parentId?S:2*Dn(x),M=S,w=Math.max(0,L-b)+p,A=Math.max(0,C-u)+M,B=(b+L)/2,P=(u+C)/2;x.x=B,x.y=P,x.width=w,x.height=A,l.set(x.id,{minX:b,maxX:L,minY:u,maxY:C})}}if(m.length>0&&l.size>0){let x=1/0,g=-1/0,b=0;for(const L of m){const u=L.padding??20;u>b&&(b=u);const C=l.get(L.id);C&&(x=Math.min(x,C.minY),g=Math.max(g,C.maxY))}if(x!==1/0&&g!==-1/0){const L=Math.max(0,g-x),C=Math.max(b,36),S=L+2*C,p=(x+g)/2;for(const E of m)E.y=p,E.height=S,E.swimlaneContentTop=x;const M=[...m].sort((E,k)=>{const Y=E.x??0,K=k.x??0;return Y-K}),w=[],A=[],B=[];for(const E of M){const k=l.get(E.id);if(!k)continue;const Y=Math.max(0,k.maxX-k.minX)+2*Dn(E),K=(k.minX+k.maxX)/2;w.push(E.id),A.push(K),B.push(Y)}const P=w.length;if(P>0){const E=new Map;if(P===1)E.set(w[0],B[0]);else{const k=[];for(let at=0;at<P-1;at++)k.push(A[at+1]-A[at]);const Y=new Array(P);Y[0]=0;for(let at=0;at<P-1;at++)Y[at+1]=2*k[at]-Y[at];let K=0,z=Number.POSITIVE_INFINITY;for(let at=0;at<P;at++){const xt=B[at];at%2===0?K=Math.max(K,xt-Y[at]):z=Math.min(z,Y[at]-xt)}let et=K;K<=z?et=(K+z)/2:et=K;for(let at=0;at<P;at++){const xt=Y[at]+(at%2===0?et:-et),Kt=Math.max(B[at],xt);E.set(w[at],Kt)}}for(const k of m){const Y=E.get(k.id);Y!=null&&(k.width=Y),fs(k)}}}}}i(bs,"writeBackToLayoutData");var Ci="[EdgeLabelNodes]";function Is(t){const e=[],n=[],o=new Map;for(const c of t.nodes)o.set(c.id,c);for(const c of t.edges){if(!c.label||c.label.length===0||c.isLayoutOnly||c.labelNodeId)continue;const a=c.start?o.get(c.start):void 0,f=c.end?o.get(c.end):void 0;if(!a||!f){ze.warn(Ci,`Edge ${c.id} has missing source or target node`);continue}const h=`edge-label-${c.start}-${c.end}-${c.id}`,l=a.parentId!==f.parentId?f.parentId:a.parentId,I={id:h,label:c.label,edgeStart:c.start??"",edgeEnd:c.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:l,isGroup:!1,labelStyle:Array.isArray(c.labelStyle)?c.labelStyle[0]:c.labelStyle??"",...a.dir?{dir:a.dir}:{}};e.push(I),c.labelNodeId=h,c.label=void 0,c.text=void 0;const m={id:`${c.id}-to-label`,start:c.start,end:h,type:"normal",isLayoutOnly:!0},x={id:`${c.id}-from-label`,start:h,end:c.end,type:"normal",isLayoutOnly:!0};n.push(m,x)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}i(Is,"createEdgeLabelNodes");var Wt=.001;function Mo(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:De(e,n,o,s)}:void 0}i(Mo,"measuredNodeRect");function So(t){if(t.isGroup)return;const e=Mo(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}i(So,"nodeBoundsInfoFor");function ue(t,e,n=Wt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}i(ue,"samePoint");function St(t,e,n=Wt){return Math.abs(t.x-e.x)<n}i(St,"sameX");function Ct(t,e,n=Wt){return Math.abs(t.y-e.y)<n}i(Ct,"sameY");function Dt(t,e,n=Wt){return Ct(t,e,n)&&Math.abs(t.x-e.x)>n}i(Dt,"isHorizontalSegment");function Xt(t,e,n=Wt){return St(t,e,n)&&Math.abs(t.y-e.y)>n}i(Xt,"isVerticalSegment");function ne(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)))}i(ne,"overlapLength");function ye(t,e,n=Wt){return t.horizontal&&e.horizontal&&Ct(t.a,e.a,n)?ne(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&St(t.a,e.a,n)?ne(t.a.y,t.b.y,e.a.y,e.b.y):0}i(ye,"sameAxisSegmentOverlapLength");function le(t,e=Wt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],c=Dt(s,r,e),a=Xt(s,r,e);(c||a)&&n.push({index:o,a:s,b:r,horizontal:c,vertical:a})}return n}i(le,"orthogonalSegmentsForPoints");function ae(t,e=Wt){const n=le(t,e);let o=0;for(let s=1;s<n.length;s++)n[s-1].horizontal!==n[s].horizontal&&o++;return o}i(ae,"countOrthogonalBends");function Ms(t){const e=le(It(t));return e.slice(1).flatMap((n,o)=>e[o].horizontal===n.horizontal?[]:[n.a])}i(Ms,"bendPoints");function Ss(t,e){const n=Math.max(Math.min(e.a.x,e.b.x)-t.x,0,t.x-Math.max(e.a.x,e.b.x)),o=Math.max(Math.min(e.a.y,e.b.y)-t.y,0,t.y-Math.max(e.a.y,e.b.y));return Math.hypot(n,o)}i(Ss,"distanceToSegment");function an(t,e,n){const o=i((s,r)=>{const c=le(It(r));return Ms(s).some(a=>c.some(f=>Ss(a,f)<n))},"touches");return o(t,e)||o(e,t)}i(an,"routesTouchAtBend");function It(t,e=Wt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ue(s,o,e))&&n.push({x:o.x,y:o.y})}return n}i(It,"dedupeConsecutivePoints");function vo(t,e=Wt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Dt(n,o,e)&&Xt(o,s,e)&&Dt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Xt(n,o,e)&&Dt(o,s,e)&&Xt(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}i(vo,"classifyThreeSegmentRoute");function Mn(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),c=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&a>n.top-o&&c<n.bottom+o}i(Mn,"segmentBoundsOverlapRect");function Co(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}i(Co,"pointInsideRect");function vs(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}i(vs,"rectContainsRect");function ln(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}i(ln,"rectsOverlap");function Xn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}i(Xn,"inflateRect");function De(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}i(De,"rectFromCenterSize");function Qt(t){return Mo(t)?.rect}i(Qt,"rectOfNodeBounds");function Pe(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}}}i(Pe,"portForRectSide");function Lo(t,e,n,o,s,r=Wt){const c=e==="left"||e==="right",a=o==="left"||o==="right";if(c&&a){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(Ct(t,n,r))return[t,n];const l=(t.x+n.x)/2;return[t,{x:l,y:t.y},{x:l,y:n.y},n]}if(e===o){if(Ct(t,n,r))return;const l=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x:l,y:t.y},{x:l,y:n.y},n]}return}if(!c&&!a){if(e===o){if(St(t,n,r))return;const I=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:I},{x:n.x,y:I},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(St(t,n,r))return[t,n];const l=(t.y+n.y)/2;return[t,{x:t.x,y:l},{x:n.x,y:l},n]}if(c&&!a){const y=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,l=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return y&&l?[t,{x:n.x,y:t.y},n]:void 0}const f=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,h=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return f&&h?[t,{x:t.x,y:n.y},n]:void 0}i(Lo,"buildOrthogonalPortPath");function wo(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]}i(wo,"buildSameSideTrackPath");function Sn(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=So(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}i(Sn,"collectRealNodeBounds");function xe(t){const e=[],n=[];for(const o of t){const s=So(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}}i(xe,"collectNodeRectEntries");function Cs(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const s=o.x??0,r=o.y??0,c=o.width??0,a=o.height??0;n.push({nodeId:o.id,...De(s,r,c,a)})}return n}i(Cs,"collectLayoutNodeRects");function Ao(t,e,n=Wt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),c=e.get(s);if(!(!r||!c))return{srcId:o,dstId:s,srcInfo:r,dstInfo:c,collinearX:Math.abs(r.cx-c.cx)<n,collinearY:Math.abs(r.cy-c.cy)<n}}i(Ao,"getNodePairGeometry");function Ft(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&Mn(t,e,r.rect,-s))return!0;return!1}i(Ft,"segmentHitsAnyRect");function Eo(t,e,n,o,s=Wt,r=1e-6){const c=Ct(t,e,s),a=St(t,e,s),f=Ct(n,o,s),h=St(n,o,s);if(c&&f||a&&h||!(c||a)||!(f||h))return!1;const y=c?{a:t,b:e}:{a:n,b:o},l=a?{a:t,b:e}:{a:n,b:o},I=y.a.y,m=Math.min(y.a.x,y.b.x),x=Math.max(y.a.x,y.b.x),g=l.a.x,b=Math.min(l.a.y,l.b.y),L=Math.max(l.a.y,l.b.y);if(g<m||g>x||I<b||I>L)return!1;const u=Math.abs(g-y.a.x)<r&&Math.abs(I-y.a.y)<r||Math.abs(g-y.b.x)<r&&Math.abs(I-y.b.y)<r,C=Math.abs(g-l.a.x)<r&&Math.abs(I-l.a.y)<r||Math.abs(g-l.b.x)<r&&Math.abs(I-l.b.y)<r;return!(u&&C)}i(Eo,"orthogonalSegmentsCross");function To(t,e,n,o,s=Wt){const r=Ct(t,e,s),c=St(t,e,s),a=Ct(n,o,s),f=St(n,o,s);return c&&f&&St(t,n,s)?ne(t.y,e.y,n.y,o.y)>s:r&&a&&Ct(t,n,s)?ne(t.x,e.x,n.x,o.x)>s:!1}i(To,"sameAxisSegmentsOverlap");function fn(t,e,n,o,{epsilon:s=Wt,skipDegenerateOther:r=!1}={}){for(const c of n){if(c===o||c.isLayoutOnly)continue;const a=c.points;if(!(!a||a.length<2))for(let f=0;f<a.length-1;f++){const h=a[f],y=a[f+1];if(!(r&&ue(h,y,s))&&(Eo(t,e,h,y,s)||To(t,e,h,y,s)))return!0}}return!1}i(fn,"segmentConflictsWithAnyEdge");function be(t,e,n,o,s=Wt){const r=Ct(t,e,s),c=St(t,e,s),a=Ct(n,o,s),f=St(n,o,s);if(!(r&&f||c&&a))return!1;const h=r?{a:t,b:e}:{a:n,b:o},y=r?{a:n,b:o}:{a:t,b:e},l=h.a.y,I=Math.min(h.a.x,h.b.x),m=Math.max(h.a.x,h.b.x),x=y.a.x,g=Math.min(y.a.y,y.b.y),b=Math.max(y.a.y,y.b.y);return x>I+s&&x<m-s&&l>g+s&&l<b-s}i(be,"orthogonalSegmentsStrictlyCross");function Gn(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Wt&&t<s-Wt}i(Gn,"strictlyBetween");function Ls(t,e,n){return St(t,e)&&St(e,n)?Gn(e.y,t.y,n.y):Ct(t,e)&&Ct(e,n)?Gn(e.x,t.x,n.x):!1}i(Ls,"isCollinearIntermediate");function ws(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],c=o+1<t.length?t[o+1]:void 0;if(s&&c){if(ue(s,c)){o++,e=!0;continue}if(Ls(s,r,c)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}i(ws,"simplifyPolylineOnce");function dn(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!St(s,r)&&!Ct(s,r)){const c=e.length>=2?e[e.length-2]:void 0,f=(c?St(c,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(f)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ue(s,o))&&n.push(o)}return n}i(dn,"orthogonalizePolyline");function ge(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=ws(e);if(e=o.points,!o.changed)break}return e}i(ge,"simplifyPolyline");var ht=.001,Li=.5,Yn=4;function Ro(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const s=o.start?e.get(o.start):void 0,r=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:s?Qt(s):void 0,dstRect:r?Qt(r):void 0}}i(Ro,"endpointContextFor");function As(t,e,n){if(Ct(t,e,ht))return{x:t.x<n.left?n.left:n.right,y:t.y};if(St(t,e,ht)){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))}}i(As,"segmentEnterPoint");function zn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Co(t[s],e,Li);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const c=As(t[s],t[r],e);return n?[c,...t.slice(s)]:[...t.slice(0,s+1),c]}i(zn,"clipEndpoint");function Es(t,e){for(const n of t){const o=Ro(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=zn(s,o.srcRect,!0)),o.dstRect&&(s=zn(s,o.dstRect,!1)),s=ge(dn(s)),s=Oo(s,o.srcRect,o.dstRect),o.edge.points=ge(dn(s))}}i(Es,"clipEdgeEndpointsToNodeBoundaries");function $n(t,e,n,o=!1){if(Ct(t,e,ht)){if(e.y<n.top-ht||e.y>n.bottom+ht)return e;if(o){if(t.x<n.left-ht)return{x:n.left,y:t.y};if(t.x>n.right+ht)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(St(t,e,ht)){if(e.x<n.left-ht||e.x>n.right+ht)return e;if(o){if(t.y<n.top-ht)return{x:t.x,y:n.top};if(t.y>n.bottom+ht)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}i($n,"snapEndpointToBoundary");function un(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ue(r,o,ht))return r}return t[e+n]}i(un,"firstDistinctAdjacent");function hn(t,e){const n=t+Yn,o=e-Yn;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}i(hn,"cornerClearanceRange");function Vn(t,e,n){const{lo:o,hi:s}=hn(e,n);return Math.min(s,Math.max(o,t))}i(Vn,"clampToCornerClearance");function Ts(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}}i(Ts,"intersectRanges");function Un(t,e){return e==="left"||e==="right"?hn(t.top,t.bottom):hn(t.left,t.right)}i(Un,"clearanceRangeForSide");function gn(t,e,n){const o=t.y>=n.top-ht&&t.y<=n.bottom+ht,s=t.x>=n.left-ht&&t.x<=n.right+ht;if(Ct(t,e,ht)&&o){if(Math.abs(t.x-n.left)<ht)return"left";if(Math.abs(t.x-n.right)<ht)return"right"}if(St(t,e,ht)&&s){if(Math.abs(t.y-n.top)<ht)return"top";if(Math.abs(t.y-n.bottom)<ht)return"bottom"}}i(gn,"terminalSideForSegment");function Ve(t){return t==="left"||t==="right"}i(Ve,"isHorizontalSide");function Rs(t,e,n,o,s){const r=[],c=n?gn(t,e,n):void 0,a=o?gn(e,t,o):void 0;return n&&c&&Ve(c)===s&&r.push(Un(n,c)),o&&a&&Ve(a)===s&&r.push(Un(o,a)),r.length>0?Ts(r):void 0}i(Rs,"straightClearanceRange");function jn(t,e,n,o,s){const r=Rs(t,e,n,o,s);if(!r)return;const c=s?t.y:t.x,a=Math.min(r.hi,Math.max(r.lo,c));if(!(Math.abs(a-c)<ht))return s?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}i(jn,"clearStraightEndpointCornerAxis");function Oo(t,e,n){if(t.length!==2)return t;const[o,s]=t;return Ct(o,s,ht)?jn(o,s,e,n,!0)??t:St(o,s,ht)?jn(o,s,e,n,!1)??t:t}i(Oo,"clearStraightEndpointCornerConnections");function Os(t,e,n){return Ve(n)?{x:t.x,y:Vn(t.y,e.top,e.bottom)}:{x:Vn(t.x,e.left,e.right),y:t.y}}i(Os,"cornerClearedEndpoint");function Ns(t,e,n,o,s,r){const c=t.map(a=>({...a}));for(let a=e;a>=0&&a<t.length;a+=n){const f=t[a];if(r&&!Ct(f,o,ht)||!r&&!St(f,o,ht))break;r?c[a].y=s.y:c[a].x=s.x}return c}i(Ns,"moveCollinearEndpointRun");function Wn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],c=un(t,o,s);if(!c)return t;const a=gn(r,c,e);if(!a)return t;const f=Ve(a),h=Os(r,e,a);return ue(r,h,ht)?t:Ns(t,o,s,r,h,f)}i(Wn,"clearEndpointCornerConnection");function Kn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ht&&Math.max(t.x,e.x)<=n.right+ht,s=Math.min(t.y,e.y)>=n.top-ht&&Math.max(t.y,e.y)<=n.bottom+ht;if(Math.abs(t.y-n.top)<ht&&Math.abs(e.y-n.top)<ht&&o)return"top";if(Math.abs(t.y-n.bottom)<ht&&Math.abs(e.y-n.bottom)<ht&&o)return"bottom";if(Math.abs(t.x-n.left)<ht&&Math.abs(e.x-n.left)<ht&&s)return"left";if(Math.abs(t.x-n.right)<ht&&Math.abs(e.x-n.right)<ht&&s)return"right"}i(Kn,"borderSideForSegment");function qn(t,e,n,o){switch(t){case"top":return St(e,n,ht)&&n.y<o.top-ht;case"bottom":return St(e,n,ht)&&n.y>o.bottom+ht;case"left":return Ct(e,n,ht)&&n.x<o.left-ht;case"right":return Ct(e,n,ht)&&n.x>o.right+ht}}i(qn,"leavesOutward");function Zn(t,e,n){if(t.length<3)return t;if(n){const r=Kn(t[0],t[1],e);return r&&qn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=Kn(t[o-1],t[o],e);return s&&qn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}i(Zn,"collapseOwnBorderStub");function Bs(t,e,n){let o=t;if(e){const r=un(o,0,1);if(r){const c=$n(r,o[0],e);c!==o[0]&&(o=[c,...o.slice(1)])}o=Zn(o,e,!0)}if(n){const r=o.length-1,c=un(o,r,-1);if(c){const a=$n(c,o[r],n,!0);a!==o[r]&&(o=[...o.slice(0,r),a])}o=Zn(o,n,!1)}const s=Oo(o,e,n);return s!==o||o.length===2?s:(e&&(o=Wn(o,e,!0)),n&&(o=Wn(o,n,!1)),o)}i(Bs,"snapAndCollapseEndpoints");function pn(t,e){for(const n of t){const o=Ro(n,e,2);if(!o)continue;const s=It(o.points,ht),r=Bs(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const c=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=c}}i(pn,"prepareEdgeEndpointsForRenderer");function Ps(t){return new Map(t.map(e=>[e.id,e]))}i(Ps,"buildNodeMap");function Jn(t,e){const n=new Set([t.id]);let o=0,s=t.parentId;for(;s&&!n.has(s);){const r=e.get(s);if(!r?.isGroup)break;n.add(s),o++,s=r.parentId}return o}i(Jn,"groupDepth");function No(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const c=r.x,a=r.y;if(typeof c!="number"||typeof a!="number")continue;const f=r.width??0,h=r.height??0;e=Math.min(e,c-f/2),n=Math.max(n,c+f/2),o=Math.min(o,a-h/2),s=Math.max(s,a+h/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}i(No,"boundsForChildren");function Fs(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}i(Fs,"applyGroupBounds");function ks(t){const e=Ps(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>Jn(s,e)-Jn(o,e));for(const o of n){const s=t.filter(c=>c.parentId===o.id),r=No(s);r&&Fs(o,r)}}i(ks,"recomputeNestedGroupBounds");function mn(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(f=>!f.isGroup);let r=1/0,c=-1/0;for(const f of s){const h=f[e];typeof h=="number"&&(r=Math.min(r,h),c=Math.max(c,h))}if(!Number.isFinite(r)||!Number.isFinite(c))return!1;const a=i(f=>r+c-f,"mirror");for(const f of n){const h=f[e];typeof h=="number"&&(f[e]=a(h));const y=f.groupTitleRect;y&&(f.groupTitleRect=e==="x"?{...y,left:a(y.right),right:a(y.left)}:{...y,top:a(y.bottom),bottom:a(y.top)})}for(const f of o)for(const h of f.points??[])h[e]=a(h[e]);return!0}i(mn,"mirrorAxis");function _s(t){return(t.nodes??[]).some(n=>!n.isGroup)?mn(t,"y"):!0}i(_s,"applyBtDirectionTransform");function Bo(t){const e=Ge(t),n=t.filter(a=>!a.isGroup&&!a.isEdgeLabel&&!e.has(a.id));if(n.length===0)return 1;let o=0,s=0;for(const a of n)o+=a.width??0,s+=a.height??0;const r=o/n.length,c=s/n.length;return c>0?Math.max(1,r/c):1}i(Bo,"flowAxisStretch");var wi=36,Ai=["top","right","bottom","left"];function Hs(t){return t==="left"?"right":t==="right"?"left":t}i(Hs,"mirroredSide");function Ds(t,e,n,o,s){if(n==="top"||n==="bottom"){const c=(e.left+e.right)/2,[a,f]=s?[o.after,o.before]:[o.before,o.after];t.left=Math.min(t.left,c-a),t.right=Math.max(t.right,c+f);return}const r=(e.top+e.bottom)/2;t.top=Math.min(t.top,r-o.before),t.bottom=Math.max(t.bottom,r+o.after)}i(Ds,"growAlongBorder");var Ei={top:i((t,e,n)=>{t.top=Math.min(t.top,e.top-n)},"top"),bottom:i((t,e,n)=>{t.bottom=Math.max(t.bottom,e.bottom+n)},"bottom"),left:i((t,e,n)=>{t.left=Math.min(t.left,e.left-n)},"left"),right:i((t,e,n)=>{t.right=Math.max(t.right,e.right+n)},"right")};function Xs(t,e,n,o,s){Ds(t,e,n,o,s),Ei[n](t,e,o.beyond)}i(Xs,"reserveOnSide");function Gs(t,e,n){const o=t.x??0,s=t.y??0,r=(t.width??0)/2,c=(t.height??0)/2,a={left:o-r,right:o+r,top:s-c,bottom:s+c},f={...a},h=n==="RL";for(const y of Ai){const l=e[y];l&&Xs(f,a,h?Hs(y):y,l,h)}return{...t,x:(f.left+f.right)/2,y:(f.top+f.bottom)/2,width:f.right-f.left,height:f.bottom-f.top}}i(Gs,"withAnchorFootprints");function Ys(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=Ge(n),r=n.filter(E=>!E.isGroup&&!s.has(E.id));let c=1/0,a=1/0;for(const E of r){const k=E.x??0,Y=E.y??0;k<c&&(c=k),Y<a&&(a=Y)}if(!Number.isFinite(c)||!Number.isFinite(a))return!1;const f=wi,h=Bo(n);for(const E of r){const k=E.x??0,K=((E.y??0)-a)*h+f,z=k-c;E.x=K,E.y=z}for(const E of o)if(E.points)for(const k of E.points){const Y=k.x,z=(k.y-a)*h+f,et=Y-c;k.x=z,k.y=et}ks(n);const y=pe(n),l=n.filter(E=>y.isLane(E.id));if(l.length===0)return e==="RL"&&mn(t,"x"),!0;const I=new Map,m=ls(n,e);for(const E of n){if(y.isLane(E.id)||y.isPool(E.id)||s.has(E.id))continue;const k=y.laneIdOf(E.id);if(!k)continue;const Y=I.get(k)??[],K=m.get(E.id);Y.push(K?Gs(E,K,e):E),I.set(k,Y)}let x=0;for(const E of l){const k=E.padding??0;k>x&&(x=k)}const g=[];let b=1/0,L=-1/0;for(const E of l){const k=I.get(E.id)??[],Y=No(k);Y&&(b=Math.min(b,Y.minX),L=Math.max(L,Y.maxX),g.push({lane:E,contentTop:Y.minY,contentBottom:Y.maxY,centerY:(Y.minY+Y.maxY)/2}))}if(b===1/0||L===-1/0)return!0;const u=Math.max(0,L-b),C=Math.max(x,10),S=u+2*C,p=f+S,A=(b+L)/2-S/2-f,B=A+p/2,P=Math.max(x,f);g.sort((E,k)=>E.centerY-k.centerY);for(let E=0;E<g.length;E++){const k=g[E];let Y,K;if(E===0?Y=k.contentTop-P:Y=(g[E-1].contentBottom+k.contentTop)/2,E===g.length-1)K=k.contentBottom+P;else{const at=g[E+1];K=(k.contentBottom+at.contentTop)/2}const z=Math.max(0,K-Y),et=(Y+K)/2;k.lane.x=B,k.lane.y=et,k.lane.width=p,k.lane.height=z,k.lane.swimlaneContentTop=k.contentTop,k.lane.groupTitleRect={left:A,right:A+f,top:Y,bottom:K}}return e==="RL"&&mn(t,"x"),!0}i(Ys,"applyLrDirectionTransform");var he=1e-6,Ti=8,en=Ti,Ri=[0,en,-en,2*en,-2*en];function zs(t,e){const{nodeInfoById:n,realNodeRects:o}=Sn(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const c=vo(It(r,he),he);if(!c)continue;const{p3:a}=c,f=c.kind==="HVH",h=Ao(s,n,he);if(!h)continue;const{srcId:y,dstId:l,srcInfo:I,dstInfo:m,collinearX:x,collinearY:g}=h;if(x||g)continue;let b;const L=I.rect;for(const u of Ri){let C,S,p;if(f){const E=m.cy>I.cy?L.bottom:L.top,k=I.cx+u;if(k<=L.left+he||k>=L.right-he)continue;C={x:k,y:E},S={x:k,y:a.y},p={x:a.x,y:a.y}}else{const E=m.cx>I.cx?L.right:L.left,k=I.cy+u;if(k<=L.top+he||k>=L.bottom-he)continue;C={x:E,y:k},S={x:a.x,y:k},p={x:a.x,y:a.y}}const M=ue(C,S,he),w=ue(S,p,he);if(M&&w||!M&&Ft(C,S,o,[y],1)||!w&&Ft(S,p,o,[l],1))continue;const A=!M&&fn(C,S,t,s,{epsilon:he,skipDegenerateOther:!0}),B=!w&&fn(S,p,t,s,{epsilon:he,skipDegenerateOther:!0});if(!(A||B)){M?b=[S,p]:w?b=[C,S]:b=[C,S,p];break}}b&&(s.points=b)}}i(zs,"portSwapToLShape");function $s(t,e){const{realNodeRects:r,labelNodeRects:c}=xe(e.values());for(const a of t){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<4)continue;const h=It(f,.001);if(h.length<4)continue;const y=h.length-1,l=h[y],I=h[y-1],m=h[y-2],x=l.x-I.x,g=l.y-I.y,b=Math.hypot(x,g);if(b>=10||b<.001)continue;const L=I.x-m.x,u=I.y-m.y;if(Math.hypot(L,u)<.001)continue;const S=Dt(I,l,.001),p=Xt(I,l,.001),M=Dt(m,I,.001),w=Xt(m,I,.001);if(!(S&&w||p&&M))continue;const A=a.end,B=a.start,P=A?e.get(A):void 0;if(!P)continue;const E=P.x??0,k=P.y??0,Y=Qt(P);if(!Y)continue;let K,z;if(w){const Q=u<0;K={x:E,y:m.y},z={x:E,y:Q?Y.bottom:Y.top}}else{const Q=L>0;K={x:m.x,y:k},z={x:Q?Y.right:Y.left,y:k}}if(Ft(K,z,r,A?[A]:[],-2)||Ft(K,z,c,[],-2))continue;if(B){const Q=e.get(B),ft=Q?Qt(Q):void 0;if(ft&&Co(K,ft,2))continue}const et=i((Q,ft)=>`${Q.x.toFixed(3)},${Q.y.toFixed(3)}|${ft.x.toFixed(3)},${ft.y.toFixed(3)}`,"ownSegmentKey"),at=new Set;for(let Q=0;Q<h.length-1;Q++)at.add(et(h[Q],h[Q+1]));const xt=i((Q,ft)=>{for(const _ of t){if(_===a||_.isLayoutOnly)continue;const $=_.points;if(!(!$||$.length<2))for(let tt=0;tt<$.length-1;tt++){const Z=$[tt],rt=$[tt+1];if(!at.has(et(Z,rt))&&be(Q,ft,Z,rt,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(xt(K,z))continue;if(y-3>=0){const Q=h[y-3],ft=[B,A].filter(_=>!!_);if(Ft(Q,K,r,ft,-2)||xt(Q,K))continue}const Ut=[...h.slice(0,y-2),K,z];a.points=Ut;const jt=a.labelNodeId;if(jt){const Q=e.get(jt);if(Q){const ft=Q.width??0,_=Q.height??0;if(ft>0&&_>0){let $,tt,Z=-1;for(let rt=0;rt<Ut.length-1;rt++){const ut=Ut[rt],gt=Ut[rt+1],pt=Math.hypot(gt.x-ut.x,gt.y-ut.y),bt=Ct(ut,gt,.001),Pt=St(ut,gt,.001);(bt&&pt>=ft+2||Pt&&pt>=_+2)&&pt>Z&&(Z=pt,$=(ut.x+gt.x)/2,tt=(ut.y+gt.y)/2)}$!==void 0&&tt!==void 0&&(Q.x=$,Q.y=tt)}}}}}i($s,"collapseShortTerminalStub");var Oi=4,Ni=2,Po={MIN_ARROWHEAD_SPACING:12,ROUTE_TOUCH_TOLERANCE:Oi+Ni},Bi={EPSILON:1e-6},yn={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},Pn={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40,EDGE_LABEL_CLEARANCE:16},ct=.001,Vt=8,Vs=i(t=>typeof t=="string"?t.toUpperCase():"","upperCaseDirection"),yt=le,Fn=i((t,e)=>St(t,e,ct)||Ct(t,e,ct),"orthogonallyAligned");function Qn(t,e){const r=i((u,C)=>{const S=Math.min(8,(C-u)/4);return{low:u+S,high:C-S}},"usableFace"),c=i((u,C)=>{const S=u.x??0,p=u.y??0,M=C.x-S,w=C.y-p;let A=(u.width??0)/2,B=(u.height??0)/2;return Math.abs(w)*A>Math.abs(M)*B?(w<0&&(B=-B),{x:S+(w===0?0:B*M/w),y:p+B}):(M<0&&(A=-A),{x:S+A,y:p+(M===0?0:A*w/M)})},"rectIntersect"),a=i((u,C)=>{const S=It(u.points??[]);if(S.length<2)return;const p=C?u.start:u.end,M=p?e.get(p):void 0,w=M?Qt(M):void 0;if(!M||!p||!w)return;const A=C?S[0]:S[S.length-1],B=C?S[1]:S[S.length-2],P=c(M,A);let E=A;if(Fn(B,P)&&(E=B),St(P,E,ct))return{edge:u,edgeId:String(u.id??""),nodeId:p,atStart:C,orientation:"V",coord:P.x,min:Math.min(P.y,E.y),max:Math.max(P.y,E.y),boundary:P,railEnd:E,rect:w};if(Ct(P,E,ct))return{edge:u,edgeId:String(u.id??""),nodeId:p,atStart:C,orientation:"H",coord:P.y,min:Math.min(P.x,E.x),max:Math.max(P.x,E.x),boundary:P,railEnd:E,rect:w}},"terminalLaneFor"),f=i((u,C)=>Math.max(0,Math.min(u.max,C.max)-Math.max(u.min,C.min)),"projectedOverlapLength"),h=i((u,C)=>u.nodeId!==C.nodeId||u.orientation!==C.orientation?!1:u.orientation==="H"?(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1)&&St(u.boundary,C.boundary,1):(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1)&&Ct(u.boundary,C.boundary,1),"sameTerminalFace"),y=i((u,C)=>u.nodeId!==C.nodeId||u.orientation!==C.orientation?!1:f(u,C)>=Vt&&Math.abs(u.coord-C.coord)<.5,"exactTerminalLaneConflict"),l=i((u,C)=>{if(u.nodeId!==C.nodeId||u.orientation!==C.orientation||u.orientation!=="H"||u.atStart===C.atStart)return!1;const S=f(u,C);if(S<Vt)return!1;const p=u.rect.bottom-u.rect.top;return S<p||S>2*p?!1:h(u,C)&&Math.abs(u.coord-C.coord)<16},"nearTerminalLaneConflict"),I=i((u,C)=>{const S=It(u.edge.points??[]);if(S.length<2)return;const p=u.orientation==="V"?{x:u.boundary.x+C,y:u.boundary.y}:{x:u.boundary.x,y:u.boundary.y+C},M=u.orientation==="V"?{x:u.railEnd.x+C,y:u.railEnd.y}:{x:u.railEnd.x,y:u.railEnd.y+C};if(!i(()=>{if(Math.abs(u.boundary.y-u.rect.top)<1||Math.abs(u.boundary.y-u.rect.bottom)<1){const E=r(u.rect.left,u.rect.right);return Ct(p,u.boundary,ct)&&p.x>=E.low&&p.x<=E.high}if(Math.abs(u.boundary.x-u.rect.left)<1||Math.abs(u.boundary.x-u.rect.right)<1){const E=r(u.rect.top,u.rect.bottom);return St(p,u.boundary,ct)&&p.y>=E.low&&p.y<=E.high}return!1},"boundaryStaysOnSameFace")())return;if(u.atStart){const E=S.length>1&&ue(S[1],u.railEnd,ct),k=S.slice(E?2:1),Y=k[0];return Y&&!Fn(Y,M)?void 0:[p,M,...k]}const A=S.length>1&&ue(S[S.length-2],u.railEnd,ct),B=S.slice(0,A?-2:-1),P=B[B.length-1];if(!(P&&!Fn(P,M)))return[...B,M,p]},"shiftedCandidate"),m=i(u=>{const C=u.edge,S=It(C.points??[]);if(S.length!==2)return!1;const p=C.start,M=C.end,w=p?e.get(p):void 0,A=M?e.get(M):void 0;if(!w||!A)return!1;const B=w.x??0,P=w.y??0,E=A.x??0,k=A.y??0,[Y,K]=S;return Ct(Y,K,ct)&&Math.abs(P-k)<1&&Math.abs(B-E)>1||St(Y,K,ct)&&Math.abs(B-E)<1&&Math.abs(P-k)>1},"laneIsStraightCollinearConnector"),x=i(u=>u.orientation==="H"?r(u.rect.top,u.rect.bottom):r(u.rect.left,u.rect.right),"usableSpanOf"),g=i((u,C)=>{const S=x(u),p=u.coord<C.coord?S.low-u.coord:S.high-u.coord;return Math.sign(p)===Math.sign(u.coord-C.coord)?p:0},"shiftToFaceLimit"),b=i(u=>{const C=x(u);return[C.low-u.coord,C.high-u.coord]},"shiftsToFaceEnds"),L=[-7,7,-14,14,-21,21];for(let u=0;u<8;u++){const C=t.filter(p=>!p.isLayoutOnly).flatMap(p=>[a(p,!0),a(p,!1)]).filter(p=>!!p);let S=!1;for(let p=0;p<C.length&&!S;p++)for(let M=p+1;M<C.length&&!S;M++){const w=C[p],A=C[M];if(w.edge===A.edge||!(y(w,A)||l(w,A)))continue;const B=!y(w,A),P=[w,A].sort((z,et)=>{const at=m(z),xt=m(et);return at!==xt?Number(at)-Number(xt):+!et.atStart-+!z.atStart}),E=i((z,et,at)=>C.some(xt=>xt.edge!==z.edge&&(y(et,xt)||at&&l(et,xt))),"conflictsWith"),k=i((z,et)=>Math.min(...C.filter(at=>at.edge!==z.edge&&at.nodeId===et.nodeId&&at.orientation===et.orientation&&f(et,at)>=Vt).map(at=>Math.abs(et.coord-at.coord))),"closestTrackGap"),Y=i((z,et,at,xt=!1)=>{const Kt=et?a({...z.edge,points:et},z.atStart):void 0;return!et||!Kt||E(z,Kt,at)||xt&&k(z,Kt)<k(z,z)?!1:(z.edge.points=et,!0)},"accept"),K=B?P.filter(z=>!m(z)):P;for(const z of K)if(S=L.some(et=>Y(z,I(z,et),B)),S)break;if(!S){for(const z of K)if(S=(B?[g(z,z===w?A:w)]:b(z)).some(xt=>Math.abs(xt)>ct&&Y(z,I(z,xt),!1,!0)),S)break}}if(!S)return}}i(Qn,"separateSharedRenderedTerminalLanes");function Us(t,e){const{realNodeRects:o,labelNodeRects:s}=xe(e.values()),r=i((a,f)=>{const h=a.start,y=a.end,l=yt(f);if(l.length!==f.length-1)return!1;const I=[h,y].filter(m=>!!m);for(const m of l)if(Ft(m.a,m.b,o,I,-2)||Ft(m.a,m.b,s,[],-2))return!1;for(const m of t){if(m===a||m.isLayoutOnly)continue;const x=m.points;if(!(!x||x.length<2)){for(const g of l)for(const b of yt(It(x)))if(ye(g,b,.5)>=Vt||be(g.a,g.b,b.a,b.b,ct))return!1}}return!0},"candidateIsSafe"),c=i((a,f)=>{if(f+4>=a.length)return;const h=a[f],y=a[f+1],l=a[f+2],I=a[f+3],m=a[f+4],x=Dt(h,y)&&Xt(y,l)&&Dt(l,I)&&Xt(I,m)&&St(h,I,ct)&&St(h,m,ct)&&St(y,l,ct)&&(y.x-h.x)*(I.x-l.x)<0,g=Xt(h,y)&&Dt(y,l)&&Xt(l,I)&&Dt(I,m)&&Ct(h,I,ct)&&Ct(h,m,ct)&&Ct(y,l,ct)&&(y.y-h.y)*(I.y-l.y)<0;if(x||g)return It([...a.slice(0,f+1),m,...a.slice(f+5)]);if(f+5>=a.length)return;const b=a[f+5],L=Xt(h,y)&&Dt(y,l)&&Xt(l,I)&&Dt(I,m)&&Xt(m,b)&&St(h,m,ct)&&St(h,b,ct)&&St(l,I,ct)&&(l.x-y.x)*(m.x-I.x)<0,u=Dt(h,y)&&Xt(y,l)&&Dt(l,I)&&Xt(I,m)&&Dt(m,b)&&Ct(h,m,ct)&&Ct(h,b,ct)&&Ct(l,I,ct)&&(l.y-y.y)*(m.y-I.y)<0;if(!(!L&&!u))return It([...a.slice(0,f+1),b,...a.slice(f+6)])},"withoutDogleg");for(let a=0;a<8;a++){let f=!1;for(const h of t){if(h.isLayoutOnly)continue;const y=It(h.points??[]);for(let l=0;l<=y.length-5;l++){const I=c(y,l);if(!(!I||!r(h,I))){h.points=I,f=!0;break}}if(f)break}if(!f)return}}i(Us,"collapseRedundantRectangularDoglegs");function to(t,e){const{realNodeRects:r,labelNodeRects:c}=xe(e.values()),a=t.filter(x=>!x.isLayoutOnly),f=i((x,g,b)=>It(x===g?b??[]:x.points??[]),"pointsFor"),h=i((x,g)=>{let b=0;for(let L=0;L<a.length;L++){const u=yt(f(a[L],x,g));for(let C=L+1;C<a.length;C++){const S=yt(f(a[C],x,g));for(const p of u)for(const M of S)be(p.a,p.b,M.a,M.b,ct)&&b++}}return b},"strictCrossingCount"),y=i(x=>{const g=yt(x);if(g.length!==3)return;const b=g[1];if(!(g[0].horizontal===b.horizontal||g[2].horizontal===b.horizontal))return{index:b.index,horizontal:b.horizontal,vertical:b.vertical,segment:b}},"middleRail"),l=i((x,g)=>{const b=[x.start,x.end].filter(L=>!!L);return r.filter(L=>{if(b.includes(L.id))return!1;const u=L.rect;return g.horizontal?ne(g.a.x,g.b.x,u.left,u.right)>=Vt&&g.a.y>=u.top-2&&g.a.y<=u.bottom+2:ne(g.a.y,g.b.y,u.top,u.bottom)>=Vt&&g.a.x>=u.left-2&&g.a.x<=u.right+2})},"blockingRectsFor"),I=i((x,g,b)=>{const L=x.map(C=>({...C}));if(g.horizontal)L[g.index].y=b,L[g.index+1].y=b;else if(g.vertical)L[g.index].x=b,L[g.index+1].x=b;else return;const u=ge(It(L));return yt(u).length===u.length-1?u:void 0},"candidateByMovingRail"),m=i((x,g,b)=>{const L=[x.start,x.end].filter(C=>!!C),u=yt(g);if(u.length!==g.length-1)return!1;for(const C of u)if(Ft(C.a,C.b,r,L,-2)||Ft(C.a,C.b,c,[],-2))return!1;for(const C of a)if(C!==x){for(const S of u)for(const p of yt(f(C)))if(ye(S,p,.5)>=Vt)return!1}return h(x,g)<=b},"candidateIsSafe");for(let x=0;x<8;x++){const g=h();let b=!1;for(const L of a){const u=f(L),C=y(u);if(!C)continue;const S=l(L,C.segment);if(S.length===0)continue;const p=C.horizontal?[Math.min(...S.map(M=>M.rect.top))-20,Math.max(...S.map(M=>M.rect.bottom))+20]:[Math.min(...S.map(M=>M.rect.left))-20,Math.max(...S.map(M=>M.rect.right))+20];for(const M of p){const w=I(u,C.segment,M);if(!(!w||!m(L,w,g))){L.points=w,b=!0;break}}if(b)break}if(!b)return}}i(to,"liftObstacleHuggingSameSideRails");function eo(t,e,n){const s=i(y=>{const l=y.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"),r=pe([...e.values()]),c=i(y=>{if(!r.isLane(y.id))return;const l=Vs(y.direction??n);if(l==="LR"||l==="RL"||l==="BT")return;const I=s(y),m=y.y,x=y.height;if(!I||typeof m!="number"||typeof x!="number"||!Number.isFinite(m)||!Number.isFinite(x)||x<=0)return;const g=I.right-I.left,b=I.bottom-I.top;if(!(b<=0||g<b))return{node:y,rect:I}},"topLaneTitleFor"),a=i((y,l)=>{if(!y.horizontal)return!1;const I=y.a.y;return I<l.top-ct||I>l.bottom+ct?!1:ne(y.a.x,y.b.x,l.left,l.right)>=Vt},"horizontalSegmentIntersectsTitle"),f=[...e.values()].map(c).filter(y=>!!y);if(f.length===0)return;let h=0;for(const y of t){if(y.isLayoutOnly)continue;const l=It(y.points??[]);for(const I of yt(l))for(const m of f)a(I,m.rect)&&(h=Math.max(h,m.rect.bottom-I.a.y+4))}if(!(h<=ct))for(const y of f){const l=y.node.y,I=y.node.height;typeof l!="number"||typeof I!="number"||!Number.isFinite(l)||!Number.isFinite(I)||I<=0||(y.node.y=l-h/2,y.node.height=I+h,y.node.groupTitleRect={...y.rect,top:y.rect.top-h,bottom:y.rect.bottom-h})}}i(eo,"liftTopLaneTitleBandsAboveRails");function no(t,e,n){const s=i(l=>{const I=l.groupTitleRect;if(!(!I||typeof I.left!="number"||typeof I.right!="number"||typeof I.top!="number"||typeof I.bottom!="number"||!Number.isFinite(I.left)||!Number.isFinite(I.right)||!Number.isFinite(I.top)||!Number.isFinite(I.bottom)||I.right<=I.left||I.bottom<=I.top))return{left:I.left,right:I.right,top:I.top,bottom:I.bottom}},"validTitleRect"),r=pe([...e.values()]),c=i(l=>{if(!r.isLane(l.id)||Vs(l.direction??n)!=="LR")return;const m=s(l),x=l.x,g=l.width;if(!m||typeof x!="number"||typeof g!="number"||!Number.isFinite(x)||!Number.isFinite(g)||g<=0)return;const b=m.right-m.left,L=m.bottom-m.top;if(!(b<=0||L<b))return{node:l,rect:m}},"leftLaneTitleFor"),a=i((l,I)=>{if(!l.vertical)return!1;const m=l.a.x;return m<I.left-ct||m>I.right+ct?!1:ne(l.a.y,l.b.y,I.top,I.bottom)>=Vt},"verticalSegmentIntersectsTitle"),f=i((l,I)=>{if(!l.horizontal)return!1;const m=l.a.y;return m<I.top-ct||m>I.bottom+ct?!1:ne(l.a.x,l.b.x,I.left,I.right)>=Vt},"horizontalSegmentIntersectsTitle"),h=[...e.values()].map(c).filter(l=>!!l);if(h.length===0)return;let y=0;for(const l of t){if(l.isLayoutOnly)continue;const I=It(l.points??[]);for(const m of yt(I))for(const x of h)if(a(m,x.rect))y=Math.max(y,x.rect.right-m.a.x+4);else if(f(m,x.rect)){const g=Math.min(m.a.x,m.b.x);y=Math.max(y,x.rect.right-g+4)}}if(!(y<=ct))for(const l of h){const I=l.node.x,m=l.node.width;typeof I!="number"||typeof m!="number"||!Number.isFinite(I)||!Number.isFinite(m)||m<=0||(l.node.x=I-y/2,l.node.width=m+y,l.node.groupTitleRect={...l.rect,left:l.rect.left-y,right:l.rect.right-y})}}i(no,"shiftLeftLaneTitleBandsLeftOfRails");function js(t,e){const{realNodeRects:o}=xe(e.values()),s=t.filter(x=>!x.isLayoutOnly),r=i((x,g=new Map)=>It(g.get(x)??x.points??[]),"replacementPointsFor"),c=i((x=new Map)=>{let g=0;for(let b=0;b<s.length;b++){const L=yt(r(s[b],x));for(let u=b+1;u<s.length;u++){const C=yt(r(s[u],x));for(const S of L)for(const p of C)be(S.a,S.b,p.a,p.b,ct)&&g++}}return g},"crossingCount"),a=i((x=new Map)=>s.reduce((g,b)=>g+ae(r(b,x)),0),"totalBends"),f=i(x=>{const g=r(x);if(g.length<4)return;const b=g[g.length-2],L=g[g.length-1];if(!(!Dt(b,L,ct)&&!Xt(b,L,ct)))return{tailStart:b,terminal:L}},"terminalTailFor"),h=i((x,g)=>{const b=r(x);if(b.length<3)return;const L=b[0],u=b[1];let C;if(Dt(L,u,ct))C={x:u.x,y:g.tailStart.y};else if(Xt(L,u,ct))C={x:g.tailStart.x,y:u.y};else return;const S=ge(It([L,u,C,g.tailStart,g.terminal]));return yt(S).length===S.length-1?S:void 0},"candidateWithDestinationTail"),y=i((x,g)=>{const b=[x.start,x.end].filter(L=>!!L);for(const L of yt(g))if(Ft(L.a,L.b,o,b,-2))return!0;return!1},"pathHasNodeHit"),l=i((x,g,b)=>{for(const L of s)if(L!==x){for(const u of yt(g))for(const C of yt(r(L,b)))if(ye(u,C,.5)>=Vt)return!0}return!1},"pathHasSharedTrack"),I=i((x,g,b)=>!y(x,g)&&!l(x,g,b),"candidateIsSafe"),m=i(()=>{const x=new Map;for(const g of s){const b=g.end;if(!b||!e.has(b)||r(g).length<4)continue;const u=x.get(b)??[];u.push(g),x.set(b,u)}return x},"edgesByDestination");for(let x=0;x<4;x++){const g=c();if(g===0)return;const b=a();let L,u=g,C=b;for(const S of m().values())for(let p=0;p<S.length;p++)for(let M=p+1;M<S.length;M++){const w=S[p],A=S[M],B=f(w),P=f(A);if(!B||!P)continue;const E=h(w,P),k=h(A,B);if(!E||!k)continue;const Y=new Map([[w,E],[A,k]]);if(!I(w,E,Y)||!I(A,k,Y))continue;const K=c(Y),z=a(Y);K>=g||K>u||K===u&&z>=C||(L=Y,u=K,C=z)}if(!L)return;for(const[S,p]of L)S.points=p}}i(js,"swapDestinationTerminalTailsToReduceCrossings");function Ws(t,e){const{realNodeRects:r,labelNodeRects:c}=xe(e.values()),a=t.filter(S=>!S.isLayoutOnly),f=i((S,p=new Map)=>It(p.get(S)??S.points??[]),"replacementPointsFor"),h=i((S=new Map)=>{let p=0;for(let M=0;M<a.length;M++){const w=yt(f(a[M],S));for(let A=M+1;A<a.length;A++){const B=yt(f(a[A],S));for(const P of w)for(const E of B)be(P.a,P.b,E.a,E.b,ct)&&p++}}return p},"strictCrossingCount"),y=i((S=new Map)=>a.reduce((p,M)=>p+ae(f(M,S)),0),"totalBends"),l=i(S=>{const p=S.start,M=S.end,w=p?e.get(p):void 0,A=M?e.get(M):void 0,B=w?Qt(w):void 0,P=A?Qt(A):void 0;return B&&P?{src:B,dst:P}:void 0},"endpointRectsFor"),I=i((S,p,M)=>{if(M.index<=0||M.index+1>=p.length-1)return;const w=l(S);if(w){if(M.vertical){const A=M.a.x,B=Math.min(w.src.left,w.dst.left),P=Math.max(w.src.right,w.dst.right),E=A<B-ct?"left":A>P+ct?"right":void 0;return E?{edge:S,points:p,segmentIndex:M.index,axis:"vertical",side:E,coord:A,min:Math.min(M.a.y,M.b.y),max:Math.max(M.a.y,M.b.y)}:void 0}if(M.horizontal){const A=M.a.y,B=Math.min(w.src.top,w.dst.top),P=Math.max(w.src.bottom,w.dst.bottom),E=A<B-ct?"top":A>P+ct?"bottom":void 0;return E?{edge:S,points:p,segmentIndex:M.index,axis:"horizontal",side:E,coord:A,min:Math.min(M.a.x,M.b.x),max:Math.max(M.a.x,M.b.x)}:void 0}}},"externalRailForSegment"),m=i(()=>{const S=[];for(const p of a){const M=f(p);for(const w of yt(M)){const A=I(p,M,w);A&&S.push(A)}}return S},"collectExternalRails"),x=i((S,p)=>S.edge!==p.edge&&S.axis===p.axis&&S.side===p.side&&ne(S.min,S.max,p.min,p.max)>=Vt,"railsInteract"),g=i(S=>{const p=[],M=new Set;for(const w of S){if(M.has(w))continue;const A=[w],B=[];for(M.add(w);A.length>0;){const P=A.pop();B.push(P);for(const E of S)!M.has(E)&&x(P,E)&&(M.add(E),A.push(E))}B.length>1&&p.push(B)}return p},"connectedComponents"),b=i(S=>{const p=[];for(const M of S)p.some(w=>Math.abs(w-M.coord)<ct)||p.push(M.coord);for(;p.length<S.length;){const M=Math.min(...p),w=Math.max(...p),A=S[0].side;p.push(A==="left"||A==="top"?M-12*(S.length-p.length):w+12*(S.length-p.length))}return p},"uniqueCoordsFor"),L=i(S=>{const p=S.map(A=>A.coord),M=b(S),w=[];if(S.length<=6){const A=new Array(M.length).fill(!1),B=[],P=i(()=>{if(B.length===S.length){B.some((E,k)=>Math.abs(E-p[k])>=ct)&&w.push([...B]);return}for(const[E,k]of M.entries())A[E]||(A[E]=!0,B.push(k),P(),B.pop(),A[E]=!1)},"visit");return P(),w}for(let A=0;A<p.length;A++)for(let B=A+1;B<p.length;B++){const P=[...p];[P[A],P[B]]=[P[B],P[A]],w.push(P)}return w},"coordinateAssignmentsFor"),u=i((S,p)=>{const M=new Map;for(const[A,B]of S.entries()){const P=p[A],E=M.get(B.edge)??B.points.map(k=>({x:k.x,y:k.y}));B.axis==="vertical"?(E[B.segmentIndex].x=P,E[B.segmentIndex+1].x=P):(E[B.segmentIndex].y=P,E[B.segmentIndex+1].y=P),M.set(B.edge,E)}const w=new Map;for(const[A,B]of M){const P=ge(It(B));if(yt(P).length!==P.length-1)return;w.set(A,P)}return w},"replacementsForAssignment"),C=i(S=>{for(const[p,M]of S){const w=[p.start,p.end].filter(A=>!!A);for(const A of yt(M))if(Ft(A.a,A.b,r,w,-2)||Ft(A.a,A.b,c,[],-2))return!1}for(let p=0;p<a.length;p++){const M=a[p],w=S.has(M),A=yt(f(M,S));for(let B=p+1;B<a.length;B++){const P=a[B];if(!w&&!S.has(P))continue;const E=yt(f(P,S));for(const k of A)for(const Y of E)if(ye(k,Y,.5)>=Vt)return!1}}return!0},"candidateIsSafe");for(let S=0;S<4;S++){const p=h();if(p===0)return;let M,w=p,A=y(),B=Number.POSITIVE_INFINITY;for(const P of g(m()))for(const E of L(P)){const k=u(P,E);if(!k||!C(k))continue;const Y=h(k);if(Y>=p)continue;const K=y(k),z=P.reduce((et,at,xt)=>et+Math.abs(E[xt]-at.coord),0);Y>w||Y===w&&(K>A||K===A&&z>=B)||(M=k,w=Y,A=K,B=z)}if(!M)return;for(const[P,E]of M)P.points=E}}i(Ws,"reassignCrossingExternalRailChannels");function Ks(t,e){const{realNodeRects:o,labelNodeRects:s}=xe(e.values()),r=t.filter(m=>!m.isLayoutOnly),c=i((m,x,g)=>It(m===x?g??[]:m.points??[]),"pointsFor"),a=i(m=>yt(m).reduce((x,g)=>{const b=g.a.x-g.b.x,L=g.a.y-g.b.y;return x+Math.hypot(b,L)},0),"pathLength"),f=i((m,x)=>{let g=0;for(let b=0;b<r.length;b++){const L=yt(c(r[b],m,x));for(let u=b+1;u<r.length;u++){const C=yt(c(r[u],m,x));for(const S of L)for(const p of C)be(S.a,S.b,p.a,p.b,ct)&&g++}}return g},"strictCrossingCount"),h=i((m,x)=>{if(m.horizontal){const g=m.a.y;return(Math.abs(g-x.top)<1||Math.abs(g-x.bottom)<1)&&ne(m.a.x,m.b.x,x.left,x.right)>=Vt}if(m.vertical){const g=m.a.x;return(Math.abs(g-x.left)<1||Math.abs(g-x.right)<1)&&ne(m.a.y,m.b.y,x.top,x.bottom)>=Vt}return!1},"segmentRunsAlongRectBorder"),y=i(m=>{const x=[m.start,m.end].filter(b=>!!b),g=[];for(const b of x){const L=e.get(b),u=L?Qt(L):void 0;u&&g.push(u)}return g},"endpointRectsFor"),l=i((m,x)=>{if(x+3>=m.length)return[];const g=m[x],b=m[x+1],L=m[x+2],u=m[x+3],C=Dt(g,b,ct)&&Xt(b,L,ct)&&Dt(L,u,ct),S=Xt(g,b,ct)&&Dt(b,L,ct)&&Xt(L,u,ct);if(!C&&!S)return[];if(!(C?Math.sign(b.x-g.x)!==Math.sign(u.x-L.x):Math.sign(b.y-g.y)!==Math.sign(u.y-L.y)))return[];const M=St(g,u,ct)||Ct(g,u,ct)?[]:[{x:g.x,y:u.y},{x:u.x,y:g.y}],w=M.length===0?[[...m.slice(0,x+1),...m.slice(x+3)]]:M.map(B=>[...m.slice(0,x+1),B,...m.slice(x+3)]),A=new Set;return w.map(B=>ge(It(B))).filter(B=>{if(yt(B).length!==B.length-1||!B.some(E=>ue(E,u,ct)))return!1;const P=B.map(E=>`${E.x.toFixed(3)},${E.y.toFixed(3)}`).join("|");return A.has(P)?!1:(A.add(P),!0)})},"shortcutCandidatesAt"),I=i((m,x,g)=>{const b=[m.start,m.end].filter(u=>!!u),L=y(m);for(const u of yt(x))if(Ft(u.a,u.b,o,b,-2)||Ft(u.a,u.b,s,[],-2)||L.some(C=>h(u,C)))return!1;for(const u of r)if(u!==m){for(const C of yt(x))for(const S of yt(c(u)))if(ye(C,S,.5)>=Vt)return!1}return f(m,x)<=g},"candidateIsSafe");for(let m=0;m<8;m++){const x=f();let g,b,L=x,u=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY;for(const S of r){const p=c(S),M=ae(p,ct),w=a(p);for(let A=0;A<=p.length-4;A++)for(const B of l(p,A)){const P=ae(B,ct),E=a(B);if(!(P<M||P===M&&E<w-ct)||!I(S,B,x))continue;const Y=f(S,B);Y>L||Y===L&&(P>u||P===u&&E>=C)||(g=S,b=B,L=Y,u=P,C=E)}}if(!g||!b)return;g.points=b}}i(Ks,"shortcutRedundantOrthogonalJogs");function qs(t,e){const c=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const F=N.x??0,D=N.y??0,j=Qt(N);j&&c.push({id:String(N.id??""),cx:F,cy:D,rect:j})}if(c.length===0)return;const a=new Map(c.map(N=>[N.id,N])),f=c.map(N=>({id:N.id,rect:N.rect})),h=["top","bottom","left","right"],y={top:Math.min(...c.map(N=>N.rect.top))-20,bottom:Math.max(...c.map(N=>N.rect.bottom))+20,left:Math.min(...c.map(N=>N.rect.left))-20,right:Math.max(...c.map(N=>N.rect.right))+20},l=t.filter(N=>!N.isLayoutOnly),I=new Map(l.map((N,F)=>[N,F])),m=i(N=>{const F=N==="left"||N==="top"?-1:1,D=[];for(let j=0;j<=2;j++)D.push(y[N]+F*20*j);return D},"outwardTracksForSide"),x=i((N,F=new Map)=>It(F.get(N)??N.points??[]),"replacementPointsFor"),g=i((N,F)=>{let D=0;for(const j of N)for(const q of F)be(j.a,j.b,q.a,q.b,ct)&&D++;return D},"crossingCountBetweenSegments"),b=i((N,F)=>g(yt(N),yt(F)),"crossingCountBetweenPaths"),L=i((N=new Map)=>{let F=0;const D=[],j=new Set,q=[],nt=i(G=>{j.has(G)||(j.add(G),q.push(G))},"addEdge");for(let G=0;G<l.length;G++){const ot=l[G],dt=x(ot,N);for(let d=G+1;d<l.length;d++){const v=l[d],T=b(dt,x(v,N));T>0&&(F+=T,D.push({first:ot,second:v,count:T}),nt(ot),nt(v))}}return q.sort((G,ot)=>(I.get(G)??0)-(I.get(ot)??0)),{count:F,pairs:D,edgeSet:j,edges:q}},"crossingSnapshot"),u=i((N,F)=>{const D=new Set(F.keys());if(D.size===0)return N.count;let j=0;for(const nt of N.pairs)(D.has(nt.first)||D.has(nt.second))&&(j+=nt.count);let q=0;for(let nt=0;nt<l.length;nt++){const G=l[nt],ot=D.has(G),dt=x(G,F);for(let d=nt+1;d<l.length;d++){const v=l[d];!ot&&!D.has(v)||(q+=b(dt,x(v,F)))}}return N.count-j+q},"crossingCountWithReplacements"),C=i(N=>{const F=new Map;for(const q of N.pairs){const nt=F.get(q.first)??new Set;nt.add(q.second),F.set(q.first,nt);const G=F.get(q.second)??new Set;G.add(q.first),F.set(q.second,G)}const D=[],j=new Set;for(const q of N.edges){if(j.has(q))continue;const nt=[q],G=[];for(j.add(q);nt.length>0;){const ot=nt.pop();G.push(ot);for(const dt of F.get(ot)??[])j.has(dt)||(j.add(dt),nt.push(dt))}G.sort((ot,dt)=>(I.get(ot)??0)-(I.get(dt)??0)),G.length>1&&D.push(G)}return D},"crossingComponents"),S=i(N=>[N.start,N.end].filter(F=>!!F),"endpointIdsFor"),p=i(N=>{const F=[];for(const D of C(N)){const j=new Set(D),q=new Set(D.flatMap(G=>S(G))),nt=[...D];for(const G of l)j.has(G)||S(G).some(ot=>q.has(ot))&&nt.push(G);nt.sort((G,ot)=>(I.get(G)??0)-(I.get(ot)??0)),F.push(nt)}return F},"pairSearchGroups"),M=i((N,F,D)=>u(N,new Map([[F,D]])),"crossingCountWithSingleReplacement"),w=i(N=>{const F=new Map;for(const D of N.pairs)F.set(D.first,(F.get(D.first)??0)+D.count),F.set(D.second,(F.get(D.second)??0)+D.count);return F},"currentCrossingsByEdge"),A=i(N=>N.slice(1).reduce((F,D,j)=>{const q=N[j];return F+Math.abs(D.x-q.x)+Math.abs(D.y-q.y)},0),"pathLength"),B=i((N=new Map)=>l.reduce((F,D)=>F+ae(x(D,N)),0),"totalBends"),P=i((N=new Map)=>l.reduce((F,D)=>F+A(x(D,N)),0),"totalLength"),E=i((N,F)=>an(N,F,Po.ROUTE_TOUCH_TOLERANCE),"touchesAtBend"),k=i((N,F,D=new Map)=>{const j=yt(F);for(const q of l)if(q!==N){for(const nt of j)for(const G of yt(x(q,D)))if(ye(nt,G,.5)>=Vt)return!0;if(E(F,x(q,D)))return!0}return!1},"pathHasSegmentConflict"),Y=i((N,F)=>{const D=[N.start,N.end].filter(j=>!!j);for(const j of yt(F))if(Ft(j.a,j.b,f,D,-2))return!0;return!1},"pathHitsNode"),K=i((N,F)=>{const D=ge(It(F));yt(D).length===D.length-1&&N.push(D)},"pushOrthogonalCandidate"),z=i(N=>N==="left"||N==="right","sideIsHorizontal"),et=i((N,F,D)=>{switch(F){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"),at=i((N,F,D,j)=>{const q=D==="left"||D==="top"?-1:1,nt=[et(F,D,j),y[D]];for(const G of nt)for(let ot=0;ot<=2;ot++)K(N,wo(F,D,j,G+q*20*ot))},"addSameSideCandidates"),xt=i((N,F,D,j,q)=>{for(const nt of m(D))for(const G of m(q))K(N,[F,{x:nt,y:F.y},{x:nt,y:G},{x:j.x,y:G},j])},"addHorizontalToVerticalCandidates"),Kt=i((N,F,D,j,q)=>{for(const nt of m(D))for(const G of m(q))K(N,[F,{x:F.x,y:nt},{x:G,y:nt},{x:G,y:j.y},j])},"addVerticalToHorizontalCandidates"),Ut=i((N,F,D,j,q)=>{const nt=[...m("top"),...m("bottom")];for(const G of m(D))for(const ot of m(q))for(const dt of nt)K(N,[F,{x:G,y:F.y},{x:G,y:dt},{x:ot,y:dt},{x:ot,y:j.y},j])},"addHorizontalPairCandidates"),jt=i((N,F,D,j,q)=>{const nt=[...m("left"),...m("right")];for(const G of m(D))for(const ot of m(q))for(const dt of nt)K(N,[F,{x:F.x,y:G},{x:dt,y:G},{x:dt,y:ot},{x:j.x,y:ot},j])},"addVerticalPairCandidates"),Q=i(N=>{const F=new Set;return N.map(D=>It(D)).filter(D=>{const j=D.map(q=>`${q.x.toFixed(3)},${q.y.toFixed(3)}`).join("|");return F.has(j)||D.length<2?!1:(F.add(j),!0)})},"dedupeCandidatePaths"),ft=i((N,F,D,j)=>{const q=[],nt=Lo(N,F,D,j,20,ct);nt&&K(q,nt),F===j&&at(q,N,F,D);const G=z(F),ot=z(j);return G&&!ot?xt(q,N,F,D,j):!G&&ot?Kt(q,N,F,D,j):G?Ut(q,N,F,D,j):jt(q,N,F,D,j),Q(q)},"buildCandidatesForSides"),_=i((N,F,D,j)=>{const q=[...m("left"),...m("right")],nt=[...m("top"),...m("bottom")];for(const G of h){const ot=Pe(j,G),dt=G==="top"||G==="bottom"?m(G):nt;for(const d of q){z(G)&&K(N,[F,D,{x:d,y:D.y},{x:d,y:ot.y},ot]);for(const v of dt)K(N,[F,D,{x:d,y:D.y},{x:d,y:v},{x:ot.x,y:v},ot])}}},"addVerticalDepartureOuterTrackCandidates"),$=i((N,F,D,j)=>{const q=[...m("left"),...m("right")],nt=[...m("top"),...m("bottom")];for(const G of h){const ot=Pe(j,G),dt=G==="left"||G==="right"?m(G):q;for(const d of nt){z(G)||K(N,[F,D,{x:D.x,y:d},{x:ot.x,y:d},ot]);for(const v of dt)K(N,[F,D,{x:D.x,y:d},{x:v,y:d},{x:v,y:ot.y},ot])}}},"addHorizontalDepartureOuterTrackCandidates"),tt=i(N=>{const F=N.start,D=N.end,j=D?a.get(D):void 0;if(!F||!j)return[];const q=It(N.points??[]);if(q.length<4)return[];const nt=q[0],G=q[1],ot=[];return Xt(nt,G,ct)?_(ot,nt,G,j):Dt(nt,G,ct)&&$(ot,nt,G,j),ot},"terminalPreservingOuterTrackCandidates"),Z=i(N=>{const F=N.start,D=N.end,j=F?a.get(F):void 0,q=D?a.get(D):void 0;if(!j||!q)return[];const nt=[];for(const G of h){const ot=Pe(j,G);for(const dt of h)nt.push(...ft(ot,G,Pe(q,dt),dt))}return nt.push(...tt(N)),nt},"candidatePathsFor"),rt=i(()=>new Map(l.map(N=>[N,yt(x(N))])),"currentSegmentsByEdge"),ut=i((N,F,D,j)=>{const q=new Set;for(const nt of l){if(nt===N)continue;const G=j.get(nt)??yt(x(nt));(D.some(ot=>G.some(dt=>ye(ot,dt,.5)>=Vt))||E(F,x(nt)))&&q.add(nt)}return q},"sharedTrackConflictsFor"),gt=i((N,F,D,j)=>{const q=new Set;return Z(N).map(G=>ge(It(G))).filter(G=>{if(Y(N,G))return!1;const ot=G.map(dt=>`${dt.x.toFixed(3)},${dt.y.toFixed(3)}`).join("|");return q.has(ot)||G.length<2?!1:(q.add(ot),!0)}).map(G=>{const ot=yt(G);let dt=0;for(const d of l)d!==N&&(dt+=g(ot,D.get(d)??yt(x(d))));return{candidate:G,candidateSegments:ot,crossings:F.count-(j.get(N)??0)+dt,bends:ae(G,ct),totalBends:ae(G),length:A(G)}}).filter(({crossings:G})=>G<=F.count).sort((G,ot)=>G.crossings-ot.crossings||G.bends-ot.bends||G.length-ot.length).slice(0,48).map(G=>({path:G.candidate,segments:G.candidateSegments,sharedTrackConflicts:ut(N,G.candidate,G.candidateSegments,D),totalBends:G.totalBends,length:G.length}))},"pairCandidatesFor"),pt=i((N,F,D,j,q,nt)=>{let G=0;for(const dt of N.pairs)(dt.first===F||dt.second===F||dt.first===j||dt.second===j)&&(G+=dt.count);let ot=g(D.segments,q.segments);for(const dt of l){if(dt===F||dt===j)continue;const d=nt.get(dt)??yt(x(dt));ot+=g(D.segments,d)+g(q.segments,d)}return N.count-G+ot},"pairCrossingCount"),bt=i((N,F)=>{for(const D of N.sharedTrackConflicts)if(D!==F)return!1;return!0},"conflictsOnlyWith"),Pt=i((N,F)=>N.segments.some(D=>F.segments.some(j=>ye(D,j,.5)>=Vt))||E(N.path,F.path),"candidatesShareTrack"),Te=i((N,F,D,j)=>bt(F,D.edge)&&bt(j,N.edge)&&!Pt(F,j),"pairCandidatesAreCompatible"),Ie=i((N,F,D,j,q)=>{const nt=pt(N.current,F.edge,D,j.edge,q,N.baseSegments);if(!(nt>=N.current.count))return{replacements:new Map([[F.edge,D.path],[j.edge,q.path]]),crossings:nt,bends:N.currentBends-(N.baseBendsByEdge.get(F.edge)??0)-(N.baseBendsByEdge.get(j.edge)??0)+D.totalBends+q.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(F.edge)??0)-(N.baseLengthByEdge.get(j.edge)??0)+D.length+q.length}},"scorePairReplacement"),Me=i((N,F)=>N.crossings<F.crossings||N.crossings===F.crossings&&(N.bends<F.bends||N.bends===F.bends&&N.length<F.length),"pairScoreIsBetter"),Re=i((N,F,D,j)=>{let q=j;for(const nt of F.candidates)for(const G of D.candidates){if(!Te(F,nt,D,G))continue;const ot=Ie(N,F,nt,D,G);ot&&Me(ot,q)&&(q=ot)}return q},"bestScoreForOptionPair"),We=i(N=>{const F=B(),D=P(),j=rt(),q=w(N),nt=new Map(l.map(T=>[T,ae(x(T))])),G=new Map(l.map(T=>[T,A(x(T))])),ot=new Map,dt=p(N);for(const T of dt)for(const R of T){if(ot.has(R))continue;const O=gt(R,N,j,q);O.length>0&&ot.set(R,{edge:R,candidates:O})}let d={replacements:new Map,crossings:N.count,bends:F,length:D};const v={current:N,currentBends:F,currentLength:D,baseBendsByEdge:nt,baseLengthByEdge:G,baseSegments:j};for(const T of dt){const R=new Set(T.filter(H=>N.edgeSet.has(H))),O=T.map(H=>ot.get(H)).filter(H=>!!H);for(let H=0;H<O.length;H++){const J=O[H];for(let lt=H+1;lt<O.length;lt++){const W=O[lt];!R.has(J.edge)&&!R.has(W.edge)||(d=Re(v,J,W,d))}}}return d.replacements.size>0?d.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const F=L(),D=F.count;if(D===0)return;let j,q,nt=D,G=Number.POSITIVE_INFINITY;for(const dt of F.edges){const d=ae(x(dt),ct);for(const v of Z(dt)){const T=Y(dt,v),R=!T&&k(dt,v),O=M(F,dt,v),H=ae(v,ct);T||R||!(O<D||O===D&&H<d)||O>nt||O===nt&&H>=G||(j=dt,q=v,nt=O,G=H)}}if(j&&q){j.points=q;continue}const ot=We(F);if(!ot)return;for(const[dt,d]of ot)dt.points=d}}i(qs,"resolveRenderedOrthogonalCrossings");var Ae=.001,Pi=8;function Zs(t,e){const{nodeInfoById:n,realNodeRects:o}=Sn(e),s=["top","bottom","left","right"],r=20,c={top:Math.min(...o.map(g=>g.rect.top))-r,bottom:Math.max(...o.map(g=>g.rect.bottom))+r,left:Math.min(...o.map(g=>g.rect.left))-r,right:Math.max(...o.map(g=>g.rect.right))+r},a=i((g,b,L,u)=>{const C=[],S=Lo(g,b,L,u,r,Ae);return S&&C.push(S),b===u&&C.push(wo(g,b,L,c[b])),C},"buildOrthogonalPathCandidates"),f=i((g,b)=>{for(let L=0;L<g.length-1;L++){const u=g[L],C=g[L+1];if(Ft(u,C,o,b,1))return!0}return!1},"pathHitsNode"),h=i((g,b,L=!1)=>{let u=0;const C=le(g,Ae),S=b.start,p=b.end;for(const M of t){if(M===b||M.isLayoutOnly)continue;const w=M.start,A=M.end;if(!L&&S&&p&&(w===S||w===p||A===S||A===p))continue;const B=M.points;if(!(!B||B.length<2))for(const P of C)for(const E of le(B,Ae)){if(Eo(P.a,P.b,E.a,E.b,Ae,Ae)){u++;continue}ye(P,E,Ae)>=Pi&&u++}}return u},"pathConflictCount"),y=4,l=i((g,b)=>{const L=Math.abs(g.y-b.rect.top),u=Math.abs(g.y-b.rect.bottom),C=Math.abs(g.x-b.rect.left),S=Math.abs(g.x-b.rect.right);let p="top",M=L;return u<M&&(p="bottom",M=u),C<M&&(p="left",M=C),S<M&&(p="right",M=S),p},"nearestSideOfRect"),I=new Map,m=i((g,b,L)=>{const u=I.get(g)??[];u.push({side:b,edgeId:L}),I.set(g,u)},"addFaceClaim");for(const g of t){if(g.isLayoutOnly)continue;const b=g.points??[];if(b.length<1)continue;const L=g.id??"",u=g.start,C=g.end;if(u){const S=n.get(u);S&&m(u,l(b[0],S),L)}if(C){const S=n.get(C);S&&m(C,l(b[b.length-1],S),L)}}const x=i((g,b,L)=>I.get(g)?.some(u=>u.edgeId!==L&&u.side===b)??!1,"faceIsClaimed");for(const g of t){if(g.isLayoutOnly)continue;const b=g.points;if(!b||b.length<2)continue;const L=ae(b,Ae);if(L<y)continue;const u=g.start,C=g.end;if(!u||!C)continue;const S=n.get(u),p=n.get(C);if(!S||!p)continue;const M=g.id??"",w=h(b,g,!0),A=h(b,g);let B,P=w,E=L;for(const k of s){if(x(u,k,M))continue;const Y=Pe(S,k);for(const K of s){if(x(C,K,M))continue;const z=Pe(p,K);for(const et of a(Y,k,z,K)){if(f(et,[u,C]))continue;const at=ae(et,Ae);if(w>0){const xt=h(et,g,!0);if(xt>P||xt===P&&at>=E)continue;P=xt,E=at,B=et;continue}h(et,g)>A||at<E&&(E=at,B=et)}}}if(B){g.points=B;const k=I.get(u);k&&I.set(u,k.filter(K=>K.edgeId!==M));const Y=I.get(C);Y&&I.set(C,Y.filter(K=>K.edgeId!==M)),m(u,l(B[0],S),M),m(C,l(B[B.length-1],p),M)}}}i(Zs,"simplifyDetouredEdges");var re=.001,qo=10,nn=7;function oo(t,e){const n=e?0:t.length-1,o=e?1:-1,s=t[n],r=t[n+o];if(!s||!r)return;const c=r.x-s.x,a=r.y-s.y;if(!(Math.abs(c)+Math.abs(a)<re)){if(Math.abs(a)<=re){const h=s.x+Math.sign(c)*qo;return{left:Math.min(s.x,h),right:Math.max(s.x,h),top:s.y-nn,bottom:s.y+nn}}if(Math.abs(c)<=re){const h=s.y+Math.sign(a)*qo;return{left:s.x-nn,right:s.x+nn,top:Math.min(s.y,h),bottom:Math.max(s.y,h)}}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)}}}i(oo,"markerClearanceRectFor");function Js(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)}}i(Js,"normalizeRect");function so(t,e){const n=It(e),o=oo(n,!0),s=oo(n,!1);return[o,s].some(r=>r&&ln(t,Js(r)))}i(so,"labelOverlapsOwnMarker");function Ye(t,e){const n=[];for(const g of t){if(g.isLayoutOnly)continue;const b=g.points;if(!(!b||b.length<2))for(let L=0;L<b.length-1;L++)n.push({edgeId:g.id,p1:b[L],p2:b[L+1]})}const o=[],s=[],r=pe([...e.values()]);for(const g of e.values()){const b=g.isGroup;if(r.isLane(g.id)){const u=Qt(g);u&&s.push({id:g.id,rect:u});continue}if(b||g.isEdgeLabel)continue;const L=Qt(g);L&&o.push({nodeId:g.id,rect:L})}const c=3,a=1,f=12,h=i((g,b)=>{const L=Xn(b,c);for(const{nodeId:u,rect:C}of o)if(u!==g&&ln(L,C))return!0;return!1},"labelOverlapsForeignNode"),y=i((g,b)=>{const L=Xn(b,c);for(const u of n)if(u.edgeId!==g&&Mn(u.p1,u.p2,L))return!0;return!1},"labelOverlapsForeignEdge"),l=i((g,b,L)=>h(g,L)||y(b,L),"labelOverlapsAnything"),I=[],m=i(g=>{for(const{id:b,rect:L}of s)if(vs(L,g))return b},"findContainingLane"),x=i((g,b)=>I.some(L=>L.labelId!==g&&ln(b,L.rect)),"overlapsPlacedLabel");for(const g of t){if(g.isLayoutOnly)continue;const b=g.labelNodeId;if(!b)continue;const L=e.get(b);if(!L)continue;const u=g.points;if(!u||u.length<2)continue;const C=L.width??0,S=L.height??0;if(C<=0||S<=0)continue;const p=[];for(let Q=0;Q<u.length-1;Q++){const ft=u[Q],_=u[Q+1],$=Math.abs(ft.x-_.x),tt=Math.abs(ft.y-_.y);$<re&&tt<re||$>=re&&tt>=re||p.push({idx:Q,length:$+tt,orientation:$>=re?"horizontal":"vertical",midX:(ft.x+_.x)/2,midY:(ft.y+_.y)/2})}if(p.length===0)continue;const M=p.length>=3?p.filter(Q=>Q.idx>0&&Q.idx<p.length-1):p,w=M.length>0?M:p,A=C>=S?"horizontal":"vertical",B=i(Q=>[...Q].sort((ft,_)=>{const $=ft.orientation===A,tt=_.orientation===A;if($!==tt)return $?-1:1;const Z=ft.length>=(ft.orientation==="horizontal"?C:S)+2,rt=_.length>=(_.orientation==="horizontal"?C:S)+2;return Z!==rt?Z?-1:1:_.length-ft.length}),"rankSegments"),P=p[0],E=p[p.length-1],k=[.5,.25,.75,.05,.95,.15,.85,.1,.9],Y=i((Q,ft)=>{const _=u[Q.idx],$=u[Q.idx+1];return{midX:_.x+($.x-_.x)*ft,midY:_.y+($.y-_.y)*ft}},"anchorAtT"),K=i((Q,ft,_)=>Math.min(_,Math.max(ft,Q)),"clamp"),z=i((Q,ft)=>Q.midX>=ft.left-re&&Q.midX<=ft.right+re&&Q.midY>=ft.top-re&&Q.midY<=ft.bottom+re,"pointInsideRectInclusive"),et=i(Q=>{const ft=De(Q.midX,Q.midY,C,S),_=m(ft);if(_)return{laneId:_,anchor:Q,rect:ft};const $=s.find(({rect:bt})=>z(Q,bt));if(!$)return;const tt=$.rect.left+C/2+a,Z=$.rect.right-C/2-a,rt=$.rect.top+S/2+a,ut=$.rect.bottom-S/2-a;if(tt>Z||rt>ut)return;const gt={midX:K(Q.midX,tt,Z),midY:K(Q.midY,rt,ut)},pt=De(gt.midX,gt.midY,C,S);return z(Q,pt)?{laneId:$.id,anchor:gt,rect:pt}:void 0},"placementForAnchor"),at=i((Q,ft,_)=>Q.orientation==="horizontal"?Math.abs(ft.midX-_.x):Math.abs(ft.midY-_.y),"distanceAlongSegment"),xt=i((Q,ft)=>{const $=(Q.orientation==="horizontal"?C/2:S/2)+f;if(Q===P){const tt=u[Q.idx];if(at(Q,ft,tt)+re<$)return!1}if(Q===E){const tt=u[Q.idx+1];if(at(Q,ft,tt)+re<$)return!1}return!0},"labelClearsTerminalEndpoints"),Kt=i(Q=>{const ft=B(Q);for(const _ of ft)for(const $ of k){const tt=Y(_,$);if(!xt(_,tt))continue;const Z=et(tt);if(Z&&!so(Z.rect,u)&&!x(b,Z.rect)&&!l(b,g.id,Z.rect))return{laneId:Z.laneId,anchor:Z.anchor}}},"tryPool"),Ut=i((Q,ft,_=!1)=>{const $=B(Q);for(const tt of $){const Z={midX:tt.midX,midY:tt.midY};if(ft&&!xt(tt,Z))continue;const rt=et(Z);if(rt&&!so(rt.rect,u)&&!x(b,rt.rect)&&!h(b,rt.rect)&&(_||!y(g.id,rt.rect)))return{laneId:rt.laneId,anchor:rt.anchor}}},"findLaneContainingFallback"),jt=Kt(w)??(w.length<p.length?Kt(p):void 0)??Ut(p,!0)??Ut(p,!1)??Ut(p,!1,!0);if(jt){L.x=jt.anchor.midX,L.y=jt.anchor.midY,L.parentId=jt.laneId;const Q=De(jt.anchor.midX,jt.anchor.midY,C,S),ft=I.findIndex(_=>_.labelId===b);ft>=0?I[ft]={labelId:b,rect:Q}:I.push({labelId:b,rect:Q})}}}i(Ye,"anchorLabelsToPolyline");var kn=1e-6,Fi=8,Zo=Fi/2,ki=3;function ro(t,e,n,{cx:o,cy:s},r,c){const a={x:o,y:s},f=c==="x"?"y":"x",h=Math.sign(r[f]-a[f]);for(const y of t){if(y===e||y.isLayoutOnly||!y.points?.length)continue;if([...y.end===n?[y.points.at(-1)]:[],...y.start===n?[y.points[0]]:[]].some(I=>Math.sign(I[f]-a[f])===h&&Math.abs(I[c]-r[c])<Po.MIN_ARROWHEAD_SPACING))return!0}return!1}i(ro,"crowdsFaceNeighbour");function io(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}i(io,"pairKey");function Qs(t,e){const{nodeInfoById:n,realNodeRects:o}=Sn(e),s=new Map;for(const c of e){const a=c.id;if(!c.isGroup&&c.isEdgeLabel){s.set(a,{w:c.width??0,h:c.height??0});continue}}const r=i((c,a,f,h)=>{const y=io(a,f);let l=0;const I=i(m=>{if(!m)return;const x=s.get(m);if(!x)return;const g=h==="x"?x.w/2:x.h/2;g>l&&(l=g)},"consider");I(c.labelNodeId);for(const m of t){if(m===c||m.isLayoutOnly)continue;const x=m.start,g=m.end;!x||!g||io(x,g)===y&&I(m.labelNodeId)}return l>0?l+ki:0},"labelClearanceFor");for(const c of t){if(c.isLayoutOnly)continue;const a=c.points;if(!vo(a,kn))continue;const f=Ao(c,n,kn);if(!f)continue;const{srcId:h,dstId:y,srcInfo:l,dstInfo:I,collinearX:m,collinearY:x}=f;if(m===x)continue;let g,b;if(m){const M=I.cy>l.cy;g={x:l.cx,y:M?l.rect.bottom:l.rect.top},b={x:I.cx,y:M?I.rect.top:I.rect.bottom}}else{const M=I.cx>l.cx;g={x:M?l.rect.right:l.rect.left,y:l.cy},b={x:M?I.rect.left:I.rect.right,y:I.cy}}if(Ft(g,b,o,[h,y],1))continue;const L=m?"x":"y",u=r(c,h,y,L),C=u>Zo?u:Zo,S=[0,C,-C];let p;for(const M of S){const w={...g},A={...b};if(m){if(w.x+=M,A.x+=M,w.x<=l.rect.left||w.x>=l.rect.right||A.x<=I.rect.left||A.x>=I.rect.right)continue}else if(w.y+=M,A.y+=M,w.y<=l.rect.top||w.y>=l.rect.bottom||A.y<=I.rect.top||A.y>=I.rect.bottom)continue;if(Ft(w,A,o,[h,y],1)||fn(w,A,t,c,{epsilon:kn}))continue;const B=[w,A];if(ro(t,c,h,l,w,L)||ro(t,c,y,I,A,L)){p??=B;continue}c.points=B,p=void 0;break}p&&(c.points=p)}}i(Qs,"straightenCollinearSiblingDetours");function co(t,e){const{realNodeRects:f,labelNodeRects:h}=xe(e.values()),y=i((p,M)=>le(M,.001).map(w=>({...w,edge:p,interior:w.index>=1&&w.index<=M.length-3})),"segmentsFor"),l=i(()=>{const p=[];for(const M of t){if(M.isLayoutOnly)continue;const w=M.points;!w||w.length<2||p.push(...y(M,It(w)))}return p},"allSegments"),I=i((p,M)=>p.horizontal&&M.horizontal?ne(p.a.x,p.b.x,M.a.x,M.b.x)>=8&&Math.abs(p.a.y-M.a.y)<7:p.vertical&&M.vertical?ne(p.a.y,p.b.y,M.a.y,M.b.y)>=8&&Math.abs(p.a.x-M.a.x)<7:!1,"hasCrowdedParallelTrack"),m=i((p,M)=>{const w=p.start,A=p.end,B=y(p,M);if(B.length!==M.length-1)return!1;const P=[w,A].filter(k=>!!k),E=p.labelNodeId?[p.labelNodeId]:[];for(const k of B)if(Ft(k.a,k.b,f,P,-2)||Ft(k.a,k.b,h,E,-2))return!1;for(const k of t){if(k===p||k.isLayoutOnly)continue;const Y=k.points;if(!(!Y||Y.length<2)){for(const K of B)for(const z of y(k,It(Y)))if(I(K,z)||be(K.a,K.b,z.a,z.b,.001))return!1}}return!0},"candidateIsSafe"),x=i((p,M)=>{const w=It(p.edge.points??[]);if(w.length<4||p.index>=w.length-1)return;const A=w.map(B=>({...B}));if(p.horizontal)A[p.index].y+=M,A[p.index+1].y+=M;else if(p.vertical)A[p.index].x+=M,A[p.index+1].x+=M;else return;return y(p.edge,A).length===A.length-1?A:void 0},"shiftedCandidate"),g=i((p,M)=>({x:p.x??(M.left+M.right)/2,y:p.y??(M.top+M.bottom)/2}),"nodeCenter"),b=i(p=>{const M=p.edge,w=It(M.points??[]);if(w.length!==4||p.index!==1)return;const A=M.start?e.get(M.start):void 0,B=M.end?e.get(M.end):void 0,P=A?Qt(A):void 0,E=B?Qt(B):void 0,k=w.slice(p.index+2);if(!(!A||!B||!P||!E||k.length===0))return{sourceCenter:g(A,P),targetCenter:g(B,E),sourceRect:P,tail:k}},"sourceDetourContextFor"),L=i((p,M,w,A,B,P)=>{const E=A.y>=w.y,k=E?B.bottom:B.top,Y=k+(E?20:-20);if(E&&p.b.y<=Y+.001||!E&&p.b.y>=Y-.001)return;const K=p.a.x+M;return It([{x:w.x,y:k},{x:w.x,y:Y},{x:K,y:Y},{x:K,y:p.b.y},...P],.001)},"verticalSourceDetour"),u=i((p,M,w,A,B,P)=>{const E=A.x>=w.x,k=E?B.right:B.left,Y=k+(E?20:-20);if(E&&p.b.x<=Y+.001||!E&&p.b.x>=Y-.001)return;const K=p.a.y+M;return It([{x:k,y:w.y},{x:Y,y:w.y},{x:Y,y:K},{x:p.b.x,y:K},...P],.001)},"horizontalSourceDetour"),C=i((p,M)=>{const w=b(p);if(w){if(p.vertical)return L(p,M,w.sourceCenter,w.targetCenter,w.sourceRect,w.tail);if(p.horizontal)return u(p,M,w.sourceCenter,w.targetCenter,w.sourceRect,w.tail)}},"sourceDetourCandidate"),S=[-7,7,-14,14,-21,21];for(let p=0;p<12;p++){const M=l();let w=!1;for(let A=0;A<M.length&&!w;A++)for(let B=A+1;B<M.length&&!w;B++){const P=M[A],E=M[B];if(P.edge===E.edge||!I(P,E))continue;const k=[P,E].filter(Y=>Y.interior);for(const Y of k){for(const K of S){const z=x(Y,K);if(z&&m(Y.edge,z)){Y.edge.points=z,w=!0;break}const et=C(Y,K);if(et&&m(Y.edge,et)){Y.edge.points=et,w=!0;break}}if(w)break}}if(!w)return}}i(co,"nudgeSharedInteriorSubpaths");var kt=.001,Jo=2,vn=i(t=>t==="top"||t==="bottom"?"x":"y","runsAlongFace");function tr(t,e,n){const o=vn(n),[s,r]=o==="x"?[e.left,e.right]:[e.top,e.bottom];return{top:e.top-t.y,bottom:t.y-e.bottom,left:e.left-t.x,right:t.x-e.right}[n]>-kt&&t[o]>=s-kt&&t[o]<=r+kt}i(tr,"endpointThroughFace");function xn(t,e,n){const o=t.node.id;return n.every(s=>{if(s===e||s.isLayoutOnly)return!0;const r=s.points??[];return[[s.start,r.at(0)],[s.end,r.at(-1)]].every(([a,f])=>a!==o||!f||!tr(f,t.rect,t.side))})}i(xn,"faceIsOwn");function ao(t,e){const n=le(e,kt);return le(t,kt).reduce((o,s)=>o+n.filter(r=>be(s.a,s.b,r.a,r.b,kt)).length,0)}i(ao,"strictCrossings");function er(t,e){const n=le(e,kt);return le(t,kt).some(o=>n.some(s=>To(o.a,o.b,s.a,s.b,kt)))}i(er,"overlapsAny");function Fo(t,e,n,o){const s=Po.ROUTE_TOUCH_TOLERANCE;return o.every(r=>{const c=It(r.points??[],kt);return r===t||r.isLayoutOnly||c.length<2?!0:!er(n,c)&&ao(n,c)<=ao(e,c)&&(!an(n,c,s)||an(e,c,s))})}i(Fo,"clearOfOtherEdges");function ko(t,e,n){const o=t.labelNodeId,s=[t.start,t.end].filter(c=>!!c),r=le(e,kt);return r.every(c=>{const f=c.index===0||c.index===r.length-1?s:[];return!Ft(c.a,c.b,n.realNodeRects,f,Jo)&&!Ft(c.a,c.b,n.labelNodeRects,o?[o]:[],Jo)})}i(ko,"clearOfNodes");var Qo=1;function lo(t){const e=t&&!t.isGroup?Qt(t):void 0;return t&&e?{node:t,rect:e,cx:t.x??0,cy:t.y??0}:void 0}i(lo,"placed");function nr(t,e){const n=e.rect.top>t.rect.bottom;if(!n&&e.rect.bottom>=t.rect.top)return;const[o,s]=n?["bottom","top"]:["top","bottom"];return{from:{node:t.node,rect:t.rect,side:o},to:{node:e.node,rect:e.rect,side:s},points:[{x:t.cx,y:n?t.rect.bottom:t.rect.top},{x:t.cx,y:n?e.rect.top:e.rect.bottom}]}}i(nr,"verticalLine");function or(t,e){const n=e.rect.left>t.rect.right;if(!n&&e.rect.right>=t.rect.left)return;const[o,s]=n?["right","left"]:["left","right"];return{from:{node:t.node,rect:t.rect,side:o},to:{node:e.node,rect:e.rect,side:s},points:[{x:n?t.rect.right:t.rect.left,y:t.cy},{x:n?e.rect.left:e.rect.right,y:t.cy}]}}i(or,"horizontalLine");function sr(t,e){const n=lo(e.get(t.start??"")),o=lo(e.get(t.end??""));if(!(!n||!o||n.node===o.node))return n.node.parentId===o.node.parentId?void 0:[n,o]}i(sr,"crossGroupPair");function rr(t,e){const n=sr(t,e);if(!n)return;const[o,s]=n;return Math.abs(o.cx-s.cx)<=Qo?nr(o,s):Math.abs(o.cy-s.cy)<=Qo?or(o,s):void 0}i(rr,"straightLineFor");var _i=i((t,e)=>t.length===e.length&&t.every((n,o)=>Math.abs(n.x-e[o].x)<kt&&Math.abs(n.y-e[o].y)<kt),"isAlready");function ir(t,e,n,o,s){return xn(e.from,t,o)&&xn(e.to,t,o)&&ko(t,e.points,s)&&Fo(t,n,e.points,o)}i(ir,"lineIsClear");function cr(t,e,n,o){const s=rr(t,n),r=It(t.points??[],kt);return!s||r.length<2||_i(r,s.points)||!ir(t,s,r,e,o)?!1:(t.points=s.points,!0)}i(cr,"straighten");function ar(t,e){const n=xe(e.values());let o=!1;for(const s of t)!s.isLayoutOnly&&cr(s,t,e,n)&&(o=!0);return o}i(ar,"straightenAlignedCrossLaneEdges");var Hi=new Set(["question","diamond","diam","decision"]),Di=i(t=>Hi.has(t.shape??""),"isDiamond"),Ue=i((t,e)=>Math.abs(t-e)<kt,"near"),lr=i((t,e,n)=>t>=e-kt&&t<=n+kt,"within");function fr(t,e,n){if(!(!St(t,e,kt)||!lr(t.x,n.left,n.right)))return Ue(t.y,n.bottom)&&e.y>t.y?"bottom":Ue(t.y,n.top)&&e.y<t.y?"top":void 0}i(fr,"verticalLegFace");function dr(t,e,n){if(!(!Ct(t,e,kt)||!lr(t.y,n.top,n.bottom)))return Ue(t.x,n.right)&&e.x>t.x?"right":Ue(t.x,n.left)&&e.x<t.x?"left":void 0}i(dr,"horizontalLegFace");var Xi=i((t,e,n)=>fr(t,e,n)??dr(t,e,n),"faceOfLeg");function ur(t,e,n,o){const s=Xi(o[0],o[1],n);if(!s)return;const r=vn(s);return Ue(o[1][r],o[2][r])?void 0:{edge:t,node:e,rect:n,side:s,route:o}}i(ur,"terminalFrom");var Gi=i((t,e)=>(e?t.start:t.end)??"","endpointId");function hr(t,e,n){const o=It(t.points??[],kt),s=n.get(Gi(t,e)),r=s?Qt(s):void 0;if(!(!s||!r||o.length<3))return ur(t,s,r,e?o:o.reverse())}i(hr,"terminalAt");function gr({node:t,rect:e,side:n,route:o}){const s=vn(n),r=(s==="x"?t.x:t.y)??0,c=o[0][s];if(Math.abs(c-r)<kt)return;if(Di(t))return r;const[a,f]=s==="x"?[e.left,e.right]:[e.top,e.bottom];return Math.min(c-a,f-c)<=Yn+kt?r:void 0}i(gr,"alignedCoord");function pr(t,e,n,o){const s=gr(t);if(s===void 0||!xn(t,t.edge,e))return!1;const r=vn(t.side),[c,a,...f]=t.route,h=ge(It([{...c,[r]:s},{...a,[r]:s},...f],kt)),y=o?t.route:[...t.route].reverse(),l=o?h:[...h].reverse();return!ko(t.edge,l,n)||!Fo(t.edge,y,l,e)?!1:(t.edge.points=l,!0)}i(pr,"alignTerminal");function mr(t,e){const n=xe(e.values());let o=!1;for(const s of t)if(!s.isLayoutOnly)for(const r of[!0,!1]){const c=hr(s,r,e);c&&pr(c,t,n,r)&&(o=!0)}return o}i(mr,"alignTerminalLegsToPorts");function yr(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,c=o.x-n.x,a=o.y-n.y,f=s*a-r*c;if(Math.abs(f)<1e-10)return!1;const h=n.x-t.x,y=n.y-t.y,l=(h*a-y*c)/f,I=(h*r-y*s)/f,m=.01;return l>m&&l<1-m&&I>m&&I<1-m}i(yr,"segmentsIntersect");function xr(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Cs(e),r=[];for(const a of n){if(a.isLayoutOnly)continue;const f=a.points;if(!f||f.length<2)continue;const h=a.start,y=a.end,l=a.labelNodeId,I=a.id??`${h}->${y}`;for(const m of s)if(!(m.nodeId===h||m.nodeId===y)&&!(l&&m.nodeId===l)){for(let x=0;x<f.length-1;x++)if(Mn(f[x],f[x+1],m,-1)){o.push({type:"edge-node-overlap",edgeId:I,targetId:m.nodeId,detail:`segment ${x} passes through node "${m.nodeId}"`});break}}for(let m=0;m<f.length-1;m++)r.push({edgeId:I,start:h,end:y,p1:f[m],p2:f[m+1]})}const c=new Set;for(let a=0;a<r.length;a++)for(let f=a+1;f<r.length;f++){const h=r[a],y=r[f];if(h.edgeId!==y.edgeId&&!(h.start===y.start||h.start===y.end||h.end===y.start||h.end===y.end)&&yr(h.p1,h.p2,y.p1,y.p2)){const l=h.edgeId<y.edgeId?`${h.edgeId}|${y.edgeId}`:`${y.edgeId}|${h.edgeId}`;c.has(l)||(c.add(l),o.push({type:"edge-edge-crossing",edgeId:h.edgeId,targetId:y.edgeId,detail:`edges "${h.edgeId}" and "${y.edgeId}" cross`}))}}if(o.length>0){const a=o.filter(h=>h.type==="edge-node-overlap").length,f=o.filter(h=>h.type==="edge-edge-crossing").length;ze.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${a} edge-node overlap(s), ${f} edge crossing(s)`);for(const h of o)ze.warn(`[SWIMLANE_VALIDATE] ${h.type}: ${h.detail}`)}return o}i(xr,"validateSwimlanesLayout");function br(t,e){const n=ar(t,e);(mr(t,e)||n)&&(Ye(t,e),pn(t,e))}i(br,"alignTerminalLegsAndRefresh");function Ir(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(a=>!a.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!Ys(t,e)||e==="BT"&&s.length>0&&!_s(t))return;for(const a of o){if(a.isLayoutOnly)continue;const f=a.points;!f||f.length<2||(a.points=ge(dn(f)))}Zs(o,n),Qs(o,n),zs(o,n);const r=new Map;for(const a of n)r.set(String(a.id),a);Ye(o,r),Es(o,r),$s(o,r),co(o,r),Qn(o,r),Us(o,r),to(o,r),js(o,r);const c=i(()=>{qs(o,r),Qn(o,r),Ws(o,r),Ks(o,r),Ye(o,r),pn(o,r),to(o,r),Ye(o,r),pn(o,r)},"finalizeRenderedEdges");c(),co(o,r),c(),br(o,r),eo(o,r,e),no(o,r,e),eo(o,r,e),no(o,r,e)}i(Ir,"postProcessSwimlaneLayout");function Ee(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const c=`${r.id}:${r.src}->${r.dst}`;n.has(c)||(n.add(c),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}i(Ee,"normalizeGraph");function _o(t,e){return t.edges.filter(n=>n.dst===e)}i(_o,"incoming");function Mr(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}i(Mr,"buildSuccessorMap");function Ho(t){const e=Mr(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}i(Ho,"buildSortedSuccessorMap");function Cn(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}i(Cn,"buildInDegreeMap");function Do(t,e){const n=[...e.entries()].filter(([,a])=>a===0).map(([a])=>a).sort((a,f)=>a.localeCompare(f)),o=new Set(t.edges.flatMap(a=>[a.src,a.dst])),s=i(a=>!o.has(a)&&!t.nodeById.get(a)?.isGroup,"isUnconnected"),r=[...e.keys()].filter(a=>e.get(a)===0&&s(a));let c=0;return n.map(a=>s(a)?r[c++]:a)}i(Do,"sortedZeroInDegreeNodes");function Ln(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}}i(Ln,"buildPredecessorSuccessorMaps");function Xo(t,e,n,o){let s=0;for(const c of t.nodes)o?.skipGroups&&t.nodeById.get(c)?.isGroup||(s=Math.max(s,n[c]??0));const r=Array.from({length:s+1},()=>[]);for(const c of e)o?.skipGroups&&t.nodeById.get(c)?.isGroup||r[Math.max(0,n[c]??0)].push(c);return r}i(Xo,"buildLayersFromRanks");function je(t){const e=Cn(t),n=Do(t,e),o=[],s=Ho(t);for(;n.length;){const r=n.shift();o.push(r);for(const c of s.get(r)??[])if(e.set(c,(e.get(c)??0)-1),(e.get(c)??0)===0){let a=0;for(;a<n.length&&n[a]<c;)a++;n.splice(a,0,c)}}return o.length===t.nodes.length?o:null}i(je,"topoSortIfAcyclic");function Xe(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}i(Xe,"buildLayerIndex");function Go(t){const e=new Array(t.length),n=i((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let c=n(o,r)+n(r,s),a=o,f=r,h=o;for(;a<r||f<s;)f>=s||a<r&&t[a]<=t[f]?e[h++]=t[a++]:(e[h++]=t[f++],c+=r-a);for(let y=o;y<s;y++)t[y]=e[y];return c},"count");return n(0,t.length)}i(Go,"countInversions");function Sr(t){const e=Ee(t),n=new Map;for(const l of e.nodes)n.set(l,[]);for(const l of e.edges)n.get(l.src).push(l);for(const l of n.values())l.sort((I,m)=>I.dst===m.dst?I.id.localeCompare(m.id):I.dst.localeCompare(m.dst));const o=Object.create(null);for(const l of e.nodes)o[l]=0;const s=[],r=i(l=>{o[l]=1;for(const I of n.get(l)??[]){const m=I.dst;o[m]===0?r(m):o[m]===1&&s.push(I)}o[l]=2},"dfs"),c=Cn(e),a=[...e.nodes.filter(l=>(c.get(l)??0)===0),...e.nodes.filter(l=>(c.get(l)??0)!==0)];for(const l of a)o[l]===0&&r(l);const f=new Set(s.map(l=>`${l.id}:${l.src}->${l.dst}`)),h=e.edges.map(l=>f.has(`${l.id}:${l.src}->${l.dst}`)?{id:l.id,src:l.dst,dst:l.src,weight:l.weight,ref:l.ref}:l);return{acyclic:{nodes:[...e.nodes],edges:h,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}i(Sr,"removeCycles_DFS");function vr(t){const e=pe(t.layout.nodes??[]),n=new Map;for(const o of t.nodes)n.set(o,e.laneIdOf(o));return n}i(vr,"buildTopLaneMap");function Se(t){const e=vr(t);return n=>e.get(n)??null}i(Se,"createTopLaneResolver");function wn(t){const e=t.layout.nodes??[],n=pe(e),o=e.filter(c=>n.isLane(c.id)),s=o.filter(c=>sn(c)!==void 0);if(s.length>0&&s.length===o.length)return[...s].sort((c,a)=>(sn(c)??0)-(sn(a)??0)).map(c=>c.id);if(!n.hasPools)return[...new Set(o.map(c=>c.id))].reverse();const r=[];for(const c of e)c.parentId||(n.isPool(c.id)?r.push(...n.lanesByPool.get(c.id)??[]):n.isLane(c.id)&&r.push(c.id));return[...new Set(r)].reverse()}i(wn,"buildTopLaneOrder");function Yo(t,e){const n=wn(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const c of e)!o.has(c)||s.has(c)||(s.add(c),r.push(c));for(const c of n)s.has(c)||r.push(c);return r}i(Yo,"resolveTopLaneOrder");function Cr(t,e){const n=Ee(t),o=e?.laneOf??(()=>null),s=e?.rankHint,{preds:r}=Ln(n);for(const p of r.values())p.sort((M,w)=>M.localeCompare(w));const c=je(n)??[...n.nodes].sort((p,M)=>p.localeCompare(M)),a=new Map;for(const[p,M]of c.entries())a.set(M,p);const f=new Map,h=new Map;for(const p of n.nodes)h.set(p,[]);for(const p of c){const M=(r.get(p)??[]).filter(w=>f.has(w));if(M.length>0){const w=Lr(p,M,{laneOf:o,rankHint:s,topoIndex:a});f.set(p,w),h.get(w).push(p)}else f.has(p)||f.set(p,null)}for(const p of n.nodes)f.has(p)||f.set(p,null);const y=new Set;for(const p of n.nodes)(f.get(p)??null)===null&&y.add(p);const l=[...y].sort((p,M)=>{const w=a.get(p)??0,A=a.get(M)??0;return w===A?p.localeCompare(M):w-A}),I=wr(n),m=new Map;for(const[p,M]of I.entries())m.set(p,[...M].sort((w,A)=>w.localeCompare(A)));const x=Ar(m),g=Er(m),b=new Map;for(const p of n.nodes)b.set(p,[]);for(const p of g)for(const M of p.nodes){const w=b.get(M);w?w.push(p.id):b.set(M,[p.id])}const L=[],u=[],C=new Set,S=i(p=>{if(!C.has(p)){C.add(p),L.push(p);for(const M of h.get(p)??[])S(M);u.push(p)}},"walk");for(const p of l)S(p);for(const p of c)S(p);return{parent:f,children:h,roots:l,componentOf:x,blocks:g,nodeBlocks:b,adjacency:m,preorder:L,postorder:u,topologicalOrder:c}}i(Cr,"buildDrivingTree");function Lr(t,e,n){const o=n.laneOf(t);return[...e].sort((r,c)=>{const a=n.laneOf(r),f=n.laneOf(c),h=a!=null&&a===o,y=f!=null&&f===o;if(h!==y)return h?-1:1;const l=n.rankHint?.[r],I=n.rankHint?.[c];if(l!=null&&I!=null&&l!==I)return I-l;const m=n.topoIndex.get(r)??0,x=n.topoIndex.get(c)??0;return m!==x?m-x:r.localeCompare(c)})[0]}i(Lr,"chooseParent");function wr(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}i(wr,"buildAdjacency");function Ar(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 c of t.get(r)??[])e.has(c)||s.push(c)}}n++}return e}i(Ar,"assignComponents");function Er(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const c=i((a,f)=>{e.set(a,++r),n.set(a,r);for(const h of t.get(a)??[])h!==f&&(e.has(h)?(e.get(h)??0)<(e.get(a)??0)&&(o.push([a,h]),n.set(a,Math.min(n.get(a)??r,e.get(h)??r))):(o.push([a,h]),c(h,a),n.set(a,Math.min(n.get(a)??r,n.get(h)??r)),(n.get(h)??0)>=(e.get(a)??0)&&s.push(Tr(a,h,o,s.length))))},"visit");for(const a of t.keys())e.has(a)||c(a,null);return s}i(Er,"computeBlocks");function Tr(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const c=n.pop();if(s.push(c),r.add(c[0]),r.add(c[1]),c[0]===t&&c[1]===e||c[0]===e&&c[1]===t)break}return{id:o,edges:s,nodes:[...r]}}i(Tr,"popBlock");function Rr(t,e,n){const o=[...t.nodes],s=new Map;for(const[u,C]of o.entries())s.set(C,u);const r=o.length,c=new Array(r).fill(-1),a=new Array(r).fill(0),f=[],h=new Set;for(const u of o){const C=n.parent.get(u)??null,S=s.get(u);S!=null&&C==null&&(c[S]=-1,a[S]=0,h.has(u)||(h.add(u),f.push(u)))}for(;f.length>0;){const u=f.shift(),C=s.get(u);if(C==null)continue;const S=n.children.get(u)??[];for(const p of S){if(h.has(p))continue;const M=s.get(p);M!=null&&(c[M]=C,a[M]=a[C]+1,h.add(p),f.push(p))}}for(const u of o){if(h.has(u))continue;const C=s.get(u);C!=null&&(c[C]=-1,a[C]=0,h.add(u))}const y=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),l=Array.from({length:y},()=>new Array(r).fill(-1));for(let u=0;u<r;u++)l[0][u]=c[u];for(let u=1;u<y;u++)for(let C=0;C<r;C++){const S=l[u-1][C];l[u][C]=S===-1?-1:l[u-1][S]}const I=i((u,C)=>{if(u===-1||C===-1)return-1;a[u]<a[C]&&([u,C]=[C,u]);const S=a[u]-a[C];for(let p=0;p<y;p++)if(S>>p&1&&(u=l[p][u],u===-1))return-1;if(u===C)return u;for(let p=y-1;p>=0;p--){const M=l[p][u],w=l[p][C];M===-1||w===-1||M!==w&&(u=M,C=w)}return l[0][u]},"lcaIndex"),m=Array.from({length:r},()=>new Map);for(const u of t.edges){let C=u.src,S=u.dst,p=e[C],M=e[S];if(p==null||M==null||(p>M&&([C,S]=[S,C],[p,M]=[M,p]),p==null||M==null||p===M))continue;const w=s.get(C),A=s.get(S);if(w==null||A==null)continue;const B=I(w,A);if(B===-1)continue;const P=m[B];for(let E=p;E<M;E++)P.set(E,(P.get(E)??0)+1)}const x=new Map,g=i((u,C)=>{if(C.size!==0)for(const[S,p]of C)u.set(S,(u.get(S)??0)+p)},"mergeInto"),b=new Set,L=i(u=>{const C=s.get(u);b.add(u);const S=C==null?void 0:m[C],p=S?new Map(S):new Map,M=n.children.get(u)??[];for(const w of M){const A=L(w),B=e[u];if(B!=null){let P=x.get(u);P||(P=new Map,x.set(u,P));let E=A.get(B)??0;const k=e[w];k!=null&&k>B&&(E+=1),P.set(w,E)}g(p,A)}return p},"dfs");for(const u of n.roots)b.has(u)||L(u);for(const u of o)b.has(u)||L(u);return x}i(Rr,"computeSubtreeCrossCounts");function Or(t,e,n){const o=new Map,s=i(r=>{let c=n[r]??0;const a=[...e.get(r)??[]];a.sort(zo(n));for(const f of a){s(f);const h=o.get(f);h!=null&&(c=Math.min(c,h))}o.set(r,c)},"annotate");for(const r of t)s(r);return o}i(Or,"annotateMinimumLayers");function zo(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}i(zo,"compareByRankThenId");function Nr(t,e,n,o){let s=0;for(const f of e){const h=n[f]??0;h>s&&(s=h)}const r=Array.from({length:s+1},()=>[]),c=new Set,a=i(f=>{if(c.has(f))return;c.add(f);const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f);for(const y of o(f))a(y)},"emit");for(const f of t)a(f);for(const f of e)if(!c.has(f)){const h=n[f]??0;r[h]||(r[h]=[]),r[h].push(f),c.add(f)}return r}i(Nr,"emitNodesInTreeOrder");function Br(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}i(Br,"deduplicateLayers");function Pr(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const c=e[s]??0,a=[],f=[],h=n.get(s);for(const y of r){const l=o.get(y)??c;l>c?a.push({child:y,min:l}):f.push(y)}return a.sort((y,l)=>y.min===l.min?y.child.localeCompare(l.child):y.min-l.min),f.sort((y,l)=>{const I=h?.get(y)??0,m=h?.get(l)??0;if(I!==m)return I-m;const x=o.get(y)??c,g=o.get(l)??c;return x!==g?x-g:y.localeCompare(l)}),[...a.map(y=>y.child),...f]}}i(Pr,"createChildOrderer");function bn(t,e,n){const o=Cr(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const l of t.nodes)s.has(l)||s.set(l,[]);const c=Rr(t,e,o),a=[...r].sort(zo(e)),f=Or(a,s,e),h=Pr(s,e,c,f);let y=Nr(a,t.nodes,e,h);return y=Br(y),y}i(bn,"buildMultitreeLayerOrder");function Fr(t,e,n){const o=new Set(t),s=new Set(e),r=Xe(e),c=[];for(const a of n)o.has(a.src)&&s.has(a.dst)&&c.push(r.get(a.dst));return Go(c)}i(Fr,"countCrossingsBetweenAdjacent");function fo(t,e,n){const o=[];for(const r of e){const c=n[r.src],a=n[r.dst];if(c==null||a==null||c===a)continue;let f=r.src,h=r.dst,y=c,l=a;c>a&&(f=r.dst,h=r.src,y=a,l=c);for(let I=y;I<l;I++)o.push({id:`${r.id}@${I}`,src:f,dst:h,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=Fr(t[r],t[r+1],o);return s}i(fo,"totalCrossings");function kr(t,e){const n={...e},{preds:o}=Ln(t),s=Se(t),r=bn(t,n,s);let c=fo(r,t.edges,n);const a=yn.MAX_CROSSING_OPTIMIZATION_PASSES;for(let f=0;f<a;f++){let h=!1;const y=[...t.nodes].sort((l,I)=>(n[I]??0)-(n[l]??0));for(const l of y){const I=n[l]??0;if(I===0)continue;let m=0;for(const L of o.get(l)??[])m=Math.max(m,(n[L]??0)+1);if(m>=I)continue;const x=I;n[l]=m;const g=bn(t,n,s),b=fo(g,t.edges,n);b<c?(c=b,h=!0):n[l]=x}if(!h)break}return n}i(kr,"optimizeRanksByCrossings");function _r(t,e){const n=Se(t),o=[...t.nodes].sort((s,r)=>(e[s]??0)-(e[r]??0)||s.localeCompare(r));for(const s of o){const r=n(s);if(!r)continue;const c=t.edges.filter(g=>g.src===s);if(c.length===0)continue;let a=!1,f=0;for(const g of c){const b=n(g.dst);b==null||b===r?a=!0:f++}if(f===0||a)continue;let h=0,y=!1;for(const g of t.edges){if(g.dst!==s)continue;const b=n(g.src);b&&(b===r?y=!0:h++)}if(h>0||!y)continue;const l=e[s]??0,I=l+f;let m=0;for(const g of t.edges)g.dst===s&&(m=Math.max(m,(e[g.src]??0)+1));const x=Math.max(l,m,I);x!==l&&(e[s]=x)}}i(_r,"adjustCrossLaneSources");function Hr(t,e){const n=Ee(t),o=je(n)??[...n.nodes].sort(),s=e?.compactSingleInput??!1,r=Se(n);let c=Object.create(null);for(const f of o){const h=_o(n,f),y=e?.ignoreCrossLaneEdges?h.filter(l=>{const I=r(l.src),m=r(f);return!I||!m?!0:I===m}):h;if(y.length===0)c[f]=0;else if(s&&y.length===1){const l=y[0].src,I=r(l),m=r(f);I!==m?c[f]=c[l]??0:c[f]=(c[l]??0)+1}else{let l=-1/0;for(const I of y)l=Math.max(l,(c[I.src]??0)+1);c[f]=l===-1/0?0:l}}return(e?.optimizeRanksByCrossings??!1)&&(c=kr(n,c)),e?.ignoreCrossLaneEdges&&_r(n,c),{layers:bn(n,c,r),rankOf:c,dummy:new Set}}i(Hr,"assignLayers_LongestPath");function Dr(t,e){const n=Ee(t),s={...Hr(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=Se(n),{preds:c,succs:a}=Ln(n,x=>{if(e?.ignoreCrossLaneEdges){const g=r(x.src),b=r(x.dst);if(g&&b&&g!==b)return!1}return!0}),f=je(n)??[...n.nodes],h=[...f].reverse(),y=i((x,g)=>{let b=0;for(const C of c.get(x)??[])b=Math.max(b,(s[C]??0)+1);let L=Number.POSITIVE_INFINITY;const u=a.get(x)??[];return u.length>0&&(L=Math.min(...u.map(C=>(s[C]??0)-1))),Number.isFinite(L)||(L=Math.max(b,g)),Math.min(Math.max(g,b),L)},"clampFeasible"),l=yn.GRAVITY_ITERATIONS,I=i(x=>{let g=!1;for(const b of x){const L=c.get(b)??[],u=a.get(b)??[];if(L.length===0&&u.length===0)continue;const C=L.length>0?L.reduce((w,A)=>w+(s[A]??0)+1,0)/L.length:s[b]??0,S=u.length>0?u.reduce((w,A)=>w+(s[A]??0)-1,0)/u.length:s[b]??0,p=Math.round((C+S)/2),M=y(b,p);M!==s[b]&&(s[b]=M,g=!0)}return g},"relaxOrder");for(let x=0;x<l;x++){const g=I(f),b=I(h);if(!g&&!b)break}for(const x of f){let g=0;for(const b of c.get(x)??[])g=Math.max(g,(s[b]??0)+1);(s[x]??0)<g&&(s[x]=g)}for(const x of h){const g=a.get(x)??[];if(g.length>0){const b=Math.min(...g.map(L=>(s[L]??0)-1));(s[x]??0)>b&&(s[x]=b)}}return{layers:Xo(n,f,s),rankOf:s,dummy:new Set}}i(Dr,"assignLayers_Gravity");function Xr(t){const e=Cn(t),n=Ho(t);let o=Do(t,e);const s=[];for(;o.length>0;){const r=[];for(const c of o){s.push(c);for(const a of n.get(c)??[])e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0&&r.push(a)}o=r.sort((c,a)=>c.localeCompare(a))}return s.length===t.nodes.length?s:null}i(Xr,"topoSortByGenerationIfAcyclic");function Gr(t,e){const n=Ee(t),o=e?.direction==="LR"?Xr(n)??[...n.nodes].sort():je(n)??[...n.nodes].sort(),s=Se(n),r=i(y=>s(y)??y,"laneOf"),c=Object.create(null),a=new Map,f=i((y,l)=>e?.ignoreCrossLaneEdges??!0?r(y)===r(l)?1:0:1,"edgeWeight");for(const y of o){if(n.nodeById.get(y)?.isGroup)continue;const I=_o(n,y);let m=0;if(I.length>0)for(const L of I){const u=L.src,C=c[u]??0;m=Math.max(m,C+f(u,y))}const x=r(y),g=a.get(x)??0,b=Math.max(m,g);c[y]=b,a.set(x,b+1)}return{layers:Xo(n,o,c,{skipGroups:!0}),rankOf:c,dummy:new Set}}i(Gr,"assignLayers_LaneAwareCompact");function Yr(t,e){const n=Ee(e),{rankOf:o}=t,s=t.layers.map(m=>[...m]),r=new Set(t.dummy?[...t.dummy]:[]);let c=0;const a=new Map(n.nodeById),f=i(m=>{const x=`placeholder-${c++}`,g={id:x,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(x,g),r.add(x);s.length<=m;)s.push([]);return s[m].push(x),o[x]=m,x},"addDummyAt"),h=[...n.edges].sort((m,x)=>m.id===x.id?m.src===x.src?m.dst.localeCompare(x.dst):m.src.localeCompare(x.src):m.id.localeCompare(x.id)),y=[];for(const m of h){const x=o[m.src]??0,g=o[m.dst]??0;if(g-x<=1){y.push(m);continue}let b=m.src;for(let u=x+1,C=0;u<g;u++,C++){const S=f(u);y.push({id:`${m.id}#${C}`,src:b,dst:S,weight:m.weight,ref:m.ref}),b=S}const L=g-x-2;y.push({id:`${m.id}#${Math.max(L+1,0)}`,src:b,dst:m.dst,weight:m.weight,ref:m.ref})}const I={nodes:[...n.nodes,...[...r].filter(m=>!n.nodes.includes(m))],edges:y,layout:n.layout,nodeById:a};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:I}}i(Yr,"makeProperLayering");function uo(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])}i(uo,"median");function ho(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}i(ho,"barycenter");function zr(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}i(zr,"neighborPositionsFor");function $r(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}i($r,"currentOrderTieBreak");function go(t,e,n){const o=new Set(t),s=new Set(e),r=Xe(t),c=Xe(e),a=[];for(const h of n)o.has(h.src)&&s.has(h.dst)&&a.push({u:r.get(h.src),v:c.get(h.dst)});a.sort((h,y)=>h.u===y.u?h.v-y.v:h.u-y.u);const f=a.map(h=>h.v);return Go(f)}i(go,"countCrossingsBetweenAdjacent");function rn(t,e,n){return[...t].sort((o,s)=>{const r=uo(e.get(o)??[]),c=uo(e.get(s)??[]);return r===c?$r(o,s,n):isFinite(r)?isFinite(c)?r-c:-1:1})}i(rn,"sortByHeuristic");function po(t,e,n,o,s,r){const c=Xe(t),a=Xe(e),f=zr(e,c,n,o);if(!s||!r||r.length===0)return rn(e,f,a);const h=new Map;for(const I of e){const m=s(I),x=h.get(m)??[];x.push(I),h.set(m,x)}const y=[];for(const I of r){const m=h.get(I);if(!m||m.length===0)continue;const x=rn(m,f,a);y.push(...x)}const l=h.get(null);if(l&&l.length>0){const I=rn(l,f,a);for(const m of I){const x=ho(f.get(m)??[]);let g=y.length;if(isFinite(x))for(const[b,L]of y.entries()){const u=ho(f.get(L)??[]);if(x<u){g=b;break}}y.splice(g,0,m)}}return y}i(po,"reorderLayer");function mo(t,e,n,o,s){const r=[...e],c=new Set(t),a=new Set(e),f=o?new Set(o):null,h=n.filter(g=>c.has(g.src)&&a.has(g.dst)),y=f?n.filter(g=>a.has(g.src)&&f.has(g.dst)):void 0,l=i(g=>{let b=go(t,g,h);return y&&o&&(b+=go(g,o,y)),b},"crossingScore"),I=s?new Map:null;if(s&&I)for(const g of e)I.set(g,s(g));let m=!0,x=l(r);for(;m;){m=!1;for(let g=0;g+1<r.length;g++){if(I){const u=I.get(r[g]),C=I.get(r[g+1]);if(u!==C)continue}const b=x;[r[g],r[g+1]]=[r[g+1],r[g]];const L=l(r);L<b?(x=L,m=!0):[r[g],r[g+1]]=[r[g+1],r[g]]}}return r}i(mo,"transposeImprove");function Vr(t,e,n){const o=t.layers.map(a=>[...a]),s=e.edges,r=Se(e),c=Yo(e,n?.laneOrder);for(let a=0;a<3;a++){for(let f=1;f<o.length;f++)o[f]=po(o[f-1],o[f],s,"down",r,c),o[f]=mo(o[f-1],o[f],s,o[f+1],r);for(let f=o.length-2;f>=0;f--)o[f]=po(o[f+1],o[f],s,"up",r,c),o[f]=mo(o[f+1],o[f],s,o[f-1],r)}return{layers:o}}i(Vr,"orderLayers");function Ur(t,e,n){const o=n?.layerGap??Pn.DEFAULT_LAYER_GAP,s=n?.nodeGap??Pn.DEFAULT_NODE_GAP,r=n?.laneGap??s*2,c=n?.direction??"TB",a=c==="LR"||c==="RL",f=Object.create(null),h=Object.create(null),y=new Map((e.layout?.nodes??[]).filter(_=>_.isEdgeLabel).map(_=>[_.id,_])),l=i(_=>y.get(_)??e.nodeById.get(_),"getNode"),I=i(_=>l(_)?.width??0,"getWidth"),m=i(_=>l(_)?.height??0,"getHeight"),x=Se(e),g=new Map,b=i(_=>g.has(_)?g.get(_)??null:x(_),"topLaneOf"),L=Yo(e,n?.laneOrder),u=new Set;for(const _ of t.layers)for(const $ of _)u.add(x($));const C=u.has(null),S=L.filter(_=>u.has(_)),p=[...C?[null]:[],...S],M=t.layers,w=new Map;for(const[_,$]of M.entries())for(const tt of $)w.set(tt,_);const A=[],B=[],P=[];for(const _ of e.layout?.edges??[]){const $=_.labelNodeId,tt=_.start,Z=_.end;if(!$||!y.has($)||tt==null||Z==null)continue;const rt=w.get(tt),ut=w.get(Z);if(rt==null||ut==null){P.push({labelId:$,near:rt==null?Z:tt});continue}if(g.set($,x(Z)),rt===ut){const bt=i(Pt=>p.indexOf(x(Pt)),"column");A.push({labelId:$,rank:ut,lane:x(Z),side:tt!==Z&&bt(tt)<bt(Z)?"before":"after"});continue}const gt=Math.min(rt,ut),pt=Math.max(rt,ut);B.push({labelId:$,start:tt,end:Z,gap:gt+Math.floor((pt-gt-1)/2),crossesLanes:x(tt)!==x(Z)})}const E=M.map(_=>_.reduce(($,tt)=>Math.max($,m(tt)),0));for(const{labelId:_,rank:$}of A)E[$]=Math.max(E[$],m(_));const k=M.map(()=>0);if(a)for(let _=0;_+1<M.length;_++){const $=M[_].reduce((pt,bt)=>Math.max(pt,I(bt)),0),tt=M[_+1].reduce((pt,bt)=>Math.max(pt,I(bt)),0),Z=E[_],rt=E[_+1],ut=Z/2+rt/2,gt=($+tt)/2;k[_]=Math.max(0,gt-ut-o)}const Y=a?Bo(e.layout?.nodes??[]):1,K=M.map(()=>0);for(const{labelId:_,gap:$}of B){const Z=((a?I(_):m(_))+2*Pn.EDGE_LABEL_CLEARANCE)/Y;K[$]=Math.max(K[$],Z)}for(const[_,$]of K.entries())k[_]+=$;const z=Object.create(null);for(const _ of S)z[_]=0;C&&(z.null=0);for(const _ of M){const $=Object.create(null),tt=[];for(const Z of _){const rt=b(Z);rt===null?tt.push(Z):($[rt]||=[]).push(Z)}for(const[Z,rt]of Object.entries($)){const ut=rt.reduce((gt,pt)=>gt+I(pt),0)+s*Math.max(0,rt.length-1);z[Z]=Math.max(z[Z]??0,ut)}if(C&&tt.length){const Z=tt.reduce((rt,ut)=>rt+I(ut),0)+s*Math.max(0,tt.length-1);z.null=Math.max(z.null??0,Z)}}const et=new Map;for(const _ of B){const $=`${_.gap}:${b(_.labelId)}`,tt=et.get($);tt?tt.push(_):et.set($,[_])}for(const _ of et.values()){const $=b(_[0].labelId);if($!==null){const tt=_.reduce((Z,rt,ut)=>Z+I(rt.labelId)+(ut>0?s:0),0);z[$]=Math.max(z[$]??0,tt)}}const at=new Map;for(const{labelId:_,rank:$,lane:tt,side:Z}of A){const rt=`${$}:${tt}:${Z}`;at.set(rt,(at.get(rt)??0)+s+I(_))}const xt=i((_,$,tt)=>at.get(`${_}:${$}:${tt}`)??0,"rowLabelSpan");for(const{rank:_,lane:$}of A){const tt=M[_].filter(ut=>b(ut)===$).reduce((ut,gt,pt)=>ut+I(gt)+(pt>0?s:0),0),Z=Math.max(xt(_,$,"before"),xt(_,$,"after")),rt=$??"null";z[rt]=Math.max(z[rt]??0,tt+2*Z)}const Kt=new Map;{const _=p.map(Z=>(Z===null?z.null:z[Z])??0);let tt=-(_.reduce((Z,rt)=>Z+rt,0)+r*Math.max(0,p.length-1))/2;for(let Z=0;Z<p.length;Z++){const rt=p[Z],ut=_[Z]??0,gt=tt+ut/2;Kt.set(rt,gt),tt+=ut,Z<p.length-1&&(tt+=r)}}const Ut=[];let jt=0;for(const[_,$]of M.entries()){const tt=E[_]??0,Z=new Map;for(const ut of $){const gt=b(ut),pt=Z.get(gt)??[];pt.push(ut),Z.set(gt,pt)}for(const ut of p){const gt=Z.get(ut)??[];if(gt.length===0)continue;const pt=Kt.get(ut);if(gt.length===1){const bt=gt[0];f[bt]=pt,h[bt]=jt+tt/2}else{const bt=gt.map(Ie=>I(Ie)),Pt=bt.reduce((Ie,Me)=>Ie+Me,0)+s*(gt.length-1);let Te=pt-Pt/2;for(const[Ie,Me]of gt.entries()){const Re=bt[Ie];f[Me]=Te+Re/2,h[Me]=jt+tt/2,Te+=Re+s}}}const rt=o+(k[_]??0);Ut[_]=jt+tt+rt/2,jt+=tt+rt}const Q=new Map;for(const{labelId:_,rank:$,lane:tt,side:Z}of A){const rt=`${$}:${tt}:${Z}`;if(!Q.has(rt)){const bt=M[$].filter(Pt=>b(Pt)===tt).map(Pt=>Z==="before"?f[Pt]-I(Pt)/2:f[Pt]+I(Pt)/2);Q.set(rt,Z==="before"?Math.min(...bt):Math.max(...bt))}const ut=I(_),gt=Q.get(rt)+(Z==="before"?-1:1)*(s+ut/2);f[_]=gt,h[_]=h[M[$].find(pt=>b(pt)===tt)],Q.set(rt,gt+(Z==="before"?-1:1)*(ut/2))}for(const _ of et.values()){const $=_.map(({start:pt,end:bt,crossesLanes:Pt})=>Pt?f[bt]:((f[pt]??0)+(f[bt]??0))/2),tt=_.map((pt,bt)=>bt).sort((pt,bt)=>$[pt]-$[bt]||pt-bt),Z=[];let rt=-1/0;for(const pt of tt){const bt=I(_[pt].labelId);Z[pt]=Math.max($[pt],rt+s+bt/2),rt=Z[pt]+bt/2}const ut=i(pt=>pt.reduce((bt,Pt)=>bt+Pt,0)/pt.length,"mean"),gt=ut($)-ut(Z);for(const[pt,{labelId:bt,gap:Pt}]of _.entries())f[bt]=Z[pt]+gt,h[bt]=Ut[Pt]}for(const{labelId:_,near:$}of P)f[_]=f[$]??0,h[_]=h[$]??0;const ft=new Map;for(const _ of e.edges){const $=_.ref.id;ft.has($)||ft.set($,[]),ft.get($).push(_)}for(const[,_]of ft){if(_.length===0)continue;const $=_[0].ref,tt=$.start,Z=$.end;if(tt==null||Z==null)continue;const rt=Math.round(((f[tt]??0)+(f[Z]??0))/2),ut=new Set;for(const gt of _)ut.add(gt.src),ut.add(gt.dst);for(const gt of ut){if(gt===tt||gt===Z)continue;e.nodeById.get(gt)?.isDummy&&(f[gt]=rt)}}return{x:f,y:h}}i(Ur,"assignCoordinates");var jr=8;function Wr(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}i(Wr,"hashString");function Kr(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}}i(Kr,"mulberry32");function qr(t,e){const n=[...t],o=Kr(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}i(qr,"deterministicShuffle");function Zr(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}i(Zr,"sourceDistance");function yo(t,e){const n=new Map;for(const[s,r]of t.entries())n.set(r,s);let o=0;for(const{a:s,b:r,weight:c}of e){const a=n.get(s),f=n.get(r);a==null||f==null||(o+=c*Math.abs(a-f))}return o}i(yo,"laneArrangementCost");function Jr(t){const e=wn(t);if(e.length<2)return[];const n=new Map(e.map((r,c)=>[r,c])),o=Se(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const c=typeof r.start=="string"?r.start:void 0,a=typeof r.end=="string"?r.end:void 0;if(!c||!a||!t.nodeById.has(c)||!t.nodeById.has(a))continue;const f=o(c),h=o(a);if(!f||!h||f===h)continue;const y=n.get(f),l=n.get(h);if(y==null||l==null)continue;const[I,m]=y<=l?[f,h]:[h,f],x=`${I}\0${m}`,g=s.get(x);g?g.weight++:s.set(x,{a:I,b:m,weight:1})}return[...s.values()]}i(Jr,"buildWeightedLaneEdges");function xo(t,e,n){const o=[...t];let s=yo(o,e),r=!0,c=0;const a=Math.max(1,o.length);for(;r&&c<a;){r=!1,c++;for(let f=0;f+1<o.length;f++){[o[f],o[f+1]]=[o[f+1],o[f]];const h=yo(o,e);h<s?(s=h,r=!0):[o[f],o[f+1]]=[o[f+1],o[f]]}}return{order:o,cost:s,sourceDistance:Zr(o,n)}}i(xo,"greedySwitch");function Qr(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}i(Qr,"isBetterCandidate");function ti(t,e,n){const o=[...e].sort((s,r)=>s.a===r.a?s.b.localeCompare(r.b):s.a.localeCompare(r.a)).map(({a:s,b:r,weight:c})=>`${s}:${r}:${c}`).join("|");return Wr(`${t.join("|")}#${o}#${n}`)}i(ti,"seedForRestart");function ei(t,e={}){const n=wn(t);if(n.length<2)return n;const o=Jr(t);if(o.length===0)return n;const s=new Map(n.map((a,f)=>[a,f]));let r=xo(n,o,s);const c=Math.max(0,e.restarts??jr);for(let a=0;a<c;a++){const f=ti(n,o,a),h=qr(n,f),y=xo(h,o,s);Qr(y,r)&&(r=y)}return r.order}i(ei,"optimizeTopLaneOrder");function ni(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,s=Ee(t),r=e?.automaticLaneOrdering?ei(s,{restarts:jr}):void 0,c=Sr(s),a=c.acyclic,f=n?Gr(a,{compactSingleInput:e?.compactSingleInput??yn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Dr(a,{compactSingleInput:e?.compactSingleInput??yn.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:h,graphWithDummies:y}=Yr(f,a),l=Vr(h,y,{laneOrder:r}),I=Ur(l,y,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:r});return{acyclic:a,reversed:c.reversed,layering:h,ordered:l,coordinates:I}}i(ni,"sugiyamaLayout");var mt=Bi.EPSILON,Yi=8,Ne=15,He=15,on=25,de=20,_n=10;function bo(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,c=e.y-s,a=Math.abs(r),f=Math.abs(c);return a<mt&&f<mt?n:f>mt&&f*3>=a?c>0?"bottom":"top":a>mt?r>0?"right":"left":n}i(bo,"chooseOrthogonalSide");var ts=i(t=>typeof t=="number"&&Number.isFinite(t)&&t>0,"isDrawableSize");function cn(t,e){const n=t.metadata?.drawnExtent;return{w:ts(n?.width)?n.width:t.width??e,h:ts(n?.height)?n.height:t.height??e}}i(cn,"drawnSize");function Io(t,e){return Math.abs(t.to-e.from)<mt||Math.abs(t.to-e.to)<mt?t.to:t.from}i(Io,"sharedLineEndpointCoord");function Be(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}i(Be,"pointOnLine");function oi(t,e){const n=t.nodes??[],o=t.edges??[],s=[];for(const d of o)d.isLayoutOnly||s.push({...d,__originalEdge:d});const r=new Map,c=new Map,a=[],f=e==="LR";for(const d of n)r.set(d.id,d);const h=pe(n),y=n.filter(d=>h.isLane(d.id));for(const d of y){const v={id:d.id},T=i(R=>{c.set(R.id,v),n.filter(O=>O.parentId===R.id).forEach(T)},"assignLane");T(d)}const l=Ge(n),I=n.filter(d=>!d.isGroup&&!d.isEdgeLabel&&!l.has(d.id)).map(d=>{const v=d.width??10,T=d.height??10,R=d.x??0,O=d.y??0,H=Yi;return{nodeId:d.id,minX:R-v/2-H,maxX:R+v/2+H,minY:O-T/2-H,maxY:O+T/2+H,visualXHalfExtent:f?T/2+H:v/2+H}}),m=i((d,v,T,R)=>{let O=a.find(H=>H.orientation===d&&Math.abs(H.coord-v)<1);return O||(O={id:`pipe-${d}-${v.toFixed(0)}`,orientation:d,coord:v,spanMin:T,spanMax:R,tracks:[]},a.push(O)),O.spanMin=Math.min(O.spanMin,T),O.spanMax=Math.max(O.spanMax,R),O},"getOrAddPipe"),x=i((d,v)=>{const{w:T,h:R}=cn(d,10),O=d.x??0,H=d.y??0;switch(v){case"top":return{x:O,y:H-R/2};case"bottom":return{x:O,y:H+R/2};case"left":return{x:O-T/2,y:H};case"right":return{x:O+T/2,y:H}}},"portForSide"),g=i((d,v,T)=>x(d,bo(d,v,T?"bottom":"top")),"getOrthogonalPort"),b=[],L=[],u=new Set,C=1e3,S=i((d,v,T)=>{if(b.length===0)return 0;const R=Math.abs(v.y-T.y)<mt,O=Math.abs(v.x-T.x)<mt;if(!R&&!O)return 0;let H=0;if(R){const J=v.y,lt=Math.min(v.x,T.x)-mt,W=Math.max(v.x,T.x)+mt;if(W<=lt)return 0;for(const U of b)U.edgeIndex===d||U.orientation!=="vertical"||U.pipe.coord<lt||U.pipe.coord>W||U.from-mt<=J&&U.to+mt>=J&&(H+=C)}else if(O){const J=v.x,lt=Math.min(v.y,T.y)-mt,W=Math.max(v.y,T.y)+mt;if(W<=lt)return 0;for(const U of b)U.edgeIndex===d||U.orientation!=="horizontal"||U.pipe.coord<lt||U.pipe.coord>W||U.from-mt<=J&&U.to+mt>=J&&(H+=C)}return H},"crossingPenalty"),p=s.map((d,v)=>{if(!d.start||!d.end)return{idx:v,crossLane:0,dx:0,dy:0};const T=r.get(d.start),R=r.get(d.end),O=c.get(d.start),H=c.get(d.end),J=O&&H&&O.id!==H.id?1:0,lt=T&&R?Math.abs((R.x??0)-(T.x??0)):0,W=T&&R?Math.abs((R.y??0)-(T.y??0)):0;return{idx:v,crossLane:J,dx:lt,dy:W}}).sort((d,v)=>{if(d.crossLane!==v.crossLane)return v.crossLane-d.crossLane;const T=d.dx+d.dy,R=v.dx+v.dy;return Math.abs(T-R)>1?T-R:d.idx-v.idx}).map(d=>d.idx),M=i((d,v,T,R)=>{const O=Math.min(d.x,v.x),H=Math.max(d.x,v.x),J=Math.min(d.y,v.y),lt=Math.max(d.y,v.y);return!!I.find(U=>T&&U.nodeId===T||R&&U.nodeId===R?!1:Math.abs(d.x-v.x)>mt?U.minY<d.y&&U.maxY>d.y&&U.maxX>O&&U.minX<H:U.minX<d.x&&U.maxX>d.x&&U.maxY>J&&U.minY<lt)},"isSegmentBlocked"),w=new Map,A=new Map;for(const d of s)!d.start||!d.end||d.start===d.end||(A.set(d.start,(A.get(d.start)??0)+1),A.set(d.end,(A.get(d.end)??0)+1));const B=i((d,v)=>bo(d,v,"bottom"),"determineSide"),P=new Map;for(const[d,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),R=r.get(v.end);if(!T||!R)continue;const O=(R.x??0)-(T.x??0),H=(R.y??0)-(T.y??0);P.set(d,{edgeIdx:d,srcId:v.start,dstId:v.end,srcSide:B(T,{x:R.x??0,y:R.y??0}),dstSide:B(R,{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 E=i(d=>d.srcSide==="top"||d.srcSide==="bottom"?d.absDx===0?1/0:d.absDy/d.absDx:d.absDy===0?1/0:d.absDx/d.absDy,"preferenceStrength"),k=i(d=>d.srcSide==="top"||d.srcSide==="bottom"?d.dxSign===0?["right","left"]:[d.dxSign>0?"right":"left"]:d.dySign===0?["bottom","top"]:[d.dySign>0?"bottom":"top"],"secondarySides"),Y=i(d=>k(d)[0],"secondarySide"),K=new Map;for(const d of P.values()){const v=`${d.srcId}:${d.srcSide}`;K.has(v)||K.set(v,[]),K.get(v).push(d)}const z=new Map,et=i((d,v)=>`${d}:${v}`,"loadKey");for(const d of P.values())z.set(et(d.srcId,d.srcSide),(z.get(et(d.srcId,d.srcSide))??0)+1),z.set(et(d.dstId,d.dstSide),(z.get(et(d.dstId,d.dstSide))??0)+1);for(const d of K.values())if(!(d.length<2)){d.sort((v,T)=>{const R=E(v),O=E(T);return Math.abs(R-O)>1e-9?O-R:v.edgeIdx-T.edgeIdx});for(let v=1;v<d.length;v++){const T=d[v],R=z.get(et(T.srcId,T.srcSide))??0,O=k(T).reduce((J,lt)=>(z.get(et(T.srcId,lt))??0)<(z.get(et(T.srcId,J))??0)?lt:J),H=z.get(et(T.srcId,O))??0;H>=R||(z.set(et(T.srcId,T.srcSide),R-1),z.set(et(T.srcId,O),H+1),T.srcSide=O)}}const at=i(d=>{const v=d?.shape;return v==="question"||v==="diamond"},"isDiamondNode"),xt=new Map;for(const d of P.values())xt.has(d.dstId)||xt.set(d.dstId,new Set),xt.get(d.dstId).add(d.dstSide);for(const d of P.values()){if(!at(r.get(d.srcId)))continue;const v=xt.get(d.srcId);if(!v?.has(d.srcSide))continue;const T=Y(d);if(v.has(T)||(z.get(et(d.srcId,T))??0)>0)continue;const R=z.get(et(d.srcId,d.srcSide))??0;z.set(et(d.srcId,d.srcSide),Math.max(0,R-1)),z.set(et(d.srcId,T),1),d.srcSide=T}const Kt=i(d=>{const v=d?.shape;return v==="hexagon"||v==="notch-pent"},"hasVertexFaces"),Ut=new Map;for(const d of P.values())Ut.has(d.srcId)||Ut.set(d.srcId,new Set),Ut.get(d.srcId).add(d.srcSide);const jt=i(d=>d.dstSide==="top"||d.dstSide==="bottom"?d.dxSign>=0?"left":"right":d.dySign>=0?"top":"bottom","secondaryDstSide");for(const d of P.values()){if(!Kt(r.get(d.dstId)))continue;const v=Ut.get(d.dstId);if(!v?.has(d.dstSide))continue;const T=jt(d);if(v.has(T)||(z.get(et(d.dstId,T))??0)>0)continue;const R=z.get(et(d.dstId,d.dstSide))??0;z.set(et(d.dstId,d.dstSide),Math.max(0,R-1)),z.set(et(d.dstId,T),1),d.dstSide=T;const O=d.dySign>=0?"bottom":"top";if((T==="top"||T==="bottom")&&xt.get(d.srcId)?.has(d.srcSide)&&!xt.get(d.srcId)?.has(O)&&(z.get(et(d.srcId,O))??0)===0){const H=z.get(et(d.srcId,d.srcSide))??0;z.set(et(d.srcId,d.srcSide),Math.max(0,H-1)),z.set(et(d.srcId,O),1),d.srcSide=O}}for(const d of P.values()){const{edgeIdx:v,srcId:T,dstId:R,srcSide:O,dstSide:H}=d,J=r.get(T),lt=r.get(R),W=`${T}:${O}:src`,U=O==="top"||O==="bottom"?lt.x??0:lt.y??0;w.has(W)||w.set(W,[]),w.get(W).push({edgeIdx:v,oppositeCoord:U});const wt=`${R}:${H}:dst`,At=H==="top"||H==="bottom"?J.x??0:J.y??0;w.has(wt)||w.set(wt,[]),w.get(wt).push({edgeIdx:v,oppositeCoord:At})}const Q=new Map,ft=8;for(const[d,v]of w){if(v.length<2)continue;v.sort((Gt,ie)=>Gt.oppositeCoord-ie.oppositeCoord);const T=d.split(":"),R=T.slice(0,-2).join(":"),O=T[T.length-2],H=T[T.length-1],J=r.get(R);if(!J)continue;const lt=O==="left"||O==="right",W=cn(J,10),U=lt?W.h:W.w,wt=J.shape,Tt=wt==="question"||wt==="diamond"?U*.3:U,Mt=Math.min(20,Tt/(v.length-1),Math.max(ft,Tt/(v.length+1))),oe=-(Mt*(v.length-1))/2;for(const[Gt,ie]of v.entries()){const ve=oe+Gt*Mt,An=`${ie.edgeIdx}:${H}`;Q.set(An,ve)}}const _=i(d=>!!s[d]?.labelNodeId,"edgeHasLabelNode"),$=i((d,v)=>d?(w.get(`${d}:${v}:src`)??[]).some(({edgeIdx:T})=>_(T))||(w.get(`${d}:${v}:dst`)??[]).some(({edgeIdx:T})=>_(T)):!1,"faceHasLabelNode"),tt=i((d,v,T)=>v==="top"||v==="bottom"?{x:d.x+T,y:d.y}:{x:d.x,y:d.y+T},"applyPortOffset"),Z=i((d,v,T)=>{const R=P.get(d),O={x:T.x??0,y:T.y??0},H={x:v.x??0,y:v.y??0},J=R?.srcSide??B(v,O),lt=R?.dstSide??B(T,H);let W=R?x(v,R.srcSide):g(v,O,!0),U=R?x(T,R.dstSide):g(T,H,!1);const wt=Q.get(`${d}:src`),At=Q.get(`${d}:dst`);return wt!==void 0&&(W=tt(W,J,wt)),At!==void 0&&(U=tt(U,lt,At)),{pSrcPort:W,pDstPort:U,srcSide:J,dstSide:lt}},"portsForEdge");for(const d of p){const v=s[d];if(L[d]=[],!v.start||!v.end||v.points&&v.points.length>0||v.start===v.end)continue;const T=r.get(v.start),R=r.get(v.end);if(!T||!R)continue;const{pSrcPort:O,pDstPort:H,srcSide:J,dstSide:lt}=Z(d,T,R),W={...O},U={...H},wt=J==="top"||J==="bottom",At=lt==="top"||lt==="bottom";if(wt){const X=O.y>(T.y??0);W.y=X?O.y+de:O.y-de}else{const X=O.x>(T.x??0);W.x=X?O.x+de:O.x-de}if(At){const X=H.y>(R.y??0);U.y=X?H.y+de:H.y-de}else{const X=H.x>(R.x??0);U.x=X?H.x+de:H.x-de}const Tt=i((X,V)=>{for(const st of I)if(!V.includes(st.nodeId)&&X.x>st.minX&&X.x<st.maxX&&X.y>st.minY&&X.y<st.maxY)return{inside:!0,obstacle:st};return{inside:!1}},"isPointInObstacle"),it=i((X,V,st,vt,Bt)=>{if(Bt){const Yt=X.y>(V.y??0);return{x:(st.x??0)>=X.x?vt.maxX+Ne:vt.minX-Ne,y:Yt?vt.maxY+He:vt.minY-He,leavesPositiveSide:Yt}}const Et=X.x>(V.x??0),Ht=(st.y??0)>=X.y;return{x:Et?vt.maxX+Ne:vt.minX-Ne,y:Ht?vt.maxY+He:vt.minY-He,leavesPositiveSide:Et}},"obstacleDetour");let Mt=[];const _t=[v.start,v.end],oe=Tt(W,_t);if(oe.inside&&oe.obstacle){const X=oe.obstacle;if(wt){const V=it(O,T,R,X,!0);W.x=V.x,W.y=V.y;const st=V.leavesPositiveSide?Math.min(X.minY-2,O.y+de):Math.max(X.maxY+2,O.y-de);Mt=[{x:O.x,y:st},{x:V.x,y:st},{x:V.x,y:V.y}]}else{const V=it(O,T,R,X,!1),st=V.leavesPositiveSide?Math.min(X.minX-2,O.x+de):Math.max(X.maxX+2,O.x-de);W.x=V.x,W.y=V.y,Mt=[{x:st,y:O.y},{x:st,y:V.y},{x:V.x,y:V.y}]}}let Gt=[];const ie=Tt(U,_t);if(ie.inside&&ie.obstacle){const X=ie.obstacle;if(At){const V=it(H,R,T,X,!0);U.x=V.x,U.y=V.y,Gt=[{x:V.x,y:V.y},{x:H.x,y:V.y}]}else{const V=it(H,R,T,X,!1);U.x=V.x,U.y=V.y,Gt=[{x:V.x,y:V.y},{x:V.x,y:H.y}]}}if(Mt.length===0&&Gt.length===0){const X=Ne,V=Math.abs(W.x-U.x)<X,st=Math.abs(W.y-U.y)<X,vt=Q.get(`${d}:src`)!==void 0||Q.get(`${d}:dst`)!==void 0,Bt=(w.get(`${v.start??""}:${J}:src`)?.length??0)+(w.get(`${v.start??""}:${J}:dst`)?.length??0),Et=(w.get(`${v.end??""}:${lt}:src`)?.length??0)+(w.get(`${v.end??""}:${lt}:dst`)?.length??0),Ht=Bt>1||Et>1,Yt=A.get(v.start??"")??0,Lt=A.get(v.end??"")??0,Jt=Bt>1&&$(v.start,J)||Et>1&&$(v.end,lt),fe=Bt<=1||Yt<=2,$t=Et<=1||Lt<=2;if((V||st)&&!vt&&(!Ht||Ht&&!Jt&&fe&&$t)&&!M(O,H,v.start,v.end)){v.points=[{...O},{...W},{...U},{...H}],u.add(d);const Rt=st?"horizontal":"vertical",ee=st?O.y:O.x,Ot=st?Math.min(O.x,H.x):Math.min(O.y,H.y),Nt=st?Math.max(O.x,H.x):Math.max(O.y,H.y),se={id:`fast-path-${Rt}-${ee.toFixed(0)}-${d}`,orientation:Rt,coord:ee,spanMin:Ot,spanMax:Nt,tracks:[]};b.push({edgeIndex:d,segmentIndex:0,orientation:Rt,pipe:se,trackIndex:0,from:Ot,to:Nt});continue}}const ve=m("vertical",W.x,W.y,W.y);W.x=ve.coord;const An=m("vertical",U.x,U.y,U.y);U.x=An.coord;let Ce=Math.min(W.x,U.x)-50,Le=Math.max(W.x,U.x)+50,Fe=Math.min(W.y,U.y)-50,ke=Math.max(W.y,U.y)+50;for(const X of I){const V=Math.min(W.x,U.x),st=Math.max(W.x,U.x),vt=Math.min(W.y,U.y),Bt=Math.max(W.y,U.y);X.minX<st&&X.maxX>V&&X.minY<Bt&&X.maxY>vt&&(Ce=Math.min(Ce,X.minX-on),Le=Math.max(Le,X.maxX+on),Fe=Math.min(Fe,X.minY-on),ke=Math.max(ke,X.maxY+on))}for(const X of I){if(X.maxX<Ce||X.minX>Le||X.maxY<Fe||X.minY>ke)continue;const V=Ne;m("horizontal",X.minY-V,Ce,Le),m("horizontal",X.maxY+V,Ce,Le);const st=He;m("vertical",X.minX-st,Fe,ke),m("vertical",X.maxX+st,Fe,ke)}m("horizontal",W.y,Ce,Le),m("horizontal",U.y,Ce,Le);const ci=a.filter(X=>X.orientation==="horizontal"&&X.coord>=Fe&&X.coord<=ke),ai=a.filter(X=>X.orientation==="vertical"&&X.coord>=Ce&&X.coord<=Le),Ke=i((X,V)=>`${X.toFixed(1)},${V.toFixed(1)}`,"getKey"),qe=Ke(W.x,W.y),$o=Ke(U.x,U.y),Ze=new Map,En=new Map,Tn=new Map,Je=new Set,Oe=[];Ze.set(qe,0),Tn.set(qe,"n"),Oe.push({key:qe,f:Math.hypot(U.x-W.x,U.y-W.y),pt:W}),Je.add(qe);let qt=[];const we=i((X,V)=>M(X,V,v.start,v.end),"checkSegmentBlocked"),Rn={x:U.x,y:W.y},li=we(W,Rn),fi=we(Rn,U),di=li||fi,On={x:W.x,y:U.y},ui=we(W,On),hi=we(On,U);if(di?ui||hi||(Math.abs(W.x-U.x)<mt?qt=[W,U]:qt=[W,On,U]):Math.abs(W.y-U.y)<mt||Math.abs(W.x-U.x)<mt?qt=[W,U]:qt=[W,Rn,U],qt.length===0)for(;Oe.length>0;){Oe.sort((Lt,Jt)=>Lt.f-Jt.f);const X=Oe.shift();if(Je.delete(X.key),X.key===$o){let Lt=$o,Jt=U;for(qt=[Jt];En.has(Lt);){const fe=En.get(Lt);qt.unshift(fe),Jt=fe,Lt=Ke(fe.x,fe.y)}break}const V=X.pt.x,st=X.pt.y,vt=ai.sort((Lt,Jt)=>Lt.coord-Jt.coord),Bt=vt.findIndex(Lt=>Math.abs(Lt.coord-V)<1),Et=ci.sort((Lt,Jt)=>Lt.coord-Jt.coord),Ht=Et.findIndex(Lt=>Math.abs(Lt.coord-st)<1),Yt=[];Bt>0&&Yt.push({x:vt[Bt-1].coord,y:st}),Bt>=0&&Bt<vt.length-1&&Yt.push({x:vt[Bt+1].coord,y:st}),Ht>0&&Yt.push({x:V,y:Et[Ht-1].coord}),Ht>=0&&Ht<Et.length-1&&Yt.push({x:V,y:Et[Ht+1].coord});for(const Lt of Yt){const Jt=Math.min(V,Lt.x),fe=Math.max(V,Lt.x),$t=Math.min(st,Lt.y),te=Math.max(st,Lt.y);if(I.some(ce=>ce.nodeId===v.start||ce.nodeId===v.end?!1:Jt!==fe?ce.minY<st&&ce.maxY>st&&ce.maxX>Jt&&ce.minX<fe:ce.minX<V&&ce.maxX>V&&ce.maxY>$t&&ce.minY<te))continue;const Rt=Ke(Lt.x,Lt.y),ee=Math.abs(Lt.x-V)+Math.abs(Lt.y-st),Ot=S(d,X.pt,Lt);let Nt=0;const se=U.x-W.x,_e=U.y-W.y,Qe=Lt.x-V,Nn=Lt.y-st;(_e>10&&Nn<-5||_e<-10&&Nn>5)&&(Nt=Math.abs(Nn)*100),(se>10&&Qe<-5||se<-10&&Qe>5)&&(Nt+=Math.abs(Qe)*50);let Vo=0;const Uo=Tn.get(X.key)??"n",jo=Math.abs(Qe)>mt?"h":"v";Uo!=="n"&&Uo!==jo&&(Vo=50);const gi=ee+Ot+Nt+Vo,tn=(Ze.get(X.key)??1/0)+gi,Wo=Math.abs(U.x-Lt.x)+Math.abs(U.y-Lt.y);if(tn<(Ze.get(Rt)??1/0))if(En.set(Rt,X.pt),Ze.set(Rt,tn),Tn.set(Rt,jo),!Je.has(Rt))Oe.push({key:Rt,f:tn+Wo,pt:Lt}),Je.add(Rt);else{const ce=Oe.findIndex(pi=>pi.key===Rt);ce!==-1&&(Oe[ce].f=tn+Wo)}}}if(qt.length===0&&(qt=[W,{x:W.x,y:U.y},U]),qt.length>4){const X=qt[0],V=qt[qt.length-1];let st=Math.min(X.x,V.x),vt=Math.max(X.x,V.x),Bt=Math.min(X.y,V.y),Et=Math.max(X.y,V.y);for(const $t of qt)st=Math.min(st,$t.x),vt=Math.max(vt,$t.x),Bt=Math.min(Bt,$t.y),Et=Math.max(Et,$t.y);const Ht=vt>Math.max(X.x,V.x),Yt=st<Math.min(X.x,V.x);if(f){const $t=He;if(Ht){const te=Math.max(X.x,V.x),zt=Math.min(X.y,V.y),Rt=Math.max(X.y,V.y),ee=I.filter(Ot=>Ot.minX<te&&Ot.maxX>te&&Ot.minY<Rt&&Ot.maxY>zt);if(ee.length>0){let Ot=Math.max(X.x,V.x);for(const Nt of ee){const se=(Nt.minX+Nt.maxX)/2;if(Nt.visualXHalfExtent===void 0||isNaN(Nt.visualXHalfExtent))continue;const _e=se+Nt.visualXHalfExtent+$t;Ot=Math.max(Ot,_e)}isNaN(Ot)||(vt=Ot)}}if(Yt){const te=I.filter(zt=>zt.minX<Math.min(X.x,V.x)+$t&&zt.minY<Math.max(X.y,V.y)&&zt.maxY>Math.min(X.y,V.y));if(te.length>0){let zt=Math.min(X.x,V.x);for(const Rt of te){const Ot=(Rt.minX+Rt.maxX)/2-Rt.visualXHalfExtent-$t;zt=Math.min(zt,Ot)}st=zt}}}const Lt=i($t=>{const te=V.y>X.y,zt=I.filter(Ot=>{const Nt=Math.min(X.x,V.x)<Ot.maxX&&Math.max(X.x,V.x)>Ot.minX,se=Math.min(X.y,V.y)<Ot.maxY&&Math.max(X.y,V.y)>Ot.minY;return Nt&&se});let Rt=zt;if(f&&zt.length>0){const Ot=zt.filter(Nt=>Nt.minX<$t&&Nt.maxX>$t);Ot.length>0&&(Rt=Ot)}if(Rt.length===0)return V.y;const ee=Ne;if(te){const Nt=Math.max(...Rt.map(se=>se.maxY))+ee;if(Nt<V.y-mt)return Nt}else{const Nt=Math.min(...Rt.map(se=>se.minY))-ee;if(Nt>V.y+mt)return Nt}return V.y},"findBestReturnY"),Jt=i($t=>{const te=Lt($t),zt={x:$t,y:X.y},Rt={x:$t,y:te},ee={x:V.x,y:te},Ot=we(X,zt),Nt=we(zt,Rt),se=we(Rt,ee),_e=te!==V.y?we(ee,V):!1;return!Ot&&!Nt&&!se&&!_e?Math.abs(te-V.y)<mt?[X,zt,Rt,V]:[X,zt,Rt,ee,V]:null},"trySimplifyWithDetourX"),fe=Ht&&!Yt?Jt(vt):Yt&&!Ht?Jt(st):null;fe&&(qt=fe)}const Zt=[O,...Mt,...qt,...Gt.reverse(),H];if(Zt.length>=3){const X=Zt[Zt.length-1],V=Zt[Zt.length-2],st=Zt[Zt.length-3],vt=Math.abs(st.y-V.y)<mt&&Math.abs(V.y-X.y)<mt,Bt=Math.abs(st.x-V.x)<mt&&Math.abs(V.x-X.x)<mt;if(vt){const Et=Math.sign(V.x-st.x),Ht=Math.sign(X.x-st.x);Et!==0&&Et===Ht&&Math.abs(V.x-st.x)>Math.abs(X.x-st.x)&&Zt.splice(-2,1)}else if(Bt){const Et=Math.sign(V.y-st.y),Ht=Math.sign(X.y-st.y);Et!==0&&Et===Ht&&Math.abs(V.y-st.y)>Math.abs(X.y-st.y)&&Zt.splice(-2,1)}}const me=[Zt[0]];for(let X=1;X<Zt.length-1;X++){if(X===1){me.push(Zt[X]);continue}const V=me[me.length-1],st=Zt[X],vt=Zt[X+1];if(Math.abs(V.y-st.y)<mt&&Math.abs(st.y-vt.y)<mt){const Bt=st.x>V.x,Et=vt.x>st.x;if(Bt!==Et){me.push(st);continue}continue}if(Math.abs(V.x-st.x)<mt&&Math.abs(st.x-vt.x)<mt){const Bt=st.y>V.y,Et=vt.y>st.y;if(Bt!==Et){me.push(st);continue}continue}me.push(st)}me.push(Zt[Zt.length-1]);for(let X=0;X<me.length-1;X++){const V=me[X],st=me[X+1],vt=Math.abs(V.x-st.x)<mt?"vertical":"horizontal",Bt=vt==="vertical"?V.x:V.y,Et=vt==="vertical"?Math.min(V.y,st.y):Math.min(V.x,st.x),Ht=vt==="vertical"?Math.max(V.y,st.y):Math.max(V.x,st.x),Yt=m(vt,Bt,Et,Ht),Lt={edgeIndex:d,segmentIndex:X,orientation:vt,pipe:Yt,trackIndex:0,from:Et,to:Ht};b.push(Lt),L[d].push(b.length-1),Yt.tracks[0]||(Yt.tracks[0]={index:0,coord:Yt.coord,segments:[]}),Yt.tracks[0].segments.push({edgeIndex:d,segmentIndex:X,from:Et,to:Ht})}}const rt=i((d,v)=>d.from<v.to&&v.from<d.to,"segmentsOverlap"),ut=i((d,v,T,R)=>{const O=!R.segments.some(J=>(J.edgeIndex!==v.edgeIndex||J.segmentIndex!==v.segmentIndex)&&rt(J,d)),H=!T.segments.some(J=>(J.edgeIndex!==d.edgeIndex||J.segmentIndex!==d.segmentIndex)&&rt(J,v));return O&&H?(d.trackIndex=R.index,v.trackIndex=T.index,T.segments=[...T.segments.filter(J=>J.edgeIndex!==d.edgeIndex||J.segmentIndex!==d.segmentIndex),{edgeIndex:v.edgeIndex,segmentIndex:v.segmentIndex,from:v.from,to:v.to}],R.segments=[...R.segments.filter(J=>J.edgeIndex!==v.edgeIndex||J.segmentIndex!==v.segmentIndex),{edgeIndex:d.edgeIndex,segmentIndex:d.segmentIndex,from:d.from,to:d.to}],!0):!1},"trySwapSegmentsAcrossTracks"),gt=i(d=>{const v=d.tracks.length;return d.tracks[v]={index:v,coord:d.coord,segments:[]},v},"createNewTrack"),pt=i((d,v)=>{const T=d.pipe.tracks[d.trackIndex];T.segments=T.segments.filter(O=>O.edgeIndex!==d.edgeIndex||O.segmentIndex!==d.segmentIndex),d.trackIndex=v,d.pipe.tracks[v].segments.push({edgeIndex:d.edgeIndex,segmentIndex:d.segmentIndex,from:d.from,to:d.to})},"moveSegmentToTrack"),bt=i((d,v)=>{const T=L[d.edgeIndex];for(const R of T){const O=b[R];O.pipe===d.pipe&&pt(O,v)}},"moveSegmentChainToTrack"),Pt=i(d=>{const v=L[d.edgeIndex],T=v.indexOf(b.indexOf(d)),R=[];return T>0&&R.push(b[v[T-1]]),T<v.length-1&&R.push(b[v[T+1]]),R},"getAdjacentSegmentsAlongEdge"),Te=i((d,v)=>{if(d.orientation===v.orientation)return!1;const T=d.orientation==="horizontal"?d:v,R=d.orientation==="horizontal"?v:d;return R.pipe.coord>T.from&&R.pipe.coord<T.to&&T.pipe.coord>R.from&&T.pipe.coord<R.to},"haveAnyCrossing"),Ie=i((d,v)=>{for(const T of d.tracks)if(!T.segments.some(O=>(O.edgeIndex!==v.edgeIndex||O.segmentIndex!==v.segmentIndex)&&rt(O,v)))return T.index;return-1},"findAvailableTrack"),Me=i((d,v)=>{if(d.trackIndex===v.trackIndex)return rt(d,v);const T=Pt(d),R=Pt(v);return T.some(O=>R.some(H=>Te(O,H)))},"segmentsConflict"),Re=i((d,v,T)=>{if(ut(d,v,d.pipe.tracks[d.trackIndex],v.pipe.tracks[v.trackIndex]))return;const R=Ie(d.pipe,v);T(v,R!==-1?R:gt(d.pipe))},"resolveTrackConflict"),We=i(d=>{let v=0;for(let T=0;T<d.length;T++)for(let R=T+1;R<d.length;R++){const O=d[T],H=d[R];O.pipe===H.pipe&&Me(O,H)&&(v++,Re(O,H,bt))}return v},"resolveHandleConflicts"),N=new Map,F=i(d=>{if(N.has(d))return N.get(d);const v=L[d];if(v.length===0){const lt={dest:0,deviation:0,base:0,delta:0};return N.set(d,lt),lt}const R=b[v[0]].pipe.coord;let O=R;for(let lt=1;lt<v.length;lt++){const W=b[v[lt]];if(W.orientation==="horizontal"){const U=W.from,wt=W.to;O=Math.abs(U-R)>Math.abs(wt-R)?U:wt;break}}const H=Math.abs(O-R),J={dest:O,deviation:H,base:R,delta:O-R};return N.set(d,J),J},"getDestInfo"),D=i(()=>{let d=0;const v=new Map;for(const[R,O]of s.entries())L[R].length!==0&&O.start&&(v.has(O.start)||v.set(O.start,[]),v.get(O.start).push(R));const T=i(R=>{const O=s[R];if(!O.start||!O.end)return 0;const H=r.get(O.start),J=r.get(O.end);if(!H||!J)return 0;const lt=(J.x??0)-(H.x??0),W=(J.y??0)-(H.y??0);return Math.abs(lt)+Math.abs(W)},"getEdgeDistance");for(const R of v.values()){R.sort((H,J)=>{const lt=F(H),W=F(J);if(Math.abs(lt.deviation-W.deviation)>1)return lt.deviation-W.deviation;if(Math.abs(lt.dest-W.dest)>1)return lt.dest-W.dest;const U=T(H),wt=T(J);if(Math.abs(U-wt)>1)return wt-U;const At=L[H].length,Tt=L[J].length;if(At!==Tt)return At-Tt;if(At===1){const it=L[H][0],Mt=L[J][0];if(b[it]&&b[Mt]){const _t=b[it],oe=b[Mt],Gt=Math.abs(_t.to-_t.from),ie=Math.abs(oe.to-oe.from);if(Math.abs(Gt-ie)>1)return Gt-ie}}return 0});const O=R.map(H=>b[L[H][0]]);d+=We(O)}return d},"fixSourceHandleCrossings"),j=i(()=>{let d=0;const v=new Map;for(const[T,R]of s.entries())L[T].length!==0&&R.end&&(v.has(R.end)||v.set(R.end,[]),v.get(R.end).push(T));for(const T of v.values()){T.sort((O,H)=>{const J=i(U=>{const wt=L[U];if(wt.length<2)return 0;const At=b[wt[wt.length-2]];return Math.abs(At.to-At.from)},"getDist"),lt=J(O),W=J(H);return Math.abs(lt-W)>.1?lt-W:O-H});const R=T.map(O=>b[L[O][L[O].length-1]]);d+=We(R)}return d},"fixTargetHandleCrossings"),q=i(()=>{let d=0;for(const v of a){const T=[];for(const R of v.tracks)for(const O of R.segments){const H=L[O.edgeIndex].find(J=>b[J].segmentIndex===O.segmentIndex);H!==void 0&&T.push(b[H])}T.sort((R,O)=>R.edgeIndex-O.edgeIndex||R.segmentIndex-O.segmentIndex);for(let R=0;R<T.length;R++)for(let O=R+1;O<T.length;O++){const H=T[R],J=T[O];Me(H,J)&&(d++,Re(H,J,pt))}}return d},"fixPipeCrossings");let nt=0;const G=10;for(;nt<G;){let d=0;if(d+=D(),d+=j(),d+=q(),d===0)break;nt++}const ot=new Map;for(const d of a){const v=[];d.tracks.forEach(R=>{R.segments.forEach(O=>{v.push({edgeIndex:O.edgeIndex,segmentIndex:O.segmentIndex,trackIndex:R.index,from:O.from,to:O.to})})}),v.sort((R,O)=>R.from-O.from);const T=[];if(v.length>0){let R=[v[0]],O=v[0].to;for(let H=1;H<v.length;H++){const J=v[H];J.from<O?(R.push(J),O=Math.max(O,J.to)):(T.push(R),R=[J],O=J.to)}T.push(R)}for(const R of T){const O=new Set;R.forEach(it=>O.add(it.trackIndex));const H=new Map;R.forEach(it=>{const Mt=F(it.edgeIndex);H.set(it.trackIndex,(H.get(it.trackIndex)??0)+Mt.delta)});const J=[...O].filter(it=>(H.get(it)??0)<-1),lt=[...O].filter(it=>(H.get(it)??0)>1),W=[...O].filter(it=>Math.abs(H.get(it)??0)<=1);J.sort((it,Mt)=>(H.get(Mt)??0)-(H.get(it)??0)),lt.sort((it,Mt)=>(H.get(it)??0)-(H.get(Mt)??0));const U=i((it,Mt)=>{R.filter(_t=>_t.trackIndex===it).forEach(_t=>{const oe=u.has(_t.edgeIndex)?d.coord:Mt;ot.set(`${_t.edgeIndex}-${_t.segmentIndex}`,oe)})},"assignCoord");let wt=0;for(const it of J)wt++,U(it,d.coord-wt*_n);if(W.length===0&&O.size>0){const it=[...O].sort((oe,Gt)=>Math.abs(H.get(oe)??0)-Math.abs(H.get(Gt)??0))[0],Mt=J.indexOf(it);Mt!==-1&&J.splice(Mt,1);const _t=lt.indexOf(it);_t!==-1&&lt.splice(_t,1),W.push(it)}let At=0;for(const it of W){if(At===0)U(it,d.coord);else{const Mt=At%2===1?1:-1,_t=Math.ceil(At/2);U(it,d.coord+Mt*_t*_n*.5)}At++}let Tt=0;for(const it of lt)Tt++,U(it,d.coord+Tt*_n)}}for(const[d,v]of s.entries()){const T=L[d]??[];if(T.length===0)continue;const R=[],O=r.get(v.start),H=r.get(v.end),{pSrcPort:J,pDstPort:lt}=Z(d,O,H),W=T.map(Tt=>{const it=b[Tt],Mt=ot.get(`${it.edgeIndex}-${it.segmentIndex}`)??it.pipe.coord;return{orient:it.orientation,coord:Mt,from:it.from,to:it.to}});R.push(J);for(let Tt=0;Tt<W.length;Tt++){const it=W[Tt],Mt=R[R.length-1],_t=it.orient==="vertical"?Mt.y:Mt.x,oe=it.orient==="vertical"?Mt.x:Mt.y,Gt=W[Tt+1],ie=Tt<W.length-1;if(Math.abs(oe-it.coord)>mt&&R.push(Be(it,_t)),ie&&Gt.orient===it.orient)if(Math.abs(it.coord-Gt.coord)>mt){const ve=it.orient==="vertical"?(_t+Gt.from)/2:Io(it,Gt);R.push(Be(it,ve),Be(Gt,ve))}else(Tt===0||Tt===W.length-2)&&R.push(Be(it,Io(it,Gt)));else if(ie)R.push(Be(it,Gt.coord));else{const ve=Math.abs(it.from-_t)<Math.abs(it.to-_t)?it.to:it.from;R.push(Be(it,ve))}}const U=R[R.length-1];(Math.abs(U.x-lt.x)>mt||Math.abs(U.y-lt.y)>mt)&&R.push(lt);const wt=R[0];wt&&(Math.abs(wt.x-J.x)>mt||Math.abs(wt.y-J.y)>mt)&&R.unshift(J);const At=[];R.length>0&&At.push(R[0]);for(let Tt=1;Tt<R.length;Tt++){const it=R[Tt],Mt=At[At.length-1];(Math.abs(it.x-Mt.x)>mt||Math.abs(it.y-Mt.y)>mt)&&At.push(it)}v.points=At}for(const d of s){const v=d.__originalEdge;v&&d.points&&(v.points=d.points)}t.edges=(t.edges??[]).filter(d=>!d.isLayoutOnly);const dt=i((d,v)=>{const T=v.x??0,R=v.y??0,{w:O,h:H}=cn(v,0);if(O<=0||H<=0)return d;const J=T-O/2,lt=T+O/2,W=R-H/2,U=R+H/2;if(d.x<J||d.x>lt||d.y<W||d.y>U)return d;const wt=d.x-J,At=lt-d.x,Tt=d.y-W,it=U-d.y,Mt=Math.min(wt,At,Tt,it);return Mt===wt?{x:J,y:d.y}:Mt===At?{x:lt,y:d.y}:Mt===Tt?{x:d.x,y:W}:{x:d.x,y:U}},"nodeBoundaryClamp");for(const d of t.edges){const v=d.points;if(!v||v.length<2)continue;const T=d.start,R=d.end,O=T?r.get(T):void 0,H=R?r.get(R):void 0;O&&(v[0]=dt(v[0],O)),H&&(v[v.length-1]=dt(v[v.length-1],H))}return t}i(oi,"routeEdgesOrthogonal");function si(t){return t.direction??"TB"}i(si,"getSwimlaneDirection");function ri(t){const e=ys(t),n=t.config.flowchart?.nodeSpacing??40,o=t.config.flowchart?.rankSpacing??100,s=t.config.swimlane?.ignoreCrossLaneEdges??!0,r=t.config.swimlane?.optimizeRanksByCrossings??!0,c=t.config.swimlane?.automaticLaneOrdering??!1,a=si(t),{ordered:f,coordinates:h}=ni(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:c,direction:a});bs(e,f,h,{nodeGap:n,layerGap:o});for(const y of t.edges??[])delete y.points;oi(t,a);for(const y of t.edges??[])(!y.curve||y.curve==="basis")&&(y.curve="rounded");return Ir(t,a),xr(t),a}i(ri,"runSwimlaneLayoutCore");function ii(t){ms(t);const e=Is(t);t.nodes=e.nodes,t.edges=e.edges}i(ii,"prepareSwimlaneLayout");var qi=xi({prepareLayout:ii,runLayoutCore:ri,afterPaint:es});export{qi as render};