@intent-hq/web 2.286.1 → 2.286.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/intent-web.mjs +11 -2
- package/package.json +1 -1
- package/web/app/immutable/assets/0.B2ssLqMh.css +1 -0
- package/web/app/immutable/chunks/{R0wDqNpY.js → 0azY1Euo.js} +1 -1
- package/web/app/immutable/chunks/{BdMP-rwq.js → 1Xl1_j69.js} +1 -1
- package/web/app/immutable/chunks/{CzK2fiHA.js → 1iwlWivR.js} +1 -1
- package/web/app/immutable/chunks/{DqkDKEMV.js → 2N--vaHR.js} +1 -1
- package/web/app/immutable/chunks/3kw_jVcY.js +3 -0
- package/web/app/immutable/chunks/{BUqUwu2G.js → 3oGwK09B.js} +1 -1
- package/web/app/immutable/chunks/{DuzQF9m7.js → 5JOOVIIo.js} +1 -1
- package/web/app/immutable/chunks/{2oaDc1nn.js → 6CBvudM-.js} +1 -1
- package/web/app/immutable/chunks/{Dh52so4o.js → 6gxnLEJP.js} +3 -3
- package/web/app/immutable/chunks/{DiBTM3GP.js → 976zYcoh.js} +1 -1
- package/web/app/immutable/chunks/{BB0aq9c_.js → B-GuaxD4.js} +1 -1
- package/web/app/immutable/chunks/{2FstYM1s.js → B2Ta8ZYX.js} +1 -1
- package/web/app/immutable/chunks/{HHGL3CBU.js → B2jOXbpl.js} +1 -1
- package/web/app/immutable/chunks/{B1kJVNhf.js → B3foPak9.js} +1 -1
- package/web/app/immutable/chunks/{CJKeXT5H.js → B5mo4ccL.js} +1 -1
- package/web/app/immutable/chunks/{Fy3QvGgT.js → B6n3m66K.js} +1 -1
- package/web/app/immutable/chunks/{C5E1PJb6.js → B781x4pz.js} +2 -2
- package/web/app/immutable/chunks/{Ct7iVnk5.js → B7JUZ-OL.js} +2 -2
- package/web/app/immutable/chunks/{D9qYrFLr.js → B8mLANMy.js} +1 -1
- package/web/app/immutable/chunks/{CQlclm_i.js → BCFbCagC.js} +1 -1
- package/web/app/immutable/chunks/{CdEtW7wp.js → BCPDBuLJ.js} +1 -1
- package/web/app/immutable/chunks/{xpCT4rnW.js → BHBAtBBB.js} +1 -1
- package/web/app/immutable/chunks/{Bxc57npw.js → BJwk8LqM.js} +1 -1
- package/web/app/immutable/chunks/{BnDVzHAF.js → BLFT0vk0.js} +1 -1
- package/web/app/immutable/chunks/{Cv6pFp-w.js → BME8wn-Y.js} +1 -1
- package/web/app/immutable/chunks/{Bn4hj7HG.js → BMoKffXR.js} +1 -1
- package/web/app/immutable/chunks/{CjOWZNUy.js → BOlugeJj.js} +1 -1
- package/web/app/immutable/chunks/{RNQdr-NN.js → BPDNj0Ug.js} +1 -1
- package/web/app/immutable/chunks/{CeHlFtmN.js → BSZTRNsD.js} +1 -1
- package/web/app/immutable/chunks/{CgOfeXf8.js → BUVJimmV.js} +1 -1
- package/web/app/immutable/chunks/{D7y4iPD0.js → BZBudGQG.js} +1 -1
- package/web/app/immutable/chunks/{3q61Z6zu.js → B_vj7xxI.js} +1 -1
- package/web/app/immutable/chunks/{p20Ma5Ub.js → Bb0plfAx.js} +1 -1
- package/web/app/immutable/chunks/{C4Zcz5ig.js → BbJXkiov.js} +1 -1
- package/web/app/immutable/chunks/{Cbe4LDCb.js → BbNzaCQR.js} +1 -1
- package/web/app/immutable/chunks/{DdZVLxLI.js → BctbI4aU.js} +1 -1
- package/web/app/immutable/chunks/{B2SAFlE_.js → BeQ1MqDU.js} +1 -1
- package/web/app/immutable/chunks/{aWlYJ1qq.js → BeddIW6i.js} +1 -1
- package/web/app/immutable/chunks/{O_LhoKyf.js → Bf4Ffzqn.js} +1 -1
- package/web/app/immutable/chunks/{B8N5zbP-.js → BfS0Q-nX.js} +1 -1
- package/web/app/immutable/chunks/{4LCvEsVS.js → BfnrA5Ab.js} +1 -1
- package/web/app/immutable/chunks/{Dj9OdxPP.js → Bmq5LtFr.js} +1 -1
- package/web/app/immutable/chunks/{C68FzyYL.js → BmufqNuq.js} +1 -1
- package/web/app/immutable/chunks/{fsCYHFC5.js → BnWH1iQz.js} +1 -1
- package/web/app/immutable/chunks/{qsyNpi2_.js → BnoRvwv3.js} +1 -1
- package/web/app/immutable/chunks/{BIGmpOjZ.js → Bp8wUB3U.js} +1 -1
- package/web/app/immutable/chunks/Bpruhzz0.js +4 -0
- package/web/app/immutable/chunks/{CqwbuddS.js → Bq3GTaKG.js} +1 -1
- package/web/app/immutable/chunks/{9JjZRepm.js → BqJHaeQw.js} +1 -1
- package/web/app/immutable/chunks/{YIljg4QC.js → BrEqoZ1p.js} +1 -1
- package/web/app/immutable/chunks/{CfHaLL96.js → BrHwmqrG.js} +1 -1
- package/web/app/immutable/chunks/{DZ2EweHv.js → BrhmFCB4.js} +1 -1
- package/web/app/immutable/chunks/{ALbX902-.js → BuEHStYX.js} +1 -1
- package/web/app/immutable/chunks/{DWvbS4mu.js → BvzONeHW.js} +1 -1
- package/web/app/immutable/chunks/{BsKoK3Rk.js → Bwxf2JuH.js} +1 -1
- package/web/app/immutable/chunks/{2LPpSBFe.js → ByIRYR8A.js} +1 -1
- package/web/app/immutable/chunks/{Du9ULB4g.js → BzoF1_ij.js} +1 -1
- package/web/app/immutable/chunks/{oTkHTTGI.js → C-OvZCj_.js} +1 -1
- package/web/app/immutable/chunks/{B5WfnJ_I.js → C24Rzfzk.js} +1 -1
- package/web/app/immutable/chunks/{BsNGkCax.js → C2pKnlEJ.js} +1 -1
- package/web/app/immutable/chunks/{CG-WEY6g.js → C3jNWf9W.js} +1 -1
- package/web/app/immutable/chunks/{B78OjmQ3.js → C5p3cAYv.js} +1 -1
- package/web/app/immutable/chunks/{BdvBYYZC.js → C5qP0fL9.js} +1 -1
- package/web/app/immutable/chunks/{QOLdaLP0.js → C6AX083-.js} +1 -1
- package/web/app/immutable/chunks/{DHLYr2dR.js → C6FMFHeq.js} +1 -1
- package/web/app/immutable/chunks/{BCiyShif.js → CAE5fLft.js} +1 -1
- package/web/app/immutable/chunks/{BxKmCVSh.js → CB76QYmX.js} +1 -1
- package/web/app/immutable/chunks/{DQprfQGN.js → CCYqEJG1.js} +1 -1
- package/web/app/immutable/chunks/{DcOGngFl.js → CGid_txv.js} +1 -1
- package/web/app/immutable/chunks/{Uvf94Vit.js → CGy8AR53.js} +1 -1
- package/web/app/immutable/chunks/{BgX6IJDk.js → CHq8gooQ.js} +1 -1
- package/web/app/immutable/chunks/{CEiokx4X.js → CHwcICZW.js} +1 -1
- package/web/app/immutable/chunks/{B_IE7AMR.js → CK1AF7GU.js} +1 -1
- package/web/app/immutable/chunks/{BhBL2il-.js → CL28-RkP.js} +1 -1
- package/web/app/immutable/chunks/{VwRqUxpW.js → CLBb9J0e.js} +1 -1
- package/web/app/immutable/chunks/{B5NXv3LV.js → CMAxIbm4.js} +6 -6
- package/web/app/immutable/chunks/{Ov_SEXEY.js → CMUt7G5B.js} +1 -1
- package/web/app/immutable/chunks/{kpgdVhmB.js → COgknoIp.js} +1 -1
- package/web/app/immutable/chunks/{BHwB2t2J.js → CQcnUt15.js} +6 -6
- package/web/app/immutable/chunks/{C5RdKv5y.js → CSEB8cDa.js} +1 -1
- package/web/app/immutable/chunks/{l9lbU6dU.js → CSKprktf.js} +1 -1
- package/web/app/immutable/chunks/{hTe-_Fjh.js → CXsEQ4Fe.js} +3 -3
- package/web/app/immutable/chunks/{ChOA9PWi.js → C_CE49CT.js} +1 -1
- package/web/app/immutable/chunks/{Cg71xtru.js → C_m_o9vM.js} +1 -1
- package/web/app/immutable/chunks/{CN6UuCI4.js → Cae3uxuh.js} +2 -2
- package/web/app/immutable/chunks/{vkDSSzeI.js → Caf4tDH7.js} +1 -1
- package/web/app/immutable/chunks/{B-jWalbO.js → CeWSuA2o.js} +1 -1
- package/web/app/immutable/chunks/{CJPP3n_b.js → ChBqCTy0.js} +1 -1
- package/web/app/immutable/chunks/{CnT2T-Bp.js → Cix_mnLj.js} +4 -4
- package/web/app/immutable/chunks/{CusMGTEg.js → CmWV3gyr.js} +1 -1
- package/web/app/immutable/chunks/{BAEKjYyz.js → CnLkqvzY.js} +1 -1
- package/web/app/immutable/chunks/{D61mreVc.js → Cniog18G.js} +1 -1
- package/web/app/immutable/chunks/{cKTNBTNE.js → Cnlrbhbh.js} +1 -1
- package/web/app/immutable/chunks/{B0jdpkVd.js → CpiOwqpL.js} +1 -1
- package/web/app/immutable/chunks/{DGWxO_aL.js → CqTutsn0.js} +1 -1
- package/web/app/immutable/chunks/{CNG6DDdt.js → CrsB8npl.js} +1 -1
- package/web/app/immutable/chunks/{B5VfU0KM.js → CuYFxjMF.js} +1 -1
- package/web/app/immutable/chunks/{3sa2ZSPC.js → Cui_1F-9.js} +1 -1
- package/web/app/immutable/chunks/{zln0bEou.js → Cx463bih.js} +1 -1
- package/web/app/immutable/chunks/{Ds-FLOE0.js → CxFDPuIk.js} +1 -1
- package/web/app/immutable/chunks/{DM4MRAyE.js → CyGw7JU5.js} +1 -1
- package/web/app/immutable/chunks/{DyjYgqtH.js → CyMVqmzv.js} +1 -1
- package/web/app/immutable/chunks/{HjNzRj_q.js → D0M9u_n-.js} +1 -1
- package/web/app/immutable/chunks/{CC-oK8xP.js → D2b1hcog.js} +2 -2
- package/web/app/immutable/chunks/{XgTDusK7.js → D5VLKYyC.js} +1 -1
- package/web/app/immutable/chunks/{Cic3Ymv4.js → D7KhJm9U.js} +2 -2
- package/web/app/immutable/chunks/{DAPK9slU.js → D9ScELxf.js} +1 -1
- package/web/app/immutable/chunks/{F7QETuhI.js → DC3ZkLye.js} +1 -1
- package/web/app/immutable/chunks/{BDFJ3z4C.js → DD0At2PN.js} +1 -1
- package/web/app/immutable/chunks/{B_Ngo80M.js → DD6Pkbic.js} +1 -1
- package/web/app/immutable/chunks/{laFenviK.js → DDFSWjQU.js} +3 -3
- package/web/app/immutable/chunks/{DeD2_APR.js → DGjH5-Hx.js} +1 -1
- package/web/app/immutable/chunks/{BmnDHgDT.js → DIFKHzYL.js} +1 -1
- package/web/app/immutable/chunks/{CM-RTisq.js → DIoX_b5x.js} +1 -1
- package/web/app/immutable/chunks/{PSWhBTN5.js → DK77esWJ.js} +1 -1
- package/web/app/immutable/chunks/{DKnyYiOE.js → DL9fM9Z6.js} +1 -1
- package/web/app/immutable/chunks/{B5OVBjIf.js → DNo8L_9b.js} +1 -1
- package/web/app/immutable/chunks/{BR5lR6Td.js → DOL39Ac3.js} +1 -1
- package/web/app/immutable/chunks/{BbANJKYX.js → DOpb_Wa_.js} +1 -1
- package/web/app/immutable/chunks/{DU5u4CoB.js → DPBL52wT.js} +7 -7
- package/web/app/immutable/chunks/{CMieQf0P.js → DQ04s54w.js} +1 -1
- package/web/app/immutable/chunks/{BGgB8Pc0.js → DQ070aDn.js} +2 -2
- package/web/app/immutable/chunks/{Cdv2uRTZ.js → DQayjjKQ.js} +1 -1
- package/web/app/immutable/chunks/{Dz40TuR7.js → DQkyZkjw.js} +1 -1
- package/web/app/immutable/chunks/{JktSJt1s.js → DQpQ_Eis.js} +1 -1
- package/web/app/immutable/chunks/{C9g8CU4z.js → DRbQFCiN.js} +1 -1
- package/web/app/immutable/chunks/{C9129WmZ.js → DSkl9mpQ.js} +1 -1
- package/web/app/immutable/chunks/DTosDNas.js +8 -0
- package/web/app/immutable/chunks/{D4uZwrDX.js → DXJ8guE-.js} +1 -1
- package/web/app/immutable/chunks/{BKAT2tIv.js → DYiKRSyK.js} +1 -1
- package/web/app/immutable/chunks/{Cc8gV_FE.js → DZzZGRg-.js} +1 -1
- package/web/app/immutable/chunks/{BY3DTY8F.js → DauuhR4o.js} +1 -1
- package/web/app/immutable/chunks/{F9nw4iUp.js → DbulPCWG.js} +1 -1
- package/web/app/immutable/chunks/{C6RQmr0V.js → DdMy5hhm.js} +1 -1
- package/web/app/immutable/chunks/{DeMWATch.js → DfYC2vFl.js} +1 -1
- package/web/app/immutable/chunks/{BIY56SBV.js → Dft5YBpv.js} +1 -1
- package/web/app/immutable/chunks/{Cf1Jz9Vb.js → DiD3o6_1.js} +1 -1
- package/web/app/immutable/chunks/{D6eVIgjz.js → Dj-i-4vt.js} +1 -1
- package/web/app/immutable/chunks/{-4iKCYSl.js → Djhs3H6B.js} +1 -1
- package/web/app/immutable/chunks/{pUHkzJ_d.js → Dm08LoPV.js} +1 -1
- package/web/app/immutable/chunks/{B-34RgWF.js → DojlGzur.js} +1 -1
- package/web/app/immutable/chunks/{CJlBFmXK.js → DpTBUsJF.js} +1 -1
- package/web/app/immutable/chunks/{C4lY6YLh.js → DssISSPU.js} +1 -1
- package/web/app/immutable/chunks/{DuXpwSkB.js → DvgbaoNK.js} +1 -1
- package/web/app/immutable/chunks/{BOFk1KrL.js → DvxEHPPT.js} +1 -1
- package/web/app/immutable/chunks/{Bz08MgGK.js → DyfUN8R7.js} +1 -1
- package/web/app/immutable/chunks/{CcDZ8sih.js → DzjRhthn.js} +4 -4
- package/web/app/immutable/chunks/{BCYRUItZ.js → FSpiE1wW.js} +4 -4
- package/web/app/immutable/chunks/{CcFGFqFC.js → FhGlrjm8.js} +1 -1
- package/web/app/immutable/chunks/{ChMhvUux.js → H3_j1RTy.js} +1 -1
- package/web/app/immutable/chunks/{DvDXb3dW.js → HOnA76CN.js} +1 -1
- package/web/app/immutable/chunks/{DoIwXvY5.js → HgUF9JxD.js} +1 -1
- package/web/app/immutable/chunks/{BwqCA_Tg.js → LcC8t7uh.js} +1 -1
- package/web/app/immutable/chunks/{CQ8xUw8b.js → NiM-1eU3.js} +1 -1
- package/web/app/immutable/chunks/{BwixslcF.js → OOZgSySO.js} +1 -1
- package/web/app/immutable/chunks/{BaWkgFPr.js → OduqxoGp.js} +1 -1
- package/web/app/immutable/chunks/{BkBZtLYF.js → PCjNYuXW.js} +1 -1
- package/web/app/immutable/chunks/Pd6GM4gY.js +1 -0
- package/web/app/immutable/chunks/{DrI7rzCm.js → QEDJCahU.js} +1 -1
- package/web/app/immutable/chunks/{CaJjlkv1.js → QLIsYm_0.js} +1 -1
- package/web/app/immutable/chunks/{TKnaMJht.js → QPnNKbqJ.js} +1 -1
- package/web/app/immutable/chunks/{De60mY1u.js → QjTgQQZx.js} +1 -1
- package/web/app/immutable/chunks/{pqiENG4w.js → RykOFORR.js} +1 -1
- package/web/app/immutable/chunks/{DES0UXLU.js → W48e0TcX.js} +1 -1
- package/web/app/immutable/chunks/{Bluyq349.js → Xsgb18SC.js} +1 -1
- package/web/app/immutable/chunks/{CjOA3fQ_.js → YlwMMeOs.js} +1 -1
- package/web/app/immutable/chunks/{DJeS0Z6Z.js → Z0VS8LLQ.js} +1 -1
- package/web/app/immutable/chunks/{Bg8XhRuy.js → dbgkJ9GM.js} +1 -1
- package/web/app/immutable/chunks/{CbQJkQ1_.js → eFMkdoaf.js} +1 -1
- package/web/app/immutable/chunks/{BTRxaITj.js → es3FqSjg.js} +1 -1
- package/web/app/immutable/chunks/{l6-BV5ui.js → j1f7tS2i.js} +1 -1
- package/web/app/immutable/chunks/{bb6KeZoT.js → jvKdDF7D.js} +1 -1
- package/web/app/immutable/chunks/{DLOFCVO4.js → pRcFjb-H.js} +1 -1
- package/web/app/immutable/chunks/{CN1yc9sw.js → rgwCePpO.js} +1 -1
- package/web/app/immutable/chunks/{b7qEBWdv.js → u-Y0Tv7i.js} +1 -1
- package/web/app/immutable/chunks/{Dxitz0gG.js → umDdblid.js} +1 -1
- package/web/app/immutable/chunks/{BhIrT2jr.js → vGBd4whl.js} +2 -2
- package/web/app/immutable/chunks/{gn8kmMF6.js → vKQIfgIp.js} +1 -1
- package/web/app/immutable/chunks/{qk0mFpjO.js → x1zid8su.js} +1 -1
- package/web/app/immutable/chunks/{nvAK9EyO.js → xHA823KN.js} +1 -1
- package/web/app/immutable/chunks/{lN-utS8K.js → xpSH95ot.js} +1 -1
- package/web/app/immutable/chunks/{CU9uaZDq.js → zcEXOR-1.js} +1 -1
- package/web/app/immutable/entry/{app.BvKW_t2N.js → app.DzBvG1_l.js} +2 -2
- package/web/app/immutable/entry/start.CErE1GCU.js +1 -0
- package/web/app/immutable/nodes/{0.BYMSP7Y-.js → 0.C2zst7i8.js} +1 -1
- package/web/app/immutable/nodes/{1.DIEji4Js.js → 1.BIkIikjL.js} +1 -1
- package/web/app/immutable/nodes/{10.DvTvrgji.js → 10.NQQ6RXJ5.js} +1 -1
- package/web/app/immutable/nodes/{14.CJs3OY3_.js → 14.DjgXWnV3.js} +1 -1
- package/web/app/immutable/nodes/{16.DsO7YO_c.js → 16.DIpAzx7I.js} +2 -2
- package/web/app/immutable/nodes/{2.Cht0dQl2.js → 2.D39xDr6a.js} +3 -3
- package/web/app/immutable/nodes/{3.BGeidrSE.js → 3.CXiy3cZ4.js} +1 -1
- package/web/app/immutable/nodes/{4.iguZO2rl.js → 4.Dc4411ZQ.js} +1 -1
- package/web/app/immutable/nodes/{5.BppWO1IB.js → 5.p_n2sq1_.js} +1 -1
- package/web/app/immutable/nodes/{6.ChXOvT3x.js → 6.D6xC5nhC.js} +1 -1
- package/web/app/immutable/nodes/{7.CgsIeK3J.js → 7.DXE6hDOy.js} +1 -1
- package/web/app/immutable/nodes/{8.Bq2NzD4c.js → 8.BU4_235n.js} +11 -11
- package/web/app/immutable/nodes/{9.CvEBRJEV.js → 9.CYdkB-g-.js} +1 -1
- package/web/app/version.json +1 -1
- package/web/generated/paraglide.js +8 -8
- package/web/index.html +10 -10
- package/web/app/immutable/assets/0.Racpq4cy.css +0 -1
- package/web/app/immutable/chunks/172GvQgx.js +0 -4
- package/web/app/immutable/chunks/BZXl3la6.js +0 -1
- package/web/app/immutable/chunks/CDuyWy4D.js +0 -3
- package/web/app/immutable/chunks/DNOilvOO.js +0 -8
- package/web/app/immutable/entry/start.CQ7TZDH6.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as vr,ad as So,a as f,ag as ir}from"./DU5u4CoB.js";import{g as A}from"./BHwB2t2J.js";var cr=5,nn=1e-5,on=1e-6;function _e(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}A(_e,"buildSegmentList");f(_e,"buildSegmentList");function Co(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,a=o.x-n.x,l=o.y-n.y,d=s*l-r*a;if(d===0)return null;const i=n.x-t.x,g=n.y-t.y,x=(i*l-g*a)/d,C=(i*r-g*s)/d;return x<=on||x>=1-on||C<=on||C>=1-on?null:{point:{x:t.x+x*s,y:t.y+x*r},tA:x,tB:C}}A(Co,"segmentIntersection");f(Co,"segmentIntersection");function an(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}A(an,"isHorizontalSeg");f(an,"isHorizontalSeg");function vo(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=_e(o.points);for(let r=n+1;r<t.length;r++){const a=t[r],l=_e(a.points);for(const[d,i]of s.entries())for(const[g,x]of l.entries()){const C=Co(i.a,i.b,x.a,x.b);if(!C)continue;const h=an(i),p=an(x);(h!==p?h:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:a.id,segIndex:d,t:C.tA,point:C.point}):e.push({jumpEdgeId:a.id,otherEdgeId:o.id,segIndex:g,t:C.tB,point:C.point})}}}return e}A(vo,"findEdgeIntersections");f(vo,"findEdgeIntersections");function re(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}A(re,"fmt");f(re,"fmt");function Ce(t){return`${re(t.x)},${re(t.y)}`}A(Ce,"pointToString");f(Ce,"pointToString");function Lo(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}A(Lo,"getArcSweepFlag");f(Lo,"getArcSweepFlag");var Lr=.001;function To(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&ir[e.arrowTypeStart];if(o){const r=t[0],a=t[1],l=Math.atan2(a.y-r.y,a.x-r.x);n[0].x=r.x+o*Math.cos(l),n[0].y=r.y+o*Math.sin(l)}const s=e.arrowTypeEnd&&ir[e.arrowTypeEnd];if(s){const r=t.length,a=t[r-2],l=t[r-1],d=Math.atan2(l.y-a.y,l.x-a.x);n[r-1].x=l.x-s*Math.cos(d),n[r-1].y=l.y-s*Math.sin(d)}return n}A(To,"applyMarkerOffsets");f(To,"applyMarkerOffsets");function Eo(t,e,n,o,s){const r=t.point.x,a=t.point.y,l={x:r-e*t.r,y:a-n*t.r},d={x:r+e*t.r,y:a+n*t.r},i=[`L${Ce(l)}`];return s==="arc"?i.push(`A${re(t.r)},${re(t.r)} 0 0 ${o} ${Ce(d)}`):i.push(`M${Ce(d)}`),i}A(Eo,"emitJump");f(Eo,"emitJump");function ln(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,a=n.x-e.x,l=n.y-e.y,d=Math.hypot(s,r),i=Math.hypot(a,l);if(d<nn||i<nn)return null;const g=s/d,x=r/d,C=a/i,h=l/i,p=g*C+x*h,c=Math.max(-1,Math.min(1,p)),y=Math.acos(c);if(y<nn||Math.abs(Math.PI-y)<nn)return null;const v=Math.min(o/Math.sin(y/2),d/2,i/2);return{startX:e.x-g*v,startY:e.y-x*v,endX:e.x+C*v,endY:e.y+h*v,ctrlX:e.x,ctrlY:e.y,cutLen:v}}A(ln,"computeRoundedCorner");f(ln,"computeRoundedCorner");function wo(t,e,n){const o=t.points;if(o.length<2)return"";const s=To(o,t),r=t.curve==="rounded",a=_e(s),l=new Map;for(const i of e){const g=a[i.segIndex];if(!g)continue;const x=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),C=l.get(i.segIndex)??[];C.push({t:i.t,point:i.point,d:i.t*x,r:n.jumpRadius}),l.set(i.segIndex,C)}const d=[`M${Ce(s[0])}`];for(let i=0;i<a.length;i++){const g=a[i],x=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),C=x===0?0:(g.b.x-g.a.x)/x,h=x===0?0:(g.b.y-g.a.y)/x,p=Lo(g);let c=0;if(r&&i>0){const T=ln(s[i-1],s[i],s[i+1]??s[i],cr);T&&(c=T.cutLen)}let y=x,v=null;r&&i<a.length-1&&(v=ln(s[i],s[i+1],s[i+2]??s[i+1],cr),v&&(y=x-v.cutLen));const M=[...l.get(i)??[]].sort((T,E)=>T.t-E.t);for(const T of M)T.r=Math.min(T.r,T.d-c,y-T.d);for(let T=0;T<M.length-1;T++){const E=M[T+1].d-M[T].d;if(M[T].r+M[T+1].r>E){const m=E/2;M[T].r=Math.min(M[T].r,m),M[T+1].r=Math.min(M[T+1].r,m)}}for(const T of M)T.r<Lr||d.push(...Eo(T,C,h,p,n.jumpStyle));r&&v?(d.push(`L${re(v.startX)},${re(v.startY)}`),d.push(`Q${re(v.ctrlX)},${re(v.ctrlY)} ${re(v.endX)},${re(v.endY)}`)):d.push(`L${Ce(g.b)}`)}return d.join(" ")}A(wo,"rewriteEdgePath");f(wo,"rewriteEdgePath");function Ro(t){return/^[\d\s+,.LMelm-]*$/.test(t)}A(Ro,"isStraightPath");f(Ro,"isStraightPath");function Ao(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}A(Ao,"curveSupportsLineHops");f(Ao,"curveSupportsLineHops");function Oo(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}A(Oo,"decodeDataPoints");f(Oo,"decodeDataPoints");function No(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const i of e)s.set(i.id,i);const r=[],a=new Map;for(const i of e){const g=typeof CSS<"u"&&CSS.escape?CSS.escape(i.id):i.id,x=o.querySelector(`path[data-id="${g}"]`);if(!x)continue;a.set(i.id,x);const h=Oo(x.getAttribute("data-points"))??i.points;r.push({...i,points:h})}const l=vo(r);if(l.length===0)return;const d=new Map;for(const i of l){const g=d.get(i.jumpEdgeId)??[];g.push(i),d.set(i.jumpEdgeId,g)}for(const i of r){const g=d.get(i.id);if(!g||g.length===0)continue;const C=s.get(i.id)?.curve;if(C!==void 0&&!Ao(C))continue;const h=a.get(i.id);if(!h)continue;if(C===void 0){const T=h.getAttribute("d")??"";if(!Ro(T))continue}const p=h.getAttribute("style")??"",c=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(p),y=c?Number.parseFloat(c[1]):null,v=c?Number.parseFloat(c[2]):null,M=wo(i,g,n);if(h.setAttribute("d",M),y!==null&&v!==null&&typeof h.getTotalLength=="function"){const T=h.getTotalLength(),E=Math.max(0,T-y-v),m=`0 ${y} ${E} ${v}`,I=p.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${m};`).replace(/;\s*;+/g,";");h.setAttribute("style",I)}}}A(No,"applyLineJumpsToSvg");f(No,"applyLineJumpsToSvg");function Bo(t,{measure:e}){const n=t.config?.swimlane?.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(r=>Array.isArray(r.points)&&r.points.length>=2).map(r=>({id:r.id,points:r.points,curve:r.curve,arrowTypeStart:r.arrowTypeStart,arrowTypeEnd:r.arrowTypeEnd}));No(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}A(Bo,"applySwimlaneLineJumps");f(Bo,"applySwimlaneLineJumps");var xo="__swimlane_default__",Tr=21,ar=20;function dn(t){return Math.max(t.padding??ar,ar)}A(dn,"topLaneHorizontalPadding");f(dn,"topLaneHorizontalPadding");function Po(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 a=n-s/2,l=Math.min(r,n+s/2),d=Math.min(Tr,Math.max(0,l-a)),i=a+d;if(i<=a){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:a,bottom:i}}A(Po,"assignTopLaneTitleRect");f(Po,"assignTopLaneTitleRect");function ko(t){const e=t.direction,n=t.nodes??=[];for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===xo);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:xo,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=xo}A(ko,"prepareLayoutForSwimlanes");f(ko,"prepareLayoutForSwimlanes");function Fo(t){const e=new Map;for(const d of t.nodes??[])e.set(d.id,d);const n=[];for(const d of t.edges??[]){const i=typeof d.start=="string"?d.start:void 0,g=typeof d.end=="string"?d.end:void 0;!i||!g||d.labelNodeId||n.push({id:d.id,src:i,dst:g,ref:d})}const o=t.nodes??[],s=o.filter(d=>d.isGroup),r=o.filter(d=>!d.isGroup);return{nodes:[...[...s].reverse(),...r].map(d=>d.id),edges:n,layout:t,nodeById:e}}A(Fo,"toGraphView");f(Fo,"toGraphView");function _o(t,e,n,o){const{layout:s}=t,r=t.nodeById,a=o?.layerGap??100,l=o?.nodeGap??40;let d=0;for(const C of e.layers){let h=0;for(const p of C){const c=r.get(p);if(!c){h++;continue}c.layer=d,c.order=h;const y=n.x[p]??h*l,v=n.y[p]??d*a;c.x=y,c.y=v,h++}d++}const i=s.nodes??[],g=new Map,x=[];for(const C of i){if(!C?.isGroup)continue;C.parentId||x.push(C);const h=i.filter(M=>M.parentId===C.id);let p=1/0,c=-1/0,y=1/0,v=-1/0;for(const M of h){const T=M.x??n.x[M.id],E=M.y??n.y[M.id],m=M.width??0,I=M.height??0;T!=null&&E!=null&&(p=Math.min(p,T-m/2),c=Math.max(c,T+m/2),y=Math.min(y,E-I/2),v=Math.max(v,E+I/2))}if(p===1/0||y===1/0)C.x=C.x??0,C.y=C.y??0,C.width=C.width??0,C.height=C.height??0;else{const M=C.padding??20,T=C.parentId?M:2*dn(C),E=M,m=Math.max(0,c-p)+T,I=Math.max(0,v-y)+E,R=(p+c)/2,O=(y+v)/2;C.x=R,C.y=O,C.width=m,C.height=I,g.set(C.id,{minX:p,maxX:c,minY:y,maxY:v})}}if(x.length>0&&g.size>0){let C=1/0,h=-1/0,p=0;for(const c of x){const y=c.padding??20;y>p&&(p=y);const v=g.get(c.id);v&&(C=Math.min(C,v.minY),h=Math.max(h,v.maxY))}if(C!==1/0&&h!==-1/0){const c=Math.max(0,h-C),v=Math.max(p,36),M=c+2*v,T=(C+h)/2;for(const F of x)F.y=T,F.height=M,F.swimlaneContentTop=C;const E=[...x].sort((F,B)=>{const _=F.x??0,X=B.x??0;return _-X}),m=[],I=[],R=[];for(const F of E){const B=g.get(F.id);if(!B)continue;const _=Math.max(0,B.maxX-B.minX)+2*dn(F),X=(B.minX+B.maxX)/2;m.push(F.id),I.push(X),R.push(_)}const O=m.length;if(O>0){const F=new Map;if(O===1)F.set(m[0],R[0]);else{const B=[];for(let U=0;U<O-1;U++)B.push(I[U+1]-I[U]);const _=new Array(O);_[0]=0;for(let U=0;U<O-1;U++)_[U+1]=2*B[U]-_[U];let X=0,P=Number.POSITIVE_INFINITY;for(let U=0;U<O;U++){const Z=R[U];U%2===0?X=Math.max(X,Z-_[U]):P=Math.min(P,_[U]-Z)}let z=X;X<=P?z=(X+P)/2:z=X;for(let U=0;U<O;U++){const Z=_[U]+(U%2===0?z:-z),ht=Math.max(R[U],Z);F.set(m[U],ht)}}for(const B of x){const _=F.get(B.id);_!=null&&(B.width=_),Po(B)}}}}}A(_o,"writeBackToLayoutData");f(_o,"writeBackToLayoutData");var Er="[EdgeLabelNodes]";function Do(t){const e=[],n=[],o=new Map;for(const a of t.nodes)o.set(a.id,a);for(const a of t.edges){if(!a.label||a.label.length===0||a.isLayoutOnly||a.labelNodeId)continue;const l=a.start?o.get(a.start):void 0,d=a.end?o.get(a.end):void 0;if(!l||!d){So.warn(Er,`Edge ${a.id} has missing source or target node`);continue}const i=`edge-label-${a.start}-${a.end}-${a.id}`,x=l.parentId!==d.parentId?d.parentId:l.parentId,C={id:i,label:a.label,edgeStart:a.start??"",edgeEnd:a.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:x,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??"",...l.dir?{dir:l.dir}:{}};e.push(C),a.labelNodeId=i,a.label=void 0,a.text=void 0;const h={id:`${a.id}-to-label`,start:a.start,end:i,type:"normal",isLayoutOnly:!0},p={id:`${a.id}-from-label`,start:i,end:a.end,type:"normal",isLayoutOnly:!0};n.push(h,p)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}A(Do,"createEdgeLabelNodes");f(Do,"createEdgeLabelNodes");var Dt=.001;function Gn(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:ve(e,n,o,s)}:void 0}A(Gn,"measuredNodeRect");f(Gn,"measuredNodeRect");function zn(t){if(t.isGroup)return;const e=Gn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}A(zn,"nodeBoundsInfoFor");f(zn,"nodeBoundsInfoFor");function ee(t,e,n=Dt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}A(ee,"samePoint");f(ee,"samePoint");function dt(t,e,n=Dt){return Math.abs(t.x-e.x)<n}A(dt,"sameX");f(dt,"sameX");function ut(t,e,n=Dt){return Math.abs(t.y-e.y)<n}A(ut,"sameY");f(ut,"sameY");function Tt(t,e,n=Dt){return ut(t,e,n)&&Math.abs(t.x-e.x)>n}A(Tt,"isHorizontalSegment");f(Tt,"isHorizontalSegment");function Et(t,e,n=Dt){return dt(t,e,n)&&Math.abs(t.y-e.y)>n}A(Et,"isVerticalSegment");f(Et,"isVerticalSegment");function zt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}A(zt,"overlapLength");f(zt,"overlapLength");function ce(t,e,n=Dt){return t.horizontal&&e.horizontal&&ut(t.a,e.a,n)?zt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&dt(t.a,e.a,n)?zt(t.a.y,t.b.y,e.a.y,e.b.y):0}A(ce,"sameAxisSegmentOverlapLength");f(ce,"sameAxisSegmentOverlapLength");function Le(t,e=Dt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],a=Tt(s,r,e),l=Et(s,r,e);(a||l)&&n.push({index:o,a:s,b:r,horizontal:a,vertical:l})}return n}A(Le,"orthogonalSegmentsForPoints");f(Le,"orthogonalSegmentsForPoints");function Zt(t,e=Dt){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}A(Zt,"countOrthogonalBends");f(Zt,"countOrthogonalBends");function mt(t,e=Dt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ee(s,o,e))&&n.push({x:o.x,y:o.y})}return n}A(mt,"dedupeConsecutivePoints");f(mt,"dedupeConsecutivePoints");function $n(t,e=Dt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Tt(n,o,e)&&Et(o,s,e)&&Tt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Et(n,o,e)&&Tt(o,s,e)&&Et(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}A($n,"classifyThreeSegmentRoute");f($n,"classifyThreeSegmentRoute");function je(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),a=Math.min(t.y,e.y),l=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&l>n.top-o&&a<n.bottom+o}A(je,"segmentBoundsOverlapRect");f(je,"segmentBoundsOverlapRect");function Vn(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}A(Vn,"pointInsideRect");f(Vn,"pointInsideRect");function Ho(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}A(Ho,"rectContainsRect");f(Ho,"rectContainsRect");function De(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}A(De,"rectsOverlap");f(De,"rectsOverlap");function fn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}A(fn,"inflateRect");f(fn,"inflateRect");function ve(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}A(ve,"rectFromCenterSize");f(ve,"rectFromCenterSize");function jt(t){return Gn(t)?.rect}A(jt,"rectOfNodeBounds");f(jt,"rectOfNodeBounds");function Me(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}A(Me,"portForRectSide");f(Me,"portForRectSide");function jn(t,e,n,o,s,r=Dt){const a=e==="left"||e==="right",l=o==="left"||o==="right";if(a&&l){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(ut(t,n,r))return[t,n];const x=(t.x+n.x)/2;return[t,{x,y:t.y},{x,y:n.y},n]}if(e===o){if(ut(t,n,r))return;const x=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x,y:t.y},{x,y:n.y},n]}return}if(!a&&!l){if(e===o){if(dt(t,n,r))return;const C=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:C},{x:n.x,y:C},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(dt(t,n,r))return[t,n];const x=(t.y+n.y)/2;return[t,{x:t.x,y:x},{x:n.x,y:x},n]}if(a&&!l){const g=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,x=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return g&&x?[t,{x:n.x,y:t.y},n]:void 0}const d=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,i=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return d&&i?[t,{x:t.x,y:n.y},n]:void 0}A(jn,"buildOrthogonalPortPath");f(jn,"buildOrthogonalPortPath");function Un(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}A(Un,"buildSameSideTrackPath");f(Un,"buildSameSideTrackPath");function Ue(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=zn(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}A(Ue,"collectRealNodeBounds");f(Ue,"collectRealNodeBounds");function ue(t){const e=[],n=[];for(const o of t){const s=zn(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}A(ue,"collectNodeRectEntries");f(ue,"collectNodeRectEntries");function Xo(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,a=o.width??0,l=o.height??0;n.push({nodeId:o.id,...ve(s,r,a,l)})}return n}A(Xo,"collectLayoutNodeRects");f(Xo,"collectLayoutNodeRects");function Wn(t,e,n=Dt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),a=e.get(s);if(!(!r||!a))return{srcId:o,dstId:s,srcInfo:r,dstInfo:a,collinearX:Math.abs(r.cx-a.cx)<n,collinearY:Math.abs(r.cy-a.cy)<n}}A(Wn,"getNodePairGeometry");f(Wn,"getNodePairGeometry");function At(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&je(t,e,r.rect,-s))return!0;return!1}A(At,"segmentHitsAnyRect");f(At,"segmentHitsAnyRect");function Kn(t,e,n,o,s=Dt,r=1e-6){const a=ut(t,e,s),l=dt(t,e,s),d=ut(n,o,s),i=dt(n,o,s);if(a&&d||l&&i||!(a||l)||!(d||i))return!1;const g=a?{a:t,b:e}:{a:n,b:o},x=l?{a:t,b:e}:{a:n,b:o},C=g.a.y,h=Math.min(g.a.x,g.b.x),p=Math.max(g.a.x,g.b.x),c=x.a.x,y=Math.min(x.a.y,x.b.y),v=Math.max(x.a.y,x.b.y);if(c<h||c>p||C<y||C>v)return!1;const M=Math.abs(c-g.a.x)<r&&Math.abs(C-g.a.y)<r||Math.abs(c-g.b.x)<r&&Math.abs(C-g.b.y)<r,T=Math.abs(c-x.a.x)<r&&Math.abs(C-x.a.y)<r||Math.abs(c-x.b.x)<r&&Math.abs(C-x.b.y)<r;return!(M&&T)}A(Kn,"orthogonalSegmentsCross");f(Kn,"orthogonalSegmentsCross");function Yo(t,e,n,o,s=Dt){const r=ut(t,e,s),a=dt(t,e,s),l=ut(n,o,s),d=dt(n,o,s);return a&&d&&dt(t,n,s)?zt(t.y,e.y,n.y,o.y)>s:r&&l&&ut(t,n,s)?zt(t.x,e.x,n.x,o.x)>s:!1}A(Yo,"sameAxisSegmentsOverlap");f(Yo,"sameAxisSegmentsOverlap");function He(t,e,n,o,{epsilon:s=Dt,skipDegenerateOther:r=!1}={}){for(const a of n){if(a===o||a.isLayoutOnly)continue;const l=a.points;if(!(!l||l.length<2))for(let d=0;d<l.length-1;d++){const i=l[d],g=l[d+1];if(!(r&&ee(i,g,s))&&(Kn(t,e,i,g,s)||Yo(t,e,i,g,s)))return!0}}return!1}A(He,"segmentConflictsWithAnyEdge");f(He,"segmentConflictsWithAnyEdge");function de(t,e,n,o,s=Dt){const r=ut(t,e,s),a=dt(t,e,s),l=ut(n,o,s),d=dt(n,o,s);if(!(r&&d||a&&l))return!1;const i=r?{a:t,b:e}:{a:n,b:o},g=r?{a:n,b:o}:{a:t,b:e},x=i.a.y,C=Math.min(i.a.x,i.b.x),h=Math.max(i.a.x,i.b.x),p=g.a.x,c=Math.min(g.a.y,g.b.y),y=Math.max(g.a.y,g.b.y);return p>C+s&&p<h-s&&x>c+s&&x<y-s}A(de,"orthogonalSegmentsStrictlyCross");f(de,"orthogonalSegmentsStrictlyCross");function un(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Dt&&t<s-Dt}A(un,"strictlyBetween");f(un,"strictlyBetween");function Go(t,e,n){return dt(t,e)&&dt(e,n)?un(e.y,t.y,n.y):ut(t,e)&&ut(e,n)?un(e.x,t.x,n.x):!1}A(Go,"isCollinearIntermediate");f(Go,"isCollinearIntermediate");function zo(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],a=o+1<t.length?t[o+1]:void 0;if(s&&a){if(ee(s,a)){o++,e=!0;continue}if(Go(s,r,a)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}A(zo,"simplifyPolylineOnce");f(zo,"simplifyPolylineOnce");function Xe(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!dt(s,r)&&!ut(s,r)){const a=e.length>=2?e[e.length-2]:void 0,d=(a?dt(a,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(d)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ee(s,o))&&n.push(o)}return n}A(Xe,"orthogonalizePolyline");f(Xe,"orthogonalizePolyline");function ae(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=zo(e);if(e=o.points,!o.changed)break}return e}A(ae,"simplifyPolyline");f(ae,"simplifyPolyline");var ot=.001,wr=.5,lr=4;function Jn(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?jt(s):void 0,dstRect:r?jt(r):void 0}}A(Jn,"endpointContextFor");f(Jn,"endpointContextFor");function $o(t,e,n){if(ut(t,e,ot))return{x:t.x<n.left?n.left:n.right,y:t.y};if(dt(t,e,ot)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}A($o,"segmentEnterPoint");f($o,"segmentEnterPoint");function hn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Vn(t[s],e,wr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const a=$o(t[s],t[r],e);return n?[a,...t.slice(s)]:[...t.slice(0,s+1),a]}A(hn,"clipEndpoint");f(hn,"clipEndpoint");function Vo(t,e){for(const n of t){const o=Jn(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=hn(s,o.srcRect,!0)),o.dstRect&&(s=hn(s,o.dstRect,!1)),s=ae(Xe(s)),s=qn(s,o.srcRect,o.dstRect),o.edge.points=ae(Xe(s))}}A(Vo,"clipEdgeEndpointsToNodeBoundaries");f(Vo,"clipEdgeEndpointsToNodeBoundaries");function gn(t,e,n,o=!1){if(ut(t,e,ot)){if(e.y<n.top-ot||e.y>n.bottom+ot)return e;if(o){if(t.x<n.left-ot)return{x:n.left,y:t.y};if(t.x>n.right+ot)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(dt(t,e,ot)){if(e.x<n.left-ot||e.x>n.right+ot)return e;if(o){if(t.y<n.top-ot)return{x:t.x,y:n.top};if(t.y>n.bottom+ot)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}A(gn,"snapEndpointToBoundary");f(gn,"snapEndpointToBoundary");function Ye(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ee(r,o,ot))return r}return t[e+n]}A(Ye,"firstDistinctAdjacent");f(Ye,"firstDistinctAdjacent");function Ge(t,e){const n=t+lr,o=e-lr;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}A(Ge,"cornerClearanceRange");f(Ge,"cornerClearanceRange");function pn(t,e,n){const{lo:o,hi:s}=Ge(e,n);return Math.min(s,Math.max(o,t))}A(pn,"clampToCornerClearance");f(pn,"clampToCornerClearance");function jo(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}A(jo,"intersectRanges");f(jo,"intersectRanges");function mn(t,e){return e==="left"||e==="right"?Ge(t.top,t.bottom):Ge(t.left,t.right)}A(mn,"clearanceRangeForSide");f(mn,"clearanceRangeForSide");function ze(t,e,n){const o=t.y>=n.top-ot&&t.y<=n.bottom+ot,s=t.x>=n.left-ot&&t.x<=n.right+ot;if(ut(t,e,ot)&&o){if(Math.abs(t.x-n.left)<ot)return"left";if(Math.abs(t.x-n.right)<ot)return"right"}if(dt(t,e,ot)&&s){if(Math.abs(t.y-n.top)<ot)return"top";if(Math.abs(t.y-n.bottom)<ot)return"bottom"}}A(ze,"terminalSideForSegment");f(ze,"terminalSideForSegment");function Be(t){return t==="left"||t==="right"}A(Be,"isHorizontalSide");f(Be,"isHorizontalSide");function Uo(t,e,n,o,s){const r=[],a=n?ze(t,e,n):void 0,l=o?ze(e,t,o):void 0;return n&&a&&Be(a)===s&&r.push(mn(n,a)),o&&l&&Be(l)===s&&r.push(mn(o,l)),r.length>0?jo(r):void 0}A(Uo,"straightClearanceRange");f(Uo,"straightClearanceRange");function yn(t,e,n,o,s){const r=Uo(t,e,n,o,s);if(!r)return;const a=s?t.y:t.x,l=Math.min(r.hi,Math.max(r.lo,a));if(!(Math.abs(l-a)<ot))return s?[{x:t.x,y:l},{x:e.x,y:l}]:[{x:l,y:t.y},{x:l,y:e.y}]}A(yn,"clearStraightEndpointCornerAxis");f(yn,"clearStraightEndpointCornerAxis");function qn(t,e,n){if(t.length!==2)return t;const[o,s]=t;return ut(o,s,ot)?yn(o,s,e,n,!0)??t:dt(o,s,ot)?yn(o,s,e,n,!1)??t:t}A(qn,"clearStraightEndpointCornerConnections");f(qn,"clearStraightEndpointCornerConnections");function Wo(t,e,n){return Be(n)?{x:t.x,y:pn(t.y,e.top,e.bottom)}:{x:pn(t.x,e.left,e.right),y:t.y}}A(Wo,"cornerClearedEndpoint");f(Wo,"cornerClearedEndpoint");function Ko(t,e,n,o,s,r){const a=t.map(l=>({...l}));for(let l=e;l>=0&&l<t.length;l+=n){const d=t[l];if(r&&!ut(d,o,ot)||!r&&!dt(d,o,ot))break;r?a[l].y=s.y:a[l].x=s.x}return a}A(Ko,"moveCollinearEndpointRun");f(Ko,"moveCollinearEndpointRun");function xn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],a=Ye(t,o,s);if(!a)return t;const l=ze(r,a,e);if(!l)return t;const d=Be(l),i=Wo(r,e,l);return ee(r,i,ot)?t:Ko(t,o,s,r,i,d)}A(xn,"clearEndpointCornerConnection");f(xn,"clearEndpointCornerConnection");function bn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ot&&Math.max(t.x,e.x)<=n.right+ot,s=Math.min(t.y,e.y)>=n.top-ot&&Math.max(t.y,e.y)<=n.bottom+ot;if(Math.abs(t.y-n.top)<ot&&Math.abs(e.y-n.top)<ot&&o)return"top";if(Math.abs(t.y-n.bottom)<ot&&Math.abs(e.y-n.bottom)<ot&&o)return"bottom";if(Math.abs(t.x-n.left)<ot&&Math.abs(e.x-n.left)<ot&&s)return"left";if(Math.abs(t.x-n.right)<ot&&Math.abs(e.x-n.right)<ot&&s)return"right"}A(bn,"borderSideForSegment");f(bn,"borderSideForSegment");function Mn(t,e,n,o){switch(t){case"top":return dt(e,n,ot)&&n.y<o.top-ot;case"bottom":return dt(e,n,ot)&&n.y>o.bottom+ot;case"left":return ut(e,n,ot)&&n.x<o.left-ot;case"right":return ut(e,n,ot)&&n.x>o.right+ot}}A(Mn,"leavesOutward");f(Mn,"leavesOutward");function In(t,e,n){if(t.length<3)return t;if(n){const r=bn(t[0],t[1],e);return r&&Mn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=bn(t[o-1],t[o],e);return s&&Mn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}A(In,"collapseOwnBorderStub");f(In,"collapseOwnBorderStub");function Jo(t,e,n){let o=t;if(e){const r=Ye(o,0,1);if(r){const a=gn(r,o[0],e);a!==o[0]&&(o=[a,...o.slice(1)])}o=In(o,e,!0)}if(n){const r=o.length-1,a=Ye(o,r,-1);if(a){const l=gn(a,o[r],n,!0);l!==o[r]&&(o=[...o.slice(0,r),l])}o=In(o,n,!1)}const s=qn(o,e,n);return s!==o||o.length===2?s:(e&&(o=xn(o,e,!0)),n&&(o=xn(o,n,!1)),o)}A(Jo,"snapAndCollapseEndpoints");f(Jo,"snapAndCollapseEndpoints");function Sn(t,e){for(const n of t){const o=Jn(n,e,2);if(!o)continue;const s=mt(o.points,ot),r=Jo(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const a=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=a}}A(Sn,"prepareEdgeEndpointsForRenderer");f(Sn,"prepareEdgeEndpointsForRenderer");function Zn(t){return new Map(t.map(e=>[e.id,e]))}A(Zn,"buildNodeMap");f(Zn,"buildNodeMap");function qo(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!s?.isGroup)break;o=s.id,n=s.parentId}return o}A(qo,"resolveTopLevelGroupId");f(qo,"resolveTopLevelGroupId");function Cn(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!s?.isGroup)break;n++,o=s.parentId}return n}A(Cn,"groupDepth");f(Cn,"groupDepth");function Qn(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const a=r.x,l=r.y;if(typeof a!="number"||typeof l!="number")continue;const d=r.width??0,i=r.height??0;e=Math.min(e,a-d/2),n=Math.max(n,a+d/2),o=Math.min(o,l-i/2),s=Math.max(s,l+i/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}A(Qn,"boundsForChildren");f(Qn,"boundsForChildren");function Zo(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}A(Zo,"applyGroupBounds");f(Zo,"applyGroupBounds");function Qo(t){const e=Zn(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>Cn(s,e)-Cn(o,e));for(const o of n){const s=t.filter(a=>a.parentId===o.id),r=Qn(s);r&&Zo(o,r)}}A(Qo,"recomputeNestedGroupBounds");f(Qo,"recomputeNestedGroupBounds");function $e(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(d=>!d.isGroup);let r=1/0,a=-1/0;for(const d of s){const i=d[e];typeof i=="number"&&(r=Math.min(r,i),a=Math.max(a,i))}if(!Number.isFinite(r)||!Number.isFinite(a))return!1;const l=f(d=>r+a-d,"mirror");for(const d of n){const i=d[e];typeof i=="number"&&(d[e]=l(i));const g=d.groupTitleRect;g&&(d.groupTitleRect=e==="x"?{...g,left:l(g.right),right:l(g.left)}:{...g,top:l(g.bottom),bottom:l(g.top)})}for(const d of o)for(const i of d.points??[])i[e]=l(i[e]);return!0}A($e,"mirrorAxis");f($e,"mirrorAxis");function ts(t){return(t.nodes??[]).some(n=>!n.isGroup)?$e(t,"y"):!0}A(ts,"applyBtDirectionTransform");f(ts,"applyBtDirectionTransform");function es(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(P=>!P.isGroup);let r=1/0,a=1/0;for(const P of s){const z=P.x??0,U=P.y??0;z<r&&(r=z),U<a&&(a=U)}if(!Number.isFinite(r)||!Number.isFinite(a))return!1;const l=36;let d=0,i=0;for(const P of s)d+=P.width??0,i+=P.height??0;const g=d/s.length,x=i/s.length,C=x>0?Math.max(1,g/x):1;for(const P of s){const z=P.x??0,Z=((P.y??0)-a)*C+l,ht=z-r;P.x=Z,P.y=ht}for(const P of o)if(P.points)for(const z of P.points){const U=z.x,ht=(z.y-a)*C+l,yt=U-r;z.x=ht,z.y=yt}Qo(n);const h=n.filter(P=>P.isGroup&&!P.parentId);if(h.length===0)return e==="RL"&&$e(t,"x"),!0;const p=Zn(n),c=new Map;for(const P of n){if(P.isGroup)continue;const z=qo(P,p);if(!z)continue;const U=c.get(z)??[];U.push(P),c.set(z,U)}let y=0;for(const P of h){const z=P.padding??0;z>y&&(y=z)}const v=[];let M=1/0,T=-1/0;for(const P of h){const z=c.get(P.id)??[],U=Qn(z);U&&(M=Math.min(M,U.minX),T=Math.max(T,U.maxX),v.push({lane:P,contentTop:U.minY,contentBottom:U.maxY,centerY:(U.minY+U.maxY)/2}))}if(M===1/0||T===-1/0)return!0;const E=Math.max(0,T-M),m=Math.max(y,10),I=E+2*m,R=l+I,B=(M+T)/2-I/2-l,_=B+R/2,X=Math.max(y,l);v.sort((P,z)=>P.centerY-z.centerY);for(let P=0;P<v.length;P++){const z=v[P];let U,Z;if(P===0?U=z.contentTop-X:U=(v[P-1].contentBottom+z.contentTop)/2,P===v.length-1)Z=z.contentBottom+X;else{const Ft=v[P+1];Z=(z.contentBottom+Ft.contentTop)/2}const ht=Math.max(0,Z-U),yt=(U+Z)/2;z.lane.x=_,z.lane.y=yt,z.lane.width=R,z.lane.height=ht,z.lane.swimlaneContentTop=z.contentTop,z.lane.groupTitleRect={left:B,right:B+l,top:U,bottom:Z}}return e==="RL"&&$e(t,"x"),!0}A(es,"applyLrDirectionTransform");f(es,"applyLrDirectionTransform");var ie=1e-6,Rr=8,sn=Rr,Ar=[0,sn,-sn,2*sn,-2*sn];function ns(t,e){const{nodeInfoById:n,realNodeRects:o}=Ue(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const a=$n(mt(r,ie),ie);if(!a)continue;const{p3:l}=a,d=a.kind==="HVH",i=Wn(s,n,ie);if(!i)continue;const{srcId:g,dstId:x,srcInfo:C,dstInfo:h,collinearX:p,collinearY:c}=i;if(p||c)continue;let y;const v=C.rect;for(const M of Ar){let T,E,m;if(d){const _=h.cy>C.cy?v.bottom:v.top,X=C.cx+M;if(X<=v.left+ie||X>=v.right-ie)continue;T={x:X,y:_},E={x:X,y:l.y},m={x:l.x,y:l.y}}else{const _=h.cx>C.cx?v.right:v.left,X=C.cy+M;if(X<=v.top+ie||X>=v.bottom-ie)continue;T={x:_,y:X},E={x:l.x,y:X},m={x:l.x,y:l.y}}const I=ee(T,E,ie),R=ee(E,m,ie);if(I&&R||!I&&At(T,E,o,[g],1)||!R&&At(E,m,o,[x],1))continue;const O=!I&&He(T,E,t,s,{epsilon:ie,skipDegenerateOther:!0}),F=!R&&He(E,m,t,s,{epsilon:ie,skipDegenerateOther:!0});if(!(O||F)){I?y=[E,m]:R?y=[T,E]:y=[T,E,m];break}}y&&(s.points=y)}}A(ns,"portSwapToLShape");f(ns,"portSwapToLShape");function os(t,e){const{realNodeRects:r,labelNodeRects:a}=ue(e.values());for(const l of t){if(l.isLayoutOnly)continue;const d=l.points;if(!d||d.length<4)continue;const i=mt(d,.001);if(i.length<4)continue;const g=i.length-1,x=i[g],C=i[g-1],h=i[g-2],p=x.x-C.x,c=x.y-C.y,y=Math.hypot(p,c);if(y>=10||y<.001)continue;const v=C.x-h.x,M=C.y-h.y;if(Math.hypot(v,M)<.001)continue;const E=Tt(C,x,.001),m=Et(C,x,.001),I=Tt(h,C,.001),R=Et(h,C,.001);if(!(E&&R||m&&I))continue;const O=l.end,F=l.start,B=O?e.get(O):void 0;if(!B)continue;const _=B.x??0,X=B.y??0,P=jt(B);if(!P)continue;let z,U;if(R){const K=M<0;z={x:_,y:h.y},U={x:_,y:K?P.bottom:P.top}}else{const K=v>0;z={x:h.x,y:X},U={x:K?P.right:P.left,y:X}}if(At(z,U,r,O?[O]:[],-2)||At(z,U,a,[],-2))continue;if(F){const K=e.get(F),nt=K?jt(K):void 0;if(nt&&Vn(z,nt,2))continue}const Z=f((K,nt)=>`${K.x.toFixed(3)},${K.y.toFixed(3)}|${nt.x.toFixed(3)},${nt.y.toFixed(3)}`,"ownSegmentKey"),ht=new Set;for(let K=0;K<i.length-1;K++)ht.add(Z(i[K],i[K+1]));const yt=f((K,nt)=>{for(const lt of t){if(lt===l||lt.isLayoutOnly)continue;const pt=lt.points;if(!(!pt||pt.length<2))for(let bt=0;bt<pt.length-1;bt++){const Lt=pt[bt],Ut=pt[bt+1];if(!ht.has(Z(Lt,Ut))&&de(K,nt,Lt,Ut,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(yt(z,U))continue;if(g-3>=0){const K=i[g-3],nt=[F,O].filter(lt=>!!lt);if(At(K,z,r,nt,-2)||yt(K,z))continue}const Pt=[...i.slice(0,g-2),z,U];l.points=Pt;const tt=l.labelNodeId;if(tt){const K=e.get(tt);if(K){const nt=K.width??0,lt=K.height??0;if(nt>0&<>0){let pt,bt,Lt=-1;for(let Ut=0;Ut<Pt.length-1;Ut++){const Wt=Pt[Ut],Kt=Pt[Ut+1],ne=Math.hypot(Kt.x-Wt.x,Kt.y-Wt.y),Ee=ut(Wt,Kt,.001),ge=dt(Wt,Kt,.001);(Ee&&ne>=nt+2||ge&&ne>=lt+2)&&ne>Lt&&(Lt=ne,pt=(Wt.x+Kt.x)/2,bt=(Wt.y+Kt.y)/2)}pt!==void 0&&bt!==void 0&&(K.x=pt,K.y=bt)}}}}}A(os,"collapseShortTerminalStub");f(os,"collapseShortTerminalStub");var Q=.001,_t=8,ct=Le,bo=f((t,e)=>dt(t,e,Q)||ut(t,e,Q),"orthogonallyAligned");function ss(t,e){const s=f((h,p)=>{const c=h.x??0,y=h.y??0,v=p.x-c,M=p.y-y;let T=(h.width??0)/2,E=(h.height??0)/2;return Math.abs(M)*T>Math.abs(v)*E?(M<0&&(E=-E),{x:c+(M===0?0:E*v/M),y:y+E}):(v<0&&(T=-T),{x:c+T,y:y+(v===0?0:T*M/v)})},"rectIntersect"),r=f((h,p)=>{const c=mt(h.points??[]);if(c.length<2)return;const y=p?h.start:h.end,v=y?e.get(y):void 0,M=v?jt(v):void 0;if(!v||!y||!M)return;const T=p?c[0]:c[c.length-1],E=p?c[1]:c[c.length-2],m=s(v,T);let I=T;if(bo(E,m)&&(I=E),dt(m,I,Q))return{edge:h,edgeId:String(h.id??""),nodeId:y,atStart:p,orientation:"V",coord:m.x,min:Math.min(m.y,I.y),max:Math.max(m.y,I.y),boundary:m,railEnd:I,rect:M};if(ut(m,I,Q))return{edge:h,edgeId:String(h.id??""),nodeId:y,atStart:p,orientation:"H",coord:m.y,min:Math.min(m.x,I.x),max:Math.max(m.x,I.x),boundary:m,railEnd:I,rect:M}},"terminalLaneFor"),a=f((h,p)=>Math.max(0,Math.min(h.max,p.max)-Math.max(h.min,p.min)),"projectedOverlapLength"),l=f((h,p)=>h.nodeId!==p.nodeId||h.orientation!==p.orientation?!1:h.orientation==="H"?(Math.abs(h.boundary.x-h.rect.left)<1||Math.abs(h.boundary.x-h.rect.right)<1)&&dt(h.boundary,p.boundary,1):(Math.abs(h.boundary.y-h.rect.top)<1||Math.abs(h.boundary.y-h.rect.bottom)<1)&&ut(h.boundary,p.boundary,1),"sameTerminalFace"),d=f((h,p)=>h.nodeId!==p.nodeId||h.orientation!==p.orientation?!1:a(h,p)>=_t&&Math.abs(h.coord-p.coord)<.5,"exactTerminalLaneConflict"),i=f((h,p)=>{if(h.nodeId!==p.nodeId||h.orientation!==p.orientation||h.orientation!=="H"||h.atStart===p.atStart)return!1;const c=a(h,p);if(c<_t)return!1;const y=h.rect.bottom-h.rect.top;return c<y||c>2*y?!1:l(h,p)&&Math.abs(h.coord-p.coord)<16},"nearTerminalLaneConflict"),g=f((h,p)=>{const c=mt(h.edge.points??[]);if(c.length<2)return;const y=h.orientation==="V"?{x:h.boundary.x+p,y:h.boundary.y}:{x:h.boundary.x,y:h.boundary.y+p},v=h.orientation==="V"?{x:h.railEnd.x+p,y:h.railEnd.y}:{x:h.railEnd.x,y:h.railEnd.y+p};if(!f(()=>Math.abs(h.boundary.y-h.rect.top)<1||Math.abs(h.boundary.y-h.rect.bottom)<1?ut(y,h.boundary,Q)&&y.x>=h.rect.left+1&&y.x<=h.rect.right-1:Math.abs(h.boundary.x-h.rect.left)<1||Math.abs(h.boundary.x-h.rect.right)<1?dt(y,h.boundary,Q)&&y.y>=h.rect.top+1&&y.y<=h.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(h.atStart){const I=c.length>1&&ee(c[1],h.railEnd,Q),R=c.slice(I?2:1),O=R[0];return O&&!bo(O,v)?void 0:[y,v,...R]}const T=c.length>1&&ee(c[c.length-2],h.railEnd,Q),E=c.slice(0,T?-2:-1),m=E[E.length-1];if(!(m&&!bo(m,v)))return[...E,v,y]},"shiftedCandidate"),x=f(h=>{const p=h.edge,c=mt(p.points??[]);if(c.length!==2)return!1;const y=p.start,v=p.end,M=y?e.get(y):void 0,T=v?e.get(v):void 0;if(!M||!T)return!1;const E=M.x??0,m=M.y??0,I=T.x??0,R=T.y??0,[O,F]=c;return ut(O,F,Q)&&Math.abs(m-R)<1&&Math.abs(E-I)>1||dt(O,F,Q)&&Math.abs(E-I)<1&&Math.abs(m-R)>1},"laneIsStraightCollinearConnector"),C=[-7,7,-14,14,-21,21];for(let h=0;h<8;h++){const p=t.filter(y=>!y.isLayoutOnly).flatMap(y=>[r(y,!0),r(y,!1)]).filter(y=>!!y);let c=!1;for(let y=0;y<p.length&&!c;y++)for(let v=y+1;v<p.length&&!c;v++){const M=p[y],T=p[v];if(M.edge===T.edge||!(d(M,T)||i(M,T)))continue;const E=!d(M,T),m=[M,T].sort((I,R)=>{const O=x(I),F=x(R);return O!==F?Number(O)-Number(F):+!R.atStart-+!I.atStart});for(const I of m){for(const R of C){const O=g(I,R);if(!O)continue;const F=r({...I.edge,points:O},I.atStart);if(!(!F||p.some(B=>B.edge!==I.edge&&(d(F,B)||E&&i(F,B))))){I.edge.points=O,c=!0;break}}if(c)break}}if(!c)return}}A(ss,"separateSharedRenderedTerminalLanes");f(ss,"separateSharedRenderedTerminalLanes");function rs(t,e){const{realNodeRects:o,labelNodeRects:s}=ue(e.values()),r=f((l,d)=>{const i=l.start,g=l.end,x=ct(d);if(x.length!==d.length-1)return!1;const C=[i,g].filter(h=>!!h);for(const h of x)if(At(h.a,h.b,o,C,-2)||At(h.a,h.b,s,[],-2))return!1;for(const h of t){if(h===l||h.isLayoutOnly)continue;const p=h.points;if(!(!p||p.length<2)){for(const c of x)for(const y of ct(mt(p)))if(ce(c,y,.5)>=_t||de(c.a,c.b,y.a,y.b,Q))return!1}}return!0},"candidateIsSafe"),a=f((l,d)=>{if(d+4>=l.length)return;const i=l[d],g=l[d+1],x=l[d+2],C=l[d+3],h=l[d+4],p=Tt(i,g)&&Et(g,x)&&Tt(x,C)&&Et(C,h)&&dt(i,C,Q)&&dt(i,h,Q)&&dt(g,x,Q)&&(g.x-i.x)*(C.x-x.x)<0,c=Et(i,g)&&Tt(g,x)&&Et(x,C)&&Tt(C,h)&&ut(i,C,Q)&&ut(i,h,Q)&&ut(g,x,Q)&&(g.y-i.y)*(C.y-x.y)<0;if(p||c)return mt([...l.slice(0,d+1),h,...l.slice(d+5)]);if(d+5>=l.length)return;const y=l[d+5],v=Et(i,g)&&Tt(g,x)&&Et(x,C)&&Tt(C,h)&&Et(h,y)&&dt(i,h,Q)&&dt(i,y,Q)&&dt(x,C,Q)&&(x.x-g.x)*(h.x-C.x)<0,M=Tt(i,g)&&Et(g,x)&&Tt(x,C)&&Et(C,h)&&Tt(h,y)&&ut(i,h,Q)&&ut(i,y,Q)&&ut(x,C,Q)&&(x.y-g.y)*(h.y-C.y)<0;if(!(!v&&!M))return mt([...l.slice(0,d+1),y,...l.slice(d+6)])},"withoutDogleg");for(let l=0;l<8;l++){let d=!1;for(const i of t){if(i.isLayoutOnly)continue;const g=mt(i.points??[]);for(let x=0;x<=g.length-5;x++){const C=a(g,x);if(!(!C||!r(i,C))){i.points=C,d=!0;break}}if(d)break}if(!d)return}}A(rs,"collapseRedundantRectangularDoglegs");f(rs,"collapseRedundantRectangularDoglegs");function vn(t,e){const{realNodeRects:r,labelNodeRects:a}=ue(e.values()),l=t.filter(p=>!p.isLayoutOnly),d=f((p,c,y)=>mt(p===c?y??[]:p.points??[]),"pointsFor"),i=f((p,c)=>{let y=0;for(let v=0;v<l.length;v++){const M=ct(d(l[v],p,c));for(let T=v+1;T<l.length;T++){const E=ct(d(l[T],p,c));for(const m of M)for(const I of E)de(m.a,m.b,I.a,I.b,Q)&&y++}}return y},"strictCrossingCount"),g=f(p=>{const c=ct(p);if(c.length!==3)return;const y=c[1];if(!(c[0].horizontal===y.horizontal||c[2].horizontal===y.horizontal))return{index:y.index,horizontal:y.horizontal,vertical:y.vertical,segment:y}},"middleRail"),x=f((p,c)=>{const y=[p.start,p.end].filter(v=>!!v);return r.filter(v=>{if(y.includes(v.id))return!1;const M=v.rect;return c.horizontal?zt(c.a.x,c.b.x,M.left,M.right)>=_t&&c.a.y>=M.top-2&&c.a.y<=M.bottom+2:zt(c.a.y,c.b.y,M.top,M.bottom)>=_t&&c.a.x>=M.left-2&&c.a.x<=M.right+2})},"blockingRectsFor"),C=f((p,c,y)=>{const v=p.map(T=>({...T}));if(c.horizontal)v[c.index].y=y,v[c.index+1].y=y;else if(c.vertical)v[c.index].x=y,v[c.index+1].x=y;else return;const M=ae(mt(v));return ct(M).length===M.length-1?M:void 0},"candidateByMovingRail"),h=f((p,c,y)=>{const v=[p.start,p.end].filter(T=>!!T),M=ct(c);if(M.length!==c.length-1)return!1;for(const T of M)if(At(T.a,T.b,r,v,-2)||At(T.a,T.b,a,[],-2))return!1;for(const T of l)if(T!==p){for(const E of M)for(const m of ct(d(T)))if(ce(E,m,.5)>=_t)return!1}return i(p,c)<=y},"candidateIsSafe");for(let p=0;p<8;p++){const c=i();let y=!1;for(const v of l){const M=d(v),T=g(M);if(!T)continue;const E=x(v,T.segment);if(E.length===0)continue;const m=T.horizontal?[Math.min(...E.map(I=>I.rect.top))-20,Math.max(...E.map(I=>I.rect.bottom))+20]:[Math.min(...E.map(I=>I.rect.left))-20,Math.max(...E.map(I=>I.rect.right))+20];for(const I of m){const R=C(M,T.segment,I);if(!(!R||!h(v,R,c))){v.points=R,y=!0;break}}if(y)break}if(!y)return}}A(vn,"liftObstacleHuggingSameSideRails");f(vn,"liftObstacleHuggingSameSideRails");function Ln(t,e){const o=f(d=>{const i=d.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"),s=f(d=>{if(!d.isGroup||d.parentId)return;const i=d.direction,g=typeof i=="string"?i.toUpperCase():"";if(g==="LR"||g==="RL"||g==="BT")return;const x=o(d),C=d.y,h=d.height;if(!x||typeof C!="number"||typeof h!="number"||!Number.isFinite(C)||!Number.isFinite(h)||h<=0)return;const p=x.right-x.left,c=x.bottom-x.top;if(!(c<=0||p<c))return{node:d,rect:x}},"topLaneTitleFor"),r=f((d,i)=>{if(!d.horizontal)return!1;const g=d.a.y;return g<=i.top+Q||g>=i.bottom-Q?!1:zt(d.a.x,d.b.x,i.left,i.right)>=_t},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(d=>!!d);if(a.length===0)return;let l=0;for(const d of t){if(d.isLayoutOnly)continue;const i=mt(d.points??[]);for(const g of ct(i))for(const x of a)r(g,x.rect)&&(l=Math.max(l,x.rect.bottom-g.a.y+4))}if(!(l<=Q))for(const d of a){const i=d.node.y,g=d.node.height;typeof i!="number"||typeof g!="number"||!Number.isFinite(i)||!Number.isFinite(g)||g<=0||(d.node.y=i-l/2,d.node.height=g+l,d.node.groupTitleRect={...d.rect,top:d.rect.top-l,bottom:d.rect.bottom-l})}}A(Ln,"liftTopLaneTitleBandsAboveRails");f(Ln,"liftTopLaneTitleBandsAboveRails");function Tn(t,e){const o=f(i=>{const g=i.groupTitleRect;if(!(!g||typeof g.left!="number"||typeof g.right!="number"||typeof g.top!="number"||typeof g.bottom!="number"||!Number.isFinite(g.left)||!Number.isFinite(g.right)||!Number.isFinite(g.top)||!Number.isFinite(g.bottom)||g.right<=g.left||g.bottom<=g.top))return{left:g.left,right:g.right,top:g.top,bottom:g.bottom}},"validTitleRect"),s=f(i=>{if(!i.isGroup||i.parentId||i.direction!=="LR")return;const x=o(i),C=i.x,h=i.width;if(!x||typeof C!="number"||typeof h!="number"||!Number.isFinite(C)||!Number.isFinite(h)||h<=0)return;const p=x.right-x.left,c=x.bottom-x.top;if(!(p<=0||c<p))return{node:i,rect:x}},"leftLaneTitleFor"),r=f((i,g)=>{if(!i.vertical)return!1;const x=i.a.x;return x<=g.left+Q||x>=g.right-Q?!1:zt(i.a.y,i.b.y,g.top,g.bottom)>=_t},"verticalSegmentIntersectsTitle"),a=f((i,g)=>{if(!i.horizontal)return!1;const x=i.a.y;return x<=g.top+Q||x>=g.bottom-Q?!1:zt(i.a.x,i.b.x,g.left,g.right)>=_t},"horizontalSegmentIntersectsTitle"),l=[...e.values()].map(s).filter(i=>!!i);if(l.length===0)return;let d=0;for(const i of t){if(i.isLayoutOnly)continue;const g=mt(i.points??[]);for(const x of ct(g))for(const C of l)if(r(x,C.rect))d=Math.max(d,C.rect.right-x.a.x+4);else if(a(x,C.rect)){const h=Math.min(x.a.x,x.b.x);d=Math.max(d,C.rect.right-h+4)}}if(!(d<=Q))for(const i of l){const g=i.node.x,x=i.node.width;typeof g!="number"||typeof x!="number"||!Number.isFinite(g)||!Number.isFinite(x)||x<=0||(i.node.x=g-d/2,i.node.width=x+d,i.node.groupTitleRect={...i.rect,left:i.rect.left-d,right:i.rect.right-d})}}A(Tn,"shiftLeftLaneTitleBandsLeftOfRails");f(Tn,"shiftLeftLaneTitleBandsLeftOfRails");function is(t,e){const{realNodeRects:o}=ue(e.values()),s=t.filter(p=>!p.isLayoutOnly),r=f((p,c=new Map)=>mt(c.get(p)??p.points??[]),"replacementPointsFor"),a=f((p=new Map)=>{let c=0;for(let y=0;y<s.length;y++){const v=ct(r(s[y],p));for(let M=y+1;M<s.length;M++){const T=ct(r(s[M],p));for(const E of v)for(const m of T)de(E.a,E.b,m.a,m.b,Q)&&c++}}return c},"crossingCount"),l=f((p=new Map)=>s.reduce((c,y)=>c+Zt(r(y,p)),0),"totalBends"),d=f(p=>{const c=r(p);if(c.length<4)return;const y=c[c.length-2],v=c[c.length-1];if(!(!Tt(y,v,Q)&&!Et(y,v,Q)))return{tailStart:y,terminal:v}},"terminalTailFor"),i=f((p,c)=>{const y=r(p);if(y.length<3)return;const v=y[0],M=y[1];let T;if(Tt(v,M,Q))T={x:M.x,y:c.tailStart.y};else if(Et(v,M,Q))T={x:c.tailStart.x,y:M.y};else return;const E=ae(mt([v,M,T,c.tailStart,c.terminal]));return ct(E).length===E.length-1?E:void 0},"candidateWithDestinationTail"),g=f((p,c)=>{const y=[p.start,p.end].filter(v=>!!v);for(const v of ct(c))if(At(v.a,v.b,o,y,-2))return!0;return!1},"pathHasNodeHit"),x=f((p,c,y)=>{for(const v of s)if(v!==p){for(const M of ct(c))for(const T of ct(r(v,y)))if(ce(M,T,.5)>=_t)return!0}return!1},"pathHasSharedTrack"),C=f((p,c,y)=>!g(p,c)&&!x(p,c,y),"candidateIsSafe"),h=f(()=>{const p=new Map;for(const c of s){const y=c.end;if(!y||!e.has(y)||r(c).length<4)continue;const M=p.get(y)??[];M.push(c),p.set(y,M)}return p},"edgesByDestination");for(let p=0;p<4;p++){const c=a();if(c===0)return;const y=l();let v,M=c,T=y;for(const E of h().values())for(let m=0;m<E.length;m++)for(let I=m+1;I<E.length;I++){const R=E[m],O=E[I],F=d(R),B=d(O);if(!F||!B)continue;const _=i(R,B),X=i(O,F);if(!_||!X)continue;const P=new Map([[R,_],[O,X]]);if(!C(R,_,P)||!C(O,X,P))continue;const z=a(P),U=l(P);z>=c||z>M||z===M&&U>=T||(v=P,M=z,T=U)}if(!v)return;for(const[E,m]of v)E.points=m}}A(is,"swapDestinationTerminalTailsToReduceCrossings");f(is,"swapDestinationTerminalTailsToReduceCrossings");function cs(t,e){const{realNodeRects:r,labelNodeRects:a}=ue(e.values()),l=t.filter(E=>!E.isLayoutOnly),d=f((E,m=new Map)=>mt(m.get(E)??E.points??[]),"replacementPointsFor"),i=f((E=new Map)=>{let m=0;for(let I=0;I<l.length;I++){const R=ct(d(l[I],E));for(let O=I+1;O<l.length;O++){const F=ct(d(l[O],E));for(const B of R)for(const _ of F)de(B.a,B.b,_.a,_.b,Q)&&m++}}return m},"strictCrossingCount"),g=f((E=new Map)=>l.reduce((m,I)=>m+Zt(d(I,E)),0),"totalBends"),x=f(E=>{const m=E.start,I=E.end,R=m?e.get(m):void 0,O=I?e.get(I):void 0,F=R?jt(R):void 0,B=O?jt(O):void 0;return F&&B?{src:F,dst:B}:void 0},"endpointRectsFor"),C=f((E,m,I)=>{if(I.index<=0||I.index+1>=m.length-1)return;const R=x(E);if(R){if(I.vertical){const O=I.a.x,F=Math.min(R.src.left,R.dst.left),B=Math.max(R.src.right,R.dst.right),_=O<F-Q?"left":O>B+Q?"right":void 0;return _?{edge:E,points:m,segmentIndex:I.index,axis:"vertical",side:_,coord:O,min:Math.min(I.a.y,I.b.y),max:Math.max(I.a.y,I.b.y)}:void 0}if(I.horizontal){const O=I.a.y,F=Math.min(R.src.top,R.dst.top),B=Math.max(R.src.bottom,R.dst.bottom),_=O<F-Q?"top":O>B+Q?"bottom":void 0;return _?{edge:E,points:m,segmentIndex:I.index,axis:"horizontal",side:_,coord:O,min:Math.min(I.a.x,I.b.x),max:Math.max(I.a.x,I.b.x)}:void 0}}},"externalRailForSegment"),h=f(()=>{const E=[];for(const m of l){const I=d(m);for(const R of ct(I)){const O=C(m,I,R);O&&E.push(O)}}return E},"collectExternalRails"),p=f((E,m)=>E.edge!==m.edge&&E.axis===m.axis&&E.side===m.side&&zt(E.min,E.max,m.min,m.max)>=_t,"railsInteract"),c=f(E=>{const m=[],I=new Set;for(const R of E){if(I.has(R))continue;const O=[R],F=[];for(I.add(R);O.length>0;){const B=O.pop();F.push(B);for(const _ of E)!I.has(_)&&p(B,_)&&(I.add(_),O.push(_))}F.length>1&&m.push(F)}return m},"connectedComponents"),y=f(E=>{const m=[];for(const I of E)m.some(R=>Math.abs(R-I.coord)<Q)||m.push(I.coord);for(;m.length<E.length;){const I=Math.min(...m),R=Math.max(...m),O=E[0].side;m.push(O==="left"||O==="top"?I-12*(E.length-m.length):R+12*(E.length-m.length))}return m},"uniqueCoordsFor"),v=f(E=>{const m=E.map(O=>O.coord),I=y(E),R=[];if(E.length<=6){const O=new Array(I.length).fill(!1),F=[],B=f(()=>{if(F.length===E.length){F.some((_,X)=>Math.abs(_-m[X])>=Q)&&R.push([...F]);return}for(const[_,X]of I.entries())O[_]||(O[_]=!0,F.push(X),B(),F.pop(),O[_]=!1)},"visit");return B(),R}for(let O=0;O<m.length;O++)for(let F=O+1;F<m.length;F++){const B=[...m];[B[O],B[F]]=[B[F],B[O]],R.push(B)}return R},"coordinateAssignmentsFor"),M=f((E,m)=>{const I=new Map;for(const[O,F]of E.entries()){const B=m[O],_=I.get(F.edge)??F.points.map(X=>({x:X.x,y:X.y}));F.axis==="vertical"?(_[F.segmentIndex].x=B,_[F.segmentIndex+1].x=B):(_[F.segmentIndex].y=B,_[F.segmentIndex+1].y=B),I.set(F.edge,_)}const R=new Map;for(const[O,F]of I){const B=ae(mt(F));if(ct(B).length!==B.length-1)return;R.set(O,B)}return R},"replacementsForAssignment"),T=f(E=>{for(const[m,I]of E){const R=[m.start,m.end].filter(O=>!!O);for(const O of ct(I))if(At(O.a,O.b,r,R,-2)||At(O.a,O.b,a,[],-2))return!1}for(let m=0;m<l.length;m++){const I=l[m],R=E.has(I),O=ct(d(I,E));for(let F=m+1;F<l.length;F++){const B=l[F];if(!R&&!E.has(B))continue;const _=ct(d(B,E));for(const X of O)for(const P of _)if(ce(X,P,.5)>=_t)return!1}}return!0},"candidateIsSafe");for(let E=0;E<4;E++){const m=i();if(m===0)return;let I,R=m,O=g(),F=Number.POSITIVE_INFINITY;for(const B of c(h()))for(const _ of v(B)){const X=M(B,_);if(!X||!T(X))continue;const P=i(X);if(P>=m)continue;const z=g(X),U=B.reduce((Z,ht,yt)=>Z+Math.abs(_[yt]-ht.coord),0);P>R||P===R&&(z>O||z===O&&U>=F)||(I=X,R=P,O=z,F=U)}if(!I)return;for(const[B,_]of I)B.points=_}}A(cs,"reassignCrossingExternalRailChannels");f(cs,"reassignCrossingExternalRailChannels");function as(t,e){const{realNodeRects:o,labelNodeRects:s}=ue(e.values()),r=t.filter(h=>!h.isLayoutOnly),a=f((h,p,c)=>mt(h===p?c??[]:h.points??[]),"pointsFor"),l=f(h=>ct(h).reduce((p,c)=>{const y=c.a.x-c.b.x,v=c.a.y-c.b.y;return p+Math.hypot(y,v)},0),"pathLength"),d=f((h,p)=>{let c=0;for(let y=0;y<r.length;y++){const v=ct(a(r[y],h,p));for(let M=y+1;M<r.length;M++){const T=ct(a(r[M],h,p));for(const E of v)for(const m of T)de(E.a,E.b,m.a,m.b,Q)&&c++}}return c},"strictCrossingCount"),i=f((h,p)=>{if(h.horizontal){const c=h.a.y;return(Math.abs(c-p.top)<1||Math.abs(c-p.bottom)<1)&&zt(h.a.x,h.b.x,p.left,p.right)>=_t}if(h.vertical){const c=h.a.x;return(Math.abs(c-p.left)<1||Math.abs(c-p.right)<1)&&zt(h.a.y,h.b.y,p.top,p.bottom)>=_t}return!1},"segmentRunsAlongRectBorder"),g=f(h=>{const p=[h.start,h.end].filter(y=>!!y),c=[];for(const y of p){const v=e.get(y),M=v?jt(v):void 0;M&&c.push(M)}return c},"endpointRectsFor"),x=f((h,p)=>{if(p+3>=h.length)return[];const c=h[p],y=h[p+1],v=h[p+2],M=h[p+3],T=Tt(c,y,Q)&&Et(y,v,Q)&&Tt(v,M,Q),E=Et(c,y,Q)&&Tt(y,v,Q)&&Et(v,M,Q);if(!T&&!E)return[];if(!(T?Math.sign(y.x-c.x)!==Math.sign(M.x-v.x):Math.sign(y.y-c.y)!==Math.sign(M.y-v.y)))return[];const I=dt(c,M,Q)||ut(c,M,Q)?[]:[{x:c.x,y:M.y},{x:M.x,y:c.y}],R=I.length===0?[[...h.slice(0,p+1),...h.slice(p+3)]]:I.map(F=>[...h.slice(0,p+1),F,...h.slice(p+3)]),O=new Set;return R.map(F=>ae(mt(F))).filter(F=>{if(ct(F).length!==F.length-1||!F.some(_=>ee(_,M,Q)))return!1;const B=F.map(_=>`${_.x.toFixed(3)},${_.y.toFixed(3)}`).join("|");return O.has(B)?!1:(O.add(B),!0)})},"shortcutCandidatesAt"),C=f((h,p,c)=>{const y=[h.start,h.end].filter(M=>!!M),v=g(h);for(const M of ct(p))if(At(M.a,M.b,o,y,-2)||At(M.a,M.b,s,[],-2)||v.some(T=>i(M,T)))return!1;for(const M of r)if(M!==h){for(const T of ct(p))for(const E of ct(a(M)))if(ce(T,E,.5)>=_t)return!1}return d(h,p)<=c},"candidateIsSafe");for(let h=0;h<8;h++){const p=d();let c,y,v=p,M=Number.POSITIVE_INFINITY,T=Number.POSITIVE_INFINITY;for(const E of r){const m=a(E),I=Zt(m,Q),R=l(m);for(let O=0;O<=m.length-4;O++)for(const F of x(m,O)){const B=Zt(F,Q),_=l(F);if(!(B<I||B===I&&_<R-Q)||!C(E,F,p))continue;const P=d(E,F);P>v||P===v&&(B>M||B===M&&_>=T)||(c=E,y=F,v=P,M=B,T=_)}}if(!c||!y)return;c.points=y}}A(as,"shortcutRedundantOrthogonalJogs");f(as,"shortcutRedundantOrthogonalJogs");function ls(t,e){const a=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const D=N.x??0,H=N.y??0,j=jt(N);j&&a.push({id:String(N.id??""),cx:D,cy:H,rect:j})}if(a.length===0)return;const l=new Map(a.map(N=>[N.id,N])),d=a.map(N=>({id:N.id,rect:N.rect})),i=["top","bottom","left","right"],g={top:Math.min(...a.map(N=>N.rect.top))-20,bottom:Math.max(...a.map(N=>N.rect.bottom))+20,left:Math.min(...a.map(N=>N.rect.left))-20,right:Math.max(...a.map(N=>N.rect.right))+20},x=t.filter(N=>!N.isLayoutOnly),C=new Map(x.map((N,D)=>[N,D])),h=f(N=>{const D=N==="left"||N==="top"?-1:1,H=[];for(let j=0;j<=2;j++)H.push(g[N]+D*20*j);return H},"outwardTracksForSide"),p=f((N,D=new Map)=>mt(D.get(N)??N.points??[]),"replacementPointsFor"),c=f((N,D)=>{let H=0;for(const j of N)for(const u of D)de(j.a,j.b,u.a,u.b,Q)&&H++;return H},"crossingCountBetweenSegments"),y=f((N,D)=>c(ct(N),ct(D)),"crossingCountBetweenPaths"),v=f((N=new Map)=>{let D=0;const H=[],j=new Set,u=[],b=f(S=>{j.has(S)||(j.add(S),u.push(S))},"addEdge");for(let S=0;S<x.length;S++){const L=x[S],w=p(L,N);for(let k=S+1;k<x.length;k++){const W=x[k],q=y(w,p(W,N));q>0&&(D+=q,H.push({first:L,second:W,count:q}),b(L),b(W))}}return u.sort((S,L)=>(C.get(S)??0)-(C.get(L)??0)),{count:D,pairs:H,edgeSet:j,edges:u}},"crossingSnapshot"),M=f((N,D)=>{const H=new Set(D.keys());if(H.size===0)return N.count;let j=0;for(const b of N.pairs)(H.has(b.first)||H.has(b.second))&&(j+=b.count);let u=0;for(let b=0;b<x.length;b++){const S=x[b],L=H.has(S),w=p(S,D);for(let k=b+1;k<x.length;k++){const W=x[k];!L&&!H.has(W)||(u+=y(w,p(W,D)))}}return N.count-j+u},"crossingCountWithReplacements"),T=f(N=>{const D=new Map;for(const u of N.pairs){const b=D.get(u.first)??new Set;b.add(u.second),D.set(u.first,b);const S=D.get(u.second)??new Set;S.add(u.first),D.set(u.second,S)}const H=[],j=new Set;for(const u of N.edges){if(j.has(u))continue;const b=[u],S=[];for(j.add(u);b.length>0;){const L=b.pop();S.push(L);for(const w of D.get(L)??[])j.has(w)||(j.add(w),b.push(w))}S.sort((L,w)=>(C.get(L)??0)-(C.get(w)??0)),S.length>1&&H.push(S)}return H},"crossingComponents"),E=f(N=>[N.start,N.end].filter(D=>!!D),"endpointIdsFor"),m=f(N=>{const D=[];for(const H of T(N)){const j=new Set(H),u=new Set(H.flatMap(S=>E(S))),b=[...H];for(const S of x)j.has(S)||E(S).some(L=>u.has(L))&&b.push(S);b.sort((S,L)=>(C.get(S)??0)-(C.get(L)??0)),D.push(b)}return D},"pairSearchGroups"),I=f((N,D,H)=>M(N,new Map([[D,H]])),"crossingCountWithSingleReplacement"),R=f(N=>{const D=new Map;for(const H of N.pairs)D.set(H.first,(D.get(H.first)??0)+H.count),D.set(H.second,(D.get(H.second)??0)+H.count);return D},"currentCrossingsByEdge"),O=f(N=>N.slice(1).reduce((D,H,j)=>{const u=N[j];return D+Math.abs(H.x-u.x)+Math.abs(H.y-u.y)},0),"pathLength"),F=f((N=new Map)=>x.reduce((D,H)=>D+Zt(p(H,N)),0),"totalBends"),B=f((N=new Map)=>x.reduce((D,H)=>D+O(p(H,N)),0),"totalLength"),_=f((N,D,H=new Map)=>{const j=ct(D);for(const u of x)if(u!==N){for(const b of j)for(const S of ct(p(u,H)))if(ce(b,S,.5)>=_t)return!0}return!1},"pathHasSegmentConflict"),X=f((N,D)=>{const H=[N.start,N.end].filter(j=>!!j);for(const j of ct(D))if(At(j.a,j.b,d,H,-2))return!0;return!1},"pathHitsNode"),P=f((N,D)=>{const H=ae(mt(D));ct(H).length===H.length-1&&N.push(H)},"pushOrthogonalCandidate"),z=f(N=>N==="left"||N==="right","sideIsHorizontal"),U=f((N,D,H)=>{switch(D){case"left":return Math.min(N.x,H.x)-20;case"right":return Math.max(N.x,H.x)+20;case"top":return Math.min(N.y,H.y)-20;case"bottom":return Math.max(N.y,H.y)+20}},"localTrackForSameSide"),Z=f((N,D,H,j)=>{const u=H==="left"||H==="top"?-1:1,b=[U(D,H,j),g[H]];for(const S of b)for(let L=0;L<=2;L++)P(N,Un(D,H,j,S+u*20*L))},"addSameSideCandidates"),ht=f((N,D,H,j,u)=>{for(const b of h(H))for(const S of h(u))P(N,[D,{x:b,y:D.y},{x:b,y:S},{x:j.x,y:S},j])},"addHorizontalToVerticalCandidates"),yt=f((N,D,H,j,u)=>{for(const b of h(H))for(const S of h(u))P(N,[D,{x:D.x,y:b},{x:S,y:b},{x:S,y:j.y},j])},"addVerticalToHorizontalCandidates"),Ft=f((N,D,H,j,u)=>{const b=[...h("top"),...h("bottom")];for(const S of h(H))for(const L of h(u))for(const w of b)P(N,[D,{x:S,y:D.y},{x:S,y:w},{x:L,y:w},{x:L,y:j.y},j])},"addHorizontalPairCandidates"),Pt=f((N,D,H,j,u)=>{const b=[...h("left"),...h("right")];for(const S of h(H))for(const L of h(u))for(const w of b)P(N,[D,{x:D.x,y:S},{x:w,y:S},{x:w,y:L},{x:j.x,y:L},j])},"addVerticalPairCandidates"),tt=f(N=>{const D=new Set;return N.map(H=>mt(H)).filter(H=>{const j=H.map(u=>`${u.x.toFixed(3)},${u.y.toFixed(3)}`).join("|");return D.has(j)||H.length<2?!1:(D.add(j),!0)})},"dedupeCandidatePaths"),K=f((N,D,H,j)=>{const u=[],b=jn(N,D,H,j,20,Q);b&&P(u,b),D===j&&Z(u,N,D,H);const S=z(D),L=z(j);return S&&!L?ht(u,N,D,H,j):!S&&L?yt(u,N,D,H,j):S?Ft(u,N,D,H,j):Pt(u,N,D,H,j),tt(u)},"buildCandidatesForSides"),nt=f((N,D,H,j)=>{const u=[...h("left"),...h("right")],b=[...h("top"),...h("bottom")];for(const S of i){const L=Me(j,S),w=S==="top"||S==="bottom"?h(S):b;for(const k of u){P(N,[D,H,{x:k,y:H.y},{x:k,y:L.y},L]);for(const W of w)P(N,[D,H,{x:k,y:H.y},{x:k,y:W},{x:L.x,y:W},L])}}},"addVerticalDepartureOuterTrackCandidates"),lt=f((N,D,H,j)=>{const u=[...h("left"),...h("right")],b=[...h("top"),...h("bottom")];for(const S of i){const L=Me(j,S),w=S==="left"||S==="right"?h(S):u;for(const k of b){P(N,[D,H,{x:H.x,y:k},{x:L.x,y:k},L]);for(const W of w)P(N,[D,H,{x:H.x,y:k},{x:W,y:k},{x:W,y:L.y},L])}}},"addHorizontalDepartureOuterTrackCandidates"),pt=f(N=>{const D=N.start,H=N.end,j=H?l.get(H):void 0;if(!D||!j)return[];const u=mt(N.points??[]);if(u.length<4)return[];const b=u[0],S=u[1],L=[];return Et(b,S,Q)?nt(L,b,S,j):Tt(b,S,Q)&<(L,b,S,j),L},"terminalPreservingOuterTrackCandidates"),bt=f(N=>{const D=N.start,H=N.end,j=D?l.get(D):void 0,u=H?l.get(H):void 0;if(!j||!u)return[];const b=[];for(const S of i){const L=Me(j,S);for(const w of i)b.push(...K(L,S,Me(u,w),w))}return b.push(...pt(N)),b},"candidatePathsFor"),Lt=f(()=>new Map(x.map(N=>[N,ct(p(N))])),"currentSegmentsByEdge"),Ut=f((N,D,H)=>{const j=new Set;for(const u of x){if(u===N)continue;const b=H.get(u)??ct(p(u));D.some(S=>b.some(L=>ce(S,L,.5)>=_t))&&j.add(u)}return j},"sharedTrackConflictsFor"),Wt=f((N,D,H,j)=>{const u=new Set;return bt(N).map(S=>ae(mt(S))).filter(S=>{if(X(N,S))return!1;const L=S.map(w=>`${w.x.toFixed(3)},${w.y.toFixed(3)}`).join("|");return u.has(L)||S.length<2?!1:(u.add(L),!0)}).map(S=>{const L=ct(S);let w=0;for(const k of x)k!==N&&(w+=c(L,H.get(k)??ct(p(k))));return{candidate:S,candidateSegments:L,crossings:D.count-(j.get(N)??0)+w,bends:Zt(S,Q),totalBends:Zt(S),length:O(S)}}).filter(({crossings:S})=>S<=D.count).sort((S,L)=>S.crossings-L.crossings||S.bends-L.bends||S.length-L.length).slice(0,48).map(S=>({path:S.candidate,segments:S.candidateSegments,sharedTrackConflicts:Ut(N,S.candidateSegments,H),totalBends:S.totalBends,length:S.length}))},"pairCandidatesFor"),Kt=f((N,D,H,j,u,b)=>{let S=0;for(const w of N.pairs)(w.first===D||w.second===D||w.first===j||w.second===j)&&(S+=w.count);let L=c(H.segments,u.segments);for(const w of x){if(w===D||w===j)continue;const k=b.get(w)??ct(p(w));L+=c(H.segments,k)+c(u.segments,k)}return N.count-S+L},"pairCrossingCount"),ne=f((N,D)=>{for(const H of N.sharedTrackConflicts)if(H!==D)return!1;return!0},"conflictsOnlyWith"),Ee=f((N,D)=>N.segments.some(H=>D.segments.some(j=>ce(H,j,.5)>=_t)),"candidatesShareTrack"),ge=f((N,D,H,j)=>ne(D,H.edge)&&ne(j,N.edge)&&!Ee(D,j),"pairCandidatesAreCompatible"),we=f((N,D,H,j,u)=>{const b=Kt(N.current,D.edge,H,j.edge,u,N.baseSegments);if(!(b>=N.current.count))return{replacements:new Map([[D.edge,H.path],[j.edge,u.path]]),crossings:b,bends:N.currentBends-(N.baseBendsByEdge.get(D.edge)??0)-(N.baseBendsByEdge.get(j.edge)??0)+H.totalBends+u.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(D.edge)??0)-(N.baseLengthByEdge.get(j.edge)??0)+H.length+u.length}},"scorePairReplacement"),ao=f((N,D)=>N.crossings<D.crossings||N.crossings===D.crossings&&(N.bends<D.bends||N.bends===D.bends&&N.length<D.length),"pairScoreIsBetter"),lo=f((N,D,H,j)=>{let u=j;for(const b of D.candidates)for(const S of H.candidates){if(!ge(D,b,H,S))continue;const L=we(N,D,b,H,S);L&&ao(L,u)&&(u=L)}return u},"bestScoreForOptionPair"),fo=f(N=>{const D=F(),H=B(),j=Lt(),u=R(N),b=new Map(x.map(q=>[q,Zt(p(q))])),S=new Map(x.map(q=>[q,O(p(q))])),L=new Map,w=m(N);for(const q of w)for(const V of q){if(L.has(V))continue;const G=Wt(V,N,j,u);G.length>0&&L.set(V,{edge:V,candidates:G})}let k={replacements:new Map,crossings:N.count,bends:D,length:H};const W={current:N,currentBends:D,currentLength:H,baseBendsByEdge:b,baseLengthByEdge:S,baseSegments:j};for(const q of w){const V=new Set(q.filter(st=>N.edgeSet.has(st))),G=q.map(st=>L.get(st)).filter(st=>!!st);for(let st=0;st<G.length;st++){const it=G[st];for(let rt=st+1;rt<G.length;rt++){const et=G[rt];!V.has(it.edge)&&!V.has(et.edge)||(k=lo(W,it,et,k))}}}return k.replacements.size>0?k.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const D=v(),H=D.count;if(H===0)return;let j,u,b=H,S=Number.POSITIVE_INFINITY;for(const w of D.edges){const k=Zt(p(w),Q);for(const W of bt(w)){const q=X(w,W),V=!q&&_(w,W),G=I(D,w,W),st=Zt(W,Q);q||V||!(G<H||G===H&&st<k)||G>b||G===b&&st>=S||(j=w,u=W,b=G,S=st)}}if(j&&u){j.points=u;continue}const L=fo(D);if(!L)return;for(const[w,k]of L)w.points=k}}A(ls,"resolveRenderedOrthogonalCrossings");f(ls,"resolveRenderedOrthogonalCrossings");var xe=.001,Or=8;function ds(t,e){const{nodeInfoById:n,realNodeRects:o}=Ue(e),s=["top","bottom","left","right"],r=20,a={top:Math.min(...o.map(c=>c.rect.top))-r,bottom:Math.max(...o.map(c=>c.rect.bottom))+r,left:Math.min(...o.map(c=>c.rect.left))-r,right:Math.max(...o.map(c=>c.rect.right))+r},l=f((c,y,v,M)=>{const T=[],E=jn(c,y,v,M,r,xe);return E&&T.push(E),y===M&&T.push(Un(c,y,v,a[y])),T},"buildOrthogonalPathCandidates"),d=f((c,y)=>{for(let v=0;v<c.length-1;v++){const M=c[v],T=c[v+1];if(At(M,T,o,y,1))return!0}return!1},"pathHitsNode"),i=f((c,y,v=!1)=>{let M=0;const T=Le(c,xe),E=y.start,m=y.end;for(const I of t){if(I===y||I.isLayoutOnly)continue;const R=I.start,O=I.end;if(!v&&E&&m&&(R===E||R===m||O===E||O===m))continue;const F=I.points;if(!(!F||F.length<2))for(const B of T)for(const _ of Le(F,xe)){if(Kn(B.a,B.b,_.a,_.b,xe,xe)){M++;continue}ce(B,_,xe)>=Or&&M++}}return M},"pathConflictCount"),g=4,x=f((c,y)=>{const v=Math.abs(c.y-y.rect.top),M=Math.abs(c.y-y.rect.bottom),T=Math.abs(c.x-y.rect.left),E=Math.abs(c.x-y.rect.right);let m="top",I=v;return M<I&&(m="bottom",I=M),T<I&&(m="left",I=T),E<I&&(m="right",I=E),m},"nearestSideOfRect"),C=new Map,h=f((c,y,v)=>{const M=C.get(c)??[];M.push({side:y,edgeId:v}),C.set(c,M)},"addFaceClaim");for(const c of t){if(c.isLayoutOnly)continue;const y=c.points??[];if(y.length<1)continue;const v=c.id??"",M=c.start,T=c.end;if(M){const E=n.get(M);E&&h(M,x(y[0],E),v)}if(T){const E=n.get(T);E&&h(T,x(y[y.length-1],E),v)}}const p=f((c,y,v)=>C.get(c)?.some(M=>M.edgeId!==v&&M.side===y)??!1,"faceIsClaimed");for(const c of t){if(c.isLayoutOnly)continue;const y=c.points;if(!y||y.length<2)continue;const v=Zt(y,xe);if(v<g)continue;const M=c.start,T=c.end;if(!M||!T)continue;const E=n.get(M),m=n.get(T);if(!E||!m)continue;const I=c.id??"",R=i(y,c,!0),O=i(y,c);let F,B=R,_=v;for(const X of s){if(p(M,X,I))continue;const P=Me(E,X);for(const z of s){if(p(T,z,I))continue;const U=Me(m,z);for(const Z of l(P,X,U,z)){if(d(Z,[M,T]))continue;const ht=Zt(Z,xe);if(R>0){const yt=i(Z,c,!0);if(yt>B||yt===B&&ht>=_)continue;B=yt,_=ht,F=Z;continue}i(Z,c)>O||ht<_&&(_=ht,F=Z)}}}if(F){c.points=F;const X=C.get(M);X&&C.set(M,X.filter(z=>z.edgeId!==I));const P=C.get(T);P&&C.set(T,P.filter(z=>z.edgeId!==I)),h(M,x(F[0],E),I),h(T,x(F[F.length-1],m),I)}}}A(ds,"simplifyDetouredEdges");f(ds,"simplifyDetouredEdges");var qt=.001,dr=10,rn=7;function En(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 a=r.x-s.x,l=r.y-s.y;if(!(Math.abs(a)+Math.abs(l)<qt)){if(Math.abs(l)<=qt){const i=s.x+Math.sign(a)*dr;return{left:Math.min(s.x,i),right:Math.max(s.x,i),top:s.y-rn,bottom:s.y+rn}}if(Math.abs(a)<=qt){const i=s.y+Math.sign(l)*dr;return{left:s.x-rn,right:s.x+rn,top:Math.min(s.y,i),bottom:Math.max(s.y,i)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}A(En,"markerClearanceRectFor");f(En,"markerClearanceRectFor");function fs(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}A(fs,"normalizeRect");f(fs,"normalizeRect");function wn(t,e){const n=mt(e),o=En(n,!0),s=En(n,!1);return[o,s].some(r=>r&&De(t,fs(r)))}A(wn,"labelOverlapsOwnMarker");f(wn,"labelOverlapsOwnMarker");function ke(t,e){const n=[];for(const p of t){if(p.isLayoutOnly)continue;const c=p.points;if(!(!c||c.length<2))for(let y=0;y<c.length-1;y++)n.push({edgeId:p.id,p1:c[y],p2:c[y+1]})}const o=[],s=[];for(const p of e.values()){const c=p.isGroup,y=p.parentId;if(c&&!y){const M=jt(p);M&&s.push({id:p.id,rect:M});continue}if(c||p.isEdgeLabel)continue;const v=jt(p);v&&o.push({nodeId:p.id,rect:v})}const r=3,a=1,l=12,d=f((p,c)=>{const y=fn(c,r);for(const{nodeId:v,rect:M}of o)if(v!==p&&De(y,M))return!0;return!1},"labelOverlapsForeignNode"),i=f((p,c)=>{const y=fn(c,r);for(const v of n)if(v.edgeId!==p&&je(v.p1,v.p2,y))return!0;return!1},"labelOverlapsForeignEdge"),g=f((p,c,y)=>d(p,y)||i(c,y),"labelOverlapsAnything"),x=[],C=f(p=>{for(const{id:c,rect:y}of s)if(Ho(y,p))return c},"findContainingLane"),h=f((p,c)=>x.some(y=>y.labelId!==p&&De(c,y.rect)),"overlapsPlacedLabel");for(const p of t){if(p.isLayoutOnly)continue;const c=p.labelNodeId;if(!c)continue;const y=e.get(c);if(!y)continue;const v=p.points;if(!v||v.length<2)continue;const M=y.width??0,T=y.height??0;if(M<=0||T<=0)continue;const E=[];for(let tt=0;tt<v.length-1;tt++){const K=v[tt],nt=v[tt+1],lt=Math.abs(K.x-nt.x),pt=Math.abs(K.y-nt.y);lt<qt&&pt<qt||lt>=qt&&pt>=qt||E.push({idx:tt,length:lt+pt,orientation:lt>=qt?"horizontal":"vertical",midX:(K.x+nt.x)/2,midY:(K.y+nt.y)/2})}if(E.length===0)continue;const m=E.length>=3?E.filter(tt=>tt.idx>0&&tt.idx<E.length-1):E,I=m.length>0?m:E,R=M>=T?"horizontal":"vertical",O=f(tt=>[...tt].sort((K,nt)=>{const lt=K.orientation===R,pt=nt.orientation===R;if(lt!==pt)return lt?-1:1;const bt=K.length>=(K.orientation==="horizontal"?M:T)+2,Lt=nt.length>=(nt.orientation==="horizontal"?M:T)+2;return bt!==Lt?bt?-1:1:nt.length-K.length}),"rankSegments"),F=E[0],B=E[E.length-1],_=[.5,.25,.75,.05,.95,.15,.85,.1,.9],X=f((tt,K)=>{const nt=v[tt.idx],lt=v[tt.idx+1];return{midX:nt.x+(lt.x-nt.x)*K,midY:nt.y+(lt.y-nt.y)*K}},"anchorAtT"),P=f((tt,K,nt)=>Math.min(nt,Math.max(K,tt)),"clamp"),z=f((tt,K)=>tt.midX>=K.left-qt&&tt.midX<=K.right+qt&&tt.midY>=K.top-qt&&tt.midY<=K.bottom+qt,"pointInsideRectInclusive"),U=f(tt=>{const K=ve(tt.midX,tt.midY,M,T),nt=C(K);if(nt)return{laneId:nt,anchor:tt,rect:K};const lt=s.find(({rect:ne})=>z(tt,ne));if(!lt)return;const pt=lt.rect.left+M/2+a,bt=lt.rect.right-M/2-a,Lt=lt.rect.top+T/2+a,Ut=lt.rect.bottom-T/2-a;if(pt>bt||Lt>Ut)return;const Wt={midX:P(tt.midX,pt,bt),midY:P(tt.midY,Lt,Ut)},Kt=ve(Wt.midX,Wt.midY,M,T);return z(tt,Kt)?{laneId:lt.id,anchor:Wt,rect:Kt}:void 0},"placementForAnchor"),Z=f((tt,K,nt)=>tt.orientation==="horizontal"?Math.abs(K.midX-nt.x):Math.abs(K.midY-nt.y),"distanceAlongSegment"),ht=f((tt,K)=>{const lt=(tt.orientation==="horizontal"?M/2:T/2)+l;if(tt===F){const pt=v[tt.idx];if(Z(tt,K,pt)+qt<lt)return!1}if(tt===B){const pt=v[tt.idx+1];if(Z(tt,K,pt)+qt<lt)return!1}return!0},"labelClearsTerminalEndpoints"),yt=f(tt=>{const K=O(tt);for(const nt of K)for(const lt of _){const pt=X(nt,lt);if(!ht(nt,pt))continue;const bt=U(pt);if(bt&&!wn(bt.rect,v)&&!h(c,bt.rect)&&!g(c,p.id,bt.rect))return{laneId:bt.laneId,anchor:bt.anchor}}},"tryPool"),Ft=f((tt,K,nt=!1)=>{const lt=O(tt);for(const pt of lt){const bt={midX:pt.midX,midY:pt.midY};if(K&&!ht(pt,bt))continue;const Lt=U(bt);if(Lt&&!wn(Lt.rect,v)&&!h(c,Lt.rect)&&!d(c,Lt.rect)&&(nt||!i(p.id,Lt.rect)))return{laneId:Lt.laneId,anchor:Lt.anchor}}},"findLaneContainingFallback"),Pt=yt(I)??(I.length<E.length?yt(E):void 0)??Ft(E,!0)??Ft(E,!1)??Ft(E,!1,!0);if(Pt){y.x=Pt.anchor.midX,y.y=Pt.anchor.midY,y.parentId=Pt.laneId;const tt=ve(Pt.anchor.midX,Pt.anchor.midY,M,T),K=x.findIndex(nt=>nt.labelId===c);K>=0?x[K]={labelId:c,rect:tt}:x.push({labelId:c,rect:tt})}}}A(ke,"anchorLabelsToPolyline");f(ke,"anchorLabelsToPolyline");var Mo=1e-6,Nr=8,fr=Nr/2,Br=3;function Rn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}A(Rn,"pairKey");f(Rn,"pairKey");function us(t,e){const{nodeInfoById:n,realNodeRects:o}=Ue(e),s=new Map;for(const a of e){const l=a.id;if(!a.isGroup&&a.isEdgeLabel){s.set(l,{w:a.width??0,h:a.height??0});continue}}const r=f((a,l,d,i)=>{const g=Rn(l,d);let x=0;const C=f(h=>{if(!h)return;const p=s.get(h);if(!p)return;const c=i==="x"?p.w/2:p.h/2;c>x&&(x=c)},"consider");C(a.labelNodeId);for(const h of t){if(h===a||h.isLayoutOnly)continue;const p=h.start,c=h.end;!p||!c||Rn(p,c)===g&&C(h.labelNodeId)}return x>0?x+Br:0},"labelClearanceFor");for(const a of t){if(a.isLayoutOnly)continue;const l=a.points;if(!$n(l,Mo))continue;const d=Wn(a,n,Mo);if(!d)continue;const{srcId:i,dstId:g,srcInfo:x,dstInfo:C,collinearX:h,collinearY:p}=d;if(h===p)continue;let c,y;if(h){const m=C.cy>x.cy;c={x:x.cx,y:m?x.rect.bottom:x.rect.top},y={x:C.cx,y:m?C.rect.top:C.rect.bottom}}else{const m=C.cx>x.cx;c={x:m?x.rect.right:x.rect.left,y:x.cy},y={x:m?C.rect.left:C.rect.right,y:C.cy}}if(At(c,y,o,[i,g],1))continue;const M=r(a,i,g,h?"x":"y"),T=M>fr?M:fr,E=[0,T,-T];for(const m of E){const I={...c},R={...y};if(h){if(I.x+=m,R.x+=m,I.x<=x.rect.left||I.x>=x.rect.right||R.x<=C.rect.left||R.x>=C.rect.right)continue}else if(I.y+=m,R.y+=m,I.y<=x.rect.top||I.y>=x.rect.bottom||R.y<=C.rect.top||R.y>=C.rect.bottom)continue;if(!At(I,R,o,[i,g],1)&&!He(I,R,t,a,{epsilon:Mo})){a.points=[I,R];break}}}}A(us,"straightenCollinearSiblingDetours");f(us,"straightenCollinearSiblingDetours");function An(t,e){const{realNodeRects:d,labelNodeRects:i}=ue(e.values()),g=f((m,I)=>Le(I,.001).map(R=>({...R,edge:m,interior:R.index>=1&&R.index<=I.length-3})),"segmentsFor"),x=f(()=>{const m=[];for(const I of t){if(I.isLayoutOnly)continue;const R=I.points;!R||R.length<2||m.push(...g(I,mt(R)))}return m},"allSegments"),C=f((m,I)=>m.horizontal&&I.horizontal?zt(m.a.x,m.b.x,I.a.x,I.b.x)>=8&&Math.abs(m.a.y-I.a.y)<7:m.vertical&&I.vertical?zt(m.a.y,m.b.y,I.a.y,I.b.y)>=8&&Math.abs(m.a.x-I.a.x)<7:!1,"hasCrowdedParallelTrack"),h=f((m,I)=>{const R=m.start,O=m.end,F=g(m,I);if(F.length!==I.length-1)return!1;const B=[R,O].filter(X=>!!X),_=m.labelNodeId?[m.labelNodeId]:[];for(const X of F)if(At(X.a,X.b,d,B,-2)||At(X.a,X.b,i,_,-2))return!1;for(const X of t){if(X===m||X.isLayoutOnly)continue;const P=X.points;if(!(!P||P.length<2)){for(const z of F)for(const U of g(X,mt(P)))if(C(z,U)||de(z.a,z.b,U.a,U.b,.001))return!1}}return!0},"candidateIsSafe"),p=f((m,I)=>{const R=mt(m.edge.points??[]);if(R.length<4||m.index>=R.length-1)return;const O=R.map(F=>({...F}));if(m.horizontal)O[m.index].y+=I,O[m.index+1].y+=I;else if(m.vertical)O[m.index].x+=I,O[m.index+1].x+=I;else return;return g(m.edge,O).length===O.length-1?O:void 0},"shiftedCandidate"),c=f((m,I)=>({x:m.x??(I.left+I.right)/2,y:m.y??(I.top+I.bottom)/2}),"nodeCenter"),y=f(m=>{const I=m.edge,R=mt(I.points??[]);if(R.length!==4||m.index!==1)return;const O=I.start?e.get(I.start):void 0,F=I.end?e.get(I.end):void 0,B=O?jt(O):void 0,_=F?jt(F):void 0,X=R.slice(m.index+2);if(!(!O||!F||!B||!_||X.length===0))return{sourceCenter:c(O,B),targetCenter:c(F,_),sourceRect:B,tail:X}},"sourceDetourContextFor"),v=f((m,I,R,O,F,B)=>{const _=O.y>=R.y,X=_?F.bottom:F.top,P=X+(_?20:-20);if(_&&m.b.y<=P+.001||!_&&m.b.y>=P-.001)return;const z=m.a.x+I;return mt([{x:R.x,y:X},{x:R.x,y:P},{x:z,y:P},{x:z,y:m.b.y},...B],.001)},"verticalSourceDetour"),M=f((m,I,R,O,F,B)=>{const _=O.x>=R.x,X=_?F.right:F.left,P=X+(_?20:-20);if(_&&m.b.x<=P+.001||!_&&m.b.x>=P-.001)return;const z=m.a.y+I;return mt([{x:X,y:R.y},{x:P,y:R.y},{x:P,y:z},{x:m.b.x,y:z},...B],.001)},"horizontalSourceDetour"),T=f((m,I)=>{const R=y(m);if(R){if(m.vertical)return v(m,I,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail);if(m.horizontal)return M(m,I,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail)}},"sourceDetourCandidate"),E=[-7,7,-14,14,-21,21];for(let m=0;m<12;m++){const I=x();let R=!1;for(let O=0;O<I.length&&!R;O++)for(let F=O+1;F<I.length&&!R;F++){const B=I[O],_=I[F];if(B.edge===_.edge||!C(B,_))continue;const X=[B,_].filter(P=>P.interior);for(const P of X){for(const z of E){const U=p(P,z);if(U&&h(P.edge,U)){P.edge.points=U,R=!0;break}const Z=T(P,z);if(Z&&h(P.edge,Z)){P.edge.points=Z,R=!0;break}}if(R)break}}if(!R)return}}A(An,"nudgeSharedInteriorSubpaths");f(An,"nudgeSharedInteriorSubpaths");function hs(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,a=o.x-n.x,l=o.y-n.y,d=s*l-r*a;if(Math.abs(d)<1e-10)return!1;const i=n.x-t.x,g=n.y-t.y,x=(i*l-g*a)/d,C=(i*r-g*s)/d,h=.01;return x>h&&x<1-h&&C>h&&C<1-h}A(hs,"segmentsIntersect");f(hs,"segmentsIntersect");function gs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Xo(e),r=[];for(const l of n){if(l.isLayoutOnly)continue;const d=l.points;if(!d||d.length<2)continue;const i=l.start,g=l.end,x=l.labelNodeId,C=l.id??`${i}->${g}`;for(const h of s)if(!(h.nodeId===i||h.nodeId===g)&&!(x&&h.nodeId===x)){for(let p=0;p<d.length-1;p++)if(je(d[p],d[p+1],h,-1)){o.push({type:"edge-node-overlap",edgeId:C,targetId:h.nodeId,detail:`segment ${p} passes through node "${h.nodeId}"`});break}}for(let h=0;h<d.length-1;h++)r.push({edgeId:C,start:i,end:g,p1:d[h],p2:d[h+1]})}const a=new Set;for(let l=0;l<r.length;l++)for(let d=l+1;d<r.length;d++){const i=r[l],g=r[d];if(i.edgeId!==g.edgeId&&!(i.start===g.start||i.start===g.end||i.end===g.start||i.end===g.end)&&hs(i.p1,i.p2,g.p1,g.p2)){const x=i.edgeId<g.edgeId?`${i.edgeId}|${g.edgeId}`:`${g.edgeId}|${i.edgeId}`;a.has(x)||(a.add(x),o.push({type:"edge-edge-crossing",edgeId:i.edgeId,targetId:g.edgeId,detail:`edges "${i.edgeId}" and "${g.edgeId}" cross`}))}}if(o.length>0){const l=o.filter(i=>i.type==="edge-node-overlap").length,d=o.filter(i=>i.type==="edge-edge-crossing").length;So.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${l} edge-node overlap(s), ${d} edge crossing(s)`);for(const i of o)So.warn(`[SWIMLANE_VALIDATE] ${i.type}: ${i.detail}`)}return o}A(gs,"validateSwimlanesLayout");f(gs,"validateSwimlanesLayout");function ps(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(l=>!l.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!es(t,e)||e==="BT"&&s.length>0&&!ts(t))return;for(const l of o){if(l.isLayoutOnly)continue;const d=l.points;!d||d.length<2||(l.points=ae(Xe(d)))}ds(o,n),us(o,n),ns(o,n);const r=new Map;for(const l of n)r.set(String(l.id),l);ke(o,r),Vo(o,r),os(o,r),An(o,r),ss(o,r),rs(o,r),vn(o,r),is(o,r);const a=f(()=>{ls(o,r),cs(o,r),as(o,r),ke(o,r),Sn(o,r),vn(o,r),ke(o,r),Sn(o,r)},"finalizeRenderedEdges");a(),An(o,r),a(),Ln(o,r),Tn(o,r),Ln(o,r),Tn(o,r)}A(ps,"postProcessSwimlaneLayout");f(ps,"postProcessSwimlaneLayout");function he(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 a=`${r.id}:${r.src}->${r.dst}`;n.has(a)||(n.add(a),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}A(he,"normalizeGraph");f(he,"normalizeGraph");function to(t,e){return t.edges.filter(n=>n.dst===e)}A(to,"incoming");f(to,"incoming");function ms(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}A(ms,"buildSuccessorMap");f(ms,"buildSuccessorMap");function eo(t){const e=ms(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}A(eo,"buildSortedSuccessorMap");f(eo,"buildSortedSuccessorMap");function no(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}A(no,"buildInDegreeMap");f(no,"buildInDegreeMap");function oo(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}A(oo,"sortedZeroInDegreeNodes");f(oo,"sortedZeroInDegreeNodes");function We(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src));return{preds:n,succs:o}}A(We,"buildPredecessorSuccessorMaps");f(We,"buildPredecessorSuccessorMaps");function so(t,e,n,o){let s=0;for(const a of t.nodes)o?.skipGroups&&t.nodeById.get(a)?.isGroup||(s=Math.max(s,n[a]??0));const r=Array.from({length:s+1},()=>[]);for(const a of e)o?.skipGroups&&t.nodeById.get(a)?.isGroup||r[Math.max(0,n[a]??0)].push(a);return r}A(so,"buildLayersFromRanks");f(so,"buildLayersFromRanks");function Pe(t){const e=no(t),n=oo(e),o=[],s=eo(t);for(;n.length;){const r=n.shift();o.push(r);for(const a of s.get(r)??[])if(e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0){let l=0;for(;l<n.length&&n[l]<a;)l++;n.splice(l,0,a)}}return o.length===t.nodes.length?o:null}A(Pe,"topoSortIfAcyclic");f(Pe,"topoSortIfAcyclic");function Te(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}A(Te,"buildLayerIndex");f(Te,"buildLayerIndex");function ro(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let a=n(o,r)+n(r,s),l=o,d=r,i=o;for(;l<r||d<s;)d>=s||l<r&&t[l]<=t[d]?e[i++]=t[l++]:(e[i++]=t[d++],a+=r-l);for(let g=o;g<s;g++)t[g]=e[g];return a},"count");return n(0,t.length)}A(ro,"countInversions");f(ro,"countInversions");function ys(t){const e=he(t),n=new Map;for(const g of e.nodes)n.set(g,[]);for(const g of e.edges)n.get(g.src).push(g);for(const g of n.values())g.sort((x,C)=>x.dst===C.dst?x.id.localeCompare(C.id):x.dst.localeCompare(C.dst));const o=Object.create(null);for(const g of e.nodes)o[g]=0;const s=[],r=f(g=>{o[g]=1;for(const x of n.get(g)??[]){const C=x.dst;o[C]===0?r(C):o[C]===1&&s.push(x)}o[g]=2},"dfs"),a=[...e.nodes].sort((g,x)=>g.localeCompare(x));for(const g of a)o[g]===0&&r(g);const l=new Set(s.map(g=>`${g.id}:${g.src}->${g.dst}`)),d=e.edges.map(g=>l.has(`${g.id}:${g.src}->${g.dst}`)?{id:g.id,src:g.dst,dst:g.src,weight:g.weight,ref:g.ref}:g);return{acyclic:{nodes:[...e.nodes],edges:d,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}A(ys,"removeCycles_DFS");f(ys,"removeCycles_DFS");function xs(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const l=n(r)??r;return e.set(o,l),l},"resolve");for(const o of t.nodes)n(o);return e}A(xs,"buildTopLaneMap");f(xs,"buildTopLaneMap");function fe(t){const e=xs(t);return n=>e.get(n)??null}A(fe,"createTopLaneResolver");f(fe,"createTopLaneResolver");function Ke(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}A(Ke,"buildTopLaneOrder");f(Ke,"buildTopLaneOrder");function io(t,e){const n=Ke(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const a of e)!o.has(a)||s.has(a)||(s.add(a),r.push(a));for(const a of n)s.has(a)||r.push(a);return r}A(io,"resolveTopLaneOrder");f(io,"resolveTopLaneOrder");var Pr={EPSILON:1e-6},On={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},ur={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function bs(t,e){const n=he(t),o=e?.laneOf??(()=>null),s=e?.rankHint,{preds:r}=We(n);for(const m of r.values())m.sort((I,R)=>I.localeCompare(R));const a=Pe(n)??[...n.nodes].sort((m,I)=>m.localeCompare(I)),l=new Map;for(const[m,I]of a.entries())l.set(I,m);const d=new Map,i=new Map;for(const m of n.nodes)i.set(m,[]);for(const m of a){const I=(r.get(m)??[]).filter(R=>d.has(R));if(I.length>0){const R=Ms(m,I,{laneOf:o,rankHint:s,topoIndex:l});d.set(m,R),i.get(R).push(m)}else d.has(m)||d.set(m,null)}for(const m of n.nodes)d.has(m)||d.set(m,null);const g=new Set;for(const m of n.nodes)(d.get(m)??null)===null&&g.add(m);const x=[...g].sort((m,I)=>{const R=l.get(m)??0,O=l.get(I)??0;return R===O?m.localeCompare(I):R-O}),C=Is(n),h=new Map;for(const[m,I]of C.entries())h.set(m,[...I].sort((R,O)=>R.localeCompare(O)));const p=Ss(h),c=Cs(h),y=new Map;for(const m of n.nodes)y.set(m,[]);for(const m of c)for(const I of m.nodes){const R=y.get(I);R?R.push(m.id):y.set(I,[m.id])}const v=[],M=[],T=new Set,E=f(m=>{if(!T.has(m)){T.add(m),v.push(m);for(const I of i.get(m)??[])E(I);M.push(m)}},"walk");for(const m of x)E(m);for(const m of a)E(m);return{parent:d,children:i,roots:x,componentOf:p,blocks:c,nodeBlocks:y,adjacency:h,preorder:v,postorder:M,topologicalOrder:a}}A(bs,"buildDrivingTree");f(bs,"buildDrivingTree");function Ms(t,e,n){const o=n.laneOf(t);return[...e].sort((r,a)=>{const l=n.laneOf(r),d=n.laneOf(a),i=l!=null&&l===o,g=d!=null&&d===o;if(i!==g)return i?-1:1;const x=n.rankHint?.[r],C=n.rankHint?.[a];if(x!=null&&C!=null&&x!==C)return C-x;const h=n.topoIndex.get(r)??0,p=n.topoIndex.get(a)??0;return h!==p?h-p:r.localeCompare(a)})[0]}A(Ms,"chooseParent");f(Ms,"chooseParent");function Is(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}A(Is,"buildAdjacency");f(Is,"buildAdjacency");function Ss(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 a of t.get(r)??[])e.has(a)||s.push(a)}}n++}return e}A(Ss,"assignComponents");f(Ss,"assignComponents");function Cs(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const a=f((l,d)=>{e.set(l,++r),n.set(l,r);for(const i of t.get(l)??[])i!==d&&(e.has(i)?(e.get(i)??0)<(e.get(l)??0)&&(o.push([l,i]),n.set(l,Math.min(n.get(l)??r,e.get(i)??r))):(o.push([l,i]),a(i,l),n.set(l,Math.min(n.get(l)??r,n.get(i)??r)),(n.get(i)??0)>=(e.get(l)??0)&&s.push(vs(l,i,o,s.length))))},"visit");for(const l of t.keys())e.has(l)||a(l,null);return s}A(Cs,"computeBlocks");f(Cs,"computeBlocks");function vs(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const a=n.pop();if(s.push(a),r.add(a[0]),r.add(a[1]),a[0]===t&&a[1]===e||a[0]===e&&a[1]===t)break}return{id:o,edges:s,nodes:[...r]}}A(vs,"popBlock");f(vs,"popBlock");function Ls(t,e,n){const o=[...t.nodes],s=new Map;for(const[M,T]of o.entries())s.set(T,M);const r=o.length,a=new Array(r).fill(-1),l=new Array(r).fill(0),d=[],i=new Set;for(const M of o){const T=n.parent.get(M)??null,E=s.get(M);E!=null&&T==null&&(a[E]=-1,l[E]=0,i.has(M)||(i.add(M),d.push(M)))}for(;d.length>0;){const M=d.shift(),T=s.get(M);if(T==null)continue;const E=n.children.get(M)??[];for(const m of E){if(i.has(m))continue;const I=s.get(m);I!=null&&(a[I]=T,l[I]=l[T]+1,i.add(m),d.push(m))}}for(const M of o){if(i.has(M))continue;const T=s.get(M);T!=null&&(a[T]=-1,l[T]=0,i.add(M))}const g=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),x=Array.from({length:g},()=>new Array(r).fill(-1));for(let M=0;M<r;M++)x[0][M]=a[M];for(let M=1;M<g;M++)for(let T=0;T<r;T++){const E=x[M-1][T];x[M][T]=E===-1?-1:x[M-1][E]}const C=f((M,T)=>{if(M===-1||T===-1)return-1;l[M]<l[T]&&([M,T]=[T,M]);const E=l[M]-l[T];for(let m=0;m<g;m++)if(E>>m&1&&(M=x[m][M],M===-1))return-1;if(M===T)return M;for(let m=g-1;m>=0;m--){const I=x[m][M],R=x[m][T];I===-1||R===-1||I!==R&&(M=I,T=R)}return x[0][M]},"lcaIndex"),h=Array.from({length:r},()=>new Map);for(const M of t.edges){let T=M.src,E=M.dst,m=e[T],I=e[E];if(m==null||I==null||(m>I&&([T,E]=[E,T],[m,I]=[I,m]),m==null||I==null||m===I))continue;const R=s.get(T),O=s.get(E);if(R==null||O==null)continue;const F=C(R,O);if(F===-1)continue;const B=h[F];for(let _=m;_<I;_++)B.set(_,(B.get(_)??0)+1)}const p=new Map,c=f((M,T)=>{if(T.size!==0)for(const[E,m]of T)M.set(E,(M.get(E)??0)+m)},"mergeInto"),y=new Set,v=f(M=>{const T=s.get(M);y.add(M);const E=T==null?void 0:h[T],m=E?new Map(E):new Map,I=n.children.get(M)??[];for(const R of I){const O=v(R),F=e[M];if(F!=null){let B=p.get(M);B||(B=new Map,p.set(M,B));let _=O.get(F)??0;const X=e[R];X!=null&&X>F&&(_+=1),B.set(R,_)}c(m,O)}return m},"dfs");for(const M of n.roots)y.has(M)||v(M);for(const M of o)y.has(M)||v(M);return p}A(Ls,"computeSubtreeCrossCounts");f(Ls,"computeSubtreeCrossCounts");function Ts(t,e,n){const o=new Map,s=f(r=>{let a=n[r]??0;const l=[...e.get(r)??[]];l.sort(co(n));for(const d of l){s(d);const i=o.get(d);i!=null&&(a=Math.min(a,i))}o.set(r,a)},"annotate");for(const r of t)s(r);return o}A(Ts,"annotateMinimumLayers");f(Ts,"annotateMinimumLayers");function co(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}A(co,"compareByRankThenId");f(co,"compareByRankThenId");function Es(t,e,n,o){let s=0;for(const d of e){const i=n[d]??0;i>s&&(s=i)}const r=Array.from({length:s+1},()=>[]),a=new Set,l=f(d=>{if(a.has(d))return;a.add(d);const i=n[d]??0;r[i]||(r[i]=[]),r[i].push(d);for(const g of o(d))l(g)},"emit");for(const d of t)l(d);for(const d of e)if(!a.has(d)){const i=n[d]??0;r[i]||(r[i]=[]),r[i].push(d),a.add(d)}return r}A(Es,"emitNodesInTreeOrder");f(Es,"emitNodesInTreeOrder");function ws(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}A(ws,"deduplicateLayers");f(ws,"deduplicateLayers");function Rs(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const a=e[s]??0,l=[],d=[],i=n.get(s);for(const g of r){const x=o.get(g)??a;x>a?l.push({child:g,min:x}):d.push(g)}return l.sort((g,x)=>g.min===x.min?g.child.localeCompare(x.child):g.min-x.min),d.sort((g,x)=>{const C=i?.get(g)??0,h=i?.get(x)??0;if(C!==h)return C-h;const p=o.get(g)??a,c=o.get(x)??a;return p!==c?p-c:g.localeCompare(x)}),[...l.map(g=>g.child),...d]}}A(Rs,"createChildOrderer");f(Rs,"createChildOrderer");function Ve(t,e,n){const o=bs(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const x of t.nodes)s.has(x)||s.set(x,[]);const a=Ls(t,e,o),l=[...r].sort(co(e)),d=Ts(l,s,e),i=Rs(s,e,a,d);let g=Es(l,t.nodes,e,i);return g=ws(g),g}A(Ve,"buildMultitreeLayerOrder");f(Ve,"buildMultitreeLayerOrder");function As(t,e,n){const o=new Set(t),s=new Set(e),r=Te(e),a=[];for(const l of n)o.has(l.src)&&s.has(l.dst)&&a.push(r.get(l.dst));return ro(a)}A(As,"countCrossingsBetweenAdjacent");f(As,"countCrossingsBetweenAdjacent");function Nn(t,e,n){const o=[];for(const r of e){const a=n[r.src],l=n[r.dst];if(a==null||l==null||a===l)continue;let d=r.src,i=r.dst,g=a,x=l;a>l&&(d=r.dst,i=r.src,g=l,x=a);for(let C=g;C<x;C++)o.push({id:`${r.id}@${C}`,src:d,dst:i,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=As(t[r],t[r+1],o);return s}A(Nn,"totalCrossings");f(Nn,"totalCrossings");function Os(t,e){const n={...e},{preds:o}=We(t),s=fe(t),r=Ve(t,n,s);let a=Nn(r,t.edges,n);const l=On.MAX_CROSSING_OPTIMIZATION_PASSES;for(let d=0;d<l;d++){let i=!1;const g=[...t.nodes].sort((x,C)=>(n[C]??0)-(n[x]??0));for(const x of g){const C=n[x]??0;if(C===0)continue;let h=0;for(const v of o.get(x)??[])h=Math.max(h,(n[v]??0)+1);if(h>=C)continue;const p=C;n[x]=h;const c=Ve(t,n,s),y=Nn(c,t.edges,n);y<a?(a=y,i=!0):n[x]=p}if(!i)break}return n}A(Os,"optimizeRanksByCrossings");f(Os,"optimizeRanksByCrossings");function Ns(t,e){const n=fe(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 a=t.edges.filter(c=>c.src===s);if(a.length===0)continue;let l=!1,d=0;for(const c of a){const y=n(c.dst);y==null||y===r?l=!0:d++}if(d===0||l)continue;let i=0,g=!1;for(const c of t.edges){if(c.dst!==s)continue;const y=n(c.src);y&&(y===r?g=!0:i++)}if(i>0||!g)continue;const x=e[s]??0,C=x+d;let h=0;for(const c of t.edges)c.dst===s&&(h=Math.max(h,(e[c.src]??0)+1));const p=Math.max(x,h,C);p!==x&&(e[s]=p)}}A(Ns,"adjustCrossLaneSources");f(Ns,"adjustCrossLaneSources");function Bs(t,e){const n=he(t),o=Pe(n)??[...n.nodes].sort(),s=e?.compactSingleInput??!1,r=fe(n);let a=Object.create(null);for(const d of o){const i=to(n,d),g=e?.ignoreCrossLaneEdges?i.filter(x=>{const C=r(x.src),h=r(d);return!C||!h?!0:C===h}):i;if(g.length===0)a[d]=0;else if(s&&g.length===1){const x=g[0].src,C=r(x),h=r(d);C!==h?a[d]=a[x]??0:a[d]=(a[x]??0)+1}else{let x=-1/0;for(const C of g)x=Math.max(x,(a[C.src]??0)+1);a[d]=x===-1/0?0:x}}return(e?.optimizeRanksByCrossings??!1)&&(a=Os(n,a)),e?.ignoreCrossLaneEdges&&Ns(n,a),{layers:Ve(n,a,r),rankOf:a,dummy:new Set}}A(Bs,"assignLayers_LongestPath");f(Bs,"assignLayers_LongestPath");function Ps(t,e){const n=he(t),s={...Bs(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=fe(n),{preds:a,succs:l}=We(n,p=>{if(e?.ignoreCrossLaneEdges){const c=r(p.src),y=r(p.dst);if(c&&y&&c!==y)return!1}return!0}),d=Pe(n)??[...n.nodes],i=[...d].reverse(),g=f((p,c)=>{let y=0;for(const T of a.get(p)??[])y=Math.max(y,(s[T]??0)+1);let v=Number.POSITIVE_INFINITY;const M=l.get(p)??[];return M.length>0&&(v=Math.min(...M.map(T=>(s[T]??0)-1))),Number.isFinite(v)||(v=Math.max(y,c)),Math.min(Math.max(c,y),v)},"clampFeasible"),x=On.GRAVITY_ITERATIONS,C=f(p=>{let c=!1;for(const y of p){const v=a.get(y)??[],M=l.get(y)??[];if(v.length===0&&M.length===0)continue;const T=v.length>0?v.reduce((R,O)=>R+(s[O]??0)+1,0)/v.length:s[y]??0,E=M.length>0?M.reduce((R,O)=>R+(s[O]??0)-1,0)/M.length:s[y]??0,m=Math.round((T+E)/2),I=g(y,m);I!==s[y]&&(s[y]=I,c=!0)}return c},"relaxOrder");for(let p=0;p<x;p++){const c=C(d),y=C(i);if(!c&&!y)break}for(const p of d){let c=0;for(const y of a.get(p)??[])c=Math.max(c,(s[y]??0)+1);(s[p]??0)<c&&(s[p]=c)}for(const p of i){const c=l.get(p)??[];if(c.length>0){const y=Math.min(...c.map(v=>(s[v]??0)-1));(s[p]??0)>y&&(s[p]=y)}}return{layers:so(n,d,s),rankOf:s,dummy:new Set}}A(Ps,"assignLayers_Gravity");f(Ps,"assignLayers_Gravity");function ks(t){const e=no(t),n=eo(t);let o=oo(e);const s=[];for(;o.length>0;){const r=[];for(const a of o){s.push(a);for(const l of n.get(a)??[])e.set(l,(e.get(l)??0)-1),(e.get(l)??0)===0&&r.push(l)}o=r.sort((a,l)=>a.localeCompare(l))}return s.length===t.nodes.length?s:null}A(ks,"topoSortByGenerationIfAcyclic");f(ks,"topoSortByGenerationIfAcyclic");function Fs(t,e){const n=he(t),o=e?.direction==="LR"?ks(n)??[...n.nodes].sort():Pe(n)??[...n.nodes].sort(),s=fe(n),r=f(g=>s(g)??g,"laneOf"),a=Object.create(null),l=new Map,d=f((g,x)=>e?.ignoreCrossLaneEdges??!0?r(g)===r(x)?1:0:1,"edgeWeight");for(const g of o){if(n.nodeById.get(g)?.isGroup)continue;const C=to(n,g);let h=0;if(C.length>0)for(const v of C){const M=v.src,T=a[M]??0;h=Math.max(h,T+d(M,g))}const p=r(g),c=l.get(p)??0,y=Math.max(h,c);a[g]=y,l.set(p,y+1)}return{layers:so(n,o,a,{skipGroups:!0}),rankOf:a,dummy:new Set}}A(Fs,"assignLayers_LaneAwareCompact");f(Fs,"assignLayers_LaneAwareCompact");function _s(t,e){const n=he(e),{rankOf:o}=t,s=t.layers.map(h=>[...h]),r=new Set(t.dummy?[...t.dummy]:[]);let a=0;const l=new Map(n.nodeById),d=f(h=>{const p=`placeholder-${a++}`,c={id:p,isGroup:!1,isDummy:!0,width:0,height:0};for(l.set(p,c),r.add(p);s.length<=h;)s.push([]);return s[h].push(p),o[p]=h,p},"addDummyAt"),i=[...n.edges].sort((h,p)=>h.id===p.id?h.src===p.src?h.dst.localeCompare(p.dst):h.src.localeCompare(p.src):h.id.localeCompare(p.id)),g=[];for(const h of i){const p=o[h.src]??0,c=o[h.dst]??0;if(c-p<=1){g.push(h);continue}let y=h.src;for(let M=p+1,T=0;M<c;M++,T++){const E=d(M);g.push({id:`${h.id}#${T}`,src:y,dst:E,weight:h.weight,ref:h.ref}),y=E}const v=c-p-2;g.push({id:`${h.id}#${Math.max(v+1,0)}`,src:y,dst:h.dst,weight:h.weight,ref:h.ref})}const C={nodes:[...n.nodes,...[...r].filter(h=>!n.nodes.includes(h))],edges:g,layout:n.layout,nodeById:l};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:C}}A(_s,"makeProperLayering");f(_s,"makeProperLayering");function Bn(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}A(Bn,"median");f(Bn,"median");function Pn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}A(Pn,"barycenter");f(Pn,"barycenter");function Ds(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}A(Ds,"neighborPositionsFor");f(Ds,"neighborPositionsFor");function Hs(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}A(Hs,"currentOrderTieBreak");f(Hs,"currentOrderTieBreak");function kn(t,e,n){const o=new Set(t),s=new Set(e),r=Te(t),a=Te(e),l=[];for(const i of n)o.has(i.src)&&s.has(i.dst)&&l.push({u:r.get(i.src),v:a.get(i.dst)});l.sort((i,g)=>i.u===g.u?i.v-g.v:i.u-g.u);const d=l.map(i=>i.v);return ro(d)}A(kn,"countCrossingsBetweenAdjacent2");f(kn,"countCrossingsBetweenAdjacent");function Fe(t,e,n){return[...t].sort((o,s)=>{const r=Bn(e.get(o)??[]),a=Bn(e.get(s)??[]);return r===a?Hs(o,s,n):isFinite(r)?isFinite(a)?r-a:-1:1})}A(Fe,"sortByHeuristic");f(Fe,"sortByHeuristic");function Fn(t,e,n,o,s,r){const a=Te(t),l=Te(e),d=Ds(e,a,n,o);if(!s||!r||r.length===0)return Fe(e,d,l);const i=new Map;for(const C of e){const h=s(C),p=i.get(h)??[];p.push(C),i.set(h,p)}const g=[];for(const C of r){const h=i.get(C);if(!h||h.length===0)continue;const p=Fe(h,d,l);g.push(...p)}const x=i.get(null);if(x&&x.length>0){const C=Fe(x,d,l);for(const h of C){const p=Pn(d.get(h)??[]);let c=g.length;if(isFinite(p))for(const[y,v]of g.entries()){const M=Pn(d.get(v)??[]);if(p<M){c=y;break}}g.splice(c,0,h)}}return g}A(Fn,"reorderLayer");f(Fn,"reorderLayer");function _n(t,e,n,o,s){const r=[...e],a=new Set(t),l=new Set(e),d=o?new Set(o):null,i=n.filter(c=>a.has(c.src)&&l.has(c.dst)),g=d?n.filter(c=>l.has(c.src)&&d.has(c.dst)):void 0,x=f(c=>{let y=kn(t,c,i);return g&&o&&(y+=kn(c,o,g)),y},"crossingScore"),C=s?new Map:null;if(s&&C)for(const c of e)C.set(c,s(c));let h=!0,p=x(r);for(;h;){h=!1;for(let c=0;c+1<r.length;c++){if(C){const M=C.get(r[c]),T=C.get(r[c+1]);if(M!==T)continue}const y=p;[r[c],r[c+1]]=[r[c+1],r[c]];const v=x(r);v<y?(p=v,h=!0):[r[c],r[c+1]]=[r[c+1],r[c]]}}return r}A(_n,"transposeImprove");f(_n,"transposeImprove");function Xs(t,e,n){const o=t.layers.map(l=>[...l]),s=e.edges,r=fe(e),a=io(e,n?.laneOrder);for(let l=0;l<3;l++){for(let d=1;d<o.length;d++)o[d]=Fn(o[d-1],o[d],s,"down",r,a),o[d]=_n(o[d-1],o[d],s,o[d+1],r);for(let d=o.length-2;d>=0;d--)o[d]=Fn(o[d+1],o[d],s,"up",r,a),o[d]=_n(o[d+1],o[d],s,o[d-1],r)}return{layers:o}}A(Xs,"orderLayers");f(Xs,"orderLayers");function Ys(t,e,n){const o=n?.layerGap??ur.DEFAULT_LAYER_GAP,s=n?.nodeGap??ur.DEFAULT_NODE_GAP,r=n?.laneGap??s*2,a=n?.direction??"TB",l=a==="LR"||a==="RL",d=t.layers,i=Object.create(null),g=Object.create(null),x=f(B=>e.nodeById.get(B),"getNode"),C=f(B=>x(B)?.width??0,"getWidth"),h=f(B=>x(B)?.height??0,"getHeight"),p=fe(e),c=io(e,n?.laneOrder),y=d.map(B=>B.reduce((_,X)=>Math.max(_,h(X)),0)),v=[];if(l)for(let B=0;B+1<d.length;B++){const _=d[B].reduce((yt,Ft)=>Math.max(yt,C(Ft)),0),X=d[B+1].reduce((yt,Ft)=>Math.max(yt,C(Ft)),0),P=y[B],z=y[B+1],U=P/2+z/2,Z=(_+X)/2,ht=Math.max(0,Z-U-o);v.push(ht)}const M=new Set;for(const B of d)for(const _ of B)M.add(p(_));const T=M.has(null),E=c.filter(B=>M.has(B)),m=[...T?[null]:[],...E],I=Object.create(null);for(const B of E)I[B]=0;T&&(I.null=0);for(const B of d){const _=Object.create(null),X=[];for(const P of B){const z=p(P);z===null?X.push(P):(_[z]||=[]).push(P)}for(const[P,z]of Object.entries(_)){const U=z.reduce((Z,ht)=>Z+C(ht),0)+s*Math.max(0,z.length-1);I[P]=Math.max(I[P]??0,U)}if(T&&X.length){const P=X.reduce((z,U)=>z+C(U),0)+s*Math.max(0,X.length-1);I.null=Math.max(I.null??0,P)}}const R=new Map;{const B=m.map(P=>(P===null?I.null:I[P])??0);let X=-(B.reduce((P,z)=>P+z,0)+r*Math.max(0,m.length-1))/2;for(let P=0;P<m.length;P++){const z=m[P],U=B[P]??0,Z=X+U/2;R.set(z,Z),X+=U,P<m.length-1&&(X+=r)}}let O=0;for(const[B,_]of d.entries()){const X=y[B]??0,P=new Map;for(const U of _){const Z=p(U),ht=P.get(Z)??[];ht.push(U),P.set(Z,ht)}for(const U of m){const Z=P.get(U)??[];if(Z.length===0)continue;const ht=R.get(U);if(Z.length===1){const yt=Z[0];i[yt]=ht,g[yt]=O+X/2}else{const yt=Z.map(tt=>C(tt)),Ft=yt.reduce((tt,K)=>tt+K,0)+s*(Z.length-1);let Pt=ht-Ft/2;for(const[tt,K]of Z.entries()){const nt=yt[tt];i[K]=Pt+nt/2,g[K]=O+X/2,Pt+=nt+s}}}const z=v[B]??0;O+=X+o+z}const F=new Map;for(const B of e.edges){const _=B.ref.id;F.has(_)||F.set(_,[]),F.get(_).push(B)}for(const[,B]of F){if(B.length===0)continue;const _=B[0].ref,X=_.start,P=_.end;if(X==null||P==null)continue;const z=Math.round(((i[X]??0)+(i[P]??0))/2),U=new Set;for(const Z of B)U.add(Z.src),U.add(Z.dst);for(const Z of U){if(Z===X||Z===P)continue;e.nodeById.get(Z)?.isDummy&&(i[Z]=z)}}return{x:i,y:g}}A(Ys,"assignCoordinates");f(Ys,"assignCoordinates");var hr=8;function Gs(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}A(Gs,"hashString");f(Gs,"hashString");function zs(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}A(zs,"mulberry32");f(zs,"mulberry32");function $s(t,e){const n=[...t],o=zs(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}A($s,"deterministicShuffle");f($s,"deterministicShuffle");function Vs(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}A(Vs,"sourceDistance");f(Vs,"sourceDistance");function Dn(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:a}of e){const l=n.get(s),d=n.get(r);l==null||d==null||(o+=a*Math.abs(l-d))}return o}A(Dn,"laneArrangementCost");f(Dn,"laneArrangementCost");function js(t){const e=Ke(t);if(e.length<2)return[];const n=new Map(e.map((r,a)=>[r,a])),o=fe(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const a=typeof r.start=="string"?r.start:void 0,l=typeof r.end=="string"?r.end:void 0;if(!a||!l||!t.nodeById.has(a)||!t.nodeById.has(l))continue;const d=o(a),i=o(l);if(!d||!i||d===i)continue;const g=n.get(d),x=n.get(i);if(g==null||x==null)continue;const[C,h]=g<=x?[d,i]:[i,d],p=`${C}\0${h}`,c=s.get(p);c?c.weight++:s.set(p,{a:C,b:h,weight:1})}return[...s.values()]}A(js,"buildWeightedLaneEdges");f(js,"buildWeightedLaneEdges");function Hn(t,e,n){const o=[...t];let s=Dn(o,e),r=!0,a=0;const l=Math.max(1,o.length);for(;r&&a<l;){r=!1,a++;for(let d=0;d+1<o.length;d++){[o[d],o[d+1]]=[o[d+1],o[d]];const i=Dn(o,e);i<s?(s=i,r=!0):[o[d],o[d+1]]=[o[d+1],o[d]]}}return{order:o,cost:s,sourceDistance:Vs(o,n)}}A(Hn,"greedySwitch");f(Hn,"greedySwitch");function Us(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}A(Us,"isBetterCandidate");f(Us,"isBetterCandidate");function Ws(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:a})=>`${s}:${r}:${a}`).join("|");return Gs(`${t.join("|")}#${o}#${n}`)}A(Ws,"seedForRestart");f(Ws,"seedForRestart");function Ks(t,e={}){const n=Ke(t);if(n.length<2)return n;const o=js(t);if(o.length===0)return n;const s=new Map(n.map((l,d)=>[l,d]));let r=Hn(n,o,s);const a=Math.max(0,e.restarts??hr);for(let l=0;l<a;l++){const d=Ws(n,o,l),i=$s(n,d),g=Hn(i,o,s);Us(g,r)&&(r=g)}return r.order}A(Ks,"optimizeTopLaneOrder");f(Ks,"optimizeTopLaneOrder");function Js(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,s=he(t),r=e?.automaticLaneOrdering?Ks(s,{restarts:hr}):void 0,a=ys(s),l=a.acyclic,d=n?Fs(l,{compactSingleInput:e?.compactSingleInput??On.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Ps(l,{compactSingleInput:e?.compactSingleInput??On.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:i,graphWithDummies:g}=_s(d,l),x=Xs(i,g,{laneOrder:r}),C=Ys(x,g,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:r});return{acyclic:l,reversed:a.reversed,layering:i,ordered:x,coordinates:C}}A(Js,"sugiyamaLayout");f(Js,"sugiyamaLayout");var at=Pr.EPSILON,kr=8,Se=15,Ne=15,cn=25,se=20,Io=10;function Xn(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,a=e.y-s,l=Math.abs(r),d=Math.abs(a);return l<at&&d<at?n:d>at&&d*3>=l?a>0?"bottom":"top":l>at?r>0?"right":"left":n}A(Xn,"chooseOrthogonalSide");f(Xn,"chooseOrthogonalSide");function Yn(t,e){return Math.abs(t.to-e.from)<at||Math.abs(t.to-e.to)<at?t.to:t.from}A(Yn,"sharedLineEndpointCoord");f(Yn,"sharedLineEndpointCoord");function be(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}A(be,"pointOnLine");f(be,"pointOnLine");function qs(t,e){const n=t.nodes??[],o=t.edges??[],s=[];for(const u of o)u.isLayoutOnly||s.push({...u,__originalEdge:u});const r=new Map,a=new Map,l=[],d=e==="LR";for(const u of n)r.set(u.id,u);const i=n.filter(u=>u.isGroup&&!u.parentId);for(const u of i){const b={id:u.id},S=f(L=>{a.set(L.id,b),n.filter(w=>w.parentId===L.id).forEach(S)},"assignLane");S(u)}const g=n.filter(u=>!u.isGroup&&!u.isEdgeLabel).map(u=>{const b=u.width??10,S=u.height??10,L=u.x??0,w=u.y??0,k=kr;return{nodeId:u.id,minX:L-b/2-k,maxX:L+b/2+k,minY:w-S/2-k,maxY:w+S/2+k,visualXHalfExtent:d?S/2+k:b/2+k}}),x=f((u,b,S,L)=>{let w=l.find(k=>k.orientation===u&&Math.abs(k.coord-b)<1);return w||(w={id:`pipe-${u}-${b.toFixed(0)}`,orientation:u,coord:b,spanMin:S,spanMax:L,tracks:[]},l.push(w)),w.spanMin=Math.min(w.spanMin,S),w.spanMax=Math.max(w.spanMax,L),w},"getOrAddPipe"),C=f((u,b)=>{const S=u.width??10,L=u.height??10,w=u.x??0,k=u.y??0;switch(b){case"top":return{x:w,y:k-L/2};case"bottom":return{x:w,y:k+L/2};case"left":return{x:w-S/2,y:k};case"right":return{x:w+S/2,y:k}}},"portForSide"),h=f((u,b,S)=>C(u,Xn(u,b,S?"bottom":"top")),"getOrthogonalPort"),p=[],c=[],y=new Set,v=1e3,M=f((u,b,S)=>{if(p.length===0)return 0;const L=Math.abs(b.y-S.y)<at,w=Math.abs(b.x-S.x)<at;if(!L&&!w)return 0;let k=0;if(L){const W=b.y,q=Math.min(b.x,S.x)-at,V=Math.max(b.x,S.x)+at;if(V<=q)return 0;for(const G of p)G.edgeIndex===u||G.orientation!=="vertical"||G.pipe.coord<q||G.pipe.coord>V||G.from-at<=W&&G.to+at>=W&&(k+=v)}else if(w){const W=b.x,q=Math.min(b.y,S.y)-at,V=Math.max(b.y,S.y)+at;if(V<=q)return 0;for(const G of p)G.edgeIndex===u||G.orientation!=="horizontal"||G.pipe.coord<q||G.pipe.coord>V||G.from-at<=W&&G.to+at>=W&&(k+=v)}return k},"crossingPenalty"),T=s.map((u,b)=>{if(!u.start||!u.end)return{idx:b,crossLane:0,dx:0,dy:0};const S=r.get(u.start),L=r.get(u.end),w=a.get(u.start),k=a.get(u.end),W=w&&k&&w.id!==k.id?1:0,q=S&&L?Math.abs((L.x??0)-(S.x??0)):0,V=S&&L?Math.abs((L.y??0)-(S.y??0)):0;return{idx:b,crossLane:W,dx:q,dy:V}}).sort((u,b)=>{if(u.crossLane!==b.crossLane)return b.crossLane-u.crossLane;const S=u.dx+u.dy,L=b.dx+b.dy;return Math.abs(S-L)>1?S-L:u.idx-b.idx}).map(u=>u.idx),E=f((u,b,S,L)=>{const w=Math.min(u.x,b.x),k=Math.max(u.x,b.x),W=Math.min(u.y,b.y),q=Math.max(u.y,b.y);return!!g.find(G=>S&&G.nodeId===S||L&&G.nodeId===L?!1:Math.abs(u.x-b.x)>at?G.minY<u.y&&G.maxY>u.y&&G.maxX>w&&G.minX<k:G.minX<u.x&&G.maxX>u.x&&G.maxY>W&&G.minY<q)},"isSegmentBlocked"),m=new Map,I=new Map;for(const u of s)!u.start||!u.end||u.start===u.end||(I.set(u.start,(I.get(u.start)??0)+1),I.set(u.end,(I.get(u.end)??0)+1));const R=f((u,b)=>Xn(u,b,"bottom"),"determineSide"),O=new Map;for(const[u,b]of s.entries()){if(!b.start||!b.end||b.start===b.end||b.points&&b.points.length>0)continue;const S=r.get(b.start),L=r.get(b.end);if(!S||!L)continue;const w=(L.x??0)-(S.x??0),k=(L.y??0)-(S.y??0);O.set(u,{edgeIdx:u,srcId:b.start,dstId:b.end,srcSide:R(S,{x:L.x??0,y:L.y??0}),dstSide:R(L,{x:S.x??0,y:S.y??0}),absDx:Math.abs(w),absDy:Math.abs(k),dxSign:Math.sign(w),dySign:Math.sign(k)})}const F=f(u=>u.srcSide==="top"||u.srcSide==="bottom"?u.absDx===0?1/0:u.absDy/u.absDx:u.absDy===0?1/0:u.absDx/u.absDy,"preferenceStrength"),B=f(u=>u.srcSide==="top"||u.srcSide==="bottom"?u.dxSign>=0?"right":"left":u.dySign>=0?"bottom":"top","secondarySide"),_=new Map;for(const u of O.values()){const b=`${u.srcId}:${u.srcSide}`;_.has(b)||_.set(b,[]),_.get(b).push(u)}const X=new Map,P=f((u,b)=>`${u}:${b}`,"loadKey");for(const u of O.values())X.set(P(u.srcId,u.srcSide),(X.get(P(u.srcId,u.srcSide))??0)+1),X.set(P(u.dstId,u.dstSide),(X.get(P(u.dstId,u.dstSide))??0)+1);for(const u of _.values())if(!(u.length<2)){u.sort((b,S)=>{const L=F(b),w=F(S);return Math.abs(L-w)>1e-9?w-L:b.edgeIdx-S.edgeIdx});for(let b=1;b<u.length;b++){const S=u[b],L=B(S),w=X.get(P(S.srcId,S.srcSide))??0,k=X.get(P(S.srcId,L))??0;k>=w||(X.set(P(S.srcId,S.srcSide),w-1),X.set(P(S.srcId,L),k+1),S.srcSide=L)}}const z=f(u=>{const b=u?.shape;return b==="question"||b==="diamond"},"isDiamondNode"),U=new Map;for(const u of O.values())U.has(u.dstId)||U.set(u.dstId,new Set),U.get(u.dstId).add(u.dstSide);for(const u of O.values()){if(!z(r.get(u.srcId)))continue;const b=U.get(u.srcId);if(!b?.has(u.srcSide))continue;const S=B(u);if(b.has(S)||(X.get(P(u.srcId,S))??0)>0)continue;const L=X.get(P(u.srcId,u.srcSide))??0;X.set(P(u.srcId,u.srcSide),Math.max(0,L-1)),X.set(P(u.srcId,S),1),u.srcSide=S}for(const u of O.values()){const{edgeIdx:b,srcId:S,dstId:L,srcSide:w,dstSide:k}=u,W=r.get(S),q=r.get(L),V=`${S}:${w}:src`,G=w==="top"||w==="bottom"?q.x??0:q.y??0;m.has(V)||m.set(V,[]),m.get(V).push({edgeIdx:b,oppositeCoord:G});const st=`${L}:${k}:dst`,it=k==="top"||k==="bottom"?W.x??0:W.y??0;m.has(st)||m.set(st,[]),m.get(st).push({edgeIdx:b,oppositeCoord:it})}const Z=new Map,ht=8;for(const[u,b]of m){if(b.length<2)continue;b.sort((wt,Ht)=>wt.oppositeCoord-Ht.oppositeCoord);const S=u.split(":"),L=S.slice(0,-2).join(":"),w=S[S.length-2],k=S[S.length-1],W=r.get(L);if(!W)continue;const V=w==="left"||w==="right"?W.height??10:W.width??10,G=W.shape,it=G==="question"||G==="diamond"?V*.3:V,et=Math.min(20,Math.max(ht,it/(b.length+1))),Ot=-(et*(b.length-1))/2;for(const[wt,Ht]of b.entries()){const Qt=Ot+wt*et,uo=`${Ht.edgeIdx}:${k}`;Z.set(uo,Qt)}}const yt=f(u=>!!s[u]?.labelNodeId,"edgeHasLabelNode"),Ft=f((u,b)=>u?(m.get(`${u}:${b}:src`)??[]).some(({edgeIdx:S})=>yt(S))||(m.get(`${u}:${b}:dst`)??[]).some(({edgeIdx:S})=>yt(S)):!1,"faceHasLabelNode"),Pt=f((u,b,S)=>b==="top"||b==="bottom"?{x:u.x+S,y:u.y}:{x:u.x,y:u.y+S},"applyPortOffset"),tt=f((u,b,S)=>{const L=O.get(u),w={x:S.x??0,y:S.y??0},k={x:b.x??0,y:b.y??0},W=L?.srcSide??R(b,w),q=L?.dstSide??R(S,k);let V=L?C(b,L.srcSide):h(b,w,!0),G=L?C(S,L.dstSide):h(S,k,!1);const st=Z.get(`${u}:src`),it=Z.get(`${u}:dst`);return st!==void 0&&(V=Pt(V,W,st)),it!==void 0&&(G=Pt(G,q,it)),{pSrcPort:V,pDstPort:G,srcSide:W,dstSide:q}},"portsForEdge");for(const u of T){const b=s[u];if(c[u]=[],!b.start||!b.end||b.points&&b.points.length>0||b.start===b.end)continue;const S=r.get(b.start),L=r.get(b.end);if(!S||!L)continue;const{pSrcPort:w,pDstPort:k,srcSide:W,dstSide:q}=tt(u,S,L),V={...w},G={...k},st=W==="top"||W==="bottom",it=q==="top"||q==="bottom";if(st){const Y=w.y>(S.y??0);V.y=Y?w.y+se:w.y-se}else{const Y=w.x>(S.x??0);V.x=Y?w.x+se:w.x-se}if(it){const Y=k.y>(L.y??0);G.y=Y?k.y+se:k.y-se}else{const Y=k.x>(L.x??0);G.x=Y?k.x+se:k.x-se}const rt=f((Y,$)=>{for(const J of g)if(!$.includes(J.nodeId)&&Y.x>J.minX&&Y.x<J.maxX&&Y.y>J.minY&&Y.y<J.maxY)return{inside:!0,obstacle:J};return{inside:!1}},"isPointInObstacle"),et=f((Y,$,J,ft,vt)=>{if(vt){const Nt=Y.y>($.y??0);return{x:(J.x??0)>=Y.x?ft.maxX+Se:ft.minX-Se,y:Nt?ft.maxY+Ne:ft.minY-Ne,leavesPositiveSide:Nt}}const Mt=Y.x>($.x??0),Rt=(J.y??0)>=Y.y;return{x:Mt?ft.maxX+Se:ft.minX-Se,y:Rt?ft.maxY+Ne:ft.minY-Ne,leavesPositiveSide:Mt}},"obstacleDetour");let xt=[];const Ot=[b.start,b.end],wt=rt(V,Ot);if(wt.inside&&wt.obstacle){const Y=wt.obstacle;if(st){const $=et(w,S,L,Y,!0);V.x=$.x,V.y=$.y;const J=$.leavesPositiveSide?Math.min(Y.minY-2,w.y+se):Math.max(Y.maxY+2,w.y-se);xt=[{x:w.x,y:J},{x:$.x,y:J},{x:$.x,y:$.y}]}else{const $=et(w,S,L,Y,!1),J=$.leavesPositiveSide?Math.min(Y.minX-2,w.x+se):Math.max(Y.maxX+2,w.x-se);V.x=$.x,V.y=$.y,xt=[{x:J,y:w.y},{x:J,y:$.y},{x:$.x,y:$.y}]}}let Ht=[];const Qt=rt(G,Ot);if(Qt.inside&&Qt.obstacle){const Y=Qt.obstacle;if(it){const $=et(k,L,S,Y,!0);G.x=$.x,G.y=$.y,Ht=[{x:$.x,y:$.y},{x:k.x,y:$.y}]}else{const $=et(k,L,S,Y,!1);G.x=$.x,G.y=$.y,Ht=[{x:$.x,y:$.y},{x:$.x,y:k.y}]}}if(xt.length===0&&Ht.length===0){const Y=Se,$=Math.abs(V.x-G.x)<Y,J=Math.abs(V.y-G.y)<Y,ft=Z.get(`${u}:src`)!==void 0||Z.get(`${u}:dst`)!==void 0,vt=(m.get(`${b.start??""}:${W}:src`)?.length??0)+(m.get(`${b.start??""}:${W}:dst`)?.length??0),Mt=(m.get(`${b.end??""}:${q}:src`)?.length??0)+(m.get(`${b.end??""}:${q}:dst`)?.length??0),Rt=vt>1||Mt>1,Nt=I.get(b.start??"")??0,gt=I.get(b.end??"")??0,Gt=vt>1&&Ft(b.start,W)||Mt>1&&Ft(b.end,q),oe=vt<=1||Nt<=2,kt=Mt<=1||gt<=2;if(($||J)&&!ft&&(!Rt||Rt&&!Gt&&oe&&kt)&&!E(w,k,b.start,b.end)){b.points=[{...w},{...V},{...G},{...k}],y.add(u);const It=J?"horizontal":"vertical",Vt=J?w.y:w.x,St=J?Math.min(w.x,k.x):Math.min(w.y,k.y),Ct=J?Math.max(w.x,k.x):Math.max(w.y,k.y),Jt={id:`fast-path-${It}-${Vt.toFixed(0)}-${u}`,orientation:It,coord:Vt,spanMin:St,spanMax:Ct,tracks:[]};p.push({edgeIndex:u,segmentIndex:0,orientation:It,pipe:Jt,trackIndex:0,from:St,to:Ct});continue}}const uo=x("vertical",V.x,V.y,V.y);V.x=uo.coord;const gr=x("vertical",G.x,G.y,G.y);G.x=gr.coord;let pe=Math.min(V.x,G.x)-50,me=Math.max(V.x,G.x)+50,Re=Math.min(V.y,G.y)-50,Ae=Math.max(V.y,G.y)+50;for(const Y of g){const $=Math.min(V.x,G.x),J=Math.max(V.x,G.x),ft=Math.min(V.y,G.y),vt=Math.max(V.y,G.y);Y.minX<J&&Y.maxX>$&&Y.minY<vt&&Y.maxY>ft&&(pe=Math.min(pe,Y.minX-cn),me=Math.max(me,Y.maxX+cn),Re=Math.min(Re,Y.minY-cn),Ae=Math.max(Ae,Y.maxY+cn))}for(const Y of g){if(Y.maxX<pe||Y.minX>me||Y.maxY<Re||Y.minY>Ae)continue;const $=Se;x("horizontal",Y.minY-$,pe,me),x("horizontal",Y.maxY+$,pe,me);const J=Ne;x("vertical",Y.minX-J,Re,Ae),x("vertical",Y.maxX+J,Re,Ae)}x("horizontal",V.y,pe,me),x("horizontal",G.y,pe,me);const pr=l.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=Re&&Y.coord<=Ae),mr=l.filter(Y=>Y.orientation==="vertical"&&Y.coord>=pe&&Y.coord<=me),Je=f((Y,$)=>`${Y.toFixed(1)},${$.toFixed(1)}`,"getKey"),qe=Je(V.x,V.y),er=Je(G.x,G.y),Ze=new Map,ho=new Map,go=new Map,Qe=new Set,Ie=[];Ze.set(qe,0),go.set(qe,"n"),Ie.push({key:qe,f:Math.hypot(G.x-V.x,G.y-V.y),pt:V}),Qe.add(qe);let Xt=[];const ye=f((Y,$)=>E(Y,$,b.start,b.end),"checkSegmentBlocked"),po={x:G.x,y:V.y},yr=ye(V,po),xr=ye(po,G),br=yr||xr,mo={x:V.x,y:G.y},Mr=ye(V,mo),Ir=ye(mo,G);if(br?Mr||Ir||(Math.abs(V.x-G.x)<at?Xt=[V,G]:Xt=[V,mo,G]):Math.abs(V.y-G.y)<at||Math.abs(V.x-G.x)<at?Xt=[V,G]:Xt=[V,po,G],Xt.length===0)for(;Ie.length>0;){Ie.sort((gt,Gt)=>gt.f-Gt.f);const Y=Ie.shift();if(Qe.delete(Y.key),Y.key===er){let gt=er,Gt=G;for(Xt=[Gt];ho.has(gt);){const oe=ho.get(gt);Xt.unshift(oe),Gt=oe,gt=Je(oe.x,oe.y)}break}const $=Y.pt.x,J=Y.pt.y,ft=mr.sort((gt,Gt)=>gt.coord-Gt.coord),vt=ft.findIndex(gt=>Math.abs(gt.coord-$)<1),Mt=pr.sort((gt,Gt)=>gt.coord-Gt.coord),Rt=Mt.findIndex(gt=>Math.abs(gt.coord-J)<1),Nt=[];vt>0&&Nt.push({x:ft[vt-1].coord,y:J}),vt>=0&&vt<ft.length-1&&Nt.push({x:ft[vt+1].coord,y:J}),Rt>0&&Nt.push({x:$,y:Mt[Rt-1].coord}),Rt>=0&&Rt<Mt.length-1&&Nt.push({x:$,y:Mt[Rt+1].coord});for(const gt of Nt){const Gt=Math.min($,gt.x),oe=Math.max($,gt.x),kt=Math.min(J,gt.y),$t=Math.max(J,gt.y);if(g.some(te=>te.nodeId===b.start||te.nodeId===b.end?!1:Gt!==oe?te.minY<J&&te.maxY>J&&te.maxX>Gt&&te.minX<oe:te.minX<$&&te.maxX>$&&te.maxY>kt&&te.minY<$t))continue;const It=Je(gt.x,gt.y),Vt=Math.abs(gt.x-$)+Math.abs(gt.y-J),St=M(u,Y.pt,gt);let Ct=0;const Jt=G.x-V.x,Oe=G.y-V.y,tn=gt.x-$,yo=gt.y-J;(Oe>10&&yo<-5||Oe<-10&&yo>5)&&(Ct=Math.abs(yo)*100),(Jt>10&&tn<-5||Jt<-10&&tn>5)&&(Ct+=Math.abs(tn)*50);let nr=0;const or=go.get(Y.key)??"n",sr=Math.abs(tn)>at?"h":"v";or!=="n"&&or!==sr&&(nr=50);const Sr=Vt+St+Ct+nr,en=(Ze.get(Y.key)??1/0)+Sr,rr=Math.abs(G.x-gt.x)+Math.abs(G.y-gt.y);if(en<(Ze.get(It)??1/0))if(ho.set(It,Y.pt),Ze.set(It,en),go.set(It,sr),!Qe.has(It))Ie.push({key:It,f:en+rr,pt:gt}),Qe.add(It);else{const te=Ie.findIndex(Cr=>Cr.key===It);te!==-1&&(Ie[te].f=en+rr)}}}if(Xt.length===0&&(Xt=[V,{x:V.x,y:G.y},G]),Xt.length>4){const Y=Xt[0],$=Xt[Xt.length-1];let J=Math.min(Y.x,$.x),ft=Math.max(Y.x,$.x),vt=Math.min(Y.y,$.y),Mt=Math.max(Y.y,$.y);for(const kt of Xt)J=Math.min(J,kt.x),ft=Math.max(ft,kt.x),vt=Math.min(vt,kt.y),Mt=Math.max(Mt,kt.y);const Rt=ft>Math.max(Y.x,$.x),Nt=J<Math.min(Y.x,$.x);if(d){const kt=Ne;if(Rt){const $t=Math.max(Y.x,$.x),Bt=Math.min(Y.y,$.y),It=Math.max(Y.y,$.y),Vt=g.filter(St=>St.minX<$t&&St.maxX>$t&&St.minY<It&&St.maxY>Bt);if(Vt.length>0){let St=Math.max(Y.x,$.x);for(const Ct of Vt){const Jt=(Ct.minX+Ct.maxX)/2;if(Ct.visualXHalfExtent===void 0||isNaN(Ct.visualXHalfExtent))continue;const Oe=Jt+Ct.visualXHalfExtent+kt;St=Math.max(St,Oe)}isNaN(St)||(ft=St)}}if(Nt){const $t=g.filter(Bt=>Bt.minX<Math.min(Y.x,$.x)+kt&&Bt.minY<Math.max(Y.y,$.y)&&Bt.maxY>Math.min(Y.y,$.y));if($t.length>0){let Bt=Math.min(Y.x,$.x);for(const It of $t){const St=(It.minX+It.maxX)/2-It.visualXHalfExtent-kt;Bt=Math.min(Bt,St)}J=Bt}}}const gt=f(kt=>{const $t=$.y>Y.y,Bt=g.filter(St=>{const Ct=Math.min(Y.x,$.x)<St.maxX&&Math.max(Y.x,$.x)>St.minX,Jt=Math.min(Y.y,$.y)<St.maxY&&Math.max(Y.y,$.y)>St.minY;return Ct&&Jt});let It=Bt;if(d&&Bt.length>0){const St=Bt.filter(Ct=>Ct.minX<kt&&Ct.maxX>kt);St.length>0&&(It=St)}if(It.length===0)return $.y;const Vt=Se;if($t){const Ct=Math.max(...It.map(Jt=>Jt.maxY))+Vt;if(Ct<$.y-at)return Ct}else{const Ct=Math.min(...It.map(Jt=>Jt.minY))-Vt;if(Ct>$.y+at)return Ct}return $.y},"findBestReturnY"),Gt=f(kt=>{const $t=gt(kt),Bt={x:kt,y:Y.y},It={x:kt,y:$t},Vt={x:$.x,y:$t},St=ye(Y,Bt),Ct=ye(Bt,It),Jt=ye(It,Vt),Oe=$t!==$.y?ye(Vt,$):!1;return!St&&!Ct&&!Jt&&!Oe?Math.abs($t-$.y)<at?[Y,Bt,It,$]:[Y,Bt,It,Vt,$]:null},"trySimplifyWithDetourX"),oe=Rt&&!Nt?Gt(ft):Nt&&!Rt?Gt(J):null;oe&&(Xt=oe)}const Yt=[w,...xt,...Xt,...Ht.reverse(),k];if(Yt.length>=3){const Y=Yt[Yt.length-1],$=Yt[Yt.length-2],J=Yt[Yt.length-3],ft=Math.abs(J.y-$.y)<at&&Math.abs($.y-Y.y)<at,vt=Math.abs(J.x-$.x)<at&&Math.abs($.x-Y.x)<at;if(ft){const Mt=Math.sign($.x-J.x),Rt=Math.sign(Y.x-J.x);Mt!==0&&Mt===Rt&&Math.abs($.x-J.x)>Math.abs(Y.x-J.x)&&Yt.splice(-2,1)}else if(vt){const Mt=Math.sign($.y-J.y),Rt=Math.sign(Y.y-J.y);Mt!==0&&Mt===Rt&&Math.abs($.y-J.y)>Math.abs(Y.y-J.y)&&Yt.splice(-2,1)}}const le=[Yt[0]];for(let Y=1;Y<Yt.length-1;Y++){if(Y===1){le.push(Yt[Y]);continue}const $=le[le.length-1],J=Yt[Y],ft=Yt[Y+1];if(Math.abs($.y-J.y)<at&&Math.abs(J.y-ft.y)<at){const vt=J.x>$.x,Mt=ft.x>J.x;if(vt!==Mt){le.push(J);continue}continue}if(Math.abs($.x-J.x)<at&&Math.abs(J.x-ft.x)<at){const vt=J.y>$.y,Mt=ft.y>J.y;if(vt!==Mt){le.push(J);continue}continue}le.push(J)}le.push(Yt[Yt.length-1]);for(let Y=0;Y<le.length-1;Y++){const $=le[Y],J=le[Y+1],ft=Math.abs($.x-J.x)<at?"vertical":"horizontal",vt=ft==="vertical"?$.x:$.y,Mt=ft==="vertical"?Math.min($.y,J.y):Math.min($.x,J.x),Rt=ft==="vertical"?Math.max($.y,J.y):Math.max($.x,J.x),Nt=x(ft,vt,Mt,Rt),gt={edgeIndex:u,segmentIndex:Y,orientation:ft,pipe:Nt,trackIndex:0,from:Mt,to:Rt};p.push(gt),c[u].push(p.length-1),Nt.tracks[0]||(Nt.tracks[0]={index:0,coord:Nt.coord,segments:[]}),Nt.tracks[0].segments.push({edgeIndex:u,segmentIndex:Y,from:Mt,to:Rt})}}const K=f((u,b)=>u.from<b.to&&b.from<u.to,"segmentsOverlap"),nt=f((u,b,S,L)=>{const w=!L.segments.some(W=>(W.edgeIndex!==b.edgeIndex||W.segmentIndex!==b.segmentIndex)&&K(W,u)),k=!S.segments.some(W=>(W.edgeIndex!==u.edgeIndex||W.segmentIndex!==u.segmentIndex)&&K(W,b));return w&&k?(u.trackIndex=L.index,b.trackIndex=S.index,S.segments=[...S.segments.filter(W=>W.edgeIndex!==u.edgeIndex||W.segmentIndex!==u.segmentIndex),{edgeIndex:b.edgeIndex,segmentIndex:b.segmentIndex,from:b.from,to:b.to}],L.segments=[...L.segments.filter(W=>W.edgeIndex!==b.edgeIndex||W.segmentIndex!==b.segmentIndex),{edgeIndex:u.edgeIndex,segmentIndex:u.segmentIndex,from:u.from,to:u.to}],!0):!1},"trySwapSegmentsAcrossTracks"),lt=f(u=>{const b=u.tracks.length;return u.tracks[b]={index:b,coord:u.coord,segments:[]},b},"createNewTrack"),pt=f((u,b)=>{const S=u.pipe.tracks[u.trackIndex];S.segments=S.segments.filter(w=>w.edgeIndex!==u.edgeIndex||w.segmentIndex!==u.segmentIndex),u.trackIndex=b,u.pipe.tracks[b].segments.push({edgeIndex:u.edgeIndex,segmentIndex:u.segmentIndex,from:u.from,to:u.to})},"moveSegmentToTrack"),bt=f((u,b)=>{const S=c[u.edgeIndex];for(const L of S){const w=p[L];w.pipe===u.pipe&&pt(w,b)}},"moveSegmentChainToTrack"),Lt=f(u=>{const b=c[u.edgeIndex],S=b.indexOf(p.indexOf(u)),L=[];return S>0&&L.push(p[b[S-1]]),S<b.length-1&&L.push(p[b[S+1]]),L},"getAdjacentSegmentsAlongEdge"),Ut=f((u,b)=>{if(u.orientation===b.orientation)return!1;const S=u.orientation==="horizontal"?u:b,L=u.orientation==="horizontal"?b:u;return L.pipe.coord>S.from&&L.pipe.coord<S.to&&S.pipe.coord>L.from&&S.pipe.coord<L.to},"haveAnyCrossing"),Wt=f((u,b)=>{for(const S of u.tracks)if(!S.segments.some(w=>(w.edgeIndex!==b.edgeIndex||w.segmentIndex!==b.segmentIndex)&&K(w,b)))return S.index;return-1},"findAvailableTrack"),Kt=f((u,b)=>{if(u.trackIndex===b.trackIndex)return K(u,b);const S=Lt(u),L=Lt(b);return S.some(w=>L.some(k=>Ut(w,k)))},"segmentsConflict"),ne=f((u,b,S)=>{if(nt(u,b,u.pipe.tracks[u.trackIndex],b.pipe.tracks[b.trackIndex]))return;const L=Wt(u.pipe,b);S(b,L!==-1?L:lt(u.pipe))},"resolveTrackConflict"),Ee=f(u=>{let b=0;for(let S=0;S<u.length;S++)for(let L=S+1;L<u.length;L++){const w=u[S],k=u[L];w.pipe===k.pipe&&Kt(w,k)&&(b++,ne(w,k,bt))}return b},"resolveHandleConflicts"),ge=new Map,we=f(u=>{if(ge.has(u))return ge.get(u);const b=c[u];if(b.length===0){const q={dest:0,deviation:0,base:0,delta:0};return ge.set(u,q),q}const L=p[b[0]].pipe.coord;let w=L;for(let q=1;q<b.length;q++){const V=p[b[q]];if(V.orientation==="horizontal"){const G=V.from,st=V.to;w=Math.abs(G-L)>Math.abs(st-L)?G:st;break}}const k=Math.abs(w-L),W={dest:w,deviation:k,base:L,delta:w-L};return ge.set(u,W),W},"getDestInfo"),ao=f(()=>{let u=0;const b=new Map;for(const[L,w]of s.entries())c[L].length!==0&&w.start&&(b.has(w.start)||b.set(w.start,[]),b.get(w.start).push(L));const S=f(L=>{const w=s[L];if(!w.start||!w.end)return 0;const k=r.get(w.start),W=r.get(w.end);if(!k||!W)return 0;const q=(W.x??0)-(k.x??0),V=(W.y??0)-(k.y??0);return Math.abs(q)+Math.abs(V)},"getEdgeDistance");for(const L of b.values()){L.sort((k,W)=>{const q=we(k),V=we(W);if(Math.abs(q.deviation-V.deviation)>1)return q.deviation-V.deviation;if(Math.abs(q.dest-V.dest)>1)return q.dest-V.dest;const G=S(k),st=S(W);if(Math.abs(G-st)>1)return st-G;const it=c[k].length,rt=c[W].length;if(it!==rt)return it-rt;if(it===1){const et=c[k][0],xt=c[W][0];if(p[et]&&p[xt]){const Ot=p[et],wt=p[xt],Ht=Math.abs(Ot.to-Ot.from),Qt=Math.abs(wt.to-wt.from);if(Math.abs(Ht-Qt)>1)return Ht-Qt}}return 0});const w=L.map(k=>p[c[k][0]]);u+=Ee(w)}return u},"fixSourceHandleCrossings"),lo=f(()=>{let u=0;const b=new Map;for(const[S,L]of s.entries())c[S].length!==0&&L.end&&(b.has(L.end)||b.set(L.end,[]),b.get(L.end).push(S));for(const S of b.values()){S.sort((w,k)=>{const W=f(G=>{const st=c[G];if(st.length<2)return 0;const it=p[st[st.length-2]];return Math.abs(it.to-it.from)},"getDist"),q=W(w),V=W(k);return Math.abs(q-V)>.1?q-V:w-k});const L=S.map(w=>p[c[w][c[w].length-1]]);u+=Ee(L)}return u},"fixTargetHandleCrossings"),fo=f(()=>{let u=0;for(const b of l){const S=[];for(const L of b.tracks)for(const w of L.segments){const k=c[w.edgeIndex].find(W=>p[W].segmentIndex===w.segmentIndex);k!==void 0&&S.push(p[k])}S.sort((L,w)=>L.edgeIndex-w.edgeIndex||L.segmentIndex-w.segmentIndex);for(let L=0;L<S.length;L++)for(let w=L+1;w<S.length;w++){const k=S[L],W=S[w];Kt(k,W)&&(u++,ne(k,W,pt))}}return u},"fixPipeCrossings");let N=0;const D=10;for(;N<D;){let u=0;if(u+=ao(),u+=lo(),u+=fo(),u===0)break;N++}const H=new Map;for(const u of l){const b=[];u.tracks.forEach(L=>{L.segments.forEach(w=>{b.push({edgeIndex:w.edgeIndex,segmentIndex:w.segmentIndex,trackIndex:L.index,from:w.from,to:w.to})})}),b.sort((L,w)=>L.from-w.from);const S=[];if(b.length>0){let L=[b[0]],w=b[0].to;for(let k=1;k<b.length;k++){const W=b[k];W.from<w?(L.push(W),w=Math.max(w,W.to)):(S.push(L),L=[W],w=W.to)}S.push(L)}for(const L of S){const w=new Set;L.forEach(et=>w.add(et.trackIndex));const k=new Map;L.forEach(et=>{const xt=we(et.edgeIndex);k.set(et.trackIndex,(k.get(et.trackIndex)??0)+xt.delta)});const W=[...w].filter(et=>(k.get(et)??0)<-1),q=[...w].filter(et=>(k.get(et)??0)>1),V=[...w].filter(et=>Math.abs(k.get(et)??0)<=1);W.sort((et,xt)=>(k.get(xt)??0)-(k.get(et)??0)),q.sort((et,xt)=>(k.get(et)??0)-(k.get(xt)??0));const G=f((et,xt)=>{L.filter(Ot=>Ot.trackIndex===et).forEach(Ot=>{const wt=y.has(Ot.edgeIndex)?u.coord:xt;H.set(`${Ot.edgeIndex}-${Ot.segmentIndex}`,wt)})},"assignCoord");let st=0;for(const et of W)st++,G(et,u.coord-st*Io);if(V.length===0&&w.size>0){const et=[...w].sort((wt,Ht)=>Math.abs(k.get(wt)??0)-Math.abs(k.get(Ht)??0))[0],xt=W.indexOf(et);xt!==-1&&W.splice(xt,1);const Ot=q.indexOf(et);Ot!==-1&&q.splice(Ot,1),V.push(et)}let it=0;for(const et of V){if(it===0)G(et,u.coord);else{const xt=it%2===1?1:-1,Ot=Math.ceil(it/2);G(et,u.coord+xt*Ot*Io*.5)}it++}let rt=0;for(const et of q)rt++,G(et,u.coord+rt*Io)}}for(const[u,b]of s.entries()){const S=c[u]??[];if(S.length===0)continue;const L=[],w=r.get(b.start),k=r.get(b.end),{pSrcPort:W,pDstPort:q}=tt(u,w,k),V=S.map(it=>{const rt=p[it],et=H.get(`${rt.edgeIndex}-${rt.segmentIndex}`)??rt.pipe.coord;return{orient:rt.orientation,coord:et,from:rt.from,to:rt.to}});L.push(W);for(let it=0;it<V.length;it++){const rt=V[it],et=L[L.length-1],xt=rt.orient==="vertical"?et.y:et.x,Ot=rt.orient==="vertical"?et.x:et.y,wt=V[it+1],Ht=it<V.length-1;if(Math.abs(Ot-rt.coord)>at&&L.push(be(rt,xt)),Ht&&wt.orient===rt.orient)if(Math.abs(rt.coord-wt.coord)>at){const Qt=rt.orient==="vertical"?(xt+wt.from)/2:Yn(rt,wt);L.push(be(rt,Qt),be(wt,Qt))}else(it===0||it===V.length-2)&&L.push(be(rt,Yn(rt,wt)));else if(Ht)L.push(be(rt,wt.coord));else{const Qt=Math.abs(rt.from-xt)<Math.abs(rt.to-xt)?rt.to:rt.from;L.push(be(rt,Qt))}}const G=L[L.length-1];(Math.abs(G.x-q.x)>at||Math.abs(G.y-q.y)>at)&&L.push(q);const st=[];L.length>0&&st.push(L[0]);for(let it=1;it<L.length;it++){const rt=L[it],et=st[st.length-1];(Math.abs(rt.x-et.x)>at||Math.abs(rt.y-et.y)>at)&&st.push(rt)}b.points=st}for(const u of s){const b=u.__originalEdge;b&&u.points&&(b.points=u.points)}t.edges=(t.edges??[]).filter(u=>!u.isLayoutOnly);const j=f((u,b)=>{const S=b.x??0,L=b.y??0,w=b.width??0,k=b.height??0;if(w<=0||k<=0)return u;const W=S-w/2,q=S+w/2,V=L-k/2,G=L+k/2;if(u.x<W||u.x>q||u.y<V||u.y>G)return u;const st=u.x-W,it=q-u.x,rt=u.y-V,et=G-u.y,xt=Math.min(st,it,rt,et);return xt===st?{x:W,y:u.y}:xt===it?{x:q,y:u.y}:xt===rt?{x:u.x,y:V}:{x:u.x,y:G}},"nodeBoundaryClamp");for(const u of t.edges){const b=u.points;if(!b||b.length<2)continue;const S=u.start,L=u.end,w=S?r.get(S):void 0,k=L?r.get(L):void 0;w&&(b[0]=j(b[0],w)),k&&(b[b.length-1]=j(b[b.length-1],k))}return t}A(qs,"routeEdgesOrthogonal");f(qs,"routeEdgesOrthogonal");function Zs(t){return t.direction??"TB"}A(Zs,"getSwimlaneDirection");f(Zs,"getSwimlaneDirection");function Qs(t){const e=Fo(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,a=t.config.swimlane?.automaticLaneOrdering??!1,l=Zs(t),{ordered:d,coordinates:i}=Js(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:a,direction:l});_o(e,d,i,{nodeGap:n,layerGap:o});for(const g of t.edges??[])delete g.points;qs(t,l);for(const g of t.edges??[])(!g.curve||g.curve==="basis")&&(g.curve="rounded");return ps(t,l),gs(t),l}A(Qs,"runSwimlaneLayoutCore");f(Qs,"runSwimlaneLayoutCore");function tr(t){ko(t);const e=Do(t);t.nodes=e.nodes,t.edges=e.edges}A(tr,"prepareSwimlaneLayout");f(tr,"prepareSwimlaneLayout");var Hr=vr({prepareLayout:tr,runLayoutCore:Qs,afterPaint:Bo});export{Hr as render};
|
|
1
|
+
import{t as vr,ad as So,a as f,ag as ir}from"./DPBL52wT.js";import{g as A}from"./CQcnUt15.js";var cr=5,nn=1e-5,on=1e-6;function _e(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}A(_e,"buildSegmentList");f(_e,"buildSegmentList");function Co(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,a=o.x-n.x,l=o.y-n.y,d=s*l-r*a;if(d===0)return null;const i=n.x-t.x,g=n.y-t.y,x=(i*l-g*a)/d,C=(i*r-g*s)/d;return x<=on||x>=1-on||C<=on||C>=1-on?null:{point:{x:t.x+x*s,y:t.y+x*r},tA:x,tB:C}}A(Co,"segmentIntersection");f(Co,"segmentIntersection");function an(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}A(an,"isHorizontalSeg");f(an,"isHorizontalSeg");function vo(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],s=_e(o.points);for(let r=n+1;r<t.length;r++){const a=t[r],l=_e(a.points);for(const[d,i]of s.entries())for(const[g,x]of l.entries()){const C=Co(i.a,i.b,x.a,x.b);if(!C)continue;const h=an(i),p=an(x);(h!==p?h:!1)?e.push({jumpEdgeId:o.id,otherEdgeId:a.id,segIndex:d,t:C.tA,point:C.point}):e.push({jumpEdgeId:a.id,otherEdgeId:o.id,segIndex:g,t:C.tB,point:C.point})}}}return e}A(vo,"findEdgeIntersections");f(vo,"findEdgeIntersections");function re(t){const e=Math.round(t*1e3)/1e3;return Number.isInteger(e)?`${e}`:`${e}`}A(re,"fmt");f(re,"fmt");function Ce(t){return`${re(t.x)},${re(t.y)}`}A(Ce,"pointToString");f(Ce,"pointToString");function Lo(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}A(Lo,"getArcSweepFlag");f(Lo,"getArcSweepFlag");var Lr=.001;function To(t,e){if(t.length<2)return t.map(r=>({...r}));const n=t.map(r=>({...r})),o=e.arrowTypeStart&&ir[e.arrowTypeStart];if(o){const r=t[0],a=t[1],l=Math.atan2(a.y-r.y,a.x-r.x);n[0].x=r.x+o*Math.cos(l),n[0].y=r.y+o*Math.sin(l)}const s=e.arrowTypeEnd&&ir[e.arrowTypeEnd];if(s){const r=t.length,a=t[r-2],l=t[r-1],d=Math.atan2(l.y-a.y,l.x-a.x);n[r-1].x=l.x-s*Math.cos(d),n[r-1].y=l.y-s*Math.sin(d)}return n}A(To,"applyMarkerOffsets");f(To,"applyMarkerOffsets");function Eo(t,e,n,o,s){const r=t.point.x,a=t.point.y,l={x:r-e*t.r,y:a-n*t.r},d={x:r+e*t.r,y:a+n*t.r},i=[`L${Ce(l)}`];return s==="arc"?i.push(`A${re(t.r)},${re(t.r)} 0 0 ${o} ${Ce(d)}`):i.push(`M${Ce(d)}`),i}A(Eo,"emitJump");f(Eo,"emitJump");function ln(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,a=n.x-e.x,l=n.y-e.y,d=Math.hypot(s,r),i=Math.hypot(a,l);if(d<nn||i<nn)return null;const g=s/d,x=r/d,C=a/i,h=l/i,p=g*C+x*h,c=Math.max(-1,Math.min(1,p)),y=Math.acos(c);if(y<nn||Math.abs(Math.PI-y)<nn)return null;const v=Math.min(o/Math.sin(y/2),d/2,i/2);return{startX:e.x-g*v,startY:e.y-x*v,endX:e.x+C*v,endY:e.y+h*v,ctrlX:e.x,ctrlY:e.y,cutLen:v}}A(ln,"computeRoundedCorner");f(ln,"computeRoundedCorner");function wo(t,e,n){const o=t.points;if(o.length<2)return"";const s=To(o,t),r=t.curve==="rounded",a=_e(s),l=new Map;for(const i of e){const g=a[i.segIndex];if(!g)continue;const x=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),C=l.get(i.segIndex)??[];C.push({t:i.t,point:i.point,d:i.t*x,r:n.jumpRadius}),l.set(i.segIndex,C)}const d=[`M${Ce(s[0])}`];for(let i=0;i<a.length;i++){const g=a[i],x=Math.hypot(g.b.x-g.a.x,g.b.y-g.a.y),C=x===0?0:(g.b.x-g.a.x)/x,h=x===0?0:(g.b.y-g.a.y)/x,p=Lo(g);let c=0;if(r&&i>0){const T=ln(s[i-1],s[i],s[i+1]??s[i],cr);T&&(c=T.cutLen)}let y=x,v=null;r&&i<a.length-1&&(v=ln(s[i],s[i+1],s[i+2]??s[i+1],cr),v&&(y=x-v.cutLen));const M=[...l.get(i)??[]].sort((T,E)=>T.t-E.t);for(const T of M)T.r=Math.min(T.r,T.d-c,y-T.d);for(let T=0;T<M.length-1;T++){const E=M[T+1].d-M[T].d;if(M[T].r+M[T+1].r>E){const m=E/2;M[T].r=Math.min(M[T].r,m),M[T+1].r=Math.min(M[T+1].r,m)}}for(const T of M)T.r<Lr||d.push(...Eo(T,C,h,p,n.jumpStyle));r&&v?(d.push(`L${re(v.startX)},${re(v.startY)}`),d.push(`Q${re(v.ctrlX)},${re(v.ctrlY)} ${re(v.endX)},${re(v.endY)}`)):d.push(`L${Ce(g.b)}`)}return d.join(" ")}A(wo,"rewriteEdgePath");f(wo,"rewriteEdgePath");function Ro(t){return/^[\d\s+,.LMelm-]*$/.test(t)}A(Ro,"isStraightPath");f(Ro,"isStraightPath");function Ao(t){return t?t==="linear"||t==="rounded"||t==="step"||t==="stepBefore"||t==="stepAfter":!0}A(Ao,"curveSupportsLineHops");f(Ao,"curveSupportsLineHops");function Oo(t){if(!t)return null;try{const e=typeof atob=="function"?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const s of n)s&&typeof s.x=="number"&&typeof s.y=="number"&&o.push({x:s.x,y:s.y});return o.length>=2?o:null}catch{return null}}A(Oo,"decodeDataPoints");f(Oo,"decodeDataPoints");function No(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const s=new Map;for(const i of e)s.set(i.id,i);const r=[],a=new Map;for(const i of e){const g=typeof CSS<"u"&&CSS.escape?CSS.escape(i.id):i.id,x=o.querySelector(`path[data-id="${g}"]`);if(!x)continue;a.set(i.id,x);const h=Oo(x.getAttribute("data-points"))??i.points;r.push({...i,points:h})}const l=vo(r);if(l.length===0)return;const d=new Map;for(const i of l){const g=d.get(i.jumpEdgeId)??[];g.push(i),d.set(i.jumpEdgeId,g)}for(const i of r){const g=d.get(i.id);if(!g||g.length===0)continue;const C=s.get(i.id)?.curve;if(C!==void 0&&!Ao(C))continue;const h=a.get(i.id);if(!h)continue;if(C===void 0){const T=h.getAttribute("d")??"";if(!Ro(T))continue}const p=h.getAttribute("style")??"",c=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(p),y=c?Number.parseFloat(c[1]):null,v=c?Number.parseFloat(c[2]):null,M=wo(i,g,n);if(h.setAttribute("d",M),y!==null&&v!==null&&typeof h.getTotalLength=="function"){const T=h.getTotalLength(),E=Math.max(0,T-y-v),m=`0 ${y} ${E} ${v}`,I=p.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${m};`).replace(/;\s*;+/g,";");h.setAttribute("style",I)}}}A(No,"applyLineJumpsToSvg");f(No,"applyLineJumpsToSvg");function Bo(t,{measure:e}){const n=t.config?.swimlane?.lineHops;if(n===!1)return;const o=n==="gap"?"gap":"arc",s=t.edges.filter(r=>Array.isArray(r.points)&&r.points.length>=2).map(r=>({id:r.id,points:r.points,curve:r.curve,arrowTypeStart:r.arrowTypeStart,arrowTypeEnd:r.arrowTypeEnd}));No(e.groups.edgePaths,s,{enabled:!0,jumpRadius:6,jumpStyle:o})}A(Bo,"applySwimlaneLineJumps");f(Bo,"applySwimlaneLineJumps");var xo="__swimlane_default__",Tr=21,ar=20;function dn(t){return Math.max(t.padding??ar,ar)}A(dn,"topLaneHorizontalPadding");f(dn,"topLaneHorizontalPadding");function Po(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 a=n-s/2,l=Math.min(r,n+s/2),d=Math.min(Tr,Math.max(0,l-a)),i=a+d;if(i<=a){delete t.groupTitleRect;return}t.groupTitleRect={left:e-o/2,right:e+o/2,top:a,bottom:i}}A(Po,"assignTopLaneTitleRect");f(Po,"assignTopLaneTitleRect");function ko(t){const e=t.direction,n=t.nodes??=[];for(const r of t.nodes??[])r.isGroup&&!r.parentId&&(r.shape="swimlane",e&&(r.direction=e));const o=n.filter(r=>!r.isGroup&&!r.parentId);if(o.length===0)return;let s=n.find(r=>r.id===xo);s?s.isGroup&&(s.shape="swimlane",e&&(s.direction=e)):(s={id:xo,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(s));for(const r of o)r.parentId=xo}A(ko,"prepareLayoutForSwimlanes");f(ko,"prepareLayoutForSwimlanes");function Fo(t){const e=new Map;for(const d of t.nodes??[])e.set(d.id,d);const n=[];for(const d of t.edges??[]){const i=typeof d.start=="string"?d.start:void 0,g=typeof d.end=="string"?d.end:void 0;!i||!g||d.labelNodeId||n.push({id:d.id,src:i,dst:g,ref:d})}const o=t.nodes??[],s=o.filter(d=>d.isGroup),r=o.filter(d=>!d.isGroup);return{nodes:[...[...s].reverse(),...r].map(d=>d.id),edges:n,layout:t,nodeById:e}}A(Fo,"toGraphView");f(Fo,"toGraphView");function _o(t,e,n,o){const{layout:s}=t,r=t.nodeById,a=o?.layerGap??100,l=o?.nodeGap??40;let d=0;for(const C of e.layers){let h=0;for(const p of C){const c=r.get(p);if(!c){h++;continue}c.layer=d,c.order=h;const y=n.x[p]??h*l,v=n.y[p]??d*a;c.x=y,c.y=v,h++}d++}const i=s.nodes??[],g=new Map,x=[];for(const C of i){if(!C?.isGroup)continue;C.parentId||x.push(C);const h=i.filter(M=>M.parentId===C.id);let p=1/0,c=-1/0,y=1/0,v=-1/0;for(const M of h){const T=M.x??n.x[M.id],E=M.y??n.y[M.id],m=M.width??0,I=M.height??0;T!=null&&E!=null&&(p=Math.min(p,T-m/2),c=Math.max(c,T+m/2),y=Math.min(y,E-I/2),v=Math.max(v,E+I/2))}if(p===1/0||y===1/0)C.x=C.x??0,C.y=C.y??0,C.width=C.width??0,C.height=C.height??0;else{const M=C.padding??20,T=C.parentId?M:2*dn(C),E=M,m=Math.max(0,c-p)+T,I=Math.max(0,v-y)+E,R=(p+c)/2,O=(y+v)/2;C.x=R,C.y=O,C.width=m,C.height=I,g.set(C.id,{minX:p,maxX:c,minY:y,maxY:v})}}if(x.length>0&&g.size>0){let C=1/0,h=-1/0,p=0;for(const c of x){const y=c.padding??20;y>p&&(p=y);const v=g.get(c.id);v&&(C=Math.min(C,v.minY),h=Math.max(h,v.maxY))}if(C!==1/0&&h!==-1/0){const c=Math.max(0,h-C),v=Math.max(p,36),M=c+2*v,T=(C+h)/2;for(const F of x)F.y=T,F.height=M,F.swimlaneContentTop=C;const E=[...x].sort((F,B)=>{const _=F.x??0,X=B.x??0;return _-X}),m=[],I=[],R=[];for(const F of E){const B=g.get(F.id);if(!B)continue;const _=Math.max(0,B.maxX-B.minX)+2*dn(F),X=(B.minX+B.maxX)/2;m.push(F.id),I.push(X),R.push(_)}const O=m.length;if(O>0){const F=new Map;if(O===1)F.set(m[0],R[0]);else{const B=[];for(let U=0;U<O-1;U++)B.push(I[U+1]-I[U]);const _=new Array(O);_[0]=0;for(let U=0;U<O-1;U++)_[U+1]=2*B[U]-_[U];let X=0,P=Number.POSITIVE_INFINITY;for(let U=0;U<O;U++){const Z=R[U];U%2===0?X=Math.max(X,Z-_[U]):P=Math.min(P,_[U]-Z)}let z=X;X<=P?z=(X+P)/2:z=X;for(let U=0;U<O;U++){const Z=_[U]+(U%2===0?z:-z),ht=Math.max(R[U],Z);F.set(m[U],ht)}}for(const B of x){const _=F.get(B.id);_!=null&&(B.width=_),Po(B)}}}}}A(_o,"writeBackToLayoutData");f(_o,"writeBackToLayoutData");var Er="[EdgeLabelNodes]";function Do(t){const e=[],n=[],o=new Map;for(const a of t.nodes)o.set(a.id,a);for(const a of t.edges){if(!a.label||a.label.length===0||a.isLayoutOnly||a.labelNodeId)continue;const l=a.start?o.get(a.start):void 0,d=a.end?o.get(a.end):void 0;if(!l||!d){So.warn(Er,`Edge ${a.id} has missing source or target node`);continue}const i=`edge-label-${a.start}-${a.end}-${a.id}`,x=l.parentId!==d.parentId?d.parentId:l.parentId,C={id:i,label:a.label,edgeStart:a.start??"",edgeEnd:a.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:x,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??"",...l.dir?{dir:l.dir}:{}};e.push(C),a.labelNodeId=i,a.label=void 0,a.text=void 0;const h={id:`${a.id}-to-label`,start:a.start,end:i,type:"normal",isLayoutOnly:!0},p={id:`${a.id}-from-label`,start:i,end:a.end,type:"normal",isLayoutOnly:!0};n.push(h,p)}const s=[...t.nodes,...e],r=[...t.edges,...n];return{...t,nodes:s,edges:r}}A(Do,"createEdgeLabelNodes");f(Do,"createEdgeLabelNodes");var Dt=.001;function Gn(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:ve(e,n,o,s)}:void 0}A(Gn,"measuredNodeRect");f(Gn,"measuredNodeRect");function zn(t){if(t.isGroup)return;const e=Gn(t);return e?{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}:void 0}A(zn,"nodeBoundsInfoFor");f(zn,"nodeBoundsInfoFor");function ee(t,e,n=Dt){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}A(ee,"samePoint");f(ee,"samePoint");function dt(t,e,n=Dt){return Math.abs(t.x-e.x)<n}A(dt,"sameX");f(dt,"sameX");function ut(t,e,n=Dt){return Math.abs(t.y-e.y)<n}A(ut,"sameY");f(ut,"sameY");function Tt(t,e,n=Dt){return ut(t,e,n)&&Math.abs(t.x-e.x)>n}A(Tt,"isHorizontalSegment");f(Tt,"isHorizontalSegment");function Et(t,e,n=Dt){return dt(t,e,n)&&Math.abs(t.y-e.y)>n}A(Et,"isVerticalSegment");f(Et,"isVerticalSegment");function zt(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}A(zt,"overlapLength");f(zt,"overlapLength");function ce(t,e,n=Dt){return t.horizontal&&e.horizontal&&ut(t.a,e.a,n)?zt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&dt(t.a,e.a,n)?zt(t.a.y,t.b.y,e.a.y,e.b.y):0}A(ce,"sameAxisSegmentOverlapLength");f(ce,"sameAxisSegmentOverlapLength");function Le(t,e=Dt){const n=[];for(let o=0;o<t.length-1;o++){const s=t[o],r=t[o+1],a=Tt(s,r,e),l=Et(s,r,e);(a||l)&&n.push({index:o,a:s,b:r,horizontal:a,vertical:l})}return n}A(Le,"orthogonalSegmentsForPoints");f(Le,"orthogonalSegmentsForPoints");function Zt(t,e=Dt){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}A(Zt,"countOrthogonalBends");f(Zt,"countOrthogonalBends");function mt(t,e=Dt){const n=[];for(const o of t){const s=n.length>0?n[n.length-1]:void 0;(!s||!ee(s,o,e))&&n.push({x:o.x,y:o.y})}return n}A(mt,"dedupeConsecutivePoints");f(mt,"dedupeConsecutivePoints");function $n(t,e=Dt){if(!t||t.length!==4)return;const[n,o,s,r]=t;return Tt(n,o,e)&&Et(o,s,e)&&Tt(s,r,e)?{kind:"HVH",p0:n,p1:o,p2:s,p3:r}:Et(n,o,e)&&Tt(o,s,e)&&Et(s,r,e)?{kind:"VHV",p0:n,p1:o,p2:s,p3:r}:void 0}A($n,"classifyThreeSegmentRoute");f($n,"classifyThreeSegmentRoute");function je(t,e,n,o=0){const s=Math.min(t.x,e.x),r=Math.max(t.x,e.x),a=Math.min(t.y,e.y),l=Math.max(t.y,e.y);return r>n.left-o&&s<n.right+o&&l>n.top-o&&a<n.bottom+o}A(je,"segmentBoundsOverlapRect");f(je,"segmentBoundsOverlapRect");function Vn(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}A(Vn,"pointInsideRect");f(Vn,"pointInsideRect");function Ho(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}A(Ho,"rectContainsRect");f(Ho,"rectContainsRect");function De(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}A(De,"rectsOverlap");f(De,"rectsOverlap");function fn(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}A(fn,"inflateRect");f(fn,"inflateRect");function ve(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}A(ve,"rectFromCenterSize");f(ve,"rectFromCenterSize");function jt(t){return Gn(t)?.rect}A(jt,"rectOfNodeBounds");f(jt,"rectOfNodeBounds");function Me(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}A(Me,"portForRectSide");f(Me,"portForRectSide");function jn(t,e,n,o,s,r=Dt){const a=e==="left"||e==="right",l=o==="left"||o==="right";if(a&&l){if(e==="right"&&o==="left"&&t.x<n.x||e==="left"&&o==="right"&&t.x>n.x){if(ut(t,n,r))return[t,n];const x=(t.x+n.x)/2;return[t,{x,y:t.y},{x,y:n.y},n]}if(e===o){if(ut(t,n,r))return;const x=e==="left"?Math.min(t.x,n.x)-s:Math.max(t.x,n.x)+s;return[t,{x,y:t.y},{x,y:n.y},n]}return}if(!a&&!l){if(e===o){if(dt(t,n,r))return;const C=e==="top"?Math.min(t.y,n.y)-s:Math.max(t.y,n.y)+s;return[t,{x:t.x,y:C},{x:n.x,y:C},n]}if(!(e==="bottom"&&o==="top"&&t.y<n.y||e==="top"&&o==="bottom"&&t.y>n.y))return;if(dt(t,n,r))return[t,n];const x=(t.y+n.y)/2;return[t,{x:t.x,y:x},{x:n.x,y:x},n]}if(a&&!l){const g=e==="right"&&n.x>t.x||e==="left"&&n.x<t.x,x=o==="top"&&t.y<n.y||o==="bottom"&&t.y>n.y;return g&&x?[t,{x:n.x,y:t.y},n]:void 0}const d=e==="bottom"&&n.y>t.y||e==="top"&&n.y<t.y,i=o==="left"&&t.x<n.x||o==="right"&&t.x>n.x;return d&&i?[t,{x:t.x,y:n.y},n]:void 0}A(jn,"buildOrthogonalPortPath");f(jn,"buildOrthogonalPortPath");function Un(t,e,n,o){return e==="left"||e==="right"?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}A(Un,"buildSameSideTrackPath");f(Un,"buildSameSideTrackPath");function Ue(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const s=zn(o);s&&(e.set(s.id,s),n.push({id:s.id,rect:s.rect}))}return{nodeInfoById:e,realNodeRects:n}}A(Ue,"collectRealNodeBounds");f(Ue,"collectRealNodeBounds");function ue(t){const e=[],n=[];for(const o of t){const s=zn(o);if(!s)continue;const r={id:s.id,rect:s.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}A(ue,"collectNodeRectEntries");f(ue,"collectNodeRectEntries");function Xo(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,a=o.width??0,l=o.height??0;n.push({nodeId:o.id,...ve(s,r,a,l)})}return n}A(Xo,"collectLayoutNodeRects");f(Xo,"collectLayoutNodeRects");function Wn(t,e,n=Dt){const o=t.start,s=t.end;if(!o||!s)return;const r=e.get(o),a=e.get(s);if(!(!r||!a))return{srcId:o,dstId:s,srcInfo:r,dstInfo:a,collinearX:Math.abs(r.cx-a.cx)<n,collinearY:Math.abs(r.cy-a.cy)<n}}A(Wn,"getNodePairGeometry");f(Wn,"getNodePairGeometry");function At(t,e,n,o=[],s=0){for(const r of n)if(!o.includes(r.id)&&je(t,e,r.rect,-s))return!0;return!1}A(At,"segmentHitsAnyRect");f(At,"segmentHitsAnyRect");function Kn(t,e,n,o,s=Dt,r=1e-6){const a=ut(t,e,s),l=dt(t,e,s),d=ut(n,o,s),i=dt(n,o,s);if(a&&d||l&&i||!(a||l)||!(d||i))return!1;const g=a?{a:t,b:e}:{a:n,b:o},x=l?{a:t,b:e}:{a:n,b:o},C=g.a.y,h=Math.min(g.a.x,g.b.x),p=Math.max(g.a.x,g.b.x),c=x.a.x,y=Math.min(x.a.y,x.b.y),v=Math.max(x.a.y,x.b.y);if(c<h||c>p||C<y||C>v)return!1;const M=Math.abs(c-g.a.x)<r&&Math.abs(C-g.a.y)<r||Math.abs(c-g.b.x)<r&&Math.abs(C-g.b.y)<r,T=Math.abs(c-x.a.x)<r&&Math.abs(C-x.a.y)<r||Math.abs(c-x.b.x)<r&&Math.abs(C-x.b.y)<r;return!(M&&T)}A(Kn,"orthogonalSegmentsCross");f(Kn,"orthogonalSegmentsCross");function Yo(t,e,n,o,s=Dt){const r=ut(t,e,s),a=dt(t,e,s),l=ut(n,o,s),d=dt(n,o,s);return a&&d&&dt(t,n,s)?zt(t.y,e.y,n.y,o.y)>s:r&&l&&ut(t,n,s)?zt(t.x,e.x,n.x,o.x)>s:!1}A(Yo,"sameAxisSegmentsOverlap");f(Yo,"sameAxisSegmentsOverlap");function He(t,e,n,o,{epsilon:s=Dt,skipDegenerateOther:r=!1}={}){for(const a of n){if(a===o||a.isLayoutOnly)continue;const l=a.points;if(!(!l||l.length<2))for(let d=0;d<l.length-1;d++){const i=l[d],g=l[d+1];if(!(r&&ee(i,g,s))&&(Kn(t,e,i,g,s)||Yo(t,e,i,g,s)))return!0}}return!1}A(He,"segmentConflictsWithAnyEdge");f(He,"segmentConflictsWithAnyEdge");function de(t,e,n,o,s=Dt){const r=ut(t,e,s),a=dt(t,e,s),l=ut(n,o,s),d=dt(n,o,s);if(!(r&&d||a&&l))return!1;const i=r?{a:t,b:e}:{a:n,b:o},g=r?{a:n,b:o}:{a:t,b:e},x=i.a.y,C=Math.min(i.a.x,i.b.x),h=Math.max(i.a.x,i.b.x),p=g.a.x,c=Math.min(g.a.y,g.b.y),y=Math.max(g.a.y,g.b.y);return p>C+s&&p<h-s&&x>c+s&&x<y-s}A(de,"orthogonalSegmentsStrictlyCross");f(de,"orthogonalSegmentsStrictlyCross");function un(t,e,n){const o=Math.min(e,n),s=Math.max(e,n);return t>o+Dt&&t<s-Dt}A(un,"strictlyBetween");f(un,"strictlyBetween");function Go(t,e,n){return dt(t,e)&&dt(e,n)?un(e.y,t.y,n.y):ut(t,e)&&ut(e,n)?un(e.x,t.x,n.x):!1}A(Go,"isCollinearIntermediate");f(Go,"isCollinearIntermediate");function zo(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const s=n[n.length-1],r=t[o],a=o+1<t.length?t[o+1]:void 0;if(s&&a){if(ee(s,a)){o++,e=!0;continue}if(Go(s,r,a)){e=!0;continue}}n.push(r)}return{points:n,changed:e}}A(zo,"simplifyPolylineOnce");f(zo,"simplifyPolylineOnce");function Xe(t){const e=[t[0]];for(let o=1;o<t.length;o++){const s=e[e.length-1],r=t[o];if(!dt(s,r)&&!ut(s,r)){const a=e.length>=2?e[e.length-2]:void 0,d=(a?dt(a,s):!1)?{x:s.x,y:r.y}:{x:r.x,y:s.y};e.push(d)}e.push(r)}const n=[];for(const o of e){const s=n[n.length-1];(!s||!ee(s,o))&&n.push(o)}return n}A(Xe,"orthogonalizePolyline");f(Xe,"orthogonalizePolyline");function ae(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const o=zo(e);if(e=o.points,!o.changed)break}return e}A(ae,"simplifyPolyline");f(ae,"simplifyPolyline");var ot=.001,wr=.5,lr=4;function Jn(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?jt(s):void 0,dstRect:r?jt(r):void 0}}A(Jn,"endpointContextFor");f(Jn,"endpointContextFor");function $o(t,e,n){if(ut(t,e,ot))return{x:t.x<n.left?n.left:n.right,y:t.y};if(dt(t,e,ot)){const o=t.y<n.top?n.top:n.bottom;return{x:t.x,y:o}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}A($o,"segmentEnterPoint");f($o,"segmentEnterPoint");function hn(t,e,n){const o=n?1:-1;let s=n?0:t.length-1;for(;s>=0&&s<t.length&&Vn(t[s],e,wr);)s+=o;if(s<0||s>=t.length)return t;const r=s-o;if(r<0||r>=t.length)return t;const a=$o(t[s],t[r],e);return n?[a,...t.slice(s)]:[...t.slice(0,s+1),a]}A(hn,"clipEndpoint");f(hn,"clipEndpoint");function Vo(t,e){for(const n of t){const o=Jn(n,e,2);if(!o)continue;let s=[...o.points];o.srcRect&&(s=hn(s,o.srcRect,!0)),o.dstRect&&(s=hn(s,o.dstRect,!1)),s=ae(Xe(s)),s=qn(s,o.srcRect,o.dstRect),o.edge.points=ae(Xe(s))}}A(Vo,"clipEdgeEndpointsToNodeBoundaries");f(Vo,"clipEdgeEndpointsToNodeBoundaries");function gn(t,e,n,o=!1){if(ut(t,e,ot)){if(e.y<n.top-ot||e.y>n.bottom+ot)return e;if(o){if(t.x<n.left-ot)return{x:n.left,y:t.y};if(t.x>n.right+ot)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(dt(t,e,ot)){if(e.x<n.left-ot||e.x>n.right+ot)return e;if(o){if(t.y<n.top-ot)return{x:t.x,y:n.top};if(t.y>n.bottom+ot)return{x:t.x,y:n.bottom}}const s=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:s?n.top:n.bottom}}return e}A(gn,"snapEndpointToBoundary");f(gn,"snapEndpointToBoundary");function Ye(t,e,n){const o=t[e];for(let s=e+n;s>=0&&s<t.length;s+=n){const r=t[s];if(!ee(r,o,ot))return r}return t[e+n]}A(Ye,"firstDistinctAdjacent");f(Ye,"firstDistinctAdjacent");function Ge(t,e){const n=t+lr,o=e-lr;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}A(Ge,"cornerClearanceRange");f(Ge,"cornerClearanceRange");function pn(t,e,n){const{lo:o,hi:s}=Ge(e,n);return Math.min(s,Math.max(o,t))}A(pn,"clampToCornerClearance");f(pn,"clampToCornerClearance");function jo(t){const e=Math.max(...t.map(o=>o.lo)),n=Math.min(...t.map(o=>o.hi));if(!(e>n))return{lo:e,hi:n}}A(jo,"intersectRanges");f(jo,"intersectRanges");function mn(t,e){return e==="left"||e==="right"?Ge(t.top,t.bottom):Ge(t.left,t.right)}A(mn,"clearanceRangeForSide");f(mn,"clearanceRangeForSide");function ze(t,e,n){const o=t.y>=n.top-ot&&t.y<=n.bottom+ot,s=t.x>=n.left-ot&&t.x<=n.right+ot;if(ut(t,e,ot)&&o){if(Math.abs(t.x-n.left)<ot)return"left";if(Math.abs(t.x-n.right)<ot)return"right"}if(dt(t,e,ot)&&s){if(Math.abs(t.y-n.top)<ot)return"top";if(Math.abs(t.y-n.bottom)<ot)return"bottom"}}A(ze,"terminalSideForSegment");f(ze,"terminalSideForSegment");function Be(t){return t==="left"||t==="right"}A(Be,"isHorizontalSide");f(Be,"isHorizontalSide");function Uo(t,e,n,o,s){const r=[],a=n?ze(t,e,n):void 0,l=o?ze(e,t,o):void 0;return n&&a&&Be(a)===s&&r.push(mn(n,a)),o&&l&&Be(l)===s&&r.push(mn(o,l)),r.length>0?jo(r):void 0}A(Uo,"straightClearanceRange");f(Uo,"straightClearanceRange");function yn(t,e,n,o,s){const r=Uo(t,e,n,o,s);if(!r)return;const a=s?t.y:t.x,l=Math.min(r.hi,Math.max(r.lo,a));if(!(Math.abs(l-a)<ot))return s?[{x:t.x,y:l},{x:e.x,y:l}]:[{x:l,y:t.y},{x:l,y:e.y}]}A(yn,"clearStraightEndpointCornerAxis");f(yn,"clearStraightEndpointCornerAxis");function qn(t,e,n){if(t.length!==2)return t;const[o,s]=t;return ut(o,s,ot)?yn(o,s,e,n,!0)??t:dt(o,s,ot)?yn(o,s,e,n,!1)??t:t}A(qn,"clearStraightEndpointCornerConnections");f(qn,"clearStraightEndpointCornerConnections");function Wo(t,e,n){return Be(n)?{x:t.x,y:pn(t.y,e.top,e.bottom)}:{x:pn(t.x,e.left,e.right),y:t.y}}A(Wo,"cornerClearedEndpoint");f(Wo,"cornerClearedEndpoint");function Ko(t,e,n,o,s,r){const a=t.map(l=>({...l}));for(let l=e;l>=0&&l<t.length;l+=n){const d=t[l];if(r&&!ut(d,o,ot)||!r&&!dt(d,o,ot))break;r?a[l].y=s.y:a[l].x=s.x}return a}A(Ko,"moveCollinearEndpointRun");f(Ko,"moveCollinearEndpointRun");function xn(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,s=n?1:-1,r=t[o],a=Ye(t,o,s);if(!a)return t;const l=ze(r,a,e);if(!l)return t;const d=Be(l),i=Wo(r,e,l);return ee(r,i,ot)?t:Ko(t,o,s,r,i,d)}A(xn,"clearEndpointCornerConnection");f(xn,"clearEndpointCornerConnection");function bn(t,e,n){const o=Math.min(t.x,e.x)>=n.left-ot&&Math.max(t.x,e.x)<=n.right+ot,s=Math.min(t.y,e.y)>=n.top-ot&&Math.max(t.y,e.y)<=n.bottom+ot;if(Math.abs(t.y-n.top)<ot&&Math.abs(e.y-n.top)<ot&&o)return"top";if(Math.abs(t.y-n.bottom)<ot&&Math.abs(e.y-n.bottom)<ot&&o)return"bottom";if(Math.abs(t.x-n.left)<ot&&Math.abs(e.x-n.left)<ot&&s)return"left";if(Math.abs(t.x-n.right)<ot&&Math.abs(e.x-n.right)<ot&&s)return"right"}A(bn,"borderSideForSegment");f(bn,"borderSideForSegment");function Mn(t,e,n,o){switch(t){case"top":return dt(e,n,ot)&&n.y<o.top-ot;case"bottom":return dt(e,n,ot)&&n.y>o.bottom+ot;case"left":return ut(e,n,ot)&&n.x<o.left-ot;case"right":return ut(e,n,ot)&&n.x>o.right+ot}}A(Mn,"leavesOutward");f(Mn,"leavesOutward");function In(t,e,n){if(t.length<3)return t;if(n){const r=bn(t[0],t[1],e);return r&&Mn(r,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,s=bn(t[o-1],t[o],e);return s&&Mn(s,t[o-1],t[o-2],e)?t.slice(0,o):t}A(In,"collapseOwnBorderStub");f(In,"collapseOwnBorderStub");function Jo(t,e,n){let o=t;if(e){const r=Ye(o,0,1);if(r){const a=gn(r,o[0],e);a!==o[0]&&(o=[a,...o.slice(1)])}o=In(o,e,!0)}if(n){const r=o.length-1,a=Ye(o,r,-1);if(a){const l=gn(a,o[r],n,!0);l!==o[r]&&(o=[...o.slice(0,r),l])}o=In(o,n,!1)}const s=qn(o,e,n);return s!==o||o.length===2?s:(e&&(o=xn(o,e,!0)),n&&(o=xn(o,n,!1)),o)}A(Jo,"snapAndCollapseEndpoints");f(Jo,"snapAndCollapseEndpoints");function Sn(t,e){for(const n of t){const o=Jn(n,e,2);if(!o)continue;const s=mt(o.points,ot),r=Jo(s,o.srcRect,o.dstRect);if(r.length<3){o.edge.points=r;continue}const a=[r[0],{...r[0]},...r.slice(1,-1),r[r.length-1],{...r[r.length-1]}];o.edge.points=a}}A(Sn,"prepareEdgeEndpointsForRenderer");f(Sn,"prepareEdgeEndpointsForRenderer");function Zn(t){return new Map(t.map(e=>[e.id,e]))}A(Zn,"buildNodeMap");f(Zn,"buildNodeMap");function qo(t,e){let n=t.parentId,o=null;for(;n;){const s=e.get(n);if(!s?.isGroup)break;o=s.id,n=s.parentId}return o}A(qo,"resolveTopLevelGroupId");f(qo,"resolveTopLevelGroupId");function Cn(t,e){let n=0,o=t.parentId;for(;o;){const s=e.get(o);if(!s?.isGroup)break;n++,o=s.parentId}return n}A(Cn,"groupDepth");f(Cn,"groupDepth");function Qn(t){let e=1/0,n=-1/0,o=1/0,s=-1/0;for(const r of t){const a=r.x,l=r.y;if(typeof a!="number"||typeof l!="number")continue;const d=r.width??0,i=r.height??0;e=Math.min(e,a-d/2),n=Math.max(n,a+d/2),o=Math.min(o,l-i/2),s=Math.max(s,l+i/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:s}}A(Qn,"boundsForChildren");f(Qn,"boundsForChildren");function Zo(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}A(Zo,"applyGroupBounds");f(Zo,"applyGroupBounds");function Qo(t){const e=Zn(t),n=t.filter(o=>o.isGroup&&o.parentId).sort((o,s)=>Cn(s,e)-Cn(o,e));for(const o of n){const s=t.filter(a=>a.parentId===o.id),r=Qn(s);r&&Zo(o,r)}}A(Qo,"recomputeNestedGroupBounds");f(Qo,"recomputeNestedGroupBounds");function $e(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(d=>!d.isGroup);let r=1/0,a=-1/0;for(const d of s){const i=d[e];typeof i=="number"&&(r=Math.min(r,i),a=Math.max(a,i))}if(!Number.isFinite(r)||!Number.isFinite(a))return!1;const l=f(d=>r+a-d,"mirror");for(const d of n){const i=d[e];typeof i=="number"&&(d[e]=l(i));const g=d.groupTitleRect;g&&(d.groupTitleRect=e==="x"?{...g,left:l(g.right),right:l(g.left)}:{...g,top:l(g.bottom),bottom:l(g.top)})}for(const d of o)for(const i of d.points??[])i[e]=l(i[e]);return!0}A($e,"mirrorAxis");f($e,"mirrorAxis");function ts(t){return(t.nodes??[]).some(n=>!n.isGroup)?$e(t,"y"):!0}A(ts,"applyBtDirectionTransform");f(ts,"applyBtDirectionTransform");function es(t,e="LR"){const n=t.nodes??[],o=t.edges??[],s=n.filter(P=>!P.isGroup);let r=1/0,a=1/0;for(const P of s){const z=P.x??0,U=P.y??0;z<r&&(r=z),U<a&&(a=U)}if(!Number.isFinite(r)||!Number.isFinite(a))return!1;const l=36;let d=0,i=0;for(const P of s)d+=P.width??0,i+=P.height??0;const g=d/s.length,x=i/s.length,C=x>0?Math.max(1,g/x):1;for(const P of s){const z=P.x??0,Z=((P.y??0)-a)*C+l,ht=z-r;P.x=Z,P.y=ht}for(const P of o)if(P.points)for(const z of P.points){const U=z.x,ht=(z.y-a)*C+l,yt=U-r;z.x=ht,z.y=yt}Qo(n);const h=n.filter(P=>P.isGroup&&!P.parentId);if(h.length===0)return e==="RL"&&$e(t,"x"),!0;const p=Zn(n),c=new Map;for(const P of n){if(P.isGroup)continue;const z=qo(P,p);if(!z)continue;const U=c.get(z)??[];U.push(P),c.set(z,U)}let y=0;for(const P of h){const z=P.padding??0;z>y&&(y=z)}const v=[];let M=1/0,T=-1/0;for(const P of h){const z=c.get(P.id)??[],U=Qn(z);U&&(M=Math.min(M,U.minX),T=Math.max(T,U.maxX),v.push({lane:P,contentTop:U.minY,contentBottom:U.maxY,centerY:(U.minY+U.maxY)/2}))}if(M===1/0||T===-1/0)return!0;const E=Math.max(0,T-M),m=Math.max(y,10),I=E+2*m,R=l+I,B=(M+T)/2-I/2-l,_=B+R/2,X=Math.max(y,l);v.sort((P,z)=>P.centerY-z.centerY);for(let P=0;P<v.length;P++){const z=v[P];let U,Z;if(P===0?U=z.contentTop-X:U=(v[P-1].contentBottom+z.contentTop)/2,P===v.length-1)Z=z.contentBottom+X;else{const Ft=v[P+1];Z=(z.contentBottom+Ft.contentTop)/2}const ht=Math.max(0,Z-U),yt=(U+Z)/2;z.lane.x=_,z.lane.y=yt,z.lane.width=R,z.lane.height=ht,z.lane.swimlaneContentTop=z.contentTop,z.lane.groupTitleRect={left:B,right:B+l,top:U,bottom:Z}}return e==="RL"&&$e(t,"x"),!0}A(es,"applyLrDirectionTransform");f(es,"applyLrDirectionTransform");var ie=1e-6,Rr=8,sn=Rr,Ar=[0,sn,-sn,2*sn,-2*sn];function ns(t,e){const{nodeInfoById:n,realNodeRects:o}=Ue(e);for(const s of t){if(s.isLayoutOnly)continue;const r=s.points;if(!r||r.length<4)continue;const a=$n(mt(r,ie),ie);if(!a)continue;const{p3:l}=a,d=a.kind==="HVH",i=Wn(s,n,ie);if(!i)continue;const{srcId:g,dstId:x,srcInfo:C,dstInfo:h,collinearX:p,collinearY:c}=i;if(p||c)continue;let y;const v=C.rect;for(const M of Ar){let T,E,m;if(d){const _=h.cy>C.cy?v.bottom:v.top,X=C.cx+M;if(X<=v.left+ie||X>=v.right-ie)continue;T={x:X,y:_},E={x:X,y:l.y},m={x:l.x,y:l.y}}else{const _=h.cx>C.cx?v.right:v.left,X=C.cy+M;if(X<=v.top+ie||X>=v.bottom-ie)continue;T={x:_,y:X},E={x:l.x,y:X},m={x:l.x,y:l.y}}const I=ee(T,E,ie),R=ee(E,m,ie);if(I&&R||!I&&At(T,E,o,[g],1)||!R&&At(E,m,o,[x],1))continue;const O=!I&&He(T,E,t,s,{epsilon:ie,skipDegenerateOther:!0}),F=!R&&He(E,m,t,s,{epsilon:ie,skipDegenerateOther:!0});if(!(O||F)){I?y=[E,m]:R?y=[T,E]:y=[T,E,m];break}}y&&(s.points=y)}}A(ns,"portSwapToLShape");f(ns,"portSwapToLShape");function os(t,e){const{realNodeRects:r,labelNodeRects:a}=ue(e.values());for(const l of t){if(l.isLayoutOnly)continue;const d=l.points;if(!d||d.length<4)continue;const i=mt(d,.001);if(i.length<4)continue;const g=i.length-1,x=i[g],C=i[g-1],h=i[g-2],p=x.x-C.x,c=x.y-C.y,y=Math.hypot(p,c);if(y>=10||y<.001)continue;const v=C.x-h.x,M=C.y-h.y;if(Math.hypot(v,M)<.001)continue;const E=Tt(C,x,.001),m=Et(C,x,.001),I=Tt(h,C,.001),R=Et(h,C,.001);if(!(E&&R||m&&I))continue;const O=l.end,F=l.start,B=O?e.get(O):void 0;if(!B)continue;const _=B.x??0,X=B.y??0,P=jt(B);if(!P)continue;let z,U;if(R){const K=M<0;z={x:_,y:h.y},U={x:_,y:K?P.bottom:P.top}}else{const K=v>0;z={x:h.x,y:X},U={x:K?P.right:P.left,y:X}}if(At(z,U,r,O?[O]:[],-2)||At(z,U,a,[],-2))continue;if(F){const K=e.get(F),nt=K?jt(K):void 0;if(nt&&Vn(z,nt,2))continue}const Z=f((K,nt)=>`${K.x.toFixed(3)},${K.y.toFixed(3)}|${nt.x.toFixed(3)},${nt.y.toFixed(3)}`,"ownSegmentKey"),ht=new Set;for(let K=0;K<i.length-1;K++)ht.add(Z(i[K],i[K+1]));const yt=f((K,nt)=>{for(const lt of t){if(lt===l||lt.isLayoutOnly)continue;const pt=lt.points;if(!(!pt||pt.length<2))for(let bt=0;bt<pt.length-1;bt++){const Lt=pt[bt],Ut=pt[bt+1];if(!ht.has(Z(Lt,Ut))&&de(K,nt,Lt,Ut,.001))return!0}}return!1},"segmentCrossesOtherEdge");if(yt(z,U))continue;if(g-3>=0){const K=i[g-3],nt=[F,O].filter(lt=>!!lt);if(At(K,z,r,nt,-2)||yt(K,z))continue}const Pt=[...i.slice(0,g-2),z,U];l.points=Pt;const tt=l.labelNodeId;if(tt){const K=e.get(tt);if(K){const nt=K.width??0,lt=K.height??0;if(nt>0&<>0){let pt,bt,Lt=-1;for(let Ut=0;Ut<Pt.length-1;Ut++){const Wt=Pt[Ut],Kt=Pt[Ut+1],ne=Math.hypot(Kt.x-Wt.x,Kt.y-Wt.y),Ee=ut(Wt,Kt,.001),ge=dt(Wt,Kt,.001);(Ee&&ne>=nt+2||ge&&ne>=lt+2)&&ne>Lt&&(Lt=ne,pt=(Wt.x+Kt.x)/2,bt=(Wt.y+Kt.y)/2)}pt!==void 0&&bt!==void 0&&(K.x=pt,K.y=bt)}}}}}A(os,"collapseShortTerminalStub");f(os,"collapseShortTerminalStub");var Q=.001,_t=8,ct=Le,bo=f((t,e)=>dt(t,e,Q)||ut(t,e,Q),"orthogonallyAligned");function ss(t,e){const s=f((h,p)=>{const c=h.x??0,y=h.y??0,v=p.x-c,M=p.y-y;let T=(h.width??0)/2,E=(h.height??0)/2;return Math.abs(M)*T>Math.abs(v)*E?(M<0&&(E=-E),{x:c+(M===0?0:E*v/M),y:y+E}):(v<0&&(T=-T),{x:c+T,y:y+(v===0?0:T*M/v)})},"rectIntersect"),r=f((h,p)=>{const c=mt(h.points??[]);if(c.length<2)return;const y=p?h.start:h.end,v=y?e.get(y):void 0,M=v?jt(v):void 0;if(!v||!y||!M)return;const T=p?c[0]:c[c.length-1],E=p?c[1]:c[c.length-2],m=s(v,T);let I=T;if(bo(E,m)&&(I=E),dt(m,I,Q))return{edge:h,edgeId:String(h.id??""),nodeId:y,atStart:p,orientation:"V",coord:m.x,min:Math.min(m.y,I.y),max:Math.max(m.y,I.y),boundary:m,railEnd:I,rect:M};if(ut(m,I,Q))return{edge:h,edgeId:String(h.id??""),nodeId:y,atStart:p,orientation:"H",coord:m.y,min:Math.min(m.x,I.x),max:Math.max(m.x,I.x),boundary:m,railEnd:I,rect:M}},"terminalLaneFor"),a=f((h,p)=>Math.max(0,Math.min(h.max,p.max)-Math.max(h.min,p.min)),"projectedOverlapLength"),l=f((h,p)=>h.nodeId!==p.nodeId||h.orientation!==p.orientation?!1:h.orientation==="H"?(Math.abs(h.boundary.x-h.rect.left)<1||Math.abs(h.boundary.x-h.rect.right)<1)&&dt(h.boundary,p.boundary,1):(Math.abs(h.boundary.y-h.rect.top)<1||Math.abs(h.boundary.y-h.rect.bottom)<1)&&ut(h.boundary,p.boundary,1),"sameTerminalFace"),d=f((h,p)=>h.nodeId!==p.nodeId||h.orientation!==p.orientation?!1:a(h,p)>=_t&&Math.abs(h.coord-p.coord)<.5,"exactTerminalLaneConflict"),i=f((h,p)=>{if(h.nodeId!==p.nodeId||h.orientation!==p.orientation||h.orientation!=="H"||h.atStart===p.atStart)return!1;const c=a(h,p);if(c<_t)return!1;const y=h.rect.bottom-h.rect.top;return c<y||c>2*y?!1:l(h,p)&&Math.abs(h.coord-p.coord)<16},"nearTerminalLaneConflict"),g=f((h,p)=>{const c=mt(h.edge.points??[]);if(c.length<2)return;const y=h.orientation==="V"?{x:h.boundary.x+p,y:h.boundary.y}:{x:h.boundary.x,y:h.boundary.y+p},v=h.orientation==="V"?{x:h.railEnd.x+p,y:h.railEnd.y}:{x:h.railEnd.x,y:h.railEnd.y+p};if(!f(()=>Math.abs(h.boundary.y-h.rect.top)<1||Math.abs(h.boundary.y-h.rect.bottom)<1?ut(y,h.boundary,Q)&&y.x>=h.rect.left+1&&y.x<=h.rect.right-1:Math.abs(h.boundary.x-h.rect.left)<1||Math.abs(h.boundary.x-h.rect.right)<1?dt(y,h.boundary,Q)&&y.y>=h.rect.top+1&&y.y<=h.rect.bottom-1:!1,"boundaryStaysOnSameFace")())return;if(h.atStart){const I=c.length>1&&ee(c[1],h.railEnd,Q),R=c.slice(I?2:1),O=R[0];return O&&!bo(O,v)?void 0:[y,v,...R]}const T=c.length>1&&ee(c[c.length-2],h.railEnd,Q),E=c.slice(0,T?-2:-1),m=E[E.length-1];if(!(m&&!bo(m,v)))return[...E,v,y]},"shiftedCandidate"),x=f(h=>{const p=h.edge,c=mt(p.points??[]);if(c.length!==2)return!1;const y=p.start,v=p.end,M=y?e.get(y):void 0,T=v?e.get(v):void 0;if(!M||!T)return!1;const E=M.x??0,m=M.y??0,I=T.x??0,R=T.y??0,[O,F]=c;return ut(O,F,Q)&&Math.abs(m-R)<1&&Math.abs(E-I)>1||dt(O,F,Q)&&Math.abs(E-I)<1&&Math.abs(m-R)>1},"laneIsStraightCollinearConnector"),C=[-7,7,-14,14,-21,21];for(let h=0;h<8;h++){const p=t.filter(y=>!y.isLayoutOnly).flatMap(y=>[r(y,!0),r(y,!1)]).filter(y=>!!y);let c=!1;for(let y=0;y<p.length&&!c;y++)for(let v=y+1;v<p.length&&!c;v++){const M=p[y],T=p[v];if(M.edge===T.edge||!(d(M,T)||i(M,T)))continue;const E=!d(M,T),m=[M,T].sort((I,R)=>{const O=x(I),F=x(R);return O!==F?Number(O)-Number(F):+!R.atStart-+!I.atStart});for(const I of m){for(const R of C){const O=g(I,R);if(!O)continue;const F=r({...I.edge,points:O},I.atStart);if(!(!F||p.some(B=>B.edge!==I.edge&&(d(F,B)||E&&i(F,B))))){I.edge.points=O,c=!0;break}}if(c)break}}if(!c)return}}A(ss,"separateSharedRenderedTerminalLanes");f(ss,"separateSharedRenderedTerminalLanes");function rs(t,e){const{realNodeRects:o,labelNodeRects:s}=ue(e.values()),r=f((l,d)=>{const i=l.start,g=l.end,x=ct(d);if(x.length!==d.length-1)return!1;const C=[i,g].filter(h=>!!h);for(const h of x)if(At(h.a,h.b,o,C,-2)||At(h.a,h.b,s,[],-2))return!1;for(const h of t){if(h===l||h.isLayoutOnly)continue;const p=h.points;if(!(!p||p.length<2)){for(const c of x)for(const y of ct(mt(p)))if(ce(c,y,.5)>=_t||de(c.a,c.b,y.a,y.b,Q))return!1}}return!0},"candidateIsSafe"),a=f((l,d)=>{if(d+4>=l.length)return;const i=l[d],g=l[d+1],x=l[d+2],C=l[d+3],h=l[d+4],p=Tt(i,g)&&Et(g,x)&&Tt(x,C)&&Et(C,h)&&dt(i,C,Q)&&dt(i,h,Q)&&dt(g,x,Q)&&(g.x-i.x)*(C.x-x.x)<0,c=Et(i,g)&&Tt(g,x)&&Et(x,C)&&Tt(C,h)&&ut(i,C,Q)&&ut(i,h,Q)&&ut(g,x,Q)&&(g.y-i.y)*(C.y-x.y)<0;if(p||c)return mt([...l.slice(0,d+1),h,...l.slice(d+5)]);if(d+5>=l.length)return;const y=l[d+5],v=Et(i,g)&&Tt(g,x)&&Et(x,C)&&Tt(C,h)&&Et(h,y)&&dt(i,h,Q)&&dt(i,y,Q)&&dt(x,C,Q)&&(x.x-g.x)*(h.x-C.x)<0,M=Tt(i,g)&&Et(g,x)&&Tt(x,C)&&Et(C,h)&&Tt(h,y)&&ut(i,h,Q)&&ut(i,y,Q)&&ut(x,C,Q)&&(x.y-g.y)*(h.y-C.y)<0;if(!(!v&&!M))return mt([...l.slice(0,d+1),y,...l.slice(d+6)])},"withoutDogleg");for(let l=0;l<8;l++){let d=!1;for(const i of t){if(i.isLayoutOnly)continue;const g=mt(i.points??[]);for(let x=0;x<=g.length-5;x++){const C=a(g,x);if(!(!C||!r(i,C))){i.points=C,d=!0;break}}if(d)break}if(!d)return}}A(rs,"collapseRedundantRectangularDoglegs");f(rs,"collapseRedundantRectangularDoglegs");function vn(t,e){const{realNodeRects:r,labelNodeRects:a}=ue(e.values()),l=t.filter(p=>!p.isLayoutOnly),d=f((p,c,y)=>mt(p===c?y??[]:p.points??[]),"pointsFor"),i=f((p,c)=>{let y=0;for(let v=0;v<l.length;v++){const M=ct(d(l[v],p,c));for(let T=v+1;T<l.length;T++){const E=ct(d(l[T],p,c));for(const m of M)for(const I of E)de(m.a,m.b,I.a,I.b,Q)&&y++}}return y},"strictCrossingCount"),g=f(p=>{const c=ct(p);if(c.length!==3)return;const y=c[1];if(!(c[0].horizontal===y.horizontal||c[2].horizontal===y.horizontal))return{index:y.index,horizontal:y.horizontal,vertical:y.vertical,segment:y}},"middleRail"),x=f((p,c)=>{const y=[p.start,p.end].filter(v=>!!v);return r.filter(v=>{if(y.includes(v.id))return!1;const M=v.rect;return c.horizontal?zt(c.a.x,c.b.x,M.left,M.right)>=_t&&c.a.y>=M.top-2&&c.a.y<=M.bottom+2:zt(c.a.y,c.b.y,M.top,M.bottom)>=_t&&c.a.x>=M.left-2&&c.a.x<=M.right+2})},"blockingRectsFor"),C=f((p,c,y)=>{const v=p.map(T=>({...T}));if(c.horizontal)v[c.index].y=y,v[c.index+1].y=y;else if(c.vertical)v[c.index].x=y,v[c.index+1].x=y;else return;const M=ae(mt(v));return ct(M).length===M.length-1?M:void 0},"candidateByMovingRail"),h=f((p,c,y)=>{const v=[p.start,p.end].filter(T=>!!T),M=ct(c);if(M.length!==c.length-1)return!1;for(const T of M)if(At(T.a,T.b,r,v,-2)||At(T.a,T.b,a,[],-2))return!1;for(const T of l)if(T!==p){for(const E of M)for(const m of ct(d(T)))if(ce(E,m,.5)>=_t)return!1}return i(p,c)<=y},"candidateIsSafe");for(let p=0;p<8;p++){const c=i();let y=!1;for(const v of l){const M=d(v),T=g(M);if(!T)continue;const E=x(v,T.segment);if(E.length===0)continue;const m=T.horizontal?[Math.min(...E.map(I=>I.rect.top))-20,Math.max(...E.map(I=>I.rect.bottom))+20]:[Math.min(...E.map(I=>I.rect.left))-20,Math.max(...E.map(I=>I.rect.right))+20];for(const I of m){const R=C(M,T.segment,I);if(!(!R||!h(v,R,c))){v.points=R,y=!0;break}}if(y)break}if(!y)return}}A(vn,"liftObstacleHuggingSameSideRails");f(vn,"liftObstacleHuggingSameSideRails");function Ln(t,e){const o=f(d=>{const i=d.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"),s=f(d=>{if(!d.isGroup||d.parentId)return;const i=d.direction,g=typeof i=="string"?i.toUpperCase():"";if(g==="LR"||g==="RL"||g==="BT")return;const x=o(d),C=d.y,h=d.height;if(!x||typeof C!="number"||typeof h!="number"||!Number.isFinite(C)||!Number.isFinite(h)||h<=0)return;const p=x.right-x.left,c=x.bottom-x.top;if(!(c<=0||p<c))return{node:d,rect:x}},"topLaneTitleFor"),r=f((d,i)=>{if(!d.horizontal)return!1;const g=d.a.y;return g<=i.top+Q||g>=i.bottom-Q?!1:zt(d.a.x,d.b.x,i.left,i.right)>=_t},"horizontalSegmentIntersectsTitle"),a=[...e.values()].map(s).filter(d=>!!d);if(a.length===0)return;let l=0;for(const d of t){if(d.isLayoutOnly)continue;const i=mt(d.points??[]);for(const g of ct(i))for(const x of a)r(g,x.rect)&&(l=Math.max(l,x.rect.bottom-g.a.y+4))}if(!(l<=Q))for(const d of a){const i=d.node.y,g=d.node.height;typeof i!="number"||typeof g!="number"||!Number.isFinite(i)||!Number.isFinite(g)||g<=0||(d.node.y=i-l/2,d.node.height=g+l,d.node.groupTitleRect={...d.rect,top:d.rect.top-l,bottom:d.rect.bottom-l})}}A(Ln,"liftTopLaneTitleBandsAboveRails");f(Ln,"liftTopLaneTitleBandsAboveRails");function Tn(t,e){const o=f(i=>{const g=i.groupTitleRect;if(!(!g||typeof g.left!="number"||typeof g.right!="number"||typeof g.top!="number"||typeof g.bottom!="number"||!Number.isFinite(g.left)||!Number.isFinite(g.right)||!Number.isFinite(g.top)||!Number.isFinite(g.bottom)||g.right<=g.left||g.bottom<=g.top))return{left:g.left,right:g.right,top:g.top,bottom:g.bottom}},"validTitleRect"),s=f(i=>{if(!i.isGroup||i.parentId||i.direction!=="LR")return;const x=o(i),C=i.x,h=i.width;if(!x||typeof C!="number"||typeof h!="number"||!Number.isFinite(C)||!Number.isFinite(h)||h<=0)return;const p=x.right-x.left,c=x.bottom-x.top;if(!(p<=0||c<p))return{node:i,rect:x}},"leftLaneTitleFor"),r=f((i,g)=>{if(!i.vertical)return!1;const x=i.a.x;return x<=g.left+Q||x>=g.right-Q?!1:zt(i.a.y,i.b.y,g.top,g.bottom)>=_t},"verticalSegmentIntersectsTitle"),a=f((i,g)=>{if(!i.horizontal)return!1;const x=i.a.y;return x<=g.top+Q||x>=g.bottom-Q?!1:zt(i.a.x,i.b.x,g.left,g.right)>=_t},"horizontalSegmentIntersectsTitle"),l=[...e.values()].map(s).filter(i=>!!i);if(l.length===0)return;let d=0;for(const i of t){if(i.isLayoutOnly)continue;const g=mt(i.points??[]);for(const x of ct(g))for(const C of l)if(r(x,C.rect))d=Math.max(d,C.rect.right-x.a.x+4);else if(a(x,C.rect)){const h=Math.min(x.a.x,x.b.x);d=Math.max(d,C.rect.right-h+4)}}if(!(d<=Q))for(const i of l){const g=i.node.x,x=i.node.width;typeof g!="number"||typeof x!="number"||!Number.isFinite(g)||!Number.isFinite(x)||x<=0||(i.node.x=g-d/2,i.node.width=x+d,i.node.groupTitleRect={...i.rect,left:i.rect.left-d,right:i.rect.right-d})}}A(Tn,"shiftLeftLaneTitleBandsLeftOfRails");f(Tn,"shiftLeftLaneTitleBandsLeftOfRails");function is(t,e){const{realNodeRects:o}=ue(e.values()),s=t.filter(p=>!p.isLayoutOnly),r=f((p,c=new Map)=>mt(c.get(p)??p.points??[]),"replacementPointsFor"),a=f((p=new Map)=>{let c=0;for(let y=0;y<s.length;y++){const v=ct(r(s[y],p));for(let M=y+1;M<s.length;M++){const T=ct(r(s[M],p));for(const E of v)for(const m of T)de(E.a,E.b,m.a,m.b,Q)&&c++}}return c},"crossingCount"),l=f((p=new Map)=>s.reduce((c,y)=>c+Zt(r(y,p)),0),"totalBends"),d=f(p=>{const c=r(p);if(c.length<4)return;const y=c[c.length-2],v=c[c.length-1];if(!(!Tt(y,v,Q)&&!Et(y,v,Q)))return{tailStart:y,terminal:v}},"terminalTailFor"),i=f((p,c)=>{const y=r(p);if(y.length<3)return;const v=y[0],M=y[1];let T;if(Tt(v,M,Q))T={x:M.x,y:c.tailStart.y};else if(Et(v,M,Q))T={x:c.tailStart.x,y:M.y};else return;const E=ae(mt([v,M,T,c.tailStart,c.terminal]));return ct(E).length===E.length-1?E:void 0},"candidateWithDestinationTail"),g=f((p,c)=>{const y=[p.start,p.end].filter(v=>!!v);for(const v of ct(c))if(At(v.a,v.b,o,y,-2))return!0;return!1},"pathHasNodeHit"),x=f((p,c,y)=>{for(const v of s)if(v!==p){for(const M of ct(c))for(const T of ct(r(v,y)))if(ce(M,T,.5)>=_t)return!0}return!1},"pathHasSharedTrack"),C=f((p,c,y)=>!g(p,c)&&!x(p,c,y),"candidateIsSafe"),h=f(()=>{const p=new Map;for(const c of s){const y=c.end;if(!y||!e.has(y)||r(c).length<4)continue;const M=p.get(y)??[];M.push(c),p.set(y,M)}return p},"edgesByDestination");for(let p=0;p<4;p++){const c=a();if(c===0)return;const y=l();let v,M=c,T=y;for(const E of h().values())for(let m=0;m<E.length;m++)for(let I=m+1;I<E.length;I++){const R=E[m],O=E[I],F=d(R),B=d(O);if(!F||!B)continue;const _=i(R,B),X=i(O,F);if(!_||!X)continue;const P=new Map([[R,_],[O,X]]);if(!C(R,_,P)||!C(O,X,P))continue;const z=a(P),U=l(P);z>=c||z>M||z===M&&U>=T||(v=P,M=z,T=U)}if(!v)return;for(const[E,m]of v)E.points=m}}A(is,"swapDestinationTerminalTailsToReduceCrossings");f(is,"swapDestinationTerminalTailsToReduceCrossings");function cs(t,e){const{realNodeRects:r,labelNodeRects:a}=ue(e.values()),l=t.filter(E=>!E.isLayoutOnly),d=f((E,m=new Map)=>mt(m.get(E)??E.points??[]),"replacementPointsFor"),i=f((E=new Map)=>{let m=0;for(let I=0;I<l.length;I++){const R=ct(d(l[I],E));for(let O=I+1;O<l.length;O++){const F=ct(d(l[O],E));for(const B of R)for(const _ of F)de(B.a,B.b,_.a,_.b,Q)&&m++}}return m},"strictCrossingCount"),g=f((E=new Map)=>l.reduce((m,I)=>m+Zt(d(I,E)),0),"totalBends"),x=f(E=>{const m=E.start,I=E.end,R=m?e.get(m):void 0,O=I?e.get(I):void 0,F=R?jt(R):void 0,B=O?jt(O):void 0;return F&&B?{src:F,dst:B}:void 0},"endpointRectsFor"),C=f((E,m,I)=>{if(I.index<=0||I.index+1>=m.length-1)return;const R=x(E);if(R){if(I.vertical){const O=I.a.x,F=Math.min(R.src.left,R.dst.left),B=Math.max(R.src.right,R.dst.right),_=O<F-Q?"left":O>B+Q?"right":void 0;return _?{edge:E,points:m,segmentIndex:I.index,axis:"vertical",side:_,coord:O,min:Math.min(I.a.y,I.b.y),max:Math.max(I.a.y,I.b.y)}:void 0}if(I.horizontal){const O=I.a.y,F=Math.min(R.src.top,R.dst.top),B=Math.max(R.src.bottom,R.dst.bottom),_=O<F-Q?"top":O>B+Q?"bottom":void 0;return _?{edge:E,points:m,segmentIndex:I.index,axis:"horizontal",side:_,coord:O,min:Math.min(I.a.x,I.b.x),max:Math.max(I.a.x,I.b.x)}:void 0}}},"externalRailForSegment"),h=f(()=>{const E=[];for(const m of l){const I=d(m);for(const R of ct(I)){const O=C(m,I,R);O&&E.push(O)}}return E},"collectExternalRails"),p=f((E,m)=>E.edge!==m.edge&&E.axis===m.axis&&E.side===m.side&&zt(E.min,E.max,m.min,m.max)>=_t,"railsInteract"),c=f(E=>{const m=[],I=new Set;for(const R of E){if(I.has(R))continue;const O=[R],F=[];for(I.add(R);O.length>0;){const B=O.pop();F.push(B);for(const _ of E)!I.has(_)&&p(B,_)&&(I.add(_),O.push(_))}F.length>1&&m.push(F)}return m},"connectedComponents"),y=f(E=>{const m=[];for(const I of E)m.some(R=>Math.abs(R-I.coord)<Q)||m.push(I.coord);for(;m.length<E.length;){const I=Math.min(...m),R=Math.max(...m),O=E[0].side;m.push(O==="left"||O==="top"?I-12*(E.length-m.length):R+12*(E.length-m.length))}return m},"uniqueCoordsFor"),v=f(E=>{const m=E.map(O=>O.coord),I=y(E),R=[];if(E.length<=6){const O=new Array(I.length).fill(!1),F=[],B=f(()=>{if(F.length===E.length){F.some((_,X)=>Math.abs(_-m[X])>=Q)&&R.push([...F]);return}for(const[_,X]of I.entries())O[_]||(O[_]=!0,F.push(X),B(),F.pop(),O[_]=!1)},"visit");return B(),R}for(let O=0;O<m.length;O++)for(let F=O+1;F<m.length;F++){const B=[...m];[B[O],B[F]]=[B[F],B[O]],R.push(B)}return R},"coordinateAssignmentsFor"),M=f((E,m)=>{const I=new Map;for(const[O,F]of E.entries()){const B=m[O],_=I.get(F.edge)??F.points.map(X=>({x:X.x,y:X.y}));F.axis==="vertical"?(_[F.segmentIndex].x=B,_[F.segmentIndex+1].x=B):(_[F.segmentIndex].y=B,_[F.segmentIndex+1].y=B),I.set(F.edge,_)}const R=new Map;for(const[O,F]of I){const B=ae(mt(F));if(ct(B).length!==B.length-1)return;R.set(O,B)}return R},"replacementsForAssignment"),T=f(E=>{for(const[m,I]of E){const R=[m.start,m.end].filter(O=>!!O);for(const O of ct(I))if(At(O.a,O.b,r,R,-2)||At(O.a,O.b,a,[],-2))return!1}for(let m=0;m<l.length;m++){const I=l[m],R=E.has(I),O=ct(d(I,E));for(let F=m+1;F<l.length;F++){const B=l[F];if(!R&&!E.has(B))continue;const _=ct(d(B,E));for(const X of O)for(const P of _)if(ce(X,P,.5)>=_t)return!1}}return!0},"candidateIsSafe");for(let E=0;E<4;E++){const m=i();if(m===0)return;let I,R=m,O=g(),F=Number.POSITIVE_INFINITY;for(const B of c(h()))for(const _ of v(B)){const X=M(B,_);if(!X||!T(X))continue;const P=i(X);if(P>=m)continue;const z=g(X),U=B.reduce((Z,ht,yt)=>Z+Math.abs(_[yt]-ht.coord),0);P>R||P===R&&(z>O||z===O&&U>=F)||(I=X,R=P,O=z,F=U)}if(!I)return;for(const[B,_]of I)B.points=_}}A(cs,"reassignCrossingExternalRailChannels");f(cs,"reassignCrossingExternalRailChannels");function as(t,e){const{realNodeRects:o,labelNodeRects:s}=ue(e.values()),r=t.filter(h=>!h.isLayoutOnly),a=f((h,p,c)=>mt(h===p?c??[]:h.points??[]),"pointsFor"),l=f(h=>ct(h).reduce((p,c)=>{const y=c.a.x-c.b.x,v=c.a.y-c.b.y;return p+Math.hypot(y,v)},0),"pathLength"),d=f((h,p)=>{let c=0;for(let y=0;y<r.length;y++){const v=ct(a(r[y],h,p));for(let M=y+1;M<r.length;M++){const T=ct(a(r[M],h,p));for(const E of v)for(const m of T)de(E.a,E.b,m.a,m.b,Q)&&c++}}return c},"strictCrossingCount"),i=f((h,p)=>{if(h.horizontal){const c=h.a.y;return(Math.abs(c-p.top)<1||Math.abs(c-p.bottom)<1)&&zt(h.a.x,h.b.x,p.left,p.right)>=_t}if(h.vertical){const c=h.a.x;return(Math.abs(c-p.left)<1||Math.abs(c-p.right)<1)&&zt(h.a.y,h.b.y,p.top,p.bottom)>=_t}return!1},"segmentRunsAlongRectBorder"),g=f(h=>{const p=[h.start,h.end].filter(y=>!!y),c=[];for(const y of p){const v=e.get(y),M=v?jt(v):void 0;M&&c.push(M)}return c},"endpointRectsFor"),x=f((h,p)=>{if(p+3>=h.length)return[];const c=h[p],y=h[p+1],v=h[p+2],M=h[p+3],T=Tt(c,y,Q)&&Et(y,v,Q)&&Tt(v,M,Q),E=Et(c,y,Q)&&Tt(y,v,Q)&&Et(v,M,Q);if(!T&&!E)return[];if(!(T?Math.sign(y.x-c.x)!==Math.sign(M.x-v.x):Math.sign(y.y-c.y)!==Math.sign(M.y-v.y)))return[];const I=dt(c,M,Q)||ut(c,M,Q)?[]:[{x:c.x,y:M.y},{x:M.x,y:c.y}],R=I.length===0?[[...h.slice(0,p+1),...h.slice(p+3)]]:I.map(F=>[...h.slice(0,p+1),F,...h.slice(p+3)]),O=new Set;return R.map(F=>ae(mt(F))).filter(F=>{if(ct(F).length!==F.length-1||!F.some(_=>ee(_,M,Q)))return!1;const B=F.map(_=>`${_.x.toFixed(3)},${_.y.toFixed(3)}`).join("|");return O.has(B)?!1:(O.add(B),!0)})},"shortcutCandidatesAt"),C=f((h,p,c)=>{const y=[h.start,h.end].filter(M=>!!M),v=g(h);for(const M of ct(p))if(At(M.a,M.b,o,y,-2)||At(M.a,M.b,s,[],-2)||v.some(T=>i(M,T)))return!1;for(const M of r)if(M!==h){for(const T of ct(p))for(const E of ct(a(M)))if(ce(T,E,.5)>=_t)return!1}return d(h,p)<=c},"candidateIsSafe");for(let h=0;h<8;h++){const p=d();let c,y,v=p,M=Number.POSITIVE_INFINITY,T=Number.POSITIVE_INFINITY;for(const E of r){const m=a(E),I=Zt(m,Q),R=l(m);for(let O=0;O<=m.length-4;O++)for(const F of x(m,O)){const B=Zt(F,Q),_=l(F);if(!(B<I||B===I&&_<R-Q)||!C(E,F,p))continue;const P=d(E,F);P>v||P===v&&(B>M||B===M&&_>=T)||(c=E,y=F,v=P,M=B,T=_)}}if(!c||!y)return;c.points=y}}A(as,"shortcutRedundantOrthogonalJogs");f(as,"shortcutRedundantOrthogonalJogs");function ls(t,e){const a=[];for(const N of e.values()){if(N.isGroup||N.isEdgeLabel)continue;const D=N.x??0,H=N.y??0,j=jt(N);j&&a.push({id:String(N.id??""),cx:D,cy:H,rect:j})}if(a.length===0)return;const l=new Map(a.map(N=>[N.id,N])),d=a.map(N=>({id:N.id,rect:N.rect})),i=["top","bottom","left","right"],g={top:Math.min(...a.map(N=>N.rect.top))-20,bottom:Math.max(...a.map(N=>N.rect.bottom))+20,left:Math.min(...a.map(N=>N.rect.left))-20,right:Math.max(...a.map(N=>N.rect.right))+20},x=t.filter(N=>!N.isLayoutOnly),C=new Map(x.map((N,D)=>[N,D])),h=f(N=>{const D=N==="left"||N==="top"?-1:1,H=[];for(let j=0;j<=2;j++)H.push(g[N]+D*20*j);return H},"outwardTracksForSide"),p=f((N,D=new Map)=>mt(D.get(N)??N.points??[]),"replacementPointsFor"),c=f((N,D)=>{let H=0;for(const j of N)for(const u of D)de(j.a,j.b,u.a,u.b,Q)&&H++;return H},"crossingCountBetweenSegments"),y=f((N,D)=>c(ct(N),ct(D)),"crossingCountBetweenPaths"),v=f((N=new Map)=>{let D=0;const H=[],j=new Set,u=[],b=f(S=>{j.has(S)||(j.add(S),u.push(S))},"addEdge");for(let S=0;S<x.length;S++){const L=x[S],w=p(L,N);for(let k=S+1;k<x.length;k++){const W=x[k],q=y(w,p(W,N));q>0&&(D+=q,H.push({first:L,second:W,count:q}),b(L),b(W))}}return u.sort((S,L)=>(C.get(S)??0)-(C.get(L)??0)),{count:D,pairs:H,edgeSet:j,edges:u}},"crossingSnapshot"),M=f((N,D)=>{const H=new Set(D.keys());if(H.size===0)return N.count;let j=0;for(const b of N.pairs)(H.has(b.first)||H.has(b.second))&&(j+=b.count);let u=0;for(let b=0;b<x.length;b++){const S=x[b],L=H.has(S),w=p(S,D);for(let k=b+1;k<x.length;k++){const W=x[k];!L&&!H.has(W)||(u+=y(w,p(W,D)))}}return N.count-j+u},"crossingCountWithReplacements"),T=f(N=>{const D=new Map;for(const u of N.pairs){const b=D.get(u.first)??new Set;b.add(u.second),D.set(u.first,b);const S=D.get(u.second)??new Set;S.add(u.first),D.set(u.second,S)}const H=[],j=new Set;for(const u of N.edges){if(j.has(u))continue;const b=[u],S=[];for(j.add(u);b.length>0;){const L=b.pop();S.push(L);for(const w of D.get(L)??[])j.has(w)||(j.add(w),b.push(w))}S.sort((L,w)=>(C.get(L)??0)-(C.get(w)??0)),S.length>1&&H.push(S)}return H},"crossingComponents"),E=f(N=>[N.start,N.end].filter(D=>!!D),"endpointIdsFor"),m=f(N=>{const D=[];for(const H of T(N)){const j=new Set(H),u=new Set(H.flatMap(S=>E(S))),b=[...H];for(const S of x)j.has(S)||E(S).some(L=>u.has(L))&&b.push(S);b.sort((S,L)=>(C.get(S)??0)-(C.get(L)??0)),D.push(b)}return D},"pairSearchGroups"),I=f((N,D,H)=>M(N,new Map([[D,H]])),"crossingCountWithSingleReplacement"),R=f(N=>{const D=new Map;for(const H of N.pairs)D.set(H.first,(D.get(H.first)??0)+H.count),D.set(H.second,(D.get(H.second)??0)+H.count);return D},"currentCrossingsByEdge"),O=f(N=>N.slice(1).reduce((D,H,j)=>{const u=N[j];return D+Math.abs(H.x-u.x)+Math.abs(H.y-u.y)},0),"pathLength"),F=f((N=new Map)=>x.reduce((D,H)=>D+Zt(p(H,N)),0),"totalBends"),B=f((N=new Map)=>x.reduce((D,H)=>D+O(p(H,N)),0),"totalLength"),_=f((N,D,H=new Map)=>{const j=ct(D);for(const u of x)if(u!==N){for(const b of j)for(const S of ct(p(u,H)))if(ce(b,S,.5)>=_t)return!0}return!1},"pathHasSegmentConflict"),X=f((N,D)=>{const H=[N.start,N.end].filter(j=>!!j);for(const j of ct(D))if(At(j.a,j.b,d,H,-2))return!0;return!1},"pathHitsNode"),P=f((N,D)=>{const H=ae(mt(D));ct(H).length===H.length-1&&N.push(H)},"pushOrthogonalCandidate"),z=f(N=>N==="left"||N==="right","sideIsHorizontal"),U=f((N,D,H)=>{switch(D){case"left":return Math.min(N.x,H.x)-20;case"right":return Math.max(N.x,H.x)+20;case"top":return Math.min(N.y,H.y)-20;case"bottom":return Math.max(N.y,H.y)+20}},"localTrackForSameSide"),Z=f((N,D,H,j)=>{const u=H==="left"||H==="top"?-1:1,b=[U(D,H,j),g[H]];for(const S of b)for(let L=0;L<=2;L++)P(N,Un(D,H,j,S+u*20*L))},"addSameSideCandidates"),ht=f((N,D,H,j,u)=>{for(const b of h(H))for(const S of h(u))P(N,[D,{x:b,y:D.y},{x:b,y:S},{x:j.x,y:S},j])},"addHorizontalToVerticalCandidates"),yt=f((N,D,H,j,u)=>{for(const b of h(H))for(const S of h(u))P(N,[D,{x:D.x,y:b},{x:S,y:b},{x:S,y:j.y},j])},"addVerticalToHorizontalCandidates"),Ft=f((N,D,H,j,u)=>{const b=[...h("top"),...h("bottom")];for(const S of h(H))for(const L of h(u))for(const w of b)P(N,[D,{x:S,y:D.y},{x:S,y:w},{x:L,y:w},{x:L,y:j.y},j])},"addHorizontalPairCandidates"),Pt=f((N,D,H,j,u)=>{const b=[...h("left"),...h("right")];for(const S of h(H))for(const L of h(u))for(const w of b)P(N,[D,{x:D.x,y:S},{x:w,y:S},{x:w,y:L},{x:j.x,y:L},j])},"addVerticalPairCandidates"),tt=f(N=>{const D=new Set;return N.map(H=>mt(H)).filter(H=>{const j=H.map(u=>`${u.x.toFixed(3)},${u.y.toFixed(3)}`).join("|");return D.has(j)||H.length<2?!1:(D.add(j),!0)})},"dedupeCandidatePaths"),K=f((N,D,H,j)=>{const u=[],b=jn(N,D,H,j,20,Q);b&&P(u,b),D===j&&Z(u,N,D,H);const S=z(D),L=z(j);return S&&!L?ht(u,N,D,H,j):!S&&L?yt(u,N,D,H,j):S?Ft(u,N,D,H,j):Pt(u,N,D,H,j),tt(u)},"buildCandidatesForSides"),nt=f((N,D,H,j)=>{const u=[...h("left"),...h("right")],b=[...h("top"),...h("bottom")];for(const S of i){const L=Me(j,S),w=S==="top"||S==="bottom"?h(S):b;for(const k of u){P(N,[D,H,{x:k,y:H.y},{x:k,y:L.y},L]);for(const W of w)P(N,[D,H,{x:k,y:H.y},{x:k,y:W},{x:L.x,y:W},L])}}},"addVerticalDepartureOuterTrackCandidates"),lt=f((N,D,H,j)=>{const u=[...h("left"),...h("right")],b=[...h("top"),...h("bottom")];for(const S of i){const L=Me(j,S),w=S==="left"||S==="right"?h(S):u;for(const k of b){P(N,[D,H,{x:H.x,y:k},{x:L.x,y:k},L]);for(const W of w)P(N,[D,H,{x:H.x,y:k},{x:W,y:k},{x:W,y:L.y},L])}}},"addHorizontalDepartureOuterTrackCandidates"),pt=f(N=>{const D=N.start,H=N.end,j=H?l.get(H):void 0;if(!D||!j)return[];const u=mt(N.points??[]);if(u.length<4)return[];const b=u[0],S=u[1],L=[];return Et(b,S,Q)?nt(L,b,S,j):Tt(b,S,Q)&<(L,b,S,j),L},"terminalPreservingOuterTrackCandidates"),bt=f(N=>{const D=N.start,H=N.end,j=D?l.get(D):void 0,u=H?l.get(H):void 0;if(!j||!u)return[];const b=[];for(const S of i){const L=Me(j,S);for(const w of i)b.push(...K(L,S,Me(u,w),w))}return b.push(...pt(N)),b},"candidatePathsFor"),Lt=f(()=>new Map(x.map(N=>[N,ct(p(N))])),"currentSegmentsByEdge"),Ut=f((N,D,H)=>{const j=new Set;for(const u of x){if(u===N)continue;const b=H.get(u)??ct(p(u));D.some(S=>b.some(L=>ce(S,L,.5)>=_t))&&j.add(u)}return j},"sharedTrackConflictsFor"),Wt=f((N,D,H,j)=>{const u=new Set;return bt(N).map(S=>ae(mt(S))).filter(S=>{if(X(N,S))return!1;const L=S.map(w=>`${w.x.toFixed(3)},${w.y.toFixed(3)}`).join("|");return u.has(L)||S.length<2?!1:(u.add(L),!0)}).map(S=>{const L=ct(S);let w=0;for(const k of x)k!==N&&(w+=c(L,H.get(k)??ct(p(k))));return{candidate:S,candidateSegments:L,crossings:D.count-(j.get(N)??0)+w,bends:Zt(S,Q),totalBends:Zt(S),length:O(S)}}).filter(({crossings:S})=>S<=D.count).sort((S,L)=>S.crossings-L.crossings||S.bends-L.bends||S.length-L.length).slice(0,48).map(S=>({path:S.candidate,segments:S.candidateSegments,sharedTrackConflicts:Ut(N,S.candidateSegments,H),totalBends:S.totalBends,length:S.length}))},"pairCandidatesFor"),Kt=f((N,D,H,j,u,b)=>{let S=0;for(const w of N.pairs)(w.first===D||w.second===D||w.first===j||w.second===j)&&(S+=w.count);let L=c(H.segments,u.segments);for(const w of x){if(w===D||w===j)continue;const k=b.get(w)??ct(p(w));L+=c(H.segments,k)+c(u.segments,k)}return N.count-S+L},"pairCrossingCount"),ne=f((N,D)=>{for(const H of N.sharedTrackConflicts)if(H!==D)return!1;return!0},"conflictsOnlyWith"),Ee=f((N,D)=>N.segments.some(H=>D.segments.some(j=>ce(H,j,.5)>=_t)),"candidatesShareTrack"),ge=f((N,D,H,j)=>ne(D,H.edge)&&ne(j,N.edge)&&!Ee(D,j),"pairCandidatesAreCompatible"),we=f((N,D,H,j,u)=>{const b=Kt(N.current,D.edge,H,j.edge,u,N.baseSegments);if(!(b>=N.current.count))return{replacements:new Map([[D.edge,H.path],[j.edge,u.path]]),crossings:b,bends:N.currentBends-(N.baseBendsByEdge.get(D.edge)??0)-(N.baseBendsByEdge.get(j.edge)??0)+H.totalBends+u.totalBends,length:N.currentLength-(N.baseLengthByEdge.get(D.edge)??0)-(N.baseLengthByEdge.get(j.edge)??0)+H.length+u.length}},"scorePairReplacement"),ao=f((N,D)=>N.crossings<D.crossings||N.crossings===D.crossings&&(N.bends<D.bends||N.bends===D.bends&&N.length<D.length),"pairScoreIsBetter"),lo=f((N,D,H,j)=>{let u=j;for(const b of D.candidates)for(const S of H.candidates){if(!ge(D,b,H,S))continue;const L=we(N,D,b,H,S);L&&ao(L,u)&&(u=L)}return u},"bestScoreForOptionPair"),fo=f(N=>{const D=F(),H=B(),j=Lt(),u=R(N),b=new Map(x.map(q=>[q,Zt(p(q))])),S=new Map(x.map(q=>[q,O(p(q))])),L=new Map,w=m(N);for(const q of w)for(const V of q){if(L.has(V))continue;const G=Wt(V,N,j,u);G.length>0&&L.set(V,{edge:V,candidates:G})}let k={replacements:new Map,crossings:N.count,bends:D,length:H};const W={current:N,currentBends:D,currentLength:H,baseBendsByEdge:b,baseLengthByEdge:S,baseSegments:j};for(const q of w){const V=new Set(q.filter(st=>N.edgeSet.has(st))),G=q.map(st=>L.get(st)).filter(st=>!!st);for(let st=0;st<G.length;st++){const it=G[st];for(let rt=st+1;rt<G.length;rt++){const et=G[rt];!V.has(it.edge)&&!V.has(et.edge)||(k=lo(W,it,et,k))}}}return k.replacements.size>0?k.replacements:void 0},"bestPairedReplacement");for(let N=0;N<4;N++){const D=v(),H=D.count;if(H===0)return;let j,u,b=H,S=Number.POSITIVE_INFINITY;for(const w of D.edges){const k=Zt(p(w),Q);for(const W of bt(w)){const q=X(w,W),V=!q&&_(w,W),G=I(D,w,W),st=Zt(W,Q);q||V||!(G<H||G===H&&st<k)||G>b||G===b&&st>=S||(j=w,u=W,b=G,S=st)}}if(j&&u){j.points=u;continue}const L=fo(D);if(!L)return;for(const[w,k]of L)w.points=k}}A(ls,"resolveRenderedOrthogonalCrossings");f(ls,"resolveRenderedOrthogonalCrossings");var xe=.001,Or=8;function ds(t,e){const{nodeInfoById:n,realNodeRects:o}=Ue(e),s=["top","bottom","left","right"],r=20,a={top:Math.min(...o.map(c=>c.rect.top))-r,bottom:Math.max(...o.map(c=>c.rect.bottom))+r,left:Math.min(...o.map(c=>c.rect.left))-r,right:Math.max(...o.map(c=>c.rect.right))+r},l=f((c,y,v,M)=>{const T=[],E=jn(c,y,v,M,r,xe);return E&&T.push(E),y===M&&T.push(Un(c,y,v,a[y])),T},"buildOrthogonalPathCandidates"),d=f((c,y)=>{for(let v=0;v<c.length-1;v++){const M=c[v],T=c[v+1];if(At(M,T,o,y,1))return!0}return!1},"pathHitsNode"),i=f((c,y,v=!1)=>{let M=0;const T=Le(c,xe),E=y.start,m=y.end;for(const I of t){if(I===y||I.isLayoutOnly)continue;const R=I.start,O=I.end;if(!v&&E&&m&&(R===E||R===m||O===E||O===m))continue;const F=I.points;if(!(!F||F.length<2))for(const B of T)for(const _ of Le(F,xe)){if(Kn(B.a,B.b,_.a,_.b,xe,xe)){M++;continue}ce(B,_,xe)>=Or&&M++}}return M},"pathConflictCount"),g=4,x=f((c,y)=>{const v=Math.abs(c.y-y.rect.top),M=Math.abs(c.y-y.rect.bottom),T=Math.abs(c.x-y.rect.left),E=Math.abs(c.x-y.rect.right);let m="top",I=v;return M<I&&(m="bottom",I=M),T<I&&(m="left",I=T),E<I&&(m="right",I=E),m},"nearestSideOfRect"),C=new Map,h=f((c,y,v)=>{const M=C.get(c)??[];M.push({side:y,edgeId:v}),C.set(c,M)},"addFaceClaim");for(const c of t){if(c.isLayoutOnly)continue;const y=c.points??[];if(y.length<1)continue;const v=c.id??"",M=c.start,T=c.end;if(M){const E=n.get(M);E&&h(M,x(y[0],E),v)}if(T){const E=n.get(T);E&&h(T,x(y[y.length-1],E),v)}}const p=f((c,y,v)=>C.get(c)?.some(M=>M.edgeId!==v&&M.side===y)??!1,"faceIsClaimed");for(const c of t){if(c.isLayoutOnly)continue;const y=c.points;if(!y||y.length<2)continue;const v=Zt(y,xe);if(v<g)continue;const M=c.start,T=c.end;if(!M||!T)continue;const E=n.get(M),m=n.get(T);if(!E||!m)continue;const I=c.id??"",R=i(y,c,!0),O=i(y,c);let F,B=R,_=v;for(const X of s){if(p(M,X,I))continue;const P=Me(E,X);for(const z of s){if(p(T,z,I))continue;const U=Me(m,z);for(const Z of l(P,X,U,z)){if(d(Z,[M,T]))continue;const ht=Zt(Z,xe);if(R>0){const yt=i(Z,c,!0);if(yt>B||yt===B&&ht>=_)continue;B=yt,_=ht,F=Z;continue}i(Z,c)>O||ht<_&&(_=ht,F=Z)}}}if(F){c.points=F;const X=C.get(M);X&&C.set(M,X.filter(z=>z.edgeId!==I));const P=C.get(T);P&&C.set(T,P.filter(z=>z.edgeId!==I)),h(M,x(F[0],E),I),h(T,x(F[F.length-1],m),I)}}}A(ds,"simplifyDetouredEdges");f(ds,"simplifyDetouredEdges");var qt=.001,dr=10,rn=7;function En(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 a=r.x-s.x,l=r.y-s.y;if(!(Math.abs(a)+Math.abs(l)<qt)){if(Math.abs(l)<=qt){const i=s.x+Math.sign(a)*dr;return{left:Math.min(s.x,i),right:Math.max(s.x,i),top:s.y-rn,bottom:s.y+rn}}if(Math.abs(a)<=qt){const i=s.y+Math.sign(l)*dr;return{left:s.x-rn,right:s.x+rn,top:Math.min(s.y,i),bottom:Math.max(s.y,i)}}return{left:Math.min(s.x,r.x),right:Math.max(s.x,r.x),top:Math.min(s.y,r.y),bottom:Math.max(s.y,r.y)}}}A(En,"markerClearanceRectFor");f(En,"markerClearanceRectFor");function fs(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}A(fs,"normalizeRect");f(fs,"normalizeRect");function wn(t,e){const n=mt(e),o=En(n,!0),s=En(n,!1);return[o,s].some(r=>r&&De(t,fs(r)))}A(wn,"labelOverlapsOwnMarker");f(wn,"labelOverlapsOwnMarker");function ke(t,e){const n=[];for(const p of t){if(p.isLayoutOnly)continue;const c=p.points;if(!(!c||c.length<2))for(let y=0;y<c.length-1;y++)n.push({edgeId:p.id,p1:c[y],p2:c[y+1]})}const o=[],s=[];for(const p of e.values()){const c=p.isGroup,y=p.parentId;if(c&&!y){const M=jt(p);M&&s.push({id:p.id,rect:M});continue}if(c||p.isEdgeLabel)continue;const v=jt(p);v&&o.push({nodeId:p.id,rect:v})}const r=3,a=1,l=12,d=f((p,c)=>{const y=fn(c,r);for(const{nodeId:v,rect:M}of o)if(v!==p&&De(y,M))return!0;return!1},"labelOverlapsForeignNode"),i=f((p,c)=>{const y=fn(c,r);for(const v of n)if(v.edgeId!==p&&je(v.p1,v.p2,y))return!0;return!1},"labelOverlapsForeignEdge"),g=f((p,c,y)=>d(p,y)||i(c,y),"labelOverlapsAnything"),x=[],C=f(p=>{for(const{id:c,rect:y}of s)if(Ho(y,p))return c},"findContainingLane"),h=f((p,c)=>x.some(y=>y.labelId!==p&&De(c,y.rect)),"overlapsPlacedLabel");for(const p of t){if(p.isLayoutOnly)continue;const c=p.labelNodeId;if(!c)continue;const y=e.get(c);if(!y)continue;const v=p.points;if(!v||v.length<2)continue;const M=y.width??0,T=y.height??0;if(M<=0||T<=0)continue;const E=[];for(let tt=0;tt<v.length-1;tt++){const K=v[tt],nt=v[tt+1],lt=Math.abs(K.x-nt.x),pt=Math.abs(K.y-nt.y);lt<qt&&pt<qt||lt>=qt&&pt>=qt||E.push({idx:tt,length:lt+pt,orientation:lt>=qt?"horizontal":"vertical",midX:(K.x+nt.x)/2,midY:(K.y+nt.y)/2})}if(E.length===0)continue;const m=E.length>=3?E.filter(tt=>tt.idx>0&&tt.idx<E.length-1):E,I=m.length>0?m:E,R=M>=T?"horizontal":"vertical",O=f(tt=>[...tt].sort((K,nt)=>{const lt=K.orientation===R,pt=nt.orientation===R;if(lt!==pt)return lt?-1:1;const bt=K.length>=(K.orientation==="horizontal"?M:T)+2,Lt=nt.length>=(nt.orientation==="horizontal"?M:T)+2;return bt!==Lt?bt?-1:1:nt.length-K.length}),"rankSegments"),F=E[0],B=E[E.length-1],_=[.5,.25,.75,.05,.95,.15,.85,.1,.9],X=f((tt,K)=>{const nt=v[tt.idx],lt=v[tt.idx+1];return{midX:nt.x+(lt.x-nt.x)*K,midY:nt.y+(lt.y-nt.y)*K}},"anchorAtT"),P=f((tt,K,nt)=>Math.min(nt,Math.max(K,tt)),"clamp"),z=f((tt,K)=>tt.midX>=K.left-qt&&tt.midX<=K.right+qt&&tt.midY>=K.top-qt&&tt.midY<=K.bottom+qt,"pointInsideRectInclusive"),U=f(tt=>{const K=ve(tt.midX,tt.midY,M,T),nt=C(K);if(nt)return{laneId:nt,anchor:tt,rect:K};const lt=s.find(({rect:ne})=>z(tt,ne));if(!lt)return;const pt=lt.rect.left+M/2+a,bt=lt.rect.right-M/2-a,Lt=lt.rect.top+T/2+a,Ut=lt.rect.bottom-T/2-a;if(pt>bt||Lt>Ut)return;const Wt={midX:P(tt.midX,pt,bt),midY:P(tt.midY,Lt,Ut)},Kt=ve(Wt.midX,Wt.midY,M,T);return z(tt,Kt)?{laneId:lt.id,anchor:Wt,rect:Kt}:void 0},"placementForAnchor"),Z=f((tt,K,nt)=>tt.orientation==="horizontal"?Math.abs(K.midX-nt.x):Math.abs(K.midY-nt.y),"distanceAlongSegment"),ht=f((tt,K)=>{const lt=(tt.orientation==="horizontal"?M/2:T/2)+l;if(tt===F){const pt=v[tt.idx];if(Z(tt,K,pt)+qt<lt)return!1}if(tt===B){const pt=v[tt.idx+1];if(Z(tt,K,pt)+qt<lt)return!1}return!0},"labelClearsTerminalEndpoints"),yt=f(tt=>{const K=O(tt);for(const nt of K)for(const lt of _){const pt=X(nt,lt);if(!ht(nt,pt))continue;const bt=U(pt);if(bt&&!wn(bt.rect,v)&&!h(c,bt.rect)&&!g(c,p.id,bt.rect))return{laneId:bt.laneId,anchor:bt.anchor}}},"tryPool"),Ft=f((tt,K,nt=!1)=>{const lt=O(tt);for(const pt of lt){const bt={midX:pt.midX,midY:pt.midY};if(K&&!ht(pt,bt))continue;const Lt=U(bt);if(Lt&&!wn(Lt.rect,v)&&!h(c,Lt.rect)&&!d(c,Lt.rect)&&(nt||!i(p.id,Lt.rect)))return{laneId:Lt.laneId,anchor:Lt.anchor}}},"findLaneContainingFallback"),Pt=yt(I)??(I.length<E.length?yt(E):void 0)??Ft(E,!0)??Ft(E,!1)??Ft(E,!1,!0);if(Pt){y.x=Pt.anchor.midX,y.y=Pt.anchor.midY,y.parentId=Pt.laneId;const tt=ve(Pt.anchor.midX,Pt.anchor.midY,M,T),K=x.findIndex(nt=>nt.labelId===c);K>=0?x[K]={labelId:c,rect:tt}:x.push({labelId:c,rect:tt})}}}A(ke,"anchorLabelsToPolyline");f(ke,"anchorLabelsToPolyline");var Mo=1e-6,Nr=8,fr=Nr/2,Br=3;function Rn(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}A(Rn,"pairKey");f(Rn,"pairKey");function us(t,e){const{nodeInfoById:n,realNodeRects:o}=Ue(e),s=new Map;for(const a of e){const l=a.id;if(!a.isGroup&&a.isEdgeLabel){s.set(l,{w:a.width??0,h:a.height??0});continue}}const r=f((a,l,d,i)=>{const g=Rn(l,d);let x=0;const C=f(h=>{if(!h)return;const p=s.get(h);if(!p)return;const c=i==="x"?p.w/2:p.h/2;c>x&&(x=c)},"consider");C(a.labelNodeId);for(const h of t){if(h===a||h.isLayoutOnly)continue;const p=h.start,c=h.end;!p||!c||Rn(p,c)===g&&C(h.labelNodeId)}return x>0?x+Br:0},"labelClearanceFor");for(const a of t){if(a.isLayoutOnly)continue;const l=a.points;if(!$n(l,Mo))continue;const d=Wn(a,n,Mo);if(!d)continue;const{srcId:i,dstId:g,srcInfo:x,dstInfo:C,collinearX:h,collinearY:p}=d;if(h===p)continue;let c,y;if(h){const m=C.cy>x.cy;c={x:x.cx,y:m?x.rect.bottom:x.rect.top},y={x:C.cx,y:m?C.rect.top:C.rect.bottom}}else{const m=C.cx>x.cx;c={x:m?x.rect.right:x.rect.left,y:x.cy},y={x:m?C.rect.left:C.rect.right,y:C.cy}}if(At(c,y,o,[i,g],1))continue;const M=r(a,i,g,h?"x":"y"),T=M>fr?M:fr,E=[0,T,-T];for(const m of E){const I={...c},R={...y};if(h){if(I.x+=m,R.x+=m,I.x<=x.rect.left||I.x>=x.rect.right||R.x<=C.rect.left||R.x>=C.rect.right)continue}else if(I.y+=m,R.y+=m,I.y<=x.rect.top||I.y>=x.rect.bottom||R.y<=C.rect.top||R.y>=C.rect.bottom)continue;if(!At(I,R,o,[i,g],1)&&!He(I,R,t,a,{epsilon:Mo})){a.points=[I,R];break}}}}A(us,"straightenCollinearSiblingDetours");f(us,"straightenCollinearSiblingDetours");function An(t,e){const{realNodeRects:d,labelNodeRects:i}=ue(e.values()),g=f((m,I)=>Le(I,.001).map(R=>({...R,edge:m,interior:R.index>=1&&R.index<=I.length-3})),"segmentsFor"),x=f(()=>{const m=[];for(const I of t){if(I.isLayoutOnly)continue;const R=I.points;!R||R.length<2||m.push(...g(I,mt(R)))}return m},"allSegments"),C=f((m,I)=>m.horizontal&&I.horizontal?zt(m.a.x,m.b.x,I.a.x,I.b.x)>=8&&Math.abs(m.a.y-I.a.y)<7:m.vertical&&I.vertical?zt(m.a.y,m.b.y,I.a.y,I.b.y)>=8&&Math.abs(m.a.x-I.a.x)<7:!1,"hasCrowdedParallelTrack"),h=f((m,I)=>{const R=m.start,O=m.end,F=g(m,I);if(F.length!==I.length-1)return!1;const B=[R,O].filter(X=>!!X),_=m.labelNodeId?[m.labelNodeId]:[];for(const X of F)if(At(X.a,X.b,d,B,-2)||At(X.a,X.b,i,_,-2))return!1;for(const X of t){if(X===m||X.isLayoutOnly)continue;const P=X.points;if(!(!P||P.length<2)){for(const z of F)for(const U of g(X,mt(P)))if(C(z,U)||de(z.a,z.b,U.a,U.b,.001))return!1}}return!0},"candidateIsSafe"),p=f((m,I)=>{const R=mt(m.edge.points??[]);if(R.length<4||m.index>=R.length-1)return;const O=R.map(F=>({...F}));if(m.horizontal)O[m.index].y+=I,O[m.index+1].y+=I;else if(m.vertical)O[m.index].x+=I,O[m.index+1].x+=I;else return;return g(m.edge,O).length===O.length-1?O:void 0},"shiftedCandidate"),c=f((m,I)=>({x:m.x??(I.left+I.right)/2,y:m.y??(I.top+I.bottom)/2}),"nodeCenter"),y=f(m=>{const I=m.edge,R=mt(I.points??[]);if(R.length!==4||m.index!==1)return;const O=I.start?e.get(I.start):void 0,F=I.end?e.get(I.end):void 0,B=O?jt(O):void 0,_=F?jt(F):void 0,X=R.slice(m.index+2);if(!(!O||!F||!B||!_||X.length===0))return{sourceCenter:c(O,B),targetCenter:c(F,_),sourceRect:B,tail:X}},"sourceDetourContextFor"),v=f((m,I,R,O,F,B)=>{const _=O.y>=R.y,X=_?F.bottom:F.top,P=X+(_?20:-20);if(_&&m.b.y<=P+.001||!_&&m.b.y>=P-.001)return;const z=m.a.x+I;return mt([{x:R.x,y:X},{x:R.x,y:P},{x:z,y:P},{x:z,y:m.b.y},...B],.001)},"verticalSourceDetour"),M=f((m,I,R,O,F,B)=>{const _=O.x>=R.x,X=_?F.right:F.left,P=X+(_?20:-20);if(_&&m.b.x<=P+.001||!_&&m.b.x>=P-.001)return;const z=m.a.y+I;return mt([{x:X,y:R.y},{x:P,y:R.y},{x:P,y:z},{x:m.b.x,y:z},...B],.001)},"horizontalSourceDetour"),T=f((m,I)=>{const R=y(m);if(R){if(m.vertical)return v(m,I,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail);if(m.horizontal)return M(m,I,R.sourceCenter,R.targetCenter,R.sourceRect,R.tail)}},"sourceDetourCandidate"),E=[-7,7,-14,14,-21,21];for(let m=0;m<12;m++){const I=x();let R=!1;for(let O=0;O<I.length&&!R;O++)for(let F=O+1;F<I.length&&!R;F++){const B=I[O],_=I[F];if(B.edge===_.edge||!C(B,_))continue;const X=[B,_].filter(P=>P.interior);for(const P of X){for(const z of E){const U=p(P,z);if(U&&h(P.edge,U)){P.edge.points=U,R=!0;break}const Z=T(P,z);if(Z&&h(P.edge,Z)){P.edge.points=Z,R=!0;break}}if(R)break}}if(!R)return}}A(An,"nudgeSharedInteriorSubpaths");f(An,"nudgeSharedInteriorSubpaths");function hs(t,e,n,o){const s=e.x-t.x,r=e.y-t.y,a=o.x-n.x,l=o.y-n.y,d=s*l-r*a;if(Math.abs(d)<1e-10)return!1;const i=n.x-t.x,g=n.y-t.y,x=(i*l-g*a)/d,C=(i*r-g*s)/d,h=.01;return x>h&&x<1-h&&C>h&&C<1-h}A(hs,"segmentsIntersect");f(hs,"segmentsIntersect");function gs(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const s=Xo(e),r=[];for(const l of n){if(l.isLayoutOnly)continue;const d=l.points;if(!d||d.length<2)continue;const i=l.start,g=l.end,x=l.labelNodeId,C=l.id??`${i}->${g}`;for(const h of s)if(!(h.nodeId===i||h.nodeId===g)&&!(x&&h.nodeId===x)){for(let p=0;p<d.length-1;p++)if(je(d[p],d[p+1],h,-1)){o.push({type:"edge-node-overlap",edgeId:C,targetId:h.nodeId,detail:`segment ${p} passes through node "${h.nodeId}"`});break}}for(let h=0;h<d.length-1;h++)r.push({edgeId:C,start:i,end:g,p1:d[h],p2:d[h+1]})}const a=new Set;for(let l=0;l<r.length;l++)for(let d=l+1;d<r.length;d++){const i=r[l],g=r[d];if(i.edgeId!==g.edgeId&&!(i.start===g.start||i.start===g.end||i.end===g.start||i.end===g.end)&&hs(i.p1,i.p2,g.p1,g.p2)){const x=i.edgeId<g.edgeId?`${i.edgeId}|${g.edgeId}`:`${g.edgeId}|${i.edgeId}`;a.has(x)||(a.add(x),o.push({type:"edge-edge-crossing",edgeId:i.edgeId,targetId:g.edgeId,detail:`edges "${i.edgeId}" and "${g.edgeId}" cross`}))}}if(o.length>0){const l=o.filter(i=>i.type==="edge-node-overlap").length,d=o.filter(i=>i.type==="edge-edge-crossing").length;So.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${l} edge-node overlap(s), ${d} edge crossing(s)`);for(const i of o)So.warn(`[SWIMLANE_VALIDATE] ${i.type}: ${i.detail}`)}return o}A(gs,"validateSwimlanesLayout");f(gs,"validateSwimlanesLayout");function ps(t,e){const n=t.nodes??[],o=t.edges??[],s=n.filter(l=>!l.isGroup);if((e==="LR"||e==="RL")&&s.length>0&&!es(t,e)||e==="BT"&&s.length>0&&!ts(t))return;for(const l of o){if(l.isLayoutOnly)continue;const d=l.points;!d||d.length<2||(l.points=ae(Xe(d)))}ds(o,n),us(o,n),ns(o,n);const r=new Map;for(const l of n)r.set(String(l.id),l);ke(o,r),Vo(o,r),os(o,r),An(o,r),ss(o,r),rs(o,r),vn(o,r),is(o,r);const a=f(()=>{ls(o,r),cs(o,r),as(o,r),ke(o,r),Sn(o,r),vn(o,r),ke(o,r),Sn(o,r)},"finalizeRenderedEdges");a(),An(o,r),a(),Ln(o,r),Tn(o,r),Ln(o,r),Tn(o,r)}A(ps,"postProcessSwimlaneLayout");f(ps,"postProcessSwimlaneLayout");function he(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 a=`${r.id}:${r.src}->${r.dst}`;n.has(a)||(n.add(a),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}A(he,"normalizeGraph");f(he,"normalizeGraph");function to(t,e){return t.edges.filter(n=>n.dst===e)}A(to,"incoming");f(to,"incoming");function ms(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}A(ms,"buildSuccessorMap");f(ms,"buildSuccessorMap");function eo(t){const e=ms(t);for(const n of e.values())n.sort((o,s)=>o.localeCompare(s));return e}A(eo,"buildSortedSuccessorMap");f(eo,"buildSortedSuccessorMap");function no(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}A(no,"buildInDegreeMap");f(no,"buildInDegreeMap");function oo(t){return[...t.entries()].filter(([,e])=>e===0).map(([e])=>e).sort((e,n)=>e.localeCompare(n))}A(oo,"sortedZeroInDegreeNodes");f(oo,"sortedZeroInDegreeNodes");function We(t,e=()=>!0){const n=new Map,o=new Map;for(const s of t.nodes)n.set(s,[]),o.set(s,[]);for(const s of t.edges)e(s)&&(o.get(s.src).push(s.dst),n.get(s.dst).push(s.src));return{preds:n,succs:o}}A(We,"buildPredecessorSuccessorMaps");f(We,"buildPredecessorSuccessorMaps");function so(t,e,n,o){let s=0;for(const a of t.nodes)o?.skipGroups&&t.nodeById.get(a)?.isGroup||(s=Math.max(s,n[a]??0));const r=Array.from({length:s+1},()=>[]);for(const a of e)o?.skipGroups&&t.nodeById.get(a)?.isGroup||r[Math.max(0,n[a]??0)].push(a);return r}A(so,"buildLayersFromRanks");f(so,"buildLayersFromRanks");function Pe(t){const e=no(t),n=oo(e),o=[],s=eo(t);for(;n.length;){const r=n.shift();o.push(r);for(const a of s.get(r)??[])if(e.set(a,(e.get(a)??0)-1),(e.get(a)??0)===0){let l=0;for(;l<n.length&&n[l]<a;)l++;n.splice(l,0,a)}}return o.length===t.nodes.length?o:null}A(Pe,"topoSortIfAcyclic");f(Pe,"topoSortIfAcyclic");function Te(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}A(Te,"buildLayerIndex");f(Te,"buildLayerIndex");function ro(t){const e=new Array(t.length),n=f((o,s)=>{if(s-o<=1)return 0;const r=o+s>>1;let a=n(o,r)+n(r,s),l=o,d=r,i=o;for(;l<r||d<s;)d>=s||l<r&&t[l]<=t[d]?e[i++]=t[l++]:(e[i++]=t[d++],a+=r-l);for(let g=o;g<s;g++)t[g]=e[g];return a},"count");return n(0,t.length)}A(ro,"countInversions");f(ro,"countInversions");function ys(t){const e=he(t),n=new Map;for(const g of e.nodes)n.set(g,[]);for(const g of e.edges)n.get(g.src).push(g);for(const g of n.values())g.sort((x,C)=>x.dst===C.dst?x.id.localeCompare(C.id):x.dst.localeCompare(C.dst));const o=Object.create(null);for(const g of e.nodes)o[g]=0;const s=[],r=f(g=>{o[g]=1;for(const x of n.get(g)??[]){const C=x.dst;o[C]===0?r(C):o[C]===1&&s.push(x)}o[g]=2},"dfs"),a=[...e.nodes].sort((g,x)=>g.localeCompare(x));for(const g of a)o[g]===0&&r(g);const l=new Set(s.map(g=>`${g.id}:${g.src}->${g.dst}`)),d=e.edges.map(g=>l.has(`${g.id}:${g.src}->${g.dst}`)?{id:g.id,src:g.dst,dst:g.src,weight:g.weight,ref:g.ref}:g);return{acyclic:{nodes:[...e.nodes],edges:d,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:s}}A(ys,"removeCycles_DFS");f(ys,"removeCycles_DFS");function xs(t){const e=new Map,n=f(o=>{if(e.has(o))return e.get(o);const s=t.nodeById.get(o);if(!s)return e.set(o,null),null;const r=s.parentId;if(!r)return e.set(o,null),null;const l=n(r)??r;return e.set(o,l),l},"resolve");for(const o of t.nodes)n(o);return e}A(xs,"buildTopLaneMap");f(xs,"buildTopLaneMap");function fe(t){const e=xs(t);return n=>e.get(n)??null}A(fe,"createTopLaneResolver");f(fe,"createTopLaneResolver");function Ke(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}A(Ke,"buildTopLaneOrder");f(Ke,"buildTopLaneOrder");function io(t,e){const n=Ke(t);if(!e||e.length===0)return n;const o=new Set(n),s=new Set,r=[];for(const a of e)!o.has(a)||s.has(a)||(s.add(a),r.push(a));for(const a of n)s.has(a)||r.push(a);return r}A(io,"resolveTopLaneOrder");f(io,"resolveTopLaneOrder");var Pr={EPSILON:1e-6},On={GRAVITY_ITERATIONS:8,MAX_CROSSING_OPTIMIZATION_PASSES:4,DEFAULT_COMPACT_SINGLE_INPUT:!0},ur={DEFAULT_LAYER_GAP:100,DEFAULT_NODE_GAP:40};function bs(t,e){const n=he(t),o=e?.laneOf??(()=>null),s=e?.rankHint,{preds:r}=We(n);for(const m of r.values())m.sort((I,R)=>I.localeCompare(R));const a=Pe(n)??[...n.nodes].sort((m,I)=>m.localeCompare(I)),l=new Map;for(const[m,I]of a.entries())l.set(I,m);const d=new Map,i=new Map;for(const m of n.nodes)i.set(m,[]);for(const m of a){const I=(r.get(m)??[]).filter(R=>d.has(R));if(I.length>0){const R=Ms(m,I,{laneOf:o,rankHint:s,topoIndex:l});d.set(m,R),i.get(R).push(m)}else d.has(m)||d.set(m,null)}for(const m of n.nodes)d.has(m)||d.set(m,null);const g=new Set;for(const m of n.nodes)(d.get(m)??null)===null&&g.add(m);const x=[...g].sort((m,I)=>{const R=l.get(m)??0,O=l.get(I)??0;return R===O?m.localeCompare(I):R-O}),C=Is(n),h=new Map;for(const[m,I]of C.entries())h.set(m,[...I].sort((R,O)=>R.localeCompare(O)));const p=Ss(h),c=Cs(h),y=new Map;for(const m of n.nodes)y.set(m,[]);for(const m of c)for(const I of m.nodes){const R=y.get(I);R?R.push(m.id):y.set(I,[m.id])}const v=[],M=[],T=new Set,E=f(m=>{if(!T.has(m)){T.add(m),v.push(m);for(const I of i.get(m)??[])E(I);M.push(m)}},"walk");for(const m of x)E(m);for(const m of a)E(m);return{parent:d,children:i,roots:x,componentOf:p,blocks:c,nodeBlocks:y,adjacency:h,preorder:v,postorder:M,topologicalOrder:a}}A(bs,"buildDrivingTree");f(bs,"buildDrivingTree");function Ms(t,e,n){const o=n.laneOf(t);return[...e].sort((r,a)=>{const l=n.laneOf(r),d=n.laneOf(a),i=l!=null&&l===o,g=d!=null&&d===o;if(i!==g)return i?-1:1;const x=n.rankHint?.[r],C=n.rankHint?.[a];if(x!=null&&C!=null&&x!==C)return C-x;const h=n.topoIndex.get(r)??0,p=n.topoIndex.get(a)??0;return h!==p?h-p:r.localeCompare(a)})[0]}A(Ms,"chooseParent");f(Ms,"chooseParent");function Is(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}A(Is,"buildAdjacency");f(Is,"buildAdjacency");function Ss(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 a of t.get(r)??[])e.has(a)||s.push(a)}}n++}return e}A(Ss,"assignComponents");f(Ss,"assignComponents");function Cs(t){const e=new Map,n=new Map,o=[],s=[];let r=0;const a=f((l,d)=>{e.set(l,++r),n.set(l,r);for(const i of t.get(l)??[])i!==d&&(e.has(i)?(e.get(i)??0)<(e.get(l)??0)&&(o.push([l,i]),n.set(l,Math.min(n.get(l)??r,e.get(i)??r))):(o.push([l,i]),a(i,l),n.set(l,Math.min(n.get(l)??r,n.get(i)??r)),(n.get(i)??0)>=(e.get(l)??0)&&s.push(vs(l,i,o,s.length))))},"visit");for(const l of t.keys())e.has(l)||a(l,null);return s}A(Cs,"computeBlocks");f(Cs,"computeBlocks");function vs(t,e,n,o){const s=[],r=new Set;for(;n.length>0;){const a=n.pop();if(s.push(a),r.add(a[0]),r.add(a[1]),a[0]===t&&a[1]===e||a[0]===e&&a[1]===t)break}return{id:o,edges:s,nodes:[...r]}}A(vs,"popBlock");f(vs,"popBlock");function Ls(t,e,n){const o=[...t.nodes],s=new Map;for(const[M,T]of o.entries())s.set(T,M);const r=o.length,a=new Array(r).fill(-1),l=new Array(r).fill(0),d=[],i=new Set;for(const M of o){const T=n.parent.get(M)??null,E=s.get(M);E!=null&&T==null&&(a[E]=-1,l[E]=0,i.has(M)||(i.add(M),d.push(M)))}for(;d.length>0;){const M=d.shift(),T=s.get(M);if(T==null)continue;const E=n.children.get(M)??[];for(const m of E){if(i.has(m))continue;const I=s.get(m);I!=null&&(a[I]=T,l[I]=l[T]+1,i.add(m),d.push(m))}}for(const M of o){if(i.has(M))continue;const T=s.get(M);T!=null&&(a[T]=-1,l[T]=0,i.add(M))}const g=Math.max(1,Math.ceil(Math.log2(Math.max(1,r)))+1),x=Array.from({length:g},()=>new Array(r).fill(-1));for(let M=0;M<r;M++)x[0][M]=a[M];for(let M=1;M<g;M++)for(let T=0;T<r;T++){const E=x[M-1][T];x[M][T]=E===-1?-1:x[M-1][E]}const C=f((M,T)=>{if(M===-1||T===-1)return-1;l[M]<l[T]&&([M,T]=[T,M]);const E=l[M]-l[T];for(let m=0;m<g;m++)if(E>>m&1&&(M=x[m][M],M===-1))return-1;if(M===T)return M;for(let m=g-1;m>=0;m--){const I=x[m][M],R=x[m][T];I===-1||R===-1||I!==R&&(M=I,T=R)}return x[0][M]},"lcaIndex"),h=Array.from({length:r},()=>new Map);for(const M of t.edges){let T=M.src,E=M.dst,m=e[T],I=e[E];if(m==null||I==null||(m>I&&([T,E]=[E,T],[m,I]=[I,m]),m==null||I==null||m===I))continue;const R=s.get(T),O=s.get(E);if(R==null||O==null)continue;const F=C(R,O);if(F===-1)continue;const B=h[F];for(let _=m;_<I;_++)B.set(_,(B.get(_)??0)+1)}const p=new Map,c=f((M,T)=>{if(T.size!==0)for(const[E,m]of T)M.set(E,(M.get(E)??0)+m)},"mergeInto"),y=new Set,v=f(M=>{const T=s.get(M);y.add(M);const E=T==null?void 0:h[T],m=E?new Map(E):new Map,I=n.children.get(M)??[];for(const R of I){const O=v(R),F=e[M];if(F!=null){let B=p.get(M);B||(B=new Map,p.set(M,B));let _=O.get(F)??0;const X=e[R];X!=null&&X>F&&(_+=1),B.set(R,_)}c(m,O)}return m},"dfs");for(const M of n.roots)y.has(M)||v(M);for(const M of o)y.has(M)||v(M);return p}A(Ls,"computeSubtreeCrossCounts");f(Ls,"computeSubtreeCrossCounts");function Ts(t,e,n){const o=new Map,s=f(r=>{let a=n[r]??0;const l=[...e.get(r)??[]];l.sort(co(n));for(const d of l){s(d);const i=o.get(d);i!=null&&(a=Math.min(a,i))}o.set(r,a)},"annotate");for(const r of t)s(r);return o}A(Ts,"annotateMinimumLayers");f(Ts,"annotateMinimumLayers");function co(t){return(e,n)=>{const o=t[e]??0,s=t[n]??0;return o===s?e.localeCompare(n):o-s}}A(co,"compareByRankThenId");f(co,"compareByRankThenId");function Es(t,e,n,o){let s=0;for(const d of e){const i=n[d]??0;i>s&&(s=i)}const r=Array.from({length:s+1},()=>[]),a=new Set,l=f(d=>{if(a.has(d))return;a.add(d);const i=n[d]??0;r[i]||(r[i]=[]),r[i].push(d);for(const g of o(d))l(g)},"emit");for(const d of t)l(d);for(const d of e)if(!a.has(d)){const i=n[d]??0;r[i]||(r[i]=[]),r[i].push(d),a.add(d)}return r}A(Es,"emitNodesInTreeOrder");f(Es,"emitNodesInTreeOrder");function ws(t){const e=[];for(const n of t){const o=new Set,s=[];for(const r of n)o.has(r)||(o.add(r),s.push(r));e.push(s)}return e}A(ws,"deduplicateLayers");f(ws,"deduplicateLayers");function Rs(t,e,n,o){return s=>{const r=t.get(s)??[];if(r.length===0)return[];const a=e[s]??0,l=[],d=[],i=n.get(s);for(const g of r){const x=o.get(g)??a;x>a?l.push({child:g,min:x}):d.push(g)}return l.sort((g,x)=>g.min===x.min?g.child.localeCompare(x.child):g.min-x.min),d.sort((g,x)=>{const C=i?.get(g)??0,h=i?.get(x)??0;if(C!==h)return C-h;const p=o.get(g)??a,c=o.get(x)??a;return p!==c?p-c:g.localeCompare(x)}),[...l.map(g=>g.child),...d]}}A(Rs,"createChildOrderer");f(Rs,"createChildOrderer");function Ve(t,e,n){const o=bs(t,{rankHint:e,laneOf:n}),{children:s,roots:r}=o;for(const x of t.nodes)s.has(x)||s.set(x,[]);const a=Ls(t,e,o),l=[...r].sort(co(e)),d=Ts(l,s,e),i=Rs(s,e,a,d);let g=Es(l,t.nodes,e,i);return g=ws(g),g}A(Ve,"buildMultitreeLayerOrder");f(Ve,"buildMultitreeLayerOrder");function As(t,e,n){const o=new Set(t),s=new Set(e),r=Te(e),a=[];for(const l of n)o.has(l.src)&&s.has(l.dst)&&a.push(r.get(l.dst));return ro(a)}A(As,"countCrossingsBetweenAdjacent");f(As,"countCrossingsBetweenAdjacent");function Nn(t,e,n){const o=[];for(const r of e){const a=n[r.src],l=n[r.dst];if(a==null||l==null||a===l)continue;let d=r.src,i=r.dst,g=a,x=l;a>l&&(d=r.dst,i=r.src,g=l,x=a);for(let C=g;C<x;C++)o.push({id:`${r.id}@${C}`,src:d,dst:i,ref:r.ref})}let s=0;for(let r=0;r+1<t.length;r++)s+=As(t[r],t[r+1],o);return s}A(Nn,"totalCrossings");f(Nn,"totalCrossings");function Os(t,e){const n={...e},{preds:o}=We(t),s=fe(t),r=Ve(t,n,s);let a=Nn(r,t.edges,n);const l=On.MAX_CROSSING_OPTIMIZATION_PASSES;for(let d=0;d<l;d++){let i=!1;const g=[...t.nodes].sort((x,C)=>(n[C]??0)-(n[x]??0));for(const x of g){const C=n[x]??0;if(C===0)continue;let h=0;for(const v of o.get(x)??[])h=Math.max(h,(n[v]??0)+1);if(h>=C)continue;const p=C;n[x]=h;const c=Ve(t,n,s),y=Nn(c,t.edges,n);y<a?(a=y,i=!0):n[x]=p}if(!i)break}return n}A(Os,"optimizeRanksByCrossings");f(Os,"optimizeRanksByCrossings");function Ns(t,e){const n=fe(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 a=t.edges.filter(c=>c.src===s);if(a.length===0)continue;let l=!1,d=0;for(const c of a){const y=n(c.dst);y==null||y===r?l=!0:d++}if(d===0||l)continue;let i=0,g=!1;for(const c of t.edges){if(c.dst!==s)continue;const y=n(c.src);y&&(y===r?g=!0:i++)}if(i>0||!g)continue;const x=e[s]??0,C=x+d;let h=0;for(const c of t.edges)c.dst===s&&(h=Math.max(h,(e[c.src]??0)+1));const p=Math.max(x,h,C);p!==x&&(e[s]=p)}}A(Ns,"adjustCrossLaneSources");f(Ns,"adjustCrossLaneSources");function Bs(t,e){const n=he(t),o=Pe(n)??[...n.nodes].sort(),s=e?.compactSingleInput??!1,r=fe(n);let a=Object.create(null);for(const d of o){const i=to(n,d),g=e?.ignoreCrossLaneEdges?i.filter(x=>{const C=r(x.src),h=r(d);return!C||!h?!0:C===h}):i;if(g.length===0)a[d]=0;else if(s&&g.length===1){const x=g[0].src,C=r(x),h=r(d);C!==h?a[d]=a[x]??0:a[d]=(a[x]??0)+1}else{let x=-1/0;for(const C of g)x=Math.max(x,(a[C.src]??0)+1);a[d]=x===-1/0?0:x}}return(e?.optimizeRanksByCrossings??!1)&&(a=Os(n,a)),e?.ignoreCrossLaneEdges&&Ns(n,a),{layers:Ve(n,a,r),rankOf:a,dummy:new Set}}A(Bs,"assignLayers_LongestPath");f(Bs,"assignLayers_LongestPath");function Ps(t,e){const n=he(t),s={...Bs(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=fe(n),{preds:a,succs:l}=We(n,p=>{if(e?.ignoreCrossLaneEdges){const c=r(p.src),y=r(p.dst);if(c&&y&&c!==y)return!1}return!0}),d=Pe(n)??[...n.nodes],i=[...d].reverse(),g=f((p,c)=>{let y=0;for(const T of a.get(p)??[])y=Math.max(y,(s[T]??0)+1);let v=Number.POSITIVE_INFINITY;const M=l.get(p)??[];return M.length>0&&(v=Math.min(...M.map(T=>(s[T]??0)-1))),Number.isFinite(v)||(v=Math.max(y,c)),Math.min(Math.max(c,y),v)},"clampFeasible"),x=On.GRAVITY_ITERATIONS,C=f(p=>{let c=!1;for(const y of p){const v=a.get(y)??[],M=l.get(y)??[];if(v.length===0&&M.length===0)continue;const T=v.length>0?v.reduce((R,O)=>R+(s[O]??0)+1,0)/v.length:s[y]??0,E=M.length>0?M.reduce((R,O)=>R+(s[O]??0)-1,0)/M.length:s[y]??0,m=Math.round((T+E)/2),I=g(y,m);I!==s[y]&&(s[y]=I,c=!0)}return c},"relaxOrder");for(let p=0;p<x;p++){const c=C(d),y=C(i);if(!c&&!y)break}for(const p of d){let c=0;for(const y of a.get(p)??[])c=Math.max(c,(s[y]??0)+1);(s[p]??0)<c&&(s[p]=c)}for(const p of i){const c=l.get(p)??[];if(c.length>0){const y=Math.min(...c.map(v=>(s[v]??0)-1));(s[p]??0)>y&&(s[p]=y)}}return{layers:so(n,d,s),rankOf:s,dummy:new Set}}A(Ps,"assignLayers_Gravity");f(Ps,"assignLayers_Gravity");function ks(t){const e=no(t),n=eo(t);let o=oo(e);const s=[];for(;o.length>0;){const r=[];for(const a of o){s.push(a);for(const l of n.get(a)??[])e.set(l,(e.get(l)??0)-1),(e.get(l)??0)===0&&r.push(l)}o=r.sort((a,l)=>a.localeCompare(l))}return s.length===t.nodes.length?s:null}A(ks,"topoSortByGenerationIfAcyclic");f(ks,"topoSortByGenerationIfAcyclic");function Fs(t,e){const n=he(t),o=e?.direction==="LR"?ks(n)??[...n.nodes].sort():Pe(n)??[...n.nodes].sort(),s=fe(n),r=f(g=>s(g)??g,"laneOf"),a=Object.create(null),l=new Map,d=f((g,x)=>e?.ignoreCrossLaneEdges??!0?r(g)===r(x)?1:0:1,"edgeWeight");for(const g of o){if(n.nodeById.get(g)?.isGroup)continue;const C=to(n,g);let h=0;if(C.length>0)for(const v of C){const M=v.src,T=a[M]??0;h=Math.max(h,T+d(M,g))}const p=r(g),c=l.get(p)??0,y=Math.max(h,c);a[g]=y,l.set(p,y+1)}return{layers:so(n,o,a,{skipGroups:!0}),rankOf:a,dummy:new Set}}A(Fs,"assignLayers_LaneAwareCompact");f(Fs,"assignLayers_LaneAwareCompact");function _s(t,e){const n=he(e),{rankOf:o}=t,s=t.layers.map(h=>[...h]),r=new Set(t.dummy?[...t.dummy]:[]);let a=0;const l=new Map(n.nodeById),d=f(h=>{const p=`placeholder-${a++}`,c={id:p,isGroup:!1,isDummy:!0,width:0,height:0};for(l.set(p,c),r.add(p);s.length<=h;)s.push([]);return s[h].push(p),o[p]=h,p},"addDummyAt"),i=[...n.edges].sort((h,p)=>h.id===p.id?h.src===p.src?h.dst.localeCompare(p.dst):h.src.localeCompare(p.src):h.id.localeCompare(p.id)),g=[];for(const h of i){const p=o[h.src]??0,c=o[h.dst]??0;if(c-p<=1){g.push(h);continue}let y=h.src;for(let M=p+1,T=0;M<c;M++,T++){const E=d(M);g.push({id:`${h.id}#${T}`,src:y,dst:E,weight:h.weight,ref:h.ref}),y=E}const v=c-p-2;g.push({id:`${h.id}#${Math.max(v+1,0)}`,src:y,dst:h.dst,weight:h.weight,ref:h.ref})}const C={nodes:[...n.nodes,...[...r].filter(h=>!n.nodes.includes(h))],edges:g,layout:n.layout,nodeById:l};return{layering:{layers:s,rankOf:o,dummy:r},graphWithDummies:C}}A(_s,"makeProperLayering");f(_s,"makeProperLayering");function Bn(t){const e=t.length;if(e===0)return Number.POSITIVE_INFINITY;const n=[...t].sort((o,s)=>o-s);return e%2===1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}A(Bn,"median");f(Bn,"median");function Pn(t){return t.length===0?Number.POSITIVE_INFINITY:t.reduce((n,o)=>n+o,0)/t.length}A(Pn,"barycenter");f(Pn,"barycenter");function Ds(t,e,n,o){const s=new Map;for(const r of t)s.set(r,[]);for(const r of n)o==="down"?e.has(r.src)&&s.has(r.dst)&&s.get(r.dst).push(e.get(r.src)):e.has(r.dst)&&s.has(r.src)&&s.get(r.src).push(e.get(r.dst));return s}A(Ds,"neighborPositionsFor");f(Ds,"neighborPositionsFor");function Hs(t,e,n){const o=n.get(t)??0,s=n.get(e)??0;return o!==s?o-s:t.localeCompare(e)}A(Hs,"currentOrderTieBreak");f(Hs,"currentOrderTieBreak");function kn(t,e,n){const o=new Set(t),s=new Set(e),r=Te(t),a=Te(e),l=[];for(const i of n)o.has(i.src)&&s.has(i.dst)&&l.push({u:r.get(i.src),v:a.get(i.dst)});l.sort((i,g)=>i.u===g.u?i.v-g.v:i.u-g.u);const d=l.map(i=>i.v);return ro(d)}A(kn,"countCrossingsBetweenAdjacent2");f(kn,"countCrossingsBetweenAdjacent");function Fe(t,e,n){return[...t].sort((o,s)=>{const r=Bn(e.get(o)??[]),a=Bn(e.get(s)??[]);return r===a?Hs(o,s,n):isFinite(r)?isFinite(a)?r-a:-1:1})}A(Fe,"sortByHeuristic");f(Fe,"sortByHeuristic");function Fn(t,e,n,o,s,r){const a=Te(t),l=Te(e),d=Ds(e,a,n,o);if(!s||!r||r.length===0)return Fe(e,d,l);const i=new Map;for(const C of e){const h=s(C),p=i.get(h)??[];p.push(C),i.set(h,p)}const g=[];for(const C of r){const h=i.get(C);if(!h||h.length===0)continue;const p=Fe(h,d,l);g.push(...p)}const x=i.get(null);if(x&&x.length>0){const C=Fe(x,d,l);for(const h of C){const p=Pn(d.get(h)??[]);let c=g.length;if(isFinite(p))for(const[y,v]of g.entries()){const M=Pn(d.get(v)??[]);if(p<M){c=y;break}}g.splice(c,0,h)}}return g}A(Fn,"reorderLayer");f(Fn,"reorderLayer");function _n(t,e,n,o,s){const r=[...e],a=new Set(t),l=new Set(e),d=o?new Set(o):null,i=n.filter(c=>a.has(c.src)&&l.has(c.dst)),g=d?n.filter(c=>l.has(c.src)&&d.has(c.dst)):void 0,x=f(c=>{let y=kn(t,c,i);return g&&o&&(y+=kn(c,o,g)),y},"crossingScore"),C=s?new Map:null;if(s&&C)for(const c of e)C.set(c,s(c));let h=!0,p=x(r);for(;h;){h=!1;for(let c=0;c+1<r.length;c++){if(C){const M=C.get(r[c]),T=C.get(r[c+1]);if(M!==T)continue}const y=p;[r[c],r[c+1]]=[r[c+1],r[c]];const v=x(r);v<y?(p=v,h=!0):[r[c],r[c+1]]=[r[c+1],r[c]]}}return r}A(_n,"transposeImprove");f(_n,"transposeImprove");function Xs(t,e,n){const o=t.layers.map(l=>[...l]),s=e.edges,r=fe(e),a=io(e,n?.laneOrder);for(let l=0;l<3;l++){for(let d=1;d<o.length;d++)o[d]=Fn(o[d-1],o[d],s,"down",r,a),o[d]=_n(o[d-1],o[d],s,o[d+1],r);for(let d=o.length-2;d>=0;d--)o[d]=Fn(o[d+1],o[d],s,"up",r,a),o[d]=_n(o[d+1],o[d],s,o[d-1],r)}return{layers:o}}A(Xs,"orderLayers");f(Xs,"orderLayers");function Ys(t,e,n){const o=n?.layerGap??ur.DEFAULT_LAYER_GAP,s=n?.nodeGap??ur.DEFAULT_NODE_GAP,r=n?.laneGap??s*2,a=n?.direction??"TB",l=a==="LR"||a==="RL",d=t.layers,i=Object.create(null),g=Object.create(null),x=f(B=>e.nodeById.get(B),"getNode"),C=f(B=>x(B)?.width??0,"getWidth"),h=f(B=>x(B)?.height??0,"getHeight"),p=fe(e),c=io(e,n?.laneOrder),y=d.map(B=>B.reduce((_,X)=>Math.max(_,h(X)),0)),v=[];if(l)for(let B=0;B+1<d.length;B++){const _=d[B].reduce((yt,Ft)=>Math.max(yt,C(Ft)),0),X=d[B+1].reduce((yt,Ft)=>Math.max(yt,C(Ft)),0),P=y[B],z=y[B+1],U=P/2+z/2,Z=(_+X)/2,ht=Math.max(0,Z-U-o);v.push(ht)}const M=new Set;for(const B of d)for(const _ of B)M.add(p(_));const T=M.has(null),E=c.filter(B=>M.has(B)),m=[...T?[null]:[],...E],I=Object.create(null);for(const B of E)I[B]=0;T&&(I.null=0);for(const B of d){const _=Object.create(null),X=[];for(const P of B){const z=p(P);z===null?X.push(P):(_[z]||=[]).push(P)}for(const[P,z]of Object.entries(_)){const U=z.reduce((Z,ht)=>Z+C(ht),0)+s*Math.max(0,z.length-1);I[P]=Math.max(I[P]??0,U)}if(T&&X.length){const P=X.reduce((z,U)=>z+C(U),0)+s*Math.max(0,X.length-1);I.null=Math.max(I.null??0,P)}}const R=new Map;{const B=m.map(P=>(P===null?I.null:I[P])??0);let X=-(B.reduce((P,z)=>P+z,0)+r*Math.max(0,m.length-1))/2;for(let P=0;P<m.length;P++){const z=m[P],U=B[P]??0,Z=X+U/2;R.set(z,Z),X+=U,P<m.length-1&&(X+=r)}}let O=0;for(const[B,_]of d.entries()){const X=y[B]??0,P=new Map;for(const U of _){const Z=p(U),ht=P.get(Z)??[];ht.push(U),P.set(Z,ht)}for(const U of m){const Z=P.get(U)??[];if(Z.length===0)continue;const ht=R.get(U);if(Z.length===1){const yt=Z[0];i[yt]=ht,g[yt]=O+X/2}else{const yt=Z.map(tt=>C(tt)),Ft=yt.reduce((tt,K)=>tt+K,0)+s*(Z.length-1);let Pt=ht-Ft/2;for(const[tt,K]of Z.entries()){const nt=yt[tt];i[K]=Pt+nt/2,g[K]=O+X/2,Pt+=nt+s}}}const z=v[B]??0;O+=X+o+z}const F=new Map;for(const B of e.edges){const _=B.ref.id;F.has(_)||F.set(_,[]),F.get(_).push(B)}for(const[,B]of F){if(B.length===0)continue;const _=B[0].ref,X=_.start,P=_.end;if(X==null||P==null)continue;const z=Math.round(((i[X]??0)+(i[P]??0))/2),U=new Set;for(const Z of B)U.add(Z.src),U.add(Z.dst);for(const Z of U){if(Z===X||Z===P)continue;e.nodeById.get(Z)?.isDummy&&(i[Z]=z)}}return{x:i,y:g}}A(Ys,"assignCoordinates");f(Ys,"assignCoordinates");var hr=8;function Gs(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}A(Gs,"hashString");f(Gs,"hashString");function zs(t){let e=t>>>0;return()=>{e+=1831565813;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}A(zs,"mulberry32");f(zs,"mulberry32");function $s(t,e){const n=[...t],o=zs(e);for(let s=n.length-1;s>0;s--){const r=Math.floor(o()*(s+1));[n[s],n[r]]=[n[r],n[s]]}return n}A($s,"deterministicShuffle");f($s,"deterministicShuffle");function Vs(t,e){let n=0;for(const[o,s]of t.entries())n+=Math.abs(o-(e.get(s)??o));return n}A(Vs,"sourceDistance");f(Vs,"sourceDistance");function Dn(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:a}of e){const l=n.get(s),d=n.get(r);l==null||d==null||(o+=a*Math.abs(l-d))}return o}A(Dn,"laneArrangementCost");f(Dn,"laneArrangementCost");function js(t){const e=Ke(t);if(e.length<2)return[];const n=new Map(e.map((r,a)=>[r,a])),o=fe(t),s=new Map;for(const r of t.layout.edges??[]){if(r.isLayoutOnly)continue;const a=typeof r.start=="string"?r.start:void 0,l=typeof r.end=="string"?r.end:void 0;if(!a||!l||!t.nodeById.has(a)||!t.nodeById.has(l))continue;const d=o(a),i=o(l);if(!d||!i||d===i)continue;const g=n.get(d),x=n.get(i);if(g==null||x==null)continue;const[C,h]=g<=x?[d,i]:[i,d],p=`${C}\0${h}`,c=s.get(p);c?c.weight++:s.set(p,{a:C,b:h,weight:1})}return[...s.values()]}A(js,"buildWeightedLaneEdges");f(js,"buildWeightedLaneEdges");function Hn(t,e,n){const o=[...t];let s=Dn(o,e),r=!0,a=0;const l=Math.max(1,o.length);for(;r&&a<l;){r=!1,a++;for(let d=0;d+1<o.length;d++){[o[d],o[d+1]]=[o[d+1],o[d]];const i=Dn(o,e);i<s?(s=i,r=!0):[o[d],o[d+1]]=[o[d+1],o[d]]}}return{order:o,cost:s,sourceDistance:Vs(o,n)}}A(Hn,"greedySwitch");f(Hn,"greedySwitch");function Us(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}A(Us,"isBetterCandidate");f(Us,"isBetterCandidate");function Ws(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:a})=>`${s}:${r}:${a}`).join("|");return Gs(`${t.join("|")}#${o}#${n}`)}A(Ws,"seedForRestart");f(Ws,"seedForRestart");function Ks(t,e={}){const n=Ke(t);if(n.length<2)return n;const o=js(t);if(o.length===0)return n;const s=new Map(n.map((l,d)=>[l,d]));let r=Hn(n,o,s);const a=Math.max(0,e.restarts??hr);for(let l=0;l<a;l++){const d=Ws(n,o,l),i=$s(n,d),g=Hn(i,o,s);Us(g,r)&&(r=g)}return r.order}A(Ks,"optimizeTopLaneOrder");f(Ks,"optimizeTopLaneOrder");function Js(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,s=he(t),r=e?.automaticLaneOrdering?Ks(s,{restarts:hr}):void 0,a=ys(s),l=a.acyclic,d=n?Fs(l,{compactSingleInput:e?.compactSingleInput??On.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!0,direction:e?.direction}):Ps(l,{compactSingleInput:e?.compactSingleInput??On.DEFAULT_COMPACT_SINGLE_INPUT,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:i,graphWithDummies:g}=_s(d,l),x=Xs(i,g,{laneOrder:r}),C=Ys(x,g,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:r});return{acyclic:l,reversed:a.reversed,layering:i,ordered:x,coordinates:C}}A(Js,"sugiyamaLayout");f(Js,"sugiyamaLayout");var at=Pr.EPSILON,kr=8,Se=15,Ne=15,cn=25,se=20,Io=10;function Xn(t,e,n){const o=t.x??0,s=t.y??0,r=e.x-o,a=e.y-s,l=Math.abs(r),d=Math.abs(a);return l<at&&d<at?n:d>at&&d*3>=l?a>0?"bottom":"top":l>at?r>0?"right":"left":n}A(Xn,"chooseOrthogonalSide");f(Xn,"chooseOrthogonalSide");function Yn(t,e){return Math.abs(t.to-e.from)<at||Math.abs(t.to-e.to)<at?t.to:t.from}A(Yn,"sharedLineEndpointCoord");f(Yn,"sharedLineEndpointCoord");function be(t,e){return t.orient==="vertical"?{x:t.coord,y:e}:{x:e,y:t.coord}}A(be,"pointOnLine");f(be,"pointOnLine");function qs(t,e){const n=t.nodes??[],o=t.edges??[],s=[];for(const u of o)u.isLayoutOnly||s.push({...u,__originalEdge:u});const r=new Map,a=new Map,l=[],d=e==="LR";for(const u of n)r.set(u.id,u);const i=n.filter(u=>u.isGroup&&!u.parentId);for(const u of i){const b={id:u.id},S=f(L=>{a.set(L.id,b),n.filter(w=>w.parentId===L.id).forEach(S)},"assignLane");S(u)}const g=n.filter(u=>!u.isGroup&&!u.isEdgeLabel).map(u=>{const b=u.width??10,S=u.height??10,L=u.x??0,w=u.y??0,k=kr;return{nodeId:u.id,minX:L-b/2-k,maxX:L+b/2+k,minY:w-S/2-k,maxY:w+S/2+k,visualXHalfExtent:d?S/2+k:b/2+k}}),x=f((u,b,S,L)=>{let w=l.find(k=>k.orientation===u&&Math.abs(k.coord-b)<1);return w||(w={id:`pipe-${u}-${b.toFixed(0)}`,orientation:u,coord:b,spanMin:S,spanMax:L,tracks:[]},l.push(w)),w.spanMin=Math.min(w.spanMin,S),w.spanMax=Math.max(w.spanMax,L),w},"getOrAddPipe"),C=f((u,b)=>{const S=u.width??10,L=u.height??10,w=u.x??0,k=u.y??0;switch(b){case"top":return{x:w,y:k-L/2};case"bottom":return{x:w,y:k+L/2};case"left":return{x:w-S/2,y:k};case"right":return{x:w+S/2,y:k}}},"portForSide"),h=f((u,b,S)=>C(u,Xn(u,b,S?"bottom":"top")),"getOrthogonalPort"),p=[],c=[],y=new Set,v=1e3,M=f((u,b,S)=>{if(p.length===0)return 0;const L=Math.abs(b.y-S.y)<at,w=Math.abs(b.x-S.x)<at;if(!L&&!w)return 0;let k=0;if(L){const W=b.y,q=Math.min(b.x,S.x)-at,V=Math.max(b.x,S.x)+at;if(V<=q)return 0;for(const G of p)G.edgeIndex===u||G.orientation!=="vertical"||G.pipe.coord<q||G.pipe.coord>V||G.from-at<=W&&G.to+at>=W&&(k+=v)}else if(w){const W=b.x,q=Math.min(b.y,S.y)-at,V=Math.max(b.y,S.y)+at;if(V<=q)return 0;for(const G of p)G.edgeIndex===u||G.orientation!=="horizontal"||G.pipe.coord<q||G.pipe.coord>V||G.from-at<=W&&G.to+at>=W&&(k+=v)}return k},"crossingPenalty"),T=s.map((u,b)=>{if(!u.start||!u.end)return{idx:b,crossLane:0,dx:0,dy:0};const S=r.get(u.start),L=r.get(u.end),w=a.get(u.start),k=a.get(u.end),W=w&&k&&w.id!==k.id?1:0,q=S&&L?Math.abs((L.x??0)-(S.x??0)):0,V=S&&L?Math.abs((L.y??0)-(S.y??0)):0;return{idx:b,crossLane:W,dx:q,dy:V}}).sort((u,b)=>{if(u.crossLane!==b.crossLane)return b.crossLane-u.crossLane;const S=u.dx+u.dy,L=b.dx+b.dy;return Math.abs(S-L)>1?S-L:u.idx-b.idx}).map(u=>u.idx),E=f((u,b,S,L)=>{const w=Math.min(u.x,b.x),k=Math.max(u.x,b.x),W=Math.min(u.y,b.y),q=Math.max(u.y,b.y);return!!g.find(G=>S&&G.nodeId===S||L&&G.nodeId===L?!1:Math.abs(u.x-b.x)>at?G.minY<u.y&&G.maxY>u.y&&G.maxX>w&&G.minX<k:G.minX<u.x&&G.maxX>u.x&&G.maxY>W&&G.minY<q)},"isSegmentBlocked"),m=new Map,I=new Map;for(const u of s)!u.start||!u.end||u.start===u.end||(I.set(u.start,(I.get(u.start)??0)+1),I.set(u.end,(I.get(u.end)??0)+1));const R=f((u,b)=>Xn(u,b,"bottom"),"determineSide"),O=new Map;for(const[u,b]of s.entries()){if(!b.start||!b.end||b.start===b.end||b.points&&b.points.length>0)continue;const S=r.get(b.start),L=r.get(b.end);if(!S||!L)continue;const w=(L.x??0)-(S.x??0),k=(L.y??0)-(S.y??0);O.set(u,{edgeIdx:u,srcId:b.start,dstId:b.end,srcSide:R(S,{x:L.x??0,y:L.y??0}),dstSide:R(L,{x:S.x??0,y:S.y??0}),absDx:Math.abs(w),absDy:Math.abs(k),dxSign:Math.sign(w),dySign:Math.sign(k)})}const F=f(u=>u.srcSide==="top"||u.srcSide==="bottom"?u.absDx===0?1/0:u.absDy/u.absDx:u.absDy===0?1/0:u.absDx/u.absDy,"preferenceStrength"),B=f(u=>u.srcSide==="top"||u.srcSide==="bottom"?u.dxSign>=0?"right":"left":u.dySign>=0?"bottom":"top","secondarySide"),_=new Map;for(const u of O.values()){const b=`${u.srcId}:${u.srcSide}`;_.has(b)||_.set(b,[]),_.get(b).push(u)}const X=new Map,P=f((u,b)=>`${u}:${b}`,"loadKey");for(const u of O.values())X.set(P(u.srcId,u.srcSide),(X.get(P(u.srcId,u.srcSide))??0)+1),X.set(P(u.dstId,u.dstSide),(X.get(P(u.dstId,u.dstSide))??0)+1);for(const u of _.values())if(!(u.length<2)){u.sort((b,S)=>{const L=F(b),w=F(S);return Math.abs(L-w)>1e-9?w-L:b.edgeIdx-S.edgeIdx});for(let b=1;b<u.length;b++){const S=u[b],L=B(S),w=X.get(P(S.srcId,S.srcSide))??0,k=X.get(P(S.srcId,L))??0;k>=w||(X.set(P(S.srcId,S.srcSide),w-1),X.set(P(S.srcId,L),k+1),S.srcSide=L)}}const z=f(u=>{const b=u?.shape;return b==="question"||b==="diamond"},"isDiamondNode"),U=new Map;for(const u of O.values())U.has(u.dstId)||U.set(u.dstId,new Set),U.get(u.dstId).add(u.dstSide);for(const u of O.values()){if(!z(r.get(u.srcId)))continue;const b=U.get(u.srcId);if(!b?.has(u.srcSide))continue;const S=B(u);if(b.has(S)||(X.get(P(u.srcId,S))??0)>0)continue;const L=X.get(P(u.srcId,u.srcSide))??0;X.set(P(u.srcId,u.srcSide),Math.max(0,L-1)),X.set(P(u.srcId,S),1),u.srcSide=S}for(const u of O.values()){const{edgeIdx:b,srcId:S,dstId:L,srcSide:w,dstSide:k}=u,W=r.get(S),q=r.get(L),V=`${S}:${w}:src`,G=w==="top"||w==="bottom"?q.x??0:q.y??0;m.has(V)||m.set(V,[]),m.get(V).push({edgeIdx:b,oppositeCoord:G});const st=`${L}:${k}:dst`,it=k==="top"||k==="bottom"?W.x??0:W.y??0;m.has(st)||m.set(st,[]),m.get(st).push({edgeIdx:b,oppositeCoord:it})}const Z=new Map,ht=8;for(const[u,b]of m){if(b.length<2)continue;b.sort((wt,Ht)=>wt.oppositeCoord-Ht.oppositeCoord);const S=u.split(":"),L=S.slice(0,-2).join(":"),w=S[S.length-2],k=S[S.length-1],W=r.get(L);if(!W)continue;const V=w==="left"||w==="right"?W.height??10:W.width??10,G=W.shape,it=G==="question"||G==="diamond"?V*.3:V,et=Math.min(20,Math.max(ht,it/(b.length+1))),Ot=-(et*(b.length-1))/2;for(const[wt,Ht]of b.entries()){const Qt=Ot+wt*et,uo=`${Ht.edgeIdx}:${k}`;Z.set(uo,Qt)}}const yt=f(u=>!!s[u]?.labelNodeId,"edgeHasLabelNode"),Ft=f((u,b)=>u?(m.get(`${u}:${b}:src`)??[]).some(({edgeIdx:S})=>yt(S))||(m.get(`${u}:${b}:dst`)??[]).some(({edgeIdx:S})=>yt(S)):!1,"faceHasLabelNode"),Pt=f((u,b,S)=>b==="top"||b==="bottom"?{x:u.x+S,y:u.y}:{x:u.x,y:u.y+S},"applyPortOffset"),tt=f((u,b,S)=>{const L=O.get(u),w={x:S.x??0,y:S.y??0},k={x:b.x??0,y:b.y??0},W=L?.srcSide??R(b,w),q=L?.dstSide??R(S,k);let V=L?C(b,L.srcSide):h(b,w,!0),G=L?C(S,L.dstSide):h(S,k,!1);const st=Z.get(`${u}:src`),it=Z.get(`${u}:dst`);return st!==void 0&&(V=Pt(V,W,st)),it!==void 0&&(G=Pt(G,q,it)),{pSrcPort:V,pDstPort:G,srcSide:W,dstSide:q}},"portsForEdge");for(const u of T){const b=s[u];if(c[u]=[],!b.start||!b.end||b.points&&b.points.length>0||b.start===b.end)continue;const S=r.get(b.start),L=r.get(b.end);if(!S||!L)continue;const{pSrcPort:w,pDstPort:k,srcSide:W,dstSide:q}=tt(u,S,L),V={...w},G={...k},st=W==="top"||W==="bottom",it=q==="top"||q==="bottom";if(st){const Y=w.y>(S.y??0);V.y=Y?w.y+se:w.y-se}else{const Y=w.x>(S.x??0);V.x=Y?w.x+se:w.x-se}if(it){const Y=k.y>(L.y??0);G.y=Y?k.y+se:k.y-se}else{const Y=k.x>(L.x??0);G.x=Y?k.x+se:k.x-se}const rt=f((Y,$)=>{for(const J of g)if(!$.includes(J.nodeId)&&Y.x>J.minX&&Y.x<J.maxX&&Y.y>J.minY&&Y.y<J.maxY)return{inside:!0,obstacle:J};return{inside:!1}},"isPointInObstacle"),et=f((Y,$,J,ft,vt)=>{if(vt){const Nt=Y.y>($.y??0);return{x:(J.x??0)>=Y.x?ft.maxX+Se:ft.minX-Se,y:Nt?ft.maxY+Ne:ft.minY-Ne,leavesPositiveSide:Nt}}const Mt=Y.x>($.x??0),Rt=(J.y??0)>=Y.y;return{x:Mt?ft.maxX+Se:ft.minX-Se,y:Rt?ft.maxY+Ne:ft.minY-Ne,leavesPositiveSide:Mt}},"obstacleDetour");let xt=[];const Ot=[b.start,b.end],wt=rt(V,Ot);if(wt.inside&&wt.obstacle){const Y=wt.obstacle;if(st){const $=et(w,S,L,Y,!0);V.x=$.x,V.y=$.y;const J=$.leavesPositiveSide?Math.min(Y.minY-2,w.y+se):Math.max(Y.maxY+2,w.y-se);xt=[{x:w.x,y:J},{x:$.x,y:J},{x:$.x,y:$.y}]}else{const $=et(w,S,L,Y,!1),J=$.leavesPositiveSide?Math.min(Y.minX-2,w.x+se):Math.max(Y.maxX+2,w.x-se);V.x=$.x,V.y=$.y,xt=[{x:J,y:w.y},{x:J,y:$.y},{x:$.x,y:$.y}]}}let Ht=[];const Qt=rt(G,Ot);if(Qt.inside&&Qt.obstacle){const Y=Qt.obstacle;if(it){const $=et(k,L,S,Y,!0);G.x=$.x,G.y=$.y,Ht=[{x:$.x,y:$.y},{x:k.x,y:$.y}]}else{const $=et(k,L,S,Y,!1);G.x=$.x,G.y=$.y,Ht=[{x:$.x,y:$.y},{x:$.x,y:k.y}]}}if(xt.length===0&&Ht.length===0){const Y=Se,$=Math.abs(V.x-G.x)<Y,J=Math.abs(V.y-G.y)<Y,ft=Z.get(`${u}:src`)!==void 0||Z.get(`${u}:dst`)!==void 0,vt=(m.get(`${b.start??""}:${W}:src`)?.length??0)+(m.get(`${b.start??""}:${W}:dst`)?.length??0),Mt=(m.get(`${b.end??""}:${q}:src`)?.length??0)+(m.get(`${b.end??""}:${q}:dst`)?.length??0),Rt=vt>1||Mt>1,Nt=I.get(b.start??"")??0,gt=I.get(b.end??"")??0,Gt=vt>1&&Ft(b.start,W)||Mt>1&&Ft(b.end,q),oe=vt<=1||Nt<=2,kt=Mt<=1||gt<=2;if(($||J)&&!ft&&(!Rt||Rt&&!Gt&&oe&&kt)&&!E(w,k,b.start,b.end)){b.points=[{...w},{...V},{...G},{...k}],y.add(u);const It=J?"horizontal":"vertical",Vt=J?w.y:w.x,St=J?Math.min(w.x,k.x):Math.min(w.y,k.y),Ct=J?Math.max(w.x,k.x):Math.max(w.y,k.y),Jt={id:`fast-path-${It}-${Vt.toFixed(0)}-${u}`,orientation:It,coord:Vt,spanMin:St,spanMax:Ct,tracks:[]};p.push({edgeIndex:u,segmentIndex:0,orientation:It,pipe:Jt,trackIndex:0,from:St,to:Ct});continue}}const uo=x("vertical",V.x,V.y,V.y);V.x=uo.coord;const gr=x("vertical",G.x,G.y,G.y);G.x=gr.coord;let pe=Math.min(V.x,G.x)-50,me=Math.max(V.x,G.x)+50,Re=Math.min(V.y,G.y)-50,Ae=Math.max(V.y,G.y)+50;for(const Y of g){const $=Math.min(V.x,G.x),J=Math.max(V.x,G.x),ft=Math.min(V.y,G.y),vt=Math.max(V.y,G.y);Y.minX<J&&Y.maxX>$&&Y.minY<vt&&Y.maxY>ft&&(pe=Math.min(pe,Y.minX-cn),me=Math.max(me,Y.maxX+cn),Re=Math.min(Re,Y.minY-cn),Ae=Math.max(Ae,Y.maxY+cn))}for(const Y of g){if(Y.maxX<pe||Y.minX>me||Y.maxY<Re||Y.minY>Ae)continue;const $=Se;x("horizontal",Y.minY-$,pe,me),x("horizontal",Y.maxY+$,pe,me);const J=Ne;x("vertical",Y.minX-J,Re,Ae),x("vertical",Y.maxX+J,Re,Ae)}x("horizontal",V.y,pe,me),x("horizontal",G.y,pe,me);const pr=l.filter(Y=>Y.orientation==="horizontal"&&Y.coord>=Re&&Y.coord<=Ae),mr=l.filter(Y=>Y.orientation==="vertical"&&Y.coord>=pe&&Y.coord<=me),Je=f((Y,$)=>`${Y.toFixed(1)},${$.toFixed(1)}`,"getKey"),qe=Je(V.x,V.y),er=Je(G.x,G.y),Ze=new Map,ho=new Map,go=new Map,Qe=new Set,Ie=[];Ze.set(qe,0),go.set(qe,"n"),Ie.push({key:qe,f:Math.hypot(G.x-V.x,G.y-V.y),pt:V}),Qe.add(qe);let Xt=[];const ye=f((Y,$)=>E(Y,$,b.start,b.end),"checkSegmentBlocked"),po={x:G.x,y:V.y},yr=ye(V,po),xr=ye(po,G),br=yr||xr,mo={x:V.x,y:G.y},Mr=ye(V,mo),Ir=ye(mo,G);if(br?Mr||Ir||(Math.abs(V.x-G.x)<at?Xt=[V,G]:Xt=[V,mo,G]):Math.abs(V.y-G.y)<at||Math.abs(V.x-G.x)<at?Xt=[V,G]:Xt=[V,po,G],Xt.length===0)for(;Ie.length>0;){Ie.sort((gt,Gt)=>gt.f-Gt.f);const Y=Ie.shift();if(Qe.delete(Y.key),Y.key===er){let gt=er,Gt=G;for(Xt=[Gt];ho.has(gt);){const oe=ho.get(gt);Xt.unshift(oe),Gt=oe,gt=Je(oe.x,oe.y)}break}const $=Y.pt.x,J=Y.pt.y,ft=mr.sort((gt,Gt)=>gt.coord-Gt.coord),vt=ft.findIndex(gt=>Math.abs(gt.coord-$)<1),Mt=pr.sort((gt,Gt)=>gt.coord-Gt.coord),Rt=Mt.findIndex(gt=>Math.abs(gt.coord-J)<1),Nt=[];vt>0&&Nt.push({x:ft[vt-1].coord,y:J}),vt>=0&&vt<ft.length-1&&Nt.push({x:ft[vt+1].coord,y:J}),Rt>0&&Nt.push({x:$,y:Mt[Rt-1].coord}),Rt>=0&&Rt<Mt.length-1&&Nt.push({x:$,y:Mt[Rt+1].coord});for(const gt of Nt){const Gt=Math.min($,gt.x),oe=Math.max($,gt.x),kt=Math.min(J,gt.y),$t=Math.max(J,gt.y);if(g.some(te=>te.nodeId===b.start||te.nodeId===b.end?!1:Gt!==oe?te.minY<J&&te.maxY>J&&te.maxX>Gt&&te.minX<oe:te.minX<$&&te.maxX>$&&te.maxY>kt&&te.minY<$t))continue;const It=Je(gt.x,gt.y),Vt=Math.abs(gt.x-$)+Math.abs(gt.y-J),St=M(u,Y.pt,gt);let Ct=0;const Jt=G.x-V.x,Oe=G.y-V.y,tn=gt.x-$,yo=gt.y-J;(Oe>10&&yo<-5||Oe<-10&&yo>5)&&(Ct=Math.abs(yo)*100),(Jt>10&&tn<-5||Jt<-10&&tn>5)&&(Ct+=Math.abs(tn)*50);let nr=0;const or=go.get(Y.key)??"n",sr=Math.abs(tn)>at?"h":"v";or!=="n"&&or!==sr&&(nr=50);const Sr=Vt+St+Ct+nr,en=(Ze.get(Y.key)??1/0)+Sr,rr=Math.abs(G.x-gt.x)+Math.abs(G.y-gt.y);if(en<(Ze.get(It)??1/0))if(ho.set(It,Y.pt),Ze.set(It,en),go.set(It,sr),!Qe.has(It))Ie.push({key:It,f:en+rr,pt:gt}),Qe.add(It);else{const te=Ie.findIndex(Cr=>Cr.key===It);te!==-1&&(Ie[te].f=en+rr)}}}if(Xt.length===0&&(Xt=[V,{x:V.x,y:G.y},G]),Xt.length>4){const Y=Xt[0],$=Xt[Xt.length-1];let J=Math.min(Y.x,$.x),ft=Math.max(Y.x,$.x),vt=Math.min(Y.y,$.y),Mt=Math.max(Y.y,$.y);for(const kt of Xt)J=Math.min(J,kt.x),ft=Math.max(ft,kt.x),vt=Math.min(vt,kt.y),Mt=Math.max(Mt,kt.y);const Rt=ft>Math.max(Y.x,$.x),Nt=J<Math.min(Y.x,$.x);if(d){const kt=Ne;if(Rt){const $t=Math.max(Y.x,$.x),Bt=Math.min(Y.y,$.y),It=Math.max(Y.y,$.y),Vt=g.filter(St=>St.minX<$t&&St.maxX>$t&&St.minY<It&&St.maxY>Bt);if(Vt.length>0){let St=Math.max(Y.x,$.x);for(const Ct of Vt){const Jt=(Ct.minX+Ct.maxX)/2;if(Ct.visualXHalfExtent===void 0||isNaN(Ct.visualXHalfExtent))continue;const Oe=Jt+Ct.visualXHalfExtent+kt;St=Math.max(St,Oe)}isNaN(St)||(ft=St)}}if(Nt){const $t=g.filter(Bt=>Bt.minX<Math.min(Y.x,$.x)+kt&&Bt.minY<Math.max(Y.y,$.y)&&Bt.maxY>Math.min(Y.y,$.y));if($t.length>0){let Bt=Math.min(Y.x,$.x);for(const It of $t){const St=(It.minX+It.maxX)/2-It.visualXHalfExtent-kt;Bt=Math.min(Bt,St)}J=Bt}}}const gt=f(kt=>{const $t=$.y>Y.y,Bt=g.filter(St=>{const Ct=Math.min(Y.x,$.x)<St.maxX&&Math.max(Y.x,$.x)>St.minX,Jt=Math.min(Y.y,$.y)<St.maxY&&Math.max(Y.y,$.y)>St.minY;return Ct&&Jt});let It=Bt;if(d&&Bt.length>0){const St=Bt.filter(Ct=>Ct.minX<kt&&Ct.maxX>kt);St.length>0&&(It=St)}if(It.length===0)return $.y;const Vt=Se;if($t){const Ct=Math.max(...It.map(Jt=>Jt.maxY))+Vt;if(Ct<$.y-at)return Ct}else{const Ct=Math.min(...It.map(Jt=>Jt.minY))-Vt;if(Ct>$.y+at)return Ct}return $.y},"findBestReturnY"),Gt=f(kt=>{const $t=gt(kt),Bt={x:kt,y:Y.y},It={x:kt,y:$t},Vt={x:$.x,y:$t},St=ye(Y,Bt),Ct=ye(Bt,It),Jt=ye(It,Vt),Oe=$t!==$.y?ye(Vt,$):!1;return!St&&!Ct&&!Jt&&!Oe?Math.abs($t-$.y)<at?[Y,Bt,It,$]:[Y,Bt,It,Vt,$]:null},"trySimplifyWithDetourX"),oe=Rt&&!Nt?Gt(ft):Nt&&!Rt?Gt(J):null;oe&&(Xt=oe)}const Yt=[w,...xt,...Xt,...Ht.reverse(),k];if(Yt.length>=3){const Y=Yt[Yt.length-1],$=Yt[Yt.length-2],J=Yt[Yt.length-3],ft=Math.abs(J.y-$.y)<at&&Math.abs($.y-Y.y)<at,vt=Math.abs(J.x-$.x)<at&&Math.abs($.x-Y.x)<at;if(ft){const Mt=Math.sign($.x-J.x),Rt=Math.sign(Y.x-J.x);Mt!==0&&Mt===Rt&&Math.abs($.x-J.x)>Math.abs(Y.x-J.x)&&Yt.splice(-2,1)}else if(vt){const Mt=Math.sign($.y-J.y),Rt=Math.sign(Y.y-J.y);Mt!==0&&Mt===Rt&&Math.abs($.y-J.y)>Math.abs(Y.y-J.y)&&Yt.splice(-2,1)}}const le=[Yt[0]];for(let Y=1;Y<Yt.length-1;Y++){if(Y===1){le.push(Yt[Y]);continue}const $=le[le.length-1],J=Yt[Y],ft=Yt[Y+1];if(Math.abs($.y-J.y)<at&&Math.abs(J.y-ft.y)<at){const vt=J.x>$.x,Mt=ft.x>J.x;if(vt!==Mt){le.push(J);continue}continue}if(Math.abs($.x-J.x)<at&&Math.abs(J.x-ft.x)<at){const vt=J.y>$.y,Mt=ft.y>J.y;if(vt!==Mt){le.push(J);continue}continue}le.push(J)}le.push(Yt[Yt.length-1]);for(let Y=0;Y<le.length-1;Y++){const $=le[Y],J=le[Y+1],ft=Math.abs($.x-J.x)<at?"vertical":"horizontal",vt=ft==="vertical"?$.x:$.y,Mt=ft==="vertical"?Math.min($.y,J.y):Math.min($.x,J.x),Rt=ft==="vertical"?Math.max($.y,J.y):Math.max($.x,J.x),Nt=x(ft,vt,Mt,Rt),gt={edgeIndex:u,segmentIndex:Y,orientation:ft,pipe:Nt,trackIndex:0,from:Mt,to:Rt};p.push(gt),c[u].push(p.length-1),Nt.tracks[0]||(Nt.tracks[0]={index:0,coord:Nt.coord,segments:[]}),Nt.tracks[0].segments.push({edgeIndex:u,segmentIndex:Y,from:Mt,to:Rt})}}const K=f((u,b)=>u.from<b.to&&b.from<u.to,"segmentsOverlap"),nt=f((u,b,S,L)=>{const w=!L.segments.some(W=>(W.edgeIndex!==b.edgeIndex||W.segmentIndex!==b.segmentIndex)&&K(W,u)),k=!S.segments.some(W=>(W.edgeIndex!==u.edgeIndex||W.segmentIndex!==u.segmentIndex)&&K(W,b));return w&&k?(u.trackIndex=L.index,b.trackIndex=S.index,S.segments=[...S.segments.filter(W=>W.edgeIndex!==u.edgeIndex||W.segmentIndex!==u.segmentIndex),{edgeIndex:b.edgeIndex,segmentIndex:b.segmentIndex,from:b.from,to:b.to}],L.segments=[...L.segments.filter(W=>W.edgeIndex!==b.edgeIndex||W.segmentIndex!==b.segmentIndex),{edgeIndex:u.edgeIndex,segmentIndex:u.segmentIndex,from:u.from,to:u.to}],!0):!1},"trySwapSegmentsAcrossTracks"),lt=f(u=>{const b=u.tracks.length;return u.tracks[b]={index:b,coord:u.coord,segments:[]},b},"createNewTrack"),pt=f((u,b)=>{const S=u.pipe.tracks[u.trackIndex];S.segments=S.segments.filter(w=>w.edgeIndex!==u.edgeIndex||w.segmentIndex!==u.segmentIndex),u.trackIndex=b,u.pipe.tracks[b].segments.push({edgeIndex:u.edgeIndex,segmentIndex:u.segmentIndex,from:u.from,to:u.to})},"moveSegmentToTrack"),bt=f((u,b)=>{const S=c[u.edgeIndex];for(const L of S){const w=p[L];w.pipe===u.pipe&&pt(w,b)}},"moveSegmentChainToTrack"),Lt=f(u=>{const b=c[u.edgeIndex],S=b.indexOf(p.indexOf(u)),L=[];return S>0&&L.push(p[b[S-1]]),S<b.length-1&&L.push(p[b[S+1]]),L},"getAdjacentSegmentsAlongEdge"),Ut=f((u,b)=>{if(u.orientation===b.orientation)return!1;const S=u.orientation==="horizontal"?u:b,L=u.orientation==="horizontal"?b:u;return L.pipe.coord>S.from&&L.pipe.coord<S.to&&S.pipe.coord>L.from&&S.pipe.coord<L.to},"haveAnyCrossing"),Wt=f((u,b)=>{for(const S of u.tracks)if(!S.segments.some(w=>(w.edgeIndex!==b.edgeIndex||w.segmentIndex!==b.segmentIndex)&&K(w,b)))return S.index;return-1},"findAvailableTrack"),Kt=f((u,b)=>{if(u.trackIndex===b.trackIndex)return K(u,b);const S=Lt(u),L=Lt(b);return S.some(w=>L.some(k=>Ut(w,k)))},"segmentsConflict"),ne=f((u,b,S)=>{if(nt(u,b,u.pipe.tracks[u.trackIndex],b.pipe.tracks[b.trackIndex]))return;const L=Wt(u.pipe,b);S(b,L!==-1?L:lt(u.pipe))},"resolveTrackConflict"),Ee=f(u=>{let b=0;for(let S=0;S<u.length;S++)for(let L=S+1;L<u.length;L++){const w=u[S],k=u[L];w.pipe===k.pipe&&Kt(w,k)&&(b++,ne(w,k,bt))}return b},"resolveHandleConflicts"),ge=new Map,we=f(u=>{if(ge.has(u))return ge.get(u);const b=c[u];if(b.length===0){const q={dest:0,deviation:0,base:0,delta:0};return ge.set(u,q),q}const L=p[b[0]].pipe.coord;let w=L;for(let q=1;q<b.length;q++){const V=p[b[q]];if(V.orientation==="horizontal"){const G=V.from,st=V.to;w=Math.abs(G-L)>Math.abs(st-L)?G:st;break}}const k=Math.abs(w-L),W={dest:w,deviation:k,base:L,delta:w-L};return ge.set(u,W),W},"getDestInfo"),ao=f(()=>{let u=0;const b=new Map;for(const[L,w]of s.entries())c[L].length!==0&&w.start&&(b.has(w.start)||b.set(w.start,[]),b.get(w.start).push(L));const S=f(L=>{const w=s[L];if(!w.start||!w.end)return 0;const k=r.get(w.start),W=r.get(w.end);if(!k||!W)return 0;const q=(W.x??0)-(k.x??0),V=(W.y??0)-(k.y??0);return Math.abs(q)+Math.abs(V)},"getEdgeDistance");for(const L of b.values()){L.sort((k,W)=>{const q=we(k),V=we(W);if(Math.abs(q.deviation-V.deviation)>1)return q.deviation-V.deviation;if(Math.abs(q.dest-V.dest)>1)return q.dest-V.dest;const G=S(k),st=S(W);if(Math.abs(G-st)>1)return st-G;const it=c[k].length,rt=c[W].length;if(it!==rt)return it-rt;if(it===1){const et=c[k][0],xt=c[W][0];if(p[et]&&p[xt]){const Ot=p[et],wt=p[xt],Ht=Math.abs(Ot.to-Ot.from),Qt=Math.abs(wt.to-wt.from);if(Math.abs(Ht-Qt)>1)return Ht-Qt}}return 0});const w=L.map(k=>p[c[k][0]]);u+=Ee(w)}return u},"fixSourceHandleCrossings"),lo=f(()=>{let u=0;const b=new Map;for(const[S,L]of s.entries())c[S].length!==0&&L.end&&(b.has(L.end)||b.set(L.end,[]),b.get(L.end).push(S));for(const S of b.values()){S.sort((w,k)=>{const W=f(G=>{const st=c[G];if(st.length<2)return 0;const it=p[st[st.length-2]];return Math.abs(it.to-it.from)},"getDist"),q=W(w),V=W(k);return Math.abs(q-V)>.1?q-V:w-k});const L=S.map(w=>p[c[w][c[w].length-1]]);u+=Ee(L)}return u},"fixTargetHandleCrossings"),fo=f(()=>{let u=0;for(const b of l){const S=[];for(const L of b.tracks)for(const w of L.segments){const k=c[w.edgeIndex].find(W=>p[W].segmentIndex===w.segmentIndex);k!==void 0&&S.push(p[k])}S.sort((L,w)=>L.edgeIndex-w.edgeIndex||L.segmentIndex-w.segmentIndex);for(let L=0;L<S.length;L++)for(let w=L+1;w<S.length;w++){const k=S[L],W=S[w];Kt(k,W)&&(u++,ne(k,W,pt))}}return u},"fixPipeCrossings");let N=0;const D=10;for(;N<D;){let u=0;if(u+=ao(),u+=lo(),u+=fo(),u===0)break;N++}const H=new Map;for(const u of l){const b=[];u.tracks.forEach(L=>{L.segments.forEach(w=>{b.push({edgeIndex:w.edgeIndex,segmentIndex:w.segmentIndex,trackIndex:L.index,from:w.from,to:w.to})})}),b.sort((L,w)=>L.from-w.from);const S=[];if(b.length>0){let L=[b[0]],w=b[0].to;for(let k=1;k<b.length;k++){const W=b[k];W.from<w?(L.push(W),w=Math.max(w,W.to)):(S.push(L),L=[W],w=W.to)}S.push(L)}for(const L of S){const w=new Set;L.forEach(et=>w.add(et.trackIndex));const k=new Map;L.forEach(et=>{const xt=we(et.edgeIndex);k.set(et.trackIndex,(k.get(et.trackIndex)??0)+xt.delta)});const W=[...w].filter(et=>(k.get(et)??0)<-1),q=[...w].filter(et=>(k.get(et)??0)>1),V=[...w].filter(et=>Math.abs(k.get(et)??0)<=1);W.sort((et,xt)=>(k.get(xt)??0)-(k.get(et)??0)),q.sort((et,xt)=>(k.get(et)??0)-(k.get(xt)??0));const G=f((et,xt)=>{L.filter(Ot=>Ot.trackIndex===et).forEach(Ot=>{const wt=y.has(Ot.edgeIndex)?u.coord:xt;H.set(`${Ot.edgeIndex}-${Ot.segmentIndex}`,wt)})},"assignCoord");let st=0;for(const et of W)st++,G(et,u.coord-st*Io);if(V.length===0&&w.size>0){const et=[...w].sort((wt,Ht)=>Math.abs(k.get(wt)??0)-Math.abs(k.get(Ht)??0))[0],xt=W.indexOf(et);xt!==-1&&W.splice(xt,1);const Ot=q.indexOf(et);Ot!==-1&&q.splice(Ot,1),V.push(et)}let it=0;for(const et of V){if(it===0)G(et,u.coord);else{const xt=it%2===1?1:-1,Ot=Math.ceil(it/2);G(et,u.coord+xt*Ot*Io*.5)}it++}let rt=0;for(const et of q)rt++,G(et,u.coord+rt*Io)}}for(const[u,b]of s.entries()){const S=c[u]??[];if(S.length===0)continue;const L=[],w=r.get(b.start),k=r.get(b.end),{pSrcPort:W,pDstPort:q}=tt(u,w,k),V=S.map(it=>{const rt=p[it],et=H.get(`${rt.edgeIndex}-${rt.segmentIndex}`)??rt.pipe.coord;return{orient:rt.orientation,coord:et,from:rt.from,to:rt.to}});L.push(W);for(let it=0;it<V.length;it++){const rt=V[it],et=L[L.length-1],xt=rt.orient==="vertical"?et.y:et.x,Ot=rt.orient==="vertical"?et.x:et.y,wt=V[it+1],Ht=it<V.length-1;if(Math.abs(Ot-rt.coord)>at&&L.push(be(rt,xt)),Ht&&wt.orient===rt.orient)if(Math.abs(rt.coord-wt.coord)>at){const Qt=rt.orient==="vertical"?(xt+wt.from)/2:Yn(rt,wt);L.push(be(rt,Qt),be(wt,Qt))}else(it===0||it===V.length-2)&&L.push(be(rt,Yn(rt,wt)));else if(Ht)L.push(be(rt,wt.coord));else{const Qt=Math.abs(rt.from-xt)<Math.abs(rt.to-xt)?rt.to:rt.from;L.push(be(rt,Qt))}}const G=L[L.length-1];(Math.abs(G.x-q.x)>at||Math.abs(G.y-q.y)>at)&&L.push(q);const st=[];L.length>0&&st.push(L[0]);for(let it=1;it<L.length;it++){const rt=L[it],et=st[st.length-1];(Math.abs(rt.x-et.x)>at||Math.abs(rt.y-et.y)>at)&&st.push(rt)}b.points=st}for(const u of s){const b=u.__originalEdge;b&&u.points&&(b.points=u.points)}t.edges=(t.edges??[]).filter(u=>!u.isLayoutOnly);const j=f((u,b)=>{const S=b.x??0,L=b.y??0,w=b.width??0,k=b.height??0;if(w<=0||k<=0)return u;const W=S-w/2,q=S+w/2,V=L-k/2,G=L+k/2;if(u.x<W||u.x>q||u.y<V||u.y>G)return u;const st=u.x-W,it=q-u.x,rt=u.y-V,et=G-u.y,xt=Math.min(st,it,rt,et);return xt===st?{x:W,y:u.y}:xt===it?{x:q,y:u.y}:xt===rt?{x:u.x,y:V}:{x:u.x,y:G}},"nodeBoundaryClamp");for(const u of t.edges){const b=u.points;if(!b||b.length<2)continue;const S=u.start,L=u.end,w=S?r.get(S):void 0,k=L?r.get(L):void 0;w&&(b[0]=j(b[0],w)),k&&(b[b.length-1]=j(b[b.length-1],k))}return t}A(qs,"routeEdgesOrthogonal");f(qs,"routeEdgesOrthogonal");function Zs(t){return t.direction??"TB"}A(Zs,"getSwimlaneDirection");f(Zs,"getSwimlaneDirection");function Qs(t){const e=Fo(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,a=t.config.swimlane?.automaticLaneOrdering??!1,l=Zs(t),{ordered:d,coordinates:i}=Js(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:s,optimizeRanksByCrossings:r,automaticLaneOrdering:a,direction:l});_o(e,d,i,{nodeGap:n,layerGap:o});for(const g of t.edges??[])delete g.points;qs(t,l);for(const g of t.edges??[])(!g.curve||g.curve==="basis")&&(g.curve="rounded");return ps(t,l),gs(t),l}A(Qs,"runSwimlaneLayoutCore");f(Qs,"runSwimlaneLayoutCore");function tr(t){ko(t);const e=Do(t);t.nodes=e.nodes,t.edges=e.edges}A(tr,"prepareSwimlaneLayout");f(tr,"prepareSwimlaneLayout");var Hr=vr({prepareLayout:tr,runLayoutCore:Qs,afterPaint:Bo});export{Hr as render};
|