@esri/solutions-components 5.1.0-next.87 → 5.1.0-next.89
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/dist/cdn/{5IIGQVJO.js → 26K4UTAF.js} +1 -1
- package/dist/cdn/{UWU7WKT4.js → 2AO55DUN.js} +1 -1
- package/dist/cdn/2HUG6L4M.js +2 -0
- package/dist/cdn/{5MAO5XLB.js → 2PM224B6.js} +1 -1
- package/dist/cdn/{O5CIRNTW.js → 32YZXXMV.js} +1 -1
- package/dist/cdn/{X7GJCPNX.js → 34EUIYLN.js} +1 -1
- package/dist/cdn/{GF4QELNV.js → 3FMOO3PJ.js} +1 -1
- package/dist/cdn/{YKB6256M.js → 3IHLJADI.js} +1 -1
- package/dist/cdn/{76PFFHQQ.js → 3JGLETSR.js} +1 -1
- package/dist/cdn/3PT5ULE3.js +2 -0
- package/dist/cdn/{ZUM2PBNR.js → 3RUGNS6K.js} +1 -1
- package/dist/cdn/{AJZDBHB6.js → 45M33Q5G.js} +1 -1
- package/dist/cdn/{5O53T3SW.js → 4HFHJOS3.js} +1 -1
- package/dist/cdn/{MH4GMDK7.js → 4J3ETN35.js} +1 -1
- package/dist/cdn/{LXI55MKX.js → 4LXH3MTT.js} +1 -1
- package/dist/cdn/{Y4WHK65W.js → 4QJK4LPR.js} +1 -1
- package/dist/cdn/{QMPT2LSN.js → 4ZKGHGGU.js} +1 -1
- package/dist/cdn/{MOK7GNOH.js → 55PTISQ7.js} +1 -1
- package/dist/cdn/{ATWINUVK.js → 5A7H4LVR.js} +1 -1
- package/dist/cdn/{A4NILC27.js → 5ADMCIGY.js} +1 -1
- package/dist/cdn/{GURBVBZQ.js → 5AVH2R6T.js} +1 -1
- package/dist/cdn/{RJ35WJNP.js → 5CW67X4G.js} +1 -1
- package/dist/cdn/{UNJV2PKC.js → 5EBHORLK.js} +1 -1
- package/dist/cdn/{2LBDG4TO.js → 5EYS2CH4.js} +1 -1
- package/dist/cdn/{ZV6TCDGB.js → 5JLXNBOA.js} +1 -1
- package/dist/cdn/{IZT3JCS7.js → 5NPISZEN.js} +1 -1
- package/dist/cdn/{QX5WB6H3.js → 5RTR3NSC.js} +1 -1
- package/dist/cdn/{BQVD2BBH.js → 64Y5CQSL.js} +1 -1
- package/dist/cdn/6DCCVJMZ.js +2 -0
- package/dist/cdn/{J5GPIJHD.js → 6IIMJC5D.js} +1 -1
- package/dist/cdn/{JNREEHT7.js → 6MP2RVUK.js} +1 -1
- package/dist/cdn/{JR5GBFT2.js → 6O3XSKQY.js} +1 -1
- package/dist/cdn/{HJJK5IEH.js → 6PFEFNQM.js} +1 -1
- package/dist/cdn/{GQ4DWI5G.js → 6WQK4DHL.js} +1 -1
- package/dist/cdn/{BSBNPUTI.js → 6XELM7OM.js} +1 -1
- package/dist/cdn/{DV6MFL2N.js → 73YLLTLN.js} +1 -1
- package/dist/cdn/{LRZBOUPX.js → 74PV6PZ3.js} +1 -1
- package/dist/cdn/{6SADY7KT.js → 76APML4N.js} +1 -1
- package/dist/cdn/{VRSBUIGV.js → 7CJQI7VH.js} +1 -1
- package/dist/cdn/{KG6FSDWT.js → 7EF5FK2O.js} +1 -1
- package/dist/cdn/{QLOWHDGX.js → 7JEVFHRJ.js} +1 -1
- package/dist/cdn/{C4IFGE7P.js → 7TCHZME4.js} +1 -1
- package/dist/cdn/A7PEA2YP.js +2 -0
- package/dist/cdn/{6RTR35JT.js → AFZETCUL.js} +1 -1
- package/dist/cdn/AIQEYNZE.js +2 -0
- package/dist/cdn/{FFMJQJUP.js → AL2DDBXW.js} +1 -1
- package/dist/cdn/{YFXSWGXE.js → ALSK2SPM.js} +1 -1
- package/dist/cdn/{EUPJV6QI.js → AM5URNYD.js} +1 -1
- package/dist/cdn/{JCQ5JRVZ.js → B67TTSQO.js} +1 -1
- package/dist/cdn/{5G5LMAT4.js → B7AQR2UD.js} +1 -1
- package/dist/cdn/BBNWDMCK.js +2 -0
- package/dist/cdn/{JBNWEBAG.js → BMBNSJZQ.js} +1 -1
- package/dist/cdn/BRQJSGIX.js +2 -0
- package/dist/cdn/{3OCYAA4P.js → BU5PIAGS.js} +1 -1
- package/dist/cdn/{CR7KUQQF.js → BVWAUO73.js} +1 -1
- package/dist/cdn/{FEQDFENU.js → C3ZGM4K7.js} +1 -1
- package/dist/cdn/{SMNWKCWR.js → CZKXDUOH.js} +1 -1
- package/dist/cdn/{RQRAFBVO.js → DJOOB7YP.js} +1 -1
- package/dist/cdn/DLH53PYM.js +7 -0
- package/dist/cdn/{ZJ3PH44C.js → DQWJUYMM.js} +1 -1
- package/dist/cdn/{ERCI6HI5.js → DUZ4KXB3.js} +1 -1
- package/dist/cdn/{QK5IXICV.js → DWEIHGFT.js} +1 -1
- package/dist/cdn/{Y3CYPNEY.js → EBRCBPEM.js} +1 -1
- package/dist/cdn/{B3BR2NG5.js → ELD2UQO4.js} +1 -1
- package/dist/cdn/{TMYE7YBP.js → ELPH6EFW.js} +1 -1
- package/dist/cdn/{JUCL7I6N.js → ET32EBBO.js} +3 -3
- package/dist/cdn/{I33PCNP7.js → FGWGYIBZ.js} +1 -1
- package/dist/cdn/{TJNO7ZMF.js → FMHXFW3E.js} +1 -1
- package/dist/cdn/{I53PAKKW.js → FN2NSVLO.js} +1 -1
- package/dist/cdn/{AZ4JB3M3.js → GEXLEGOL.js} +1 -1
- package/dist/cdn/{NPUZIHVP.js → GM772Z5U.js} +1 -1
- package/dist/cdn/H5E6ISYP.js +4 -0
- package/dist/cdn/{5MVIKBSS.js → H5TWIMN3.js} +1 -1
- package/dist/cdn/{SPUZEM7P.js → HKVSZTWH.js} +1 -1
- package/dist/cdn/{JUWJNZMD.js → HMKJYAVE.js} +1 -1
- package/dist/cdn/{3MEDCOT3.js → HNVWONX2.js} +1 -1
- package/dist/cdn/{6TCJ2NKA.js → HOLASUOX.js} +1 -1
- package/dist/cdn/I33B45EZ.js +2 -0
- package/dist/cdn/{SNR6ZHKZ.js → I6H42GYO.js} +1 -1
- package/dist/cdn/{UOGOGQ2H.js → IV4U4XB5.js} +1 -1
- package/dist/cdn/{E7Y745EK.js → J5FYHTE4.js} +1 -1
- package/dist/cdn/J75MHJID.js +4 -0
- package/dist/cdn/{XRZHHEBP.js → J7IFAEYK.js} +1 -1
- package/dist/cdn/{3PUFU3VY.js → JC5EXPFH.js} +1 -1
- package/dist/cdn/{D66IBZZA.js → JDVVMD4S.js} +1 -1
- package/dist/cdn/{A73LPATI.js → JDX6K42U.js} +132 -149
- package/dist/cdn/{3FOUGCWY.js → JMU5KKZH.js} +1 -1
- package/dist/cdn/{XYG3Z7ZY.js → JWGDDEVT.js} +1 -1
- package/dist/cdn/JZ472WDS.js +2 -0
- package/dist/cdn/{7UVBIBQS.js → K3DQKY7V.js} +1 -1
- package/dist/cdn/K6PW4IX6.js +2 -0
- package/dist/cdn/{63QOJNSI.js → KCEVE53E.js} +1 -1
- package/dist/cdn/{5Z43RSKO.js → KEZAVYJU.js} +1 -1
- package/dist/cdn/{3OLSNMWN.js → KHHT54BU.js} +1 -1
- package/dist/cdn/{JSJYFWT6.js → KIUBUHVM.js} +1 -1
- package/dist/cdn/{E4GB5Z4R.js → KOHVDHPZ.js} +1 -1
- package/dist/cdn/{LRRFLTS7.js → L33BENH7.js} +1 -1
- package/dist/cdn/{SGK4AMN6.js → L342GSW5.js} +1 -1
- package/dist/cdn/{L6QVMYXE.js → LCERYSRG.js} +1 -1
- package/dist/cdn/{QKKYYRVF.js → LCPWL74J.js} +1 -1
- package/dist/cdn/{N2XIWSCG.js → LDK4C3VJ.js} +1 -1
- package/dist/cdn/{SNE4DYFB.js → LNLCO244.js} +1 -1
- package/dist/cdn/{N2KSPEVT.js → LPBP7CBN.js} +1 -1
- package/dist/cdn/{KP3AJBAI.js → LPJHRY3Y.js} +1 -1
- package/dist/cdn/{FUAPM3ST.js → LVOTTNTF.js} +1 -1
- package/dist/cdn/{CQIP3CFN.js → M6HNHWAM.js} +1 -6
- package/dist/cdn/{BWTT7T3L.js → MBBG3S5B.js} +1 -1
- package/dist/cdn/{ULZKT76M.js → MKHDEHCO.js} +1 -1
- package/dist/cdn/{K5MMGZY2.js → MPJRP2QO.js} +1 -1
- package/dist/cdn/{AGMFVUEV.js → MVGX2AGG.js} +1 -1
- package/dist/cdn/{URLISIUW.js → MVYIHKFK.js} +1 -1
- package/dist/cdn/{D5Y4JMF7.js → MZY3G7B5.js} +1 -1
- package/dist/cdn/{JZUDCYGF.js → N3F6RUT6.js} +1 -1
- package/dist/cdn/{LCWGF752.js → NBQ5MMHE.js} +1 -1
- package/dist/cdn/{SNBTGG5B.js → NH5526ON.js} +1 -1
- package/dist/cdn/{OR5M4R6K.js → NP7POZTI.js} +1 -1
- package/dist/cdn/{ZDTDI643.js → NPOHA56R.js} +1 -1
- package/dist/cdn/NSJAGP7T.js +18 -0
- package/dist/cdn/NSKVOAA7.js +2 -0
- package/dist/cdn/{6GSCRFFW.js → NUD23X7L.js} +1 -1
- package/dist/cdn/NV3RC3FX.js +2 -0
- package/dist/cdn/{Q2WAWIFY.js → O2L7DY23.js} +1 -1
- package/dist/cdn/{WUJQ6R2U.js → O3O4EPB6.js} +1 -1
- package/dist/cdn/{N7CI3FRD.js → O4E54ZIL.js} +1 -1
- package/dist/cdn/{SQVN3YNK.js → OBKT6Y6H.js} +1 -1
- package/dist/cdn/{JM44ZPIE.js → OIRNHTN3.js} +1 -1
- package/dist/cdn/{MYPJ63EE.js → OPWB5U5Y.js} +1 -1
- package/dist/cdn/OV4IBBDL.js +2 -0
- package/dist/cdn/{C5AR5K23.js → P2YLMWCT.js} +1 -1
- package/dist/cdn/{ECFYA6DN.js → PAMG6BC2.js} +1 -1
- package/dist/cdn/{3S5XSBME.js → PHIGRQ7V.js} +1 -1
- package/dist/cdn/PP2SFAFD.js +2 -0
- package/dist/cdn/PRXFYNIG.js +19 -0
- package/dist/cdn/{HT55AVL4.js → QAMVNRII.js} +1 -1
- package/dist/cdn/{QX742MCD.js → QO2RC46D.js} +1 -1
- package/dist/cdn/{J72FZDMP.js → QPNIPE5H.js} +1 -1
- package/dist/cdn/{23CGFV6D.js → QQN472YW.js} +1 -1
- package/dist/cdn/QSBVJLYZ.js +2 -0
- package/dist/cdn/QYDGCI2P.js +2 -0
- package/dist/cdn/{SCZI2MJN.js → QZRJRLYA.js} +1 -1
- package/dist/cdn/R3TKXDOE.js +6 -0
- package/dist/cdn/{HO5JGUUI.js → R67EKKSL.js} +1 -1
- package/dist/cdn/{EWUZF57U.js → RIM6ODUZ.js} +1 -1
- package/dist/cdn/{TMSMQA7C.js → RJFWIPOY.js} +1 -1
- package/dist/cdn/{FDQE4EO7.js → RKBDZ7GR.js} +1 -1
- package/dist/cdn/{TW7HOOK6.js → ROKVOX7R.js} +1 -1
- package/dist/cdn/{XZ65OHYC.js → RUZVGWHQ.js} +1 -1
- package/dist/cdn/{ACINVVFD.js → RWGEJGAH.js} +1 -1
- package/dist/cdn/{SHAQ3O3Z.js → RX7HKQ7Y.js} +1 -1
- package/dist/cdn/{C5QZMZX7.js → S7MMEM3H.js} +1 -1
- package/dist/cdn/{QUWHB36D.js → SB3EADQF.js} +1 -1
- package/dist/cdn/{BXNDQ2JH.js → SBTQKPQR.js} +1 -1
- package/dist/cdn/{CGFMGQ3A.js → SFM524YL.js} +1 -1
- package/dist/cdn/{HWOOHVH5.js → SGBMDDAS.js} +1 -1
- package/dist/cdn/{XV7A4KNT.js → SUK3BLEW.js} +1 -1
- package/dist/cdn/{JTIMMQ6K.js → SWAMKTGK.js} +1 -1
- package/dist/cdn/SWWDYNJE.js +2 -0
- package/dist/cdn/SXVCHOTK.js +79 -0
- package/dist/cdn/{LR57LX6P.js → TILX2YPV.js} +1 -1
- package/dist/cdn/{JFJRHOAG.js → TM3CBSWO.js} +1 -1
- package/dist/cdn/{CGZDUJRA.js → TMKYG3QB.js} +1 -1
- package/dist/cdn/{NLOASWJ3.js → UDBUSMCV.js} +1 -1
- package/dist/cdn/{V52O7WYV.js → UDGR2GC5.js} +1 -1
- package/dist/cdn/{XY65IFHL.js → UHVJUD6J.js} +1 -1
- package/dist/cdn/{7D5KMJGC.js → UJLDLGTN.js} +1 -1
- package/dist/cdn/{MCZXYUMV.js → ULTK7DMM.js} +1 -1
- package/dist/cdn/{GIANH6D4.js → UYYYSJL4.js} +1 -1
- package/dist/cdn/V3YTRV33.js +2 -0
- package/dist/cdn/{WOBPKAC2.js → VHOYM5MD.js} +1 -1
- package/dist/cdn/{KXGN75L6.js → VPDMT4CY.js} +1 -1
- package/dist/cdn/{AUNFZODL.js → VWPOKKOE.js} +1 -1
- package/dist/cdn/{RU3J7KVD.js → W6E3DYEQ.js} +1 -1
- package/dist/cdn/{DPSP2HYG.js → WAW43L2Y.js} +1 -1
- package/dist/cdn/WDHXTOWG.js +102 -0
- package/dist/cdn/{AE4OV2XZ.js → WEAC3FS7.js} +2 -2
- package/dist/cdn/{G3CCK7KY.js → WHS5LXKB.js} +1 -1
- package/dist/cdn/{XMOI3PP6.js → WLXO44M4.js} +1 -1
- package/dist/cdn/WQGGCG6M.js +2 -0
- package/dist/cdn/{C2CJFQ6Q.js → WSPAWPSL.js} +1 -1
- package/dist/cdn/{MGAKD4WY.js → WUM5AKBT.js} +1 -1
- package/dist/cdn/WVZM6LEZ.js +2 -0
- package/dist/cdn/{2HIYREV6.js → X25OZSS4.js} +1 -1
- package/dist/cdn/{R4CW26PN.js → X5EABWHE.js} +1 -1
- package/dist/cdn/{PX2KKGLQ.js → XN2JVOOR.js} +1 -1
- package/dist/cdn/{GWSB6X4X.js → XPIAEAK5.js} +1 -1
- package/dist/cdn/{CQRK2NYK.js → XVXOCPOT.js} +1 -1
- package/dist/cdn/{X26QOEYN.js → XXQKFENH.js} +1 -1
- package/dist/cdn/{RLHHGWT4.js → XXT542UR.js} +1 -1
- package/dist/cdn/{RH47YGDG.js → Y2ORH4QJ.js} +1 -1
- package/dist/cdn/{CKNELMMH.js → YHACLWMU.js} +1 -1
- package/dist/cdn/{TFINIJHF.js → YKQDHR27.js} +1 -1
- package/dist/cdn/{U727H4NV.js → YN7SGJOG.js} +1 -1
- package/dist/cdn/{FWWWKZLH.js → YOAGUXW6.js} +1 -1
- package/dist/cdn/{IPIK53AM.js → ZBET72YB.js} +1 -1
- package/dist/cdn/{DVXR45DO.js → ZDLTST3A.js} +1 -1
- package/dist/cdn/{U3ZZOP55.js → ZKELOWSS.js} +1 -1
- package/dist/cdn/ZONXYZVU.js +2 -0
- package/dist/cdn/{BXOH6SN4.js → ZR4T2HGR.js} +1 -1
- package/dist/cdn/{2LV7NQMM.js → ZYCAAXQF.js} +1 -1
- package/dist/cdn/{TJDAE43J.js → ZYRNI524.js} +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ar.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.bg.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.bs.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ca.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.cs.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.da.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.de.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.el.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.es.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.et.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.fi.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.fr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.he.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.hr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.hu.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.id.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.it.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ja.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ko.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.lt.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.lv.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.nl.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.no.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.pl.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.pt-BR.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.pt-PT.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ro.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.ru.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sk.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sl.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.sv.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.th.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.tr.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.uk.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.vi.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.zh-CN.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.zh-HK.json +1 -1
- package/dist/cdn/assets/solution-configure-titles/t9n/messages.zh-TW.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/description.js +1 -6
- package/dist/chunks/designSolution.js +105 -0
- package/dist/chunks/findExistingSolution.js +22 -0
- package/dist/chunks/get-portal-url.js +345 -0
- package/dist/chunks/initialAssessment.js +82 -0
- package/dist/chunks/solution-deploy-dialog.js +7 -17
- package/dist/chunks/updateDesign.js +5 -0
- package/dist/components/arcgis-solutions-assistant/customElement.d.ts +16 -38
- package/dist/components/arcgis-solutions-assistant/customElement.js +10205 -10519
- package/dist/components/consent-manager/customElement.js +638 -609
- package/dist/components/solution-builder-assistant/customElement.d.ts +12 -2
- package/dist/components/solution-builder-assistant/customElement.js +87 -87
- package/dist/components/solution-builder-assistant/index.js +0 -4
- package/dist/components/solution-deploy-dialog/index.js +0 -1
- package/dist/components/solutions-deploy-app/customElement.d.ts +7 -0
- package/dist/components/solutions-deploy-app/customElement.js +346 -27
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +2 -2
- package/dist/solutions-components_commit.txt +7 -7
- package/dist/types/lumina.d.ts +2 -2
- package/dist/types/preact.d.ts +2 -2
- package/dist/types/react.d.ts +2 -2
- package/dist/types/stencil.d.ts +2 -2
- package/dist/utils/interfaces.d.ts +1 -0
- package/package.json +25 -24
- package/dist/cdn/46C7TV4N.js +0 -10
- package/dist/cdn/4TL66G66.js +0 -9
- package/dist/cdn/67YHFNNT.js +0 -2
- package/dist/cdn/7FKMQ3QO.js +0 -2
- package/dist/cdn/AODE5TBO.js +0 -2
- package/dist/cdn/B4Y2UZHO.js +0 -2
- package/dist/cdn/BDKWDKBM.js +0 -7
- package/dist/cdn/CIG6UPFZ.js +0 -35
- package/dist/cdn/D4VZQUOX.js +0 -2
- package/dist/cdn/EJQKVRSG.js +0 -2
- package/dist/cdn/HE2XAIDT.js +0 -4
- package/dist/cdn/HQE4ABPK.js +0 -53
- package/dist/cdn/IRRMUFW7.js +0 -2
- package/dist/cdn/IVFBBPSY.js +0 -2
- package/dist/cdn/JAITP34E.js +0 -2
- package/dist/cdn/JSXNTE4I.js +0 -2
- package/dist/cdn/KNGBLBV7.js +0 -2
- package/dist/cdn/KQBIVJ7H.js +0 -36
- package/dist/cdn/LYDP7VMM.js +0 -2
- package/dist/cdn/MRGCC5C4.js +0 -4
- package/dist/cdn/NTOQES4U.js +0 -41
- package/dist/cdn/NUVTCMAW.js +0 -9
- package/dist/cdn/NYWSGPCD.js +0 -18
- package/dist/cdn/O3G7OWBQ.js +0 -164
- package/dist/cdn/OFM2G4BH.js +0 -2
- package/dist/cdn/QHHYNSCP.js +0 -2
- package/dist/cdn/RF2W2PD4.js +0 -7
- package/dist/cdn/RYETW3AF.js +0 -6
- package/dist/cdn/SY5KYHF4.js +0 -2
- package/dist/cdn/TV7TG34E.js +0 -2
- package/dist/cdn/WFHPQFNH.js +0 -2
- package/dist/cdn/WROPXUSZ.js +0 -2
- package/dist/cdn/X7ZFLHUP.js +0 -2
- package/dist/cdn/XFG55QXT.js +0 -2
- package/dist/cdn/YSLCWEDP.js +0 -2
- package/dist/chunks/create_design_prompt.js +0 -5
- package/dist/chunks/create_user_query.js +0 -12
- package/dist/chunks/extract-template.js +0 -44
- package/dist/chunks/extract-use-case.js +0 -38
- package/dist/chunks/get.js +0 -387
- package/dist/chunks/matching_solution_prompt.js +0 -12
- package/dist/chunks/prompts.js +0 -13
- package/dist/chunks/review_use_case_prompt.js +0 -10
- package/dist/chunks/system_prompt.js +0 -167
- package/dist/chunks/valid_tempates.js +0 -39
- package/dist/chunks/workflow_1_step_4.js +0 -56
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{b as un}from"./63QOJNSI.js";import"./IPIK53AM.js";import"./2B4SGB3I.js";import"./TFINIJHF.js";import{a as ln}from"./HO5JGUUI.js";import"./CR7KUQQF.js";import"./7UVBIBQS.js";import{b as hn}from"./JSJYFWT6.js";import{E as ms,F as ps,G as an,h as on,i as rn}from"./MRGCC5C4.js";import"./QPIMTXPL.js";(function(){let K=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};K.requestAnimationFrame===void 0&&(K.setImmediate===void 0?K.requestAnimationFrame=x=>K.setTimeout(x,0):K.requestAnimationFrame=K.setImmediate);class m{static fr=K.navigator!==void 0&&K.navigator.platform!==void 0&&K.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static PP(t,e,i){let s=-1;return function(){let n=this,o=arguments;s!==-1&&m.yc(s),s=m.dn(()=>{s=-1,i||t.apply(n,o)},e),i&&!s&&t.apply(n,o)}}static dn(t,e){return K.setTimeout(t,e)}static yc(t){K.clearTimeout(t)}static Ci(t){return K.document.createElement(t)}static o(t){throw new Error(t)}static L(t,e){let i="The object is frozen, so its properties cannot be set: "+t.toString();e!==void 0&&(i+=" to value: "+e),m.o(i)}static se(t,e,i,s){}static s(t,e,i,s){}static LU(t,e,i){}static wc(t,e,i){if(t===null||typeof t!="object"){let s=m.LL(e);i!==void 0&&(s+="."+i),m.si(t,"object",s)}}static S(t,e,i){m.s(t,"function",e,i)}static AU(t,e,i){}static si(t,e,i,s){}static J(t,e,i,s){let n=m.LL(i);s!==void 0&&(n+="."+s),m.o(n+" is not in the range "+e+": "+t)}static Yi(t){}static ur(t,e){}static ne(t){K.console&&K.console.log(t)}static $(t){return t!==null&&typeof t=="object"}static it(t){return typeof t=="function"}static SP=[];static st(){let t=m.SP.pop();return t===void 0?[]:t}static Z(t){t.length=0,m.SP.push(t)}static TU=Object.freeze([]);static LL(t){return t===null?"*":typeof t=="string"?t:m.it(t)?t.name:""}static Yn(t){return m.it(t)?t.className?t.className:t.name:m.$(t)&&t.constructor?m.Yn(t.constructor):typeof t}static Ja(t,e){return e==null||e===""?null:m.$(t)&&e in t||t[e]?t[e]:null}static toString(t){let e=t;return m.$(t)&&(t.text?e=t.text:t.name?e=t.name:t.key!==void 0?e=t.key:t.id!==void 0?e=t.id:t.constructor===Object&&(t.Text?e=t.Text:t.Name?e=t.Name:t.Key!==void 0?e=t.Key:t.Id!==void 0?e=t.Id:t.ID!==void 0&&(e=t.ID))),e===void 0?"undefined":e===null?"null":e.toString()}static Gw(t,e){if(t.hasOwnProperty(e))return!0;let i=Object.getPrototypeOf(t);for(;i&&i!==Function;){if(i.hasOwnProperty(e))return!0;let s=i.DU;if(s&&s[e])return!0;i=Object.getPrototypeOf(i)}return!1}static XF(t){let e=[],i=0;for(i=0;i<256;i++)e[i]=i;let s=0,n=0;for(i=0;i<256;i++)s=(s+e[i]+119)%256,n=e[i],e[i]=e[s],e[s]=n;i=0,s=0;let o="";for(let r=0;r<t.length;r++)i=(i+1)%256,s=(s+e[i])%256,n=e[i],e[i]=e[s],e[s]=n,o+=String.fromCharCode(t.charCodeAt(r)^e[(e[i]+e[s])%256]);return o}static GF(t){let e="0123456789abcdef",i=[];for(let r=0;r<256;r++)i[e.charAt(r>>4)+e.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);let s=[],n=0;for(let r=0;r<t.length;r+=2)s[n++]=i[t.substring(r,r+2)];let o=s.join("");return o===""?"0":o}static We(t){return m.XF(m.GF(t))}static color1="@COLOR1";static color2="@COLOR2";static Yw="32ab5ff3b26f42dc0ed90f21422913b5"}m.vfo="29e647fdba";class at{MP;constructor(){this.MP=[]}toString(){return this.MP.join("")}add(t){t!==""&&this.MP.push(t)}}class yt{}class Pt{g;constructor(){this.g=[]}[Symbol.iterator](){return this.g.values()}key;value;get iterator(){return this}reset(){}next(){return!1}hasNext(){return!1}first(){return null}any(){return!1}all(){return!0}each(){return this}map(t){return this}filter(){return this}get count(){return 0}Nl(){}toString(){return"EmptyIterator"}static instance=new Pt}class ut{constructor(t){this.key=-1,this.value=t}[Symbol.iterator](){return[this.value].values()}key;value;get iterator(){return this}reset(){this.key=-1}next(){return this.key===-1?(this.key=0,!0):!1}hasNext(){return this.next()}first(){return this.key=0,this.value}any(t){return this.key=-1,t(this.value)}all(t){return this.key=-1,t(this.value)}each(t){return this.key=-1,t(this.value),this}map(t){return new ut(t(this.value))}filter(t){return t(this.value)?new ut(this.value):Pt.instance}get count(){return 1}Nl(){this.value=null}toString(){return"SingletonIterator("+this.value+")"}}class ct{qt;Xs;Gt;Tt;constructor(t){this.qt=t,this.Xs=null,t.dr=null,this.Gt=t.rt,this.Tt=-1}[Symbol.iterator](){return this.Xs===null?this.qt.r.values():this.qt.r.filter(this.Xs).values()}key;value;get iterator(){return this}get predicate(){return this.Xs}set predicate(t){this.Xs=t}reset(){let t=this.qt;t.dr=null,this.Gt=t.rt,this.Tt=-1}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Yi(t)}let e=t.r,i=e.length,s=++this.Tt,n=this.Xs;if(n!==null)for(;s<i;){let o=e[s];if(n(o))return this.Tt=s,this.key=s,this.value=o,!0;s++}else{if(s<i)return this.key=s,this.value=e[s],!0;this.Nl()}return!1}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt,this.Tt=0;let e=t.r,i=e.length,s=this.Xs;if(s!==null){let n=0;for(;n<i;){let o=e[n];if(s(o))return this.Tt=n,this.key=n,this.value=o,o;n++}return null}else if(i>0){let n=e[0];return this.key=0,this.value=n,n}else return null}any(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(t(a))return!0;e.rt!==i&&m.Yi(e)}}return!1}all(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(!t(a))return!1;e.rt!==i&&m.Yi(e)}}return!0}each(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];o!==null&&!o(a)||(t(a),e.rt!==i&&m.Yi(e))}return this}map(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.Xs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(s.push(t(l)),e.rt!==i&&m.Yi(e))}let a=new q;return a.r=s,a.Ki(),a.iterator}filter(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.Xs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(t(l)&&s.push(l),e.rt!==i&&m.Yi(e))}let a=new q;return a.r=s,a.Ki(),a.iterator}get count(){let t=this.Xs;if(t!==null){let e=0,i=this.qt.r,s=i.length;for(let n=0;n<s;n++)t(i[n])&&e++;return e}else return this.qt.r.length}Nl(){this.key=-1,this.value=null,this.Gt=-1,this.Xs=null,this.qt.dr=this}toString(){return"ListIterator@"+this.Tt+"/"+this.qt.count}}class kt{qt;Gt;Tt;constructor(t){this.qt=t,t.gr=null,this.Gt=t.rt,this.Tt=t.r.length}[Symbol.iterator](){return this.qt.r.reverse().values()}key;value;get iterator(){return this}reset(){let t=this.qt;t.gr=null,this.Gt=t.rt,this.Tt=t.r.length}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Yi(t)}let e=--this.Tt;return e>=0?(this.key=e,this.value=t.r[e],!0):(this.Nl(),!1)}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt;let e=t.r,i=e.length-1;if(this.Tt=i,i>=0){let s=e[i];return this.key=i,this.value=s,s}else return null}any(t){let e=this.qt;e.gr=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(t(r))return!0;e.rt!==i&&m.Yi(e)}return!1}all(t){let e=this.qt;e.gr=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(!t(r))return!1;e.rt!==i&&m.Yi(e)}return!0}each(t){let e=this.qt;e.gr=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];t(r),e.rt!==i&&m.Yi(e)}return this}map(t){let e=this.qt;e.gr=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];s.push(t(h)),e.rt!==i&&m.Yi(e)}let r=new q;return r.r=s,r.Ki(),r.iterator}filter(t){let e=this.qt;e.gr=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];t(h)&&s.push(h),e.rt!==i&&m.Yi(e)}let r=new q;return r.r=s,r.Ki(),r.iterator}get count(){return this.qt.r.length}Nl(){this.key=-1,this.value=null,this.Gt=-1,this.qt.gr=this}toString(){return"ListIteratorBackwards("+this.Tt+"/"+this.qt.count+")"}}class q{u;r;rt;dr;gr;constructor(t){V.Je(this),this.u=!1,this.r=[],this.rt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Ki(){let t=this.rt;t++,t>999999999&&(t=0),this.rt=t}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"List()#"+V.xs(this)}add(t){return this.u&&m.L(this,t),this.r.push(t),this.Ki(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.u&&m.L(this);let e=this.r;if(t.first){let i=t.iterator;for(;i.next();)e.push(i.value)}else for(let i of t)e.push(i);return this.Ki(),this}clear(){this.u&&m.L(this),this.r.length=0,this.Ki()}contains(t){return this.has(t)}has(t){return t===null?!1:this.r.indexOf(t)!==-1}indexOf(t){return t===null?-1:this.r.indexOf(t)}elt(t){let e=this.r;return(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"elt:i"),e[t]}get(t){return this.elt(t)}setElt(t,e){let i=this.r;(t<0||t>=i.length)&&m.J(t,"0 <= i < length",q,"setElt:i"),this.u&&m.L(this,t),i[t]=e}set(t,e){this.setElt(t,e)}first(){let t=this.r;return t.length===0?null:t[0]}last(){let t=this.r,e=t.length;return e>0?t[e-1]:null}pop(){this.u&&m.L(this);let t=this.r;if(t.length>0){let e=t.pop();return e===void 0?null:e}return null}any(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(t(e[n]))return!0;this.rt!==i&&m.Yi(this)}return!1}all(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(!t(e[n]))return!1;this.rt!==i&&m.Yi(this)}return!0}each(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++)t(e[n]),this.rt!==i&&m.Yi(this);return this}map(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++)i.push(t(s[r])),this.rt!==n&&m.Yi(this);return e.r=i,e.Ki(),e}filter(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++){let a=s[r];t(a)&&i.push(a),this.rt!==n&&m.Yi(this)}return e.r=i,e.Ki(),e}insertAt(t,e){t<0&&m.J(t,">= 0",q,"insertAt:i"),this.u&&m.L(this,t);let i=this.r;t>=i.length?i.push(e):i.splice(t,0,e),this.Ki()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.u&&m.L(this,t);let e=this.r,i=e.indexOf(t);return i===-1?!1:(i===e.length-1?e.pop():e.splice(i,1),this.Ki(),!0)}removeAt(t){let e=this.r;(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"removeAt:i"),this.u&&m.L(this,t),t===e.length-1?e.pop():e.splice(t,1),this.Ki()}removeRange(t,e){let i=this.r,s=i.length;if(t<0)t=0;else if(t>=s)return this;if(e<0)return this;if(e>=s&&(e=s-1),t>e)return this;this.u&&m.L(this);let n=t,o=e+1;for(;o<s;)i[n++]=i[o++];return i.length=s-(e-t+1),this.Ki(),this}copy(){let t=new q,e=this.r;return e.length>0&&(t.r=Array.prototype.slice.call(e)),t}toArray(){let t=this.r,e=this.count,i=new Array(e);for(let s=0;s<e;s++)i[s]=t[s];return i}get AL(){return this.r}toSet(){let t=new V,e=this.r,i=this.count;for(let s=0;s<i;s++)t.add(e[s]);return t}sort(t){return this.u&&m.L(this),this.r.sort(t),this.Ki(),this}sortRange(t,e,i){let s=this.r,n=s.length;e===void 0&&(e=0),i===void 0&&(i=n),this.u&&m.L(this);let o=i-e;if(o<=1)return this;if((e<0||e>=n-1)&&m.J(e,"0 <= from < length",q,"sortRange:from"),o===2){let r=s[e],a=s[e+1];return t(r,a)>0&&(s[e]=a,s[e+1]=r,this.Ki()),this}if(e===0)if(i>=n)s.sort(t);else{let r=s.slice(0,i);r.sort(t);for(let a=0;a<i;a++)s[a]=r[a]}else if(i>=n){let r=s.slice(e);r.sort(t);for(let a=e;a<n;a++)s[a]=r[a-e]}else{let r=s.slice(e,i);r.sort(t);for(let a=e;a<i;a++)s[a]=r[a-e]}return this.Ki(),this}reverse(){return this.u&&m.L(this),this.r.reverse(),this.Ki(),this}get count(){return this.r.length}get size(){return this.r.length}get length(){return this.r.length}get iterator(){if(this.r.length<=0)return Pt.instance;let t=this.dr;return t!==null?(t.reset(),t):new ct(this)}get iteratorBackwards(){if(this.r.length<=0)return Pt.instance;let t=this.gr;return t!==null?(t.reset(),t):new kt(this)}}class _t{To;oe;constructor(t){this.To=t,this.oe=t.g.values()}[Symbol.iterator](){return this.To.g.values()}key;value;get iterator(){return this}reset(){let t=this.To;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.To.g.size===0?null:(this.oe=this.To.g.values(),this.oe.next().value)}any(t){return this.To.any(t)}all(t){return this.To.all(t)}each(t){return this.To.each(t),this}map(t){let e=new q;return this.To.g.forEach(i=>e.add(t(i))),e.iterator}filter(t){let e=new q;return this.To.g.forEach(i=>{t(i)&&e.add(i)}),e.iterator}get count(){return this.To.count}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"SetIterator"}}class V{u;g;constructor(t){this.u=!1,this.g=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.values()}values(){return this.g.values()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Set()#"+V.xs(this)}add(t){return t===null?this:(this.g.add(t),this)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.g.add(e.value)}else for(let e of t)this.g.add(e);return this}has(t){return this.g.has(t)}contains(t){return this.has(t)}containsAll(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(!this.has(e.value))return!1}else for(let e of t)if(!this.has(e))return!1;return!0}containsAny(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(this.has(e.value))return!0}else for(let e of t)if(this.has(e))return!0;return!1}first(){return this.g.size===0?null:this.g.values().next().value}any(t){for(let e of this.g)if(t(e))return!0;return!1}all(t){for(let e of this.g)if(!t(e))return!1;return!0}each(t){for(let e of this.g)t(e);return this}map(t){let e=new V;for(let i of this.g)e.add(t(i));return e}filter(t){let e=new V;for(let i of this.g)t(i)&&e.add(i);return e}delete(t){return this.u&&m.L(this),this.g.delete(t)}remove(t){return this.delete(t)}removeAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.delete(e.value)}else for(let e of t)this.delete(e);return this}retainAll(t){if(t===null)return this;if(this.count===0)return this;this.u&&m.L(this);let e=new V;e.addAll(t);let i=[];if(t.first){let s=t.iterator;for(;s.next();){let n=s.value;e.has(n)||i.push(n)}}else for(let s of t)e.has(s)||i.push(s);return this.removeAll(i),this}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new V;return this.g.forEach(e=>t.add(e)),t}toArray(){return Array.from(this.g)}toList(){let t=new q;return this.g.forEach(e=>t.add(e)),t}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new _t(this)}entries(){return this.g.entries()}keys(){return this.g.keys()}forEach(t,e){return this.g.forEach(t,e)}static Kw=1;static Je(t){t.__gohashid=V.Kw++}static xs(t){return t.__gohashid}}class We{j;oe;constructor(t){this.j=t,this.oe=t.g.keys()}[Symbol.iterator](){return this.j.g.keys()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.keys()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.keys(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[0]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[0];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"MapKeySetIterator"}}class Oi extends V{j;constructor(t){super(),V.Je(this),this.u=!0,this.j=t}[Symbol.iterator](){return this.g.keys()}values(){return this.g.keys()}k(){return this}ce(){return this}toString(){return"MapKeySet("+this.j.toString()+")"}add(t){m.o("This Set is read-only: "+this.toString())}has(t){return this.j.has(t)}contains(t){return this.has(t)}delete(t){m.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){m.o("This Set is read-only: "+this.toString())}first(){return this.j.g.size===0?null:this.j.g.keys().next().value}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=new V;for(let i of this.j.g)e.add(t(i[0]));return e}filter(t){let e=new V;for(let i of this.j.g){let s=i[0];t(s)&&e.add(s)}return e}copy(){return new Oi(this.j)}toSet(){let t=new V,e=this.j.g;for(let i of e)t.add(i[0]);return t}toArray(){let t=this.j.g,e=new Array(t.size),i=0;for(let s of t)e[i]=s[0],i++;return e}toList(){let t=new q,e=this.j.g;for(let i of e)t.add(i[0]);return t}get count(){return this.j.size}get size(){return this.j.size}get iterator(){return this.j.size<=0?Pt.instance:new We(this.j)}}class Tn{j;oe;constructor(t){this.j=t,this.oe=t.g.values()}[Symbol.iterator](){return this.j.g.values()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.values(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[1]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[1]))return!1;return!0}each(t){for(let e of this.j.g)t(e[1]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[1]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[1];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"MapValueSetIterator"}}class ye{constructor(t,e){this.key=t,this.value=e}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class Ln{j;oe;constructor(t){this.j=t,this.oe=t.g.entries()}[Symbol.iterator](){return this.j.g.entries()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.entries()}next(){let t=this.oe.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.j.g.size===0)return null;this.oe=this.j.g.entries();let t=this.oe.next().value;return this.key=t[0],this.value=t[1],new ye(t[0],t[1])}any(t){return this.j.any(t)}all(t){return this.j.all(t)}each(t){return this.j.each(t),this}map(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new ye(n,s):(i.key=n,i.value=s),e.add(t(i))}),e.iterator}filter(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new ye(n,s):(i.key=n,i.value=s),t(i)&&(e.add(i),i=null)}),e.iterator}get count(){return this.j.size}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"MapIterator"}}class Mt{u;g;constructor(t){V.Je(this),this.u=!1,this.g=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.entries()}entries(){return this.g.entries()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Map()#"+V.xs(this)}set(t,e){return this.u&&m.L(this,t),this.g.set(t,e),this}add(t,e){return this.set(t,e)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t instanceof Mt){let e=t.iterator;for(;e.next();)this.g.set(e.key,e.value)}else if(t.first){let e=t.iterator;for(;e.next();){let i=e.value;this.g.set(i.key,i.value)}}else for(let e of t){let i=e;Array.isArray(i)?this.g.set(i[0],i[1]):this.g.set(i.key,i.value)}return this}first(){if(this.g.size===0)return null;let t=this.g.entries().next().value;return t?new ye(t[0],t[1]):null}any(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new ye(i,s):(e.key=i,e.value=s),t(e))return!0;return!1}all(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new ye(i,s):(e.key=i,e.value=s),!t(e))return!1;return!0}each(t){let e=null;for(let[i,s]of this.g)e===null?e=new ye(i,s):(e.key=i,e.value=s),t(e);return this}map(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new ye(s,n):(i.key=s,i.value=n),e.set(s,t(i));return e}filter(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new ye(s,n):(i.key=s,i.value=n),t(i)&&e.set(s,n);return e}has(t){return this.g.has(t)}contains(t){return this.has(t)}get(t){let e=this.g.get(t);return e===void 0?null:e}getValue(t){return this.get(t)}delete(t){return t===null?!1:(this.u&&m.L(this,t),this.g.delete(t))}remove(t){return this.delete(t)}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new Mt;return t.g=new Map(this.g),t}toArray(){let t=this.g,e=new Array(t.size),i=0;for(let s of t)e[i]=new ye(s[0],s[1]),i++;return e}toKeySet(){return new Oi(this)}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new Ln(this)}get iteratorKeys(){return this.count<=0?Pt.instance:new We(this)}keys(){return this.g.keys()}get iteratorValues(){return this.count<=0?Pt.instance:new Tn(this)}values(){return this.g.values()}forEach(t,e){return this.g.forEach(t,e)}}class P{px;py;u;constructor(t,e){t===void 0?(this.px=0,this.py=0):typeof t=="number"&&typeof e=="number"?(this.px=t,this.py=e):m.o("Invalid arguments to Point constructor: "+t+", "+e),this.u=!1}h(t){return this.px=t.px,this.py=t.py,this}e(t,e){return this.px=t,this.py=e,this}setTo(t,e){return this.px=t,this.py=e,this}set(t){return this.px=t.px,this.py=t.py,this}copy(){let t=new P;return t.px=this.px,t.py=this.py,t}kt(){return this.u=!0,Object.freeze(this),this}C(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new P(s,o)}else return new P}static stringify(t){return t.x.toString()+" "+t.y.toString()}static stringifyFixed(t){return m.s(t,"number",P,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof P?this.px===t.x&&this.py===t.y:!1}equalTo(t,e){return this.px===t&&this.py===e}equalsApprox(t){return C.c(this.px,t.x)&&C.c(this.py,t.y)}add(t){return this.px+=t.x,this.py+=t.y,this}subtract(t){return this.px-=t.x,this.py-=t.y,this}offset(t,e){return this.px+=t,this.py+=e,this}rotate(t){if(t===0)return this;let e=this.px,i=this.py;if(e===0&&i===0)return this;let s=0,n=0;if(t=C.Ee(t),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.px=s*e-n*i,this.py=n*e+s*i,this}scale(t,e){return this.px*=t,this.py*=e,this}distanceSquaredPoint(t){let e=t.x-this.px,i=t.y-this.py;return e*e+i*i}distanceSquared(t,e){let i=t-this.px,s=e-this.py;return i*i+s*s}normalize(){let t=this.px,e=this.py,i=Math.sqrt(t*t+e*e);return i>0&&(this.px=t/i,this.py=e/i),this}directionPoint(t){return this.TL(t.x-this.px,t.y-this.py)}direction(t,e){return this.TL(t-this.px,e-this.py)}TL(t,e){if(t===0)return e>0?90:e<0?270:0;if(e===0)return t>0?0:180;{if(isNaN(t)||isNaN(e))return 0;let i=Math.atan(Math.abs(e/t))*180/Math.PI;return t<0?e<0?i+=180:i=180-i:e<0&&(i=360-i),i}}static compareWithLineSegment(t,e,i,s,n,o){return C.ku(t,e,i,s,n,o)}compareWithLineSegmentPoint(t,e){return C.ku(t.x,t.y,e.x,e.y,this.x,this.y)}static intersectingLineSegments(t,e,i,s,n,o,r,a){return C.Pu(t,e,i,s,n,o,r,a)}projectOntoLineSegment(t,e,i,s){return C.Ll(t,e,i,s,this.px,this.py,this),this}projectOntoLineSegmentPoint(t,e){return C.Ll(t.x,t.y,e.x,e.y,this.px,this.py,this),this}snapToGrid(t,e,i,s){return C._g(this.px,this.py,t,e,i,s,this),this}snapToGridPoint(t,e){return C._g(this.px,this.py,t.x,t.y,e.width,e.height,this),this}setRectSpot(t,e){return this.px=t.x+e.x*t.width+e.offsetX,this.py=t.y+e.y*t.height+e.offsetY,this}setSpot(t,e,i,s,n){return this.px=t+n.x*i+n.offsetX,this.py=e+n.y*s+n.offsetY,this}v(t){return t.gt(this),this}Hi(t){return t.Ni(this),this}static distanceLineSegmentSquared(t,e,i,s,n,o){let r=n-i,a=o-s,h=r*r+a*a,l=i-t,u=s-e,c=-l*r-u*a;if(c<=0||c>=h)return r=n-t,a=o-e,Math.min(l*l+u*u,r*r+a*a);{let d=r*u-a*l;return d*d/h}}static distanceSquared(t,e,i,s){let n=i-t,o=s-e;return n*n+o*o}static direction(t,e,i,s){let n=i-t,o=s-e;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.px}set x(t){this.px=t}get y(){return this.py}set y(t){this.py=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static gn=new P(0,0).kt();static DL=new P(-1/0,-1/0).kt();static vL=new P(1/0,1/0).kt();static FL=new P(6,6).kt();static mn=new P(NaN,NaN).kt();static qw=[];static l(){let t=P.qw.pop();return t===void 0?new P:t}static bs(t){let e=P.qw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e){let i=P.qw.pop();return i===void 0?new P(t,e):(i.x=t,i.y=e,i)}static i(t){P.qw.push(t)}}class nt{sw;sh;u;constructor(t,e){t===void 0?(this.sw=0,this.sh=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof e=="number"&&(e>=0||isNaN(e))?(this.sw=t,this.sh=e):m.o("Invalid arguments to Size constructor: "+t+", "+e),this.u=!1}h(t){return this.sw=t.sw,this.sh=t.sh,this}e(t,e){return this.sw=t,this.sh=e,this}setTo(t,e){return this.sw=t,this.sh=e,this}set(t){return this.sw=t.sw,this.sh=t.sh,this}copy(){let t=new nt;return t.sw=this.sw,t.sh=this.sh,t}kt(){return this.u=!0,Object.freeze(this),this}C(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new nt(s,o)}else return new nt}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",nt,"stringifyFixed:digits"),e=>e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof nt?this.sw===t.width&&this.sh===t.height:!1}equalTo(t,e){return this.sw===t&&this.sh===e}equalsApprox(t){return C.c(this.sw,t.width)&&C.c(this.sh,t.height)}inflate(t,e){let i=this.width+t;this.sw=i>=0?i:0;let s=this.height+e;return this.sh=s>=0?s:0,this}get width(){return this.sw}set width(t){t<0&&m.J(t,">= 0",nt,"width"),this.sw=t}get height(){return this.sh}set height(t){t<0&&m.J(t,">= 0",nt,"height"),this.sh=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static xc=new nt(0,0).kt();static CP=new nt(1,1).kt();static RL=new nt(6,6).kt();static Su=new nt(8,8).kt();static OL=new nt(10,10).kt();static NP=new nt(1/0,1/0).kt();static jw=new nt(NaN,NaN).kt();static IL=[];static l(){let t=nt.IL.pop();return t===void 0?new nt:t}static i(t){nt.IL.push(t)}}class I{rx;ry;rw;rh;u;constructor(t,e,i,s){if(t===void 0)this.rx=0,this.ry=0,this.rw=0,this.rh=0;else if(typeof t=="number"&&typeof e=="number"&&typeof i=="number"&&(i>=0||isNaN(i))&&typeof s=="number"&&(s>=0||isNaN(s)))this.rx=t,this.ry=e,this.rw=i,this.rh=s;else if(t instanceof P){let n=t.x,o=t.y;if(e instanceof P){let r=e.x,a=e.y;this.rx=Math.min(n,r),this.ry=Math.min(o,a),this.rw=Math.abs(n-r),this.rh=Math.abs(o-a)}else e instanceof nt?(this.rx=n,this.ry=o,this.rw=e.width,this.rh=e.height):m.o("Incorrect second argument supplied to Rect constructor "+e)}else m.o("Invalid arguments to Rect constructor: "+t+", "+e+", "+i+", "+s);this.u=!1}h(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}e(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}Kn(t,e){return this.rw=t,this.rh=e,this}setTo(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}set(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}setPoint(t){return this.rx=t.x,this.ry=t.y,this}setSize(t){return this.rw=t.width,this.rh=t.height,this}copy(){let t=new I;return t.rx=this.rx,t.ry=this.ry,t.rw=this.rw,t.rh=this.rh,t}kt(){return this.u=!0,Object.freeze(this),this}C(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}ce(){return this.u&&(Object.isFrozen(this)&&m.o("cannot thaw constant: "+this),this.u=!1),this}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),new I(s,o,r,a)}else return new I}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",I,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof I?this.rx===t.x&&this.ry===t.y&&this.rw===t.width&&this.rh===t.height:!1}equalTo(t,e,i,s){return this.rx===t&&this.ry===e&&this.rw===i&&this.rh===s}equalsApprox(t){return C.c(this.rx,t.x)&&C.c(this.ry,t.y)&&C.c(this.rw,t.width)&&C.c(this.rh,t.height)}equalsApproxTo(t,e,i,s){return C.c(this.rx,t)&&C.c(this.ry,e)&&C.c(this.rw,i)&&C.c(this.rh,s)}equalsApproxClose(t){return C.X(this.rx,t.x)&&C.X(this.ry,t.y)&&C.X(this.rw,t.width)&&C.X(this.rh,t.height)}containsPoint(t){return this.rx<=t.x&&this.rx+this.rw>=t.x&&this.ry<=t.y&&this.ry+this.rh>=t.y}containsRect(t){return this.rx<=t.x&&t.x+t.width<=this.rx+this.rw&&this.ry<=t.y&&t.y+t.height<=this.ry+this.rh}contains(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.rx<=t&&t+i<=this.rx+this.rw&&this.ry<=e&&e+s<=this.ry+this.rh}offset(t,e){return this.rx+=t,this.ry+=e,this}inflate(t,e){return this.Ww(e,t,e,t)}addMargin(t){return this.Ww(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.Ww(-t.top,-t.right,-t.bottom,-t.left)}grow(t,e,i,s){return this.Ww(t,e,i,s)}Ww(t,e,i,s){let n=this.rw;e+s<=-n?(this.rx+=n/2,this.rw=0):(this.rx-=s,this.rw+=e+s);let o=this.rh;return t+i<=-o?(this.ry+=o/2,this.rh=0):(this.ry-=t,this.rh+=t+i),this}intersectRect(t){return this.EL(t.x,t.y,t.width,t.height)}intersect(t,e,i,s){return this.EL(t,e,i,s)}EL(t,e,i,s){let n=Math.max(this.rx,t),o=Math.max(this.ry,e),r=Math.min(this.rx+this.rw,t+i),a=Math.min(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=Math.max(0,r-n),this.rh=Math.max(0,a-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,e,i,s){let n=this.rw,o=this.rx;if(n!==1/0&&i!==1/0&&(n+=o,i+=t,isNaN(i)||isNaN(n)||o>i||t>n))return!1;let r=this.rh,a=this.ry;return!(r!==1/0&&s!==1/0&&(r+=a,s+=e,isNaN(s)||isNaN(r)||a>s||e>r))}UL(t,e){let i=this.rw,s=t.width+e+e,n=this.rx,o=t.x-e;if(i+=n,s+=o,n>s||o>i)return!1;let r=this.rh,a=t.height+e+e,h=this.ry,l=t.y-e;return r+=h,a+=l,!(h>a||l>r)}unionPoint(t){return this.re(t.x,t.y,0,0)}unionRect(t){return this.re(t.rx,t.ry,t.rw,t.rh)}union(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.re(t,e,i,s)}re(t,e,i,s){let n=Math.min(this.rx,t),o=Math.min(this.ry,e),r=Math.max(this.rx+this.rw,t+i),a=Math.max(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=r-n,this.rh=a-o,this}setSpot(t,e,i){return this.rx=t-i.offsetX-i.x*this.rw,this.ry=e-i.offsetY-i.y*this.rh,this}nearestSideDirection(t,e){return C.Jw(this,t,e,!0)}nearestSideDirectionPoint(t){return C.Jw(this,t.x,t.y,!0)}static contains(t,e,i,s,n,o,r,a){return r===void 0&&(r=0),a===void 0&&(a=0),t<=n&&n+r<=t+i&&e<=o&&o+a<=e+s}static intersects(t,e,i,s,n,o,r,a){let h=i,l=r,u=t,c=n;if(h+=u,l+=c,u>l||c>h)return!1;let d=s,f=a,p=e,g=o;return d+=p,f+=g,!(p>f||g>d)}static intersectsLineSegment(t,e,i,s,n,o,r,a){return C.VL(t,e,i,s,n,o,r,a)}get x(){return this.rx}set x(t){this.rx=t}get y(){return this.ry}set y(t){this.ry=t}get width(){return this.rw}set width(t){t<0&&m.J(t,">= 0",I,"width"),this.rw=t}get height(){return this.rh}set height(t){t<0&&m.J(t,">= 0",I,"height"),this.rh=t}get left(){return this.rx}set left(t){this.rx=t}get top(){return this.ry}set top(t){this.ry=t}get right(){return this.rx+this.rw}set right(t){this.rx+=t-(this.rx+this.rw)}get bottom(){return this.ry+this.rh}set bottom(t){this.ry+=t-(this.ry+this.rh)}get position(){return new P(this.rx,this.ry)}set position(t){this.rx=t.x,this.ry=t.y}get size(){return new nt(this.rw,this.rh)}set size(t){this.rw=t.width,this.rh=t.height}get center(){return new P(this.rx+this.rw/2,this.ry+this.rh/2)}set center(t){this.rx=t.x-this.rw/2,this.ry=t.y-this.rh/2}get centerX(){return this.rx+this.rw/2}set centerX(t){this.rx=t-this.rw/2}get centerY(){return this.ry+this.rh/2}set centerY(t){this.ry=t-this.rh/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static tm=new I(0,0,0,0).kt();static YF=new I(NaN,NaN,NaN,NaN).kt();static $w=[];static l(){let t=I.$w.pop();return t===void 0?new I:t}static bs(t){let e=I.$w.pop();return e===void 0?t.copy():e.h(t)}static z(t,e,i,s){let n=I.$w.pop();return n===void 0?new I(t,e,i,s):n.e(t,e,i,s)}static i(t){I.$w.push(t)}}class Dt{mt;mr;mb;ml;constructor(t,e,i,s){t===void 0?(this.mt=0,this.mr=0,this.mb=0,this.ml=0):e===void 0?(e=t,i=t,s=t,this.mt=t,this.mr=e,this.mb=i,this.ml=s):i===void 0?(i=t,s=e,this.mt=t,this.mr=e,this.mb=i,this.ml=s):s!==void 0?(this.mt=t,this.mr=e,this.mb=i,this.ml=s):m.o("Invalid arguments to Margin constructor: "+t+", "+e+", "+i+", "+s)}setTo(t,e,i,s){return this.mt=t,this.mr=e,this.mb=i,this.ml=s,this}set(t){return this.mt=t.mt,this.mr=t.mr,this.mb=t.mb,this.ml=t.ml,this}copy(){let t=new Dt;return t.mt=this.mt,t.mr=this.mr,t.mb=this.mb,t.ml=this.ml,t}kt(){return Object.freeze(this),this}C(){return Object.isFrozen(this)?this:this.copy().kt()}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=NaN;for(;e[i]==="";)i++;let n=e[i++];if(n&&(s=parseFloat(n)),isNaN(s))return new Dt;let o=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(o=parseFloat(n)),isNaN(o))return new Dt(s);let r=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(r=parseFloat(n)),isNaN(r))return new Dt(s,o);let a=NaN;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),isNaN(a)?new Dt(s,o):new Dt(s,o,r,a)}else return new Dt}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return m.s(t,"number",Dt,"stringifyFixed:digits"),e=>e.top.toFixed(t)+" "+e.right.toFixed(t)+" "+e.bottom.toFixed(t)+" "+e.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Dt?this.mt===t.top&&this.mr===t.right&&this.mb===t.bottom&&this.ml===t.left:!1}equalTo(t,e,i,s){return this.mt===t&&this.mr===e&&this.mb===i&&this.ml===s}equalsApprox(t){return C.c(this.mt,t.top)&&C.c(this.mr,t.right)&&C.c(this.mb,t.bottom)&&C.c(this.ml,t.left)}get top(){return this.mt}set top(t){this.mt=t}get right(){return this.mr}set right(t){this.mr=t}get bottom(){return this.mb}set bottom(t){this.mb=t}get left(){return this.ml}set left(t){this.ml=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static em=new Dt(0,0,0,0).kt();static BL=new Dt(2,2,2,2).kt()}class T{sx;sy;ox;oy;constructor(t,e,i,s){t===void 0?(this.sx=0,this.sy=0,this.ox=0,this.oy=0):(e===void 0&&(e=0),i===void 0&&(i=0),s===void 0&&(s=0),this.sx=t,this.sy=e,this.ox=i,this.oy=s)}setTo(t,e,i,s){return this.sx=t,this.sy=e,this.ox=i,this.oy=s,this}set(t){return this.sx=t.sx,this.sy=t.sy,this.ox=t.ox,this.oy=t.oy,this}copy(){let t=new T;return t.sx=this.sx,t.sy=this.sy,t.ox=this.ox,t.oy=this.oy,t}kt(){return Object.freeze(this),this}C(){return Object.isFrozen(this)?this:this.copy().kt()}Hw(t){}qi(t){return this.sx=NaN,this.sy=NaN,this.ox=t,this.kt()}vU(t,e){(isNaN(t)||t>1||t<0)&&m.J(t,"0 <= "+e+" <= 1",T,e)}FU(t,e){(isNaN(t)||t===1/0||t===-1/0)&&m.J(t,"real number, not NaN or Infinity",T,e)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return T.None;if(t==="TopLeft")return T.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return T.TopCenter;if(t==="TopRight")return T.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return T.LeftCenter;if(t==="Center")return T.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return T.RightCenter;if(t==="BottomLeft")return T.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return T.BottomCenter;if(t==="BottomRight")return T.BottomRight;if(t==="TopSide")return T.TopSide;if(t==="LeftSide")return T.LeftSide;if(t==="RightSide")return T.RightSide;if(t==="BottomSide")return T.BottomSide;if(t==="TopBottomSides")return T.TopBottomSides;if(t==="LeftRightSides")return T.LeftRightSides;if(t==="TopLeftSides")return T.TopLeftSides;if(t==="TopRightSides")return T.TopRightSides;if(t==="BottomLeftSides")return T.BottomLeftSides;if(t==="BottomRightSides")return T.BottomRightSides;if(t==="NotTopSide")return T.NotTopSide;if(t==="NotLeftSide")return T.NotLeftSide;if(t==="NotRightSide")return T.NotRightSide;if(t==="NotBottomSide")return T.NotBottomSide;if(t==="AllSides")return T.AllSides;if(t==="Default")return T.Default;let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n!==void 0&&n.length>0&&(a=parseFloat(n)),new T(s,o,r,a)}else return new T}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return m.s(t,"number",T,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.offsetX.toFixed(t)+" "+e.offsetY.toFixed(t)}toString(){return this.isSpot()?this.ox===0&&this.oy===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(T.None)?"None":this.equals(T.TopLeft)?"TopLeft":this.equals(T.TopCenter)?"Top":this.equals(T.TopRight)?"TopRight":this.equals(T.LeftCenter)?"Left":this.equals(T.Center)?"Center":this.equals(T.RightCenter)?"Right":this.equals(T.BottomLeft)?"BottomLeft":this.equals(T.BottomCenter)?"Bottom":this.equals(T.BottomRight)?"BottomRight":this.equals(T.TopSide)?"TopSide":this.equals(T.LeftSide)?"LeftSide":this.equals(T.RightSide)?"RightSide":this.equals(T.BottomSide)?"BottomSide":this.equals(T.TopBottomSides)?"TopBottomSides":this.equals(T.LeftRightSides)?"LeftRightSides":this.equals(T.TopLeftSides)?"TopLeftSides":this.equals(T.TopRightSides)?"TopRightSides":this.equals(T.BottomLeftSides)?"BottomLeftSides":this.equals(T.BottomRightSides)?"BottomRightSides":this.equals(T.NotTopSide)?"NotTopSide":this.equals(T.NotLeftSide)?"NotLeftSide":this.equals(T.NotRightSide)?"NotRightSide":this.equals(T.NotBottomSide)?"NotBottomSide":this.equals(T.AllSides)?"AllSides":this.equals(T.Default)?"Default":"None"}equals(t){return t instanceof T?(this.sx===t.x||isNaN(this.sx)&&isNaN(t.x))&&(this.sy===t.y||isNaN(this.sy)&&isNaN(t.y))&&this.ox===t.offsetX&&this.oy===t.offsetY:!1}opposite(){return new T(.5-(this.sx-.5),.5-(this.sy-.5),-this.ox,-this.oy)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(T.Left))t=T.LeftSide;else if(t.equals(T.Right))t=T.RightSide;else if(t.equals(T.Top))t=T.TopSide;else if(t.equals(T.Bottom))t=T.BottomSide;else return!1;let e=this.oy,i=t.offsetY;return(e&i)===i}get x(){return this.sx}set x(t){this.sx=t}get y(){return this.sy}set y(t){this.sy=t}get offsetX(){return this.ox}set offsetX(t){this.ox=t}get offsetY(){return this.oy}set offsetY(t){this.oy=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new T(0,0,0,0).qi(0);static Default=new T(0,0,-1,0).qi(-1);static TopLeft=new T(0,0,0,0).kt();static TopCenter=new T(.5,0,0,0).kt();static TopRight=new T(1,0,0,0).kt();static LeftCenter=new T(0,.5,0,0).kt();static Center=new T(.5,.5,0,0).kt();static RightCenter=new T(1,.5,0,0).kt();static BottomLeft=new T(0,1,0,0).kt();static BottomCenter=new T(.5,1,0,0).kt();static BottomRight=new T(1,1,0,0).kt();static MiddleTop=T.TopCenter;static MiddleLeft=T.LeftCenter;static MiddleRight=T.RightCenter;static MiddleBottom=T.BottomCenter;static Top=T.TopCenter;static Left=T.LeftCenter;static Right=T.RightCenter;static Bottom=T.BottomCenter;static TopSide=new T(0,0,1,1).qi(1);static LeftSide=new T(0,0,1,2).qi(1);static RightSide=new T(0,0,1,4).qi(1);static BottomSide=new T(0,0,1,8).qi(1);static TopBottomSides=new T(0,0,1,9).qi(1);static LeftRightSides=new T(0,0,1,6).qi(1);static TopLeftSides=new T(0,0,1,3).qi(1);static TopRightSides=new T(0,0,1,5).qi(1);static BottomLeftSides=new T(0,0,1,10).qi(1);static BottomRightSides=new T(0,0,1,12).qi(1);static NotTopSide=new T(0,0,1,14).qi(1);static NotLeftSide=new T(0,0,1,13).qi(1);static NotRightSide=new T(0,0,1,11).qi(1);static NotBottomSide=new T(0,0,1,7).qi(1);static AllSides=new T(0,0,1,15).qi(1);static LP=new T(.156,.156).kt();static AP=new T(.844,.844).kt()}class Nt{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,e,i,s,n,o){return this.m11=t,this.m12=e,this.m21=i,this.m22=s,this.dx=n,this.dy=o,this}copy(){let t=new Nt;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}TP(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ue(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}bc(t){let e=this.m11*t.m11+this.m21*t.m12,i=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=e,this.m12=i,this.m21=s,this.m22=n,this}zL(t){let e=1/(t.m11*t.m22-t.m12*t.m21),i=t.m22*e,s=-t.m12*e,n=-t.m21*e,o=t.m11*e,r=e*(t.m21*t.dy-t.m22*t.dx),a=e*(t.m12*t.dx-t.m11*t.dy),h=this.m11*i+this.m21*s,l=this.m12*i+this.m22*s,u=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*a+this.dx,this.dy=this.m12*r+this.m22*a+this.dy,this.m11=h,this.m12=l,this.m21=u,this.m22=c,this}Zw(){let t=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*t,i=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=e,this.m12=i,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ks(t,e,i){if(t=C.Ee(t),t===0)return this;this.Gs(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,a=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=a,this.m22=h,this.Gs(-e,-i),this}Gs(t,e){return this.dx+=this.m11*t+this.m21*e,this.dy+=this.m12*t+this.m22*e,this}et(t,e){return e===void 0&&(e=t),this.m11*=t,this.m12*=t,this.m21*=e,this.m22*=e,this}KF(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}gt(t){let e=t.x,i=t.y;return t.e(e*this.m11+i*this.m21+this.dx,e*this.m12+i*this.m22+this.dy)}Ni(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=t.x-this.dx,a=t.y-this.dy;return t.e(r*i+a*n,r*s+a*o)}Mu(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=e*(this.m21*this.dy-this.m22*this.dx),a=e*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,l=t.y*1.2;return t.e(h*i+l*n+r,h*s+l*o+a)}im(t){let e=t.x,i=t.y,s=e+t.width,n=i+t.height,o=this.m11,r=this.m12,a=this.m21,h=this.m22,l=this.dx,u=this.dy,c=e*o+i*a+l,d=e*r+i*h+u,f=s*o+i*a+l,p=s*r+i*h+u,g=e*o+n*a+l,y=e*r+n*h+u,b=s*o+n*a+l,v=s*r+n*h+u,w=c,k=c,S=d,N=d;return w=Math.min(w,f),k=Math.max(k,f),S=Math.min(S,p),N=Math.max(N,p),w=Math.min(w,g),k=Math.max(k,g),S=Math.min(S,y),N=Math.max(N,y),w=Math.min(w,b),k=Math.max(k,b),S=Math.min(S,v),N=Math.max(N,v),t.e(w,S,k-w,N-S),t}static XL=[];static l(){let t=Nt.XL.pop();return t===void 0?new Nt:t}static i(t){Nt.XL.push(t)}static DP="54a702f3e53909c447824c6706603faf4c"}let C={HF:"7da71ca0ad381e90",Hn:4*((Math.sqrt(2)-1)/3),GL:[],Qw:x=>{if(x<=0)return 0;let t=C.GL;if(t===null){t=[];for(let e=0;e<=2e3;e++)t[e]=Math.sqrt(e);C.GL=t}if(x<1){let e=1/x;return e<=2e3?1/t[e|0]:Math.sqrt(x)}else return x<=2e3?t[x|0]:Math.sqrt(x)},c:(x,t)=>{let e=x-t;return e<.5&&e>-.5},X:(x,t)=>{let e=x-t;return e<5e-8&&e>-5e-8},Ve:(x,t,e,i,s,n,o)=>{s<=0&&(s=1e-6);let r=0,a=0,h=0,l=0;if(x<e?(a=x,r=e):(a=e,r=x),t<i?(l=t,h=i):(l=i,h=t),x===e)return l<=o&&o<=h&&x-s<=n&&n<=x+s;if(t===i)return a<=n&&n<=r&&t-s<=o&&o<=t+s;let u=r+s,c=a-s;if(c<=n&&n<=u){let d=h+s,f=l-s;if(f<=o&&o<=d)if(u-c>d-f)if(x-e>s||e-x>s){let p=(i-t)/(e-x)*(n-x)+t;if(p-s<=o&&o<=p+s)return!0}else return!0;else if(t-i>s||i-t>s){let p=(e-x)/(i-t)*(o-t)+x;if(p-s<=n&&n<=p+s)return!0}else return!0}return!1},_w:(x,t,e,i,s,n,o,r,a,h,l,u)=>{if(!C.Ve(x,t,o,r,u,e,i)||!C.Ve(x,t,o,r,u,s,n)){let c=(x+e)/2,d=(t+i)/2,f=(e+s)/2,p=(i+n)/2,g=(s+o)/2,y=(n+r)/2,b=(c+f)/2,v=(d+p)/2,w=(f+g)/2,k=(p+y)/2,S=(b+w)/2,N=(v+k)/2;return C._w(x,t,c,d,b,v,S,N,a,h,l,u)||C._w(S,N,w,k,g,y,o,r,a,h,l,u)}else return C.Ve(x,t,o,r,u,h,l)},YL:(x,t,e,i,s,n,o,r,a)=>{let h=(x+e)/2,l=(t+i)/2,u=(e+s)/2,c=(i+n)/2,d=(s+o)/2,f=(n+r)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2;return a.e((p+y)/2,(g+b)/2),a},qF:(x,t,e,i,s,n,o,r)=>{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(s+o)/2,d=(n+r)/2,f=(a+l)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2;return P.direction(f,p,g,y)},Cu:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.Cu(x,t,l,u,g,y,w,k,a,h),C.Cu(w,k,b,v,f,p,o,r,a,h)}else h.re(x,t,0,0),h.re(o,r,0,0);return h},qn:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.qn(x,t,l,u,g,y,w,k,a,h),C.qn(w,k,b,v,f,p,o,r,a,h)}else h.length===0&&(h.push(x),h.push(t)),h.push(o),h.push(r);return h},vP:(x,t,e,i,s,n,o,r,a,h)=>{if(C.Ve(x,t,s,n,h,e,i))return C.Ve(x,t,s,n,h,r,a);{let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(l+c)/2,p=(u+d)/2;return C.vP(x,t,l,u,f,p,o,r,a,h)||C.vP(f,p,c,d,s,n,o,r,a,h)}},FP:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.re(x,t,0,0),r.re(s,n,0,0);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.FP(x,t,a,h,c,d,o,r),C.FP(c,d,l,u,s,n,o,r)}return r},sm:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.length===0&&(r.push(x),r.push(t)),r.push(s),r.push(n);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.sm(x,t,a,h,c,d,o,r),C.sm(c,d,l,u,s,n,o,r)}return r},nm:(x,t,e,i,s,n,o,r,a,h,l,u,c,d)=>{if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2,M=1/0,A=!1,F=0,O=0;if(C.nm(x,t,f,p,w,k,D,L,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}if(C.nm(D,L,S,N,b,v,o,r,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}return A&&(d.x=F,d.y=O),A}else{if(!C.Pu(x,t,o,r,a,h,l,u))return!1;let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return!1;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;return d.e(p,g),!0}},om:(x,t,e,i,s,n,o,r,a,h,l,u,c)=>{let d=0;if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2;d+=C.om(x,t,f,p,w,k,D,L,a,h,l,u,c),d+=C.om(D,L,S,N,b,v,o,r,a,h,l,u,c)}else{let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return d;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;if(p>=l)return d;let y=0,b=0;if((a>l?a-l:l-a)<(h>u?h-u:u-h)){if(t<r?(y=t,b=r):(y=r,b=t),g<y||g>b)return d}else if(x<o?(y=x,b=o):(y=o,b=x),p<y||p>b)return d;f>0?d++:f<0&&d--}return d},Ll:(x,t,e,i,s,n,o)=>{if(C.X(x,e)){let r=0,a=0;t<i?(r=t,a=i):(r=i,a=t);let h=n;return h<r?(o.e(x,r),!1):h>a?(o.e(x,a),!1):(o.e(x,h),!0)}else if(C.X(t,i)){let r=0,a=0;x<e?(r=x,a=e):(r=e,a=x);let h=s;return h<r?(o.e(r,t),!1):h>a?(o.e(a,t),!1):(o.e(h,t),!0)}else{let r=(e-x)**2+(i-t)**2,a=((x-s)*(x-e)+(t-n)*(t-i))/r;if(a<-5e-6)return o.e(x,t),!1;if(a>1.000005)return o.e(e,i),!1;{let h=x+a*(e-x),l=t+a*(i-t);return o.e(h,l),!0}}},Do:(x,t,e,i,s,n,o,r,a)=>{if(C.c(x,e)&&C.c(t,i))return a.e(x,t),!1;if(C.X(s,o)){if(C.X(x,e))return C.Ll(x,t,e,i,s,n,a),!1;{let h=(i-t)/(e-x)*(s-x)+t;return C.Ll(x,t,e,i,s,h,a)}}else{let h=(r-n)/(o-s);if(C.X(x,e)){let l=h*(x-s)+n,u=0,c=0;return t<i?(u=t,c=i):(u=i,c=t),l<u?(a.e(x,u),!1):l>c?(a.e(x,c),!1):(a.e(x,l),!0)}else{let l=(i-t)/(e-x);if(C.X(h,l))return C.Ll(x,t,e,i,s,n,a),!1;{let u=(l*x-h*s+n-t)/(l-h);if(C.X(l,0)){let c=0,d=0;return x<e?(c=x,d=e):(c=e,d=x),u<c?(a.e(c,t),!1):u>d?(a.e(d,t),!1):(a.e(u,t),!0)}else{let c=l*(u-x)+t;return C.Ll(x,t,e,i,u,c,a)}}}}},Al:(x,t,e,i,s,n,o,r,a)=>{let h=1e21,l=x,u=t;if(C.Do(x,t,x,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Do(e,t,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Do(x,t,e,t,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Do(x,i,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}return a.e(l,u),h<1e21},tx:(x,t,e)=>C.VL(x.x,x.y,x.width,x.height,t.x,t.y,e.x,e.y),VL:(x,t,e,i,s,n,o,r)=>{let a=x,h=x+e,l=t,u=t+i;if(s===o){let c=0,d=0;return n<r?(c=n,d=r):(c=r,d=n),a<=s&&s<=h&&c<=u&&d>=l}if(n===r){let c=0,d=0;return s<o?(c=s,d=o):(c=o,d=s),l<=n&&n<=u&&c<=h&&d>=a}return!!(I.contains(x,t,e,i,s,n)||I.contains(x,t,e,i,o,r)||C.Pu(a,l,h,l,s,n,o,r)||C.Pu(h,l,h,u,s,n,o,r)||C.Pu(h,u,a,u,s,n,o,r)||C.Pu(a,u,a,l,s,n,o,r))},Pu:(x,t,e,i,s,n,o,r)=>x===e&&t===i&&s===o&&n===r?x===s&&t===n:C.ku(x,t,e,i,s,n)*C.ku(x,t,e,i,o,r)<=0&&C.ku(s,n,o,r,x,t)*C.ku(s,n,o,r,e,i)<=0,ku:(x,t,e,i,s,n)=>{let o=e-x,r=i-t,a=s-x,h=n-t,l=a*r-h*o;return l===0&&(l=a*o+h*r,l>0&&(a-=o,h-=r,l=a*o+h*r,l<0&&(l=0))),l},Jw(x,t,e,i){i===void 0&&(i=!1);let s=0,n=x===null?t:(t-x.x)/(x.width>0?x.width:1),o=x===null?e:(e-x.y)/(x.height>0?x.height:1);return n>o?n>1-o||(i||n<1-o?s=270:s=315):i||n<o?n>1-o?s=90:i||n<1-o?s=180:s=135:n<.5?s=225:n>.5&&(s=45),s},Ee:x=>(x>=360?x-=360:x<0&&(x+=360),x),jF:(x,t)=>x>t?Math.min(x-t,Math.abs(x-360-t)):t>x?Math.min(t-x,Math.abs(x-(t-360))):0,KL:(x,t,e,i,s,n)=>{let o=Math.PI;n||(i=i*(o/180),s=s*(o/180));let r=i>s?-1:1,a=1e-5,h=o*2,l=[],u=o/2,c=i,d=Math.min(h,Math.abs(s-i));if(d<a){let f=c+r*Math.min(d,u),p=x+e*Math.cos(c),g=t+e*Math.sin(c),y=x+e*Math.cos(f),b=t+e*Math.sin(f),v=(p+y)/2,w=(g+b)/2;return l.push([p,g,v,w,v,w,y,b]),l}for(;d>a;){let f=c+r*Math.min(d,u);l.push(C.WF(e,c,f,x,t)),d-=Math.abs(f-c),c=f}return l},WF:(x,t,e,i,s)=>{let n=(e-t)/2,o=x*Math.cos(n),r=x*Math.sin(n),a=o,h=-r,l=a*a+h*h,u=l+a*o+h*r,c=4/3*(Math.sqrt(2*l*u)-u)/(a*r-h*o),d=a-c*h,f=h+c*a,p=d,g=-f,y=n+t,b=Math.cos(y),v=Math.sin(y);return[i+x*Math.cos(t),s+x*Math.sin(t),i+d*b-f*v,s+d*v+f*b,i+p*b-g*v,s+p*v+g*b,i+x*Math.cos(e),s+x*Math.sin(e)]},_g:(x,t,e,i,s,n,o)=>{let r=s,a=n,h=Math.floor((x-e)/r)*r+e,l=Math.floor((t-i)/a)*a+i,u=h;h+r-x<r/2&&(u=h+r);let c=l;return l+a-t<a/2&&(c=l+a),o.e(u,c),o},HL:(x,t)=>{let e=Math.max(x,t),i=Math.min(x,t),s=1,n=1;do s=e%i,n=i,e=i,i=s;while(s>0);return n},JF:(x,t,e,i)=>{let s=e<0,n=i<0,o=0,r=0,a=0;x<t?(r=1,a=0):(r=0,a=1);let h=0,l=0,u=0,c=0;return o=r,h=o===0?x:t,u=o===0?e:i,(o===0?s:n)&&(u=-u),o=a,l=o===0?x:t,c=o===0?e:i,(o===0?s:n)&&(c=-c),C.$F(h,l,u,c,0,0)},$F:(x,t,e,i,s,n)=>{let o=0;if(i>0)if(e>0){let r=x*x,a=t*t,h=x*e,l=t*i,u=-a+l,c=-a+Math.sqrt(h*h+l*l),d=u,f=9999999999;for(let y=0;y<f&&(d=.5*(u+c),!(d===u||d===c));++y){let b=h/(d+r),v=l/(d+a),w=b*b+v*v-1;if(w>0)u=d;else if(w<0)c=d;else break}s=r*e/(d+r),n=a*i/(d+a);let p=s-e,g=n-i;o=Math.sqrt(p*p+g*g)}else s=0,n=t,o=Math.abs(i-t);else{let r=x*x-t*t,a=x*e;if(a<r){let h=a/r,l=h*h;s=x*h,n=t*Math.sqrt(Math.abs(1-l));let u=s-e;o=Math.sqrt(u*u+n*n)}else s=x,n=0,o=Math.abs(e-x)}return o},jn:{},rm:new yt,pr:new yt,yr:0,lm:100};C.za=C.HF;var Ve=(x=>(x[x.Line=1]="Line",x[x.Rectangle=2]="Rectangle",x[x.Ellipse=3]="Ellipse",x[x.Path=4]="Path",x))(Ve||{}),Ri=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x))(Ri||{});class wt{n;am;hm;kc;Nu;Lu;Wn;Jn;$n;W;Li;Ai;ni;oi;Ys;Pc;Sc;constructor(t,e){V.Je(this),this.n=2,t===void 0&&(t=4),this.W=t,this.Li=0,this.Ai=0,this.ni=0,this.oi=0,t===4?this.Ys=new q:this.Ys=wt.ex,this.am=this.Ys.rt,this.hm=new I,this.kc=null,this.Nu=null,this.Lu=NaN,this.Wn=T.TopLeft,this.Jn=T.BottomRight,this.Pc=NaN,this.Sc=NaN,this.$n=2,e&&Object.assign(this,e)}copy(){let t=new wt;if(t.n=this.n&-2,t.W=this.W,t.Li=this.Li,t.Ai=this.Ai,t.ni=this.ni,t.oi=this.oi,this.W===4){let e=this.Ys.r,i=t.Ys;for(let s=0;s<e.length;s++){let n=e[s];i.add(n.copy())}t.Ys=i}else t.Ys=this.Ys;return t.am=this.am,t.hm.h(this.hm),t.kc=this.kc,t.Nu=this.Nu,t.Lu=this.Lu,t.Wn=this.Wn.C(),t.Jn=this.Jn.C(),t.Pc=this.Pc,t.Sc=this.Sc,t.$n=this.$n,t}static Line=1;static Rectangle=2;static Ellipse=3;static Path=4;static ex=new q().k();get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){if(this.u=!0,this.type!==4)return this;let t=this.figures;t.k();for(let e of t)e.k();return this}equalsApprox(t){if(!(t instanceof wt))return!1;if(this.type!==t.type)return this.type===1&&t.type===4?this.qL(t):t.type===1&&this.type===4?t.qL(this):!1;if(this.type===4){let e=this.figures.r,i=t.figures.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}else return C.c(this.startX,t.startX)&&C.c(this.startY,t.startY)&&C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)}qL(t){if(this.type!==1||t.type!==4)return!1;if(t.figures.count===1){let e=t.figures.elt(0);if(e.segments.count===1&&C.c(this.startX,e.startX)&&C.c(this.startY,e.startY)){let i=e.segments.elt(0);if(i.type===2&&C.c(this.endX,i.endX)&&C.c(this.endY,i.endY))return!0}}return!1}static stringify(t){return t.toString()}static stringifyFixed(t){return m.s(t,"number",wt,"stringifyFixed:digits"),e=>e.toString(t)}fe(t){t in Ve?this.type=t:m.ur(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+e(this.startX)+" "+e(this.startY)+"L"+e(this.endX)+" "+e(this.endY);case 2:return i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0?"M"+i.x.toString()+" "+i.y.toString()+"H"+i.right.toString()+"V"+i.bottom.toString()+"H"+i.left.toString()+"z":"M"+e(i.x)+" "+e(i.y)+"H"+e(i.right)+"V"+e(i.bottom)+"H"+e(i.left)+"z";case 3:if(i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0){let r=i.left.toString()+" "+(i.y+i.height/2).toString(),a=i.right.toString()+" "+(i.y+i.height/2).toString();return"M"+r+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+a+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+r}else{let r=e(i.left)+" "+e(i.y+i.height/2),a=e(i.right)+" "+e(i.y+i.height/2);return"M"+r+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+a+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+r}case 4:let s="",n=this.figures.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];r>0&&(s+=" x "),a.isFilled&&(s+="F "),s+=a.toString(t)}return s;default:return Ve[this.type]}}static fillPath(t){typeof t!="string"&&m.si(t,"string",wt,"fillPath:str");let e=t.split(/[Xx]/),i=e.length,s="";for(let n=0;n<i;n++){let o=e[n];if(o.match(/[Ff]/)!==null){n===0?s+=o:s+="X"+(o[0]===" "?"":" ")+o;continue}s+=(n===0?"":"X ")+"F"+(o[0]===" "?"":" ")+o}return s}static cm="UuBbMmZzLlHhVvCcSsQqTtAaFfXx";static parse(t,e){e===void 0&&(e=!1),typeof t!="string"&&m.si(t,"string",wt,"parse:str");let i=new RegExp("(["+wt.cm+"])(["+wt.cm+"])","gm"),s=new RegExp("(["+wt.cm+"])([^s])","gm"),n=new RegExp("([^s])(["+wt.cm+"])","gm");t=t.replace(/,/gm," "),t=t.replace(i,"$1 $2"),t=t.replace(i,"$1 $2"),t=t.replace(s,"$1 $2"),t=t.replace(n,"$1 $2"),t=t.replace(/([0-9])([+\-])/gm,"$1 $2"),t=t.replace(/[\s\r\t\n]+/gm," "),t=t.replace(/^\s+|\s+$/g,"");let o=t.split(" ");for(let F=0;F<o.length;F++){let O=o[F];if(O.match(/(\.[0-9]*)(\.)/gm)!==null){let E=m.st(),B="",X=!1;for(let z=0;z<O.length;z++){let U=O[z];U==="."&&!X?(X=!0,B+=U):U==="."?(E.push(B),B="."):B+=U}E.push(B),o.splice(F,1);for(let z=0;z<E.length;z++)o.splice(F+z,0,E[z]);F+=E.length-1,m.Z(E)}}let r=-1,a="",h="",l=new P(0,0),u=new P(0,0),c=new P(0,0),d=!0;function f(){return r>=w-1||o[r+1].match(M)!==null?!0:(d=!1,!1)}function p(){return r++,o[r]}function g(F){let O=parseFloat(p()),E=parseFloat(p());a===a.toLowerCase()&&(O=c.x+O,E=c.y+E),F.e(O,E)}function y(){return g(c),c}function b(){return g(u),u}function v(){let F=h.toLowerCase();return F==="c"||F==="s"||F==="q"||F==="t"?new P(2*c.x-u.x,2*c.y-u.y):new P(c.x,c.y)}let w=o.length,k=Ne.jL(null),S=!1,N=!1,D=!1,L=!0,M=new RegExp("["+wt.cm+"]");for(;!(r>=w-1);){if(h=a,a=p(),a==="")continue;d=!0;let F=!1;switch(a.toUpperCase()){case"X":L=!0,S=!1,N=!1;break;case"M":let O=y();for(k.Ne===null||L===!0?(k.Au(O.x,O.y,S,!1,!N,D),L=!1):k.ZF(O.x,O.y),l.h(c);!f();){let E=y();k.Ks(E.x,E.y)}break;case"L":for(;!f();){let E=y();k.Ks(E.x,E.y)}d&&(F=!0);break;case"H":for(;!f();)c.e((a===a.toLowerCase()?c.x:0)+parseFloat(p()),c.y),k.Ks(c.x,c.y);break;case"V":for(;!f();)c.e(c.x,(a===a.toLowerCase()?c.y:0)+parseFloat(p())),k.Ks(c.x,c.y);d&&(F=!0);break;case"C":for(;!f();){let E=new P;g(E);let B=b(),X=y();k.wr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"S":for(;!f();){let E=v(),B=b(),X=y();k.wr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"Q":for(;!f();){let E=b(),B=y();k.Tu(E.x,E.y,B.x,B.y)}d&&(F=!0);break;case"T":for(;!f();){let E=v();u.h(E);let B=y();k.Tu(E.x,E.y,B.x,B.y),u.h(B)}d&&(F=!0);break;case"B":for(;!f();){let E=parseFloat(p()),B=parseFloat(p()),X=parseFloat(p()),z=parseFloat(p()),U=parseFloat(p()),tt=U,st=!1;f()||(tt=parseFloat(p()),f()||(st=parseFloat(p())!==0)),a===a.toLowerCase()&&(X+=c.x,z+=c.y),k.QF(E,B,X,z,U,tt,st)}d&&(F=!0);break;case"A":for(;!f();){let E=Math.abs(parseFloat(p())),B=Math.abs(parseFloat(p())),X=parseFloat(p()),z=!1,U=!1,tt=0,st=0,Z=p();Z.length===1?(z=!!parseFloat(Z),U=!!parseFloat(p()),tt=parseFloat(p()),st=parseFloat(p())):Z.length===2?(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(p()),st=parseFloat(p())):(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(Z.slice(2)),st=parseFloat(p())),a===a.toLowerCase()&&(tt=c.x+tt,st=c.y+st),c.e(tt,st),k._F(E,B,X,z,U,tt,st)}d&&(F=!0);break;case"Z":k.tR(),c.h(l);break;case"F":{let E="",B=1;for(;o[r+B];){if(o[r+B]==="0"){D=!0,B++;continue}if(o[r+B].match(/[Uu]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?S=!0:k.eR();break}case"U":{let E="",B=1;for(;o[r+B];){if(o[r+B].match(/[Ff]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?N=!0:k.iR(!1);break}default:if(a==="0"||a==="1")break;m.ne("Unknown geometry command: "+a);break}if(F){m.ne(`Bad geometry command: ${a}, next token: ${p()},
|
|
2
|
+
import{b as un}from"./KCEVE53E.js";import"./ZBET72YB.js";import"./2B4SGB3I.js";import"./YKQDHR27.js";import{a as ln}from"./R67EKKSL.js";import"./BVWAUO73.js";import"./K3DQKY7V.js";import{b as hn}from"./KIUBUHVM.js";import{E as ms,F as ps,G as an,h as on,i as rn}from"./H5E6ISYP.js";import"./QPIMTXPL.js";(function(){let K=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};K.requestAnimationFrame===void 0&&(K.setImmediate===void 0?K.requestAnimationFrame=x=>K.setTimeout(x,0):K.requestAnimationFrame=K.setImmediate);class m{static fr=K.navigator!==void 0&&K.navigator.platform!==void 0&&K.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static PP(t,e,i){let s=-1;return function(){let n=this,o=arguments;s!==-1&&m.yc(s),s=m.dn(()=>{s=-1,i||t.apply(n,o)},e),i&&!s&&t.apply(n,o)}}static dn(t,e){return K.setTimeout(t,e)}static yc(t){K.clearTimeout(t)}static Ci(t){return K.document.createElement(t)}static o(t){throw new Error(t)}static L(t,e){let i="The object is frozen, so its properties cannot be set: "+t.toString();e!==void 0&&(i+=" to value: "+e),m.o(i)}static se(t,e,i,s){}static s(t,e,i,s){}static LU(t,e,i){}static wc(t,e,i){if(t===null||typeof t!="object"){let s=m.LL(e);i!==void 0&&(s+="."+i),m.si(t,"object",s)}}static S(t,e,i){m.s(t,"function",e,i)}static AU(t,e,i){}static si(t,e,i,s){}static J(t,e,i,s){let n=m.LL(i);s!==void 0&&(n+="."+s),m.o(n+" is not in the range "+e+": "+t)}static Yi(t){}static ur(t,e){}static ne(t){K.console&&K.console.log(t)}static $(t){return t!==null&&typeof t=="object"}static it(t){return typeof t=="function"}static SP=[];static st(){let t=m.SP.pop();return t===void 0?[]:t}static Z(t){t.length=0,m.SP.push(t)}static TU=Object.freeze([]);static LL(t){return t===null?"*":typeof t=="string"?t:m.it(t)?t.name:""}static Yn(t){return m.it(t)?t.className?t.className:t.name:m.$(t)&&t.constructor?m.Yn(t.constructor):typeof t}static Ja(t,e){return e==null||e===""?null:m.$(t)&&e in t||t[e]?t[e]:null}static toString(t){let e=t;return m.$(t)&&(t.text?e=t.text:t.name?e=t.name:t.key!==void 0?e=t.key:t.id!==void 0?e=t.id:t.constructor===Object&&(t.Text?e=t.Text:t.Name?e=t.Name:t.Key!==void 0?e=t.Key:t.Id!==void 0?e=t.Id:t.ID!==void 0&&(e=t.ID))),e===void 0?"undefined":e===null?"null":e.toString()}static Gw(t,e){if(t.hasOwnProperty(e))return!0;let i=Object.getPrototypeOf(t);for(;i&&i!==Function;){if(i.hasOwnProperty(e))return!0;let s=i.DU;if(s&&s[e])return!0;i=Object.getPrototypeOf(i)}return!1}static XF(t){let e=[],i=0;for(i=0;i<256;i++)e[i]=i;let s=0,n=0;for(i=0;i<256;i++)s=(s+e[i]+119)%256,n=e[i],e[i]=e[s],e[s]=n;i=0,s=0;let o="";for(let r=0;r<t.length;r++)i=(i+1)%256,s=(s+e[i])%256,n=e[i],e[i]=e[s],e[s]=n,o+=String.fromCharCode(t.charCodeAt(r)^e[(e[i]+e[s])%256]);return o}static GF(t){let e="0123456789abcdef",i=[];for(let r=0;r<256;r++)i[e.charAt(r>>4)+e.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);let s=[],n=0;for(let r=0;r<t.length;r+=2)s[n++]=i[t.substring(r,r+2)];let o=s.join("");return o===""?"0":o}static We(t){return m.XF(m.GF(t))}static color1="@COLOR1";static color2="@COLOR2";static Yw="32ab5ff3b26f42dc0ed90f21422913b5"}m.vfo="29e647fdba";class at{MP;constructor(){this.MP=[]}toString(){return this.MP.join("")}add(t){t!==""&&this.MP.push(t)}}class yt{}class Pt{g;constructor(){this.g=[]}[Symbol.iterator](){return this.g.values()}key;value;get iterator(){return this}reset(){}next(){return!1}hasNext(){return!1}first(){return null}any(){return!1}all(){return!0}each(){return this}map(t){return this}filter(){return this}get count(){return 0}Nl(){}toString(){return"EmptyIterator"}static instance=new Pt}class ut{constructor(t){this.key=-1,this.value=t}[Symbol.iterator](){return[this.value].values()}key;value;get iterator(){return this}reset(){this.key=-1}next(){return this.key===-1?(this.key=0,!0):!1}hasNext(){return this.next()}first(){return this.key=0,this.value}any(t){return this.key=-1,t(this.value)}all(t){return this.key=-1,t(this.value)}each(t){return this.key=-1,t(this.value),this}map(t){return new ut(t(this.value))}filter(t){return t(this.value)?new ut(this.value):Pt.instance}get count(){return 1}Nl(){this.value=null}toString(){return"SingletonIterator("+this.value+")"}}class ct{qt;Xs;Gt;Tt;constructor(t){this.qt=t,this.Xs=null,t.dr=null,this.Gt=t.rt,this.Tt=-1}[Symbol.iterator](){return this.Xs===null?this.qt.r.values():this.qt.r.filter(this.Xs).values()}key;value;get iterator(){return this}get predicate(){return this.Xs}set predicate(t){this.Xs=t}reset(){let t=this.qt;t.dr=null,this.Gt=t.rt,this.Tt=-1}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Yi(t)}let e=t.r,i=e.length,s=++this.Tt,n=this.Xs;if(n!==null)for(;s<i;){let o=e[s];if(n(o))return this.Tt=s,this.key=s,this.value=o,!0;s++}else{if(s<i)return this.key=s,this.value=e[s],!0;this.Nl()}return!1}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt,this.Tt=0;let e=t.r,i=e.length,s=this.Xs;if(s!==null){let n=0;for(;n<i;){let o=e[n];if(s(o))return this.Tt=n,this.key=n,this.value=o,o;n++}return null}else if(i>0){let n=e[0];return this.key=0,this.value=n,n}else return null}any(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(t(a))return!0;e.rt!==i&&m.Yi(e)}}return!1}all(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(!t(a))return!1;e.rt!==i&&m.Yi(e)}}return!0}each(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.Xs;for(let r=0;r<n;r++){let a=s[r];o!==null&&!o(a)||(t(a),e.rt!==i&&m.Yi(e))}return this}map(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.Xs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(s.push(t(l)),e.rt!==i&&m.Yi(e))}let a=new q;return a.r=s,a.Ki(),a.iterator}filter(t){let e=this.qt;e.dr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.Xs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(t(l)&&s.push(l),e.rt!==i&&m.Yi(e))}let a=new q;return a.r=s,a.Ki(),a.iterator}get count(){let t=this.Xs;if(t!==null){let e=0,i=this.qt.r,s=i.length;for(let n=0;n<s;n++)t(i[n])&&e++;return e}else return this.qt.r.length}Nl(){this.key=-1,this.value=null,this.Gt=-1,this.Xs=null,this.qt.dr=this}toString(){return"ListIterator@"+this.Tt+"/"+this.qt.count}}class kt{qt;Gt;Tt;constructor(t){this.qt=t,t.gr=null,this.Gt=t.rt,this.Tt=t.r.length}[Symbol.iterator](){return this.qt.r.reverse().values()}key;value;get iterator(){return this}reset(){let t=this.qt;t.gr=null,this.Gt=t.rt,this.Tt=t.r.length}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Yi(t)}let e=--this.Tt;return e>=0?(this.key=e,this.value=t.r[e],!0):(this.Nl(),!1)}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt;let e=t.r,i=e.length-1;if(this.Tt=i,i>=0){let s=e[i];return this.key=i,this.value=s,s}else return null}any(t){let e=this.qt;e.gr=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(t(r))return!0;e.rt!==i&&m.Yi(e)}return!1}all(t){let e=this.qt;e.gr=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(!t(r))return!1;e.rt!==i&&m.Yi(e)}return!0}each(t){let e=this.qt;e.gr=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];t(r),e.rt!==i&&m.Yi(e)}return this}map(t){let e=this.qt;e.gr=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];s.push(t(h)),e.rt!==i&&m.Yi(e)}let r=new q;return r.r=s,r.Ki(),r.iterator}filter(t){let e=this.qt;e.gr=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];t(h)&&s.push(h),e.rt!==i&&m.Yi(e)}let r=new q;return r.r=s,r.Ki(),r.iterator}get count(){return this.qt.r.length}Nl(){this.key=-1,this.value=null,this.Gt=-1,this.qt.gr=this}toString(){return"ListIteratorBackwards("+this.Tt+"/"+this.qt.count+")"}}class q{u;r;rt;dr;gr;constructor(t){V.Je(this),this.u=!1,this.r=[],this.rt=0,this.dr=null,this.gr=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Ki(){let t=this.rt;t++,t>999999999&&(t=0),this.rt=t}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"List()#"+V.xs(this)}add(t){return this.u&&m.L(this,t),this.r.push(t),this.Ki(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.u&&m.L(this);let e=this.r;if(t.first){let i=t.iterator;for(;i.next();)e.push(i.value)}else for(let i of t)e.push(i);return this.Ki(),this}clear(){this.u&&m.L(this),this.r.length=0,this.Ki()}contains(t){return this.has(t)}has(t){return t===null?!1:this.r.indexOf(t)!==-1}indexOf(t){return t===null?-1:this.r.indexOf(t)}elt(t){let e=this.r;return(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"elt:i"),e[t]}get(t){return this.elt(t)}setElt(t,e){let i=this.r;(t<0||t>=i.length)&&m.J(t,"0 <= i < length",q,"setElt:i"),this.u&&m.L(this,t),i[t]=e}set(t,e){this.setElt(t,e)}first(){let t=this.r;return t.length===0?null:t[0]}last(){let t=this.r,e=t.length;return e>0?t[e-1]:null}pop(){this.u&&m.L(this);let t=this.r;if(t.length>0){let e=t.pop();return e===void 0?null:e}return null}any(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(t(e[n]))return!0;this.rt!==i&&m.Yi(this)}return!1}all(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(!t(e[n]))return!1;this.rt!==i&&m.Yi(this)}return!0}each(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++)t(e[n]),this.rt!==i&&m.Yi(this);return this}map(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++)i.push(t(s[r])),this.rt!==n&&m.Yi(this);return e.r=i,e.Ki(),e}filter(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++){let a=s[r];t(a)&&i.push(a),this.rt!==n&&m.Yi(this)}return e.r=i,e.Ki(),e}insertAt(t,e){t<0&&m.J(t,">= 0",q,"insertAt:i"),this.u&&m.L(this,t);let i=this.r;t>=i.length?i.push(e):i.splice(t,0,e),this.Ki()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.u&&m.L(this,t);let e=this.r,i=e.indexOf(t);return i===-1?!1:(i===e.length-1?e.pop():e.splice(i,1),this.Ki(),!0)}removeAt(t){let e=this.r;(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"removeAt:i"),this.u&&m.L(this,t),t===e.length-1?e.pop():e.splice(t,1),this.Ki()}removeRange(t,e){let i=this.r,s=i.length;if(t<0)t=0;else if(t>=s)return this;if(e<0)return this;if(e>=s&&(e=s-1),t>e)return this;this.u&&m.L(this);let n=t,o=e+1;for(;o<s;)i[n++]=i[o++];return i.length=s-(e-t+1),this.Ki(),this}copy(){let t=new q,e=this.r;return e.length>0&&(t.r=Array.prototype.slice.call(e)),t}toArray(){let t=this.r,e=this.count,i=new Array(e);for(let s=0;s<e;s++)i[s]=t[s];return i}get AL(){return this.r}toSet(){let t=new V,e=this.r,i=this.count;for(let s=0;s<i;s++)t.add(e[s]);return t}sort(t){return this.u&&m.L(this),this.r.sort(t),this.Ki(),this}sortRange(t,e,i){let s=this.r,n=s.length;e===void 0&&(e=0),i===void 0&&(i=n),this.u&&m.L(this);let o=i-e;if(o<=1)return this;if((e<0||e>=n-1)&&m.J(e,"0 <= from < length",q,"sortRange:from"),o===2){let r=s[e],a=s[e+1];return t(r,a)>0&&(s[e]=a,s[e+1]=r,this.Ki()),this}if(e===0)if(i>=n)s.sort(t);else{let r=s.slice(0,i);r.sort(t);for(let a=0;a<i;a++)s[a]=r[a]}else if(i>=n){let r=s.slice(e);r.sort(t);for(let a=e;a<n;a++)s[a]=r[a-e]}else{let r=s.slice(e,i);r.sort(t);for(let a=e;a<i;a++)s[a]=r[a-e]}return this.Ki(),this}reverse(){return this.u&&m.L(this),this.r.reverse(),this.Ki(),this}get count(){return this.r.length}get size(){return this.r.length}get length(){return this.r.length}get iterator(){if(this.r.length<=0)return Pt.instance;let t=this.dr;return t!==null?(t.reset(),t):new ct(this)}get iteratorBackwards(){if(this.r.length<=0)return Pt.instance;let t=this.gr;return t!==null?(t.reset(),t):new kt(this)}}class _t{To;oe;constructor(t){this.To=t,this.oe=t.g.values()}[Symbol.iterator](){return this.To.g.values()}key;value;get iterator(){return this}reset(){let t=this.To;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.To.g.size===0?null:(this.oe=this.To.g.values(),this.oe.next().value)}any(t){return this.To.any(t)}all(t){return this.To.all(t)}each(t){return this.To.each(t),this}map(t){let e=new q;return this.To.g.forEach(i=>e.add(t(i))),e.iterator}filter(t){let e=new q;return this.To.g.forEach(i=>{t(i)&&e.add(i)}),e.iterator}get count(){return this.To.count}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"SetIterator"}}class V{u;g;constructor(t){this.u=!1,this.g=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.values()}values(){return this.g.values()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Set()#"+V.xs(this)}add(t){return t===null?this:(this.g.add(t),this)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.g.add(e.value)}else for(let e of t)this.g.add(e);return this}has(t){return this.g.has(t)}contains(t){return this.has(t)}containsAll(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(!this.has(e.value))return!1}else for(let e of t)if(!this.has(e))return!1;return!0}containsAny(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(this.has(e.value))return!0}else for(let e of t)if(this.has(e))return!0;return!1}first(){return this.g.size===0?null:this.g.values().next().value}any(t){for(let e of this.g)if(t(e))return!0;return!1}all(t){for(let e of this.g)if(!t(e))return!1;return!0}each(t){for(let e of this.g)t(e);return this}map(t){let e=new V;for(let i of this.g)e.add(t(i));return e}filter(t){let e=new V;for(let i of this.g)t(i)&&e.add(i);return e}delete(t){return this.u&&m.L(this),this.g.delete(t)}remove(t){return this.delete(t)}removeAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.delete(e.value)}else for(let e of t)this.delete(e);return this}retainAll(t){if(t===null)return this;if(this.count===0)return this;this.u&&m.L(this);let e=new V;e.addAll(t);let i=[];if(t.first){let s=t.iterator;for(;s.next();){let n=s.value;e.has(n)||i.push(n)}}else for(let s of t)e.has(s)||i.push(s);return this.removeAll(i),this}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new V;return this.g.forEach(e=>t.add(e)),t}toArray(){return Array.from(this.g)}toList(){let t=new q;return this.g.forEach(e=>t.add(e)),t}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new _t(this)}entries(){return this.g.entries()}keys(){return this.g.keys()}forEach(t,e){return this.g.forEach(t,e)}static Kw=1;static Je(t){t.__gohashid=V.Kw++}static xs(t){return t.__gohashid}}class We{j;oe;constructor(t){this.j=t,this.oe=t.g.keys()}[Symbol.iterator](){return this.j.g.keys()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.keys()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.keys(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[0]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[0];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"MapKeySetIterator"}}class Oi extends V{j;constructor(t){super(),V.Je(this),this.u=!0,this.j=t}[Symbol.iterator](){return this.g.keys()}values(){return this.g.keys()}k(){return this}ce(){return this}toString(){return"MapKeySet("+this.j.toString()+")"}add(t){m.o("This Set is read-only: "+this.toString())}has(t){return this.j.has(t)}contains(t){return this.has(t)}delete(t){m.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){m.o("This Set is read-only: "+this.toString())}first(){return this.j.g.size===0?null:this.j.g.keys().next().value}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=new V;for(let i of this.j.g)e.add(t(i[0]));return e}filter(t){let e=new V;for(let i of this.j.g){let s=i[0];t(s)&&e.add(s)}return e}copy(){return new Oi(this.j)}toSet(){let t=new V,e=this.j.g;for(let i of e)t.add(i[0]);return t}toArray(){let t=this.j.g,e=new Array(t.size),i=0;for(let s of t)e[i]=s[0],i++;return e}toList(){let t=new q,e=this.j.g;for(let i of e)t.add(i[0]);return t}get count(){return this.j.size}get size(){return this.j.size}get iterator(){return this.j.size<=0?Pt.instance:new We(this.j)}}class Tn{j;oe;constructor(t){this.j=t,this.oe=t.g.values()}[Symbol.iterator](){return this.j.g.values()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.values(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[1]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[1]))return!1;return!0}each(t){for(let e of this.j.g)t(e[1]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[1]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[1];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"MapValueSetIterator"}}class ye{constructor(t,e){this.key=t,this.value=e}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class Ln{j;oe;constructor(t){this.j=t,this.oe=t.g.entries()}[Symbol.iterator](){return this.j.g.entries()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.entries()}next(){let t=this.oe.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.j.g.size===0)return null;this.oe=this.j.g.entries();let t=this.oe.next().value;return this.key=t[0],this.value=t[1],new ye(t[0],t[1])}any(t){return this.j.any(t)}all(t){return this.j.all(t)}each(t){return this.j.each(t),this}map(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new ye(n,s):(i.key=n,i.value=s),e.add(t(i))}),e.iterator}filter(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new ye(n,s):(i.key=n,i.value=s),t(i)&&(e.add(i),i=null)}),e.iterator}get count(){return this.j.size}Nl(){this.key=null,this.value=null,this.oe=null}toString(){return"MapIterator"}}class Mt{u;g;constructor(t){V.Je(this),this.u=!1,this.g=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.entries()}entries(){return this.g.entries()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Map()#"+V.xs(this)}set(t,e){return this.u&&m.L(this,t),this.g.set(t,e),this}add(t,e){return this.set(t,e)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t instanceof Mt){let e=t.iterator;for(;e.next();)this.g.set(e.key,e.value)}else if(t.first){let e=t.iterator;for(;e.next();){let i=e.value;this.g.set(i.key,i.value)}}else for(let e of t){let i=e;Array.isArray(i)?this.g.set(i[0],i[1]):this.g.set(i.key,i.value)}return this}first(){if(this.g.size===0)return null;let t=this.g.entries().next().value;return t?new ye(t[0],t[1]):null}any(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new ye(i,s):(e.key=i,e.value=s),t(e))return!0;return!1}all(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new ye(i,s):(e.key=i,e.value=s),!t(e))return!1;return!0}each(t){let e=null;for(let[i,s]of this.g)e===null?e=new ye(i,s):(e.key=i,e.value=s),t(e);return this}map(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new ye(s,n):(i.key=s,i.value=n),e.set(s,t(i));return e}filter(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new ye(s,n):(i.key=s,i.value=n),t(i)&&e.set(s,n);return e}has(t){return this.g.has(t)}contains(t){return this.has(t)}get(t){let e=this.g.get(t);return e===void 0?null:e}getValue(t){return this.get(t)}delete(t){return t===null?!1:(this.u&&m.L(this,t),this.g.delete(t))}remove(t){return this.delete(t)}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new Mt;return t.g=new Map(this.g),t}toArray(){let t=this.g,e=new Array(t.size),i=0;for(let s of t)e[i]=new ye(s[0],s[1]),i++;return e}toKeySet(){return new Oi(this)}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new Ln(this)}get iteratorKeys(){return this.count<=0?Pt.instance:new We(this)}keys(){return this.g.keys()}get iteratorValues(){return this.count<=0?Pt.instance:new Tn(this)}values(){return this.g.values()}forEach(t,e){return this.g.forEach(t,e)}}class P{px;py;u;constructor(t,e){t===void 0?(this.px=0,this.py=0):typeof t=="number"&&typeof e=="number"?(this.px=t,this.py=e):m.o("Invalid arguments to Point constructor: "+t+", "+e),this.u=!1}h(t){return this.px=t.px,this.py=t.py,this}e(t,e){return this.px=t,this.py=e,this}setTo(t,e){return this.px=t,this.py=e,this}set(t){return this.px=t.px,this.py=t.py,this}copy(){let t=new P;return t.px=this.px,t.py=this.py,t}kt(){return this.u=!0,Object.freeze(this),this}C(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new P(s,o)}else return new P}static stringify(t){return t.x.toString()+" "+t.y.toString()}static stringifyFixed(t){return m.s(t,"number",P,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof P?this.px===t.x&&this.py===t.y:!1}equalTo(t,e){return this.px===t&&this.py===e}equalsApprox(t){return C.c(this.px,t.x)&&C.c(this.py,t.y)}add(t){return this.px+=t.x,this.py+=t.y,this}subtract(t){return this.px-=t.x,this.py-=t.y,this}offset(t,e){return this.px+=t,this.py+=e,this}rotate(t){if(t===0)return this;let e=this.px,i=this.py;if(e===0&&i===0)return this;let s=0,n=0;if(t=C.Ee(t),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.px=s*e-n*i,this.py=n*e+s*i,this}scale(t,e){return this.px*=t,this.py*=e,this}distanceSquaredPoint(t){let e=t.x-this.px,i=t.y-this.py;return e*e+i*i}distanceSquared(t,e){let i=t-this.px,s=e-this.py;return i*i+s*s}normalize(){let t=this.px,e=this.py,i=Math.sqrt(t*t+e*e);return i>0&&(this.px=t/i,this.py=e/i),this}directionPoint(t){return this.TL(t.x-this.px,t.y-this.py)}direction(t,e){return this.TL(t-this.px,e-this.py)}TL(t,e){if(t===0)return e>0?90:e<0?270:0;if(e===0)return t>0?0:180;{if(isNaN(t)||isNaN(e))return 0;let i=Math.atan(Math.abs(e/t))*180/Math.PI;return t<0?e<0?i+=180:i=180-i:e<0&&(i=360-i),i}}static compareWithLineSegment(t,e,i,s,n,o){return C.ku(t,e,i,s,n,o)}compareWithLineSegmentPoint(t,e){return C.ku(t.x,t.y,e.x,e.y,this.x,this.y)}static intersectingLineSegments(t,e,i,s,n,o,r,a){return C.Pu(t,e,i,s,n,o,r,a)}projectOntoLineSegment(t,e,i,s){return C.Ll(t,e,i,s,this.px,this.py,this),this}projectOntoLineSegmentPoint(t,e){return C.Ll(t.x,t.y,e.x,e.y,this.px,this.py,this),this}snapToGrid(t,e,i,s){return C._g(this.px,this.py,t,e,i,s,this),this}snapToGridPoint(t,e){return C._g(this.px,this.py,t.x,t.y,e.width,e.height,this),this}setRectSpot(t,e){return this.px=t.x+e.x*t.width+e.offsetX,this.py=t.y+e.y*t.height+e.offsetY,this}setSpot(t,e,i,s,n){return this.px=t+n.x*i+n.offsetX,this.py=e+n.y*s+n.offsetY,this}v(t){return t.gt(this),this}Hi(t){return t.Ni(this),this}static distanceLineSegmentSquared(t,e,i,s,n,o){let r=n-i,a=o-s,h=r*r+a*a,l=i-t,u=s-e,c=-l*r-u*a;if(c<=0||c>=h)return r=n-t,a=o-e,Math.min(l*l+u*u,r*r+a*a);{let d=r*u-a*l;return d*d/h}}static distanceSquared(t,e,i,s){let n=i-t,o=s-e;return n*n+o*o}static direction(t,e,i,s){let n=i-t,o=s-e;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.px}set x(t){this.px=t}get y(){return this.py}set y(t){this.py=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static gn=new P(0,0).kt();static DL=new P(-1/0,-1/0).kt();static vL=new P(1/0,1/0).kt();static FL=new P(6,6).kt();static mn=new P(NaN,NaN).kt();static qw=[];static l(){let t=P.qw.pop();return t===void 0?new P:t}static bs(t){let e=P.qw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e){let i=P.qw.pop();return i===void 0?new P(t,e):(i.x=t,i.y=e,i)}static i(t){P.qw.push(t)}}class nt{sw;sh;u;constructor(t,e){t===void 0?(this.sw=0,this.sh=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof e=="number"&&(e>=0||isNaN(e))?(this.sw=t,this.sh=e):m.o("Invalid arguments to Size constructor: "+t+", "+e),this.u=!1}h(t){return this.sw=t.sw,this.sh=t.sh,this}e(t,e){return this.sw=t,this.sh=e,this}setTo(t,e){return this.sw=t,this.sh=e,this}set(t){return this.sw=t.sw,this.sh=t.sh,this}copy(){let t=new nt;return t.sw=this.sw,t.sh=this.sh,t}kt(){return this.u=!0,Object.freeze(this),this}C(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new nt(s,o)}else return new nt}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",nt,"stringifyFixed:digits"),e=>e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof nt?this.sw===t.width&&this.sh===t.height:!1}equalTo(t,e){return this.sw===t&&this.sh===e}equalsApprox(t){return C.c(this.sw,t.width)&&C.c(this.sh,t.height)}inflate(t,e){let i=this.width+t;this.sw=i>=0?i:0;let s=this.height+e;return this.sh=s>=0?s:0,this}get width(){return this.sw}set width(t){t<0&&m.J(t,">= 0",nt,"width"),this.sw=t}get height(){return this.sh}set height(t){t<0&&m.J(t,">= 0",nt,"height"),this.sh=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static xc=new nt(0,0).kt();static CP=new nt(1,1).kt();static RL=new nt(6,6).kt();static Su=new nt(8,8).kt();static OL=new nt(10,10).kt();static NP=new nt(1/0,1/0).kt();static jw=new nt(NaN,NaN).kt();static IL=[];static l(){let t=nt.IL.pop();return t===void 0?new nt:t}static i(t){nt.IL.push(t)}}class I{rx;ry;rw;rh;u;constructor(t,e,i,s){if(t===void 0)this.rx=0,this.ry=0,this.rw=0,this.rh=0;else if(typeof t=="number"&&typeof e=="number"&&typeof i=="number"&&(i>=0||isNaN(i))&&typeof s=="number"&&(s>=0||isNaN(s)))this.rx=t,this.ry=e,this.rw=i,this.rh=s;else if(t instanceof P){let n=t.x,o=t.y;if(e instanceof P){let r=e.x,a=e.y;this.rx=Math.min(n,r),this.ry=Math.min(o,a),this.rw=Math.abs(n-r),this.rh=Math.abs(o-a)}else e instanceof nt?(this.rx=n,this.ry=o,this.rw=e.width,this.rh=e.height):m.o("Incorrect second argument supplied to Rect constructor "+e)}else m.o("Invalid arguments to Rect constructor: "+t+", "+e+", "+i+", "+s);this.u=!1}h(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}e(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}Kn(t,e){return this.rw=t,this.rh=e,this}setTo(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}set(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}setPoint(t){return this.rx=t.x,this.ry=t.y,this}setSize(t){return this.rw=t.width,this.rh=t.height,this}copy(){let t=new I;return t.rx=this.rx,t.ry=this.ry,t.rw=this.rw,t.rh=this.rh,t}kt(){return this.u=!0,Object.freeze(this),this}C(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}ce(){return this.u&&(Object.isFrozen(this)&&m.o("cannot thaw constant: "+this),this.u=!1),this}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),new I(s,o,r,a)}else return new I}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",I,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof I?this.rx===t.x&&this.ry===t.y&&this.rw===t.width&&this.rh===t.height:!1}equalTo(t,e,i,s){return this.rx===t&&this.ry===e&&this.rw===i&&this.rh===s}equalsApprox(t){return C.c(this.rx,t.x)&&C.c(this.ry,t.y)&&C.c(this.rw,t.width)&&C.c(this.rh,t.height)}equalsApproxTo(t,e,i,s){return C.c(this.rx,t)&&C.c(this.ry,e)&&C.c(this.rw,i)&&C.c(this.rh,s)}equalsApproxClose(t){return C.X(this.rx,t.x)&&C.X(this.ry,t.y)&&C.X(this.rw,t.width)&&C.X(this.rh,t.height)}containsPoint(t){return this.rx<=t.x&&this.rx+this.rw>=t.x&&this.ry<=t.y&&this.ry+this.rh>=t.y}containsRect(t){return this.rx<=t.x&&t.x+t.width<=this.rx+this.rw&&this.ry<=t.y&&t.y+t.height<=this.ry+this.rh}contains(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.rx<=t&&t+i<=this.rx+this.rw&&this.ry<=e&&e+s<=this.ry+this.rh}offset(t,e){return this.rx+=t,this.ry+=e,this}inflate(t,e){return this.Ww(e,t,e,t)}addMargin(t){return this.Ww(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.Ww(-t.top,-t.right,-t.bottom,-t.left)}grow(t,e,i,s){return this.Ww(t,e,i,s)}Ww(t,e,i,s){let n=this.rw;e+s<=-n?(this.rx+=n/2,this.rw=0):(this.rx-=s,this.rw+=e+s);let o=this.rh;return t+i<=-o?(this.ry+=o/2,this.rh=0):(this.ry-=t,this.rh+=t+i),this}intersectRect(t){return this.EL(t.x,t.y,t.width,t.height)}intersect(t,e,i,s){return this.EL(t,e,i,s)}EL(t,e,i,s){let n=Math.max(this.rx,t),o=Math.max(this.ry,e),r=Math.min(this.rx+this.rw,t+i),a=Math.min(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=Math.max(0,r-n),this.rh=Math.max(0,a-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,e,i,s){let n=this.rw,o=this.rx;if(n!==1/0&&i!==1/0&&(n+=o,i+=t,isNaN(i)||isNaN(n)||o>i||t>n))return!1;let r=this.rh,a=this.ry;return!(r!==1/0&&s!==1/0&&(r+=a,s+=e,isNaN(s)||isNaN(r)||a>s||e>r))}UL(t,e){let i=this.rw,s=t.width+e+e,n=this.rx,o=t.x-e;if(i+=n,s+=o,n>s||o>i)return!1;let r=this.rh,a=t.height+e+e,h=this.ry,l=t.y-e;return r+=h,a+=l,!(h>a||l>r)}unionPoint(t){return this.re(t.x,t.y,0,0)}unionRect(t){return this.re(t.rx,t.ry,t.rw,t.rh)}union(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.re(t,e,i,s)}re(t,e,i,s){let n=Math.min(this.rx,t),o=Math.min(this.ry,e),r=Math.max(this.rx+this.rw,t+i),a=Math.max(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=r-n,this.rh=a-o,this}setSpot(t,e,i){return this.rx=t-i.offsetX-i.x*this.rw,this.ry=e-i.offsetY-i.y*this.rh,this}nearestSideDirection(t,e){return C.Jw(this,t,e,!0)}nearestSideDirectionPoint(t){return C.Jw(this,t.x,t.y,!0)}static contains(t,e,i,s,n,o,r,a){return r===void 0&&(r=0),a===void 0&&(a=0),t<=n&&n+r<=t+i&&e<=o&&o+a<=e+s}static intersects(t,e,i,s,n,o,r,a){let h=i,l=r,u=t,c=n;if(h+=u,l+=c,u>l||c>h)return!1;let d=s,f=a,p=e,g=o;return d+=p,f+=g,!(p>f||g>d)}static intersectsLineSegment(t,e,i,s,n,o,r,a){return C.VL(t,e,i,s,n,o,r,a)}get x(){return this.rx}set x(t){this.rx=t}get y(){return this.ry}set y(t){this.ry=t}get width(){return this.rw}set width(t){t<0&&m.J(t,">= 0",I,"width"),this.rw=t}get height(){return this.rh}set height(t){t<0&&m.J(t,">= 0",I,"height"),this.rh=t}get left(){return this.rx}set left(t){this.rx=t}get top(){return this.ry}set top(t){this.ry=t}get right(){return this.rx+this.rw}set right(t){this.rx+=t-(this.rx+this.rw)}get bottom(){return this.ry+this.rh}set bottom(t){this.ry+=t-(this.ry+this.rh)}get position(){return new P(this.rx,this.ry)}set position(t){this.rx=t.x,this.ry=t.y}get size(){return new nt(this.rw,this.rh)}set size(t){this.rw=t.width,this.rh=t.height}get center(){return new P(this.rx+this.rw/2,this.ry+this.rh/2)}set center(t){this.rx=t.x-this.rw/2,this.ry=t.y-this.rh/2}get centerX(){return this.rx+this.rw/2}set centerX(t){this.rx=t-this.rw/2}get centerY(){return this.ry+this.rh/2}set centerY(t){this.ry=t-this.rh/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static tm=new I(0,0,0,0).kt();static YF=new I(NaN,NaN,NaN,NaN).kt();static $w=[];static l(){let t=I.$w.pop();return t===void 0?new I:t}static bs(t){let e=I.$w.pop();return e===void 0?t.copy():e.h(t)}static z(t,e,i,s){let n=I.$w.pop();return n===void 0?new I(t,e,i,s):n.e(t,e,i,s)}static i(t){I.$w.push(t)}}class Dt{mt;mr;mb;ml;constructor(t,e,i,s){t===void 0?(this.mt=0,this.mr=0,this.mb=0,this.ml=0):e===void 0?(e=t,i=t,s=t,this.mt=t,this.mr=e,this.mb=i,this.ml=s):i===void 0?(i=t,s=e,this.mt=t,this.mr=e,this.mb=i,this.ml=s):s!==void 0?(this.mt=t,this.mr=e,this.mb=i,this.ml=s):m.o("Invalid arguments to Margin constructor: "+t+", "+e+", "+i+", "+s)}setTo(t,e,i,s){return this.mt=t,this.mr=e,this.mb=i,this.ml=s,this}set(t){return this.mt=t.mt,this.mr=t.mr,this.mb=t.mb,this.ml=t.ml,this}copy(){let t=new Dt;return t.mt=this.mt,t.mr=this.mr,t.mb=this.mb,t.ml=this.ml,t}kt(){return Object.freeze(this),this}C(){return Object.isFrozen(this)?this:this.copy().kt()}Hw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=NaN;for(;e[i]==="";)i++;let n=e[i++];if(n&&(s=parseFloat(n)),isNaN(s))return new Dt;let o=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(o=parseFloat(n)),isNaN(o))return new Dt(s);let r=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(r=parseFloat(n)),isNaN(r))return new Dt(s,o);let a=NaN;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),isNaN(a)?new Dt(s,o):new Dt(s,o,r,a)}else return new Dt}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return m.s(t,"number",Dt,"stringifyFixed:digits"),e=>e.top.toFixed(t)+" "+e.right.toFixed(t)+" "+e.bottom.toFixed(t)+" "+e.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Dt?this.mt===t.top&&this.mr===t.right&&this.mb===t.bottom&&this.ml===t.left:!1}equalTo(t,e,i,s){return this.mt===t&&this.mr===e&&this.mb===i&&this.ml===s}equalsApprox(t){return C.c(this.mt,t.top)&&C.c(this.mr,t.right)&&C.c(this.mb,t.bottom)&&C.c(this.ml,t.left)}get top(){return this.mt}set top(t){this.mt=t}get right(){return this.mr}set right(t){this.mr=t}get bottom(){return this.mb}set bottom(t){this.mb=t}get left(){return this.ml}set left(t){this.ml=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static em=new Dt(0,0,0,0).kt();static BL=new Dt(2,2,2,2).kt()}class T{sx;sy;ox;oy;constructor(t,e,i,s){t===void 0?(this.sx=0,this.sy=0,this.ox=0,this.oy=0):(e===void 0&&(e=0),i===void 0&&(i=0),s===void 0&&(s=0),this.sx=t,this.sy=e,this.ox=i,this.oy=s)}setTo(t,e,i,s){return this.sx=t,this.sy=e,this.ox=i,this.oy=s,this}set(t){return this.sx=t.sx,this.sy=t.sy,this.ox=t.ox,this.oy=t.oy,this}copy(){let t=new T;return t.sx=this.sx,t.sy=this.sy,t.ox=this.ox,t.oy=this.oy,t}kt(){return Object.freeze(this),this}C(){return Object.isFrozen(this)?this:this.copy().kt()}Hw(t){}qi(t){return this.sx=NaN,this.sy=NaN,this.ox=t,this.kt()}vU(t,e){(isNaN(t)||t>1||t<0)&&m.J(t,"0 <= "+e+" <= 1",T,e)}FU(t,e){(isNaN(t)||t===1/0||t===-1/0)&&m.J(t,"real number, not NaN or Infinity",T,e)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return T.None;if(t==="TopLeft")return T.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return T.TopCenter;if(t==="TopRight")return T.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return T.LeftCenter;if(t==="Center")return T.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return T.RightCenter;if(t==="BottomLeft")return T.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return T.BottomCenter;if(t==="BottomRight")return T.BottomRight;if(t==="TopSide")return T.TopSide;if(t==="LeftSide")return T.LeftSide;if(t==="RightSide")return T.RightSide;if(t==="BottomSide")return T.BottomSide;if(t==="TopBottomSides")return T.TopBottomSides;if(t==="LeftRightSides")return T.LeftRightSides;if(t==="TopLeftSides")return T.TopLeftSides;if(t==="TopRightSides")return T.TopRightSides;if(t==="BottomLeftSides")return T.BottomLeftSides;if(t==="BottomRightSides")return T.BottomRightSides;if(t==="NotTopSide")return T.NotTopSide;if(t==="NotLeftSide")return T.NotLeftSide;if(t==="NotRightSide")return T.NotRightSide;if(t==="NotBottomSide")return T.NotBottomSide;if(t==="AllSides")return T.AllSides;if(t==="Default")return T.Default;let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n!==void 0&&n.length>0&&(a=parseFloat(n)),new T(s,o,r,a)}else return new T}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return m.s(t,"number",T,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.offsetX.toFixed(t)+" "+e.offsetY.toFixed(t)}toString(){return this.isSpot()?this.ox===0&&this.oy===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(T.None)?"None":this.equals(T.TopLeft)?"TopLeft":this.equals(T.TopCenter)?"Top":this.equals(T.TopRight)?"TopRight":this.equals(T.LeftCenter)?"Left":this.equals(T.Center)?"Center":this.equals(T.RightCenter)?"Right":this.equals(T.BottomLeft)?"BottomLeft":this.equals(T.BottomCenter)?"Bottom":this.equals(T.BottomRight)?"BottomRight":this.equals(T.TopSide)?"TopSide":this.equals(T.LeftSide)?"LeftSide":this.equals(T.RightSide)?"RightSide":this.equals(T.BottomSide)?"BottomSide":this.equals(T.TopBottomSides)?"TopBottomSides":this.equals(T.LeftRightSides)?"LeftRightSides":this.equals(T.TopLeftSides)?"TopLeftSides":this.equals(T.TopRightSides)?"TopRightSides":this.equals(T.BottomLeftSides)?"BottomLeftSides":this.equals(T.BottomRightSides)?"BottomRightSides":this.equals(T.NotTopSide)?"NotTopSide":this.equals(T.NotLeftSide)?"NotLeftSide":this.equals(T.NotRightSide)?"NotRightSide":this.equals(T.NotBottomSide)?"NotBottomSide":this.equals(T.AllSides)?"AllSides":this.equals(T.Default)?"Default":"None"}equals(t){return t instanceof T?(this.sx===t.x||isNaN(this.sx)&&isNaN(t.x))&&(this.sy===t.y||isNaN(this.sy)&&isNaN(t.y))&&this.ox===t.offsetX&&this.oy===t.offsetY:!1}opposite(){return new T(.5-(this.sx-.5),.5-(this.sy-.5),-this.ox,-this.oy)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(T.Left))t=T.LeftSide;else if(t.equals(T.Right))t=T.RightSide;else if(t.equals(T.Top))t=T.TopSide;else if(t.equals(T.Bottom))t=T.BottomSide;else return!1;let e=this.oy,i=t.offsetY;return(e&i)===i}get x(){return this.sx}set x(t){this.sx=t}get y(){return this.sy}set y(t){this.sy=t}get offsetX(){return this.ox}set offsetX(t){this.ox=t}get offsetY(){return this.oy}set offsetY(t){this.oy=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new T(0,0,0,0).qi(0);static Default=new T(0,0,-1,0).qi(-1);static TopLeft=new T(0,0,0,0).kt();static TopCenter=new T(.5,0,0,0).kt();static TopRight=new T(1,0,0,0).kt();static LeftCenter=new T(0,.5,0,0).kt();static Center=new T(.5,.5,0,0).kt();static RightCenter=new T(1,.5,0,0).kt();static BottomLeft=new T(0,1,0,0).kt();static BottomCenter=new T(.5,1,0,0).kt();static BottomRight=new T(1,1,0,0).kt();static MiddleTop=T.TopCenter;static MiddleLeft=T.LeftCenter;static MiddleRight=T.RightCenter;static MiddleBottom=T.BottomCenter;static Top=T.TopCenter;static Left=T.LeftCenter;static Right=T.RightCenter;static Bottom=T.BottomCenter;static TopSide=new T(0,0,1,1).qi(1);static LeftSide=new T(0,0,1,2).qi(1);static RightSide=new T(0,0,1,4).qi(1);static BottomSide=new T(0,0,1,8).qi(1);static TopBottomSides=new T(0,0,1,9).qi(1);static LeftRightSides=new T(0,0,1,6).qi(1);static TopLeftSides=new T(0,0,1,3).qi(1);static TopRightSides=new T(0,0,1,5).qi(1);static BottomLeftSides=new T(0,0,1,10).qi(1);static BottomRightSides=new T(0,0,1,12).qi(1);static NotTopSide=new T(0,0,1,14).qi(1);static NotLeftSide=new T(0,0,1,13).qi(1);static NotRightSide=new T(0,0,1,11).qi(1);static NotBottomSide=new T(0,0,1,7).qi(1);static AllSides=new T(0,0,1,15).qi(1);static LP=new T(.156,.156).kt();static AP=new T(.844,.844).kt()}class Nt{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,e,i,s,n,o){return this.m11=t,this.m12=e,this.m21=i,this.m22=s,this.dx=n,this.dy=o,this}copy(){let t=new Nt;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}TP(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ue(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}bc(t){let e=this.m11*t.m11+this.m21*t.m12,i=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=e,this.m12=i,this.m21=s,this.m22=n,this}zL(t){let e=1/(t.m11*t.m22-t.m12*t.m21),i=t.m22*e,s=-t.m12*e,n=-t.m21*e,o=t.m11*e,r=e*(t.m21*t.dy-t.m22*t.dx),a=e*(t.m12*t.dx-t.m11*t.dy),h=this.m11*i+this.m21*s,l=this.m12*i+this.m22*s,u=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*a+this.dx,this.dy=this.m12*r+this.m22*a+this.dy,this.m11=h,this.m12=l,this.m21=u,this.m22=c,this}Zw(){let t=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*t,i=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=e,this.m12=i,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ks(t,e,i){if(t=C.Ee(t),t===0)return this;this.Gs(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,a=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=a,this.m22=h,this.Gs(-e,-i),this}Gs(t,e){return this.dx+=this.m11*t+this.m21*e,this.dy+=this.m12*t+this.m22*e,this}et(t,e){return e===void 0&&(e=t),this.m11*=t,this.m12*=t,this.m21*=e,this.m22*=e,this}KF(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}gt(t){let e=t.x,i=t.y;return t.e(e*this.m11+i*this.m21+this.dx,e*this.m12+i*this.m22+this.dy)}Ni(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=t.x-this.dx,a=t.y-this.dy;return t.e(r*i+a*n,r*s+a*o)}Mu(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=e*(this.m21*this.dy-this.m22*this.dx),a=e*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,l=t.y*1.2;return t.e(h*i+l*n+r,h*s+l*o+a)}im(t){let e=t.x,i=t.y,s=e+t.width,n=i+t.height,o=this.m11,r=this.m12,a=this.m21,h=this.m22,l=this.dx,u=this.dy,c=e*o+i*a+l,d=e*r+i*h+u,f=s*o+i*a+l,p=s*r+i*h+u,g=e*o+n*a+l,y=e*r+n*h+u,b=s*o+n*a+l,v=s*r+n*h+u,w=c,k=c,S=d,N=d;return w=Math.min(w,f),k=Math.max(k,f),S=Math.min(S,p),N=Math.max(N,p),w=Math.min(w,g),k=Math.max(k,g),S=Math.min(S,y),N=Math.max(N,y),w=Math.min(w,b),k=Math.max(k,b),S=Math.min(S,v),N=Math.max(N,v),t.e(w,S,k-w,N-S),t}static XL=[];static l(){let t=Nt.XL.pop();return t===void 0?new Nt:t}static i(t){Nt.XL.push(t)}static DP="54a702f3e53909c447824c6706603faf4c"}let C={HF:"7da71ca0ad381e90",Hn:4*((Math.sqrt(2)-1)/3),GL:[],Qw:x=>{if(x<=0)return 0;let t=C.GL;if(t===null){t=[];for(let e=0;e<=2e3;e++)t[e]=Math.sqrt(e);C.GL=t}if(x<1){let e=1/x;return e<=2e3?1/t[e|0]:Math.sqrt(x)}else return x<=2e3?t[x|0]:Math.sqrt(x)},c:(x,t)=>{let e=x-t;return e<.5&&e>-.5},X:(x,t)=>{let e=x-t;return e<5e-8&&e>-5e-8},Ve:(x,t,e,i,s,n,o)=>{s<=0&&(s=1e-6);let r=0,a=0,h=0,l=0;if(x<e?(a=x,r=e):(a=e,r=x),t<i?(l=t,h=i):(l=i,h=t),x===e)return l<=o&&o<=h&&x-s<=n&&n<=x+s;if(t===i)return a<=n&&n<=r&&t-s<=o&&o<=t+s;let u=r+s,c=a-s;if(c<=n&&n<=u){let d=h+s,f=l-s;if(f<=o&&o<=d)if(u-c>d-f)if(x-e>s||e-x>s){let p=(i-t)/(e-x)*(n-x)+t;if(p-s<=o&&o<=p+s)return!0}else return!0;else if(t-i>s||i-t>s){let p=(e-x)/(i-t)*(o-t)+x;if(p-s<=n&&n<=p+s)return!0}else return!0}return!1},_w:(x,t,e,i,s,n,o,r,a,h,l,u)=>{if(!C.Ve(x,t,o,r,u,e,i)||!C.Ve(x,t,o,r,u,s,n)){let c=(x+e)/2,d=(t+i)/2,f=(e+s)/2,p=(i+n)/2,g=(s+o)/2,y=(n+r)/2,b=(c+f)/2,v=(d+p)/2,w=(f+g)/2,k=(p+y)/2,S=(b+w)/2,N=(v+k)/2;return C._w(x,t,c,d,b,v,S,N,a,h,l,u)||C._w(S,N,w,k,g,y,o,r,a,h,l,u)}else return C.Ve(x,t,o,r,u,h,l)},YL:(x,t,e,i,s,n,o,r,a)=>{let h=(x+e)/2,l=(t+i)/2,u=(e+s)/2,c=(i+n)/2,d=(s+o)/2,f=(n+r)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2;return a.e((p+y)/2,(g+b)/2),a},qF:(x,t,e,i,s,n,o,r)=>{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(s+o)/2,d=(n+r)/2,f=(a+l)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2;return P.direction(f,p,g,y)},Cu:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.Cu(x,t,l,u,g,y,w,k,a,h),C.Cu(w,k,b,v,f,p,o,r,a,h)}else h.re(x,t,0,0),h.re(o,r,0,0);return h},qn:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.qn(x,t,l,u,g,y,w,k,a,h),C.qn(w,k,b,v,f,p,o,r,a,h)}else h.length===0&&(h.push(x),h.push(t)),h.push(o),h.push(r);return h},vP:(x,t,e,i,s,n,o,r,a,h)=>{if(C.Ve(x,t,s,n,h,e,i))return C.Ve(x,t,s,n,h,r,a);{let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(l+c)/2,p=(u+d)/2;return C.vP(x,t,l,u,f,p,o,r,a,h)||C.vP(f,p,c,d,s,n,o,r,a,h)}},FP:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.re(x,t,0,0),r.re(s,n,0,0);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.FP(x,t,a,h,c,d,o,r),C.FP(c,d,l,u,s,n,o,r)}return r},sm:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.length===0&&(r.push(x),r.push(t)),r.push(s),r.push(n);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.sm(x,t,a,h,c,d,o,r),C.sm(c,d,l,u,s,n,o,r)}return r},nm:(x,t,e,i,s,n,o,r,a,h,l,u,c,d)=>{if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2,M=1/0,A=!1,F=0,O=0;if(C.nm(x,t,f,p,w,k,D,L,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}if(C.nm(D,L,S,N,b,v,o,r,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}return A&&(d.x=F,d.y=O),A}else{if(!C.Pu(x,t,o,r,a,h,l,u))return!1;let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return!1;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;return d.e(p,g),!0}},om:(x,t,e,i,s,n,o,r,a,h,l,u,c)=>{let d=0;if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2;d+=C.om(x,t,f,p,w,k,D,L,a,h,l,u,c),d+=C.om(D,L,S,N,b,v,o,r,a,h,l,u,c)}else{let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return d;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;if(p>=l)return d;let y=0,b=0;if((a>l?a-l:l-a)<(h>u?h-u:u-h)){if(t<r?(y=t,b=r):(y=r,b=t),g<y||g>b)return d}else if(x<o?(y=x,b=o):(y=o,b=x),p<y||p>b)return d;f>0?d++:f<0&&d--}return d},Ll:(x,t,e,i,s,n,o)=>{if(C.X(x,e)){let r=0,a=0;t<i?(r=t,a=i):(r=i,a=t);let h=n;return h<r?(o.e(x,r),!1):h>a?(o.e(x,a),!1):(o.e(x,h),!0)}else if(C.X(t,i)){let r=0,a=0;x<e?(r=x,a=e):(r=e,a=x);let h=s;return h<r?(o.e(r,t),!1):h>a?(o.e(a,t),!1):(o.e(h,t),!0)}else{let r=(e-x)**2+(i-t)**2,a=((x-s)*(x-e)+(t-n)*(t-i))/r;if(a<-5e-6)return o.e(x,t),!1;if(a>1.000005)return o.e(e,i),!1;{let h=x+a*(e-x),l=t+a*(i-t);return o.e(h,l),!0}}},Do:(x,t,e,i,s,n,o,r,a)=>{if(C.c(x,e)&&C.c(t,i))return a.e(x,t),!1;if(C.X(s,o)){if(C.X(x,e))return C.Ll(x,t,e,i,s,n,a),!1;{let h=(i-t)/(e-x)*(s-x)+t;return C.Ll(x,t,e,i,s,h,a)}}else{let h=(r-n)/(o-s);if(C.X(x,e)){let l=h*(x-s)+n,u=0,c=0;return t<i?(u=t,c=i):(u=i,c=t),l<u?(a.e(x,u),!1):l>c?(a.e(x,c),!1):(a.e(x,l),!0)}else{let l=(i-t)/(e-x);if(C.X(h,l))return C.Ll(x,t,e,i,s,n,a),!1;{let u=(l*x-h*s+n-t)/(l-h);if(C.X(l,0)){let c=0,d=0;return x<e?(c=x,d=e):(c=e,d=x),u<c?(a.e(c,t),!1):u>d?(a.e(d,t),!1):(a.e(u,t),!0)}else{let c=l*(u-x)+t;return C.Ll(x,t,e,i,u,c,a)}}}}},Al:(x,t,e,i,s,n,o,r,a)=>{let h=1e21,l=x,u=t;if(C.Do(x,t,x,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Do(e,t,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Do(x,t,e,t,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Do(x,i,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}return a.e(l,u),h<1e21},tx:(x,t,e)=>C.VL(x.x,x.y,x.width,x.height,t.x,t.y,e.x,e.y),VL:(x,t,e,i,s,n,o,r)=>{let a=x,h=x+e,l=t,u=t+i;if(s===o){let c=0,d=0;return n<r?(c=n,d=r):(c=r,d=n),a<=s&&s<=h&&c<=u&&d>=l}if(n===r){let c=0,d=0;return s<o?(c=s,d=o):(c=o,d=s),l<=n&&n<=u&&c<=h&&d>=a}return!!(I.contains(x,t,e,i,s,n)||I.contains(x,t,e,i,o,r)||C.Pu(a,l,h,l,s,n,o,r)||C.Pu(h,l,h,u,s,n,o,r)||C.Pu(h,u,a,u,s,n,o,r)||C.Pu(a,u,a,l,s,n,o,r))},Pu:(x,t,e,i,s,n,o,r)=>x===e&&t===i&&s===o&&n===r?x===s&&t===n:C.ku(x,t,e,i,s,n)*C.ku(x,t,e,i,o,r)<=0&&C.ku(s,n,o,r,x,t)*C.ku(s,n,o,r,e,i)<=0,ku:(x,t,e,i,s,n)=>{let o=e-x,r=i-t,a=s-x,h=n-t,l=a*r-h*o;return l===0&&(l=a*o+h*r,l>0&&(a-=o,h-=r,l=a*o+h*r,l<0&&(l=0))),l},Jw(x,t,e,i){i===void 0&&(i=!1);let s=0,n=x===null?t:(t-x.x)/(x.width>0?x.width:1),o=x===null?e:(e-x.y)/(x.height>0?x.height:1);return n>o?n>1-o||(i||n<1-o?s=270:s=315):i||n<o?n>1-o?s=90:i||n<1-o?s=180:s=135:n<.5?s=225:n>.5&&(s=45),s},Ee:x=>(x>=360?x-=360:x<0&&(x+=360),x),jF:(x,t)=>x>t?Math.min(x-t,Math.abs(x-360-t)):t>x?Math.min(t-x,Math.abs(x-(t-360))):0,KL:(x,t,e,i,s,n)=>{let o=Math.PI;n||(i=i*(o/180),s=s*(o/180));let r=i>s?-1:1,a=1e-5,h=o*2,l=[],u=o/2,c=i,d=Math.min(h,Math.abs(s-i));if(d<a){let f=c+r*Math.min(d,u),p=x+e*Math.cos(c),g=t+e*Math.sin(c),y=x+e*Math.cos(f),b=t+e*Math.sin(f),v=(p+y)/2,w=(g+b)/2;return l.push([p,g,v,w,v,w,y,b]),l}for(;d>a;){let f=c+r*Math.min(d,u);l.push(C.WF(e,c,f,x,t)),d-=Math.abs(f-c),c=f}return l},WF:(x,t,e,i,s)=>{let n=(e-t)/2,o=x*Math.cos(n),r=x*Math.sin(n),a=o,h=-r,l=a*a+h*h,u=l+a*o+h*r,c=4/3*(Math.sqrt(2*l*u)-u)/(a*r-h*o),d=a-c*h,f=h+c*a,p=d,g=-f,y=n+t,b=Math.cos(y),v=Math.sin(y);return[i+x*Math.cos(t),s+x*Math.sin(t),i+d*b-f*v,s+d*v+f*b,i+p*b-g*v,s+p*v+g*b,i+x*Math.cos(e),s+x*Math.sin(e)]},_g:(x,t,e,i,s,n,o)=>{let r=s,a=n,h=Math.floor((x-e)/r)*r+e,l=Math.floor((t-i)/a)*a+i,u=h;h+r-x<r/2&&(u=h+r);let c=l;return l+a-t<a/2&&(c=l+a),o.e(u,c),o},HL:(x,t)=>{let e=Math.max(x,t),i=Math.min(x,t),s=1,n=1;do s=e%i,n=i,e=i,i=s;while(s>0);return n},JF:(x,t,e,i)=>{let s=e<0,n=i<0,o=0,r=0,a=0;x<t?(r=1,a=0):(r=0,a=1);let h=0,l=0,u=0,c=0;return o=r,h=o===0?x:t,u=o===0?e:i,(o===0?s:n)&&(u=-u),o=a,l=o===0?x:t,c=o===0?e:i,(o===0?s:n)&&(c=-c),C.$F(h,l,u,c,0,0)},$F:(x,t,e,i,s,n)=>{let o=0;if(i>0)if(e>0){let r=x*x,a=t*t,h=x*e,l=t*i,u=-a+l,c=-a+Math.sqrt(h*h+l*l),d=u,f=9999999999;for(let y=0;y<f&&(d=.5*(u+c),!(d===u||d===c));++y){let b=h/(d+r),v=l/(d+a),w=b*b+v*v-1;if(w>0)u=d;else if(w<0)c=d;else break}s=r*e/(d+r),n=a*i/(d+a);let p=s-e,g=n-i;o=Math.sqrt(p*p+g*g)}else s=0,n=t,o=Math.abs(i-t);else{let r=x*x-t*t,a=x*e;if(a<r){let h=a/r,l=h*h;s=x*h,n=t*Math.sqrt(Math.abs(1-l));let u=s-e;o=Math.sqrt(u*u+n*n)}else s=x,n=0,o=Math.abs(e-x)}return o},jn:{},rm:new yt,pr:new yt,yr:0,lm:100};C.za=C.HF;var Ve=(x=>(x[x.Line=1]="Line",x[x.Rectangle=2]="Rectangle",x[x.Ellipse=3]="Ellipse",x[x.Path=4]="Path",x))(Ve||{}),Ri=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x))(Ri||{});class wt{n;am;hm;kc;Nu;Lu;Wn;Jn;$n;W;Li;Ai;ni;oi;Ys;Pc;Sc;constructor(t,e){V.Je(this),this.n=2,t===void 0&&(t=4),this.W=t,this.Li=0,this.Ai=0,this.ni=0,this.oi=0,t===4?this.Ys=new q:this.Ys=wt.ex,this.am=this.Ys.rt,this.hm=new I,this.kc=null,this.Nu=null,this.Lu=NaN,this.Wn=T.TopLeft,this.Jn=T.BottomRight,this.Pc=NaN,this.Sc=NaN,this.$n=2,e&&Object.assign(this,e)}copy(){let t=new wt;if(t.n=this.n&-2,t.W=this.W,t.Li=this.Li,t.Ai=this.Ai,t.ni=this.ni,t.oi=this.oi,this.W===4){let e=this.Ys.r,i=t.Ys;for(let s=0;s<e.length;s++){let n=e[s];i.add(n.copy())}t.Ys=i}else t.Ys=this.Ys;return t.am=this.am,t.hm.h(this.hm),t.kc=this.kc,t.Nu=this.Nu,t.Lu=this.Lu,t.Wn=this.Wn.C(),t.Jn=this.Jn.C(),t.Pc=this.Pc,t.Sc=this.Sc,t.$n=this.$n,t}static Line=1;static Rectangle=2;static Ellipse=3;static Path=4;static ex=new q().k();get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){if(this.u=!0,this.type!==4)return this;let t=this.figures;t.k();for(let e of t)e.k();return this}equalsApprox(t){if(!(t instanceof wt))return!1;if(this.type!==t.type)return this.type===1&&t.type===4?this.qL(t):t.type===1&&this.type===4?t.qL(this):!1;if(this.type===4){let e=this.figures.r,i=t.figures.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}else return C.c(this.startX,t.startX)&&C.c(this.startY,t.startY)&&C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)}qL(t){if(this.type!==1||t.type!==4)return!1;if(t.figures.count===1){let e=t.figures.elt(0);if(e.segments.count===1&&C.c(this.startX,e.startX)&&C.c(this.startY,e.startY)){let i=e.segments.elt(0);if(i.type===2&&C.c(this.endX,i.endX)&&C.c(this.endY,i.endY))return!0}}return!1}static stringify(t){return t.toString()}static stringifyFixed(t){return m.s(t,"number",wt,"stringifyFixed:digits"),e=>e.toString(t)}fe(t){t in Ve?this.type=t:m.ur(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+e(this.startX)+" "+e(this.startY)+"L"+e(this.endX)+" "+e(this.endY);case 2:return i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0?"M"+i.x.toString()+" "+i.y.toString()+"H"+i.right.toString()+"V"+i.bottom.toString()+"H"+i.left.toString()+"z":"M"+e(i.x)+" "+e(i.y)+"H"+e(i.right)+"V"+e(i.bottom)+"H"+e(i.left)+"z";case 3:if(i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0){let r=i.left.toString()+" "+(i.y+i.height/2).toString(),a=i.right.toString()+" "+(i.y+i.height/2).toString();return"M"+r+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+a+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+r}else{let r=e(i.left)+" "+e(i.y+i.height/2),a=e(i.right)+" "+e(i.y+i.height/2);return"M"+r+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+a+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+r}case 4:let s="",n=this.figures.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];r>0&&(s+=" x "),a.isFilled&&(s+="F "),s+=a.toString(t)}return s;default:return Ve[this.type]}}static fillPath(t){typeof t!="string"&&m.si(t,"string",wt,"fillPath:str");let e=t.split(/[Xx]/),i=e.length,s="";for(let n=0;n<i;n++){let o=e[n];if(o.match(/[Ff]/)!==null){n===0?s+=o:s+="X"+(o[0]===" "?"":" ")+o;continue}s+=(n===0?"":"X ")+"F"+(o[0]===" "?"":" ")+o}return s}static cm="UuBbMmZzLlHhVvCcSsQqTtAaFfXx";static parse(t,e){e===void 0&&(e=!1),typeof t!="string"&&m.si(t,"string",wt,"parse:str");let i=new RegExp("(["+wt.cm+"])(["+wt.cm+"])","gm"),s=new RegExp("(["+wt.cm+"])([^s])","gm"),n=new RegExp("([^s])(["+wt.cm+"])","gm");t=t.replace(/,/gm," "),t=t.replace(i,"$1 $2"),t=t.replace(i,"$1 $2"),t=t.replace(s,"$1 $2"),t=t.replace(n,"$1 $2"),t=t.replace(/([0-9])([+\-])/gm,"$1 $2"),t=t.replace(/[\s\r\t\n]+/gm," "),t=t.replace(/^\s+|\s+$/g,"");let o=t.split(" ");for(let F=0;F<o.length;F++){let O=o[F];if(O.match(/(\.[0-9]*)(\.)/gm)!==null){let E=m.st(),B="",X=!1;for(let z=0;z<O.length;z++){let U=O[z];U==="."&&!X?(X=!0,B+=U):U==="."?(E.push(B),B="."):B+=U}E.push(B),o.splice(F,1);for(let z=0;z<E.length;z++)o.splice(F+z,0,E[z]);F+=E.length-1,m.Z(E)}}let r=-1,a="",h="",l=new P(0,0),u=new P(0,0),c=new P(0,0),d=!0;function f(){return r>=w-1||o[r+1].match(M)!==null?!0:(d=!1,!1)}function p(){return r++,o[r]}function g(F){let O=parseFloat(p()),E=parseFloat(p());a===a.toLowerCase()&&(O=c.x+O,E=c.y+E),F.e(O,E)}function y(){return g(c),c}function b(){return g(u),u}function v(){let F=h.toLowerCase();return F==="c"||F==="s"||F==="q"||F==="t"?new P(2*c.x-u.x,2*c.y-u.y):new P(c.x,c.y)}let w=o.length,k=Ne.jL(null),S=!1,N=!1,D=!1,L=!0,M=new RegExp("["+wt.cm+"]");for(;!(r>=w-1);){if(h=a,a=p(),a==="")continue;d=!0;let F=!1;switch(a.toUpperCase()){case"X":L=!0,S=!1,N=!1;break;case"M":let O=y();for(k.Ne===null||L===!0?(k.Au(O.x,O.y,S,!1,!N,D),L=!1):k.ZF(O.x,O.y),l.h(c);!f();){let E=y();k.Ks(E.x,E.y)}break;case"L":for(;!f();){let E=y();k.Ks(E.x,E.y)}d&&(F=!0);break;case"H":for(;!f();)c.e((a===a.toLowerCase()?c.x:0)+parseFloat(p()),c.y),k.Ks(c.x,c.y);break;case"V":for(;!f();)c.e(c.x,(a===a.toLowerCase()?c.y:0)+parseFloat(p())),k.Ks(c.x,c.y);d&&(F=!0);break;case"C":for(;!f();){let E=new P;g(E);let B=b(),X=y();k.wr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"S":for(;!f();){let E=v(),B=b(),X=y();k.wr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"Q":for(;!f();){let E=b(),B=y();k.Tu(E.x,E.y,B.x,B.y)}d&&(F=!0);break;case"T":for(;!f();){let E=v();u.h(E);let B=y();k.Tu(E.x,E.y,B.x,B.y),u.h(B)}d&&(F=!0);break;case"B":for(;!f();){let E=parseFloat(p()),B=parseFloat(p()),X=parseFloat(p()),z=parseFloat(p()),U=parseFloat(p()),tt=U,st=!1;f()||(tt=parseFloat(p()),f()||(st=parseFloat(p())!==0)),a===a.toLowerCase()&&(X+=c.x,z+=c.y),k.QF(E,B,X,z,U,tt,st)}d&&(F=!0);break;case"A":for(;!f();){let E=Math.abs(parseFloat(p())),B=Math.abs(parseFloat(p())),X=parseFloat(p()),z=!1,U=!1,tt=0,st=0,Z=p();Z.length===1?(z=!!parseFloat(Z),U=!!parseFloat(p()),tt=parseFloat(p()),st=parseFloat(p())):Z.length===2?(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(p()),st=parseFloat(p())):(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(Z.slice(2)),st=parseFloat(p())),a===a.toLowerCase()&&(tt=c.x+tt,st=c.y+st),c.e(tt,st),k._F(E,B,X,z,U,tt,st)}d&&(F=!0);break;case"Z":k.tR(),c.h(l);break;case"F":{let E="",B=1;for(;o[r+B];){if(o[r+B]==="0"){D=!0,B++;continue}if(o[r+B].match(/[Uu]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?S=!0:k.eR();break}case"U":{let E="",B=1;for(;o[r+B];){if(o[r+B].match(/[Ff]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?N=!0:k.iR(!1);break}default:if(a==="0"||a==="1")break;m.ne("Unknown geometry command: "+a);break}if(F){m.ne(`Bad geometry command: ${a}, next token: ${p()},
|
|
3
3
|
string: ${t}`);break}}let A=k.fm;if(Ne.WL(k),e){let F=A.figures.iterator;for(;F.next();){let O=F.value;O.isFilled=!0}}return A}static JL(t,e){let i=t.length,s=P.l();for(let n=0;n<i;n++){let o=t[n];s.x=o[0],s.y=o[1],e.gt(s),o[0]=s.x,o[1]=s.y,s.x=o[2],s.y=o[3],e.gt(s),o[2]=s.x,o[3]=s.y,s.x=o[4],s.y=o[5],e.gt(s),o[4]=s.x,o[5]=s.y,s.x=o[6],s.y=o[7],e.gt(s),o[6]=s.x,o[7]=s.y}P.i(s)}RP(){if(this.yt)return!0;if(this.type===4){let t=this.figures;if(this.am!==t.rt)return!0;let e=this.figures.r,i=e.length;for(let s=0;s<i;s++)if(e[s].RP())return!0}return!1}ix(){if(this.yt=!1,this.kc=null,this.Nu=null,this.Lu=NaN,this.type===4){let e=this.figures;this.am=e.rt;let i=this.figures.r,s=i.length;for(let n=0;n<s;n++)i[n].sR()}let t=this.hm;isNaN(this.Pc)||isNaN(this.Sc)?t.e(0,0,0,0):t.e(0,0,this.Pc,this.Sc),this.$L(t,!1),t.re(0,0,0,0)}computeBoundsWithoutOrigin(){let t=new I;return this.$L(t,!0),t}$L(t,e){switch(this.type){case 1:case 2:case 3:e?t.e(this.Li,this.Ai,0,0):t.re(this.Li,this.Ai,0,0),t.re(this.ni,this.oi,0,0);break;case 4:let i=this.figures,s=i.r,n=i.length;for(let o=0;o<n;o++){let r=s[o];e&&o===0?t.e(r.startX,r.startY,0,0):t.re(r.startX,r.startY,0,0);let a=r.segments.r,h=a.length,l=r.startX,u=r.startY;for(let c=0;c<h;c++){let d=a[c];switch(d.type){case 2:case 1:l=d.endX,u=d.endY,t.re(l,u,0,0);break;case 3:C.Cu(l,u,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,t),l=d.endX,u=d.endY;break;case 4:C.FP(l,u,d.point1X,d.point1Y,d.endX,d.endY,.5,t),l=d.endX,u=d.endY;break;case 5:case 6:let f=d.type===5?d.vo(r):d.$a(r,l,u),p=f.length;if(p===0){l=d.type===5?d.centerX:d.endX,u=d.type===5?d.centerY:d.endY,t.re(l,u,0,0);break}let g=null;for(let y=0;y<p;y++)g=f[y],C.Cu(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],.5,t);g!==null&&(l=g[6],u=g[7]);break;default:m.o("Unknown Segment type: "+d.type)}}}break;default:m.o("Unknown Geometry type: "+this.type)}}nR(t,e){let i=this.bounds,s=t/i.width,n=e/i.height;return isFinite(s)||(s=1),isFinite(n)||(n=1),s===1&&n===1?this:this.copy().scale(s,n)}normalize(){this.u&&m.L(this);let t=this.computeBoundsWithoutOrigin();return this.offset(-t.x,-t.y),new P(-t.x,-t.y)}offset(t,e){return this.u&&m.L(this),this.v(1,0,0,1,t,e),this}scale(t,e){return this.u&&m.L(this),this.v(t,0,0,e,0,0),this}rotate(t,e,i){this.u&&m.L(this),e===void 0&&(e=0),i===void 0&&(i=0);let s=Nt.l();return s.Ue(),s.ks(t,e,i),this.v(s.m11,s.m12,s.m21,s.m22,s.dx,s.dy),Nt.i(s),this}v(t,e,i,s,n,o){let r=0,a=0;switch(this.type){case 1:case 2:case 3:r=this.Li,a=this.Ai,this.Li=r*t+a*i+n,this.Ai=r*e+a*s+o,r=this.ni,a=this.oi,this.ni=r*t+a*i+n,this.oi=r*e+a*s+o;break;case 4:let h=this.figures.r,l=h.length;for(let u=0;u<l;u++){let c=h[u];r=c.startX,a=c.startY,c.startX=r*t+a*i+n,c.startY=r*e+a*s+o;let d=c.segments.r,f=d.length;for(let p=0;p<f;p++){let g=d[p];switch(g.type){case 2:case 1:r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o;break;case 3:r=g.point1X,a=g.point1Y,g.point1X=r*t+a*i+n,g.point1Y=r*e+a*s+o,r=g.point2X,a=g.point2Y,g.point2X=r*t+a*i+n,g.point2Y=r*e+a*s+o,r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o;break;case 4:r=g.point1X,a=g.point1Y,g.point1X=r*t+a*i+n,g.point1Y=r*e+a*s+o,r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o;break;case 5:if(r=g.centerX,a=g.centerY,g.centerX=r*t+a*i+n,g.centerY=r*e+a*s+o,e!==0){let y=Math.atan2(e,t)*180/Math.PI;y<0&&(y+=360),g.startAngle+=y}t<0&&(g.startAngle=180-g.startAngle,g.sweepAngle=-g.sweepAngle),s<0&&(g.startAngle=-g.startAngle,g.sweepAngle=-g.sweepAngle),g.radiusX*=Math.sqrt(t*t+i*i),g.radiusY!==void 0&&(g.radiusY*=Math.sqrt(e*e+s*s));break;case 6:if(r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o,g.radiusX===0||g.radiusY===0)break;if(e!==0){let y=Math.atan2(e,t)*180/Math.PI;y<0&&(y+=360),g.xAxisRotation+=y}t<0&&(g.xAxisRotation=180-g.xAxisRotation,g.isClockwiseArc=!g.isClockwiseArc),s<0&&(g.xAxisRotation=-g.xAxisRotation,g.isClockwiseArc=!g.isClockwiseArc),g.radiusX*=Math.sqrt(t*t+i*i),g.radiusY*=Math.sqrt(e*e+s*s);break;default:m.o("Unknown Segment type: "+g.type)}}}break}return this.yt=!0,this}containsPoint(t,e){e===void 0&&(e=0);let i=this.Li,s=this.Ai,n=this.ni,o=this.oi;switch(this.type){case 1:return C.Ve(i,s,n,o,e,t.x,t.y);case 2:{let r=Math.min(i,n)-e,a=Math.min(s,o)-e,h=Math.abs(n-i)+e*2,l=Math.abs(o-s)+e*2,u=I.z(r,a,h,l),c=u.containsPoint(t);return I.i(u),c}case 3:{let r=Math.min(i,n)-e,a=Math.min(s,o)-e,h=Math.abs(n-i)+e*2,l=Math.abs(o-s)+e*2,u=h/2,c=l/2;return u<=0||c<=0?!1:(r=t.x-(r+u),a=t.y-(a+c),r*r/(u*u)+a*a/(c*c)<=1)}case 4:return this.OP(t,e,!0,!1);default:return!1}}OP(t,e,i,s){let n=t.x,o=t.y,r=this.bounds.x-20,a=o,h=0,l=0,u=0,c=0,d=0,f=0,p=this.figures.r,g=p.length;for(let y=0;y<g;y++){let b=p[y],v=!b.isEvenOdd;if(b.isFilled){if(i&&b.IP(n,o,e))return!0}else{if(b.IP(n,o,s?e:e+2))return!0;continue}let w=b.segments;l=b.startX,u=b.startY;let k=l,S=u,N=w.r,D=N[0];for(let L=0;L<=w.length;L++){let M;switch(L!==w.length?(D=N[L],M=D.type,d=D.endX,f=D.endY):(M=2,d=k,f=S),M){case 1:{let A=this.nx(n,o,r,a,l,u,k,S);if(isNaN(A))return!0;h+=A,k=d,S=f;break}case 2:{let A=this.nx(n,o,r,a,l,u,d,f);if(isNaN(A))return!0;h+=A;break}case 3:c=C.om(l,u,D.point1X,D.point1Y,D.point2X,D.point2Y,d,f,r,a,n,o,.5),h+=c;break;case 4:{let A=(l+2*D.point1X)/3,F=(u+2*D.point1Y)/3,O=(D.point1X*2+d)/3,E=(D.point1Y*2+f)/3;c=C.om(l,u,A,F,O,E,d,f,r,a,n,o,.5),h+=c;break}case 5:case 6:{let A=D.type===5?D.vo(b):D.$a(b,l,u),F=A.length;if(F===0){let E=this.nx(n,o,r,a,l,u,D.type===5?D.centerX:D.endX,D.type===5?D.centerY:D.endY);if(isNaN(E))return!0;h+=E;break}let O=null;for(let E=0;E<F;E++){if(O=A[E],E===0){let B=this.nx(n,o,r,a,l,u,O[0],O[1]);if(isNaN(B))return!0;h+=B}c=C.om(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],r,a,n,o,.5),h+=c}O!==null&&(d=O[6],f=O[7]);break}default:m.o("Unknown Segment type: "+D.type)}l=d,u=f}if(v){if(h!==0)return!0}else if(h%2!==0)return!0;h=0}return!1}nx(t,e,i,s,n,o,r,a){if(C.Ve(n,o,r,a,.05,t,e))return NaN;let h=(t-i)*(o-a);if(h===0)return 0;let l=((t*s-e*i)*(n-r)-(t-i)*(n*a-o*r))/h,u=(t*s-e*i)*(o-a)/h;if(l>=t)return 0;if((n>r?n-r:r-n)<(o>a?o-a:a-o)){if(o<a){if(u<o||u>a)return 0}else if(u<a||u>o)return 0}else if(n<r){if(l<n||l>r)return 0}else if(l<r||l>n)return 0;return h>0?1:-1}ZL(t,e,i){let s=this.figures.r,n=s.length;for(let o=0;o<n;o++)if(s[o].IP(t,e,i))return!0;return!1}getPointAlongPath(t,e){if(t<0?t=0:t>1&&(t=1),e===void 0&&(e=new P),this.type===1)return e.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),e;let i=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=i.length,r=n*t,a=0;for(let h=0;h<o;h++){let l=s[h],u=l.length;for(let c=0;c<u;c++){let d=l[c];if(a+d>=r){let f=r-a,p=d===0?0:f/d,g=i[h],y=g[c*2],b=g[c*2+1],v=g[c*2+2],w=g[c*2+3];return e.e(y+(v-y)*p,b+(w-b)*p),e}a+=d}}return e}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;let e=this.flattenedSegments,i=this.flattenedLengths,s=this.flattenedTotalLength,n=e.length,o=s*t,r=0;for(let a=0;a<n;a++){let h=i[a],l=h.length;for(let u=0;u<l;u++){let c=h[u];if(r+c>=o){let d=e[a],f=d[u*2],p=d[u*2+1],g=d[u*2+2],y=d[u*2+3];return Math.abs(g-f)<1&&Math.abs(y-p)<1?0:Math.abs(g-f)<1?y-p>=0?90:270:Math.abs(y-p)<1?g-f>=0?0:180:Math.atan2(y-p,g-f)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,e){if(t<0?t=0:t>1&&(t=1),e===void 0&&(e=[]),e.length=3,this.type===1)return e[0]=this.startX+t*(this.endX-this.startX),e[1]=this.startY+t*(this.endY-this.startY),e[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,e;let i=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=i.length,r=n*t,a=0;for(let h=0;h<o;h++){let l=s[h],u=l.length;for(let c=0;c<u;c++){let d=l[c];if(a+d>=r){let f=r-a,p=d===0?0:f/d,g=i[h],y=g[c*2],b=g[c*2+1],v=g[c*2+2],w=g[c*2+3];e[0]=y+(v-y)*p,e[1]=b+(w-b)*p;let k;return Math.abs(v-y)<1&&Math.abs(w-b)<1?k=0:Math.abs(v-y)<1?k=w-b>=0?90:270:Math.abs(w-b)<1?k=v-y>=0?0:180:k=Math.atan2(w-b,v-y)*180/Math.PI,e[2]=k,e}a+=d}}return e}getFractionForPoint(t){if(this.type===1){let e=this.startX,i=this.startY,s=this.endX,n=this.endY;if(e===s&&i===n)return 0;{let o=t.x,r=t.y,a=0,h=0;if(e===s)return i<n?(a=i,h=n):(a=n,h=i),r<=a?a===i?0:1:r>=h?h===i?0:1:Math.abs(r-i)/(h-a);if(i===n)return e<s?(a=e,h=s):(a=s,h=e),o<=a?a===e?0:1:o>=h?h===e?0:1:Math.abs(o-e)/(h-a);{let l=(s-e)**2+(n-i)**2,u=P.l();C.Ll(e,i,s,n,o,r,u);let c=u.x,d=u.y;return P.i(u),Math.sqrt(((c-e)**2+(d-i)**2)/l)}}}else if(this.type===2){let e=this.startX,i=this.startY,s=this.endX,n=this.endY;if(e===s&&i===n)return 0;{let o=s-e,r=n-i,a=o*2+r*2,h=t.x,l=t.y;h=Math.min(Math.max(h,e),s),l=Math.min(Math.max(l,i),n);let u=Math.abs(h-e),c=Math.abs(h-s),d=Math.abs(l-i),f=Math.abs(l-n),p=Math.min(u,c,d,f);if(p===d)return h/a;if(p===c)return(o+l)/a;if(p===f)return(o*2+r-h)/a;if(p===u)return(o*2+r*2-l)/a}}else{let e=this.flattenedSegments,i=this.flattenedLengths,s=this.flattenedTotalLength,n=P.l(),o=1/0,r=0,a=0,h=e.length,l=0,u=0;for(let d=0;d<h;d++){let f=e[d],p=i[d],g=f.length;for(let y=0;y<g;y+=2){let b=f[y],v=f[y+1];if(y===0){l=b,u=v;continue}C.Ll(l,u,b,v,t.x,t.y,n);let w=(n.x-t.x)**2+(n.y-t.y)**2;w<o&&(o=w,r=a,r+=Math.sqrt((n.x-l)**2+(n.y-u)**2)),a+=p[(y-2)/2],l=b,u=v}}P.i(n);let c=r/s;return c<0?0:c>1?1:c}return 0}get flattenedSegments(){return this.QL(),this.kc}QL(){if(this.kc===null){let t=this.kc=[],e=this.Nu=[];this.oR(t,e)}}get flattenedLengths(){return this.QL(),this.Nu}get flattenedTotalLength(){let t=this.Lu;if(isNaN(t)){if(this.type===1){let e=Math.abs(this.endX-this.startX),i=Math.abs(this.endY-this.startY);t=Math.sqrt(e*e+i*i)}else if(this.type===2){let e=Math.abs(this.endX-this.startX),i=Math.abs(this.endY-this.startY);t=e*2+i*2}else{let e=this.flattenedLengths,i=e.length;t=0;for(let s=0;s<i;s++){let n=e[s],o=n.length;for(let r=0;r<o;r++)t+=n[r]}}this.Lu=t}return t}EP(t){let e=[],i=0,s=0,n=t.length;for(let o=0;o<n;o+=2){let r=t[o],a=t[o+1];if(o===0){i=r,s=a;continue}let h=Math.sqrt(P.distanceSquared(i,s,r,a));e.push(h),i=r,s=a}return e}oR(t,e){let i=[],s=[];if(this.type===1)i.push(this.startX),i.push(this.startY),i.push(this.endX),i.push(this.endY),t.push(i),s.push(Math.sqrt((this.startX-this.endX)**2+(this.startY-this.endY)**2)),e.push(s);else if(this.type===2)i.push(this.startX),i.push(this.startY),i.push(this.endX),i.push(this.startY),i.push(this.endX),i.push(this.endY),i.push(this.startX),i.push(this.endY),i.push(this.startX),i.push(this.startY),t.push(i),s.push(Math.abs(this.startX-this.endX)),s.push(Math.abs(this.startY-this.endY)),s.push(Math.abs(this.startX-this.endX)),s.push(Math.abs(this.startY-this.endY)),e.push(s);else if(this.type===3){let n=new zt;n.startX=this.endX,n.startY=(this.startY+this.endY)/2;let o=new mt(5);o.startAngle=0,o.sweepAngle=360,o.centerX=(this.startX+this.endX)/2,o.centerY=(this.startY+this.endY)/2,o.radiusX=Math.abs(this.startX-this.endX)/2,o.radiusY=Math.abs(this.startY-this.endY)/2,n.add(o);let r=o.vo(n),a=r.length;if(a===0)i.push(o.centerX),i.push(o.centerY);else{let h=n.startX,l=n.startY;for(let u=0;u<a;u++){let c=r[u];C.qn(h,l,c[2],c[3],c[4],c[5],c[6],c[7],.5,i),h=c[6],l=c[7]}}t.push(i),e.push(this.EP(i))}else{let n=this.figures.iterator;for(;n.next();){let o=n.value;i=[],i.push(o.startX),i.push(o.startY);let r=o.startX,a=o.startY,h=r,l=a,u=o.segments.r,c=u.length;for(let d=0;d<c;d++){let f=u[d];switch(f.type){case 1:i.length>=4&&(t.push(i),e.push(this.EP(i))),i=[],i.push(f.endX),i.push(f.endY),r=f.endX,a=f.endY,h=r,l=a;break;case 2:i.push(f.endX),i.push(f.endY),r=f.endX,a=f.endY;break;case 3:C.qn(r,a,f.point1X,f.point1Y,f.point2X,f.point2Y,f.endX,f.endY,.5,i),r=f.endX,a=f.endY;break;case 4:C.sm(r,a,f.point1X,f.point1Y,f.endX,f.endY,.5,i),r=f.endX,a=f.endY;break;case 5:{let p=f.vo(o),g=p.length;if(g===0){i.push(f.centerX),i.push(f.centerY),r=f.centerX,a=f.centerY;break}for(let y=0;y<g;y++){let b=p[y];C.qn(r,a,b[2],b[3],b[4],b[5],b[6],b[7],.5,i),r=b[6],a=b[7]}break}case 6:{let p=f.$a(o,r,a),g=p.length,y=f.endX,b=f.endY;if(g===0){i.push(y),i.push(b),r=y,a=b;break}for(let v=0;v<g;v++){let w=p[v];C.qn(r,a,w[2],w[3],w[4],w[5],w[6],w[7],.5,i),r=w[6],a=w[7]}break}default:m.o("Segment not of valid type: "+f.type)}f.isClosed&&(i.push(h),i.push(l))}i.length>=4&&(t.push(i),e.push(this.EP(i)))}}}get type(){return this.W}set type(t){this.W!==t&&(this.u&&m.L(this,t),this.W=t,t===4?this.Ys=new q:(wt.ex===null&&(wt.ex=new q().k()),this.Ys=wt.ex),this.yt=!0)}get startX(){return this.Li}set startX(t){this.Li!==t&&(this.u&&m.L(this,t),this.Li=t,this.yt=!0)}get startY(){return this.Ai}set startY(t){this.Ai!==t&&(this.u&&m.L(this,t),this.Ai=t,this.yt=!0)}get endX(){return this.ni}set endX(t){this.ni!==t&&(this.u&&m.L(this,t),this.ni=t,this.yt=!0)}get endY(){return this.oi}set endY(t){this.oi!==t&&(this.u&&m.L(this,t),this.oi=t,this.yt=!0)}get figures(){return this.Ys}set figures(t){this.Ys!==t&&(this.u&&m.L(this,t),this.Ys=t,this.yt=!0)}add(t){return this.Ys.add(t),this}setSpots(t,e,i,s,n,o,r,a){return this.u&&m.L(this),this.Wn=new T(t,e,n,o),this.Jn=new T(i,s,r,a),this}get spot1(){return this.Wn}set spot1(t){this.u&&m.L(this,t),this.Wn=t.C()}get spot2(){return this.Jn}set spot2(t){this.u&&m.L(this,t),this.Jn=t.C()}get defaultStretch(){return this.$n}set defaultStretch(t){this.$n=t}get bounds(){return this.RP()&&this.ix(),this.hm}polygonClosestSegment(t,e){if(e===void 0&&(e=10),this.type!==4)return null;let i=t.x,s=t.y,n=1/0,o=0,r=0,a=0,h=0,l=0,u=0,c=0,d=0;return this.figures.each(f=>{let p=f.startX,g=f.startY;f.segments.each(y=>{let b=y.endX,v=y.endY,w=0;if(y.type===2)w=P.distanceLineSegmentSquared(i,s,p,g,b,v);else{p=y.endX,g=y.endY;return}w<n&&(n=w,o=a,r=h,l=p,u=g,c=b,d=v),p=b,g=v,h++,y.isClosed&&(b=f.startX,v=f.startY,w=P.distanceLineSegmentSquared(i,s,p,g,b,v),w<n&&(n=w,o=a,r=h,l=p,u=g,c=b,d=v),h++)}),a++,h=0}),n<e*e?{figi:o,segi:r,ax:l,ay:u,bx:c,by:d}:null}get polygonArea(){if(this.type===4){let t=this.figures.iterator,e=0,i=0,s=0,n=0,o=0;for(;t.next();){let r=t.value;if(!r.isFilled)continue;e=r.startX,i=r.startY;let a=r.segments.iterator;for(;a.next();){let h=a.value;s=h.endX,n=h.endY,h.type===1||h.type!==5&&(o+=e*n-i*s),e=s,i=n}o+=e*r.startY-i*r.startX}return Math.abs(o)/2}else if(this.type===2){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return t*e}else if(this.type===3){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return Math.PI*t/2*e/2}else return 0}get polygonLength(){if(this.type===4){let t=this.figures.iterator,e=0,i=0,s=0,n=0,o=0;for(;t.next();){let r=t.value;e=r.startX,i=r.startY;let a=r.segments.iterator;for(;a.next();){let l=a.value;s=l.endX,n=l.endY,l.type===1||l.type!==5&&(o+=Math.sqrt((s-e)*(s-e)+(n-i)*(n-i))),e=s,i=n}let h=r.segments.last();h&&h.isClosed&&(s=r.startX,n=r.startY,o+=Math.sqrt((s-e)*(s-e)+(n-i)*(n-i)))}return o}else if(this.type===2){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return t*2+e*2}else if(this.type===3){let t=Math.abs(this.startX-this.endX)/2,e=Math.abs(this.startY-this.endY)/2;if(t+e===0)return 0;let i=(t-e)*(t-e)/((t+e)*(t+e)),s=i,n=1+s/4;return s*=i,n+=s/64,s*=i,n+=s/256,s*=i,n+=s*25/16384,s*=i,n+=s*49/65536,s*=i,n+=s*441/1048576,Math.PI*(t+e)*n}else{let t=this.startX,e=this.startY,i=this.endX,s=this.endY;return Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}}static computeConvexHull(t){t.sort((s,n)=>s.x===n.x?n.y-s.y:n.x-s.x);let e=[];for(let s=0;s<t.length;s++){for(;e.length>=2&&t[s].compareWithLineSegmentPoint(e[e.length-2],e[e.length-1])>=0;)e.pop();e.push(t[s])}e.pop();let i=[];for(let s=t.length-1;s>=0;s--){for(;i.length>=2&&t[s].compareWithLineSegmentPoint(i[i.length-2],i[i.length-1])>=0;)i.pop();i.push(t[s])}return i.pop(),e.concat(i)}static generatePolygon(t,e,i){e===void 0&&(e=0),i===void 0&&(i=!0);let s=new wt;if(t.length>1)if(e>0)if(i){t.push(t[0]),t.push(t[1]);let n=!0,o=new zt(0,0,i,!1);for(let a=1;a<t.length;a++){let h=(t[a-1].x+t[a].x)/2,l=(t[a-1].y+t[a].y)/2,u=t[a-1].distanceSquaredPoint(t[a]),c=.5*e/Math.sqrt(u);if(c<.5){let d=t[a-1].x+(t[a].x-t[a-1].x)*c,f=t[a-1].y+(t[a].y-t[a-1].y)*c;if(n?(n=!1,o.startX=d,o.startY=f):o.add(new mt(3,d,f,t[a-1].x,t[a-1].y,t[a-1].x,t[a-1].y)),a<t.length-1){let p=t[a].x+(t[a-1].x-t[a].x)*c,g=t[a].y+(t[a-1].y-t[a].y)*c;o.add(new mt(2,p,g))}}else n?(n=!1,o.startX=h,o.startY=l):o.add(new mt(3,h,l,t[a-1].x,t[a-1].y,t[a-1].x,t[a-1].y))}let r=o.segments.last();r&&r.close(),s.add(o)}else{let n=new zt(t[0].x,t[0].y,!1,!1);for(let o=1;o<t.length;o++){let r=(t[o-1].x+t[o].x)/2,a=(t[o-1].y+t[o].y)/2,h=t[o-1].distanceSquaredPoint(t[o]),l=.5*e/Math.sqrt(h);if(l<.5){if(o>1){let d=t[o-1].x+(t[o].x-t[o-1].x)*l,f=t[o-1].y+(t[o].y-t[o-1].y)*l;n.add(new mt(3,d,f,t[o-1].x,t[o-1].y,t[o-1].x,t[o-1].y))}let u=t[o].x+(t[o-1].x-t[o].x)*l,c=t[o].y+(t[o-1].y-t[o].y)*l;n.add(new mt(2,u,c))}else o>1&&n.add(new mt(3,r,a,t[o-1].x,t[o-1].y,t[o-1].x,t[o-1].y));o===t.length-1&&n.add(new mt(2,t[o].x,t[o].y))}s.add(n)}else{let n=new zt(t[0].x,t[0].y,i,!1);for(let o=1;o<t.length;o++)n.add(new mt(2,t[o].x,t[o].y));if(i){let o=n.segments.last();o&&o.close()}s.add(n)}return s}}wt.stringify=wt.stringify,wt.stringifyFixed=wt.stringifyFixed,wt.fillPath=wt.fillPath,wt.parse=wt.parse;class zt{n;Li;Ai;Mc;um;ji;constructor(t,e,i,s,n){i===void 0&&(i=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(i?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.Li=t:this.Li=0,e!==void 0?this.Ai=e:this.Ai=0,this.Mc=new q,this.um=this.Mc.rt,this.ji=null}copy(){let t=new zt;t.n=this.n&-2,t.Li=this.Li,t.Ai=this.Ai;let e=this.Mc.r,i=e.length,s=t.Mc;for(let n=0;n<i;n++){let o=e[n].copy();s.add(o)}return t.um=this.um,t.ji=this.ji,t}equalsApprox(t){if(!(t instanceof zt)||!C.c(this.startX,t.startX)||!C.c(this.startY,t.startY))return!1;let e=this.segments.r,i=t.segments.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}toString(t){t===void 0&&(t=-1);let e="";if(t<0)e="M"+this.startX.toString()+" "+this.startY.toString();else{let n=o=>o===0?"0":o.toFixed(t);e="M"+n(this.startX)+" "+n(this.startY)}let i=this.segments.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+o.toString(t)}return e}get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){this.u=!0;let t=this.segments;t.k();let e=t.r,i=t.length;for(let s=0;s<i;s++)e[s].k();return this}RP(){if(this.yt)return!0;let t=this.segments;if(this.um!==t.rt)return!0;for(let e of t)if(e.yt)return!0;return!1}sR(){this.yt=!1,this.ji=null;let t=this.segments;this.um=t.rt;for(let e of t)e.yt=!1,e.Hs=null}get isFilled(){return(this.n&4)!==0}set isFilled(t){this.u&&m.L(this,t),t?this.n|=4:this.n&=-5}get isShadowed(){return(this.n&8)!==0}set isShadowed(t){this.u&&m.L(this,t),t?this.n|=8:this.n&=-9}get isEvenOdd(){return(this.n&16)!==0}set isEvenOdd(t){this.u&&m.L(this,t),t?this.n|=16:this.n&=-17}get startX(){return this.Li}set startX(t){this.u&&m.L(this,t),this.Li=t,this.ji=null,this.yt=!0}get startY(){return this.Ai}set startY(t){this.u&&m.L(this,t),this.Ai=t,this.ji=null,this.yt=!0}get segments(){return this.Mc}set segments(t){this.u&&m.L(this,t),this.Mc=t,this.ji=null,this.yt=!0}add(t){return this.Mc.add(t),this.ji=null,this}IP(t,e,i){let s=this,n=s.startX,o=s.startY,r=n,a=o,h=s.segments.r,l=h.length;for(let u=0;u<l;u++){let c=h[u];switch(c.type){case 1:r=c.endX,a=c.endY,n=c.endX,o=c.endY;break;case 2:if(C.Ve(n,o,c.endX,c.endY,i,t,e))return!0;n=c.endX,o=c.endY;break;case 3:if(C._w(n,o,c.point1X,c.point1Y,c.point2X,c.point2Y,c.endX,c.endY,.5,t,e,i))return!0;n=c.endX,o=c.endY;break;case 4:if(C.vP(n,o,c.point1X,c.point1Y,c.endX,c.endY,.5,t,e,i))return!0;n=c.endX,o=c.endY;break;case 5:case 6:let d=c.type===5?c.vo(s):c.$a(s,n,o),f=d.length,p=c.type===5?c.centerX:c.endX,g=c.type===5?c.centerY:c.endY;if(f===0){if(C.Ve(n,o,p,g,i,t,e))return!0;n=p,o=g;break}let y=null;for(let b=0;b<f;b++)if(y=d[b],b===0&&C.Ve(n,o,y[0],y[1],i,t,e)||C._w(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],.5,t,e,i))return!0;y!==null&&(n=y[6],o=y[7]);break;default:m.o("Unknown Segment type: "+c.type)}if(c.isClosed&&(n!==r||o!==a)&&C.Ve(n,o,r,a,i,t,e))return!0}return!1}}var ni=(x=>(x[x.Move=1]="Move",x[x.Line=2]="Line",x[x.Bezier=3]="Bezier",x[x.QuadraticBezier=4]="QuadraticBezier",x[x.Arc=5]="Arc",x[x.SvgArc=6]="SvgArc",x))(ni||{});class mt{W;n;ni;oi;pn;Tl;Dl;xr;Hs;constructor(t,e,i,s,n,o,r,a){if(V.Je(this),t===void 0&&(t=2),this.W=t,this.n=2,e!==void 0?this.ni=e:this.ni=0,i!==void 0?this.oi=i:this.oi=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.pn=h,this.Tl=0,this.Dl=Math.max(s,0),this.xr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),a&&(this.isClockwiseArc=!0)}else this.pn=s,this.Tl=n,t===5&&(o=Math.max(o,0)),this.Dl=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.xr=r):this.xr=0;this.Hs=null}copy(){let t=new mt;return t.W=this.W,t.n=this.n&-2,t.ni=this.ni,t.oi=this.oi,t.pn=this.pn,t.Tl=this.Tl,t.Dl=this.Dl,t.xr=this.xr,t}equalsApprox(t){if(!(t instanceof mt)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return C.c(this.endX,t.endX)&&C.c(this.endY,t.endY);case 3:return C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)&&C.c(this.point1X,t.point1X)&&C.c(this.point1Y,t.point1Y)&&C.c(this.point2X,t.point2X)&&C.c(this.point2Y,t.point2Y);case 4:return C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)&&C.c(this.point1X,t.point1X)&&C.c(this.point1Y,t.point1Y);case 5:return C.c(this.startAngle,t.startAngle)&&C.c(this.sweepAngle,t.sweepAngle)&&C.c(this.centerX,t.centerX)&&C.c(this.centerY,t.centerY)&&C.c(this.radiusX,t.radiusX)&&C.c(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&C.c(this.xAxisRotation,t.xAxisRotation)&&C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)&&C.c(this.radiusX,t.radiusX)&&C.c(this.radiusY,t.radiusY);default:return!1}}fe(t){t in ni?this.type=t:m.ur(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i="";switch(this.type){case 1:t<0?i="M"+this.endX.toString()+" "+this.endY.toString():i="M"+e(this.endX)+" "+e(this.endY);break;case 2:t<0?i="L"+this.endX.toString()+" "+this.endY.toString():i="L"+e(this.endX)+" "+e(this.endY);break;case 3:t<0?i="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():i="C"+e(this.point1X)+" "+e(this.point1Y)+" "+e(this.point2X)+" "+e(this.point2Y)+" "+e(this.endX)+" "+e(this.endY);break;case 4:t<0?i="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():i="Q"+e(this.point1X)+" "+e(this.point1Y)+" "+e(this.endX)+" "+e(this.endY);break;case 5:t<0?i="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():i="B"+e(this.startAngle)+" "+e(this.sweepAngle)+" "+e(this.centerX)+" "+e(this.centerY)+" "+e(this.radiusX)+" "+e(this.radiusY);break;case 6:t<0?i="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():i="A"+e(this.radiusX)+" "+e(this.radiusY)+" "+e(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+e(this.endX)+" "+e(this.endY);break;default:i=ni[this.type]}return i+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){return this.u=!0,this}close(){return this.isClosed=!0,this}vo(t){if(this.Hs!==null&&t.yt===!1)return this.Hs;let e=this.radiusX,i=this.radiusY;if(i===void 0&&(i=e),e===0||i===0)return this.Hs=[],this.Hs;let s=this.pn,n=this.Tl,o=C.KL(0,0,e<i?e:i,this.startAngle,this.startAngle+this.sweepAngle,!1);if(e!==i){let a=Nt.l();a.Ue(),e<i?a.et(1,i/e):a.et(e/i,1),wt.JL(o,a),Nt.i(a)}let r=o.length;for(let a=0;a<r;a++){let h=o[a];h[0]+=s,h[1]+=n,h[2]+=s,h[3]+=n,h[4]+=s,h[5]+=n,h[6]+=s,h[7]+=n}return this.Hs=o,this.Hs}$a(t,e,i){if(this.Hs!==null&&t.yt===!1)return this.Hs;if(this.radiusX===0||this.radiusY===0)return this.Hs=[],this.Hs;let s=e,n=i,o=this.Dl,r=this.xr;o===0&&(o=1e-4),r===0&&(r=1e-4);let a=this.pn*(Math.PI/180),h=this.isLargeArc,l=this.isClockwiseArc,u=this.ni,c=this.oi,d=Math.cos(a),f=Math.sin(a),p=d*(s-u)/2+f*(n-c)/2,g=-f*(s-u)/2+d*(n-c)/2,y=p*p/(o*o)+g*g/(r*r);y>1&&(o*=Math.sqrt(y),r*=Math.sqrt(y));let b=(h===l?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*p*p)/(o*o*g*g+r*r*p*p));isNaN(b)&&(b=0);let v=b*o*g/r,w=b*-r*p/o;isNaN(v)&&(v=0),isNaN(w)&&(w=0);let k=(s+u)/2+d*v-f*w,S=(n+c)/2+f*v+d*w,N=(et,Q)=>Math.sqrt(et*et+Q*Q),D=(et,Q,rt,ft)=>(et*rt+Q*ft)/(N(et,Q)*N(rt,ft)),L=(et,Q,rt,ft)=>(et*ft<Q*rt?-1:1)*Math.acos(D(et,Q,rt,ft)),M=L(1,0,(p-v)/o,(g-w)/r),A=(p-v)/o,F=(g-w)/r,O=(-p-v)/o,E=(-g-w)/r,B=L(A,F,O,E),X=D(A,F,O,E);X<=-1?B=Math.PI:X>=1&&(B=0),!l&&B>0&&(B=B-2*Math.PI),l&&B<0&&(B=B+2*Math.PI);let z=o>r?o:r,U=o>r?1:o/r,tt=o>r?r/o:1,st=C.KL(0,0,z,M,M+B,!0),Z=Nt.l();return Z.Ue(),Z.Gs(k,S),Z.ks(this.pn,0,0),Z.et(U,tt),wt.JL(st,Z),Nt.i(Z),this.Hs=st,this.Hs}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.yt=!0)}get type(){return this.W}set type(t){this.u&&m.L(this,t),this.W=t,this.yt=!0}get endX(){return this.ni}set endX(t){this.u&&m.L(this,t),this.ni=t,this.yt=!0}get endY(){return this.oi}set endY(t){this.u&&m.L(this,t),this.oi=t,this.yt=!0}get point1X(){return this.pn}set point1X(t){this.u&&m.L(this,t),this.pn=t,this.yt=!0}get point1Y(){return this.Tl}set point1Y(t){this.u&&m.L(this,t),this.Tl=t,this.yt=!0}get point2X(){return this.Dl}set point2X(t){this.u&&m.L(this,t),this.Dl=t,this.yt=!0}get point2Y(){return this.xr}set point2Y(t){this.u&&m.L(this,t),this.xr=t,this.yt=!0}get centerX(){return this.pn}set centerX(t){this.u&&m.L(this,t),this.pn=t,this.yt=!0}get centerY(){return this.Tl}set centerY(t){this.u&&m.L(this,t),this.Tl=t,this.yt=!0}get radiusX(){return this.Dl}set radiusX(t){t<0&&m.J(t,">= zero",mt,"radiusX"),this.u&&m.L(this,t),this.Dl=t,this.yt=!0}get radiusY(){return this.xr}set radiusY(t){t<0&&m.J(t,">= zero",mt,"radiusY"),this.u&&m.L(this,t),this.xr=t,this.yt=!0}get startAngle(){return this.ni}set startAngle(t){this.u&&m.L(this,t),t=t%360,t<0&&(t+=360),this.ni=t,this.yt=!0}get sweepAngle(){return this.oi}set sweepAngle(t){this.u&&m.L(this,t),t>360&&(t=360),t<-360&&(t=-360),this.oi=t,this.yt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.u&&m.L(this,t),t?this.n|=4:this.n&=-5,this.yt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.u&&m.L(this,t),t?this.n|=16:this.n&=-17,this.yt=!0}get xAxisRotation(){return this.pn}set xAxisRotation(t){this.u&&m.L(this,t),t=t%360,t<0&&(t+=360),this.pn=t,this.yt=!0}}class te{a;lx;hx;dm;gm;mm;pm;ym;wm;xm;bm;km;Pm;Sm;Fo;Mm;Cm;Ps;Ti;constructor(){this.a=null,this.lx=new P(0,0).k(),this.hx=new P(0,0).k(),this.dm=0,this.gm=0,this.mm=1,this.pm="",this.ym="",this.wm=!1,this.xm=!1,this.bm=0,this.km=0,this.Pm=!1,this.Sm=!1,this.Fo=!1,this.Mm=null,this.Cm=0,this.Ps=null,this.Ti=null}copy(){let t=new te;return this.clone(t)}clone(t){return t.a=this.a,t.lx.h(this.viewPoint),t.hx.h(this.documentPoint),t.dm=this.dm,t.gm=this.gm,t.mm=this.mm,t.pm=this.pm,t.ym=this.ym,t.wm=this.wm,t.xm=this.xm,t.bm=this.bm,t.km=this.km,t.Pm=this.Pm,t.Sm=this.Sm,t.Fo=this.Fo,t.Mm=this.Mm,t.Cm=this.Cm,t.Ps=this.Ps,t.Ti=this.Ti,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.a}set diagram(t){this.a=t}get viewPoint(){return this.lx}set viewPoint(t){this.lx.h(t)}get documentPoint(){return this.hx}set documentPoint(t){this.hx.h(t)}getMultiTouchViewPoint(t,e){let i=this.diagram;return i===null||i._L(this.event,t,e),e}getMultiTouchDocumentPoint(t,e){let i=this.diagram;return i===null||(i._L(this.event,t,e),e.h(i.transformViewToDoc(e))),e}get modifiers(){return this.dm}set modifiers(t){this.dm=t}get button(){return this.gm}set button(t){if(this.gm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.mm}set buttons(t){this.mm=t}get key(){return this.pm}set key(t){this.pm=t}get code(){return this.ym}set code(t){this.ym=t}get down(){return this.wm}set down(t){this.wm=t}get up(){return this.xm}set up(t){this.xm=t}get clickCount(){return this.bm}set clickCount(t){this.bm=t}get delta(){return this.km}set delta(t){this.km=t}get isMultiTouch(){return this.Pm}set isMultiTouch(t){this.Pm=t}get handled(){return this.Sm}set handled(t){this.Sm=t}get bubbles(){return this.Fo}set bubbles(t){this.Fo=t}get event(){return this.Mm}set event(t){this.Mm=t}get isTouchEvent(){let t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.Cm}set timestamp(t){this.Cm=t}get targetDiagram(){return this.Ps}set targetDiagram(t){this.Ps=t}get targetObject(){return this.Ti}set targetObject(t){this.Ti=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){let t=this.code,e=this.key;return"cxvyzagCXVYZAG".includes(e)?e.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:e}}class wi{a;Pt;Nm;Lm;constructor(){this.a=null,this.Pt="",this.Nm=null,this.Lm=null}copy(){let t=new wi;return t.a=this.a,t.Pt=this.Pt,t.Nm=this.Nm,t.Lm=this.Lm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.a}set diagram(t){this.a=t}get name(){return this.Pt}set name(t){this.Pt=t}get subject(){return this.Nm}set subject(t){this.Nm=t}get parameter(){return this.Lm}set parameter(t){this.Lm=t}}var Ei=(x=>(x[x.Transaction=1]="Transaction",x[x.Property=2]="Property",x[x.Insert=3]="Insert",x[x.Remove=4]="Remove",x))(Ei||{});class ze{Du;Am;yn;Le;a;vu;Cc;Nc;Lc;Ac;constructor(){this.Du=2,this.Am="",this.yn="",this.Le=null,this.a=null,this.vu=null,this.Cc=null,this.Nc=null,this.Lc=null,this.Ac=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Le=null,this.a=null,this.vu=null,this.Cc=null,this.Nc=null,this.Lc=null,this.Ac=null}copy(){let t=new ze;t.Du=this.Du,t.Am=this.Am,t.yn=this.yn,t.Le=this.Le,t.a=this.a,t.vu=this.vu;let e=this.Cc;return m.$(e)&&m.it(e.copyFrozen)?t.Cc=e.copyFrozen():t.Cc=e,e=this.Nc,m.$(e)&&m.it(e.copyFrozen)?t.Nc=e.copyFrozen():t.Nc=e,e=this.Lc,m.$(e)&&m.it(e.copyFrozen)?t.Lc=e.copyFrozen():t.Lc=e,e=this.Ac,m.$(e)&&m.it(e.copyFrozen)?t.Ac=e.copyFrozen():t.Ac=e,t}fe(t){t in Ei?this.change=t:m.ur(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=m.toString(this.object)),this.oldValue!==null&&(t+=" old: "+m.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+m.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.tA(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.tA(this,!1))}get model(){return this.Le}set model(t){this.Le=t}get diagram(){return this.a}set diagram(t){this.a=t}get change(){return this.Du}set change(t){this.Du=t}get modelChange(){return this.Am}set modelChange(t){this.Am=t}get propertyName(){return this.yn}set propertyName(t){this.yn=t}get isTransactionFinished(){return this.Du===1&&(this.yn==="CommittedTransaction"||this.yn==="FinishedUndo"||this.yn==="FinishedRedo")}get object(){return this.vu}set object(t){this.vu=t}get oldValue(){return this.Cc}set oldValue(t){this.Cc=t}get oldParam(){return this.Nc}set oldParam(t){this.Nc=t}get newValue(){return this.Lc}set newValue(t){this.Lc=t}get newParam(){return this.Ac}set newParam(t){this.Ac=t}}class oi{eA;Pt;UP;constructor(){this.eA=new q().k(),this.Pt="",this.UP=!1}toString(t){let e="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){let i=this.changes.count;for(let s=0;s<i;s++){let n=this.changes.elt(s);n!==null&&(e+=`
|
|
4
4
|
`+n.toString())}}return e}clear(){let t=this.changes;t.ce();for(let e=t.count-1;e>=0;e--){let i=t.elt(e);i!==null&&i.clear()}t.clear(),t.k()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){let e=this.changes.elt(t);e!==null&&e.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;let t=this.changes.count;for(let e=0;e<t;e++){let i=this.changes.elt(e);i!==null&&i.redo()}}rR(t){let e=this.changes;for(let i=e.count-1;i>=t;i--){let s=e.elt(i);s!==null&&s.undo(),e.ce(),e.removeAt(i)}e.k()}thaw(){this.changes.ce()}optimize(){if(!this.isComplete)return;let t=this.changes;t.ce();let e=new Map;for(let s=0;s<t.count;s++){let n=t.elt(s);if(n===null||n.change!==2||!n.object)continue;let o=e.get(n.object);o||(o=new Map,e.set(n.object,o));let r=o.get(n.propertyName);r===void 0?o.set(n.propertyName,-1):(r>0&&t.setElt(r,null),o.set(n.propertyName,s))}let i=0;for(let s=0;s<t.count;s++){let n=t.elt(s);n!==null&&(s>i&&t.setElt(i,n),i++)}for(;t.length>i;)t.pop();t.k()}get changes(){return this.eA}get name(){return this.Pt}set name(t){this.Pt=t}get isComplete(){return this.UP}set isComplete(t){this.UP=t}}class vi{cx;Be;iA;qs;VP;Tm;vl;BP;zP;wn;Tc;fx;js;ux;gx;Dm;mx;constructor(t){this.cx=new V,this.Be=!1,this.iA=new q().k(),this.qs=-1,this.VP=999,this.js=!1,this.Tm=null,this.vl=0,this.BP=!1,this.zP=23,this.wn=new q().k(),this.Tc=new q,this.fx=!0,this.ux=!1,this.gx=!1,this.Dm=!1,this.mx=!1,t&&Object.assign(this,t)}toString(t){let e="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;e+="[";let i=this.nestedTransactionNames.count;for(let s=0;s<i;s++)s>0&&(e+=" "),e+=this.nestedTransactionNames.elt(s);if(e+="]",t!==void 0&&t>0){i=this.history.count;for(let s=0;s<i;s++)e+=`
|
|
5
5
|
`+this.history.elt(s).toString(t-1)}return e}clear(){let t=this.history;t.ce();for(let e=t.count-1;e>=0;e--){let i=t.elt(e);i!==null&&i.clear()}t.clear(),this.qs=-1,t.k(),this.js=!1,this.Tm=null,this.vl=0,this.wn.ce(),this.wn.clear(),this.wn.k(),this.Tc.clear(),this.ux=!1,this.gx=!1,this.Dm=!1,this.mx=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.checksTransactionLevel=t.checksTransactionLevel}addModel(t){this.cx.add(t)}removeModel(t){this.cx.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.fx===!0&&(this.fx=!1,this.vl++,this.Fl||this.Rl("StartingFirstTransaction",t,this.currentTransaction),this.vl>0&&this.vl--),this.isEnabled&&(this.wn.ce(),this.wn.add(t),this.wn.k(),this.currentTransaction===null?this.Tc.add(0):this.Tc.add(this.currentTransaction.changes.count)),this.vl++;let e=this.transactionLevel===1;return e&&(this.Fl||this.Rl("StartedTransaction",t,this.currentTransaction)),e}commitTransaction(t){return t===void 0&&(t=""),this.sA(!0,t)}rollbackTransaction(){return this.sA(!1,"")}sA(t,e){if(this.isUndoingRedoing)return!1;this.checksTransactionLevel&&this.transactionLevel<1&&m.ne("Ending transaction without having started a transaction: "+e);let i=this.transactionLevel===1,s=this.currentTransaction;i&&t&&(this.Fl||this.Rl("CommittingTransaction",e,s));let n=0;if(this.transactionLevel>0&&(this.vl--,this.isEnabled)){let o=this.wn.count;o>0&&(e===""&&(e=this.wn.elt(0)),this.wn.ce(),this.wn.removeAt(o-1),this.wn.k());let r=this.Tc.count;r>0&&(n=this.Tc.elt(r-1),this.Tc.removeAt(r-1))}if(i){if(t){if(this.Dm=!1,s===null&&e!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){let o=s;o.isComplete||(o.isComplete=!0,o.name=e),this.discardHistoryAfterIndex();let r=this.history;r.ce();let a=this.maxHistoryLength;if(a>=0){if(a===0)r.clear();else if(r.count>=a){let h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.qs--}}a!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.qs++),r.k(),s=o}this.Fl||this.Rl("CommittedTransaction",e,s)}else{this.js=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Fl||this.Rl("RolledBackTransaction",e,s),this.js=!1}s!==null&&s.clear()}return this.Tm=null,this.yx&&this.clear(),this.yx=!1,this.wx=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.rR(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;let t=this.history;t.ce();for(let e=t.count-1;e>this.historyIndex;e--){let i=t.elt(e);i!==null&&i.clear(),t.removeAt(e),this.Dm=!0}t.k()}thaw(){this.history.ce()}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;let t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;let t=this.transactionToUndo;if(t!==null)try{this.js=!0,this.Rl("StartingUndo","Undo",t),this.qs--,t.undo()}catch(e){m.ne("undo error: "+e.toString())}finally{this.Rl("FinishedUndo","Undo",t),this.js=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;let t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;let t=this.transactionToRedo;if(t!==null)try{this.js=!0,this.Rl("StartingRedo","Redo",t),this.qs++,t.redo()}catch(e){m.ne("redo error: "+e.toString())}finally{this.Rl("FinishedRedo","Redo",t),this.js=!1}}Rl(t,e,i){let s=new ze;s.change=1,s.propertyName=t,s.object=i,s.oldValue=e;let n=this.models;for(;n.next();){let o=n.value;s.model=o,o.lR(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let e=this.currentTransaction;e===null&&(e=new oi,this.Tm=e);let i=t.copy(),s=e.changes;if(s.ce(),s.add(i),s.k(),this.checksTransactionLevel&&this.zP>0&&this.transactionLevel<=0&&!this.fx){let n=t.diagram;if(n!==null&&n.Za===!1)return;m.ne("Change not within a transaction: "+i.toString()),this.zP--}}}skipsEvent(t){if(t===null||t.change===1)return!0;let e=t.object;if(e===null)return!1;if(e.layer!==void 0){let i=e.layer;if(i!==null&&i.isTemporary)return!0}else if(e.isTemporary)return!0;return!1}get models(){return this.cx.iterator}get isEnabled(){return this.Be}set isEnabled(t){this.Be=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex<this.history.count-1?this.history.elt(this.historyIndex+1):null}get isUndoingRedoing(){return this.js}get history(){return this.iA}get maxHistoryLength(){return this.VP}set maxHistoryLength(t){this.VP=t}get historyIndex(){return this.qs}get currentTransaction(){return this.Tm}get transactionLevel(){return this.vl}get isInTransaction(){return this.vl>0}get checksTransactionLevel(){return this.BP}set checksTransactionLevel(t){this.BP=t}get nestedTransactionNames(){return this.wn}get yx(){return this.ux}set yx(t){this.ux=t}get wx(){return this.gx}set wx(t){this.gx=t}get Fl(){return this.mx}set Fl(t){this.mx=t}get isJustDiscarded(){return this.Dm}}class Zt{a;Pt;Be;XP;GP;vm;nA;constructor(){V.Je(this),this.a=Y.Fm(),this.Pt="",this.Be=!0,this.XP=!1,this.GP=null,this.nA=new te,this.vm=-1}get diagram(){return this.a}set diagram(t){t instanceof Y&&(this.a=t)}toString(){return this.name!==""?this.name+" Tool":m.Yn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){let t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){let t=this.diagram,e=t.lastInput,i=e.getMultiTouchViewPoint(0,P.z(NaN,NaN)),s=e.getMultiTouchViewPoint(1,P.z(NaN,NaN));if(!i.isReal()||!s.isReal()){P.i(i),P.i(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.YP=t.scale;let n=s.x-i.x,o=s.y-i.y,r=Math.sqrt(n*n+o*o);t.KP=r,e.bubbles=!1}P.i(i),P.i(s)}standardPinchZoomMove(){let t=this.diagram,e=t.lastInput,i=e.getMultiTouchViewPoint(0,P.z(NaN,NaN)),s=e.getMultiTouchViewPoint(1,P.z(NaN,NaN));if(!i.isReal()||!s.isReal()){P.i(i),P.i(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){let n=s.x-i.x,o=s.y-i.y,r=Math.sqrt(n*n+o*o)/t.KP,a=new P((Math.min(s.x,i.x)+Math.max(s.x,i.x))/2,(Math.min(s.y,i.y)+Math.max(s.y,i.y))/2),h=t.YP*r,l=t.commandHandler;if(h!==t.scale&&l.canResetZoom(h)){let u=t.zoomPoint;t.zoomPoint=a,l.resetZoom(h),t.zoomPoint=u}e.bubbles=!1}P.i(i),P.i(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){let t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){let t=this.diagram;if(!t.allowSelect)return;let e=t.lastInput,i=t.findPartAt(e.documentPoint,!1);if(i!==null){if(m.fr?e.meta:e.control){t.T("ChangingSelection",t.selection);let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.T("ChangedSelection",t.selection)}else if(e.shift){if(!i.isSelected){t.T("ChangingSelection",t.selection);let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.T("ChangedSelection",t.selection)}}else if(!i.isSelected){let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else e.left&&!(m.fr?e.meta:e.control)&&!e.shift&&t.clearSelection()}standardMouseClick(t,e){t===void 0&&(t=null),e===void 0&&(e=o=>!o.layer?.isTemporary);let i=this.diagram,s=i.lastInput,n=i.findObjectAt(s.documentPoint,t,e);return s.targetObject=n,this.oA(n,s,i)}oA(t,e,i){if(e.handled=!1,t!==null&&!t.isEnabledObject())return!1;let s=0;e.left?e.clickCount===1?s=1:e.clickCount===2?s=2:s=1:e.right&&e.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&i.T(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&i.T(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(e,t),e.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=i.click;break;case 2:o=i.doubleClick?i.doubleClick:i.click;break;case 3:o=i.contextClick;break}o!==null&&o(e)}return e.handled}standardMouseOver(){let t=this.diagram,e=t.lastInput;if(t.animationManager.Pe===!0)return;let i=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(e.documentPoint)?t.findObjectAt(e.documentPoint,null,null):null;e.event&&(e.event.type==="pointercancel"||e.event.type==="pointerout")&&(s=null),e.targetObject=s;let n=!1;if(s!==t.Dc){let o=t.Dc,r=o;for(t.Dc=s,this.rA(o,s),e.handled=!1;o!==null;){let a=o.mouseLeave;if(a!==null&&(s===o||s!==null&&s.isContainedBy(o)||(a(e,o,s),n=!0,e.handled)))break;o=o.panel}for(o=r,e.handled=!1;s!==null;){let a=s.mouseEnter;if(a!==null&&(o===s||o!==null&&o.isContainedBy(s)||(a(e,s,o),n=!0,e.handled)))break;s=s.panel}s=t.Dc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,e.handled=!1,o=s;o!==null;){let a=o.mouseOver;if(a!==null&&(a(e,o),n=!0,e.handled))break;o=o.panel}}else{this.doUpdateCursor(null);let o=t.mouseOver;o!==null&&(o(e),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=i}doUpdateCursor(t){let e=this.diagram;e&&(e.currentCursor="")}rA(t,e){}standardMouseWheel(){let t=this.diagram,e=t.lastInput,i=e.delta;if(i===0||!t.documentBounds.isReal())return;let s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!e.shift||n===1&&e.control)){if(i>0?s.canIncreaseZoom():s.canDecreaseZoom()){let o=t.zoomPoint;t.zoomPoint=e.viewPoint,i>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}e.bubbles=!1}else if(n===2&&e.shift||n===1&&!e.control){let o=t.position.copy(),r=e.event,a=r.deltaMode,h=r.deltaX,l=r.deltaY,u="pixel";if((h!==0||l!==0)&&!e.shift){switch(a){case 0:u="pixel";break;case 1:u="line";break;case 2:u="page";break}if(h!==0&&t.allowHorizontalScroll){let c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(u,h>0?"right":"left",Math.abs(h))}if(l!==0&&t.allowVerticalScroll){let c=t.scrollVerticalLineChange;l=l*(c/16),t.scroll(u,l>0?"down":"up",Math.abs(l))}}else!e.shift&&t.allowVerticalScroll?(i=i*3*t.scrollVerticalLineChange,t.scroll(u,i>0?"up":"down",Math.abs(i))):e.shift&&t.allowHorizontalScroll&&(i=i*3*t.scrollHorizontalLineChange,t.scroll(u,i>0?"left":"right",Math.abs(i)));this.doWheelChange(t,o,e)}}doWheelChange(t,e,i){(!t.position.equals(e)||i.event.wheelDeltaX!==0)&&(i.bubbles=!1)}standardWaitAfter(t,e){e===void 0&&(e=this.diagram.lastInput),this.cancelWaitAfter();let i=this,s=e.clone(this.nA);this.vm=m.dn(()=>i.doWaitAfter(s),t)}cancelWaitAfter(){this.vm!==-1&&m.yc(this.vm),this.vm=-1}doWaitAfter(t){}findToolHandleAt(t,e){let i=this.diagram.findObjectAt(t,s=>{for(;s!==null&&!(s.panel instanceof vt);)s=s.panel;return s});return i===null?null:i.part.category===e?i:null}isBeyondDragSize(t,e){let i=this.diagram;t===void 0&&(t=i.firstInput.viewPoint),e===void 0&&(e=i.lastInput.viewPoint);let s=i.toolManager.dragSize,n=s.width,o=s.height;return i.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(e.x-t.x)>n||Math.abs(e.y-t.y)>o}get name(){return this.Pt}set name(t){m.s(t,"string",Zt,"name"),this.Pt=t}get isEnabled(){return this.Be}set isEnabled(t){m.s(t,"boolean",Zt,"isEnabled"),this.Be=t}get isActive(){return this.XP}set isActive(t){m.s(t,"boolean",Zt,"isActive"),this.XP=t}get transactionResult(){return this.GP}set transactionResult(t){t!==null&&m.s(t,"string",Zt,"transactionResult"),this.GP=t}}var Cs=(x=>(x[x.Scroll=1]="Scroll",x[x.Zoom=2]="Zoom",x[x.None=3]="None",x))(Cs||{}),As=(x=>(x[x.Zoom=1]="Zoom",x[x.Cancel=2]="Cancel",x[x.None=3]="None",x))(As||{});class oe extends Zt{lA;aA;hA;HP;qP;jP;WP;JP;$P;ZP;Rm;Qa;constructor(t){super(),this.name="ToolManager",this.lA=new q,this.aA=new q,this.hA=new q,this.HP=850,this.qP=850,this.jP=new nt(2,2).kt(),this.WP=5e3,this.JP=1,this.$P=1,this.ZP=null,this.Rm=null,this.Qa=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.JP}set mouseWheelBehavior(t){this.JP=t}get gestureBehavior(){return this.$P}set gestureBehavior(t){this.$P=t}initializeStandardTools(){return this}updateAdornments(t){let e=this.currentToolTip;if(e instanceof vt&&this.Rm===t){let i=e.adornedObject;(t!==null?i!==null&&i.part===t:i===null)?this.showToolTip(e,i):this.hideToolTip()}}doMouseDown(){let t=this.diagram,e=t.lastInput;if(e.isTouchEvent&&this.gestureBehavior===2&&(e.bubbles=!1),e.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){e.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}let i=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n<s;n++){let o=this.mouseDownTools.elt(n);if(o.diagram=this.diagram,o.canStart()){t.doFocus(),t.currentTool=o,t.currentTool===o&&(o.isActive||o.doActivate(),o.doMouseDown());return}}t.lastInput.button===1&&(this.mouseWheelBehavior===1?this.mouseWheelBehavior=2:this.mouseWheelBehavior===2&&(this.mouseWheelBehavior=1)),this.doActivate(),this.standardWaitAfter(this.holdDelay,e)}doMouseMove(){let t=this.diagram,e=t.lastInput;if(e.isMultiTouch){if(this.gestureBehavior===3){e.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomMove();return}}if(this.isActive){let s=this.mouseMoveTools.length;for(let n=0;n<s;n++){let o=this.mouseMoveTools.elt(n);if(o.diagram=this.diagram,o.canStart()){t.doFocus(),t.currentTool=o,t.currentTool===o&&(o.isActive||o.doActivate(),o.doMouseMove());return}}}this.cA(t);let i=e.event;i!==null&&(i.type==="pointermove"||!i.cancelable)&&(e.bubbles=!0)}cA(t){this.standardMouseOver(),this.isBeyondDragSize()&&this.standardWaitAfter(this.isActive?this.holdDelay:this.hoverDelay,t.lastInput)}rA(t,e){let i=this.currentToolTip;i!==null&&(e!==null&&i instanceof vt&&(e===i||e.isContainedBy(i))||this.hideToolTip())}doWaitAfter(t){let e=this.diagram;if(!e.aR())return;let i=e.lastInput;if(e.lastInput=t,this.doMouseHover(),this.isActive||this.doToolTip(),t.isTouchEvent&&!e.lastInput.handled){let s=t.copy();s.button=2,e.lastInput=s,e.xx=!0,e.doMouseUp()}e.lastInput=i}doMouseHover(){let t=this.diagram,e=t.lastInput;e.targetObject===null&&(e.targetObject=t.findObjectAt(e.documentPoint,null,null));let i=e.targetObject;if(i!==null)for(e.handled=!1;i!==null;){let s=this.isActive?i.mouseHold:i.mouseHover;if(s!==null&&(s(e,i),e.handled))break;i=i.panel}else{let s=this.isActive?t.mouseHold:t.mouseHover;s!==null&&s(e)}}doToolTip(){let t=this.diagram,e=t.lastInput;e.targetObject===null&&(e.targetObject=t.findObjectAt(e.documentPoint,null,null));let i=e.targetObject;if(i!==null){let s=this.currentToolTip;if(s instanceof vt&&(i===s||i.isContainedBy(s)))return;for(;i!==null;){let n=i.toolTip;if(n!==null){this.showToolTip(n,i);return}i=i.panel}this.hideToolTip()}else{let s=t.toolTip;s!==null?this.showToolTip(s,null):this.hideToolTip()}}showToolTip(t,e){e!==null&&m.se(e,J,oe,"showToolTip:obj");let i=this.diagram;if(t!==this.currentToolTip&&this.hideToolTip(),t instanceof vt){t.layerName="Tool",t.selectable=!1,t.scale=1/i.scale,t.category="ToolTip",t.hasPlaceholder()&&(t.placeholder.scale=i.scale);let s=t.diagram;s!==null&&s!==i&&s.remove(t),i.add(t),e!==null?t.adornedObject=e:t.data=i.model,t.ensureBounds(),this.positionToolTip(t,e)}else t instanceof ge&&t!==this.currentToolTip&&t.show!==null&&t.show(e,i,this);this.currentToolTip=t,this.extendToolTip(this.toolTipDuration)}positionToolTip(t,e){if(t.hasPlaceholder())return;let i=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=i.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.x<r.x&&(n.x=r.x),n.y+20/s.scale+o.height>r.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y<r.y&&(n.y=r.y),i.position=n}extendToolTip(t){t===void 0&&(t=3e3),this.currentToolTip!==null&&(this.Qa!==-1&&(m.yc(this.Qa),this.Qa=-1),t>0&&t!==1/0&&(this.Qa=m.dn(()=>this.hideToolTip(),t)))}hideToolTip(){this.Qa!==-1&&(m.yc(this.Qa),this.Qa=-1);let t=this.diagram,e=this.currentToolTip;e!==null&&(e instanceof vt?(t.remove(e),this.Rm!==null&&this.Rm.removeAdornment(e.category),e.data=null,e.adornedObject=null):e instanceof ge&&e.hide!==null&&e.hide(t,this),this.currentToolTip=null)}get currentToolTip(){return this.ZP}set currentToolTip(t){this.ZP=t,this.Rm=t!==null&&t instanceof vt?t.adornedPart:null}doMouseUp(){this.cancelWaitAfter();let t=this.diagram;if(this.isActive){let e=this.mouseUpTools.length;for(let i=0;i<e;i++){let s=this.mouseUpTools.elt(i);if(s.diagram=this.diagram,s.canStart()){t.doFocus(),t.currentTool=s,t.currentTool===s&&(s.isActive||s.doActivate(),s.doMouseUp());return}}}t.doFocus(),this.doDeactivate()}doMouseWheel(){this.standardMouseWheel()}doKeyDown(){let t=this.diagram;t.commandHandler!==null&&t.commandHandler.doKeyDown()}doKeyUp(){let t=this.diagram;t.commandHandler!==null&&t.commandHandler.doKeyUp()}findTool(t){m.s(t,"string",oe,"findTool:name");let e=this.mouseDownTools.length;for(let i=0;i<e;i++){let s=this.mouseDownTools.elt(i);if(s.name===t)return s}e=this.mouseMoveTools.length;for(let i=0;i<e;i++){let s=this.mouseMoveTools.elt(i);if(s.name===t)return s}e=this.mouseUpTools.length;for(let i=0;i<e;i++){let s=this.mouseUpTools.elt(i);if(s.name===t)return s}return null}replaceTool(t,e){m.s(t,"string",oe,"replaceTool:name"),e!==null&&(e.diagram=this.diagram);let i=this.mouseDownTools.length;for(let s=0;s<i;s++){let n=this.mouseDownTools.elt(s);if(n.name===t)return e!==null?this.mouseDownTools.setElt(s,e):this.mouseDownTools.removeAt(s),n}i=this.mouseMoveTools.length;for(let s=0;s<i;s++){let n=this.mouseMoveTools.elt(s);if(n.name===t)return e!==null?this.mouseMoveTools.setElt(s,e):this.mouseMoveTools.removeAt(s),n}i=this.mouseUpTools.length;for(let s=0;s<i;s++){let n=this.mouseUpTools.elt(s);if(n.name===t)return e!==null?this.mouseUpTools.setElt(s,e):this.mouseUpTools.removeAt(s),n}return null}replaceStandardTool(t,e,i){this.Jt(t,e,i)}Jt(t,e,i){m.s(t,"string",oe,"replaceStandardTool:name"),e!==null&&(e.name=t,e.diagram=this.diagram),this.findTool(t)?this.replaceTool(t,e):e!==null&&i.add(e)}get mouseDownTools(){return this.lA}get mouseMoveTools(){return this.aA}get mouseUpTools(){return this.hA}get hoverDelay(){return this.HP}set hoverDelay(t){m.s(t,"number",oe,"hoverDelay"),this.HP=t}get holdDelay(){return this.qP}set holdDelay(t){m.s(t,"number",oe,"holdDelay"),this.qP=t}get dragSize(){return this.jP}set dragSize(t){this.jP=t.C()}get toolTipDuration(){return this.WP}set toolTipDuration(t){m.s(t,"number",oe,"toolTipDuration"),this.WP=t}get actionTool(){return this.findTool("Action")}set actionTool(t){this.Jt("Action",t,this.mouseDownTools)}get relinkingTool(){return this.findTool("Relinking")}set relinkingTool(t){this.Jt("Relinking",t,this.mouseDownTools)}get linkReshapingTool(){return this.findTool("LinkReshaping")}set linkReshapingTool(t){this.Jt("LinkReshaping",t,this.mouseDownTools)}get resizingTool(){return this.findTool("Resizing")}set resizingTool(t){this.Jt("Resizing",t,this.mouseDownTools)}get rotatingTool(){return this.findTool("Rotating")}set rotatingTool(t){this.Jt("Rotating",t,this.mouseDownTools)}get linkingTool(){return this.findTool("Linking")}set linkingTool(t){this.Jt("Linking",t,this.mouseMoveTools)}get draggingTool(){return this.findTool("Dragging")}set draggingTool(t){this.Jt("Dragging",t,this.mouseMoveTools)}get dragSelectingTool(){return this.findTool("DragSelecting")}set dragSelectingTool(t){this.Jt("DragSelecting",t,this.mouseMoveTools)}get panningTool(){return this.findTool("Panning")}set panningTool(t){this.Jt("Panning",t,this.mouseMoveTools)}get contextMenuTool(){return this.findTool("ContextMenu")}set contextMenuTool(t){this.Jt("ContextMenu",t,this.mouseUpTools)}get textEditingTool(){return this.findTool("TextEditing")}set textEditingTool(t){this.Jt("TextEditing",t,this.mouseUpTools)}get clickCreatingTool(){return this.findTool("ClickCreating")}set clickCreatingTool(t){this.Jt("ClickCreating",t,this.mouseUpTools)}get clickSelectingTool(){return this.findTool("ClickSelecting")}set clickSelectingTool(t){this.Jt("ClickSelecting",t,this.mouseUpTools)}}class Tt extends Zt{QP;_P;xn;tS;eS;iS;sS;vc;Om;nS;_a;br;fA;oS;Fu;Ru;rS;lS;aS;hS;static kx=new q;static le=null;static th=null;constructor(t){super(),this.name="Dragging",this.QP=!0,this.hS=!0,this._P=!0,this.xn=null,this.tS=null,this.eS=null,this.iS=null,this.sS=!1,this.Fu=!1,this.vc=new P(NaN,NaN),this.Om=new P,this.nS=!0,this._a=100,this.br=[],this.fA=new V().k(),this.oS=new Pi,this.Ru=null,this.rS="copy",this.lS="",this.aS="no-drop",t&&Object.assign(this,t)}get isCopyEnabled(){return this.QP}set isCopyEnabled(t){m.s(t,"boolean",Tt,"isCopyEnabled"),this.QP=t}get copiesEffectiveCollection(){return this._P}set copiesEffectiveCollection(t){m.s(t,"boolean",Tt,"copiesEffectiveCollection"),this._P=t}get dragOptions(){return this.oS}set dragOptions(t){this.oS=t}get isGridSnapEnabled(){return this.dragOptions.isGridSnapEnabled}set isGridSnapEnabled(t){m.s(t,"boolean",Tt,"isGridSnapEnabled"),this.dragOptions.isGridSnapEnabled=t}get isComplexRoutingRealtime(){return this.nS}set isComplexRoutingRealtime(t){this.nS=t;let e=this.diagram.findRouter("AvoidsLinks");e!==null&&(e.isRealtime=t)}get isGridSnapRealtime(){return this.dragOptions.isGridSnapRealtime}set isGridSnapRealtime(t){m.s(t,"boolean",Tt,"isGridSnapRealtime"),this.dragOptions.isGridSnapRealtime=t}get gridSnapCellSize(){return this.dragOptions.gridSnapCellSize}set gridSnapCellSize(t){this.dragOptions.gridSnapCellSize.equals(t)||(t=t.C(),this.dragOptions.gridSnapCellSize=t)}get gridSnapCellSpot(){return this.dragOptions.gridSnapCellSpot}set gridSnapCellSpot(t){this.dragOptions.gridSnapCellSpot.equals(t)||(t=t.C(),this.dragOptions.gridSnapCellSpot=t)}get gridSnapOrigin(){return this.dragOptions.gridSnapOrigin}set gridSnapOrigin(t){this.dragOptions.gridSnapOrigin.equals(t)||(t=t.C(),this.dragOptions.gridSnapOrigin=t)}get dragsLink(){return this.dragOptions.dragsLink}set dragsLink(t){m.s(t,"boolean",Tt,"dragsLink"),this.dragOptions.dragsLink=t}get dragsTree(){return this.dragOptions.dragsTree}set dragsTree(t){m.s(t,"boolean",Tt,"dragsTree"),this.dragOptions.dragsTree=t}get copyCursor(){return this.rS}set copyCursor(t){this.rS=t}get moveCursor(){return this.lS}set moveCursor(t){this.lS=t}get nodropCursor(){return this.aS}set nodropCursor(t){this.aS=t}get currentPart(){return this.tS}set currentPart(t){t!==null&&m.se(t,pt,Tt,"currentPart"),this.tS=t}get copiedParts(){return this.iS}set copiedParts(t){this.iS=t}get draggedParts(){return this.eS}set draggedParts(t){this.eS=t}get draggingParts(){return this.copiedParts!==null?this.copiedParts.toKeySet():this.draggedParts!==null?this.draggedParts.toKeySet():this.fA}get draggedLink(){return this.diagram.draggedLink}set draggedLink(t){t!==null&&m.se(t,j,Tt,"draggedLink"),this.diagram.draggedLink=t}get isDragOutStarted(){return this.sS}set isDragOutStarted(t){this.sS=t}get startPoint(){return this.Om}set startPoint(t){this.Om.equals(t)||this.Om.h(t)}get delay(){return this._a}set delay(t){m.s(t,"number",Tt,"delay"),this._a=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||t.isReadOnly&&!t.allowDragOut||!t.allowMove&&!t.allowCopy&&!t.allowDragOut||!t.allowSelect)return!1;let e=t.lastInput;return!e.left||t.currentTool!==this&&(!this.isBeyondDragSize()||e.isTouchEvent&&e.timestamp-t.firstInput.timestamp<this._a)?!1:this.findDraggablePart()!==null}findDraggablePart(){let t=this.diagram,e=t.findPartAt(t.firstInput.documentPoint,!1);if(e===null)return null;for(;e!==null&&!e.canSelect();)e=e.containingGroup;return e!==null&&(e.canMove()||e.canCopy())?e:null}standardMouseSelect(){let t=this.diagram;if(!t.allowSelect)return;let e=t.findPartAt(t.firstInput.documentPoint,!1);if(e!==null){for(;e!==null&&!e.canSelect();)e=e.containingGroup;if(this.currentPart=e,this.currentPart!==null&&!this.currentPart.isSelected){t.T("ChangingSelection",t.selection);let i=t.lastInput;!(m.fr?i.meta:i.control)&&!i.shift&&t.clearSelection(!0),this.currentPart.isSelected=!0,t.T("ChangedSelection",t.selection)}}}doActivate(){let t=this.diagram;this.Ru=null,this.currentPart===null&&this.standardMouseSelect();let e=this.currentPart;if(e===null||!e.canMove()&&!e.canCopy())return;t.cacheGroupExternalLinks(!0),Tt.le=null,this.isActive=!0,this.vc.set(t.position),this.cS(t.selection),this.br.length=0,t.animationManager.stopAnimation();let i=this.computeEffectiveCollection(t.selection,this.dragOptions);this.draggedParts=i,this.hS=!!this.diagram.layout.isRealtime,this.diagram.layout.isRealtime=!1,t.Ou=!0,t.getRenderingHint("temporaryPixelRatio")===!0&&t.avgSpf>30&&t.Px(),t.uA(this.draggedParts),t.Iu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.hR()}cS(t){if(!this.dragsLink)return;let e=this.diagram,i=e.model.fS(),s=t.first();i&&t.count===1&&s instanceof j&&this.mayDragLink(s)?(this.draggedLink=s,this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.xn=e.toolManager.findTool("Relinking"),this.xn===null&&(this.xn=new $e,this.xn.diagram=e),this.xn.originalLink=this.draggedLink):(this.draggedLink=null,this.xn=null)}mayDragLink(t){let e=this.diagram;return e!==null&&e.allowRelink}computeEffectiveCollection(t,e){return this.diagram.commandHandler.computeEffectiveCollection(t,e)}Ws(t){return t===void 0?new Xe(P.gn):this.isGridSnapEnabled?new Xe(new P(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new Xe(t.copy())}doDeactivate(){this.isActive=!1;let t=this.diagram;this.diagram.layout.isRealtime=this.hS,t.Iu=!1,t.Ol=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.uS(),t.dS(this.draggedParts),this.Ru=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.Fu=!1,Tt.cR(),this.dA(),this.vc.e(NaN,NaN),Tt.th!==null&&(Tt.th.currentCursor=""),Tt.th=null,Tt.le=null,this.Il(),t.isMouseCaptured=!1,t.currentCursor="",t.Ou=!1,this.stopTransaction(),t.gS(!0)}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}uS(){let t=this.diagram,e=t.skipsUndoManager;t.skipsUndoManager=!0;let i=t.lastInput;this.gA(i,null),t.skipsUndoManager=e,this.br.length=0}mA(){this.Il(),this.mS();let t=this.diagram;this.vc.isReal()&&(t.position=this.vc),t.stopAutoScroll()}doCancel(){this.Il(),this.mS();let t=this.diagram;this.vc.isReal()&&(t.position=this.vc),this.stopTool()}doKeyDown(){let t=this.diagram;if(!this.isActive)return;let e=t.lastInput,i=t.previousInput;e.code==="Escape"?this.doCancel():(e.code!==i.code||e.modifiers!==i.modifiers)&&this.doMouseMove()}doKeyUp(){this.isActive&&this.doMouseMove()}fR(t,e){let i=1/0,s=1/0,n=-1/0,o=-1/0,r=t.iterator;for(;r.next();){let a=r.value;if(!a.isVisible())continue;let h=a.location,l=h.x,u=h.y;isNaN(l)||isNaN(u)||(l<i&&(i=l),u<s&&(s=u),l>n&&(n=l),u>o&&(o=u))}return i===1/0?e.e(0,0,0,0):e.e(i,s,n-i,o-s),e}pS(t){if(this.copiedParts!==null)return;let e=this.diagram;if(t&&(e.isReadOnly||e.isModelReadOnly)||this.draggedParts===null)return;let i=e.undoManager;i.isEnabled&&i.isInTransaction?i.currentTransaction!==null&&i.currentTransaction.changes.count>0&&(e.undoManager.rollbackTransaction(),e.startTransaction("Drag")):this.mS(),e.skipsUndoManager=!t,e.partManager.addsToTemporaryLayer=!t,this.startPoint=e.firstInput.documentPoint;let s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():e.selection,n=e.copyParts(s,e,!0);e.commandHandler.Fc(n);let o=new Mt,r=this.draggedParts.iterator;for(;r.next();){let h=r.key;if(h.Di()&&h.canCopy()){let l=n.get(h);if(l===null)continue;l.location=h.location,l.ensureBounds(),o.set(l,this.Ws(l.location))}}let a=n.iterator;for(;a.next();){let h=a.value;h instanceof j&&h.canCopy()&&o.set(h,this.Ws())}if(this.copiedParts=o,this.cS(o.toKeySet()),this.draggedLink!==null){let h=this.draggedLink,l=h.routeBounds;h.kr(this.startPoint.x-(l.x+l.width/2),this.startPoint.y-(l.y+l.height/2))}this.doUpdateCursor(null)}Il(){let t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){let e=this.draggedParts.iterator;for(;e.next();)if(e.key instanceof j){let i=e.value;i.point=new P(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}dA(){this.draggedLink!==null&&(this.dragsLink&&this.xn!==null&&(this.xn.stopDraggingMouseMove(),this.xn.originalLink=null),this.draggedLink=null,this.xn=null)}Rc(t,e){if(t===null)return;let i=this.diagram,s=this.startPoint,n=P.l();n.h(i.lastInput.documentPoint),this.moveParts(t,n.subtract(s),e),P.i(n),i.getRenderingHint("temporaryPixelRatio")===!0&&i.El===null&&i.avgSpf>30&&(i.Px(),i.Eu())}moveParts(t,e,i){i===void 0&&(i=!1);let s=this.diagram;s!==null&&s.Sx(t,e,this.dragOptions,i)}mS(){if(this.draggedParts===null)return;let t=this.diagram,e=this.draggedParts.iterator;for(;e.next();){let i=e.key;i.Di()&&(i.location=e.value.point)}for(e=this.draggedParts.iterator;e.next();){let i=e.key;if(i instanceof j&&i.suspendsRouting){let s=e.value.point;this.draggedParts.set(i,this.Ws()),i.kr(-s.x,-s.y)}}t.maybeUpdate()}uR(t){if(t===null)return!0;let e=t.part;return!!(e===null||e instanceof vt||e.layer?.isTemporary||this.draggedParts&&this.draggedParts.has(e)||this.copiedParts&&this.copiedParts.has(e))}yS(t){let e=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.pA(!1));let i=this.findDragOverObject(t),s=e.lastInput;s.targetObject=i,this.doUpdateCursor(i);let n=e.skipsUndoManager,o=!1;try{if(e.skipsUndoManager=!0,o=this.gA(s,i),!this.isActive&&Tt.le===null)return;let r=i!==null?i.part:null;if(r===null||e.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof ht)){let a=e.mouseDragOver;a!==null&&(a(s),o=!0)}if(!this.isActive&&Tt.le===null||(this.doDragOver(t,i),!this.isActive&&Tt.le===null))return}finally{e.skipsUndoManager=n,o&&e.maybeUpdate()}this.Ru=i,!e.isReadOnly&&(e.allowMove||e.allowCopy)&&(e.allowHorizontalScroll||e.allowVerticalScroll)&&e.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.wS(t,null,e=>!this.uR(e))}doUpdateCursor(t){let e=this.diagram;(t===null||this.Ru!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?e.currentCursor=this.copyCursor:this.mayMove()?e.currentCursor=this.moveCursor:this.mayDragOut()&&(e.currentCursor=this.nodropCursor))}gA(t,e){let i=!1,s=this.br.length,n=s>0?this.br[0]:null;if(e===n)return!1;t.handled=!1;for(let r=0;r<s;r++){let a=this.br[r],h=a.mouseDragLeave;if(h!==null&&(h(t,a,e),i=!0,t.handled))break}if(this.br.length=0,!this.isActive&&Tt.le===null||e===null)return i;t.handled=!1;let o=e;for(;o!==null;)this.br.push(o),o=this.yA(o);s=this.br.length;for(let r=0;r<s;r++){let a=this.br[r],h=a.mouseDragEnter;if(h!==null&&(h(t,a,n),i=!0,t.handled))break}return i}RU(t,e){return t===null?!1:!!(t===e||t.isContainedBy(e)||e instanceof ht&&!(t instanceof ht)&&e.handlesDragDropForMembers&&t.part?.isMemberOf(e))}yA(t){let e=t.panel;if(e!==null)return e;if(t instanceof pt&&!(t instanceof ht)){let i=t.containingGroup;if(i!==null&&i.handlesDragDropForMembers)return i}return null}wA(t,e){let i=this.diagram,s=this.xn;if(s===null)return null;let n=s.portGravity,o=i.findObjectsNear(t,n,l=>s.findValidLinkablePort(l,e)),r=P.l(),a=1/0,h=null;for(let l=o.iterator;l.next();){let u=l.value;if(u.part===null)continue;let c=u.getDocumentPoint(T.Center,r),d=t.distanceSquaredPoint(c);d<a&&(h=u,a=d)}return P.i(r),h}pA(t){let e=this.draggedLink;if(e!==null){if(e.pointsCount<2)return;let i=this.diagram;if(i.isReadOnly)return;let s=this.xn;if(s===null)return;let n=null,o=null;e.fromNode===null&&(n=this.wA(e.getPoint(0),!1),n!==null&&(o=n.part));let r=null,a=null;e.toNode===null&&(r=this.wA(e.getPoint(e.pointsCount-1),!0),r!==null&&(a=r.part)),s.isValidLink(o,n,a,r)?t?(e.defaultFromPoint=e.getPoint(0),e.defaultToPoint=e.getPoint(e.pointsCount-1),e.suspendsRouting=!1,e.fromNode=o,n!==null&&(e.fromPortId=n.portId),e.toNode=a,r!==null&&(e.toPortId=r.portId),e.fromPort!==i.xS&&i.T("LinkRelinked",e,i.xS),e.toPort!==i.bS&&i.T("LinkRelinked",e,i.bS)):s.doDraggingMouseMove(o,n,a,r):s.doDraggingMouseMove(null,null,null,null)}}doDragOver(t,e){}xA(t){let e=this.diagram;this.dragsLink&&this.pA(!0),this.uS();let i=this.findDragOverObject(t),s=e.lastInput;if(s.targetObject=i,i!==null){s.handled=!1;let a=i;for(;a!==null;){let h=a.mouseDrop;if(h!==null&&(h(s,a),s.handled))break;this.dR(s,a),a=this.yA(a)}}else{let a=e.mouseDrop;a!==null&&a(s)}if(!this.isActive&&Tt.le===null)return;let n=this.copiedParts||this.draggedParts;if(n!==null){let a=n.iterator;for(;a.next();){let h=a.key;h instanceof $&&h.linksConnected.each(l=>l.suspendsRouting=!1)}}if(this.doDropOnto(t,i),!this.isActive&&Tt.le===null)return;let o=I.l(),r=e.selection.iterator;for(;r.next();){let a=r.value;a instanceof $&&this.gR(e,a,o)}I.i(o)}dR(t,e){let i=this.diagram,s=e.part;if(i.handlesDragDropForTopLevelParts&&s!==null&&s.isTopLevel&&!(s instanceof ht)){let n=i.mouseDrop;n!==null&&n(t)}}gR(t,e,i){if(!e.canAvoid())return;let s=!1;i=e.getAvoidableRect(i),t.viewportBounds.containsRect(i)&&(s=!0);let n=this.copiedParts||this.draggedParts;if(n===null)return;let o=t.kS(i,a=>a.part,a=>a instanceof j,!0,a=>a instanceof j,s);if(o.count===0)return;let r=o.iterator;for(;r.next();){let a=r.value;n.has(a)&&n.has(e)||!a.isMemberOf(e)&&a.isAvoiding&&a.$t()}}doDropOnto(t,e){}doMouseMove(){if(!this.isActive)return;let t=this.diagram,e=t.lastInput;this.simulatedMouseMove(e.event,e.documentPoint,e.targetDiagram)||this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.pS(!1),this.Rc(this.copiedParts,!1)):this.mayMove()?(this.Il(),this.Rc(this.draggedParts,!0)):this.mayDragOut()?(this.pS(!1),this.Rc(this.copiedParts,!1)):this.Il(),this.yS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;let t=this.diagram,e=t.lastInput;if(this.simulatedMouseUp(e.event,e.documentPoint,e.targetDiagram))return;let i=!1,s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Il(),this.pS(!0),this.Rc(this.copiedParts,!1),this.copiedParts!==null&&(t.T("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(i=!0,this.Il(),this.mayMove()&&(this.Rc(this.draggedParts,!0),this.yS(t.lastInput.documentPoint))),this.Fu=!0,this.xA(t.lastInput.documentPoint),this.isActive){let n=s&&this.copiedParts,o=n?this.copiedParts?.toKeySet():this.draggedParts?this.draggedParts.toKeySet():null;this.copiedParts=null,i&&this.mR(),t.invalidateDocumentBounds(),t.dS(this.draggedParts),this.transactionResult=n?"Copy":"Move",t.T(n?"SelectionCopied":"SelectionMoved",o)}this.stopTool(),s&&t.T("ChangedSelection",t.selection)}simulatedMouseMove(t,e,i){if(Tt.le===null)return!1;let s=Tt.le.diagram;i instanceof Y||(i=null);let n=Tt.th;if(i!==n){if(n!==null&&n!==s){n.stopAutoScroll(),Tt.le.isDragOutStarted=!1;let r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(Tt.th=i,i!==null&&i!==s){Tt.le.mA();let r=i.toolManager.findTool("Dragging");r!==null&&(r.bA(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(i===null||i===s||!i.allowDrop||i.isReadOnly||!i.allowInsert)return!1;let o=i.toolManager.findTool("Dragging");if(o!==null){let r=e;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=i.getMouse(t)),i.lastInput.documentPoint=r,i.lastInput.viewPoint=i.transformDocToView(r),i.lastInput.down=!1,i.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,e,i){if(Tt.le===null)return!1;let s=Tt.th,n=Tt.le.diagram;if(i===null)return Tt.le.doCancel(),!0;if(i!==s){if(s!==null){let r=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&r!==null)return s.stopAutoScroll(),Tt.le.isDragOutStarted=!1,r.doSimulatedDragLeave(),!1}Tt.th=i;let o=i.toolManager.findTool("Dragging");o!==null&&(Tt.le.mA(),o.bA(),o.doSimulatedDragEnter())}if(i!==this.diagram){let o=e;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=i.getMouse(t)):o===null&&(o=new P),i.lastInput.documentPoint=o,i.lastInput.viewPoint=i.transformDocToView(o),i.lastInput.down=!1,i.lastInput.up=!0;let r=i.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();let a=Tt.le;if(a!==null){let h=a.mayCopy();a.transactionResult=h?"Copy":"Move",a.stopTool()}return!0}return!1}mR(){if(this.draggedParts===null)return;let t=this.draggedParts.iterator;for(;t.next();){let e=t.key;if(e instanceof $){let i=e.containingGroup;i!==null&&i.hasPlaceholder()&&!this.draggedParts.has(i)&&i.placeholder.f()}}}mayCopy(){if(!this.isCopyEnabled)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(m.fr?t.lastInput.alt:t.lastInput.control))return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;let t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){let t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}bA(){Tt.kx.has(this)||Tt.kx.add(this)}static cR(){if(Tt.kx.count>0){let t=Tt.kx,e=t.length;for(let i=0;i<e;i++){let s=t.elt(i);s.dA(),s.Il(),s.uS(),s.diagram.stopAutoScroll()}t.clear()}}pR(t,e,i){return!this.Fu&&this.draggedParts!==null&&!this.draggedParts.has(t)?(i.h(e),!0):!1}get draggingSource(){return Tt.le}mayDragIn(){let t=this.diagram;if(!t.allowDrop||t.isReadOnly||t.isModelReadOnly||!t.allowInsert)return!1;let e=Tt.le;return!(e===null||e.diagram.model.dataFormat!==t.model.dataFormat)}doSimulatedDragEnter(){if(!this.mayDragIn())return;let t=this.diagram;t.animationManager.stopAnimation(),t.Pr(),t.animationManager.stopAnimation();let e=Tt.le;e!==null&&(this.diagram.Ou=!0,t.lastInput.event===null&&(t.lastInput.event=e.diagram.lastInput.event)),this.doUpdateCursor(null)}doSimulatedDragLeave(){let t=Tt.le;t!==null&&t.doSimulatedDragOut(),this.diagram.Ou=!1,this.doCancel()}doSimulatedDragOver(){let t=this.diagram;t.animationManager.Uu=!0;let e=Tt.le;if(e!==null&&e.draggedParts!==null){if(!this.mayDragIn())return;this.kA(e.draggedParts.toKeySet(),!1,t.firstInput),this.Rc(this.copiedParts,!1),this.yS(t.lastInput.documentPoint)}t.animationManager.Uu=!1}doSimulatedDrop(){let t=this.diagram,e=Tt.le;if(e!==null){let i=e.diagram;if(e.Fu=!0,this.Il(),e.draggedParts===null||!this.mayDragIn())return;t.animationManager.Uu=!0,t.T("ChangingSelection",t.selection),this.startTransaction("Drop"),this.kA(e.draggedParts.toKeySet(),!0,t.lastInput),this.Rc(this.copiedParts,!1);let s=new V;this.copiedParts!==null&&(t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0,s.add(n)})),this.xA(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.Ou=!1,t.T("ExternalObjectsDropped",s,i),this.stopTransaction(),t.T("ChangedSelection",t.selection)}t.animationManager.Uu=!1}kA(t,e,i){if(this.copiedParts!==null)return;let s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!e,s.partManager.addsToTemporaryLayer=!e,this.startPoint=i.documentPoint;let n=s.copyParts(t,s,!0);s.commandHandler.Fc(n);let o=I.l();this.fR(t,o);let r=o.x+o.width/2,a=o.y+o.height/2;I.i(o);let h=this.Om,l=new Mt,u=P.l(),c=t.iterator;for(;c.next();){let f=c.value;if(f instanceof j&&f.canCopy()){let p=n.get(f);if(p===null)continue;p.points=f.points,p.kr(h.x-r,h.y-a),p.suspendsRouting=!0,l.set(p,this.Ws())}}let d=t.iterator;for(;d.next();){let f=d.value;if(f.Di()&&f.canCopy()){let p=n.get(f);if(p===null)continue;let g=f.location;u.e(h.x-(r-g.x),h.y-(a-g.y)),p.location=u,p.ensureBounds(),l.set(p,this.Ws(u))}}if(P.i(u),this.copiedParts=l,this.cS(l.toKeySet()),this.draggedLink!==null){let f=this.draggedLink,p=f.routeBounds;f.kr(this.startPoint.x-(p.x+p.width/2),this.startPoint.y-(p.y+p.height/2))}this.doUpdateCursor(null)}hR(){this.isDragOutStarted=!0,this.Fu=!1,Tt.le=this,Tt.th=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){let t=this.diagram;!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Ru=null}computeMove(t,e,i,s){let n=this.diagram;return n!==null?n.computeMove(t,e,this.dragOptions,s):new P}}oe.prototype.doCancel=function(){Tt.le!==null&&Tt.le.doCancel(),Zt.prototype.doCancel.call(this)};class he extends Zt{PS;SS;Ul;MS;CS;eh;NS;ih;LS;AS;TS;DS;vS;FS;PA;RS;Vl;OS;constructor(){super(),this.PS=100,this.SS=!1,this.Ul="pointer",this.MS=new j({layerName:"Tool"}).add(new it({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new it({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).It(),this.eh=new it("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:nt.CP}).theme("stroke","tempPort"),this.CS=new $({selectable:!1,layerName:"Tool"}).add(this.eh).It(),this.ih=new it("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:nt.CP}).theme("stroke","tempPort"),this.NS=new $({selectable:!1,layerName:"Tool"}).add(this.ih).It(),this.LS=null,this.AS=null,this.TS=null,this.DS=null,this.vS=null,this.FS=!0,this.PA=new Mt,this.RS=null,this.Vl=null,this.OS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.PS}set portGravity(t){m.s(t,"number",he,"portGravity"),t>=0&&(this.PS=t)}get isUnconnectedLinkValid(){return this.SS}set isUnconnectedLinkValid(t){m.s(t,"boolean",he,"isUnconnectedLinkValid"),this.SS=t}get linkingCursor(){return this.Ul}set linkingCursor(t){this.Ul=t}get temporaryLink(){return this.MS}set temporaryLink(t){t.It(),this.MS=t}get temporaryFromNode(){return this.CS}set temporaryFromNode(t){t.It(),this.CS=t,t&&(this.eh=t.port)}get temporaryFromPort(){return this.eh}set temporaryFromPort(t){if(this.eh!==null){let e=this.eh.panel;if(e!==null){let i=e.D.indexOf(this.eh);e.removeAt(i),e.insertAt(i,t)}}this.eh=t}get temporaryToNode(){return this.NS}set temporaryToNode(t){t.It(),this.NS=t,t&&(this.ih=t.port)}get temporaryToPort(){return this.ih}set temporaryToPort(t){if(this.ih!==null){let e=this.ih.panel;if(e!==null){let i=e.D.indexOf(this.ih);e.removeAt(i),e.insertAt(i,t)}}this.ih=t}get originalLink(){return this.LS}set originalLink(t){t!==null&&m.se(t,j,he,"originalLink"),this.LS=t}get originalFromNode(){return this.AS}set originalFromNode(t){t!==null&&m.se(t,$,he,"originalFromNode"),this.AS=t}get originalFromPort(){return this.TS}set originalFromPort(t){t!==null&&m.se(t,J,he,"originalFromPort"),this.TS=t}get originalToNode(){return this.DS}set originalToNode(t){t!==null&&m.se(t,$,he,"originalToNode"),this.DS=t}get originalToPort(){return this.vS}set originalToPort(t){t!==null&&m.se(t,J,he,"originalToPort"),this.vS=t}get isForwards(){return this.FS}set isForwards(t){this.FS=t}get validPortsCache(){return this.PA}get targetPort(){return this.RS}set targetPort(t){t!==null&&m.se(t,J,he,"targetPort"),this.RS=t}copyPortProperties(t,e,i,s,n){if(t===null||e===null||i===null||s===null)return;let o=e.getDocumentScale(),r=nt.l();r.width=e.naturalBounds.width*o,r.height=e.naturalBounds.height*o,s.desiredSize=r,nt.i(r),n?(s.toSpot=e.toSpot,s.toEndSegmentLength=e.toEndSegmentLength):(s.fromSpot=e.fromSpot,s.fromEndSegmentLength=e.fromEndSegmentLength),i.locationSpot=T.Center;let a=P.l();i.location=e.getDocumentPoint(T.Center,a),P.i(a),s.angle=e.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,e,i,s,n)}setNoTargetPortProperties(t,e,i){e!==null&&(e.desiredSize=nt.CP,e.fromSpot=T.None,e.toSpot=T.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,e,i)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){let t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof $){let e=this.targetPort.part;this.isForwards?this.copyPortProperties(e,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(e,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,e){if(t===null)return null;let i=t.part;if(!(i instanceof $))return null;for(;t!==null;){let s=e?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof $)&&(e?this.isValidTo(i,t):this.isValidFrom(i,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){let e=this.diagram,i=e.lastInput.documentPoint,s=this.portGravity,n=e.findObjectsNear(i,s,h=>this.findValidLinkablePort(h,t),null,!0),o=1/0,r=null,a=n.iterator;for(;a.next();){let h=a.value,l=h.part;if(!(l instanceof $))continue;let u=h.getDocumentPoint(T.Center,P.l()),c=i.x-u.x,d=i.y-u.y;P.i(u);let f=c*c+d*d;if(f<o){let p=this.validPortsCache.get(h);p!==null?p&&(r=h,o=f):t&&this.isValidLink(this.originalFromNode,this.originalFromPort,l,h)||!t&&this.isValidLink(l,h,this.originalToNode,this.originalToPort)?(this.validPortsCache.set(h,!0),r=h,o=f):this.validPortsCache.set(h,!1)}}if(r!==null){let h=r.part;if(h instanceof $&&(h.layer===null||h.layer.allowLink))return r}return null}isValidFrom(t,e){if(t===null||e===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||e.fromLinkable!==!0))return!1;let i=e.fromMaxLinks;if(i<1/0){if(this.originalLink!==null&&t===this.originalFromNode&&e===this.originalFromPort)return!0;let s=e.portId;if(s===null&&(s=""),t.findLinksOutOf(s).count>=i)return!1}return!0}isValidTo(t,e){if(t===null||e===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||e.toLinkable!==!0))return!1;let i=e.toMaxLinks;if(i<1/0){if(this.originalLink!==null&&t===this.originalToNode&&e===this.originalToPort)return!0;let s=e.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=i)return!1}return!0}isInSameNode(t,e){if(t===null||e===null)return!1;if(t===e)return!0;let i=t.part,s=e.part;return i!==null&&i===s}isLinked(t,e){if(t===null||e===null)return!1;let i=t.part;if(!(i instanceof $))return!1;let s=t.portId;s===null&&(s="");let n=e.part;if(!(n instanceof $))return!1;let o=e.portId;o===null&&(o="");let r=n.findLinksInto(o);for(;r.next();){let a=r.value;if(a.fromNode===i&&a.fromPortId===s)return!0}return!1}isValidLink(t,e,i,s){if(!this.isValidFrom(t,e)||!this.isValidTo(i,s)||e!==null&&s!==null&&(!(e.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(e,s)||!(e.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(e,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||i!==null&&this.isLabelDependentOnLink(i,this.originalLink))||t!==null&&i!==null&&(t.data===null&&i.data!==null||t.data!==null&&i.data===null)||!this.isValidCycle(t,i,this.originalLink))return!1;let n;return t!==null&&e!==null&&(n=t.linkValidation,n!==null&&!n(t,e,i,s,this.originalLink))||i!==null&&s!==null&&(n=i.linkValidation,n!==null&&!n(t,e,i,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,e,i,s,this.originalLink):!0)}isLabelDependentOnLink(t,e){if(t===null)return!1;let i=t.labeledLink;if(i===null)return!1;if(i===e)return!0;let s=new V;return s.add(t),this.IS(i,e,s)}IS(t,e,i){if(t===e)return!0;let s=t.fromNode;if(s!==null&&s.labeledLink&&(i.add(s),this.IS(s.labeledLink,e,i)))return!0;let n=t.toNode;return!!(n!==null&&n.labeledLink&&(i.add(n),this.IS(n.labeledLink,e,i)))}isValidCycle(t,e,i){if(i===void 0&&(i=null),t===null||e===null)return this.isUnconnectedLinkValid;let s=this.diagram,n=1;if(s&&(s.model.Mx()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){let o=i||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;let r=e.linksConnected;for(;r.next();){let a=r.value;if(a!==i&&a.isTreeLink&&a.toNode===e)return!1}return!this.Vu(t,e,i,!0)}else if(n===6){let o=i||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;let r=t.linksConnected;for(;r.next();){let a=r.value;if(a!==i&&a.isTreeLink&&a.fromNode===t)return!1}return!this.Vu(t,e,i,!0)}else{if(n===2)return!this.yR(t,e,i);if(n===3)return!this.Vu(t,e,i,!1);if(n===4)return!this.wR(t,e,i)}return!0}Vu(t,e,i,s){if(t===e)return!0;if(t===null||e===null)return!1;let n=t.linksConnected;for(;n.next();){let o=n.value;if(o===i||s&&!o.isTreeLink||o.toNode!==t)continue;let r=o.fromNode;if(!(r===t||r===null)&&this.Vu(r,e,i,s))return!0}return!1}yR(t,e,i){if(t===e)return!0;let s=new Set;return s.add(e),this.SA(s,t,e,i)}SA(t,e,i,s){if(e===i)return!0;if(e===null||i===null||t.has(e))return!1;t.add(e);let n=e.linksConnected;for(;n.next();){let o=n.value;if(o===s||o.toNode!==e)continue;let r=o.fromNode;if(!(r===e||r===null)&&this.SA(t,r,i,s))return!0}return!1}wR(t,e,i){if(t===e)return!0;let s=new Set;return s.add(e),this.MA(s,t,e,i)}MA(t,e,i,s){if(e===i)return!0;if(e===null||i===null||t.has(e))return!1;t.add(e);let n=e.linksConnected;for(;n.next();){let o=n.value;if(o===s)continue;let r=o.fromNode,a=o.toNode,h=r===e?a:r;if(!(h===e||h===null)&&this.MA(t,h,i,s))return!0}return!1}get linkValidation(){return this.Vl}set linkValidation(t){t!==null&&m.S(t,he,"linkValidation"),this.Vl=t}get portTargeted(){return this.OS}set portTargeted(t){t!==null&&m.S(t,he,"portTargeted"),this.OS=t}}var Ts=(x=>(x[x.Either=1]="Either",x[x.ForwardsOnly=2]="ForwardsOnly",x[x.BackwardsOnly=3]="BackwardsOnly",x))(Ts||{});class Te extends he{ES;US;P;VS;constructor(t){super(),this.name="Linking",this.ES={},this.US=null,this.P=1,this.VS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.ES}set archetypeLinkData(t){t!==null&&m.wc(t,Te,"archetypeLinkData"),t instanceof J&&m.se(t,j,Te,"archetypeLinkData"),this.ES=t}get archetypeLabelNodeData(){return this.US}set archetypeLabelNodeData(t){t!==null&&m.wc(t,Te,"archetypeLabelNodeData"),t instanceof J&&m.se(t,$,Te,"archetypeLabelNodeData"),this.US=t}get direction(){return this.P}set direction(t){this.P=t}get startObject(){return this.VS}set startObject(t){t!==null&&m.se(t,J,Te,"startObject"),this.VS=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Cx()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){let t=this.diagram,e=this.startObject;if(e===null&&(e=t.findObjectAt(t.firstInput.documentPoint,null,null)),e===null)return null;let i=e.part;if(!(i instanceof $))return null;let s=this.direction;if(s===1||s===2){let n=this.findValidLinkablePort(e,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===i){let o=i.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){let n=this.findValidLinkablePort(e,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===i){let o=i.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){let t=this.diagram,e=this.findLinkablePort();if(e===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=e;let i=this.originalFromPort.part;i instanceof $&&(this.originalFromNode=i),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=e;let i=this.originalToPort.part;i instanceof $&&(this.originalToNode=i),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.$t(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;let t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){let t=this.diagram;this.transactionResult=null;let e=null,i=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);let r=this.targetPort;if(r!==null){let a=r.part;a instanceof $&&(this.isForwards?(this.originalFromNode!==null&&(e=this.originalFromNode,i=this.originalFromPort),s=a,n=r):(e=a,i=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(e=this.originalFromNode,i=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);e!==null||s!==null?(o=this.insertLink(e,i,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.T("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.T("LinkDrawn",o)):this.doNoLink(e,i,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.T("ChangedSelection",t.selection)}}}isNewTreeLink(){let t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof j)return t.isTreeLink;let e=this.diagram;if(e===null)return!0;let i=e.partManager.getLinkCategoryForData(t),s=e.partManager.findLinkTemplateForCategory(i);return s!==null?s.isTreeLink:!0}insertLink(t,e,i,s){return this.diagram.partManager.insertLink(t,e,i,s)}doNoLink(t,e,i,s){}}class $e extends he{CA=null;NA=null;BS=null;zS=null;Ss;XS;constructor(t){super(),this.name="Relinking",this.fromHandleArchetype=new it("Diamond",{desiredSize:nt.Su,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.toHandleArchetype=new it("Diamond",{desiredSize:nt.Su,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.XS=new I,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof j))return;let e="RelinkFrom",i=null;if(t.isSelected&&!this.diagram.isReadOnly){let s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(i=t.findAdornment(e),i===null&&(i=this.makeAdornment(s,!1),t.addAdornment(e,i)))}if(i===null&&t.removeAdornment(e),e="RelinkTo",i=null,t.isSelected&&!this.diagram.isReadOnly){let s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(i=t.findAdornment(e),i===null?(i=this.makeAdornment(s,!0),t.addAdornment(e,i)):i.f())}i===null&&t.removeAdornment(e)}makeAdornment(t,e){let i=e?this.zS:this.BS;return i&&(i=i.copy(),i.adornedObject=t),i}get fromHandleArchetype(){return this.CA}set fromHandleArchetype(t){t!==null&&m.se(t,J,$e,"fromHandleArchetype"),this.CA=t,t!==null?this.BS=new vt(G.Link).add(t).It():this.BS=null}get toHandleArchetype(){return this.NA}set toHandleArchetype(t){t!==null&&m.se(t,J,$e,"toHandleArchetype"),this.NA=t,t!==null?this.zS=new vt(G.Link).add(t).It():this.zS=null}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Cx()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){let t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;let s=i.part;if(!(s instanceof vt)||!(s.adornedPart instanceof j))return;this.handle=i,this.isForwards=s===null||s.category==="RelinkTo",this.originalLink=s.adornedPart}let e=this.originalLink;e!==null&&(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=e.fromPort,this.originalFromNode=e.fromNode,this.originalToPort=e.toPort,this.originalToNode=e.toNode,this.XS.set(e.actualBounds),e.pointsCount>0&&(e.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=nt.xc),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=e.getPoint(0))),e.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=nt.xc),this.temporaryToNode!==null&&(this.temporaryToNode.location=e.getPoint(e.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(e,this.temporaryLink),this.temporaryLink.$t(),t.add(this.temporaryLink)),this.isActive=!0)}copyLinkProperties(t,e){if(t===null||e===null)return;e.adjusting=t.adjusting,e.corner=t.corner;let i=t.curve;(i===11||i===10)&&(i=0),e.curve=i,e.curviness=t.curviness,e.isTreeLink=t.isTreeLink,e.points=t.points,e.routing=t.routing,e.smoothness=t.smoothness,e.fromSpot=t.fromSpot,e.fromEndSegmentLength=t.fromEndSegmentLength,e.fromShortLength=t.fromShortLength,e.toSpot=t.toSpot,e.toEndSegmentLength=t.toEndSegmentLength,e.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;let t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){let t=this.diagram;this.transactionResult=null;let e=this.originalFromNode,i=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){let r=this.targetPort.part;r instanceof $&&(this.isForwards?(s=r,n=this.targetPort):(e=r,i=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(e=null,i=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:e,this.isForwards?n:i,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.$t()),this.transactionResult=this.name,t.T("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.originalLink!==null&&this.doNoRelink(this.originalLink,this.isForwards),this.originalLink!==null&&this.originalLink.invalidateOtherJumpOvers(this.XS)}finally{this.stopTool()}}}reconnectLink(t,e,i,s){let n=i!==null&&i.portId!==null?i.portId:"";return s?(t.toNode=e,t.toPortId=n):(t.fromNode=e,t.fromPortId=n),!0}doNoRelink(t,e){}doDraggingMouseMove(t,e,i,s){t!==null?(this.copyPortProperties(t,e,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),i!==null?(this.copyPortProperties(i,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var Ls=(x=>(x[x.None=0]="None",x[x.Horizontal=1]="Horizontal",x[x.Vertical=2]="Vertical",x[x.All=3]="All",x))(Ls||{});class Je extends Zt{Sr;GS;YS;Ss;Nx;KS;Im;constructor(t){super(),this.name="LinkReshaping",this.Sr=new it("Rectangle",{desiredSize:nt.RL,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.GS=new it("Diamond",{desiredSize:nt.Su,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.YS=3,this.Ss=null,this.Nx=null,this.KS=new P,this.Im=new q,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Mr:0}setReshapingBehavior(t,e){t.Mr=e}updateAdornments(t){if(t===null||!(t instanceof j))return;let e=null;if(t.isSelected&&!this.diagram.isReadOnly){let i=t.path;i!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()&&(e=t.findAdornment(this.name),(e===null||e.HS!==t.pointsCount||e.qS!==t.resegmentable)&&(e=this.makeAdornment(i),e!==null&&(e.HS=t.pointsCount,e.qS=t.resegmentable,t.addAdornment(this.name,e))))}e===null&&t.removeAdornment(this.name)}makeAdornment(t){let e=t.part,i=e.points,s=e.pointsCount,n=e.isOrthogonal,o=null;if(i!==null&&s>1){o=new vt,o.type=G.Link;let r=e.firstPickIndex,a=e.lastPickIndex,h=n?1:0;if(e.resegmentable&&(e.computeCurve()!==9||e.isOrthogonal))for(let c=r+h;c<a-h;c++){let d=this.makeResegmentHandle(t,c);d!==null&&(d.segmentIndex=c,d.segmentFraction=.5,d.fromMaxLinks=999,o.add(d))}let l=r+1,u=a-1;for(;l<=u;)if(l<u)this.jS(t,o,r,a,l),this.jS(t,o,r,a,u),l++,u--;else if(l===u){this.jS(t,o,r,a,l);break}o.adornedObject=t}return o}jS(t,e,i,s,n){let o=t.part,r=o.isOrthogonal,a=this.makeHandle(t,n);if(a!==null){if(a.segmentIndex=n,n!==i)if(n===i+1&&r){let h=o.getPoint(i),l=o.getPoint(i+1);C.c(h.x,l.x)&&C.c(h.y,l.y)?(l=o.getPoint(i-1),C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")):C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")}else if(n===s-1&&r){let h=o.getPoint(s-1),l=o.getPoint(s);C.c(h.x,l.x)&&C.c(h.y,l.y)?(h=o.getPoint(s+1),C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")):C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")}else n===s||(this.setReshapingBehavior(a,3),a.cursor="move");e.add(a)}}makeHandle(t,e){let i=this.handleArchetype;return i===null?null:i.copy().WS()}get handleArchetype(){return this.Sr}set handleArchetype(t){t!==null&&m.se(t,J,Je,"handleArchetype"),this.Sr=t}makeResegmentHandle(t,e){let i=this.midHandleArchetype;return i===null?null:i.copy().WS()}get midHandleArchetype(){return this.GS}set midHandleArchetype(t){t!==null&&m.se(t,J,Je,"midHandleArchetype"),this.GS=t}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedLink(){return this.Nx}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowReshape||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;let e=this.handle.part.adornedPart;if(e instanceof j){if(this.Nx=e,t.isMouseCaptured=!0,this.startTransaction(this.name),e.resegmentable&&this.handle.fromMaxLinks===999){let i=e.points.copy(),s=this.getResegmentingPoint();if(i.insertAt(this.handle.segmentIndex+1,s),e.isOrthogonal&&i.insertAt(this.handle.segmentIndex+1,s),e.points=i,e.invalidateAdornments(),e.updateAdornments(),this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name),this.handle===null){this.doDeactivate();return}}this.KS=e.getPoint(this.handle.segmentIndex),this.Im=e.points.copy(),this.isActive=!0}}doDeactivate(){this.stopTransaction(),this.handle=null,this.Nx=null;let t=this.diagram;t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){let t=this.adornedLink;t!==null&&(t.points=this.Im),this.stopTool()}getResegmentingPoint(){return this.handle===null?this.diagram.lastInput.documentPoint:this.handle.getDocumentPoint(T.Center)}doMouseMove(){let t=this.diagram;if(this.isActive){let e=this.computeReshape(t.lastInput.documentPoint);this.reshape(e)}}doMouseUp(){let t=this.diagram;if(this.isActive){let e=this.computeReshape(t.lastInput.documentPoint);this.reshape(e);let i=this.adornedLink;if(i!==null&&i.resegmentable&&this.handle!==null&&(i.computeCurve()!==9||i.isOrthogonal)){let s=this.handle.segmentIndex,n=i.getPoint(s-1),o=i.getPoint(s),r=i.getPoint(s+1);if(i.isOrthogonal){if(s>i.firstPickIndex+1&&s<i.lastPickIndex-1){let a=i.getPoint(s-2);if(this.isWithinResegmentingDistance(n,o)&&(this.isInLineOrtho(a,n,o,r,!0)||this.isInLineOrtho(a,n,o,r,!1))){let h=i.points.copy();this.isInLineOrtho(a,n,o,r,!0)?(h.setElt(s-2,new P(a.x,(r.y+a.y)/2)),h.setElt(s+1,new P(r.x,(r.y+a.y)/2))):(h.setElt(s-2,new P((r.x+a.x)/2,a.y)),h.setElt(s+1,new P((r.x+a.x)/2,r.y))),h.removeAt(s),h.removeAt(s-1),i.points=h,i.invalidateAdornments()}else if(a=i.getPoint(s+2),this.isWithinResegmentingDistance(o,r)&&(this.isInLineOrtho(n,o,r,a,!0)||this.isInLineOrtho(n,o,r,a,!1))){let h=i.points.copy();this.isInLineOrtho(n,o,r,a,!0)?(h.setElt(s-1,new P(n.x,(n.y+a.y)/2)),h.setElt(s+2,new P(a.x,(n.y+a.y)/2))):(h.setElt(s-1,new P((n.x+a.x)/2,n.y)),h.setElt(s+2,new P((n.x+a.x)/2,a.y))),h.removeAt(s+1),h.removeAt(s),i.points=h,i.invalidateAdornments()}}}else{let a=P.l();if(C.Ll(n.x,n.y,r.x,r.y,o.x,o.y,a)&&a.distanceSquaredPoint(o)<this.resegmentingDistance*this.resegmentingDistance){let h=i.points.copy();h.removeAt(s),i.points=h,i.invalidateAdornments()}P.i(a)}}t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("LinkReshaped",this.adornedLink,this.Im)}this.stopTool()}isWithinResegmentingDistance(t,e){return Math.abs(t.x-e.x)<this.resegmentingDistance&&Math.abs(t.y-e.y)<this.resegmentingDistance}isInLineOrtho(t,e,i,s,n){return n?Math.abs(t.y-e.y)<this.resegmentingDistance&&Math.abs(e.y-i.y)<this.resegmentingDistance&&Math.abs(i.y-s.y)<this.resegmentingDistance:Math.abs(t.x-e.x)<this.resegmentingDistance&&Math.abs(e.x-i.x)<this.resegmentingDistance&&Math.abs(i.x-s.x)<this.resegmentingDistance}get resegmentingDistance(){return this.YS}set resegmentingDistance(t){m.s(t,"number",Je,"resegmentingDistance"),this.YS=t}reshape(t){let e=this.adornedLink;if(e===null)return;let i=this.handle;if(i===null)return;e.startRoute();let s=i.segmentIndex,n=this.getReshapingBehavior(i);if(e.isOrthogonal)if(s===e.firstPickIndex+1){let o=e.firstPickIndex+1;n===2?(e.setPointAt(o,e.getPoint(o-1).x,t.y),e.setPointAt(o+1,e.getPoint(o+2).x,t.y)):n===1&&(e.setPointAt(o,t.x,e.getPoint(o-1).y),e.setPointAt(o+1,t.x,e.getPoint(o+2).y))}else if(s===e.lastPickIndex-1){let o=e.lastPickIndex-1;n===2?(e.setPointAt(o-1,e.getPoint(o-2).x,t.y),e.setPointAt(o,e.getPoint(o+1).x,t.y)):n===1&&(e.setPointAt(o-1,t.x,e.getPoint(o-2).y),e.setPointAt(o,t.x,e.getPoint(o+1).y))}else{let o=s,r=e.getPoint(o);if(!t.equalsApprox(r)){let a=e.getPoint(o-2),h=e.getPoint(o-1),l=e.getPoint(o+1),u=e.getPoint(o+2);C.c(h.x,r.x)&&C.c(r.y,l.y)?(C.c(h.x,a.x)&&!C.c(h.y,a.y)&&!C.c(t.x,r.x)?(e.insertPointAt(o,t.x,h.y),s++,o++):e.setPointAt(o-1,t.x,h.y),C.c(l.y,u.y)&&!C.c(l.x,u.x)&&!C.c(t.y,r.y)?e.insertPointAt(o+1,l.x,t.y):e.setPointAt(o+1,l.x,t.y)):C.c(h.y,r.y)&&C.c(r.x,l.x)?(C.c(h.y,a.y)&&!C.c(h.x,a.x)&&!C.c(t.y,r.y)?(e.insertPointAt(o,h.x,t.y),s++,o++):e.setPointAt(o-1,h.x,t.y),C.c(l.x,u.x)&&!C.c(l.y,u.y)&&!C.c(t.x,r.x)?e.insertPointAt(o+1,t.x,l.y):e.setPointAt(o+1,t.x,l.y)):C.c(h.x,r.x)&&C.c(r.x,l.x)?(C.c(h.x,a.x)&&!C.c(h.y,a.y)&&!C.c(t.x,r.x)?(e.insertPointAt(o,t.x,h.y),s++,o++):e.setPointAt(o-1,t.x,h.y),C.c(l.x,u.x)&&!C.c(l.y,u.y)&&!C.c(t.x,r.x)?e.insertPointAt(o+1,t.x,l.y):e.setPointAt(o+1,t.x,l.y)):C.c(h.y,r.y)&&C.c(r.y,l.y)&&(C.c(h.y,a.y)&&!C.c(h.x,a.x)&&!C.c(t.y,r.y)?(e.insertPointAt(o,h.x,t.y),s++,o++):e.setPointAt(o-1,h.x,t.y),C.c(l.y,u.y)&&!C.c(l.x,u.x)&&!C.c(t.y,r.y)?e.insertPointAt(o+1,l.x,t.y):e.setPointAt(o+1,l.x,t.y)),e.setPointAt(s,t.x,t.y)}}else{e.setPointAt(s,t.x,t.y);let o=e.fromNode,r=e.fromPort;if(o!==null){let l=o.findVisibleNode();l!==null&&l!==o&&(o=l,r=o.port)}if(s===1&&r!==null&&e.computeSpot(!0,r).isNoSpot()){let l=r.getDocumentPoint(T.Center,P.l()),u=e.getLinkPointFromPoint(o,r,l,t,!0,P.l());e.setPointAt(0,u.x,u.y),P.i(l),P.i(u)}let a=e.toNode,h=e.toPort;if(a!==null){let l=a.findVisibleNode();l!==null&&l!==a&&(a=l,h=a.port)}if(s===e.pointsCount-2&&h!==null&&e.computeSpot(!1,h).isNoSpot()){let l=h.getDocumentPoint(T.Center,P.l()),u=e.getLinkPointFromPoint(a,h,l,t,!1,P.l());e.setPointAt(e.pointsCount-1,u.x,u.y),P.i(l),P.i(u)}}e.commitRoute()}computeReshape(t){let e=this.adornedLink;if(e===null)return t;let i=this.handle;if(i===null)return t;let s=i.segmentIndex;switch(this.getReshapingBehavior(i)){case 3:return t;case 2:{let n=e.getPoint(s);return new P(n.x,t.y)}case 1:{let n=e.getPoint(s);return new P(t.x,n.y)}default:case 0:return e.getPoint(s)}}get originalPoint(){return this.KS}get originalPoints(){return this.Im}}class Ze extends Zt{Cr;Nr;Ro;Oc;JS;Ms;Sr;Ss;Em;$S;Ic;Lx;Ax;Tx;constructor(t){super(),this.name="Resizing",this.Cr=new nt(1,1).k(),this.Nr=new nt(9999,9999).k(),this.Ro=new nt(NaN,NaN).k(),this.Oc=!1,this.JS=!0,this.Ms=null,this.Sr=new it("Rectangle",{alignmentFocus:T.Center,desiredSize:nt.RL,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.Em=new P,this.$S=new nt,this.Ic=new P,this.Lx=new nt(0,0),this.Ax=new nt(1/0,1/0),this.Tx=new nt(1,1),t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Lr()){let e=t.rotateObject;if(e===t||e===t.path||e.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){let e=t.resizeObject,i=t.findAdornment(this.name);if(e!==null&&t.canResize()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&((i===null||i.adornedObject!==e)&&(i=this.makeAdornment(e)),i!==null)){let s=e.getDocumentAngle();t.Bl()&&this.updateResizeHandles(i,s),t.addAdornment(this.name,i);return}}t.removeAdornment(this.name)}}makeAdornment(t){let e=null,i=t.part?.resizeAdornmentTemplate;if(i){if(e=i.copy(),e===null)return null}else{e=new vt,e.type=G.Spot,e.locationSpot=T.Center;let s=new ue;s.isPanelMain=!0,e.add(s);let n=this.makeHandle(t,T.TopLeft);n!==null&&e.add(n),n=this.makeHandle(t,T.TopRight),n!==null&&e.add(n),n=this.makeHandle(t,T.BottomRight),n!==null&&e.add(n),n=this.makeHandle(t,T.BottomLeft),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleTop),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleRight),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleBottom),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleLeft),n!==null&&e.add(n)}return e.adornedObject=t,e}makeHandle(t,e){let i=this.handleArchetype;if(i===null)return null;let s=i.copy().WS();return s.alignment=e,s}updateResizeHandles(t,e){if(t!==null){if(!t.alignment.isDefault()&&(t.cursor==="pointer"||t.cursor.indexOf("resize")>0))this.xR(t,e);else if(t instanceof G){let i=t.elements;for(;i.next();){let s=i.value;this.updateResizeHandles(s,e)}}}}xR(t,e){let i=t.alignment;i.isNoSpot()&&(i=T.Center);let s=e;if(i.x<=0)i.y<=0?s+=225:i.y>=1?s+=135:s+=180;else if(i.x>=1)i.y<=0?s+=315:i.y>=1&&(s+=45);else if(i.y<=0)s+=270;else if(i.y>=1)s+=90;else return;s=C.Ee(s),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.Sr}set handleArchetype(t){t!==null&&m.se(t,J,Ze,"handleArchetype"),this.Sr=t}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedObject(){return this.Ms}set adornedObject(t){t!==null&&t.part instanceof vt&&m.o("new handle must not be in an Adornment: "+t),this.Ms=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&this.adornedObject.part!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Iu=!0,this.startTransaction(this.name),this.Em.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Ic.set(this.adornedObject.part.location),this.$S.set(this.adornedObject.desiredSize),this.Tx=this.computeCellSize(),this.Lx=this.computeMinSize(),this.Ax=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){let t=this.diagram;t.Iu=!1,t.Ol=!0,this.stopTransaction(),this.handle=null,this.Ms=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){this.adornedObject!==null&&this.adornedObject.part!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){let t=this.diagram;if(!this.isActive||this.adornedObject===null||this.handle===null)return;let e=this.Lx,i=this.Ax,s=this.Tx,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,P.l()),r=this.computeReshape(),a=this.computeResize(o,this.handle.alignment,e,i,s,r);this.resize(a),t.maybeUpdate(),P.i(o)}doMouseUp(){let t=this.diagram;if(this.isActive&&this.adornedObject!==null&&this.handle!==null){let e=this.Lx,i=this.Ax,s=this.Tx,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,P.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,e,i,s,o);this.resize(r),P.i(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){let e=this.diagram,i=this.adornedObject;if(i===null)return;i.desiredSize=t.size;let s=i.part;if(s===null||this.handle===null)return;s.ensureBounds();let n=i.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof ht){let o=new q;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new Pi,r.dragsMembers=!1),e.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);e.maybeUpdate()}computeResize(t,e,i,s,n,o){if(this.adornedObject===null)return I.tm;e.isNoSpot()&&(e=T.Center);let r=this.adornedObject.naturalBounds,a=r.x,h=r.y,l=r.x+r.width,u=r.y+r.height,c=1;if(!o){let p=r.width,g=r.height;p<=0&&(p=1),g<=0&&(g=1),c=g/p}let d=P.l();C._g(t.x,t.y,a,h,n.width,n.height,d);let f=r.copy();return e.x<=0?e.y<=0?(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=Math.max(l-f.x,i.width),f.y=Math.max(d.y,u-s.height),f.y=Math.min(f.y,u-i.height),f.height=Math.max(u-f.y,i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width),f.x=l-f.width,f.y=u-f.height)):e.y>=1?(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=Math.max(l-f.x,i.width),f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width),f.x=l-f.width)):(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=l-f.x,o||(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c,f.y=h+.5*(u-h-f.height))):e.x>=1?e.y<=0?(f.width=Math.max(Math.min(d.x-a,s.width),i.width),f.y=Math.max(d.y,u-s.height),f.y=Math.min(f.y,u-i.height),f.height=Math.max(u-f.y,i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width),f.y=u-f.height)):e.y>=1?(f.width=Math.max(Math.min(d.x-a,s.width),i.width),f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width))):(f.width=Math.max(Math.min(d.x-a,s.width),i.width),o||(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c,f.y=h+.5*(u-h-f.height))):e.y<=0?(f.y=Math.max(d.y,u-s.height),f.y=Math.min(f.y,u-i.height),f.height=u-f.y,o||(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width,f.x=a+.5*(l-a-f.width))):e.y>=1&&(f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width,f.x=a+.5*(l-a-f.width))),P.i(d),f}computeReshape(){let t=0;return this.adornedObject instanceof it&&(t=this.adornedObject.ZS()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){if(this.adornedObject===null)return nt.xc;let t=this.adornedObject.minSize.copy(),e=this.minSize;return!isNaN(e.width)&&e.width>t.width&&(t.width=e.width),!isNaN(e.height)&&e.height>t.height&&(t.height=e.height),t}computeMaxSize(){if(this.adornedObject===null)return nt.NP;let t=this.adornedObject.maxSize.copy(),e=this.maxSize;return!isNaN(e.width)&&e.width<t.width&&(t.width=e.width),!isNaN(e.height)&&e.height<t.height&&(t.height=e.height),t}computeCellSize(){let t=new nt(NaN,NaN),e=this.adornedObject?.part;if(e){let n=e.resizeCellSize;!isNaN(n.width)&&n.width>0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let i=this.cellSize;isNaN(t.width)&&!isNaN(i.width)&&i.width>0&&(t.width=i.width),isNaN(t.height)&&!isNaN(i.height)&&i.height>0&&(t.height=i.height);let s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){let n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(i=n.gridCellSize,isNaN(t.width)&&!isNaN(i.width)&&i.width>0&&(t.width=i.width),isNaN(t.height)&&!isNaN(i.height)&&i.height>0&&(t.height=i.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Cr}set minSize(t){if(!this.Cr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let i=t.height;isNaN(i)&&(i=0),this.Cr.e(e,i)}}get maxSize(){return this.Nr}set maxSize(t){if(!this.Nr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let i=t.height;isNaN(i)&&(i=1/0),this.Nr.e(e,i)}}get cellSize(){return this.Ro}set cellSize(t){this.Ro.equals(t)||this.Ro.h(t)}get isGridSnapEnabled(){return this.Oc}set isGridSnapEnabled(t){m.s(t,"boolean",Ze,"isGridSnapEnabled"),this.Oc=t}get dragsMembers(){return this.JS}set dragsMembers(t){m.s(t,"boolean",Ze,"dragsMembers"),this.JS=t}get oppositePoint(){return this.Em}set oppositePoint(t){this.Em.equals(t)||this.Em.h(t)}get originalDesiredSize(){return this.$S}get originalLocation(){return this.Ic}}class Le extends Zt{QS;_S;Ms=null;Sr=null;Dx=null;Ss=null;tM;Um;Ic;eM;iM;constructor(t){super(),this.name="Rotating",this.QS=45,this._S=2,this.Ic=new P,this.Ms=null,this.handleArchetype=new it("Ellipse",{desiredSize:nt.Su,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.tM=0,this.Um=new P(NaN,NaN),this.eM=0,this.iM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Lr()){let e=t.rotateObject;if(e===t||e===t.path||e.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){let e=t.rotateObject;if(e!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()){let i=t.findAdornment(this.name);if((i===null||i.adornedObject!==e)&&(i=this.makeAdornment(e)),i!==null){i.angle=e.getDocumentAngle(),i.hasPlaceholder()||(i.location=this.computeAdornmentLocation(e)),t.addAdornment(this.name,i);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let e=null,i=t.part?.rotateAdornmentTemplate;return i?e=i.copy():this.Dx!==null&&(e=this.Dx.copy()),e===null?null:(e.adornedObject=t,e)}get handleArchetype(){return this.Sr}set handleArchetype(t){t!==null&&m.se(t,J,Le,"handleArchetype"),this.Sr=t,t!==null?this.Dx=new vt(G.Position,{locationSpot:T.Center}).add(t).It():this.Dx=null}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedObject(){return this.Ms}set adornedObject(t){t!==null&&t.part instanceof vt&&m.o("new handle must not be in an Adornment: "+t),this.Ms=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject===null||this.adornedObject.part===null||(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.tM=this.adornedObject.angle,this.Um=this.computeRotationPoint(this.adornedObject),this.Ic=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){let e=t.part;if(e!==null){let i=e.locationObject;if(e.rotationSpot.isSpot())return t.getDocumentPoint(e.rotationSpot);if(t===e||t===i)return i.getDocumentPoint(e.locationSpot)}return t.getDocumentPoint(T.Center)}computeAdornmentLocation(t){let e=this.rotationPoint;e.isReal()||(e=this.computeRotationPoint(t));let i=t.getLocalPoint(e),s=this.handleAngle;s=C.Ee(s),s=Math.round(Math.round(s/45)*45);let n=this.handleDistance;return s===0?i.x=t.naturalBounds.width+n:s===45?(i.x=t.naturalBounds.width+n,i.y=t.naturalBounds.height+n):s===90?i.y=t.naturalBounds.height+n:s===135?(i.x=-n,i.y=t.naturalBounds.height+n):s===180?i.x=-n:s===225?(i.x=-n,i.y=-n):s===270?i.y=-n:s===315&&(i.x=t.naturalBounds.width+n,i.y=-n),t.getDocumentPoint(i)}doDeactivate(){let t=this.diagram;this.stopTransaction(),this.handle=null,this.Ms=null,this.Um=new P(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){let t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){let t=this.diagram;if(this.isActive){let e=this.computeRotate(t.lastInput.documentPoint);this.rotate(e)}}doMouseUp(){let t=this.diagram;if(this.isActive){t.delaysLayout=!1;let e=this.computeRotate(t.lastInput.documentPoint);this.rotate(e),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){let e=this.adornedObject;if(e===null||e.part===null)return;e.angle=t;let i=e.part;i.ensureBounds();let s=i.locationObject,n=i.rotateObject;if(s===n||s.isContainedBy(n)){let o=this.Ic.copy();i.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let e=this.rotationPoint.directionPoint(t)-this.handleAngle,i=this.adornedObject?.panel;i&&(e-=i.getDocumentAngle()),e=C.Ee(e);let s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(e%s<n?e=Math.floor(e/s)*s:e%s>s-n&&(e=(Math.floor(e/s)+1)*s)),C.Ee(e)}get snapAngleMultiple(){return this.QS}set snapAngleMultiple(t){m.s(t,"number",Le,"snapAngleMultiple"),this.QS=t}get snapAngleEpsilon(){return this._S}set snapAngleEpsilon(t){m.s(t,"number",Le,"snapAngleEpsilon"),this._S=t}get originalAngle(){return this.tM}get rotationPoint(){return this.Um}set rotationPoint(t){this.Um=t.copy()}get handleAngle(){return this.eM}set handleAngle(t){m.s(t,"number",Le,"handleAngle"),this.eM=t}get handleDistance(){return this.iM}set handleDistance(t){m.s(t,"number",Le,"handleDistance"),this.iM=t}}class Ds extends Zt{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class Fs extends Zt{Ec;constructor(t){super(),this.name="Action",this.Ec=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram,e=t.lastInput,i=t.findObjectAt(e.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return i!==null&&i.isActionable?(this.Ec=i,t.Dc=t.findObjectAt(e.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{let t=this.diagram.lastInput,e=this.Ec;if(e===null)return;t.targetObject=e,e.actionDown!==null&&e.actionDown(t,e)}}doMouseMove(){if(this.isActive){let t=this.diagram.lastInput,e=this.Ec;if(e===null)return;t.targetObject=e,e.actionMove!==null&&e.actionMove(t,e)}}doMouseUp(){if(this.isActive){let t=this.diagram.lastInput,e=this.Ec;if(e===null)return;t.targetObject=e,e.actionUp!==null&&e.actionUp(t,e),this.standardMouseClick(i=>{for(;i.panel!==null;){if(i.isActionable&&i===e)return i;i=i.panel}return i},i=>i===e)}this.stopTool()}doCancel(){let t=this.diagram.lastInput,e=this.Ec;e!==null&&(t.targetObject=e,e.actionCancel!==null&&e.actionCancel(t,e),this.stopTool())}doStop(){this.Ec=null}}class Qe extends Zt{zl;sM;Oc;nM;constructor(t){super(),this.name="ClickCreating",this.zl=null,this.sM=!0,this.Oc=!1,this.nM=new P(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.nM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.nM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){let t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){let e=this.diagram,i=this.archetypeNodeData;if(i===null)return null;let s=null;try{if(e.T("ChangingSelection",e.selection),this.startTransaction(this.name),i instanceof pt)i.Di()&&(i.It(),s=i.copy(),s!==null&&e.add(s));else if(i!==null){let n=e.model.copyNodeData(i);e.model.addNodeData(n),s=e.findPartForData(n)}if(s!==null){let n=P.z(t.x,t.y);this.isGridSnapEnabled&&this.diagram.oM(s,t,n),s.location=n,e.allowSelect&&(e.clearSelection(!0),s.isSelected=!0),P.i(n)}e.invalidateDocumentBounds(),this.transactionResult=this.name,e.T("PartCreated",s)}finally{this.stopTransaction(),e.T("ChangedSelection",e.selection)}return s}get archetypeNodeData(){return this.zl}set archetypeNodeData(t){t!==null&&m.wc(t,Qe,"archetypeNodeData"),this.zl=t}get isDoubleClick(){return this.sM}set isDoubleClick(t){m.s(t,"boolean",Qe,"isDoubleClick"),this.sM=t}get isGridSnapEnabled(){return this.Oc}set isGridSnapEnabled(t){m.s(t,"boolean",Qe,"isGridSnapEnabled"),this.Oc=t}}class ri extends Zt{_a;rM;Xl;constructor(t){super(),this.name="DragSelecting",this._a=175,this.rM=!1,this.Xl=new pt({layerName:"Tool",selectable:!1}).add(new it("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).It(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(!t.allowSelect)return!1;let e=t.lastInput;return!(!e.left||t.currentTool!==this&&(!this.isBeyondDragSize()||e.timestamp-t.firstInput.timestamp<this.delay||t.findPartAt(e.documentPoint,!0)!==null))}doActivate(){let t=this.diagram;this.isActive=!0,t.isMouseCaptured=!0,t.skipsUndoManager=!0,this.box&&t.add(this.box),this.doMouseMove()}doDeactivate(){let t=this.diagram;t.stopAutoScroll(),this.box&&t.remove(this.box),t.skipsUndoManager=!1,t.isMouseCaptured=!1,this.isActive=!1}doMouseMove(){let t=this.diagram;if(this.isActive&&this.box!==null){let e=this.computeBoxBounds(),i=this.box.findObject("SHAPE");i===null&&(i=this.box.findMainElement());let s=nt.l().e(e.width,e.height);i!==null&&(i.desiredSize=s),this.box.Uc(e.x,e.y,!1),nt.i(s),(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}doMouseUp(){if(this.isActive){let t=this.diagram;this.box&&t.remove(this.box);try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),this.selectInRect(this.computeBoxBounds()),t.T("ChangedSelection",t.selection)}finally{t.currentCursor=""}}this.stopTool()}computeBoxBounds(){let t=this.diagram;return new I(t.firstInput.documentPoint,t.lastInput.documentPoint)}selectInRect(t){let e=this.diagram,i=e.lastInput,s=e.findPartsIn(t,this.isPartialInclusion);if(m.fr?i.meta:i.control)if(i.shift){let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected&&(o.isSelected=!1)}}else{let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected=!o.isSelected}}else if(i.shift){let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected||(o.isSelected=!0)}}else{let n=new q,o=e.selection.iterator;for(;o.next();){let h=o.value;s.has(h)||n.add(h)}let r=n.iterator;for(;r.next();){let h=r.value;h.isSelected=!1}let a=s.iterator;for(;a.next();){let h=a.value;h.isSelected||(h.isSelected=!0)}}}get delay(){return this._a}set delay(t){m.s(t,"number",ri,"delay"),this._a=t}get isPartialInclusion(){return this.rM}set isPartialInclusion(t){m.s(t,"boolean",ri,"isPartialInclusion"),this.rM=t}get box(){return this.Xl}set box(t){t!==null&&t.It(),this.Xl=t}}class ki extends Zt{vx;LA;Fo;lM;constructor(t){super(),this.name="Panning",this.vx=new P,this.LA=new P,this.Fo=!1;let e=this;this.lM=()=>{let i=e.diagram;i!==null&&i.Ae(K.document,"scroll",e.lM,!1),e.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){let t=this.diagram;this.Fo?(t.lastInput.bubbles=!0,t.Et(K.document,"scroll",this.lM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.vx.h(t.position)),this.isActive=!0}doDeactivate(){let t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){let t=this.diagram;t.position=this.vx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.AA()}doMouseUp(){this.AA(),this.stopTool()}AA(){let t=this.diagram;if(this.isActive&&t){if(this.Fo){t.lastInput.bubbles=!0;return}let e=t.position,i=t.firstInput.documentPoint,s=t.lastInput.documentPoint,n=e.x+i.x-s.x,o=e.y+i.y-s.y;t.allowHorizontalScroll||(n=e.x),t.allowVerticalScroll||(o=e.y),t.position=this.LA.e(n,o)}}get bubbles(){return this.Fo}set bubbles(t){m.s(t,"boolean",ki,"bubbles"),this.Fo=t}get originalPosition(){return this.vx}}class ge{Fx;Rx;aM;hM;constructor(t){this.Fx=null,this.Rx=null,this.aM=null,this.hM=null,t&&Object.assign(this,t)}get mainElement(){return this.aM}set mainElement(t){t!==null&&m.se(t,HTMLElement,ge,"mainElement"),this.aM=t}get show(){return this.Fx}set show(t){this.Fx!==t&&(t!==null&&m.S(t,ge,"show"),this.Fx=t)}get hide(){return this.Rx}set hide(t){this.Rx!==t&&(t!==null&&m.S(t,ge,"hide"),this.Rx=t)}get valueFunction(){return this.hM}set valueFunction(t){this.hM=t}}class de{ue;Ox;Vc;constructor(t,e,i){this.ue=t,this.Ox=e,this.Vc=i}}class It extends Zt{cM;Ix;fM;uM;Ex;Ux;Vm;constructor(t){super(),this.name="ContextMenu",this.cM=null,this.Ix=null,this.fM=null,this.uM=new P,this.Ex=null,this.Vm=!1;let e=this;this.Ux=()=>e.stopTool(),t&&Object.assign(this,t)}bR(){let t=new ge;t.show=(r,a,h)=>h.showDefaultContextMenu(),t.hide=(r,a)=>a.hideDefaultContextMenu(),It.Bu=t;let e=this;this.Ux=()=>e.stopTool();let i=m.Ci("div"),s=m.Ci("div");i.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";let n=m.Ci("style");K.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);let o=this.diagram;o!==null&&(o.Et(i,"contextmenu",It.nh,!1),o.Et(i,"selectstart",It.nh,!1),o.Et(s,"contextmenu",It.nh,!1)),i.className="goCXforeground",s.className="goCXbackground",K.document.body&&(K.document.body.appendChild(i),K.document.body.appendChild(s)),It.Bm=i,It.zm=s,It.dM=!0}static Bu=null;static dM=!1;static zm;static Bm;static nh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){let t=this.diagram;this.uM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Vm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);let e=this.diagram,i=e.lastInput,s=null;if(t instanceof Y||(t instanceof J?s=t:s=e.findObjectAt(i.documentPoint,null,n=>!n.layer?.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(e.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(e.contextMenu!==null)return e;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof vt){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof vt){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){let t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{let e=this.currentContextMenu;if(e===null)return;let i=null;e instanceof ge||(i=t.findObjectAt(t.lastInput.documentPoint,null,null),i!==null&&i.isContainedBy(e)&&this.standardMouseClick(null,null)),this.maybeStopTool(i)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,e){if(e===void 0&&(e=null),this.Vm)return;this.Vm=!0;let i=!1;if(e instanceof Y){let s=this.diagram.lastInput;s.targetObject=null,i=this.oA(null,s,this.diagram)}else t&&this.standardMouseSelect(),i=this.standardMouseClick();if(this.Vm=!1,!i){this.isActive=!0;let s=It.Bu;if(e===null&&(e=this.findObjectWithContextMenu()),e!==null){let n=e.contextMenu;n!==null?(this.currentObject=e instanceof J?e:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof vt&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,e){e!==null&&m.se(e,J,It,"showContextMenu:obj");let i=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof vt){let s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/i.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=i.scale);let n=s.diagram;n!==null&&n!==i&&n.remove(s),i.add(s),e!==null?s.adornedObject=e:s.data=i.model,s.ensureBounds(),this.positionContextMenu(s,e)}else t instanceof ge&&t.show!==null&&t.show(e,i,this);this.currentContextMenu=t}positionContextMenu(t,e){if(t.hasPlaceholder())return;let i=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=i.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.x<r.x&&(n.x=r.x),n.y+o.height>r.bottom&&(n.y-=o.height+5/s.scale),n.y<r.y&&(n.y=r.y),i.position=n}hideContextMenu(){let t=this.diagram,e=this.currentContextMenu;e!==null&&(e instanceof vt?(t.remove(e),this.Ix!==null&&this.Ix.removeAdornment(e.category),e.data=null,e.adornedObject=null):e instanceof ge&&(e.hide!==null?e.hide(t,this):e.mainElement!==null&&(e.mainElement.style.display="none")),this.currentContextMenu=null,this.standardMouseOver())}kR(){let t=this,e=new q;return e.add(new de("Copy",i=>i.commandHandler.copySelection(),i=>i.commandHandler.canCopySelection())),e.add(new de("Cut",i=>i.commandHandler.cutSelection(),i=>i.commandHandler.canCutSelection())),e.add(new de("Delete",i=>i.commandHandler.deleteSelection(),i=>i.commandHandler.canDeleteSelection())),e.add(new de("Paste",i=>i.commandHandler.pasteSelection(t.mouseDownPoint),i=>i.commandHandler.canPasteSelection(t.mouseDownPoint))),e.add(new de("Select All",i=>i.commandHandler.selectAll(),i=>i.commandHandler.canSelectAll())),e.add(new de("Undo",i=>i.commandHandler.undo(),i=>i.commandHandler.canUndo())),e.add(new de("Redo",i=>i.commandHandler.redo(),i=>i.commandHandler.canRedo())),e.add(new de("Scroll To Part",i=>i.commandHandler.scrollToPart(),i=>i.commandHandler.canScrollToPart())),e.add(new de("Zoom To Fit",i=>i.commandHandler.zoomToFit(),i=>i.commandHandler.canZoomToFit())),e.add(new de("Reset Zoom",i=>i.commandHandler.resetZoom(),i=>i.commandHandler.canResetZoom())),e.add(new de("Group Selection",i=>i.commandHandler.groupSelection(),i=>i.commandHandler.canGroupSelection())),e.add(new de("Ungroup Selection",i=>i.commandHandler.ungroupSelection(),i=>i.commandHandler.canUngroupSelection())),e.add(new de("Edit Text",i=>i.commandHandler.editTextBlock(),i=>i.commandHandler.canEditTextBlock())),e}showDefaultContextMenu(){let t=this.diagram;this.Ex===null&&(this.Ex=this.kR()),It.Bm.innerHTML="",It.zm.addEventListener("pointerdown",this.Ux,!1);let e=this,i=m.Ci("ul");i.className="goCXul",It.Bm.appendChild(i),i.innerHTML="";let s=this.Ex.iterator;for(;s.next();){let n=s.value,o=n.Ox,r=n.Vc;if(!m.it(o)||m.it(r)&&!r(t))continue;let a=m.Ci("li");a.className="goCXli";let h=m.Ci("a");h.className="goCXa",h.href="#",h.Ox=o,h.addEventListener("pointerdown",function(l){return this.Ox(t),e.stopTool(),l.preventDefault(),!1},!1),h.textContent=n.ue,a.appendChild(h),i.appendChild(a)}It.Bm.style.display="block",It.zm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==It.Bu)return;It.Bm.style.display="none",It.zm.style.display="none";let t=this.diagram;t!==null&&t.Ae(It.zm,"pointerdown",this.Ux,!1),this.currentContextMenu=null}doMouseWheel(){this.standardMouseWheel()}get currentContextMenu(){return this.cM}set currentContextMenu(t){this.cM=t,this.Ix=t instanceof vt?t.adornedPart:null}get defaultTouchContextMenu(){return It.dM===!1&&It.Bu===null&&Y.isUsingDOM()&&this.bR(),It.Bu}set defaultTouchContextMenu(t){t===null&&(It.dM=!0),It.Bu=t}get currentObject(){return this.fM}set currentObject(t){t!==null&&m.se(t,J,It,"currentObject"),this.fM=t}get mouseDownPoint(){return this.uM}}var Os=(x=>(x[x.LostFocus=1]="LostFocus",x[x.MouseDown=2]="MouseDown",x[x.Tab=3]="Tab",x[x.Enter=4]="Enter",x))(Os||{}),Rs=(x=>(x[x.SingleClick=1]="SingleClick",x[x.SingleClickSelected=2]="SingleClickSelected",x[x.DoubleClick=3]="DoubleClick",x))(Rs||{}),Es=(x=>(x[x.None=1]="None",x[x.Active=2]="Active",x[x.Editing=3]="Editing",x[x.Validating=4]="Validating",x[x.Invalid=5]="Invalid",x[x.Validated=6]="Validated",x))(Es||{});class re extends Zt{vi;gM;mM;Gl;Gt;pM;yM;wM;Vx;Bx;constructor(t){super(),this.name="TextEditing",this.vi=new lt,this.gM=null,this.mM=2,this.Gl=null,this.Gt=1,this.pM=1,this.yM=!0,this.wM=null,this.Vx=new ge,this.Bx=null,this.PR(this.Vx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;PR(t){if(!Y.isUsingDOM())return;let e=m.Ci("textarea");this.Bx=e;let i=this;e.addEventListener("input",function(s){if(i.textBlock===null)return;let n=i.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(i.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(i.textBlock.lineCount,n.lineCount)},!1),e.addEventListener("keydown",function(s){if(s.isComposing||i.textBlock===null)return;let n=s.key;if(n==="Enter"){i.textBlock.isMultiline===!1&&s.preventDefault(),i.acceptText(4);return}else if(n==="Tab"){i.acceptText(3),s.preventDefault();return}else n==="Escape"&&(i.doCancel(),i.diagram!==null&&i.diagram.doFocus())},!1),e.addEventListener("focus",function(s){i.SR(s)},!1),e.addEventListener("blur",function(s){i.MR(s)},!1),t.valueFunction=()=>e.value,t.mainElement=e,t.show=(s,n,o)=>{if(!(s instanceof lt)||!n||!n.div||!(o instanceof re))return;if(o.state===5){e.style.border="3px solid red",e.focus();return}let r=s.getDocumentPoint(T.Center),a=n.position,h=n.scale,l=s.getDocumentScale()*h;l<o.minimumEditorScale&&(l=o.minimumEditorScale);let u=s.naturalBounds.width*l+6,c=s.naturalBounds.height*l+2,d=(r.x-a.x)*h,f=(r.y-a.y)*h,p=s.verticalAlignment,g=(s.lineHeight+s.spacingAbove+s.spacingBelow)*s.lineCount*l,y=.5*c-.5*g,b=p.y*c-p.y*g+p.offsetY-y-g/2;e.value=s.text,n.div.style.font=s.font;let v=1;e.style.position="absolute",e.style.zIndex="100",e.style.font="inherit",e.style.fontSize=l*100+"%",e.style.lineHeight="normal",e.style.width=u+"px",e.style.left=(d-u/2|0)-v+"px",e.style.top=(f+b|0)-v+"px",e.style.textAlign=s.textAlign,e.style.margin="0",e.style.padding=v+"px",e.style.border="0",e.style.outline="none",e.style.whiteSpace="pre-wrap",e.style.overflow="hidden",e.rows=s.lineCount,e.textScale=l,e.className="goTXarea",n.div.appendChild(e),e.focus(),o.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))},t.hide=(s,n)=>{s.div&&s.div.removeChild(e)}}get textBlock(){return this.gM}set textBlock(t){t!==null&&m.se(t,lt,re,"textBlock"),this.gM=t}get currentTextEditor(){return this.wM}set currentTextEditor(t){this.wM=t}get defaultTextEditor(){return this.Vx}set defaultTextEditor(t){this.Vx=t}get starting(){return this.mM}set starting(t){this.mM=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||t.isReadOnly||re.Bc&&re.Bc!==this&&(re.Bc.acceptText(2),re.Bc&&re.Bc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;let e=t.lastInput.documentPoint,i=t.findObjectAt(e);if(i===null||!(i instanceof lt)||!i.editable||i.part===null||!i.part.canEdit())return!1;let s=i.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){re.Bc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;let t=this.diagram;if(t===null)return;let e=this.textBlock;if(e===null&&(e=t.findObjectAt(t.lastInput.documentPoint)),e===null||!(e instanceof lt)||(this.textBlock=e,e.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Gt=2;let i=this.defaultTextEditor;e.textEditor!==null&&(i=e.textEditor),this.vi=this.textBlock.copy();let s=new I(this.textBlock.getDocumentPoint(T.TopLeft),this.textBlock.getDocumentPoint(T.BottomRight));t.scrollToRect(s),i!==null&&i.show!==null&&i.show(e,t,this),this.currentTextEditor=i}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Gt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Gt===2||this.Gt===5||this.Gt===3)&&(this.Gt=4,this.TA());break;case 1:case 4:case 3:if(t===4&&this.textBlock!==null&&this.textBlock.isMultiline===!0)return;(this.Gt===2||this.Gt===5||this.Gt===3)&&(this.Gt=4,this.TA());break}}TA(){let t=this.textBlock,e=this.diagram,i=this.currentTextEditor;if(t!==null&&i!==null){let s=t.text,n="";if(i.valueFunction!==null&&(n=i.valueFunction()),!this.isValidText(t,s,n)){this.Gt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Gt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),e!==null&&e.T("TextEdited",t,s),this.stopTransaction(),this.stopTool(),e!==null&&e.doFocus()}}doError(t,e){let i=this.textBlock;if(i===null)return;i.errorFunction!==null&&i.errorFunction(this,t,e);let s=this.currentTextEditor;s!==null&&s.show!==null&&s.show(i,this.diagram,this)}doSuccess(t,e){let i=this.textBlock;i!==null&&i.textEdited!==null&&i.textEdited(i,t,e)}doDeactivate(){let t=this.diagram;if(t!==null){if(this.Gt=1,this.currentTextEditor!==null){let e=this.currentTextEditor;e!==null&&e.hide!==null&&e.hide(t,this)}this.textBlock=null,this.isActive=!1}}doStop(){re.Bc=null}SR(t){if(this.currentTextEditor===null||this.state===1)return;let e=this.Bx;this.Gt===2&&(this.Gt=3),m.it(e.select)&&this.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))}MR(t){if(this.currentTextEditor===null||this.state===1)return;let e=this.Bx;m.it(e.focus)&&e.focus(),m.it(e.select)&&this.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))}isValidText(t,e,i){let s=this.textValidation;if(s!==null&&!s(t,e,i))return!1;let n=t.textValidation;return!(n!==null&&!n(t,e,i))}get textValidation(){return this.Gl}set textValidation(t){t!==null&&m.S(t,re,"textValidation"),this.Gl=t}get minimumEditorScale(){return this.pM}set minimumEditorScale(t){t!==null&&m.s(t,"number",re,"minimumEditorScale"),this.pM=t}get selectsTextOnActivate(){return this.yM}set selectsTextOnActivate(t){t!==null&&m.s(t,"boolean",re,"selectsTextOnActivate"),this.yM=t}get state(){return this.Gt}set state(t){this.Gt!==t&&(this.Gt=t)}measureTemporaryTextBlock(t){let e=this.vi;return e.text=t,this.textBlock!==null&&e.ht(this.textBlock.Yl,1/0),e}static Bc=null}var Is=(x=>(x[x.Default=1]="Default",x[x.AnimateLocations=2]="AnimateLocations",x[x.None=3]="None",x))(Is||{});class le{a;Te;Be;Ar;Zn;Oo;xM;bM;Xm;zx;Pe;zc;bn;Gm;oh;Xx;Ym;Gx;Xc;Uu;Km;constructor(t){this.a=Y.Fm(),this.Te=!1,this.Xm=!1,this.zx=!1,this.Pe=!1,this.zc=!1,this.Gx=!0,this.Xc=1,this.Uu=!1,this.Be=!0,this.Ar=!0,this.Oo=600,this.xM=!1,this.bM=!1,this.Zn=new V,this.bn=new xe,this.Gm=new xe,this.bn.Cs=this,this.oh=new V,this.Xx=new V,this.Ym=new V,this.Km=new V,t&&Object.assign(this,t)}Io(t){this.a=t}OU(){return this.a}canStart(t){return!0}Kl(t){return!this.Be||!this.canStart(t)?!1:(this.Zn.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.a.De(),this.Pe=!0,!0)}getBundleAnimation(){return this.Gm}kM(){if(!this.Be||(this.Gm.yi.count>0&&this.Gm.start(),!this.Pe))return;let t=this.bn,e=this.a,i=this.Zn.has("Model");if(i&&(this.zc=!0,this.Xc===1?(t.isViewportUnconstrained=!0,t.yi.clear(),t.add(e,"position",e.position.copy().offset(0,-200),e.position),t.add(e,"opacity",0,1)):this.Xc===3&&t.yi.clear(),this.Xc===2&&e.Yx.equals(e.ct)?this.Gx=!0:this.Gx=!1,e.T("InitialAnimationStarting",this)),i&&!this.Ar||t.yi.count===0){this.Zn.clear(),this.Pe=!1,t.yi.clear(),t.Kx(e),this.zc=!1,e.N();return}this.Zn.clear(),e.Tr=!1;let s=t.yi.get(e);e.autoScale!==1&&s!==null&&(delete s.ae.scale,delete s.Ns.scale);let n=this;K.requestAnimationFrame(()=>{n.Pe===!1||t.Te||(e.getRenderingHint("temporaryPixelRatio")&&e.Px(),e.PM(),n.Pe=!1,t.start(),t.Te&&(n.zu(),e.invalidateDocumentBounds(),t.DA(0),e.Pr(!0),n.Xu(),e.T("AnimationStarting",n)))})}SM(){return this.Zn.has("Trigger")&&this.Zn.count===1}vA(t,e,i,s){this.isTicking||this.SM()||t instanceof j&&(t.fromNode!==null||t.toNode!==null)||this.bn.add(t,"position",e,i,s)}Hx(t){return this.bn.Hx(t)}MM(t){return this.bn.MM(t)}CR(t){let e=this.oh,i=this;function s(){if(i.Ym.count>0&&(e.addAll(i.Ym),i.Ym.clear(),i.Te=!0),i.Te===!1||e.count===0){i.zx=!1;return}i.Xx.addAll(e);let n=i.Xx.iterator;for(;n.next();){let o=n.value;o.Te!==!1&&(o.NR()?o.FA(!1):o.Gc=!0)}if(i.Xx.clear(),i.Te===!1){K.requestAnimationFrame(s);return}i.zu(),i.a.Pr(),i.Xu(),K.requestAnimationFrame(s)}this.Te?this.RA(t):(this.Te=!0,this.zx?this.RA(t):(this.zx=!0,e.add(t),K.requestAnimationFrame(()=>s())))}RA(t){this.Ym.add(t)}LR(){let t=this.oh.iterator;for(;t.next();)t.value.Gc=!1}zu(){if(this.Xm)return;let t=this.a;this.xM=t.skipsUndoManager,this.bM=t.wi,t.skipsUndoManager=!0,t.wi=!0,this.Xm=!0}Xu(){let t=this.a;t.skipsUndoManager=this.xM,t.wi=this.bM,this.Xm=!1}stopAnimation(t){let e=this.bn;if(this.Pe===!0&&(this.Pe=!1,this.zc=!1,this.Zn.clear(),e.AR()&&this.a.requestUpdate()),!this.Te){e.yi.clear(),e.Kx(this.a);return}if(e.Gu(!0),e.Kx(null),t===!0){let i=this.oh.toArray();for(let s=0;s<i.length;s++)i[s].Gu(!0)}}Gu(t){this.oh.delete(t),this.oh.count===0&&(this.Te=!1,this.a.requestUpdate()),t===this.defaultAnimation&&this.a.T("AnimationFinished",this)}Yc(t,e){this.Pe&&(!this.Zn.has("Expand Tree")&&!this.Zn.has("Expand SubGraph")||(this.bn.Yc(t,e),this.OA(t)))}Kc(t,e){this.Pe&&(!this.Zn.has("Collapse Tree")&&!this.Zn.has("Collapse SubGraph")||(this.bn.Kc(t,e),this.bn.CM(e,"position",e.position,e.position),this.OA(t)))}IA(t,e){!this.Pe||t.equals(e)||this.SM()||(this.a.Za||(t=e.copy()),this.bn.CM(this.a,"position",t,e))}EA(t,e){this.Pe&&(this.SM()||this.bn.add(this.a,"scale",t,e))}NM(t,e){t.Fi&&(t.Dr=e,this.Km.add(t))}OA(t){let e=t.findLinksConnected();for(;e.next();){let i=e.value;i.Fi&&(i.Dr=i.points.copy(),this.Km.add(i))}}get isEnabled(){return this.Be}set isEnabled(t){m.s(t,"boolean",le,"isEnabled"),this.Be=t,t&&this.oh.each(e=>{!e.isAnimating&&e.runCount===1/0&&e.start()})}get duration(){return this.Oo}set duration(t){m.s(t,"number",le,"duration"),t<1&&m.J(t,">= 1",le,"duration"),this.Oo=t}get isAnimating(){return this.Te}get isTicking(){return this.Xm}get isInitial(){return this.Ar}set isInitial(t){m.s(t,"boolean",le,"isInitial"),this.Ar=t}get defaultAnimation(){return this.bn}get activeAnimations(){return this.oh}get initialAnimationStyle(){return this.Xc}set initialAnimationStyle(t){this.Xc=t}static qx=new Mt;static defineAnimationEffect(t,e){le.qx.set(t,e)}static LM(t,e,i,s,n){t===null&&(t=[0,0,0,0]),e===null&&(e=[0,0,0,0]);let o=t[0],r=t[1],a=t[2],h=t[3],l=e[0],u=e[1],c=e[2],d=e[3];a===0||a===100?(o=l,r=u):(c===0||c===100)&&(l=o,u=r),Math.abs(l-o)>180&&(l>o?o+=360:l+=360);let f=n(i,o,l-o,s)%360,p=n(i,r,u-r,s),g=n(i,a,c-a,s),y=n(i,h,d-h,s);return"hsla("+f+", "+p+"%, "+g+"%, "+y+")"}static Default=1;static AnimateLocations=2;static None=3}{let x=le.qx,t=(e,i,s,n,o,r)=>{e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))};x.set("position:diagram",t),x.set("position",t),x.set("position:part",(e,i,s,n,o,r)=>{o<r?e.Uc(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!1):e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("location",(e,i,s,n,o,r)=>{o<r?e.Uc(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!0):e.location=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("position:placeholder",(e,i,s,n,o,r)=>{o<r?e.Uc(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!1):e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("position:nodeCollapse",(e,i,s,n,o,r)=>{let a=e.actualBounds,h=s.actualBounds,l=h.x+h.width/2-a.width/2,u=h.y+h.height/2-a.height/2;o<r?e.Uc(n(o,i.x,l-i.x,r),n(o,i.y,u-i.y,r),!1):e.position=new P(n(o,i.x,l-i.x,r),n(o,i.y,u-i.y,r))}),x.set("desiredSize",(e,i,s,n,o,r)=>{e.desiredSize=new nt(n(o,i.width,s.width-i.width,r),n(o,i.height,s.height-i.height,r))}),x.set("width",(e,i,s,n,o,r)=>{e.width=n(o,i,s-i,r)}),x.set("height",(e,i,s,n,o,r)=>{e.height=n(o,i,s-i,r)}),x.set("fill",(e,i,s,n,o,r)=>{e.fill=le.LM(i,s,o,r,n)}),x.set("stroke",(e,i,s,n,o,r)=>{e.stroke=le.LM(i,s,o,r,n)}),x.set("strokeWidth",(e,i,s,n,o,r)=>{e.strokeWidth=n(o,i,s-i,r)}),x.set("strokeDashOffset",(e,i,s,n,o,r)=>{e.strokeDashOffset=n(o,i,s-i,r)}),x.set("background",(e,i,s,n,o,r)=>{e.background=le.LM(i,s,o,r,n)}),x.set("opacity",(e,i,s,n,o,r)=>{e.opacity=n(o,i,s-i,r)}),x.set("scale",(e,i,s,n,o,r)=>{e.scale=n(o,i,s-i,r)}),x.set("angle",(e,i,s,n,o,r)=>{e.angle=n(o,i,s-i,r)})}class xe{jx;Hm;Te;Yu;Oo;Ls;UA;Hc;yi;Wx;ae;Qn;Ku;qc;Jx;$x;Gc;AM;Zx;Cs;a;TM;DM;vM;constructor(t){this.a=null,this.Cs=null,this.AM=null,this.Zx=null,this.TM=!1,this.Te=!1,this.Gc=!1,this.ae=0,this.Qn=0,this.jx=xe.EaseInOutQuad,this.Hm=xe.EaseInOutQuad,this.Ku=!1,this.qc=!1,this.Jx=1,this.$x=0,this.Oo=NaN,this.Ls=NaN,this.DM=0,this.Yu=null,this.UA=P.gn,this.yi=new Mt,this.Wx=new Mt,this.Hc=new V,this.vM=1,t&&Object.assign(this,t)}suspend(){this.Gc=!0}advanceTo(t,e){e&&(this.Gc=!1),this.Ku&&t>=this.Ls&&(this.qc=!0,t=t-this.Ls),this.DM=t,this.FA(!0),this.Cs.zu(),this.a.Pr(),this.Cs.Xu(),this.a.redraw()}Kx(t){if(this.Wx.clear(),this.qc=!1,this.$x=0,this.Ls=NaN,this.Hc.count>0&&this.Hc.clear(),t!==null){let e=t.links;for(;e.next();)e.value.Dr=null}}AR(){return this.yi.count>0}start(){if(this.yi.count===0)return this;if(this.Te)return this;let t=this.a,e=this.yi.iterator;for(;e.next();){let s=e.key;t===null&&(s instanceof Y?t=s:s instanceof J&&(t=s.diagram))}if(t!==null)this.a=t,this.Cs=t.animationManager;else return this;let i=this.Cs;return i.isEnabled===!1?this:(this.Ls=isNaN(this.Oo)?i.duration:this.Oo,this.Hm=this.jx,i.zc&&i.Xc===1&&this===i.defaultAnimation&&(this.Hm=xe.EaseOutExpo,this.Ls=isNaN(this.Oo)?i.duration===600?900:i.duration:this.Oo),this.vM=t.scrollMode,this.isViewportUnconstrained&&(t.lh=2),i.zu(),this.Hc.each(s=>{s.data=null,t.add(s)}),i.Xu(),this.Te=!0,this.ae=+new Date,this.Qn=this.ae+this.Ls,i.CR(this),this)}addTemporaryPart(t,e){return t.Di()?(this.Hc.add(t),this.a=e,this):this}add(t,e,i,s,n){if(this.a===null&&(t instanceof Y?this.a=t:t instanceof J&&t.diagram!==null&&(this.a=t.diagram)),t instanceof pt){if(!t.isAnimated)return this;e==="position"&&(e="position:part")}return this.CM(t,e,i,s,n),this}CM(t,e,i,s,n){let o=this.yi,r,a,h;if(t instanceof Y&&e==="position"&&(e="position:diagram"),(e==="fill"||e==="stroke"||e==="background")&&(R.Eo(i),R.FM(),i=[R.ze.n0,R.ze.n1,R.ze.n2,R.ze.n3],R.Eo(s),R.FM(),s=[R.ze.n0,R.ze.n1,R.ze.n2,R.ze.n3]),o.has(t))r=o.get(t),a=r.ae,h=r.Ns,a[e]===void 0&&(a[e]=this.Hu(i)),h[e]=this.Hu(s);else{if(e==="position"&&i.equalsApprox(s))return;a={},h={},a[e]=this.Hu(i),h[e]=this.Hu(s),r=new Dn(a,h,n),o.set(t,r)}let l=a[e];l instanceof P&&!l.isReal()&&l.h(this.UA),n&&e.indexOf("position:")===0&&t instanceof pt?r.Qx.location=this.Hu(t.location):n&&(r.Qx[e]=this.Hu(i))}Hu(t){return t instanceof P||t instanceof nt?t.copy():t}TR(t){let e=this.yi;if(e.has(t)){let i=e.get(t);i._x=!0}}Hx(t){if(!this.Te)return!1;let e=this.yi.get(t);return e!==null&&e._x}MM(t){if(!this.Te)return!1;let e=this.yi.get(t);return e!==null&&!!(e.ae.position||e.ae["position:part"]||e.ae.location)}NR(){if(this.Hc.count>0)return!0;let t=this.yi.iterator;for(;t.next();){let e=t.key;if(e instanceof J&&e.diagram!==null||e instanceof Y)return!0}return!1}FA(t){if(this.Gc&&!t)return;let e=this.Cs;if(this.Te===!1)return;let i=+new Date,s=i>this.Qn?this.Ls:i-this.ae;t&&(s=this.DM,s<this.Ls?(this.ae=+new Date-s,this.Qn=this.ae+this.Ls):s=this.Ls),e.zu(),this.DA(s),this.a.Pr(!0),e.Xu(),i>this.Qn&&(this.Ku&&!this.qc?(this.ae=+new Date,this.Qn=this.ae+this.Ls,this.qc=!0):this.Gu(!1))}DA(t){let e=this.Ls,i=this.yi.iterator,s=this.qc;for(;i.next();){let n=i.key;if(n instanceof J&&n.diagram===null)continue;let o=i.value,r=s?o.Ns:o.ae,a=s?o.ae:o.Ns,h=le.qx;for(let l in a)l==="position"&&(a["position:placeholder"]||a["position:nodeCollapse"])||h.get(l)!==null&&h.get(l)(n,r[l],a[l],this.Hm,t,e,this)}}stop(){return this.Te?(this.Gu(!0),this):this}Gu(t){if(this.Zx!==null&&this.Zx.DR(this.AM),!this.Te)return;let e=this.a,i=this.Cs;i.zc=!1,this.Te=!1,this.Gc=!1,i.zu();let s=this.yi,n=this.Hc.iterator;for(;n.next();)e.remove(n.value);let o=this.Ku,r=s.iterator,a=le.qx;for(;r.next();){let l=r.key,u=r.value,c=o?u.Ns:u.ae,d=o?u.ae:u.Ns,f=u.Qx;for(let p in d)if(a.get(p)!==null){let g=p;u.tb&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),a.get(g)(l,c[p],f[p]!==void 0?f[p]:u.tb?c[p]:d[p],this.Hm,this.Ls,this.Ls,this)}u.tb&&f.location!==void 0&&l instanceof pt&&(l.location=f.location),u._x&&l instanceof pt&&l.Xe(!1)}this.$x++;let h=!t&&this.Jx>this.$x;if(!h&&(this===i.Gm||this===i.defaultAnimation)&&this.yi.clear(),e.eb.clear(),e.gS(!1),e.invalidateDocumentBounds(),e.N(),e.Pr(!0),i.defaultAnimation===this){let l=i.Km.iterator;for(;l.next();)l.value.vR();i.Km.clear()}if(e.Pr(!0),this.isViewportUnconstrained&&(e.scrollMode=this.vM),i.Xu(),h){this.qc=!1,this.start();return}this.Kx(null),e.VA(),i.Gu(this),this.Yu&&this.Yu(this),e.requestUpdate()}Yc(t,e){let i=e.actualBounds,s=null;if(e instanceof ht&&(s=e.placeholder),s!==null&&s.visible){let n=s.getDocumentPoint(T.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new P(i.x+i.width/2,i.y+i.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof ht&&this.FR(t,e)}FR(t,e){let i=t.memberParts;for(;i.next();){let s=i.value;s instanceof $&&this.Yc(s,e)}}Kc(t,e){if(!t.isVisible())return;let i=null;if(e instanceof ht&&(i=e.placeholder),i!==null&&i.visible){let s=i.getDocumentPoint(T.TopLeft),n=i.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,e,!0);this.add(t,"scale",t.scale,.01,!0),this.TR(t),t instanceof ht&&this.RR(t,e)}RR(t,e){let i=t.memberParts;for(;i.next();){let s=i.value;s instanceof $&&this.Kc(s,e)}}get duration(){return this.Oo}set duration(t){m.s(t,"number",xe,"duration"),t<1&&m.J(t,">= 1",xe,"duration"),this.Oo=t}get reversible(){return this.Ku}set reversible(t){this.Ku=t}get runCount(){return this.Jx}set runCount(t){t>0?this.Jx=t:m.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Yu}set finished(t){this.Yu!==t&&(t!==null&&m.S(t,xe,"finished"),this.Yu=t)}get easing(){return this.jx}set easing(t){this.jx=t}get isViewportUnconstrained(){return this.TM}set isViewportUnconstrained(t){this.TM=t}get isAnimating(){return this.Te}getTemporaryState(t){let e=this.Wx.get(t);return e===null&&(e={},this.Wx.set(t,e)),e}static EaseLinear=(t,e,i,s)=>i*t/s+e;static EaseInOutQuad=(t,e,i,s)=>(t/=s/2,t<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e);static EaseInQuad=(t,e,i,s)=>i*(t/=s)*t+e;static EaseOutQuad=(t,e,i,s)=>-i*(t/=s)*(t-2)+e;static EaseInExpo=(t,e,i,s)=>t===0?e:i*Math.pow(2,10*(t/s-1))+e;static EaseOutExpo=(t,e,i,s)=>t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}class Dn{ae;Ns;Qx;tb;_x;constructor(t,e,i){this.ae=t,this.Ns=e,this.Qx={},this.tb=i,this._x=!1}}var Bs=(x=>(x[x.Default=1]="Default",x[x.Immediate=2]="Immediate",x[x.Bundled=3]="Bundled",x))(Bs||{});class ai{Ti;yn;qu;jc;constructor(t,e,i){this.Ti=null,this.yn=t,this.qu=i||1,this.jc=null,e!==void 0&&(this.jc=e,i===void 0&&(this.qu=2))}copy(){let t=new ai(this.yn);t.qu=this.qu;let e=this.jc;if(e!==null){let i={};e.duration!==void 0&&(i.duration=e.duration),e.finished!==void 0&&(i.finished=e.finished),e.easing!==void 0&&(i.easing=e.easing),t.jc=i}return t}get propertyName(){return this.yn}set propertyName(t){this.yn=t}get animationSettings(){return this.jc}set animationSettings(t){this.jc=t}OR(t){let e=this.jc;e!==null&&(e.duration&&(t.duration=e.duration),e.finished&&(t.finished=e.finished),e.easing&&(t.easing=e.easing))}get startCondition(){return this.qu}set startCondition(t){this.qu=t}static Default=1;static Immediate=2;static Bundled=3}class Et{a;Pt;Zt;vr;Hl;ql;jl;Wl;Jl;$l;Zl;Ql;_l;ta;ea;ia;Vc;sa;ib;qm;ju;Ct;constructor(t){V.Je(this),this.a=null,this.Ct=new q,this.Pt="",this.Zt=1,this.vr=!1,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Jl=!0,this.$l=!0,this.Zl=!0,this.Ql=!0,this._l=!0,this.ta=!0,this.ea=!0,this.ia=!0,this.Vc=!0,this.sa=!0,this.ib=!0,this.qm=!1,this.ju=[],t&&Object.assign(this,t)}IR(){let t=this.Ct;for(let e=0;e<t.length;e++)t.r[e].RM(null);t.clear(),this.ju.length=0}Io(t){this.a=t}toString(t){t===void 0&&(t=0);let e='Layer "'+this.name+'"';if(t<=0)return e;let i=0,s=0,n=0,o=0,r=0,a=this.Ct.iterator;for(;a.next();){let l=a.value;l instanceof ht?n++:l instanceof $?s++:l instanceof j?o++:l instanceof vt?r++:i++}let h="";if(i>0&&(h+=i+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){let l=this.Ct.iterator;for(;l.next();){let u=l.value;h+=`
|
|
6
6
|
`+u.toString();let c=u.data;c!==null&&V.xs(c)&&(h+=" #"+V.xs(c)),u instanceof $?h+=" "+m.toString(c):u instanceof j&&(h+=" "+m.toString(u.fromNode)+" "+m.toString(u.toNode))}}return e+" "+this.Ct.count+": "+h}findObjectAt(t,e,i){if(e===void 0&&(e=null),i===void 0&&(i=null),this.sa===!1)return null;let s=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(s=!0);let n=P.l(),o=this.Ct.r,r=o.length;for(let a=r;a--;){let h=o[a];if(s===!0&&h.Bl()===!1||!h.isVisible())continue;n.h(t),n.Hi(h.Js);let l=h.BA(n,e,i);if(l!==null&&(e!==null&&(l=e(l)),l!==null&&(i===null||i(l))))return P.i(n),l}return P.i(n),null}findObjectsAt(t,e,i,s){if(e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof q)&&!(s instanceof V)&&(s=new V),this.sa===!1)return s;let n=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(n=!0);let o=P.l(),r=this.Ct.r,a=r.length;for(let h=a;h--;){let l=r[h];if(n===!0&&l.Bl()===!1||!l.isVisible())continue;o.h(t),o.Hi(l.Js);let u=l;l.zA(o,e,i,s)&&(e!==null&&(u=e(u)),u!==null&&(i===null||i(u))&&s.add(u))}return P.i(o),s}findObjectsIn(t,e,i,s,n){if(e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof q)&&!(n instanceof V)&&(n=new V),this.sa===!1)return n;let o=!1;this.diagram!==null&&this.diagram.viewportBounds.containsRect(t)&&(o=!0);let r=this.Ct.r,a=r.length;for(let h=a;h--;){let l=r[h];if(o===!0&&l.Bl()===!1||!l.isVisible())continue;let u=l;l.jm(t,e,i,s,n)&&(e!==null&&(u=e(u)),u!==null&&(i===null||i(u))&&n.add(u))}return n}kS(t,e,i,s,n,o,r){if(this.sa===!1)return n;let a=this.Ct.r,h=a.length;for(let l=h;l--;){let u=a[l];if(r===!0&&u.Bl()===!1||!o(u)||!u.isVisible())continue;let c=u;u.jm(t,e,i,s,n)&&(e!==null&&(c=e(c)),c!==null&&(i===null||i(c))&&n.add(c))}return n}findObjectsNear(t,e,i,s,n,o){if(i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof q||n instanceof V)&&(o=n),n=!0),!(o instanceof q)&&!(o instanceof V)&&(o=new V),this.sa===!1)return o;let r=!1;this.diagram!==null&&this.diagram.viewportBounds.containsPoint(t)&&(r=!0);let a=P.l(),h=P.l(),l=this.Ct.r,u=l.length;for(let c=u;c--;){let d=l[c];if(r===!0&&d.Bl()===!1||!d.isVisible())continue;a.h(t),a.Hi(d.Js),h.e(t.x+e,t.y),h.Hi(d.Js);let f=d;d.XA(a,h,i,s,n,o)&&(i!==null&&(f=i(f)),f!==null&&(s===null||s(f))&&o.add(f))}return P.i(a),P.i(h),o}OM(){return this.Ct.r}rs(t,e){if(!this.visible)return;let i=this.Ct.r,s=i.length;if(s===0)return;let n=m.st(),o=m.st();for(let r=0;r<s;r++){let a=i[r];if(a.IM=r,a instanceof j){if(a.Fi===!1)continue}else if(a instanceof vt&&a.adornedPart!==null)continue;let h=a.actualBounds;a.isVisible()&&h.UL(e,10)?(a.rs(!0),n.push(a)):(a.rs(!1),a.adornments!==null&&a.adornments.count>0&&o.push(a))}for(let r=0;r<n.length;r++){let a=n[r];a.EM();let h=a.adornments;for(;h.next();){let l=h.value;l.ht(1/0,1/0),l.Ut(),l.rs(!0)}}for(let r=0;r<o.length;r++)o[r].EM();m.Z(n),m.Z(o)}Wu(t){let e=1;return this.Zt!==1&&(e=t.globalAlpha,t.globalAlpha=e*this.Zt),e}GA(t,e){for(let i=0;i<e;i++)t[i].Wc()}Ge(t,e,i){if(!this.visible||this.Zt===0||(i===void 0&&(i=!0),!i&&this.isTemporary))return;let s=this.Ct.r,n=s.length;if(n===0)return;t.vr&&this.GA(s,n);let o=this.Wu(t),r=this.ju;r.length=0;let a=e.scale,h=I.l();for(let l=0;l<n;l++){let u=s[l];this.Wm(t,u,e,r,a,h,!0)}I.i(h),t.vr&&this.GA(s,n),t.globalAlpha=o}IU(t,e,i){if(!this.visible||this.Zt===0)return;let s=this.Ct.r,n=s.length;if(n===0)return;let o=this.Wu(t),r=this.ju;r.length=0;let a=e.scale,h=I.l();for(let l=0;l<n;l++){let u=s[l];i.has(u)||this.Wm(t,u,e,r,a,h,!0)}I.i(h),t.globalAlpha=o}ER(t,e,i,s){if(!this.visible||this.Zt===0||!s&&this.isTemporary)return;let n=this.Ct.r,o=n.length;if(o===0)return;let r=this.Wu(t),a=this.ju;a.length=0;let h=e.scale,l=I.l();for(let u=0;u<o;u++){let c=n[u];i.has(c)&&this.Wm(t,c,e,a,h,l,!1)}I.i(l),t.globalAlpha=r}UR(t,e,i,s,n){if(!this.visible||this.opacity===0)return;let o=this.diagram.grid.part;if(!s&&this.isTemporary){if(n&&o.layer===this){let r=this.Wu(t);o.Ge(t,i),t.globalAlpha=r}}else{let r=this.Wu(t),a=i.scale,h=I.l(),l=this.Ct.r,u=l.length;for(let c=0;c<u;c++){let d=l[c];!n&&d===o||this.Wm(t,d,i,null,a,h,!1)}I.i(h),t.globalAlpha=r}}EU(t,e,i){if(!this.visible||this.Zt===0)return;let s=this.Wu(t),n=this.ju;n.length=0;let o=e.scale,r=I.l(),a=this.Ct.r,h=a.length,l=i.length;for(let u=0;u<h;u++){let c=a[u],d=c.ah(c.actualBounds);this.VR(d,i,l,o)&&this.Wm(t,c,e,n,o,r,!0)}I.i(r),t.globalAlpha=s}Wm(t,e,i,s,n,o,r){if(r&&!e.Bl()){t.removePartFromView(e);return}if(s!==null&&e instanceof j&&(e.isOrthogonal&&s.push(e),e.Fi===!1)){t.removePartFromView(e);return}let a=!1,h=e.containingGroup;for(;h!==null;)a?h.he!==null&&o.intersectRect(h.he):h.he!==null&&(a=!0,o.h(h.he)),h=h.containingGroup;let l=e.actualBounds,u=!1;if(a&&e.isVisible()){if(!o.intersectsRect(l)){t.removePartFromView(e);return}u=!o.containsRect(l)}u&&(t.save(),t instanceof ae?t.partClipRect=o.copy():(t.beginPath(),t.rect(o.x,o.y,o.width,o.height),t.clip())),l.width*n>i.Jm||l.height*n>i.Jm?e.Ge(t,i):this.BR(t,e,i),u&&(t.restore(),t.clearContextCache(!0))}BR(t,e,i){if(t instanceof ae){e.Ge(t,i);return}let s=e.actualBounds,n=e.naturalBounds;if(s.width===0||s.height===0||isNaN(s.x)||isNaN(s.y)||!e.isVisible())return;let o=e.v;if(e.background===null){e.kn(t,"rgba(0,0,0,0.3)",!0,!1,n,s),t.fillRect(s.x,s.y,s.width,s.height);return}if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.kn(t,e.background,!0,!1,n,s),t.fillRect(0,0,n.width/2,n.height/2),!o.TP()){let r=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*r,-o.m12*r,-o.m21*r,o.m11*r,r*(o.m21*o.dy-o.m22*o.dx),r*(o.m12*o.dx-o.m11*o.dy))}}VR(t,e,i,s){let n=2/s,o=4/s;for(let r=0;r<i;r++){let a=e[r];if(!(a.width===0||a.height===0)&&t.intersects(a.x-n,a.y-n,a.width+o,a.height+o))return!0}return!1}t(t,e,i,s,n){let o=this.diagram;o!==null&&o.raiseChangedEvent(2,t,this,e,i,s,n)}hh(t,e,i){let s=this.Ct;if(e.RM(this),t>=s.count)t=s.count;else if(s.elt(t)===e)return-1;s.insertAt(t,e),e.$m(i);let n=this.diagram;return n!==null&&(i?n.N():n.hh(e)),this.sb(t,e),t}ri(t,e,i){if(!i&&e.layer!==this&&e.layer!==null)return e.layer.ri(t,e,i);let s=this.Ct;if(t<0||t>=s.length){if(t=s.indexOf(e),t<0)return-1}else if(s.elt(t)!==e&&(t=s.indexOf(e),t<0))return-1;e.Zm(i),s.removeAt(t);let n=this.diagram;return n!==null&&(i?n.N():n.ri(e)),e.RM(null),t}sb(t,e){t=this.zR(t,e),e instanceof ht&&this.XR(t,e),e.svg!==null&&e.svg.remove()}zR(t,e){let i=e.zOrder;if(isNaN(i))return t;let s=this.Ct,n=s.count;if(n<=1)return t;if(t<0&&(t=s.indexOf(e)),t<0)return-1;let o=t-1,r=NaN;for(;o>=0&&(r=s.elt(o).zOrder,!!isNaN(r));)o--;let a=t+1,h=NaN;for(;a<n&&(h=s.elt(a).zOrder,!!isNaN(h));)a++;if(!isNaN(r)&&r>i)for(;;){if(o===-1||r<=i)return o++,o===t?t:(s.removeAt(t),s.insertAt(o,e),o);for(r=NaN;--o>=0&&(r=s.elt(o).zOrder,!!isNaN(r)););}else if(!isNaN(h)&&h<i)for(;;){if(a===n||h>=i)return a--,a===t?t:(s.removeAt(t),s.insertAt(a,e),a);for(h=NaN;++a<n&&(h=s.elt(a).zOrder,!!isNaN(h)););}return t}XR(t,e){if(e===null||!isNaN(e.zOrder))return;this.GR(t,e);let i=e.containingGroup;i!==null&&this.sb(-1,i)}GR(t,e){if(e.memberParts.count===0)return;let i=-1,s=this.Ct.r,n=s.length;for(let o=0;o<n;o++){let r=s[o];if(r===e&&(t=o,i>=0)||i<0&&r.containingGroup===e&&(i=o,t>=0))break}if(!(i<0)&&i<t){let o=this.Ct;o.removeAt(t),o.insertAt(i,e)}}get parts(){return this.Ct.iterator}get partsBackwards(){return this.Ct.iteratorBackwards}get diagram(){return this.a}get name(){return this.Pt}set name(t){m.s(t,"string",Et,"name");let e=this.Pt;if(e!==t){let i=this.diagram;if(i!==null){e===""&&m.o("Cannot rename default Layer to: "+t);let n=i.layers;for(;n.next();)n.value.name===t&&m.o("Layer.name is already present in this diagram: "+t)}this.Pt=t,this.t("name",e,t);let s=this.Ct.iterator;for(;s.next();){let n=s.value;n.layerName=this.Pt}}}get opacity(){return this.Zt}set opacity(t){let e=this.Zt;if(e!==t){m.s(t,"number",Et,"opacity"),(t<0||t>1)&&m.J(t,"0 <= value <= 1",Et,"opacity"),this.Zt=t;let i=this.diagram;i!==null&&i.N(),this.t("opacity",e,t)}}get isViewportAligned(){return this.qm}set isViewportAligned(t){let e=this.qm;e!==t&&(this.qm=t,this.diagram&&(this.YA(),this.diagram.N()),this.t("isViewportAligned",e,t),t&&(this.isInDocumentBounds=!1))}YA(){if(!this.qm)return;let t=this.diagram;if(t===null)return;let e=this.Ct.r,i=e.length,s=t.wt,n=t.xt;for(let o=0;o<i;o++){let r=e[o],a=r.naturalBounds.width,h=r.naturalBounds.height,l=r.alignment;(l.isDefault()||!l.isSpot())&&(l=T.BottomRight);let u=r.alignmentFocus;u.isDefault()&&(u=new T(l.x,l.y));let c=l.x*s+l.offsetX-(u.x*a+u.offsetX),d=l.y*n+l.offsetY-(u.y*h+u.offsetY),f=P.z(c,d);t.YR(f),r.Uc(f.x,f.y,!0),P.i(f),r.et=1/t.scale}}get isTemporary(){return this.vr}set isTemporary(t){let e=this.vr;e!==t&&(m.s(t,"boolean",Et,"isTemporary"),this.vr=t,this.t("isTemporary",e,t))}get visible(){return this.Vc}set visible(t){let e=this.Vc;if(e!==t){m.s(t,"boolean",Et,"visible"),this.Vc=t;let i=this.Ct.iterator;for(;i.next();)i.value.Xe(t);let s=this.diagram;s!==null&&s.N(),this.t("visible",e,t)}}get pickable(){return this.sa}set pickable(t){let e=this.sa;e!==t&&(m.s(t,"boolean",Et,"pickable"),this.sa=t,this.t("pickable",e,t))}get isInDocumentBounds(){return this.ib}set isInDocumentBounds(t){let e=this.ib;e!==t&&(this.ib=t,this.diagram!==null&&this.diagram.invalidateDocumentBounds(),this.t("isInDocumentBounds",e,t))}get allowCopy(){return this.Hl}set allowCopy(t){let e=this.Hl;e!==t&&(m.s(t,"boolean",Et,"allowCopy"),this.Hl=t,this.t("allowCopy",e,t))}get allowDelete(){return this.ql}set allowDelete(t){let e=this.ql;e!==t&&(m.s(t,"boolean",Et,"allowDelete"),this.ql=t,this.t("allowDelete",e,t))}get allowTextEdit(){return this.jl}set allowTextEdit(t){let e=this.jl;e!==t&&(m.s(t,"boolean",Et,"allowTextEdit"),this.jl=t,this.t("allowTextEdit",e,t))}get allowGroup(){return this.Wl}set allowGroup(t){let e=this.Wl;e!==t&&(m.s(t,"boolean",Et,"allowGroup"),this.Wl=t,this.t("allowGroup",e,t))}get allowUngroup(){return this.Jl}set allowUngroup(t){let e=this.Jl;e!==t&&(m.s(t,"boolean",Et,"allowUngroup"),this.Jl=t,this.t("allowUngroup",e,t))}get allowLink(){return this.$l}set allowLink(t){let e=this.$l;e!==t&&(m.s(t,"boolean",Et,"allowLink"),this.$l=t,this.t("allowLink",e,t))}get allowRelink(){return this.Zl}set allowRelink(t){let e=this.Zl;e!==t&&(m.s(t,"boolean",Et,"allowRelink"),this.Zl=t,this.t("allowRelink",e,t))}get allowMove(){return this.Ql}set allowMove(t){let e=this.Ql;e!==t&&(m.s(t,"boolean",Et,"allowMove"),this.Ql=t,this.t("allowMove",e,t))}get allowReshape(){return this._l}set allowReshape(t){let e=this._l;e!==t&&(m.s(t,"boolean",Et,"allowReshape"),this._l=t,this.t("allowReshape",e,t))}get allowResize(){return this.ta}set allowResize(t){let e=this.ta;e!==t&&(m.s(t,"boolean",Et,"allowResize"),this.ta=t,this.t("allowResize",e,t))}get allowRotate(){return this.ea}set allowRotate(t){let e=this.ea;e!==t&&(m.s(t,"boolean",Et,"allowRotate"),this.ea=t,this.t("allowRotate",e,t))}get allowSelect(){return this.ia}set allowSelect(t){let e=this.ia;e!==t&&(m.s(t,"boolean",Et,"allowSelect"),this.ia=t,this.t("allowSelect",e,t))}}var Ii=(x=>(x[x.None=1]="None",x[x.Uniform=2]="Uniform",x[x.UniformToFill=3]="UniformToFill",x))(Ii||{}),Vs=(x=>(x[x.All=1]="All",x[x.NotDirected=2]="NotDirected",x[x.NotDirectedFast=3]="NotDirectedFast",x[x.NotUndirected=4]="NotUndirected",x[x.DestinationTree=5]="DestinationTree",x[x.SourceTree=6]="SourceTree",x))(Vs||{}),zs=(x=>(x[x.Document=1]="Document",x[x.Infinite=2]="Infinite",x))(zs||{}),Xs=(x=>(x[x.TreeParent=1]="TreeParent",x[x.AllParents=2]="AllParents",x[x.AnyParents=3]="AnyParents",x))(Xs||{});class Y{Cs;jt;UM;nb;Fr;Ju;ob;rb;lb;ab;hb;cb;ch;lh;fb;ub;db;na;Jc;Rr;Qm;gb;pb;$u;_n;Or;fh;Uo;_m;$c;tp;Zc;Zu;Ir;to;VM;BM;yb;wb;zM;xb;XM;GM;YM;bb;ep;Er;Ur;Vr;Br;zr;Xr;kb;Gr;Pb;Yr;Kr;Hr;qr;Sb;KM;Vo;HM;Mb;Cb;qM;Le;jM;Qc;WM;qs;Bo;Be;Nb;Hl;ql;Lb;Ab;jl;Wl;Jl;Tb;$l;Zl;Ql;_l;ta;ea;ia;Db;vb;JM;Qu;_u;Fb;Rb;Ob;Ib;ip;Eb;Ub;Vb;Qt;KA;Bb;HA;td;Pn;eo;li;io;qA;oa;$M;ZM;sp;zb;ed;np;Xb;jr;ra;uh;QM;_M;op;Gb;Yb;ls;_c;rp;sd;zo;tf;lp;Wr;dh;t2;ap;Ht;v;Wi;Tr;Ye;As;e2;la;Jr;Ol;$r;gh;ef;i2;nd;mh;od;Vt;aa;ct;et;rd;wt;xt;lt;sf;xx;Kb;ph;nf;Hb;qb;hp;KR;HR;$e;El;Jm;cp;s2;o2;jA;fp;qR;jR;WR;jb;JR;$R;ZR;yh;WA;ha;wh;xh;bh;kh;Eu;nh;Wt;Mt;of;YP;KP;Dc;Zt;static Wb=null;static JA=new Mt;static l2;static a2=null;Iu;Jb;$b;ld;Zb;Qb;dp;h2;gp;mp;pp;Yx;c2;f2;rf;yp;wp;constructor(t,e){if(Y.Yw||(Y.DP(),Y.Yw=!0),V.Je(this),Y.$A(this),this.Ht=!0,this.Mt=null,this.wt=0,this.xt=0,this.lt=null,Y.isUsingDOM()){let s=this,n=()=>{s.Ae(K.document,"DOMContentLoaded",n,!1),s.setRTL()};K.document.body!==null?this.setRTL():s.Et(K.document,"DOMContentLoaded",n,!1)}this.sf=null,Y.u2("Model",me);let i=this;return this.jM=s=>i.partManager.doModelDataChanged(s),this.Qc=s=>i.partManager.doModelChanged(s),this.Hb=null,this.qb=null,this.ZA(),this.model=dt.d2(),this.themeManager=new je,this.Vo=!0,this.QA(),this.layout=new ee,this.Vo=!1,this.qR=null,this.jR=null,this.WR=null,this.jb=null,this.JR=null,this.$R=null,this.ZR=null,this.yh=null,this.WA=null,this.ha=null,this.wh=null,this.xh=null,this.bh=null,this.kh=null,this.Eu=()=>{},this.nh=null,this.sd=!1,this.of=new Fn(this),t!==void 0&&(typeof t=="string"||K.Element&&t instanceof Element?this.g2(t):e=t),e&&this.setProperties(e),this.Ht=!1,this.requestUpdate(),this}aR(){return this.lt!==null}get renderer(){return this.tf}set renderer(t){if(this instanceof hi)return;t===""&&(t="default");let e=t.toLowerCase(),i=this.tf;if(e===i)return;this.tf=e;let s=null;e==="default"||e==="canvas"?(s=this.zo.get("svg"),s!==null&&s.bt.remove(),this.lt&&(this.Wt=this.lt._t,this.Wt.clearContextCache(!0))):e==="svg"?(this.zo.has("svg")?s=this.zo.get("svg"):(s=new ui(this,K.document),this.addRenderer("svg",s)),this.div!==null&&(s.bt.role="img",this.div.appendChild(s.bt)),this.lt&&(this.Wt=s._t,this.lt._t.setTransform(this.$e,0,0,this.$e,0,0),this.lt._t.clearRect(0,0,this.wt,this.xt))):e==="debug"&&(this.zo.has("SVG")||(s=new ui(this,K.document),this.addRenderer("SVG",s),s.bt.style.backgroundColor="whitesmoke",this.div!==null&&this.div.after(s.bt))),this.Ht||this.redraw()}ZA(){if(this.rf=new q,this.setupRouters(),this.Cs=new le,this.Cs.Io(this),this.jt=17,this.UM=!1,this.rd=!1,this.nb="default",this.Vt=new q,this.zo){let t=this.zo.get("svg");t!==null&&t.bt.remove(),this.lt&&(this.Wt=this.lt._t,this.Wt.clearContextCache(!0))}this.zo=new Mt,this.tf="default",this.resetRenderingHints(),this.QR(),this.Zt=1,this.ct=new P(NaN,NaN).k(),this.Yx=new P(NaN,NaN),this.et=1,this.ap=1,this.ob=new P(NaN,NaN).k(),this.rb=NaN,this.lb=1e-4,this.ab=100,this.v=new Nt,this.hb=new P(NaN,NaN).k(),this.cb=new I(NaN,NaN,NaN,NaN).k(),this.ch=new Dt(0,0,0,0).kt(),this.lh=1,this.fb=!1,this.ub=null,this.db=null,this.na=1,this.Jc=T.Default,this.Rr=1,this.Qm=T.Default,this.gb=T.None,this.pb=T.None,this.Wi=!0,this.$u=!1,this._n=new Set,this.Or=new V,this.fh=new V,this.Uo=!1,this.aa=new Mt,this.nd=!0,this._m=250,this.$c=-1,this.tp=new Dt(16,16,16,16).kt(),this.Tr=!1,this.Zc=!1,this.Zu=!0,this.lp=new te,this.lp.diagram=this,this.Wr=new te,this.Wr.diagram=this,this.dh=new te,this.dh.diagram=this,this.Ir=null,this.to=null,this.xx=!1,this._R(),this.$r=new V,this.yb=!0,this.wb=1,this.zM=!1,this.xb=1,this.bb="auto",this.ep="auto",this.Er=null,this.Ur=null,this.Vr=null,this.Br=null,this.zr=null,this.Xr=null,this.kb=null,this.Gr=null,this.Pb=!1,this.Yr=null,this.Kr=null,this.Hr=null,this.qr=null,this.Sb=!1,this.Kb={},this.ph=[null,null],this.Vo=!1,this.HM=!1,this.Mb=!1,this.Cb=!1,this.qM=!0,this.As=!1,this.mh=!1,this.WM=!0,this.qs=-2,this.la=new Mt,this.od=new q,this.Bo=!1,this.Be=!0,this.Nb=!0,this.Hl=!0,this.ql=!0,this.Lb=!1,this.Ab=!0,this.jl=!0,this.Wl=!0,this.Jl=!0,this.Tb=!0,this.$l=!0,this.Zl=!0,this.Ql=!0,this._l=!0,this.ta=!0,this.ea=!0,this.ia=!0,this.Db=!0,this.vb=!0,this.JM=!1,this.nf=!1,this.Qu=!0,this._u=!0,this.Fb=!0,this.Rb=!0,this.Ob=16,this.Ib=16,this.ip=!1,this.Eb=!1,this.Ub=0,this.Vb=0,this.Qt=new Dt(5).kt(),this.KA=new V().k(),this.Bb=999999999,this.HA=new V().k(),this.gh=!0,this.td=!0,this.ef=!0,this.Pn=!1,this.eo=!1,this.Jr=!0,this.Ol=!1,this.io=!1,this.qA=new V,this.i2=new V,this.oa=null,this.$M=new nt(j._A,j.tT),this.ZM=999,this.sp=!1,this.YP=1,this.KP=0,this.Ye={scale:1,position:new P,bounds:new I,canvasSize:new nt,newCanvasSize:new nt,isScroll:!1},this.Ye.canvasSize=this.Ye.canvasSize,this.Ye.newCanvasSize=this.Ye.newCanvasSize,this.Ye.isScroll=!1,this.zb=new I(NaN,NaN,NaN,NaN).k(),this.ed=new nt(NaN,NaN).k(),this.np=new I(NaN,NaN,NaN,NaN).k(),this.Xb=!1,this.yp=null,this.wp=null,this.tO(),this.ls=null,this._c=!1,this.Dc=null,this.partManager=new me,this.toolManager=new oe,this.toolManager.initializeStandardTools(),this.defaultTool=this.toolManager,this.currentTool=this.defaultTool,this.$b=null,this.ld=new Pi,this.Zb=null,this.Qb=null,this.Jb=!1,this.Iu=!1,this.commandHandler=new jt,this.mp=null,this.pp=P.mn,this.c2=!1,this.$e=1,this.El=null,this.Jm=1,this.dp=0,this.h2=[0,0,0,0,0],this.gp=0,this.cp=1,this.s2=0,this.o2=new P,this.jA=500,this.rp=new P,this.fp=!1}static eT=K.document!==void 0;static isUsingDOM(){return Y.eT}static setDocument(t){K.document=t}static useDOM(t){Y.eT=t?K.document!==void 0:!1}static Ji=new WeakMap;clear(){this.animationManager.stopAnimation(),this.model.clear(),Y.iT(),this.sT(!1),this.od.clear(),this.nT(),this.oa=null,this.invalidateDocumentBounds(),this.ensureBounds(),this.N()}sT(t){this.animationManager.stopAnimation(!0),this.clearSelection(),this.clearHighlighteds();let e=this.skipsUndoManager,i=this.Le!==null&&this.Le!==void 0;i&&(this.skipsUndoManager=!0);let s=null;this.ls!==null&&(s=this.ls.part,s!==null&&this.remove(s));let n=[],o=this.Vt.length;if(t){for(let r=0;r<o;r++){let a=this.Vt.r[r].parts;for(;a.next();){let h=a.value;h!==s&&h.data===null&&n.push(h)}}for(let r=0;r<n.length;r++){let a=n[r];this.remove(a)}}for(let r=0;r<o;r++)this.Vt.r[r].IR();return this.partManager.clear(),this._n.clear(),this.Or.clear(),this.fh.clear(),this.aa.clear(),this.$r.clear(),this.Dc=null,this.od.clear(),this.nT(),m.SP=[],s!==null&&(this.add(s),this.partManager.parts.delete(s)),i&&(this.skipsUndoManager=e),n}static xp=null;static _b="";static iT(){Y.xp=null,Y._b=""}static UU(){return null}reset(){this.clear(),this.Ht=!0,this.ZA(),this.themeManager=new je,this.ca(),this.Vo=!0,this.QA(),this.layout=new ee,this.Vo=!1,this.model=dt.d2(),this.model.undoManager=new vi,this.sd=!1,this.Ht=!1,this.N()}tO(){this.jr=new Mt,this.QM=new $().add(new lt({stroke:"black",font:"10pt sans-serif"}).bind("text","",m.toString).theme("stroke","text").theme("font","normal")),this.jr.set("",this.QM),this.jr.set("Comment",new $().add(new lt({stroke:"brown",font:"10pt sans-serif"}).bind("text","",m.toString).theme("stroke","comment").theme("font","normal"))),this.jr.set("LinkLabel",new $({selectable:!1,avoidable:!1}).add(new it("Ellipse",{fill:"black",stroke:null,desiredSize:new nt(3,3).kt()}).theme("fill","link"))),this.uh=new Mt,this.e2=new ht(G.Vertical,{selectionObjectName:"GROUPPANEL"}).add(new lt({stroke:"black",font:"bold 12pt sans-serif"}).bind("text","",m.toString).theme("stroke","text").theme("font","bold"),new G(G.Auto,{name:"GROUPPPANEL"}).add(new it({fill:"rgba(128,128,128,0.2)",stroke:"black",strokeWidth:1}).theme("fill","group").theme("stroke","outline").theme("strokeWidth","group"),new ue({padding:5}).theme("padding","group"))),this.uh.set("",this.e2),this.ra=new Mt,this._M=new j().add(new it({isPanelMain:!0,stroke:"black"}).theme("stroke","link"),new it({toArrow:"Standard",fill:"black",stroke:null,strokeWidth:0}).theme("toArrow").theme("fill","link")),this.ra.set("",this._M),this.ra.set("Comment",new j().add(new it({isPanelMain:!0,stroke:"brown"}).theme("stroke","comment"))),this.op=new vt(G.Auto).add(new it({fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection"),new ue({margin:1.5}).theme("margin","selection","numbers",null,t=>t?new Dt(t/2):1.5)).freezeBindings(),this.Gb=this.op,this.Yb=new vt(G.Link).add(new it({isPanelMain:!0,fill:null,stroke:"dodgerblue",strokeWidth:3}).theme("stroke","selection").theme("strokeWidth","selection")).freezeBindings()}setRTL(t){let e=t===void 0?this.div:t;e===null&&(e=K.document.body);let i=m.Ci("div");i.dir="rtl",i.style.cssText="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll;",i.textContent="A",e.appendChild(i);let s="reverse";i.scrollLeft>0?s="default":(i.scrollLeft=1,i.scrollLeft===0&&(s="negative")),e.removeChild(i),this.nb=s}setScrollWidth(t){let e=t===void 0?this.div:t;e===null&&(e=K.document.body);let i=0;if(Y.isUsingDOM()){let s=Y.a2,n=Y.l2;s===null&&(Y.a2=m.Ci("p"),s=Y.a2,s.style.width="100%",s.style.height="200px",s.style.boxSizing="content-box",Y.l2=m.Ci("div"),n=Y.l2,n.style.position="absolute",n.style.visibility="hidden",n.style.width="200px",n.style.height="150px",n.style.boxSizing="content-box",n.appendChild(s)),n.style.overflow="hidden",e.appendChild(n);let o=s.offsetWidth;n.style.overflow="scroll";let r=s.offsetWidth;o===r&&(r=n.clientWidth),e.removeChild(n),i=o-r,i===0&&!m.fr&&(i=11)}this.jt=i,this.UM=!0}fe(t){t in Ii?this.autoScale=t:m.ur(this,t)}toString(t){t===void 0&&(t=0);let e="";this.div&&this.div.id&&(e=this.div.id);let i='Diagram "'+e+'"';if(t<=0)return i;let s=this.Vt.iterator;for(;s.next();){let n=s.value;i+=`
|
|
7
|
-
`+n.toString(t-1)}return i}static $A(t){Y.Wb=t}static Fm(){return Y.Wb}static fromDiv(t){let e=t;if(typeof t=="string"&&(e=K.document.getElementById(t)),e instanceof HTMLDivElement){let i=Y.Ji.get(e);if(i)return i}return null}get div(){return this.Mt}set div(t){if(t!==null&&m.se(t,HTMLDivElement,Y,"div"),this.Mt!==t){let e=this.Mt;if(e!==null){if(Y.Ji.delete(e),e.goDiagram=void 0,e.go=void 0,e.innerHTML="",this.lt!==null){let s=this.lt.bt;this.Ae(s,"pointermove",this.wh,!1),this.Ae(s,"pointerdown",this.ha,!1),this.Ae(s,"pointerup",this.xh,!1),this.Ae(s,"pointerout",this.bh,!1),this.Ae(s,"pointercancel",this.kh,!1),this.lt.dispose()}this.sf&&(this.sf.disconnect(),this.sf=null);let i=this.toolManager;i!==null&&(i.mouseDownTools.each(s=>s.cancelWaitAfter()),i.mouseMoveTools.each(s=>s.cancelWaitAfter()),i.mouseUpTools.each(s=>s.cancelWaitAfter())),i.cancelWaitAfter(),this.currentTool.doCancel(),this.lt=null,this.Ae(K,"resize",this.jb,!1),this.Ae(K,"wheel",this.yh,!0),Y.Fm()===this&&Y.$A(null)}else this.ha===null&&(this.io=!1);if(this.Mt=null,t!==null){let i=Y.Ji.get(t);i&&(i.div=null),this.g2(t),this.Eu(),this.themeManager&&this.themeManager.eO()}else this.themeManager&&this.themeManager.iO()}}setupRouters(){this.rf.push(new _n)}g2(t){let e=this;if(!Y.isUsingDOM())return;t==null&&m.o("Diagram setup requires an argument DIV."),e.Mt!==null&&m.o("Diagram has already completed setup."),typeof t=="string"?e.Mt=K.document.getElementById(t):t instanceof HTMLDivElement?e.Mt=t:m.o("No DIV or DIV id supplied: "+t),e.Mt===null&&m.o("Invalid DIV id; could not get element with id: "+t);let i=Y.Ji.get(e.Mt);if(i&&i!==this&&m.o("Invalid div id; div already has a Diagram associated with it."),!e.sf&&K.ResizeObserver){let u=K.ResizeObserver,c=m.PP(()=>e.requestUpdate(),250,!1);e.sf=new u(()=>c()),e.sf.observe(e.Mt)}K.getComputedStyle(e.Mt,null).position==="static"&&(e.Mt.style.position="relative");let s=5,n="rgba(2"+s+"5, 255, 255, 0)";s--,e.Mt.style["-webkit-tap-highlight-color"]=n,e.Mt.innerHTML="",Y.Ji.set(e.Mt,e),e.Mt.goDiagram=e,e.Mt.go=K.go;let o=new De(e);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",K.getComputedStyle(e.Mt,null).getPropertyValue("direction")==="rtl"&&(e.rd=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),o.bt.setAttribute("role","application"),e.lt=o,e.Wt=o._t;let r=e.Wt;e.$e=e.computePixelRatio(),e.viewSize.isReal()||(e.wt=e.Mt.clientWidth||1,e.xt=e.Mt.clientHeight||1),e.oT(e.wt,e.xt);let a=e;e.Mt.insertBefore(o.bt,e.Mt.firstChild);let h=new De(null);if(h.width=1,h.height=1,e.KR=h,e.HR=h._t,Y.isUsingDOM()){let u=m.Ci("div"),c=m.Ci("div");u.style.position="absolute",u.style.overflow="auto",u.style.width=e.wt+"px",u.style.height=e.xt+"px",u.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",e.Mt.appendChild(u),u.appendChild(c),u.onscroll=Y.sO,u.addEventListener("pointerdown",Y.nO),u.a=e,u.oO=!0,u.rO=!0,e.Hb=u,e.qb=c}e.Eu=m.PP(()=>{e.El=null,e.N()},300,!1),e.jb=m.PP(()=>{e.PM()},250,!1),e.nh=u=>(u.preventDefault(),!1),e.yh=u=>{if(!a.isEnabled)return;let c=a.lf(u,!0);c.bubbles=!0;let d=0,f=0;c.delta=0,u.deltaX!==void 0?(u.deltaX!==0&&(d=u.deltaX>0?1:-1),u.deltaY!==0&&(f=u.deltaY>0?1:-1),c.delta=Math.abs(u.deltaX)>Math.abs(u.deltaY)?-d:-f):u.wheelDeltaX!==void 0?(u.wheelDeltaX!==0&&(d=u.wheelDeltaX>0?-1:1),u.wheelDeltaY!==0&&(f=u.wheelDeltaY>0?-1:1),c.delta=Math.abs(u.wheelDeltaX)>Math.abs(u.wheelDeltaY)?-d:-f):u.wheelDelta!==void 0&&u.wheelDelta!==0&&(c.delta=u.wheelDelta>0?1:-1),a.doMouseWheel(),a.Ph(c,u)},e.WA=u=>{if(!a.isEnabled)return;e.nf=!1,a.lf(u,!0);let c=a.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},e.ha=u=>{if(!a.isEnabled)return;e.nf=!0;let c=a.Kb;c[u.pointerId]===void 0&&(c[u.pointerId]=u);let d=a.ph,f=!1;if(d[0]!==null&&(d[0].pointerId===u.pointerId||d[0].pointerType!==u.pointerType))d[0]=u;else if(d[1]!==null&&d[1].pointerId===u.pointerId)d[1]=u,f=!0;else if(d[0]===null)d[0]=u;else if(d[1]===null)d[1]=u,f=!0;else{u.preventDefault();return}let p=u.pointerType==="touch"||u.pointerType==="pen";p&&(a.xx=!1,a.fp=!0);let g=a.lO(u,u,f),y=a.o2,b=p?25:10;if(u.timeStamp-a.s2<a.jA&&!(Math.abs(y.x-u.screenX)>b||Math.abs(y.y-u.screenY)>b)?a.cp++:a.cp=1,g.clickCount=a.cp,a.s2=u.timeStamp,a.o2.setTo(u.screenX,u.screenY),a.doMouseDown(),u.button===1){u.preventDefault();return}a.Ph(g,u)},e.wh=u=>{if(!a.isEnabled)return;e.nf=!0;let c=a.ph;if(c[0]!==null&&(c[0].pointerId===u.pointerId||c[0].pointerType!==u.pointerType))c[0]=u;else if(c[1]!==null&&c[1].pointerId===u.pointerId){c[1]=u;return}else if(c[0]===null)c[0]=u;else return;if(c[0].pointerId!==u.pointerId)return;let d=a.aO(u,u,c[1]!==null);a.doMouseMove(),a.Ph(d,u)},e.xh=u=>{if(!a.isEnabled)return;e.nf=!0;let c=u.pointerType==="touch"||u.pointerType==="pen",d=a.Kb;if(c&&a.xx){delete d[u.pointerId],u.preventDefault();return}let f=a.ph;if(f[0]!==null&&(f[0].pointerId===u.pointerId||f[0].pointerType!==u.pointerType))f[0]=null;else if(f[1]!==null&&f[1].pointerId===u.pointerId){f[1]=null;return}else return;let p=a.m2(u,!1,!0,!1,!0,!1),g=K.document.elementFromPoint(u.clientX,u.clientY)||null;g!==null&&g.shadowRoot&&(g=g.shadowRoot.elementFromPoint(u.clientX,u.clientY)||null),g!==null&&g.a instanceof Y&&g.a!==a&&g.a.bp(u,p),g===null&&(g=u.target),a.bp(u,p),p.clickCount=a.cp,p.targetDiagram=a.t1(u,g),p.targetObject=null,a.doMouseUp(),a.Ph(p,u),c&&(a.fp=!1)},e.bh=u=>{if(!a.isEnabled)return;e.nf=!1;let c=a.Kb;c[u.pointerId]&&delete c[u.pointerId];let d=a.ph;if(d[0]!==null&&d[0].pointerId===u.pointerId&&(d[0]=null),d[1]!==null&&d[1].pointerId===u.pointerId&&(d[1]=null),u.pointerType==="touch"||u.pointerType==="pen")return;let f=a.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},e.kh=u=>{let c=a.ph;c[0]!==null&&c[0].pointerId===u.pointerId?(c[0]=null,a.fp=!1):c[1]!==null&&c[1].pointerId===u.pointerId&&(c[1]=null)};let l=r;if(e.hp=l.F[m.We("7eba17a4ca3b1a8346")][m.We("78a118b7")](l.F,Y.Sh,s,s),r.clearContextCache(!0),e.hO(),this.tf==="svg"){let u=this.zo.get("svg");this.Mt&&this.Mt.appendChild(u.bt),this.Wt=u._t}}addEventListener(t,e,i,s){t.addEventListener(e,i,{capture:s,passive:!1})}Et(t,e,i,s){t.addEventListener(e,i,{capture:s,passive:!1})}removeEventListener(t,e,i,s){t.removeEventListener(e,i,{capture:s})}Ae(t,e,i,s){t.removeEventListener(e,i,{capture:s})}hO(){let t=this,e=this.lt.bt;e instanceof HTMLCanvasElement||(e=t.div),this.Et(e,"pointerdown",t.ha,!1),this.Et(e,"pointermove",t.wh,!1),this.Et(e,"pointerup",t.xh,!1),this.Et(e,"pointerout",t.bh,!1),this.Et(e,"pointercancel",t.kh,!1),this.Et(e,"pointerenter",t.cO,!1),this.Et(e,"pointerleave",t.fO,!1),this.Et(e,"wheel",t.yh,!1),this.Et(e,"keydown",t.uO,!1),this.Et(e,"keyup",t.dO,!1),this.Et(e,"blur",t.gO,!1),this.Et(e,"focus",t.mO,!1),this.Et(e,"selectstart",i=>(i.preventDefault(),!1),!1),this.Et(e,"contextmenu",i=>(i.preventDefault(),!1),!1),this.Et(K,"resize",t.jb,!1)}Px(){this.dp>30&&(this.El=1)}gS(t){this.El!==null&&(this.El=null,t&&this.Eu(),this.dp=0,this.h2=[0,0,0,0,0],this.gp=0)}computePixelRatio(){return this.El!==null?this.El:K.devicePixelRatio||1}get avgSpf(){return this.dp}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){let t=this.commandHandler;if(!this.toggleKeyboardControl()){if((t.isFocusEnabled||t.isVirtualPointerEnabled)&&t.doVirtualFocusKeyDown()){let e=this.lastInput;e.bubbles=!1;let i=e.event;i&&(i.stopPropagation&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault());return}this.currentTool.doKeyDown()}}toggleKeyboardControl(){let t=this.lastInput,e=t.commandKey;if((t.control||t.meta)&&t.alt&&(e==="Enter"||e==="NumpadEnter")){let i=this.commandHandler,s=i.isFocusEnabled||i.isVirtualPointerEnabled;return i.isFocusEnabled=!s,i.isVirtualPointerEnabled=!s,i.focus=i.findFirstFocus(),this.T("FocusOrVirtualPointerEnabledChanged"),!0}return!1}doKeyUp(){let t=this.commandHandler;if((t.isFocusEnabled||t.isVirtualPointerEnabled)&&t.doVirtualFocusKeyUp()){let e=this.lastInput;e.bubbles=!1;let i=e.event;i&&(i.stopPropagation&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault());return}this.currentTool.doKeyUp()}ad(t,e){if(e)for(let i in e)i!=="sourceDiagram"&&(t[i]=e[i])}emitMouseDown(t,e,i,s){if(typeof t!="number"||typeof e!="number")throw new Error("Robot.mouseDown first two args must be X,Y numbers");i===void 0&&(i=0);let n=this;if(s&&s.sourceDiagram&&(n=s.sourceDiagram),!n.isEnabled)return this;let o=new te;return o.diagram=n,o.documentPoint=new P(t,e),o.viewPoint=n.transformDocToView(o.documentPoint),o.timestamp=i,o.down=!0,this.ad(o,s),n.lastInput=o,n.firstInput=o.copy(),n.doMouseDown(),this}emitMouseMove(t,e,i,s){if(typeof t!="number"||typeof e!="number")throw new Error("Robot.mouseMove first two args must be X,Y numbers");i===void 0&&(i=0);let n=this;if(s&&s.sourceDiagram&&(n=s.sourceDiagram),!n.isEnabled)return this;let o=new te;return o.diagram=n,o.documentPoint=new P(t,e),o.viewPoint=n.transformDocToView(o.documentPoint),o.timestamp=i,this.ad(o,s),n.lastInput=o,n.doMouseMove(),this}emitMouseUp(t,e,i,s){if(typeof t!="number"||typeof e!="number")throw new Error("Robot.mouseUp first two args must be X,Y numbers");i===void 0&&(i=0);let n=this;if(s&&s.sourceDiagram&&(n=s.sourceDiagram),!n.isEnabled)return this;let o=new te;return o.diagram=n,o.documentPoint=new P(t,e),o.viewPoint=n.transformDocToView(o.documentPoint),o.timestamp=i,o.up=!0,n.firstInput.documentPoint.equals(o.documentPoint)&&(o.clickCount=1),this.ad(o,s),n.lastInput=o,n.doMouseUp(),this}emitMouseWheel(t,e,i){if(typeof t!="number")throw new Error("Robot.mouseWheel first arg must be DELTA number");e===void 0&&(e=0);let s=this;if(!s.isEnabled)return this;let n=new te;return n.diagram=s,n.documentPoint=s.lastInput.documentPoint,n.viewPoint=s.lastInput.viewPoint,n.delta=t,n.timestamp=e,this.ad(n,i),s.lastInput=n,s.doMouseWheel(),this}emitKeyDown(t,e,i){if(typeof t!="string"&&typeof t!="number")throw new Error("Robot.keyDown first arg must be a string or a number");e===void 0&&(e=0);let s=this;if(!s.isEnabled)return this;let n=new te;return n.diagram=s,n.documentPoint=s.lastInput.documentPoint,n.viewPoint=s.lastInput.viewPoint,typeof t=="string"?n.key=t:typeof t=="number"&&(n.key=String.fromCharCode(t)),n.timestamp=e,n.down=!0,this.ad(n,i),s.lastInput=n,s.doKeyDown(),this}emitKeyUp(t,e,i){if(typeof t!="string"&&typeof t!="number")throw new Error("Robot.keyUp first arg must be a string or a number");e===void 0&&(e=0);let s=this;if(!s.isEnabled)return this;let n=new te;return n.diagram=s,n.documentPoint=s.lastInput.documentPoint,n.viewPoint=s.lastInput.viewPoint,typeof t=="string"?n.key=t:typeof t=="number"&&(n.key=String.fromCharCode(t)),n.timestamp=e,n.up=!0,this.ad(n,i),s.lastInput=n,s.doKeyUp(),this}doFocus(){this.focus()}focus(){if(this.lt)if(this.scrollsPageOnFocus)this.lt.focus();else{let t=K.scrollX,e=K.scrollY;this.lt.focus(),K.scrollTo(t,e)}}mO(t){let e=Y.Ji.get(this);e&&e.T("GainedFocus")}gO(t){let e=Y.Ji.get(this);e&&e.T("LostFocus")}PM(){if(this.lt===null)return;let t=this.Mt;if(t===null||t.clientWidth===0||t.clientHeight===0)return;this.UM||this.setScrollWidth();let e=this.eo?this.jt:0,i=this.Pn?this.jt:0,s=this.$e;if(this.$e=this.computePixelRatio(),this.$e!==s&&(this.$u=!0,this.requestUpdate()),t.clientWidth!==this.wt+e||t.clientHeight!==this.xt+i){this.Mh(),this.Wi=!0;let n=this.layout;n!==null&&n.isViewportSized&&this.autoScale===1&&(this.Zc=!0,n.p()),this.As||this.requestUpdate()}}QA(){let t=0,e=new Et;e.name="Grid",e.allowSelect=!1,e.pickable=!1,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="ViewportBackground",e.isViewportAligned=!0,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="Background",this.Zr(e,t++),e=new Et,e.name="",this.Zr(e,t++),e=new Et,e.name="Foreground",this.Zr(e,t++),e=new Et,e.name="ViewportForeground",e.isViewportAligned=!0,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="Adornment",e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="Tool",e.isTemporary=!0,e.isInDocumentBounds=!0,this.Zr(e,t++)}rT(){let t=new G(G.Grid,{name:"GRID"}).add(new it("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new it("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new it("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new it("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new it("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new it("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),e=new pt({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(e),this.partManager.parts.delete(e),t.visible=!1,t}static sO(){let t=Y.Ji.get(this.parentElement||this);if(t){if(t.Eb){t.Eb=!1;return}if(!t.isEnabled){t.lT();return}t.diagramScroll(this)}}static nO(t){if(!this.a.isEnabled){this.a.updateScroll();return}this.a.Ub=t.target.scrollTop,this.a.Vb=t.target.scrollLeft}diagramScroll(t){if(this.lt===null)return;let e=this.Hb,i=this.qb;this.ip=!0;let s=this.documentBounds,n=this.viewportBounds,o=this.ch,r=s.x-o.left,a=s.y-o.top,h=s.width+o.left+o.right,l=s.height+o.top+o.bottom,u=s.right+o.right,c=s.bottom+o.bottom,d=n.x,f=n.y,p=n.width,g=n.height,y=n.right,b=n.bottom,v=this.scale,w,k=t.scrollLeft;if(this.rd)switch(this.nb){case"negative":k=k+t.scrollWidth-t.clientWidth;break;case"reverse":k=t.scrollWidth-k-t.clientWidth;break}let S=k;if(p<h||g<l){w=P.z(this.position.x,this.position.y),this.allowHorizontalScroll&&this.Vb!==S&&(w.x=S/v+r,this.Vb=S),this.allowVerticalScroll&&this.Ub!==t.scrollTop&&(w.y=t.scrollTop/v+a,this.Ub=t.scrollTop),this.position=w,P.i(w),this.ip=!1,this.td=!1;return}if(w=P.l(),t.oO&&this.allowHorizontalScroll&&(r<d&&(this.position=w.e(S+r,this.position.y)),u>y)){let N=e.scrollWidth-this.wt;this.position=w.e(-N+S-this.wt/v+u,this.position.y)}if(t.rO&&this.allowVerticalScroll&&(a<f&&(this.position=w.e(this.position.x,t.scrollTop+a)),c>b)){let N=e.scrollHeight-this.xt;this.position=w.e(this.position.x,-N+t.scrollTop-this.xt/v+c)}P.i(w),this.Qr(),this.ip=!1,this.td=!1,s=this.documentBounds,n=this.viewportBounds,u=s.right,y=n.right,c=s.bottom,b=n.bottom,r=s.x,d=n.x,a=s.y,f=n.y,p>=h&&r>=d&&u<=y&&(i.style.width="1px"),g>=l&&a>=f&&c<=b&&(i.style.height="1px")}computeBounds(t){return t===void 0&&(t=new I),this.De(),this.aT(t)}aT(t){if(this.fixedBounds.isReal())return t.h(this.fixedBounds),t.addMargin(this.Qt),t;let e=!0,i=this.Vt.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];if(!o.visible||!o.isInDocumentBounds)continue;let r=o.Ct.r,a=r.length;for(let h=0;h<a;h++){let l=r[h];if(!l.isInDocumentBounds||!l.isVisible())continue;let u=l.actualBounds;u.isReal()&&(e?(e=!1,t.h(u)):t.unionRect(u))}}return e&&t.e(0,0,0,0),t.addMargin(this.Qt),t}computePartsBounds(t,e){e===void 0&&(e=!1);let i;if(Array.isArray(t))for(let s=0;s<t.length;s++){let n=t[s];!e&&n instanceof j||(n.ensureBounds(),i===void 0?i=n.actualBounds.copy():i.unionRect(n.actualBounds))}else{let s=t.iterator;for(;s.next();){let n=s.value;!e&&n instanceof j||(n.ensureBounds(),i===void 0?i=n.actualBounds.copy():i.unionRect(n.actualBounds))}}return i===void 0?new I(NaN,NaN,0,0):i}$s(t){if(!t&&!this.io||this.Ht||this.lt===null||!this.documentBounds.isReal())return;if(this.Ht=!0,t){let c=this.initialPosition;if(c.isReal()){this.Ht=!1,this.position=c;return}let d=this.initialDocumentSpot,f=this.initialViewportSpot;d.isNoSpot()&&(d=T.TopLeft),f.isNoSpot()&&(f=T.TopLeft);let p=P.l();p.setRectSpot(this.documentBounds,d);let g=this.viewportBounds,y=I.z(0,0,g.width,g.height),b=P.l();b.setRectSpot(y,f),b.e(p.x-b.x,p.y-b.y),this.Ht=!1,this.position=b,I.i(y),P.i(b)}let e=this.na;t&&this.Rr!==1&&(e=this.Rr);let i=e!==1?this.hd(e):this.scale,s=this.ct.x,n=this.ct.y,o=this.wt/i,r=this.xt/i,a=this.Jc,h=this.Qm;if(t&&!a.isSpot()&&(h.isSpot()||h.isDefault())){let c=this.initialDocumentSpot.isSpot()&&this.initialViewportSpot.isSpot();a=h.isDefault()&&!c?T.Center:h}this.p2(this.documentBounds,o,r,a,t);let l=this.scale;this.scale=i,this.Ht=!1;let u=this.viewportBounds;u.equalsApproxTo(s,n,o,r)||this.onViewportBoundsChanged(new I(s,n,o,r),u,l,!1)}hd(t){let e=this.ap;if(this.lt===null)return e;if(t===1)return this.scale;this.ensureBounds();let i=this.documentBounds;if(!i.isReal())return e;let s=i.width,n=i.height,o=this.wt+(this.eo?this.jt:0),r=this.xt+(this.Pn?this.jt:0),a=o/s,h=r/n,l=this.ch,u=l.left+l.right!==0,c=l.top+l.bottom!==0;(u||c)&&(h===a?(h=(r-this.jt)/n,a=(o-this.jt)/s):h>a?h=(r-this.jt)/n:a=(o-this.jt)/s);let d=0;return t===2?d=Math.min(h,a):t===3&&(h>a?d=(r-this.jt)/n:d=(o-this.jt)/s),d>e&&(d=e),d<this.minScale&&(d=this.minScale),d>this.maxScale&&(d=this.maxScale),d}zoomToFit(){let t=this.lh;this.lh=1,this.scale=this.hd(2),this.alignDocument(T.Center,T.Center),t!==1&&(this.$s(!1),this.p2(this.documentBounds,this.wt/this.et,this.xt/this.et,this.Jc,!1)),this.lh=t}zoomToRect(t,e){e===void 0&&(e=2);let i=t.width,s=t.height;if(i===0||s===0||isNaN(i)&&isNaN(s))return;let n=1;if(e===2||e===3)if(isNaN(i))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/i;else{let o=this.wt,r=this.xt;e===3?r/s>o/i?n=(r-(this.Pn?this.jt:0))/s:n=(o-(this.eo?this.jt:0))/i:n=Math.min(r/s,o/i)}this.scale=n,this.position=new P(t.x,t.y)}get pO(){return this.Ht}set pO(t){this.Ht=t}alignDocument(t,e){this.ensureBounds();let i=this.documentBounds,s=this.viewportBounds;this.position=new P(i.x+(t.x*i.width+t.offsetX)-(e.x*s.width-e.offsetX),i.y+(t.y*i.height+t.offsetY)-(e.y*s.height-e.offsetY))}focusObject(t){if(t instanceof J){this.mp=t;let e=P.l();this.pp=this.transformDocToView(t.getDocumentPoint(T.TopLeft,e)),P.i(e)}else this.mp=null,this.pp=P.mn}p2(t,e,i,s,n){let o=P.z(this.ct.x,this.ct.y),r=o.x,a=o.y;if(this.mp!==null){let h=P.l();h=this.mp.getDocumentPoint(T.TopLeft,h),r=h.x-this.pp.x/this.scale,a=h.y-this.pp.y/this.scale,s=T.None,P.i(h)}if(n||this.scrollMode===1){s.isSpot()&&(e>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*e-s.offsetX)),i>t.height&&(a=t.y+(s.y*t.height+s.offsetY)-(s.y*i-s.offsetY)));let h=this.ch,l=e-t.width;if(e<t.width+h.left+h.right){let c=r+e/2;c=Math.min(c,t.right+Math.max(l,h.right)-e/2),c=Math.max(c,t.left-Math.max(l,h.left)+e/2),r=c-e/2}else r>t.left?r=t.left:r<t.right-e&&(r=t.right-e);let u=i-t.height;if(i<t.height+h.top+h.bottom){let c=a+i/2;c=Math.min(c,t.bottom+Math.max(u,h.bottom)-i/2),c=Math.max(c,t.top-Math.max(u,h.top)+i/2),a=c-i/2}else a>t.top?a=t.top:a<t.bottom-i&&(a=t.bottom-i)}if(o.x=isFinite(r)?r:-this.Qt.left,o.y=isFinite(a)?a:-this.Qt.top,this.positionComputation!==null){let h=this.positionComputation(this,o);o.x=h.x,o.y=h.y}this.Cs.IA(this.ct,o),this.ct.e(o.x,o.y),this.kp(),this.ca(),this.yO(),P.i(o)}findPartAt(t,e){if(e===void 0&&(e=!0),e){let i=this.wS(t,s=>s.part,s=>s.canSelect());if(i instanceof pt)return i}else{let i=this.wS(t,s=>s.part);if(i instanceof pt)return i}return null}findObjectAt(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null),this.De();let s=this.Vt.iteratorBackwards;for(;s.next();){let n=s.value;if(!n.visible)continue;let o=n.findObjectAt(t,e,i);if(o!==null)return o}return null}wS(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null),this.De();let s=this.Vt.iteratorBackwards;for(;s.next();){let n=s.value;if(!n.visible||n.isTemporary)continue;let o=n.findObjectAt(t,e,i);if(o!==null)return o}return null}findPartsAt(t,e,i){return e===void 0&&(e=!0),this.wO(t,s=>s.part,e?s=>s instanceof pt&&s.canSelect():null,i)}wO(t,e,i,s){e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof q)&&!(s instanceof V)&&(s=new V),this.De();let n=this.Vt.iteratorBackwards;for(;n.next();){let o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,e,i,s)}return s}findObjectsAt(t,e,i,s){e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof q)&&!(s instanceof V)&&(s=new V),this.De();let n=this.Vt.iteratorBackwards;for(;n.next();){let o=n.value;o.visible&&o.findObjectsAt(t,e,i,s)}return s}findPartsIn(t,e,i,s){return e===void 0&&(e=!1),i===void 0&&(i=!0),this.xO(t,null,n=>n instanceof pt&&(!i||n.canSelect()),e,s)}findObjectsIn(t,e,i,s,n){e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof q)&&!(n instanceof V)&&(n=new V),this.De();let o=this.Vt.iteratorBackwards;for(;o.next();){let r=o.value;r.visible&&r.findObjectsIn(t,e,i,s,n)}return n}kS(t,e,i,s,n,o){let r=new V;this.De();let a=this.Vt.iteratorBackwards;for(;a.next();){let h=a.value;h.visible&&h.kS(t,e,i,s,r,n,o)}return r}xO(t,e,i,s,n){e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof q)&&!(n instanceof V)&&(n=new V),this.De();let o=this.Vt.iteratorBackwards;for(;o.next();){let r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,e,i,s,n)}return n}findPartsNear(t,e,i,s,n){return i===void 0&&(i=!0),s===void 0&&(s=!0),this.bO(t,e,null,o=>o instanceof pt&&(!s||o.canSelect()),i,n)}findObjectsNear(t,e,i,s,n,o){i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof q||n instanceof V)&&(o=n),n=!0),!(o instanceof q)&&!(o instanceof V)&&(o=new V),this.De();let r=this.Vt.iteratorBackwards;for(;r.next();){let a=r.value;a.visible&&a.findObjectsNear(t,e,i,s,n,o)}return o}bO(t,e,i,s,n,o){i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof q||n instanceof V)&&(o=n),n=!0),!(o instanceof q)&&!(o instanceof V)&&(o=new V),this.De();let r=this.Vt.iteratorBackwards;for(;r.next();){let a=r.value;!a.visible||a.isTemporary||a.findObjectsNear(t,e,i,s,n,o)}return o}acceptEvent(t){return this.lf(t,t instanceof MouseEvent)}lf(t,e){let i=this.Wr;this.Wr=this.dh,this.dh=i,i.diagram=this,i.event=t,e?this.bp(t,i):(i.viewPoint=this.Wr.viewPoint,i.documentPoint=this.Wr.documentPoint);let s=0,n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),i.modifiers=s,i.button=n.button,n.buttons!==void 0&&(i.buttons=n.buttons),m.fr&&n.button===0&&n.ctrlKey&&(i.button=2),i.down=!1,i.up=!1,i.clickCount=1,i.delta=0,i.handled=!1,i.bubbles=!1,i.timestamp=t.timeStamp,i.isMultiTouch=!1,i.targetDiagram=this.t1(t,t.target),i.targetObject=null,i}t1(t,e){if(e===null)return null;let i=Y.Ji.get(e);if(i)return i;let s=t.path;if(!s&&m.it(t.composedPath)&&(s=t.composedPath()),s&&s[0]){let n=Y.Ji.get(s[0]);if(n)return n}return null}lO(t,e,i){let s=this.m2(t,!0,!1,!1,!0,i);return this.bp(e,s),s.targetDiagram=this.t1(t,t.target),s.targetObject=null,i||s.clone(this.lp),s}aO(t,e,i){let s=this.m2(t,!1,!1,!1,!1,i),n=K.document.elementFromPoint(e.clientX,e.clientY)||null;n!==null&&n.shadowRoot&&(n=n.shadowRoot.elementFromPoint(e.clientX,e.clientY)||null);let o=this,r=t;if(n){let a=this.t1(t,n);a&&(r=e,o=a)}return s.targetDiagram=o,this.bp(r,s),s.targetObject=null,s}m2(t,e,i,s,n,o){let r=this.Wr;this.Wr=this.dh,this.dh=r,r.diagram=this,r.clickCount=1,r.delta=0;let a=0;return t.ctrlKey&&(a+=1),t.altKey&&(a+=2),t.shiftKey&&(a+=4),t.metaKey&&(a+=8),r.modifiers=a,r.event=t,r.timestamp=t.timeStamp,r.button=i?this.firstInput.button:t.button,r.buttons=t.buttons,m.fr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=e,r.up=i,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}Ph(t,e){return t.bubbles?!0:(e.stopPropagation!==void 0&&e.stopPropagation(),e.cancelable!==!1&&e.preventDefault(),e.cancelBubble=!0,!1)}uO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!1);return i.key=t.key,i.code=t.code,i.down=!0,e.doKeyDown(),e.Ph(i,t)}dO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!1);return i.key=t.key,i.code=t.code,i.up=!0,e.doKeyUp(),e.Ph(i,t)}cO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!0);return e.mouseEnter!==null&&e.mouseEnter(i),e.currentTool.standardMouseOver(),e.Ph(i,t)}fO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!0);return e.mouseLeave!==null&&e.mouseLeave(i),e.Ph(i,t)}getMouse(t){let e=this.lt;if(e===null)return new P(0,0);let i=e.getBoundingClientRect(),s=(t.clientX-i.left)*(this.wt/i.width),n=(t.clientY-i.top)*(this.xt/i.height);return new P(s,n).Hi(this.v)}bp(t,e){let i=this.lt,s=0,n=0;if(i!==null){let r=i.getBoundingClientRect();s=(t.clientX-r.left)*(this.wt/r.width),n=(t.clientY-r.top)*(this.xt/r.height)}e.viewPoint.e(s,n);let o=P.z(s,n);this.v.Ni(o),e.documentPoint.h(o),P.i(o)}_L(t,e,i){let s;if(this.ph[0]!==null)s=this.ph[e];else return;let n=this.lt;if(n!==null){let o=n.getBoundingClientRect();i.e((s.clientX-o.left)*(this.wt/o.width),(s.clientY-o.top)*(this.xt/o.height))}}invalidateDocumentBounds(){this.gh||(this.gh=!0,this.requestUpdate(!1))}kO(){this.As||this.De(),this.ensureBounds()}redraw(){this.Ht||this.As||(this.N(),this.maybeUpdate())}isUpdateRequested(){return this.Tr}delayInitialization(t){t===void 0&&(t=null);let e=this.animationManager,i=e.isEnabled;e.stopAnimation(),e.isEnabled=!1,this.Pr(),this.io=!1,this.Yx=new P(NaN,NaN),e.isEnabled=i,this.As=!0;let s=this;t!==null&&m.dn(()=>{s.As=!1,e.Kl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Tr===!0||this.Ht||t===!1&&this.As)return;this.Tr=!0;let e=this;K.requestAnimationFrame(()=>{e.Tr&&e.maybeUpdate()})}maybeUpdate(){this.Zu&&!this.Tr||(this.Zu&&(this.Zu=!1),this.Pr())}w2(t,e){!this.td||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.lT()||(t&&this.De(),e&&this.$s(!1))}Pr(t){if(this.As||(this.Tr=!1,this.Mt===null&&!this.ed.isReal()))return;this.As=!0;let e=this.animationManager,i=this.od;if(!e.isAnimating&&i.length!==0){let u=i.r,c=u.length;for(let d=0;d<c;d++){let f=u[d];f.xi(!1),f.f()}i.clear()}let s=this.i2;s.count>0&&(s.each(u=>u.b2()),s.clear());let n=!1,o=!1;e.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),e.Pe||this.PM(),t||this.w2(!1,!0);let r=!this.undoManager.isUndoingRedoing&&(this.Ol||this.rf.count!==0&&this.Or.size!==0),a=!this.io||this.Jr;this.De(!0);let h=!1;(a||r)&&(this.io?this.k2(!this.Zc,r):(this.startTransaction("Initial Layout"),e.isEnabled===!1&&e.stopAnimation(),this.k2(!1,r)),h=a),this.Zc=!1,this.Ol=!1,this.De(),this.Mb||this.kO(),t||this.w2(!0,!1);let l=!1;if(h){let u=I.l();u.h(this.viewportBounds),this.io||(this.io=!0,l=!0,this.skipsUndoManager||(this.undoManager.yx=!0),this.undoManager.wx=!0,this.PO()),this.SO(),this.De(!1),t||this.w2(!0,!0),I.i(u)}else if(e.zc&&e.Gx){if(this.Rr!==1)this.scale=this.hd(this.Rr);else if(this.na!==1)this.scale=this.hd(this.na);else{let u=this.initialScale;isFinite(u)&&u>0&&(this.scale=u)}this.$s(!0)}h&&l&&this.commitTransaction("Initial Layout"),this.ls!==null&&(this.ls.visible&&!this._c&&(this.P2(),this._c=!0),!this.ls.visible&&this._c&&(this._c=!1)),t||this.Ge(this.Wt),o&&(this.skipsUndoManager=n),this.As=!1}get Za(){return this.io}PO(){if(this.Rr!==1)this.scale=this.hd(this.Rr);else if(this.na!==1)this.scale=this.hd(this.na);else{let e=this.initialScale;isFinite(e)&&e>0&&(this.scale=e)}this.$s(!0);let t=this.Vt.r;this.rs(t,t.length,this,this.viewportBounds),this.T("InitialLayoutCompleted"),this.Yx.h(this.ct),this.cd()}SO(){this.T("LayoutCompleted")}Pp(t){this._n.add(t)}addInvalidRoute(t){this.Uo?this.fh.add(t):this.Or.add(t)}De(t){if(this._n.size!==0&&!(!this.As&&this.animationManager.isTicking)){if(this.As||(this.Ol=!0),t){this.hT(this._n);return}for(let e=0;e<23&&this._n.size!==0;e++){let i=new Set(this._n);this._n.clear(),this.b2(i,this._n)}this.nodes.each(e=>{e instanceof ht&&e.cT(!1)})}}hT(t,e){for(let i of t)!i.Di()||i instanceof ht||(i._r()?(i.ht(1/0,1/0),i.Ut()):e&&e.add(i));for(let i of t)if(i instanceof ht){if(!i.isVisible())continue;this.e1(i)}}b2(t,e){this.hT(t,e);for(let i of t){if(!(i instanceof j))continue;let s=i;s.isVisible()&&(s._r()?(s.ht(1/0,1/0),s.Ut()):e.add(s))}for(let i of t)i instanceof vt&&i.isVisible()&&(i._r()?(i.ht(1/0,1/0),i.Ut()):e.add(i))}fd(t){let e=t instanceof Y,i=e?t.links:t.memberParts,s=this._n;if(e)this.De(!0);else{for(;i.next();){let n=i.value;s.has(n)&&(!n.Di()||n instanceof ht||n._r()&&(n.ht(1/0,1/0),n.Ut()))}for(i.reset();i.next();){let n=i.value;if(s.has(n)&&n instanceof ht){if(!n.isVisible())continue;this.e1(n)}}i.reset()}for(;i.next();){let n=i.value;n instanceof j&&s.has(n)&&n.isVisible()&&n._r()&&(n.ht(1/0,1/0),n.Ut())}}e1(t){let e=m.st(),i=m.st(),s=t.memberParts;for(;s.next();){let o=s.value;o.isVisible()&&(o instanceof ht?(o.Xo()||o.as()||o.fa())&&this.e1(o):o instanceof j?o.fromNode===t||o.toNode===t?i.push(o):e.push(o):(o.ht(1/0,1/0),o.Ut()))}let n=e.length;for(let o=0;o<n;o++){let r=e[o];r.ht(1/0,1/0),r.Ut()}m.Z(e),t.ht(1/0,1/0),t.Ut(),n=i.length;for(let o=0;o<n;o++){let r=i[o];r.ht(1/0,1/0),r.Ut()}m.Z(i)}rs(t,e,i,s){if(!(!this.ef&&!this.animationManager.isAnimating)){for(let n=0;n<e;n++)t[n].rs(i,s);this.De()}}Ge(t){this.Mt!==null&&(this.lt===null&&m.o("No canvas specified"),this.tf==="svg"?this.MO(t):this.CO(t))}CO(t){let e=this.animationManager;if(e.Pe||e.isAnimating&&!e.isTicking)return;let i=new Date;if(this.Sp(),this.Mt&&this.Mt.style.opacity==="0")return;let s=t!==this.Wt,n=this.Vt.r,o=n.length,r=this;if(this.rs(n,o,r,r.viewportBounds),s)t.clearContextCache(!0),this.Qr();else if(!this.Wi&&!e.isAnimating)return;let a=this.v,h=this.$e;t.setTransform(h,0,0,h,0,0),t.clearRect(0,0,this.wt,this.xt),this.Zt!==1&&(t.globalAlpha=this.Zt),this.S2(t);for(let f=0;f<o;f++)t.setTransform(h,0,0,h,0,0),t.transform(a.m11,a.m12,a.m21,a.m22,a.dx,a.dy),t.commitTransform(),n[f].Ge(t,r);let l=!1;this.of?this.of.Sh(this,t)&&(l=this.hp()):l=!0,l&&(Nt.prototype.Ni=Nt.prototype.Mu),s?(this.Wt.clearContextCache(!0),this.Qr()):(this.ef=!1,this.Wi=!1);let u=+new Date-+i,c=!1,d=this.h2;if(c||this.El===null){d[this.gp]=u,this.gp=(this.gp+1)%d.length;let f=0;for(let p=0;p<d.length;p++)f+=d[p];this.dp=f/d.length}if(this.Zt!==1&&(t.globalAlpha=1),c){t.setTransform(1,0,0,1,0,0);for(let f=0;f<d.length;f++)t.fillText(d[f].toString(),20,150+ +(f*20))}}MO(t){if(this.Mt===null)return;let e=this.animationManager;if(e.Pe||e.isAnimating&&!e.isTicking)return;this.Sp();let i=this.wt,s=this.xt;t.surface.resize(i,s,i,s);let n=this.Vt.r,o=n.length,r=this;if(this.rs(n,o,r,r.viewportBounds),!this.Wi&&!e.isAnimating)return;let a=this.v;t.lastDrawnPart=null,t.setDiagramPosScale(a.m11,a.m12,a.m21,a.m22,a.dx,a.dy),this.Zt!==1&&(t.globalAlpha=this.Zt),this.S2(t);let h=this.$e,l=this.lt._t;l.setTransform(h,0,0,h,0,0),l.clearRect(0,0,this.wt,this.xt);for(let c=0;c<o;c++)n[c].Ge(t,r);let u=!1;this.of?this.of.Sh(this,l)&&(u=this.hp()):u=!0,u&&(Nt.prototype.Ni=Nt.prototype.Mu),this.ef=!1,this.Wi=!1}i1(t,e,i,s,n,o,r,a,h){o===void 0&&(o=null),r===void 0&&(r=null),a===void 0&&(a=!1),h===void 0&&(h=!1),this.Sp(),t.clearContextCache(!0),this.Qr(),this.mh=!0;let l=this.et;this.et=s;let u=this,c=this.Vt.r,d=c.length;try{let f=new I(n.x,n.y,i.width/s,i.height/s),p=f.copy();p.addMargin(e),this.P2(p),this.De(),this.rs(c,d,u,f),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,i.width,i.height),r!==null&&r!==""&&(t.fillStyle=r,t.fillBackground(0,0,i.width,i.height));let g=Nt.l();g.Ue(),g.Gs(e.left,e.top),g.et(s),(n.x!==0||n.y!==0)&&g.Gs(-n.x,-n.y),t.setTransform(g.m11,g.m12,g.m21,g.m22,g.dx,g.dy),t.commitTransform(),t instanceof ae&&t.setDiagramPosScale(g.m11,g.m12,g.m21,g.m22,g.dx,g.dy),Nt.i(g),this.S2(t),t.globalAlpha=this.Zt;let y=this.findLayer("Grid");if(o){let b=new V,v=o.iterator;for(v.reset();v.next();){let w=v.value;w instanceof pt&&(!h&&w.layer===y||(w.Wc(),b.add(w)))}for(let w=0;w<d;w++)c[w].ER(t,u,b,a);b.each(w=>w.Wc())}else for(let b=0;b<d;b++){let v=c[b];v===y?h&&v.Ge(t,u,!0):v.Ge(t,u,a)}this.mh=!1,this.of&&this.Wt&&this.of.Sh(this,this.Wt)&&this.hp()}finally{this.et=l,t.clearContextCache(!0),this.Qr(),this.rs(c,d,u,u.viewportBounds),this.cd(),this.Wt instanceof ae&&(this.Wt.diagramGroup.replaceChildren(),this.redraw())}}getRenderingHint(t){return this.Fr[t]}setRenderingHint(t,e){t==="minDrawingLength"&&(this.Jm=e),this.Fr[t]=e,this.redraw()}resetRenderingHints(){this.Fr=new yt,this.Fr.drawShadows=!0,this.Fr.textGreeking=!0,this.Fr.viewportOptimizations=!m.fr,this.Fr.temporaryPixelRatio=!0,this.Fr.pictureRatioOptimization=!0,this.Fr.minDrawingLength=1,this.Jm=1}S2(t){let e=this.Fr;if(e===null)return;if(e.imageSmoothingEnabled!==void 0){let s=!!e.imageSmoothingEnabled;t.setImageSmoothingEnabled(s)}let i=e.defaultFont;i!=null&&(t.font=i)}getInputOption(t){return this.Ju[t]}setInputOption(t,e){this.Ju[t]=e}QR(){this.Ju=new yt,this.Ju.extraTouchArea=10,this.Ju.extraTouchThreshold=10,this.Ju.hasGestureZoom=!0}set(t){return t?(Object.assign(this,t),this):this}attach(t){return this.setProperties(t)}setProperties(t){return Y.Mp(this,t),this}static Mp(t,e){if(!e)return;let i=t instanceof G,s=t instanceof Y;for(let n in e){n===""&&m.o("Setting properties requires non-empty property names");let o=t,r=n;if(i||s){let h=n.indexOf(".");if(h>0){let l=n.substring(0,h);i?o=t.findObject(l):(o=t[l],o==null&&(o=t.toolManager[l])),m.$(o)?r=n.substring(h+1):m.o("Unable to find object named: "+l+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!m.Gw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(e[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(e[r]);continue}else if(s&&m.Gw(t.toolManager,r))o=t.toolManager;else if(s&&t.fT(r)){t.addDiagramListener(r,e[r]);continue}else if(t instanceof dt&&r==="Changed"){t.addChangedListener(e[r]);continue}else m.o('Trying to set undefined property "'+r+'" on object: '+o.toString());let a=e[n];o[r]=a,r[0]==="_"&&o instanceof J&&o.addCopyProperty(r)}}VA(){if(this.aa.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.aa.count>0;){let t=this.aa;this.aa=new Mt;let e=t.iterator;for(;e.next();){let i=e.key;i.invalidateOtherJumpOvers(e.value),i.ai()}}this.N()}}N(t){if(t===void 0)this.Wi=!0,this.requestUpdate();else{let e=this.viewportBounds;t.isReal()&&e.intersectsRect(t)&&(this.Wi=!0,this.requestUpdate())}this.T("InvalidateDraw")}invalidateViewport(t,e){if(this.Wi!==!0){if(this.Wi=!0,this.tf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Px(),this.maybeUpdate(),this.gS(!0)):this.maybeUpdate()}}Mh(){this.td=!0}Qr(){this.ef=!0}Sp(){this.$u!==!1&&(this.$u=!1,this.oT(this.wt,this.xt))}oT(t,e){this.ca();let i=this.$e,s=t*i,n=e*i;this.lt.resize(s,n,t,e)&&(this.Wi=!0,this.Wt.clearContextCache(!0))}lT(){let t=this.lt;if(t===null||this.ed.isReal())return!0;let e=this.wt,i=this.xt,s=this.Mt,n=!1,o=this.eo?this.jt:0,r=this.Pn?this.jt:0,a=s.clientWidth||e+o,h=s.clientHeight||i+r,l=this.viewportBounds,u=l.x,c=l.y,d=l.width,f=l.height;if((a!==e+o||h!==i+r)&&(this.eo=!1,this.Pn=!1,o=0,r=0,this.wt=a,this.xt=h,this.$u=!0,n=!0,this.ca()),!this.io||!this.viewportBounds.isReal())return!0;let p=this.Hb,g=this.qb;if(this.td=!1,!n&&!this.eo&&!this.Pn&&!this.Qu&&!this._u)return!0;let y=this.documentBounds,b=0,v=0,w=0,k=0,S=l.width,N=l.height,D=this.ch;this.contentAlignment.isSpot()?(y.width>S&&(b=D.left,v=D.right),y.height>N&&(w=D.top,k=D.bottom)):(b=D.left,v=D.right,w=D.top,k=D.bottom);let L=y.width+b+v,M=y.height+w+k,A=this.scale,F=A,O=L>a/A,E=M>h/A;if(!n&&!this.eo&&!this.Pn&&!O&&!E)return!0;let B=y.x-b,X=l.x,z=y.right+v,U=l.right+o,tt=y.y-w,st=l.y,Z=y.bottom+k,et=l.bottom+r,Q="1px",rt="1px";if(this.scrollMode===1&&(O||E)){if(O&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let _=1;B+1<X&&(_=Math.max((X-B)*A+this.wt,_)),z>U+1&&(_=Math.max((z-U)*A+this.wt,_)),S+o+1<L&&(_=Math.max((L-S)*A+this.wt,_)),Q=_.toString()+"px"}if(E&&this.hasVerticalScrollbar&&this.allowVerticalScroll){let _=1;tt+1<st&&(_=Math.max((st-tt)*A+this.xt,_)),Z>et+1&&(_=Math.max((Z-et)*A+this.xt,_)),N+r+1<M&&(_=Math.max((M-N)*A+this.xt,_)),rt=_.toString()+"px"}}let ft=Q!=="1px",xt=rt!=="1px";if(!(ft&&xt)&&(ft||xt)){if(O=!(L<S+o),E=!(M<N+r),xt&&(U-=this.jt),ft&&(et-=this.jt),O&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let St=1;B+1<X&&(St=Math.max((X-B)*A+this.wt,St)),z>U+1&&(St=Math.max((z-U)*A+this.wt,St)),S+1<L&&(St=Math.max((L-S)*A+this.wt,St)),Q=St.toString()+"px"}ft=Q!=="1px";let _=this.xt;if(ft!==this.Pn&&(_=ft?this.xt-this.jt:this.xt+this.jt),E&&this.hasVerticalScrollbar&&this.allowVerticalScroll){let St=1;tt+1<st&&(St=Math.max((st-tt)*A+_,St)),Z>et+1&&(St=Math.max((Z-et)*A+_,St)),N+1<M&&(St=Math.max((M-N)*A+_,St)),rt=St.toString()+"px"}xt=rt!=="1px"}if(this.ip&&!(ft!==this.Pn||xt!==this.eo))return(e!==this.wt||i!==this.xt)&&this.maybeUpdate(),!1;if(ft!==this.Pn&&(Q==="1px"?this.xt=this.xt+this.jt:this.xt=Math.max(this.xt-this.jt,1),n=!0),this.Pn=ft,g.style.width=Q,xt!==this.eo&&(rt==="1px"?this.wt=this.wt+this.jt:this.wt=Math.max(this.wt-this.jt,1),n=!0,this.rd)){let _=P.l();xt?(t.style.left=this.jt+"px",this.position=_.e(this.ct.x+this.jt/this.scale,this.ct.y)):(t.style.left="0px",this.position=_.e(this.ct.x-this.jt/this.scale,this.ct.y)),P.i(_)}n&&this.ca(),this.eo=xt,g.style.height=rt,this.Eb=!0,n&&(this.$u=!0);let Ct=p.scrollLeft;if(this.hasHorizontalScrollbar&&this.allowHorizontalScroll&&(S+1<L?Ct=(this.position.x-B)*A:B+1<X?Ct=p.scrollWidth-p.clientWidth:z>U+1&&(Ct=this.position.x*A)),this.rd)switch(this.nb){case"negative":Ct=-(p.scrollWidth-Ct-p.clientWidth);break;case"reverse":Ct=p.scrollWidth-Ct-p.clientWidth;break}if(p.scrollLeft=Ct,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(N+1<M?p.scrollTop=(this.position.y-tt)*A:tt+1<st?p.scrollTop=p.scrollHeight-p.clientHeight:Z>et+1&&(p.scrollTop=this.position.y*A)),a=this.wt,h=this.xt,p.style.width=a+(this.eo?this.jt:0)+"px",p.style.height=h+(this.Pn?this.jt:0)+"px",e!==a||i!==h||this.animationManager.Pe){let _=I.z(u,c,d,f);return this.onViewportBoundsChanged(_,this.viewportBounds,F,n),I.i(_),!1}return!0}add(t){let e=t.diagram;if(e===this)return;e!==null&&m.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+e.toString());let i=this.findLayer(t.layerName);if(i===null&&(i=this.findLayer("")),i===null&&m.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===i)return;let s=i.hh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",i,null,t,null,s),i.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);let n=t.layerChanged;n!==null&&n(t,null,i)}hh(t){this.partManager.hh(t);let e=this;Y.isUsingDOM()&&t.Sn(i=>e.uT(i)),t.data||t.Go(),t.hasPlaceholder()&&t.f(),t.data!==null&&t.Sn(i=>e.partManager.M2(i,null)),(t.as()===!0||t.fa()===!0)&&this.Pp(t),t.dT(!0,this),t instanceof $&&t.canAvoid()&&this.ud(t),t.gT()?(t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.yp!==null&&this.yp(this,t),this.requestUpdate()}ri(t){t.clearAdornments(),this.partManager.ri(t);let e=this;t.data!==null&&t.Sn(i=>e.partManager.C2(i,e)),this._n.delete(t),t instanceof j?this.Or.delete(t):t instanceof $&&t.canAvoid()&&this.ud(t),t.gT()?(t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.wp!==null&&this.wp(this,t),this.requestUpdate()}remove(t){this.N2(t,!0)}N2(t,e){let i=t.layer;if(i===null||i.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),e&&t.af();let s=i.ri(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",i,t,null,s,null);let n=t.layerChanged;n!==null&&n(t,i,null)}removeParts(t,e){if(e===void 0&&(e=!1),Array.isArray(t)){let i=t.length;for(let s=0;s<i;s++){let n=t[s];e&&!n.canDelete()||this.remove(n)}}else{let i=new V;i.addAll(t);let s=i.iterator;for(;s.next();){let n=s.value;e&&!n.canDelete()||this.remove(n)}}}copyParts(t,e,i){return i===void 0&&(i=!1),this.partManager.copyParts(t,e,i)}moveParts(t,e,i,s){if(i===void 0&&(i=!1),s===void 0&&(s=this.Cp()),this.toolManager===null)return;let n=new Mt;if(t!==null)if(Array.isArray(t))for(let o=0;o<t.length;o++)this.tl(n,t[o],i,s);else{let o=t.iterator;for(;o.next();)this.tl(n,o.value,i,s)}else{let o=this.parts;for(;o.next();){let r=o.value;this.tl(n,r,i,s)}for(o=this.nodes;o.next();){let r=o.value;this.tl(n,r,i,s)}for(o=this.links;o.next();){let r=o.value;this.tl(n,r,i,s)}}this.Sx(n,e,s,i)}tl(t,e,i,s,n){if(!t.has(e)&&(n===void 0&&(n=!1),!(i&&!n&&!e.canMove()&&!e.canCopy())))if(s===void 0&&(s=this.Cp()),e instanceof $){if(t.set(e,this.Ws(s,e,e.location)),e instanceof ht&&(e.hasPlaceholder()||s.dragsMembers)){let r=e.memberParts;for(;r.next();){let a=r.value;this.tl(t,a,i,s,s.groupsAlwaysMove)}}let o=e.linksConnected;for(;o.next();){let r=o.value;if(t.has(r))continue;let a=r.fromNode,h=r.toNode;a!==null&&t.has(a)&&h!==null&&t.has(h)&&this.tl(t,r,i,s)}if(s.dragsTree){let r=e.findTreeChildrenNodes();for(;r.next();){let a=r.value;this.tl(t,a,i,s)}}}else if(e instanceof j){t.set(e,this.Ws(s,e));let o=e.labelNodes;for(;o.next();){let r=o.value;this.tl(t,r,i,s)}}else e instanceof vt||t.set(e,this.Ws(s,e,e.location))}Sx(t,e,i,s){if(t===null||t.count===0)return;let n=P.l(),o=P.l();o.h(e),isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0);let r=this.Jb;r||this.uA(t);let a=m.st(),h=m.st(),l=t.iterator,u=P.l();for(;l.next();){let g=l.key,y=l.value;if(g.Di()){let b=this.mT(g,t);if(b!==null)a.push(new On(g,y,b));else if(!s||g.canMove()){let v=y.point;n.h(v),this.computeMove(g,n.add(o),i,u),g.location=u,y.shifted===void 0&&(y.shifted=new P),y.shifted.h(u.subtract(v))}}else l.key instanceof j&&h.push(new ye(l.key,l.value))}P.i(u);let c=a.length;for(let g=0;g<c;g++){let y=a[g],b=y.pT.point;n.h(b),y.s1.shifted===void 0&&(y.s1.shifted=new P),y.Ri.location=n.add(y.s1.shifted)}let d=P.l(),f=P.l(),p=h.length;for(let g=0;g<p;g++){let y=h[g],b=y.key;if(b instanceof j){if(b.suspendsRouting){b.Dr=null;let v=b.fromNode,w=b.toNode;if(this.draggedLink!==null&&i.dragsLink){let k=y.value.point;if(b.dragComputation===null){t.set(b,this.Ws(i,b,o));let S=o.x-k.x,N=o.y-k.y;b.kr(S,N)}else{let S=P.z(0,0),N=b.getPoint(0);N&&N.isReal()&&S.h(N),u=P.l().h(S).add(o);let D=u;i.isGridSnapEnabled&&(i.isGridSnapRealtime||this.lastInput.up)&&(D=P.l(),this.oM(b,u,D,i)),u.h(b.dragComputation(b,u,D)).subtract(S),t.set(b,this.Ws(i,b,u));let L=u.x-k.x,M=u.y-k.y;b.kr(L,M),P.i(S),P.i(u),D!==u&&P.i(D)}}else{if(v!==null){d.h(v.location);let k=t.get(v);k!==null&&d.subtract(k.point)}if(w!==null){f.h(w.location);let k=t.get(w);k!==null&&f.subtract(k.point)}if(v!==null&&w!==null){let k=y.value.point;if(d.equalsApprox(f)||b.computeAdjusting()!==0){let S=n;S.h(d),S.subtract(k),t.set(b,this.Ws(i,b,d)),b.kr(S.x,S.y)}else b.suspendsRouting=!1,b.$t()}else{let k=y.value.point,S;v!==null?S=d:w!==null?S=f:S=o,t.set(b,this.Ws(i,b,S));let N=S.x-k.x,D=S.y-k.y;b.kr(N,D)}}}else if(b.fromNode===null||b.toNode===null){let v=y.value.point;t.set(b,this.Ws(i,b,o));let w=o.x-v.x,k=o.y-v.y;b.kr(w,k)}}}P.i(n),P.i(o),P.i(d),P.i(f),m.Z(a),m.Z(h),r||(this.De(),this.dS(t))}computeMove(t,e,i,s){if(s===void 0&&(s=new P),s.h(e),t===null)return s;let n=e,o=i.isGridSnapEnabled;o&&(i.isGridSnapRealtime||this.lastInput.up)&&(n=P.l(),this.oM(t,e,n,i));let r=t.dragComputation!==null?t.dragComputation(t,e,n):n,a=t.minLocation,h=a.x;isNaN(h)&&(h=o?Math.round(t.location.x*1e3)/1e3:t.location.x);let l=a.y;isNaN(l)&&(l=o?Math.round(t.location.y*1e3)/1e3:t.location.y);let u=t.maxLocation,c=u.x;isNaN(c)&&(c=o?Math.round(t.location.x*1e3)/1e3:t.location.x);let d=u.y;return isNaN(d)&&(d=o?Math.round(t.location.y*1e3)/1e3:t.location.y),s.e(Math.max(h,Math.min(r.x,c)),Math.max(l,Math.min(r.y,d))),n!==e&&P.i(n),s}Cp(){let t=this.toolManager.findTool("Dragging");return t instanceof Tt?t.dragOptions:this.ld}oM(t,e,i,s){if(s===void 0&&(s=this.Cp()),i.h(e),t===null)return i;let n=this.grid,o=s.gridSnapCellSize,r=o.width,a=o.height,h=s.gridSnapOrigin,l=h.x,u=h.y,c=s.gridSnapCellSpot;if(n!==null){let f=n.gridCellSize;isNaN(r)&&(r=f.width),isNaN(a)&&(a=f.height);let p=n.gridOrigin;isNaN(l)&&(l=p.x),isNaN(u)&&(u=p.y)}let d=P.z(0,0);return d.setSpot(0,0,r,a,c),C._g(e.x,e.y,l+d.x,u+d.y,r,a,i),P.i(d),i}uA(t){if(t===null)return;this.Jb=!0;let e=t.iterator;for(;e.next();){let i=e.key;i instanceof j&&(i.suspendsRouting=!0)}}dS(t){if(t===null)return;let e=t.iterator;for(;e.next();){let i=e.key;i instanceof j&&(i.suspendsRouting=!1,i.yT()&&i.$t())}this.Jb=!1}get draggedLink(){return this.$b}set draggedLink(t){this.$b!==t&&(this.$b=t,t!==null&&(this.Zb=t.fromPort,this.Qb=t.toPort))}get xS(){return this.Zb}set xS(t){this.Zb=t}get bS(){return this.Qb}set bS(t){this.Qb=t}mT(t,e){let i=t.containingGroup;if(i!==null){let s=this.mT(i,e);if(s!==null||(s=e.get(i),s!==null))return s}return null}Ws(t,e,i){if(i===void 0)return new Xe(P.gn);let s=t.isGridSnapEnabled;return!t.groupsSnapMembers&&e.containingGroup!==null&&(s=!1),s?new Xe(new P(Math.round(i.x*1e3)/1e3,Math.round(i.y*1e3)/1e3)):new Xe(i.copy())}L2(t,e){if(t.diagram!==null&&t.diagram!==this&&m.o("Cannot share a Layer with another Diagram: "+t+" of "+t.diagram),e===null?t.diagram!==null&&m.o("Cannot add an existing Layer to this Diagram again: "+t):(e.diagram!==this&&m.o("Existing Layer must be in this Diagram: "+e+" not in "+e.diagram),t===e&&m.o("Cannot move a Layer before or after itself: "+t)),t.diagram===this)return;let i=t.name,s=this.Vt,n=s.count;for(let o=0;o<n;o++)s.elt(o).name===i&&m.o("Cannot add Layer with the name '"+i+"'; a Layer with the same name is already present in this Diagram.")}addLayer(t){this.L2(t,null),t.Io(this);let e=this.Vt,i=e.count-1;if(!t.isTemporary)for(;i>=0&&e.elt(i).isTemporary;)i--;return e.insertAt(i+1,t),this.Le!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,i+1),this.N(),this.invalidateDocumentBounds(),this}addLayerBefore(t,e){this.L2(t,e),t.Io(this);let i=this.Vt,s=i.indexOf(t);s>=0&&(i.delete(t),this.Le!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));let n=i.count,o;for(o=0;o<n;o++)if(i.elt(o)===e){i.insertAt(o,t);break}return this.Le!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,o),this.N(),s<0&&this.invalidateDocumentBounds(),this}addLayerAfter(t,e){this.L2(t,e),t.Io(this);let i=this.Vt,s=i.indexOf(t);s>=0&&(i.delete(t),this.Le!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));let n=i.count,o;for(o=0;o<n;o++)if(i.elt(o)===e){i.insertAt(o+1,t);break}return this.Le!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,o+1),this.N(),s<0&&this.invalidateDocumentBounds(),this}Zr(t,e){t.Io(this),this.Vt.insertAt(e,t)}wT(t){this.Vt.removeAt(t)}removeLayer(t){if(t.diagram!==this&&m.o("Cannot remove a Layer from another Diagram: "+t+" of "+t.diagram),t.name==="")return;let e=this.Vt,i=e.indexOf(t);if(e.delete(t)){let s=t.Ct.copy().iterator;for(;s.next();){let n=s.value,o=n.layerName;o!==t.name?n.layerName=o:n.layerName=""}this.Le!==null&&this.raiseChangedEvent(4,"layers",this,t,null,i,null),this.N(),this.invalidateDocumentBounds()}}findLayer(t){let e=this.layers;for(;e.next();){let i=e.value;if(i.name===t)return i}return null}findRouter(t){for(let e of this.rf)if(e.name===t)return e;return null}addModelChangedListener(t){return m.S(t,Y,"addModelChangedListener:listener"),this.to===null&&(this.to=new q),this.to.add(t),this.model&&this.model.addChangedListener(t),this}removeModelChangedListener(t){m.S(t,Y,"removeModelChangedListener:listener"),this.to!==null&&(this.to.delete(t),this.to.count===0&&(this.to=null)),this.model.removeChangedListener(t)}addChangedListener(t){return m.S(t,Y,"addChangedListener:listener"),this.Ir===null&&(this.Ir=new q),this.Ir.add(t),this}removeChangedListener(t){m.S(t,Y,"removeChangedListener:listener"),this.Ir!==null&&(this.Ir.delete(t),this.Ir.count===0&&(this.Ir=null))}A2(t){if(!this.skipsUndoManager&&!this.model.skipsUndoManager&&this.model.undoManager.handleChanged(t),t.change!==1&&(this.isModified=!0),this.Ir!==null){let e=this.Ir,i=e.length;for(let s=0;s<i;s++)e.elt(s)(t)}}raiseChangedEvent(t,e,i,s,n,o,r){o===void 0&&(o=null),r===void 0&&(r=null);let a=new ze;a.diagram=this,a.change=t,a.propertyName=e,a.object=i,a.oldValue=s,a.oldParam=o,a.newValue=n,a.newParam=r,this.A2(a)}raiseChanged(t,e,i,s,n){this.raiseChangedEvent(2,t,this,e,i,s,n)}t(t,e,i,s,n){this.raiseChangedEvent(2,t,this,e,i,s,n)}get partAdded(){return this.yp}set partAdded(t){this.partAdded!==t&&(this.yp=t)}get partRemoved(){return this.wp}set partRemoved(t){this.partRemoved!==t&&(this.wp=t)}get animationManager(){return this.Cs}get undoManager(){return this.Le.undoManager}get skipsUndoManager(){return this.Vo}set skipsUndoManager(t){m.s(t,"boolean",Y,"skipsUndoManager"),this.Vo=t,this.Le.skipsUndoManager=t}get delaysLayout(){return this.Cb}set delaysLayout(t){this.Cb=t}tA(t,e){if(t===null||t.diagram!==this)return;let i=this.wi;try{this.wi=!0;let s=t.change;if(s===2){let n=t.object,o=t.propertyName,r=t.getValue(e);if(t.diagram.model.nt(n,o,r),n instanceof J){let a=n.part;a!==null&&(a.invalidateAdornments(),a instanceof j&&(a.fromNode?.Ze(a.fromPort),a.toNode?.Ze(a.toPort)))}this.isModified=!0}else if(s===3){let n=t.object,o=t.newParam,r=t.newValue;if(n instanceof G)if(typeof o=="number"&&r instanceof J){e?n.ri(o):n.insertAt(o,r);let a=n.part;a!==null&&a.invalidateAdornments()}else typeof o=="number"&&r instanceof Kt&&(r.isRow?n.xT(o,e?void 0:r):n.bT(o,e?void 0:r));else if(n instanceof Et){let a=t.oldParam===!0;typeof o=="number"&&r instanceof pt&&(e?(a||(r.isSelected=!1,r.isHighlighted=!1,r.invalidateAdornments()),n.ri(a?o:-1,r,a)):n.hh(o,r,a))}else n instanceof Y?typeof o=="number"&&r instanceof Et&&(e?this.wT(o):this.Zr(r,o)):m.o("unknown ChangeType.Insert object: "+t.toString());this.isModified=!0}else if(s===4){let n=t.object,o=t.oldParam,r=t.oldValue;if(n instanceof G)typeof o=="number"&&r instanceof J?e?n.insertAt(o,r):n.ri(o):typeof o=="number"&&r instanceof Kt&&(r.isRow?n.xT(o,e?r:void 0):n.bT(o,e?r:void 0));else if(n instanceof Et){let a=t.newParam===!0;typeof o=="number"&&r instanceof pt&&(e?n.Ct.indexOf(r)<0&&n.hh(o,r,a):(a||(r.isSelected=!1,r.isHighlighted=!1,r.invalidateAdornments()),n.ri(a?o:-1,r,a)))}else n instanceof Y?typeof o=="number"&&r instanceof Et&&(e?this.Zr(r,o):this.wT(o)):m.o("unknown ChangeType.Remove object: "+t.toString());this.isModified=!0}else s===1||m.o("unknown ChangedEvent: "+t.toString())}finally{this.wi=i}}startTransaction(t){return this.undoManager.startTransaction(t)}commitTransaction(t){return this.undoManager.commitTransaction(t)}rollbackTransaction(){return this.undoManager.rollbackTransaction()}commit(t,e){let i=e;i===void 0&&(i="");let s=this.skipsUndoManager;i===null&&(this.skipsUndoManager=!0,i=""),this.undoManager.startTransaction(i);let n=!1;try{t(this),n=!0}finally{n?this.undoManager.commitTransaction(i):this.undoManager.rollbackTransaction(),this.skipsUndoManager=s}}updateAllTargetBindings(t){this.partManager.updateAllTargetBindings(t)}updateAllThemeBindings(){if(this.partManager.updateAllThemeBindings(),this.ls!==null){let t=this.ls.part;t!==null&&t.Go()}}setDivBackground(t){this.div&&(this.div.style.backgroundColor=t)}updateAllRelationshipsFromData(){this.partManager.updateAllRelationshipsFromData()}kp(){let t=this.v,e=this.et,i=this.ct;t.Ue(),e!==1&&t.et(e),(i.x!==0||i.y!==0)&&t.Gs(-i.x,-i.y)}kT(t,e){let i=this.animationManager;if(this.Ht||this.As){this.et=e,this.ca(),this.N(),this.Mh(),i.EA(t,this.et),this.kp();return}if(this.lt===null){this.et=e,this.kp();return}this.Ht=!0;let s=this.viewportBounds.copy(),n=this.wt,o=this.xt,r=this.zoomPoint.x,a=this.zoomPoint.y,h=this.contentAlignment;isNaN(r)&&(h.isSide()?h.includesSide(T.LeftSide)?r=0:h.includesSide(T.RightSide)&&(r=n-1):h.isSpot()?r=h.x*(n-1):r=n/2),isNaN(a)&&(h.isSide()?h.includesSide(T.TopSide)?a=0:h.includesSide(T.BottomSide)&&(a=o-1):h.isSpot()?a=h.y*(o-1):a=o/2),this.scaleComputation!==null&&!this.animationManager.defaultAnimation.isAnimating&&(e=this.scaleComputation(this,e)),e<this.minScale&&(e=this.minScale),e>this.maxScale&&(e=this.maxScale);let l=P.z(this.ct.x+r/t-r/e,this.ct.y+a/t-a/e);this.position=l,P.i(l),this.et=e,this.kp(),this.ca(),this.Ht=!1,this.onViewportBoundsChanged(s,this.viewportBounds,t,!1),this.$s(!1),i.EA(t,this.et),this.N()}yO(){let t=this.Vt.r;for(let e=0;e<t.length;e++)t[e].YA()}onViewportBoundsChanged(t,e,i,s){if(t.equals(e))return;s===void 0&&(s=!1),s||this.Mh(),this.Qr();let n=this.layout;n!==null&&n.isViewportSized&&this.autoScale===1&&(t.width!==e.width||t.height!==e.height)&&n.p();let o=this.currentTool;this.nf===!0&&o instanceof oe&&!this.animationManager.isTicking&&(this.lastInput.documentPoint=this.transformViewToDoc(this.lastInput.viewPoint),o.cA(this)),this.Ht||this.invalidateViewport(t,e),this.cd();let r=this.Vt.r;this.rs(r,r.length,this,this.viewportBounds),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.canvasSize.width=Math.round(t.width*i),this.Ye.canvasSize.height=Math.round(t.height*i),this.Ye.newCanvasSize.width=this.wt,this.Ye.newCanvasSize.height=this.xt,this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t),this.isVirtualized&&this.links.each(a=>{a.isAvoiding&&a.actualBounds.intersectsRect(e)&&a.$t()})}cd(){this._c=!1,this.N()}P2(t){let e=this.ls;if(e===null||!e.visible)return;let i=e.part;if(i===null||i.layer===null)return;let s=t!==void 0?t:this.zb;if(!s.isReal())return;let n=s.width,o=s.height;if(e.scale=1,e.angle=0,i.layer.isViewportAligned)e.width=n*this.scale,e.height=o*this.scale,i.alignment=T.TopLeft;else{e.Se===null&&(e.Se=new ti);let r=e.Se.hf;if(!r.isReal())return;e.width=n+r.width*2,e.height=o+r.height*2,this.Qr();let a=P.l();C._g(s.x,s.y,0,0,r.width,r.height,a),a.offset(-r.width,-r.height),i.location=a,P.i(a)}}clearSelection(t){t===void 0&&(t=!1);let e=this.selection;if(e.count===0)return;t||this.T("ChangingSelection",e);let i=e.toArray(),s=i.length;for(let n=0;n<s;n++){let o=i[n];o.isSelected=!1}e.ce(),e.clear(),e.k(),t||this.T("ChangedSelection",e)}select(t){t!==null&&t.diagram===this&&(!t.isSelected||this.selection.count>1)&&(this.T("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.T("ChangedSelection",this.selection))}selectCollection(t){if(this.T("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++){let s=t[i];s instanceof pt||m.o("Diagram.selectCollection given something that is not a Part: "+s),s.isSelected=!0}}else{let e=t.iterator;for(;e.next();){let i=e.value;i instanceof pt||m.o("Diagram.selectCollection given something that is not a Part: "+i),i.isSelected=!0}}this.T("ChangedSelection",this.selection)}clearHighlighteds(){let t=this.highlighteds;if(t.count>0){let e=t.toArray(),i=e.length;for(let s=0;s<i;s++){let n=e[s];n.isHighlighted=!1}t.ce(),t.clear(),t.k()}}highlight(t){t!==null&&t.diagram===this&&(!t.isHighlighted||this.highlighteds.count>1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){let e=new V().addAll(t),i=this.highlighteds.copy().removeAll(e).iterator;for(;i.next();){let n=i.value;n.isHighlighted=!1}let s=e.iterator;for(;s.next();){let n=s.value;n instanceof pt||m.o("Diagram.highlightCollection given something that is not a Part: "+n),n.isHighlighted=!0}}scroll(t,e,i){i===void 0&&(i=1);let s=e==="up"||e==="down",n=0,o=P.l();if(t==="pixel")n=i;else if(t==="line")n=i*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let a=s?this.viewportBounds.height:this.viewportBounds.width;if(a*=this.scale,a!==0){let h=Math.max(a-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=i*h}}else if(t==="document"){let a=this.documentBounds,h=this.viewportBounds;e==="up"?this.position=o.e(h.x,a.y):e==="left"?this.position=o.e(a.x,h.y):e==="down"?this.position=o.e(h.x,a.bottom-h.height):e==="right"&&(this.position=o.e(a.right-h.width,h.y)),P.i(o);return}else m.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;let r=this.position;e==="up"?this.position=o.e(r.x,r.y-n):e==="down"?this.position=o.e(r.x,r.y+n):e==="left"?this.position=o.e(r.x-n,r.y):e==="right"?this.position=o.e(r.x+n,r.y):m.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+e),P.i(o)}scrollToRect(t){let e=this.viewportBounds;if(e.containsRect(t))return;let i=t.center;i.x-=e.width/2,i.y-=e.height/2,this.position=i}centerRect(t){let e=this.viewportBounds,i=t.center;i.x-=e.width/2,i.y-=e.height/2,this.position=i}transformDocToView(t){return t.copy().v(this.v)}transformViewToDoc(t){return t.copy().Hi(this.v)}YR(t){return t.Hi(this.v)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Zt}set opacity(t){let e=this.Zt;e!==t&&(m.s(t,"number",Y,"opacity"),(t<0||t>1)&&m.J(t,"0 <= value <= 1",Y,"opacity"),this.Zt=t,this.t("opacity",e,t),this.N())}get validCycle(){return this.xb}set validCycle(t){let e=this.xb;e!==t&&(this.xb=t,this.t("validCycle",e,t))}get layers(){return this.Vt.iterator}get isModelReadOnly(){let t=this.Le;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){let e=this.Le;e!==null&&(e.isReadOnly=t)}get isReadOnly(){return this.Bo}set isReadOnly(t){let e=this.Bo;e!==t&&(m.s(t,"boolean",Y,"isReadOnly"),this.Bo=t,this.t("isReadOnly",e,t))}get isEnabled(){return this.Be}set isEnabled(t){let e=this.Be;e!==t&&(m.s(t,"boolean",Y,"isEnabled"),this.Be=t,this.t("isEnabled",e,t))}get allowClipboard(){return this.Nb}set allowClipboard(t){let e=this.Nb;e!==t&&(m.s(t,"boolean",Y,"allowClipboard"),this.Nb=t,this.t("allowClipboard",e,t))}get allowCopy(){return this.Hl}set allowCopy(t){let e=this.Hl;e!==t&&(m.s(t,"boolean",Y,"allowCopy"),this.Hl=t,this.t("allowCopy",e,t))}get allowDelete(){return this.ql}set allowDelete(t){let e=this.ql;e!==t&&(m.s(t,"boolean",Y,"allowDelete"),this.ql=t,this.t("allowDelete",e,t))}get allowDragOut(){return this.Lb}set allowDragOut(t){let e=this.Lb;e!==t&&(m.s(t,"boolean",Y,"allowDragOut"),this.Lb=t,this.t("allowDragOut",e,t))}get allowDrop(){return this.Ab}set allowDrop(t){let e=this.Ab;e!==t&&(m.s(t,"boolean",Y,"allowDrop"),this.Ab=t,this.t("allowDrop",e,t))}get allowTextEdit(){return this.jl}set allowTextEdit(t){let e=this.jl;e!==t&&(m.s(t,"boolean",Y,"allowTextEdit"),this.jl=t,this.t("allowTextEdit",e,t))}get allowGroup(){return this.Wl}set allowGroup(t){let e=this.Wl;e!==t&&(m.s(t,"boolean",Y,"allowGroup"),this.Wl=t,this.t("allowGroup",e,t))}get allowUngroup(){return this.Jl}set allowUngroup(t){let e=this.Jl;e!==t&&(m.s(t,"boolean",Y,"allowUngroup"),this.Jl=t,this.t("allowUngroup",e,t))}get allowInsert(){return this.Tb}set allowInsert(t){let e=this.Tb;e!==t&&(m.s(t,"boolean",Y,"allowInsert"),this.Tb=t,this.t("allowInsert",e,t))}get allowLink(){return this.$l}set allowLink(t){let e=this.$l;e!==t&&(m.s(t,"boolean",Y,"allowLink"),this.$l=t,this.t("allowLink",e,t))}get allowRelink(){return this.Zl}set allowRelink(t){let e=this.Zl;e!==t&&(m.s(t,"boolean",Y,"allowRelink"),this.Zl=t,this.t("allowRelink",e,t))}get allowMove(){return this.Ql}set allowMove(t){let e=this.Ql;e!==t&&(m.s(t,"boolean",Y,"allowMove"),this.Ql=t,this.t("allowMove",e,t))}get allowReshape(){return this._l}set allowReshape(t){let e=this._l;e!==t&&(m.s(t,"boolean",Y,"allowReshape"),this._l=t,this.t("allowReshape",e,t))}get allowResize(){return this.ta}set allowResize(t){let e=this.ta;e!==t&&(m.s(t,"boolean",Y,"allowResize"),this.ta=t,this.t("allowResize",e,t))}get allowRotate(){return this.ea}set allowRotate(t){let e=this.ea;e!==t&&(m.s(t,"boolean",Y,"allowRotate"),this.ea=t,this.t("allowRotate",e,t))}get allowSelect(){return this.ia}set allowSelect(t){let e=this.ia;e!==t&&(m.s(t,"boolean",Y,"allowSelect"),this.ia=t,this.t("allowSelect",e,t))}get allowUndo(){return this.Db}set allowUndo(t){let e=this.Db;e!==t&&(m.s(t,"boolean",Y,"allowUndo"),this.Db=t,this.t("allowUndo",e,t))}get allowZoom(){return this.vb}set allowZoom(t){let e=this.vb;e!==t&&(m.s(t,"boolean",Y,"allowZoom"),this.vb=t,this.t("allowZoom",e,t))}get hasVerticalScrollbar(){return this._u}set hasVerticalScrollbar(t){let e=this._u;e!==t&&(m.s(t,"boolean",Y,"hasVerticalScrollbar"),this._u=t,this.Mh(),this.N(),this.t("hasVerticalScrollbar",e,t),this.$s(!1))}get hasHorizontalScrollbar(){return this.Qu}set hasHorizontalScrollbar(t){let e=this.Qu;e!==t&&(m.s(t,"boolean",Y,"hasHorizontalScrollbar"),this.Qu=t,this.Mh(),this.N(),this.t("hasHorizontalScrollbar",e,t),this.$s(!1))}get allowHorizontalScroll(){return this.Fb}set allowHorizontalScroll(t){let e=this.Fb;e!==t&&(m.s(t,"boolean",Y,"allowHorizontalScroll"),this.Fb=t,this.t("allowHorizontalScroll",e,t),this.$s(!1))}get allowVerticalScroll(){return this.Rb}set allowVerticalScroll(t){let e=this.Rb;e!==t&&(m.s(t,"boolean",Y,"allowVerticalScroll"),this.Rb=t,this.t("allowVerticalScroll",e,t),this.$s(!1))}get scrollHorizontalLineChange(){return this.Ob}set scrollHorizontalLineChange(t){let e=this.Ob;e!==t&&(m.s(t,"number",Y,"scrollHorizontalLineChange"),t<0&&m.J(t,">= 0",Y,"scrollHorizontalLineChange"),this.Ob=t,this.t("scrollHorizontalLineChange",e,t))}get scrollVerticalLineChange(){return this.Ib}set scrollVerticalLineChange(t){let e=this.Ib;e!==t&&(m.s(t,"number",Y,"scrollVerticalLineChange"),t<0&&m.J(t,">= 0",Y,"scrollVerticalLineChange"),this.Ib=t,this.t("scrollVerticalLineChange",e,t))}get lastInput(){return this.dh}set lastInput(t){this.dh=t}get previousInput(){return this.Wr}set previousInput(t){this.Wr=t}get firstInput(){return this.lp}set firstInput(t){this.lp=t}get currentCursor(){return this.bb}set currentCursor(t){if(t===""&&(t=this.ep),this.bb!==t){m.s(t,"string",Y,"currentCursor");let e=this.lt,i=this.Mt;if(e===null||i===null)return;this.bb=t;let s=e.style.cursor;e.style.cursor=t,i.style.cursor=t,e.style.cursor===s&&(e.style.cursor="-webkit-"+t,i.style.cursor="-webkit-"+t,e.style.cursor===s&&(e.style.cursor="-moz-"+t,i.style.cursor="-moz-"+t,e.style.cursor===s&&(e.style.cursor=t,i.style.cursor=t)))}}get defaultCursor(){return this.ep}set defaultCursor(t){t===""&&(t="auto");let e=this.ep;e!==t&&(m.s(t,"string",Y,"defaultCursor"),this.ep=t,this.t("defaultCursor",e,t))}get click(){return this.Er}set click(t){let e=this.Er;e!==t&&(t!==null&&m.S(t,Y,"click"),this.Er=t,this.t("click",e,t))}get doubleClick(){return this.Ur}set doubleClick(t){let e=this.Ur;e!==t&&(t!==null&&m.S(t,Y,"doubleClick"),this.Ur=t,this.t("doubleClick",e,t))}get contextClick(){return this.Vr}set contextClick(t){let e=this.Vr;e!==t&&(t!==null&&m.S(t,Y,"contextClick"),this.Vr=t,this.t("contextClick",e,t))}get mouseOver(){return this.Br}set mouseOver(t){let e=this.Br;e!==t&&(t!==null&&m.S(t,Y,"mouseOver"),this.Br=t,this.t("mouseOver",e,t))}get mouseHover(){return this.zr}set mouseHover(t){let e=this.zr;e!==t&&(t!==null&&m.S(t,Y,"mouseHover"),this.zr=t,this.t("mouseHover",e,t))}get mouseHold(){return this.Xr}set mouseHold(t){let e=this.Xr;e!==t&&(t!==null&&m.S(t,Y,"mouseHold"),this.Xr=t,this.t("mouseHold",e,t))}get mouseDragOver(){return this.kb}set mouseDragOver(t){let e=this.kb;e!==t&&(t!==null&&m.S(t,Y,"mouseDragOver"),this.kb=t,this.t("mouseDragOver",e,t))}get mouseDrop(){return this.Gr}set mouseDrop(t){let e=this.Gr;e!==t&&(this.Gr=t,this.t("mouseDrop",e,t))}get handlesDragDropForTopLevelParts(){return this.Pb}set handlesDragDropForTopLevelParts(t){let e=this.Pb;e!==t&&(m.s(t,"boolean",Y,"handlesDragDropForTopLevelParts"),this.Pb=t,this.t("handlesDragDropForTopLevelParts",e,t))}get mouseEnter(){return this.Yr}set mouseEnter(t){let e=this.Yr;e!==t&&(t!==null&&m.S(t,Y,"mouseEnter"),this.Yr=t,this.t("mouseEnter",e,t))}get mouseLeave(){return this.Kr}set mouseLeave(t){let e=this.Kr;e!==t&&(t!==null&&m.S(t,Y,"mouseLeave"),this.Kr=t,this.t("mouseLeave",e,t))}get toolTip(){return this.Hr}set toolTip(t){let e=this.Hr;e!==t&&(this.Hr=t,this.t("toolTip",e,t))}get contextMenu(){return this.qr}set contextMenu(t){let e=this.qr;e!==t&&(this.qr=t,this.t("contextMenu",e,t))}get commandHandler(){return this.KM}set commandHandler(t){let e=this.KM;e!==t&&(e&&e.doStop(),this.KM=t,t.Io(this),t.doStart())}get toolManager(){return this.XM}set toolManager(t){this.XM!==t&&(this.XM=t,t.diagram=this)}get defaultTool(){return this.GM}set defaultTool(t){let e=this.GM;e!==t&&(this.GM=t,t.diagram=this,this.currentTool===e&&(this.currentTool=t))}get currentTool(){return this.YM}set currentTool(t){let e=this.YM;e&&(e.isActive&&e.doDeactivate(),e.cancelWaitAfter(),e.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.YM=t,t.diagram=this,t.doStart())}get selection(){return this.KA}get maxSelectionCount(){return this.Bb}set maxSelectionCount(t){let e=this.Bb;if(e!==t)if(m.s(t,"number",Y,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Bb=t,this.t("maxSelectionCount",e,t),!this.undoManager.isUndoingRedoing){let i=this.selection.count-t;if(i>0){this.T("ChangingSelection",this.selection);let s=this.selection.toArray();for(let n=0;n<i;n++)s[n].isSelected=!1;this.T("ChangedSelection",this.selection)}}}else m.J(t,">= 0",Y,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.op}set nodeSelectionAdornmentTemplate(t){let e=this.op;e!==t&&(this.op=t.It(),this.t("nodeSelectionAdornmentTemplate",e,t))}get groupSelectionAdornmentTemplate(){return this.Gb}set groupSelectionAdornmentTemplate(t){let e=this.Gb;e!==t&&(this.Gb=t.It(),this.t("groupSelectionAdornmentTemplate",e,t))}get linkSelectionAdornmentTemplate(){return this.Yb}set linkSelectionAdornmentTemplate(t){let e=this.Yb;e!==t&&(this.Yb=t.It(),this.t("linkSelectionAdornmentTemplate",e,t))}get highlighteds(){return this.HA}get isModified(){let t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.sd&&this.qs!==t.historyIndex:this.sd}set isModified(t){if(this.sd!==t){m.s(t,"boolean",Y,"isModified"),this.sd=t;let e=this.undoManager;!t&&e.isEnabled&&(this.qs=e.historyIndex),t||this.PT()}}PT(){let t=this.isModified;this.WM!==t&&(this.WM=t,this.T("Modified"))}get model(){return this.Le}set model(t){let e=this.Le;if(e!==t){this.currentTool.doCancel(),e&&e.undoManager!==t.undoManager&&e.undoManager.isInTransaction&&m.o("Do not replace a Diagram.model while a transaction is in progress.");let i=this.sT(!0);this.io=!1,this.Zu=!0,this.qs=-2,this.Tr=!1;let s=this.Ht;this.Ht=!0,this.animationManager.Kl("Model"),e&&(this.to!==null&&this.to.each(n=>e.removeChangedListener(n)),e.removeChangedListener(this.Qc)),this.Le=t,this.partManager=this.NO(this.Le.type),this.initializePartManager(this.partManager);for(let n=0;n<i.length;n++)this.add(i[n]);t.addChangedListener(this.jM),this.partManager.T2(),t.removeChangedListener(this.jM),t.addChangedListener(this.Qc),this.to!==null&&this.to.each(n=>t.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.N(),e&&t.undoManager.copyProperties(e.undoManager)}}get themeManager(){return this.f2}set themeManager(t){let e=this.f2;e!==t&&(e&&e.removeDiagram(this),this.f2=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static u2(t,e){Y.JA.set(t,e)}static get licenseKey(){return Y.D2.last()}static set licenseKey(t){Y.D2.add(t.replace(/\s/g,""))}static get version(){return Y.LO}static D2=new q;static LO="3.1.9";NO(t){let e=Y.JA.get(t);return e!==null?new e:new me}get G(){return this.qM}set G(t){this.qM=t}get eb(){return this.qA}AO(t){if(t.model!==this.model)return;let e=t.change,i=t.propertyName;if(e===1&&i[0]==="S"){if(i==="StartingFirstTransaction"){let s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.As&&!this.io&&(this.Zc=!0,this.Zu&&(this.Tr=!0))}else if(i==="StartingUndo"||i==="StartingRedo"){let s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.T("ChangingSelection",this.selection)}else if(i==="StartedTransaction"){let s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.G){this.G=!1;try{if(t.modelChange===""&&e===1){(i==="FinishedUndo"||i==="FinishedRedo")&&(this.T("ChangedSelection",this.selection),this.De());let s=this.animationManager;i==="RolledBackTransaction"&&s.stopAnimation(),this.VA(),this.Zc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.kM(),i==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.qs=Math.min(this.qs,this.undoManager.historyIndex-1)),(i==="CommittedTransaction"||i==="RolledBackTransaction")&&this.undoManager.wx&&m.dn(()=>{this.isModified=!1},1);let n=t.isTransactionFinished;if(n&&(this.PT(),this.eb.clear(),this.animationManager.LR()),!this.Sb&&n&&this.lastInput.targetDiagram){this.Sb=!0;let o=this;m.dn(()=>{o.currentTool.standardMouseOver(),o.Sb=!1},10)}}}finally{this.G=!0}}}get wi(){return this.HM}set wi(t){this.HM=t}get Ou(){return this.Mb}set Ou(t){this.Mb=t}uT(t){let e=t.D.r;for(let i of e)i instanceof Bt&&this.v2(i)}v2(t){let e=t.element;if(e===null||!K.HTMLImageElement||!(e instanceof HTMLImageElement)||(e.hs instanceof V&&e.hs.add(this),t.TO(),!e.Np))return;let i=e.getAttribute("src")||"",s=this.la.get(i);if(s===null){Bt.ST(t,e);let n=[];n.push(t),this.la.set(i,n)}else{for(let n=0;n<s.length;n++)if(s[n]===t)return;s.push(t)}}DO(t){let e=t.D.r,i=e.length;for(let s=0;s<i;s++)this.F2(e[s])}F2(t){if(!(t instanceof Bt))return;let e=t.element;if(e===null||!K.HTMLImageElement||!(e instanceof HTMLImageElement)||!e.Np)return;let i=e.getAttribute("src")||"",s=this.la.get(i);if(s!==null){for(let n=0;n<s.length;n++)if(s[n]===t){s.splice(n,1),s.length===0&&(this.la.delete(i),Bt.vO(e),e.hs instanceof V&&e.hs.delete(this));return}}}nT(){Bt.clearCache(),this.la.clear()}rebuildParts(){this.partManager.rebuildParts()}Kc(t,e){this.Cs.Kc(t,e)}Yc(t,e){this.Cs.Yc(t,e)}findPartForKey(t){return this.partManager.findPartForKey(t)}findNodeForKey(t){return this.partManager.findNodeForKey(t)}findLinkForKey(t){return this.partManager.findLinkForKey(t)}findPartForData(t){return this.partManager.findPartForData(t)}findNodeForData(t){return this.partManager.findNodeForData(t)}findLinkForData(t){return this.partManager.findLinkForData(t)}findNodesByExample(...t){return this.partManager.findNodesByExample(...t)}findLinksByExample(...t){return this.partManager.findLinksByExample(...t)}get nodeTemplate(){return this.jr.get("")}set nodeTemplate(t){let e=this.jr.get("");e!==t&&(this.jr.set("",t),this.t("nodeTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get nodeTemplateMap(){return this.jr}set nodeTemplateMap(t){let e=this.jr;e!==t&&(this.jr=t,this.t("nodeTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get groupTemplate(){return this.uh.get("")}set groupTemplate(t){let e=this.uh.get("");e!==t&&(this.uh.set("",t),this.t("groupTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get groupTemplateMap(){return this.uh}set groupTemplateMap(t){let e=this.uh;e!==t&&(this.uh=t,this.t("groupTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get linkTemplate(){return this.ra.get("")}set linkTemplate(t){let e=this.ra.get("");e!==t&&(this.ra.set("",t),this.t("linkTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get linkTemplateMap(){return this.ra}set linkTemplateMap(t){let e=this.ra;e!==t&&(this.ra=t,this.t("linkTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get isMouseCaptured(){return this.JM}set isMouseCaptured(t){let e=this.lt;if(e===null)return;let i=e.bt;i instanceof SVGElement||(t?(this.lastInput.bubbles=!1,this.Ae(i,"pointermove",this.wh,!1),this.Ae(i,"pointerdown",this.ha,!1),this.Ae(i,"pointerup",this.xh,!1),this.Ae(i,"pointerout",this.bh,!1),this.Ae(i,"pointercancel",this.kh,!1),this.Et(K,"pointermove",this.wh,!0),this.Et(K,"pointerdown",this.ha,!0),this.Et(K,"pointerup",this.xh,!0),this.Et(K,"pointerout",this.bh,!0),this.Et(K,"pointercancel",this.kh,!0),this.Ae(i,"wheel",this.yh,!1),this.Et(K,"wheel",this.yh,!0),this.Et(K,"selectstart",this.nh,!1)):(this.Ae(K,"pointermove",this.wh,!0),this.Ae(K,"pointerdown",this.ha,!0),this.Ae(K,"pointerup",this.xh,!0),this.Ae(K,"pointerout",this.bh,!0),this.Ae(K,"pointercancel",this.kh,!0),this.Et(i,"pointermove",this.wh,!1),this.Et(i,"pointerdown",this.ha,!1),this.Et(i,"pointerup",this.xh,!1),this.Et(i,"pointerout",this.bh,!1),this.Et(i,"pointercancel",this.kh,!1),this.Ae(K,"wheel",this.yh,!0),this.Ae(K,"selectstart",this.nh,!1),this.Et(i,"wheel",this.yh,!1)),this.JM=t)}get position(){return this.ct}set position(t){if(this.ct.equals(t))return;let e=P.l().h(this.ct),i=this.viewportBounds.copy();if(this.ct.h(t),this.animationManager.IA(e,this.ct),!this.Ht&&!(this.lt===null&&!this.ed.isReal())){this.Ht=!0;let s=this.scale,n=this.wt/s,o=this.xt/s;this.p2(this.np,n,o,this.Jc,!1),this.Ht=!1}else this.ca(),this.kp();if(!this.Ht){let s=this.viewportBounds;this.onViewportBoundsChanged(i,s,this.et,!1)}P.i(e)}get initialPosition(){return this.ob}set initialPosition(t){this.ob.equals(t)||(this.ob=t.C())}get initialScale(){return this.rb}set initialScale(t){this.rb!==t&&(m.s(t,"number",Y,"initialScale"),this.rb=t)}get grid(){return this.ls===null&&(this.ls=this.rT()),this.ls}set grid(t){let e=this.ls;if(e!==t){e===null&&(this.ls=this.rT(),e=this.ls),t.type!==G.Grid&&m.o("Diagram.grid must be a Panel of type Panel.Grid");let i=e.panel;i!==null&&i.remove(e),this.ls=t,t.name="GRID",i!==null&&i.add(t),this._c=!1,this.N(),this.t("grid",e,t)}}get viewportBounds(){return this.zb}ca(){let t=this.zb,e=this.ct,i=this.et;t.e(e.x,e.y,Math.max(this.wt,0)/i,Math.max(this.xt,0)/i),this.Qr()}get viewSize(){return this.ed}set viewSize(t){let e=this.viewSize;if(!e.equals(t)){t=t.C(),this.ed=t;let i=0,s=0;t.isReal()?(i=t.width,s=t.height):this.Mt!==null&&(i=this.Mt.clientWidth||1,s=this.Mt.clientHeight||1),this.wt=i,this.xt=s,this.ca(),this.invalidateDocumentBounds(),this.t("viewSize",e,t),this.N()}}get fixedBounds(){return this.cb}set fixedBounds(t){let e=this.cb;e.equals(t)||((t.width===-1/0||t.height===1/0||t.height===-1/0)&&m.o("fixedBounds width/height must not be Infinity"),t=t.C(),this.cb=t,this.invalidateDocumentBounds(),this.t("fixedBounds",e,t))}get scrollMargin(){return this.ch}set scrollMargin(t){typeof t=="number"&&(t=new Dt(t));let e=this.ch;e.equals(t)||(t=t.C(),this.ch=t,this.t("scrollMargin",e,t),this.Eu())}get scrollMode(){return this.lh}set scrollMode(t){let e=this.lh;e!==t&&(this.lh=t,t===1&&this.$s(!1),this.t("scrollMode",e,t),this.Mh(),this.N())}get scrollsPageOnFocus(){return this.fb}set scrollsPageOnFocus(t){let e=this.fb;e!==t&&(m.s(t,"boolean",Y,"scrollsPageOnFocus"),this.fb=t,this.t("scrollsPageOnFocus",e,t))}get positionComputation(){return this.ub}set positionComputation(t){let e=this.ub;e!==t&&(t!==null&&m.S(t,Y,"positionComputation"),this.ub=t,this.$s(!1),this.t("positionComputation",e,t))}get scaleComputation(){return this.db}set scaleComputation(t){let e=this.db;e!==t&&(t!==null&&m.S(t,Y,"scaleComputation"),this.db=t,this.kT(this.scale,this.scale),this.t("scaleComputation",e,t))}get documentBounds(){return this.np}MT(t){this.gh=!1;let e=this.np;e.equals(t)||(e=e.copy(),this.np.h(t),this.$s(!1),this.T("DocumentBoundsChanged",void 0,e),this.Mh(),this.N())}ensureBounds(){if(this.gh){let t=I.l();this.MT(this.computeBounds(t)),I.i(t)}}get isVirtualized(){return this.Xb}set isVirtualized(t){let e=this.Xb;e!==t&&(m.s(t,"boolean",Y,"isVirtualized"),this.Xb=t,this.t("isVirtualized",e,t))}get scale(){return this.et}set scale(t){let e=this.et;e!==t&&this.kT(e,t)}get defaultScale(){return this.ap}set defaultScale(t){this.ap=t}get autoScale(){return this.na}set autoScale(t){let e=this.na;e!==t&&(this.na=t,this.t("autoScale",e,t),t!==1&&this.$s(!1))}get initialAutoScale(){return this.Rr}set initialAutoScale(t){let e=this.Rr;e!==t&&(this.Rr=t,this.t("initialAutoScale",e,t))}get initialViewportSpot(){return this.pb}set initialViewportSpot(t){let e=this.pb;e!==t&&(t.isSpot()||m.o("initialViewportSpot must be a specific Spot: "+t),this.pb=t,this.t("initialViewportSpot",e,t))}get initialDocumentSpot(){return this.gb}set initialDocumentSpot(t){let e=this.gb;e!==t&&(t.isSpot()||m.o("initialViewportSpot must be a specific Spot: "+t),this.gb=t,this.t("initialDocumentSpot",e,t))}get minScale(){return this.lb}set minScale(t){let e=this.lb;e!==t&&(t>0?(this.lb=t,this.t("minScale",e,t),t>this.scale&&(this.scale=t)):m.J(t,"> 0",Y,"minScale"))}get maxScale(){return this.ab}set maxScale(t){let e=this.ab;e!==t&&(t>0?(this.ab=t,this.t("maxScale",e,t),t<this.scale&&(this.scale=t)):m.J(t,"> 0",Y,"maxScale"))}get zoomPoint(){return this.hb}set zoomPoint(t){this.hb.equals(t)||(t=t.C(),this.hb=t)}get contentAlignment(){return this.Jc}set contentAlignment(t){let e=this.Jc;e.equals(t)||(t=t.C(),this.Jc=t,this.t("contentAlignment",e,t),this.$s(!1))}get initialContentAlignment(){return this.Qm}set initialContentAlignment(t){let e=this.Qm;e.equals(t)||(t=t.C(),this.Qm=t,this.t("initialContentAlignment",e,t))}get padding(){return this.Qt}set padding(t){typeof t=="number"&&(t=new Dt(t));let e=this.Qt;e.equals(t)||(t=t.C(),this.Qt=t,this.invalidateDocumentBounds(),this.t("padding",e,t))}get partManager(){return this.t2}set partManager(t){let e=this.t2;e!==t&&(t.diagram!==null&&m.o("Cannot share PartManagers between Diagrams: "+t.toString()),e&&e.Io(null),this.t2=t,t.Io(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){let t=new V,e=this.nodes;for(;e.next();){let s=e.value;s.isTopLevel&&t.add(s)}let i=this.links;for(;i.next();){let s=i.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.$r.iterator}get routers(){return this.rf}doLinkRouting(t){this.Uo=!0;let e=this.rf.r;for(let i=0;i<e.length;i++)e[i].canRoute(t)&&e[i].routeLinks(this.Or,t);this.Uo=!1}get layout(){return this.li}set layout(t){let e=this.li;e!==t&&(this.li=t,t.diagram=this,t.group=null,this.Jr=!0,this.t("layout",e,t),this.requestUpdate())}layoutDiagram(t){this.De(),t&&this.o1(!0),this.As?this.k2(!1,this.Ol||this.rf.count!==0&&this._n.size!==0):(this.Zc=!0,this.Pr())}o1(t){let e=this.$r.iterator;for(;e.next();)this.CT(e.value,t);this.layout&&(t?this.layout.isValidLayout=!1:this.layout.p())}CT(t,e){if(t===null)return;let i=t.Ch.iterator;for(;i.next();){let s=i.value;this.CT(s,e)}t.layout!==null&&(e?t.layout.isValidLayout=!1:t.layout.p())}k2(t,e){if(this.Cb)return;let i=this.G;this.G=!0;let s="Layout",n=this.undoManager.transactionLevel,o=this.layout,r=this.animationManager;try{n===0&&(this.undoManager.Fl=!0,this.startTransaction(s)),n<=1&&!r.defaultAnimation.isAnimating&&!r.Pe&&(t||r.Kl(s)),this.Jr=!1;let a=this.$r.iterator;for(;a.next();)this.fd(a.value),this.NT(a.value,t,n,e);let h=!1;if(o.isValidLayout||(!t||o.isRealtime||o.isRealtime===null||n===0?(o.doLayout(this),this.fd(this),h=!0,o.isValidLayout=!0):this.Jr=!0),h||this.fd(this),this.doLinkRouting(this),this.Or.clear(),this.fh.size!==0){for(let l=0;l<23&&this.fh.size!==0;l++){for(a=this.$r.iterator;a.next();)this.LT(a.value);let u=this.Or;this.Or=this.fh,this.fh=u,this.fd(this),this.doLinkRouting(this)}this.Or.clear(),this.fh.clear()}}finally{let a=this.undoManager.Fl;n===0&&(this.commitTransaction(s),this.undoManager.Fl=!1),a&&(n===0||n===1)&&r.kM(),this.Jr&&(this.Jr=!o.isValidLayout),this.G=i}}NT(t,e,i,s){let n=t.Ch.iterator;for(;n.next();)this.NT(n.value,e,i,s);let o=t.layout;o!==null&&!o.isValidLayout?!e||o.isRealtime||i===0?(t.Nh=!t.location.isReal(),o.doLayout(t),t.invalidateLayout(32),this.e1(t),this.fd(t),this.doLinkRouting(t),o.isValidLayout=!0):(this.doLinkRouting(t),this.Jr=!0):s&&this.doLinkRouting(t)}LT(t){let e=t.Ch.iterator;for(;e.next();)this.LT(e.value);this.fd(t),this.doLinkRouting(t)}get isTreePathToChildren(){return this.yb}set isTreePathToChildren(t){let e=this.yb;if(e!==t&&(m.s(t,"boolean",Y,"isTreePathToChildren"),this.yb=t,this.t("isTreePathToChildren",e,t),!this.undoManager.isUndoingRedoing)){let i=this.nodes;for(;i.next();)i.value.Lp()}}findTreeRoots(){let t=new q,e=this.nodes;for(;e.next();){let i=e.value;i.isTopLevel&&i.findTreeParentLink()===null&&t.add(i)}return t.iterator}get treeCollapsePolicy(){return this.wb}set treeCollapsePolicy(t){let e=this.wb;e!==t&&(t!==1&&t!==2&&t!==3&&m.o("Unknown Diagram.treeCollapsePolicy: "+t),this.wb=t,this.t("treeCollapsePolicy",e,t))}get isCollapsingExpanding(){return this.zM}set isCollapsingExpanding(t){this.zM=t}_R(){let t=new Mt,e=new Mt;function i(s){let n=s.toLowerCase(),o=new q;t.set(s,o),t.set(n,o),e.set(s,s),e.set(n,s)}i("InitialAnimationStarting"),i("AnimationStarting"),i("AnimationFinished"),i("BackgroundSingleClicked"),i("BackgroundDoubleClicked"),i("BackgroundContextClicked"),i("ClipboardChanged"),i("ClipboardPasted"),i("DocumentBoundsChanged"),i("ExternalObjectsDropped"),i("FocusOrVirtualPointerEnabledChanged"),i("GainedFocus"),i("InitialLayoutCompleted"),i("LayoutCompleted"),i("LinkDrawn"),i("LinkRelinked"),i("LinkReshaped"),i("LostFocus"),i("Modified"),i("ObjectSingleClicked"),i("ObjectDoubleClicked"),i("ObjectContextClicked"),i("PartCreated"),i("PartResized"),i("PartRotated"),i("SelectionMoved"),i("SelectionCopied"),i("SelectionDeleting"),i("SelectionDeleted"),i("SelectionGrouped"),i("SelectionUngrouped"),i("ChangingSelection"),i("ChangedSelection"),i("SubGraphCollapsed"),i("SubGraphExpanded"),i("TextEdited"),i("ThemeChanged"),i("TreeCollapsed"),i("TreeExpanded"),i("ViewportBoundsChanged"),i("InvalidateDraw"),this.VM=t,this.BM=e}fT(t){let e=this.BM.get(t);return e!==null?e:this.BM.get(t.toLowerCase())}R2(t){let e=this.VM.get(t);if(e!==null)return e;let i=t.toLowerCase();if(e=this.VM.get(i),e!==null)return e;m.o("Unknown DiagramEvent name: "+t)}addDiagramListener(t,e){m.s(t,"string",Y,"addDiagramListener:name"),m.S(e,Y,"addDiagramListener:listener");let i=this.R2(t);return i!==null&&i.add(e),this}removeDiagramListener(t,e){m.s(t,"string",Y,"removeDiagramListener:name"),m.S(e,Y,"addDiagramListener:listener");let i=this.R2(t);i!==null&&i.delete(e)}raiseDiagramEvent(t,e,i){this.T(t,e,i)}T(t,e,i){let s=this.R2(t),n=new wi;n.diagram=this;let o=this.fT(t);o!==null&&(n.name=o),e!==void 0&&(n.subject=e),i!==void 0&&(n.parameter=i);let r=s.length;if(r===1)s.elt(0)(n);else if(r!==0){let a=s.toArray();for(let h=0;h<r;h++){let l=a[h];l(n)}}}isUnoccupied(t,e){return this.getPositions(!1,null,e||null).isUnoccupied(t.x,t.y,t.width,t.height)}computeOccupiedArea(t){return this.isVirtualized?this.viewportBounds.copy():this.gh?this.aT(t):t.h(this.documentBounds)}getPositions(t,e,i){let s=this.oa;s===null&&(this.oa=s=new Ot(this.avoidanceCellSize));let n=e;if(s.Yo||s.Lh!==n||s.O2!==i){if(s.I2=Math.max(s.cf+1,Math.floor(this.avoidanceLimit/this.avoidanceCellSize.width)),s.E2=Math.max(s.cf+1,Math.floor(this.avoidanceLimit/this.avoidanceCellSize.height)),n!==null&&(n=this.AT(n)),n===null){let o=I.l();this.computeOccupiedArea(o),o.inflate(100,100),s.l1(o);let r=this.nodes;for(;r.next();){let a=r.value,h=a.layer;h===null||!h.visible||h.isTemporary||this.U2(a,i,o)}I.i(o)}else{if(n.memberParts.count>0){let a=this.computePartsBounds(n.memberParts,!1);a.inflate(20,20),s.l1(a)}let o=I.l(),r=n.memberParts;for(;r.next();){let a=r.value;a instanceof $&&this.U2(a,i,o)}I.i(o)}s.Lh=n,s.O2=i,s.Yo=!1}else t&&s.TT();return s}get avoidanceCellSize(){return this.$M}set avoidanceCellSize(t){this.oa=null,this.$M=new nt(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.ZM}set avoidanceLimit(t){this.ZM=Math.max(1,t)}AT(t){return t.canAvoid()?t:t.containingGroup!==null?this.AT(t.containingGroup):null}U2(t,e,i){if(t===e||!t.isVisible())return;let s=t.canAvoid();if(s){let n=t.getAvoidableRect(i);this.oa.FO(n.x,n.y,n.width,n.height)}if(t instanceof ht&&(!s||t.avoidableMembers)){let n=t.memberParts;for(;n.next();){let o=n.value;o instanceof $&&this.U2(o,e,i)}}}ud(t){this.oa!==null&&!this.oa.Yo&&(t===void 0||t.canAvoid())&&(this.oa.Yo=!0)}get autoScrollInterval(){return this._m}set autoScrollInterval(t){let e=this._m;e!==t&&(this._m=t,this.t("autoScrollInterval",e,t))}get autoScrollRegion(){return this.tp}set autoScrollRegion(t){typeof t=="number"&&(t=new Dt(t));let e=this.tp;e.equals(t)||(t=t.C(),this.tp=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",e,t))}doAutoScroll(t){this.rp.h(t);let e=P.l();this.computeAutoScrollPosition(this.rp,e).equalsApprox(this.position)?this.stopAutoScroll():this.DT(),P.i(e)}DT(){if(this.$c!==-1)return;let t=this._m,e=this;this.$c=m.dn(()=>{if(e.$c===-1||(e.stopAutoScroll(),e.lastInput.event===null))return;let i=P.l(),s=e.computeAutoScrollPosition(e.rp,i);if(!s.equalsApprox(e.position)){e.position=s,e.lastInput.documentPoint=e.transformViewToDoc(e.rp),e.doMouseMove(),e.gh=!0;let n=I.l();e.computeBounds(n),n.unionRect(e.documentBounds),e.MT(n),I.i(n),e.Wi=!0,e.maybeUpdate(),e.DT()}P.i(i)},t)}stopAutoScroll(){this.$c!==-1&&(m.yc(this.$c),this.$c=-1)}computeAutoScrollPosition(t,e){let i=this.position;e===void 0&&(e=new P),e.h(i);let s=this.tp;if(s.top<=0&&s.left<=0&&s.right<=0&&s.bottom<=0)return e;let n=this.viewportBounds,o=this.scale,r=I.z(0,0,n.width*o,n.height*o),a=P.z(0,0);if(t.x>=r.x&&t.x<r.x+s.left&&this.allowHorizontalScroll){let h=Math.max(this.scrollHorizontalLineChange,1);h=h|0,a.x-=h,t.x<r.x+s.left/2&&(a.x-=h),t.x<r.x+s.left/4&&(a.x-=4*h)}else if(t.x<=r.x+r.width&&t.x>r.x+r.width-s.right&&this.allowHorizontalScroll){let h=Math.max(this.scrollHorizontalLineChange,1);h=h|0,a.x+=h,t.x>r.x+r.width-s.right/2&&(a.x+=h),t.x>r.x+r.width-s.right/4&&(a.x+=4*h)}if(t.y>=r.y&&t.y<r.y+s.top&&this.allowVerticalScroll){let h=Math.max(this.scrollVerticalLineChange,1);h=h|0,a.y-=h,t.y<r.y+s.top/2&&(a.y-=h),t.y<r.y+s.top/4&&(a.y-=4*h)}else if(t.y<=r.y+r.height&&t.y>r.y+r.height-s.bottom&&this.allowVerticalScroll){let h=Math.max(this.scrollVerticalLineChange,1);h=h|0,a.y+=h,t.y>r.y+r.height-s.bottom/2&&(a.y+=h),t.y>r.y+r.height-s.bottom/4&&(a.y+=4*h)}return a.equalsApprox(P.gn)||(e.x=i.x+a.x/o,e.y=i.y+a.y/o),I.i(r),P.i(a),e}makeSvg(t){this.zo.has("SVG")||this.addRenderer("SVG",new ui(this,K.document));let e=new ui(this,K.document,!0);t===void 0&&(t={});let i=this;function s(n,o){let r=i.vT(n,"SVG",e),a=r!==null?r.svg:null,h=n.svgFinished;return a&&h&&h(a),m.it(o)?(o(a),null):a}return this.FT(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,e){this.zo.set(t,e)}removeRenderer(t){this.zo.delete(t)}cacheGroupExternalLinks(t){this.c2=t,t||this.nodes.each(e=>{e instanceof ht&&(e.Ap=null)})}FT(t,e){let i=e.callback,s=!0,n=this.la.iterator;for(;n.next();)if(!n.value[0].Mn){s=!1;break}if(!m.it(i)||s)return t(e,i,this);let o=this;function r(){let l=+new Date;for(s=!0,n.reset();n.next();)if(!n.value[0].Mn){s=!1;break}if(s||l-h>a){t(e,i,o);return}K.requestAnimationFrame(r)}let a=e.callbackTimeout||300,h=+new Date;return K.requestAnimationFrame(()=>r()),null}makeImage(t){return Y.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.FT(this.RO,t)}static img="image";RO(t,e,i){let s=i.vT(t,"canvas",null);if(s===null)return null;let n=s.F.canvas,o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Y.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Y.img:let a=(t.document||document).createElement("img");a.src=n.toDataURL(t.type,t.details),o=a;break;case"blob":{let h=n;return m.it(e)||(o="",m.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),m.it(h.toBlob)?(h.toBlob(e,t.type,t.details),"toBlob"):(e(null),null)}default:o=n.toDataURL(t.type,t.details)}}return m.it(e)?(e(o),null):o}static OO=!1;vT(t,e,i){this.animationManager.stopAnimation(),this.maybeUpdate(),m.$(t)||m.o("properties argument must be an Object.");let s=!1,n=t.size||null,o=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(o="NaN");let r=t.maxSize;t.maxSize===void 0&&(s=!0,e==="SVG"?r=new nt(1/0,1/0):r=new nt(2e3,2e3));let a=t.position||null,h=t.parts||null;Array.isArray(h)&&(h=new q(h));let l=t.padding===void 0?1:t.padding,u=t.background||null,c=t.omitTemporary;c===void 0&&(c=!0);let d=t.document||K.document,f=t.elementFinished||null,p=t.showTemporary;p===void 0&&(p=!c);let g=t.showGrid;g===void 0&&(g=p),n!==null&&isNaN(n.width)&&isNaN(n.height)&&(n=null),typeof l=="number"?l=new Dt(l):l instanceof Dt||m.o("MakeImage padding must be a Margin or a number."),l.left=Math.max(l.left,0),l.right=Math.max(l.right,0),l.top=Math.max(l.top,0),l.bottom=Math.max(l.bottom,0),this.Wt&&this.Wt.clearContextCache(!0);let y=new De(null,d,void 0,!0),b=y._t;if(!(n||o||h||a))return y.width=this.wt+Math.ceil(l.left+l.right),y.height=this.xt+Math.ceil(l.top+l.bottom),e==="SVG"?i===null?null:(i.resize(y.width,y.height,y.width,y.height),i.el=d,i.dd=f,this.i1(i._t,l,new nt(y.width,y.height),this.et,this.ct,h,u,p,g),i._t):(this.nd=!1,this.i1(b,l,new nt(y.width,y.height),this.et,this.ct,h,u,p,g),this.nd=!0,y._t);let v=this.ap,w=this.documentBounds.copy();if(w.subtractMargin(this.Qt),p){let F=this.Vt.r,O=F.length;for(let E=0;E<O;E++){let B=F[E];if(!B.visible||!B.isTemporary)continue;let X=B.Ct.r,z=X.length;for(let U=0;U<z;U++){let tt=X[U];if(!tt.isInDocumentBounds||!tt.isVisible())continue;let st=tt.actualBounds;st.isReal()&&w.unionRect(st)}}}let k=new P(w.x,w.y);if(h!==null){let F=new I(0,0,0,0),O=!0,E=h.iterator;for(E.reset();E.next();){let B=E.value;if(!(B instanceof pt))continue;let X=B.layer;if(X!==null&&!X.visible||X!==null&&!p&&X.isTemporary||!B.isVisible())continue;let z=B.actualBounds;z.isReal()&&(O?(O=!1,F.h(z)):F.unionRect(z))}w.width=F.width,w.height=F.height,k.x=F.x,k.y=F.y}a!==null&&a.isReal()&&(k=a,o||(o=v));let S=0,N=0;l!==null&&(S=l.left+l.right,N=l.top+l.bottom);let D=0,L=0;n!==null&&(D=n.width,L=n.height,isFinite(D)&&(D=Math.max(0,D-S)),isFinite(L)&&(L=Math.max(0,L-N)));let M=0,A=0;if(n!==null&&o!==null?(o==="NaN"&&(o=v),n.isReal()?(M=D,A=L):isNaN(L)?(M=D,A=w.height*o):(M=w.width*o,A=L)):n!==null?n.isReal()?(o=Math.min(D/w.width,L/w.height),M=D,A=L):isNaN(L)?(o=D/w.width,M=D,A=w.height*o):(o=L/w.height,M=w.width*o,A=L):o!==null?o==="NaN"&&r.isReal()?(o=Math.min((r.width-S)/w.width,(r.height-N)/w.height),o>v?(o=v,M=w.width,A=w.height):(M=r.width,A=r.height)):(M=w.width*o,A=w.height*o):(o=v,M=w.width,A=w.height),l!==null?(M+=S,A+=N):l=new Dt(0),r!==null){let F=r.width,O=r.height;e!=="SVG"&&s&&Y.OO,isNaN(F)&&(F=2e3),isNaN(O)&&(O=2e3),isFinite(F)&&(M=Math.min(M,F)),isFinite(O)&&(A=Math.min(A,O))}return y.width=Math.ceil(M),y.height=Math.ceil(A),e==="SVG"?i===null?null:(i.resize(y.width,y.height,y.width,y.height),i.el=d,i.dd=f,this.i1(i._t,l,new nt(Math.ceil(M),Math.ceil(A)),o,k,h,u,p,g),i._t):(this.nd=!1,this.i1(b,l,new nt(Math.ceil(M),Math.ceil(A)),o,k,h,u,p,g),this.nd=!0,y._t)}static Sh=null;static V2="5da73c80a36555d5038e4972187c3cae51fd22";static IO="5da73c80a36555d503aa5c72106c30b35bb2006b9cd041b259";static Yw=!1;static DP=()=>{if(Y.V2[5]===void 0&&(Nt.prototype.Ni=Nt.prototype.Mu),!Y.isUsingDOM())return;let t=m.Ci("canvas");t.width=350;let e=t.getContext("2d"),i=m.We("7ca11abfd022028846"),s="7ca11abfd7330390",n=[Y.V2,m.Yw+"4ae6247590da4bb21c324ba3a84e385776",Nt.DP+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",C.za];e.scale(2,2);let o=8;for(let r=1;r<5;r++)e[m.We(s)](m.We(n[r-1]),o,r*15);e[i]=m.We("39f046ebb36e4b");for(let r=1;r<5;r++)e[m.We(s)](m.We(n[r-1]),o,r*15);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Nt.prototype.Ni=Nt.prototype.Mu),Y.Sh=t};static EO=()=>{if(Y.V2[5]===void 0&&(Nt.prototype.Ni=Nt.prototype.Mu),!Y.isUsingDOM())return;let t=m.Ci("canvas"),e=t.getContext("2d"),i=m.We("7ca11abfd022028846"),s="7ca11abfd7330390",n=[Y.IO,C.za],o=5;e.scale(2,2);for(let r=1;r<3;r++)e[m.We(s)](m.We(n[r-1]),o,r*11);e[i]=m.We("39f046ebb36e4b");for(let r=1;r<3;r++)e[m.We(s)](m.We(n[r-1]),o,r*11);(n.length!==2||n[0][0]!=="5")&&(Nt.prototype.Ni=Nt.prototype.Mu),Y.Sh=t}}class Fn{RT;OT;B2;bi;constructor(t){if(this.RT=null,this.OT="63ad05bbe23a1786468a4c741b6d2",this.B2="@onz",this.OT===this._tk){this.B2=!0,this.bi=this.B2;return}this.bi=null}UO(t,e){let i="f",s=K[m.We("76a715b2f73f148a")][m.We("72ba13b5")]||"",n=m.We;if(this.bi=!0,!Y.isUsingDOM())return;let o=Y[n("76a115b6ed251eaf4692")];if(!o){let a=s[n("76ad18b4f73e")];for(let l=s[n("73a612b6fb191d")](n("35e7"))+2;l<a;l++)i+=s[l];let h=i[n("73a612b6fb191d")](n("7da71ca0ad381e90"));this.bi=!(h>=0&&h<i[n("73a612b6fb191d")](n("35")));return}let r=Y.D2.iterator;for(;r.next();){o=r.value;let a=n(o).split(n("39e9")),h=a.length===7?1:0;if(a.length===1&&o.includes(n("5b8b3797c61b32a7"))){if(Y.EO(),!t.lt)return;t.hp=t.lt._t.F[m.We("7eba17a4ca3b1a8346")][m.We("78a118b7")](t.lt._t.F,Y.Sh,4,4)}if(a.length<6)return;let l=n(a[1+h]).split(".");if(a[4+h]!=="7da71ca0")return;let u=n(m[n("6cae19")]).split(".");if(!(l[0]>u[0]||l[0]===u[0]&&l[1]>=u[1]))continue;let c="73a612b6fb191d",d=K[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),f=d[n(c)](n("3aad1ab6e022098b4dc4")),p=n(a[2+h]);if(f>-1){let M=d[n(c)](p.toLowerCase()+"/");if(this.bi=!(M>-1&&M<f),!this.bi)return}let g=s[n("76ad18b4f73e")];for(let M=s[n(c)](n("35e7"))+2;M<g;M++)i+=s[M];let y=i[n(c)](p);if(y<0&&p!==n("7da71ca0ad381e90")&&(y=i[n(c)](n("76a715b2ef3e149757"))),y<0&&(y=i[n(c)](n("76a715b2ef3e149757"))),y<0&&(y=i[n(c)](n("2bfa41fdb3784bca12"))),y<0&&(y=s[n(c)](n("7baa19a6f76c1988428554"))),y<0&&(y=s[n(c)](n("7ea902b2b9221e9c57c45767196566"))),this.bi=!(y>=0&&y<i[n(c)](n("35"))||i[n(c)](n("35"))===-1),!this.bi||s[n(c)](n("7fb002b6ed25128b4da25b2e"))&&(this.bi=!(s[n(c)](p)>-1),!this.bi))return;let b=K[m.We("76a715b2f73f148a")][m.We("69ad17a1e03e")],v=b[n(c)](n("7fb002b6ed25128b4da25b2e"));if(v>-1&&(this.bi=!(b[n(c)](p)>v),!this.bi))return;let w=p;if(w[0]!=="#")continue;let k=m.Ci("div"),S=a[0+h].replace(/[A-Za-z]/g,"");for(;S.length<4;)S+="9";let N=S;S=S.substring(S.length-4);let D=parseInt(u[0]),L=parseInt(u[1]);if(D>3||D===3&&L>=1){let M=parseInt(N)%40+30,A=parseInt(w.substring(1,5),16);if(j.IT===M+A){this.bi=!1;return}}else{let M="",A=["gsh","gsf"],F=["Header","Background","Display","Feedback"];if(M+=A[parseInt(S.substring(0,1),10)%2],M+=F[parseInt(S.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,K.document[n("78a712aa")]){K.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);let O=K.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),E=K.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(K.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!O)continue;let B=K[n("77a902b0eb1b1e804a8a")],X="0."+parseInt(N,10)%100;if(E===X||O.indexOf(parseInt(w[1]+w[2],16).toString())!==-1&&O.indexOf(parseInt(w[3]+w[4],16).toString())!==-1){this.bi=!1;return}else if(B&&B(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let z=0;z<K.document.styleSheets.length;z++){let U=K.document.styleSheets[z].rules||K.document.styleSheets[z].cssRules;for(let tt in U)if(M===U[tt].selectorText){this.bi=!1;return}}}}else this.bi=null,e&&(this.bi=!1)}}}Sh(t,e){return e.setTransform(t.$e/2,0,0,t.$e/2,0,0),e.commitTransform(),this.bi===null&&this.UO(t,!0),0<this.bi&&this!==this.RT}}class Xe{z2;X2;constructor(t){this.z2=t===void 0?new P:t,this.X2=new P}get point(){return this.z2}set point(t){this.z2=t}get shifted(){return this.X2}set shifted(t){this.X2=t}}class On{Ri;pT;s1;constructor(t,e,i){this.Ri=t,this.pT=e,this.s1=i}}class Pi{isGridSnapEnabled;isGridSnapRealtime;gridSnapCellSize;gridSnapCellSpot;gridSnapOrigin;dragsLink;dragsTree;groupsSnapMembers;groupsAlwaysMove;dragsMembers;constructor(t){this.Ue(),t&&Object.assign(this,t)}Ue(){this.isGridSnapEnabled=!1,this.isGridSnapRealtime=!0,this.gridSnapCellSize=new nt(NaN,NaN).k(),this.gridSnapCellSpot=T.TopLeft,this.gridSnapOrigin=new P(NaN,NaN).k(),this.dragsLink=!1,this.dragsTree=!1,this.groupsSnapMembers=!1,this.groupsAlwaysMove=!0,this.dragsMembers=!0}}class Rn extends Y{constructor(t,e){let i;return t===void 0||typeof t=="string"||K.Element&&t instanceof Element?i=t:m.$(t)&&(e=t),super(i),this.ET(),e&&this.setProperties(e),this}ET(){this.allowDragOut=!0,this.allowMove=!1,this.isReadOnly=!0,this.contentAlignment=T.TopCenter,this.layout=new Ye}setupRouters(){}reset(){super.reset(),this.ET()}}class hi extends Y{a1;h1;c1;f1;Tp;ff;Xl;G2;Y2;u1;K2;constructor(t,e){let i;return t===void 0||typeof t=="string"||K.Element&&t instanceof Element?i=t:m.$(t)&&(e=t),super(i),this.animationManager.isEnabled=!1,this.Ht=!0,this.a1=null,this.Qu=!1,this._u=!1,this.h1=!0,this.c1=!0,this.f1=0,this.Tp=!1,this.ff=null,this.setRenderingHint("drawShadows",!1),this.Xl=new pt({selectable:!0,selectionAdorned:!1,selectionObjectName:"BOXSHAPE",locationObjectName:"BOXSHAPE",resizeObjectName:"BOXSHAPE",cursor:"move"}).add(new it({name:"BOXSHAPE",fill:"transparent",stroke:"magenta",strokeWidth:2}).theme("stroke","overviewBox")).It(),this.allowCopy=!1,this.allowDelete=!1,this.allowDrop=!1,this.allowSelect=!0,this.autoScrollRegion=new Dt(0,0,0,0),this.ct.e(0,0),this.toolManager.Jt("Dragging",new En,this.toolManager.mouseMoveTools),this.click=()=>{let s=this.observed;if(s===null)return;let n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new P(o.x-n.width/2,o.y-n.height/2)},this.G2=s=>{this.invalidateDocumentBounds(),this.Dp()},this.Y2=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.N())},this.u1=s=>{this.updateDelay<1?this.N():this.Tp||(this.Tp=!0,m.dn(()=>this.redraw(),this.updateDelay))},this.K2=s=>{this.observed!==null&&this.Dp()},this.autoScale=2,this.Ht=!1,e&&this.setProperties(e),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.Tp&&this.updateDelay>=1&&(this.Tp=!1,this.VO()),super.redraw()}Ge(){if(this.Mt===null&&m.o("No div specified"),this.lt===null&&m.o("No canvas specified"),this.lt instanceof ui||(this.box.EM(),!this.Wi))return;let t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Za)return;this.Sp();let e=this.lt,i=this.Wt;if(i.clearContextCache(!0),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),this.updateDelay<1)this.UT();else if(this.ff!==null){i.drawImage(this.ff.bt,0,0);let o=this.v;i.scale(this.$e,this.$e),i.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),i.commitTransform()}let s=this.Vt.r,n=s.length;for(let o=0;o<n;o++)s[o].Ge(i,this);this.ef=!1,this.Wi=!1}VO(){let t=this.lt,e=this.Wt;if(!(t===null||e===null)){if(this.Sp(),this.ff===null){let i=new De(null);i.width=t.width,i.height=t.height,this.ff=i}try{this.lt=this.ff,this.Wt=this.lt._t,this.Wt.clearContextCache(!0),this.Wt.setTransform(1,0,0,1,0,0),this.Wt.clearRect(0,0,this.lt.width,this.lt.height),this.UT()}finally{this.lt=t,this.Wt=e}}}UT(){let t=this.observed;if(t===null)return;let e=this.drawsTemporaryLayers,i=this.drawsGrid&&e,s=t.grid;if(i&&s!==null&&s.visible&&!(isNaN(s.width)||isNaN(s.height))){let u=I.l().h(this.viewportBounds).unionRect(t.viewportBounds);t.P2(u),I.i(u),t.De()}let n=this.v,o=this.Wt;o.scale(this.$e,this.$e),o.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),o.commitTransform();let r=this.viewportBounds,a=t.Vt.r,h=a.length,l=this.Vt.r;this.rs(l,l.length,this,this.viewportBounds);for(let u=0;u<h;u++)a[u].UR(o,r,this,e,i)}get observed(){return this.a1}set observed(t){let e=this.a1;if(t!==null&&m.se(t,Y,hi,"observed"),t instanceof hi&&m.o("Overview.observed Diagram may not be an Overview itself: "+t),e!==t){if(e!==null&&this.BO(e),this.a1=t,t!==null&&this.zO(t),this.invalidateDocumentBounds(),t===null){this.ff=null;let i=this.lt,s=this.Wt;i&&s&&(s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,i.width,i.height))}else this.u1(null),this.Dp(),this.N();this.t("observed",e,t)}}get box(){return this.Xl}set box(t){let e=this.Xl;e!==t&&(t.It(),this.Xl=t,this.remove(e),this.add(this.Xl),this.Dp(),this.t("box",e,t))}get drawsTemporaryLayers(){return this.h1}set drawsTemporaryLayers(t){this.h1!==t&&(this.h1=t,this.redraw())}get drawsGrid(){return this.c1}set drawsGrid(t){this.c1!==t&&(this.c1=t,this.redraw())}get updateDelay(){return this.f1}set updateDelay(t){t<0&&(t=0),this.f1!==t&&(this.f1=t)}zO(t){t!==null&&(t.addDiagramListener("ViewportBoundsChanged",this.G2),t.addDiagramListener("DocumentBoundsChanged",this.Y2),t.addDiagramListener("InvalidateDraw",this.u1),t.addDiagramListener("AnimationFinished",this.K2),this.add(this.box))}BO(t){t!==null&&(this.remove(this.box),t.removeDiagramListener("ViewportBoundsChanged",this.G2),t.removeDiagramListener("DocumentBoundsChanged",this.Y2),t.removeDiagramListener("InvalidateDraw",this.u1),t.removeDiagramListener("AnimationFinished",this.K2))}Dp(){let t=this.box,e=this.observed;if(e===null)return;this.Wi=!0;let i=e.viewportBounds,s=t.selectionObject,n=nt.l();n.e(i.width,i.height),s.desiredSize=n,nt.i(n);let o=2/this.scale;s instanceof it&&(s.strokeWidth=o),t.location=new P(i.x-o/2,i.y-o/2),t.isSelected=!0}computeBounds(){let t=this.observed;if(t===null)return I.tm;let e=t.documentBounds.copy();return e.unionRect(t.viewportBounds),e}invalidateViewport(t,e){this.Wi!==!0&&(this.Wi=!0,this.requestUpdate())}onViewportBoundsChanged(t,e,i,s){this.Ht||(this.Qr(),this.N(),this.Mh(),this.invalidateDocumentBounds(),this.Dp(),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t))}}class En extends Tt{ua;constructor(){super(),this.ua=P.mn}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||!t.allowMove||!t.allowSelect)return!1;let e=t.observed;if(e===null)return!1;let i=t.lastInput;if(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.isTouchEvent&&i.timestamp-t.firstInput.timestamp<this.delay))return!1;if(this.findDraggablePart()===null){let s=e.viewportBounds;this.ua=new P(s.width/2,s.height/2);let n=t.firstInput.documentPoint;e.position=new P(n.x-this.ua.x,n.y-this.ua.y)}return!0}doActivate(){this.ua=P.mn,super.doActivate()}doUpdateCursor(t){let e=this.diagram,i=e.box;i!==null&&i.cursor&&(e.currentCursor=i.cursor)}moveParts(t,e,i){i===void 0&&(i=!1);let s=this.diagram,n=s.observed;if(n===null)return;let o=s.box;if(o===null)return;if(!this.ua.isReal()){let a=s.firstInput.documentPoint,h=o.location;this.ua=new P(a.x-h.x,a.y-h.y)}let r=s.lastInput.documentPoint;n.position=new P(r.x-this.ua.x,r.y-this.ua.y)}}class jt{a;d1="go._clipboard";g1="go._clipboardFormat";H2;q2;j2;W2;J2;$2;Z2;Q2;_2;da;tC;m1;p1;w1;b1;eC;Ko;iC;sC;vp;nC;k1;oC;P1;rC;lC;gd;Fp;Rp;aC;Qc;hC;cC;fC;uC;dC;md;gC;Oi;Ps;S1;Op;static pd=["Ctrl","Shft","Alt","Meta"];static VT=jt.mC(230,40,15);static XO=jt.mC(270,40,15);static GO=jt.mC(310,40,15);constructor(t){V.Je(this),this.a=Y.Fm(),this.H2=!0,this.q2=!0,this.j2=!0,this.W2=!1,this.J2=!1,this.$2=!1,this.Z2=!1,this.Q2="memory",this._2=null,this.da=null,this.tC=1.05,this.m1=NaN,this.p1=P.mn,this.w1=NaN,this.b1=I.tm,this.eC=!1,this.Ko=null,this.iC=200,this.sC=!1,this.vp=new vt("Auto",{layerName:"Tool",pickable:!1,selectable:!1}).add(new G("Spot").add(new it({name:"SHAPE",fill:null,stroke:"lime",strokeWidth:4}).bindObject("stroke","adornedPart",e=>e.isSelected?"darkcyan":"lime"),new it({name:"SHAPE2",stretch:2,fill:null,stroke:"magenta",strokeWidth:4,strokeDashArray:[4,4]})),new ue({padding:4})),this.nC=null,this.k1="",this.oC="",this.P1=m.fr,this.rC=!1,this.lC=!1,this.gd=new pt({layerName:"Tool",isInDocumentBounds:!1,locationObjectName:"CIRCLE",locationSpot:T.Center,pickable:!1,selectable:!1}).add(new it("Circle",{isGeometryPositioned:!0,width:30,height:30,fill:null,stroke:"darkcyan",strokeWidth:6,visible:!1}).bind("visible","down"),new it({isGeometryPositioned:!0,geometryString:"M15 0L15 30",stroke:"magenta"}),new it({isGeometryPositioned:!0,geometryString:"M0 15L30 15",stroke:"magenta"}),new it("Circle",{name:"CIRCLE",isGeometryPositioned:!0,width:20,height:20,fill:null,stroke:"magenta",position:new P(5,5)}),new it({isGeometryPositioned:!0,geometry:jt.VT,fill:null,stroke:"cyan",strokeWidth:4}).bind("geometry","button",jt.YO),new lt({position:new P(12,0),font:"bold 10pt sans-serif"}).bind("text","clickCount",e=>e>1?e.toString():""),new lt({position:new P(0,16)}).bind("text","modifiers",jt.KO)).freezeBindings(),this.Fp=10,this.Rp=1,this.aC=null,this.Qc=e=>this.HO(e),this.hC=e=>this.qO(e),this.cC=e=>this.jO(e),this.fC=e=>this.WO(e),this.uC=null,this.dC="distance",this.md=null,this.gC=0,this.Oi={},this.Ps=null,this.S1=!1,this.Op=null,this.pC(),this.gd.data=this.Oi,t&&Object.assign(this,t)}toString(){return"CommandHandler"}get diagram(){return this.a}Io(t){this.a=t}doStart(){let t=this.a;t&&(t.addModelChangedListener(this.Qc),t.addDiagramListener("ViewportBoundsChanged",this.hC),t.addDiagramListener("GainedFocus",this.cC),t.addDiagramListener("LostFocus",this.fC))}doStop(){let t=this.a;t&&(t.removeDiagramListener("ViewportBoundsChanged",this.hC),t.removeDiagramListener("GainedFocus",this.cC),t.removeDiagramListener("LostFocus",this.fC),t.removeModelChangedListener(this.Qc))}doKeyDown(){let t=this.a,e=t.lastInput,i=e.control||e.meta,s=e.shift,n=e.alt,o=e.commandKey;i&&(o==="Insert"||o==="c")?this.canCopySelection()&&this.copySelection():i&&o==="x"||s&&o==="Delete"?this.canCutSelection()&&this.cutSelection():i&&o==="v"||s&&o==="Insert"?this.canPasteSelection()&&this.pasteSelection():i&&o==="y"||i&&s&&o==="z"||n&&s&&o==="Backspace"?this.canRedo()&&this.redo():i&&o==="z"||n&&o==="Backspace"?this.canUndo()&&this.undo():o==="Delete"||o==="Backspace"?this.canDeleteSelection()&&this.deleteSelection():i&&o==="a"?this.canSelectAll()&&this.selectAll():o==="Escape"?this.canStopCommand()&&this.stopCommand():this.BT.indexOf(o)>=0?this.JO(o,i,s):o==="PageUp"?s&&t.allowHorizontalScroll?t.scroll("page","left"):t.allowVerticalScroll&&t.scroll("page","up"):o==="PageDown"?s&&t.allowHorizontalScroll?t.scroll("page","right"):t.allowVerticalScroll&&t.scroll("page","down"):o==="Home"?i&&t.allowVerticalScroll?t.scroll("document","up"):!i&&t.allowHorizontalScroll&&t.scroll("document","left"):o==="End"?i&&t.allowVerticalScroll?t.scroll("document","down"):!i&&t.allowHorizontalScroll&&t.scroll("document","right"):o==="Space"?this.canScrollToPart()&&this.scrollToPart():o==="Minus"||o==="NumpadSubtract"?this.canDecreaseZoom()&&this.decreaseZoom():o==="Equal"||o==="NumpadAdd"?this.canIncreaseZoom()&&this.increaseZoom():i&&o==="Digit0"?this.canResetZoom()&&this.resetZoom():s&&o==="z"?this.canZoomToFit()&&this.zoomToFit():i&&!s&&o==="g"?this.canGroupSelection()&&this.groupSelection():i&&s&&o==="g"?this.canUngroupSelection()&&this.ungroupSelection():o==="F2"?this.canEditTextBlock()&&this.editTextBlock():o==="ContextMenu"||s&&o==="F10"||i&&s&&o==="Backslash"?this.canShowContextMenu()&&this.showContextMenu():e.bubbles=!0}doKeyUp(){let t=this.a.lastInput;t.bubbles=!0}stopCommand(){let t=this.a,e=t.currentTool;if(e instanceof oe){if(e.currentToolTip!==null){e.hideToolTip();return}t.allowSelect&&t.clearSelection()}e!==null&&e.doCancel()}canStopCommand(){return!0}selectAll(){let t=this.a;t.N();try{t.currentCursor="wait",t.T("ChangingSelection",t.selection);let e=t.parts;for(;e.next();){let n=e.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}let i=t.nodes;for(;i.next();){let n=i.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}let s=t.links;for(;s.next();){let n=s.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}}finally{t.T("ChangedSelection",t.selection),t.currentCursor=""}}canSelectAll(){return this.a.allowSelect}deleteSelection(){let t=this.a;try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),t.startTransaction("Delete"),t.T("SelectionDeleting",t.selection);let e=new V,i=t.selection.iterator;for(;i.next();){let s=i.value;pt.ga(e,s,!0,this.deletesTree?1/0:0,this.deletesConnectedLinks?null:!1,n=>n.canDelete())}t.removeParts(e,!0),t.T("SelectionDeleted",e)}finally{t.commitTransaction("Delete"),t.T("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){let t=this.a;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){let t=this.a;{let e=new V,i=t.selection.iterator;for(;i.next();){let s=i.value;pt.ga(e,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(e)}}canCopySelection(){let t=this.a;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){let t=this.a;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){let e=this.a,i=this.storageLocation==="systemClipboard";if(i||this.storageLocation!=="memory")try{if(t===null)if(i&&K.navigator.clipboard)K.navigator.clipboard.writeText("");else{let n=K[this.storageLocation];if(!n)return;n.setItem(this.d1,""),n.setItem(this.g1,"")}else{let n=new Y;n.isTreePathToChildren=e.isTreePathToChildren,n.toolManager.draggingTool.dragsLink=e.toolManager.draggingTool.dragsLink,n.model=e.model.copy();let o=e.copyParts(t,n,!1);if(this.Fc(o),i&&K.navigator.clipboard)K.navigator.clipboard.writeText(n.model.toJson());else{let r=K[this.storageLocation];if(!r)return;r.setItem(this.d1,n.model.toJson()),r.setItem(this.g1,n.model.dataFormat)}}e.T("ClipboardChanged",t);return}catch{return}let s=null;if(t===null)Y.iT();else{let n=null;try{n=e.copyParts(t,null,!0),this.Fc(n)}finally{s=new q,n!==null&&s.addAll(n.iteratorValues),Y.xp=s,Y._b=e.model.dataFormat}}e.T("ClipboardChanged",s)}Fc(t){let e=this.diagram.model;this.copiesParentKey&&e.Mx()?t.each(i=>{let s=i.key,n=i.value;if(s instanceof $&&n instanceof $&&s.data&&n.data){let o=e.getParentKeyForNodeData(s.data),r=this.diagram.findNodeForKey(o);r!==null&&!t.has(r)&&e.setParentKeyForNodeData(n.data,o)}}):this.copiesGroupKey&&e.Ah()&&t.each(i=>{let s=i.key,n=i.value;if(!(s instanceof j)&&!(n instanceof j)&&s.data&&n.data){let o=e.getGroupForData(s.data),r=this.diagram.findNodeForKey(o);r!==null&&!t.has(r)&&e.setGroupForData(n.data,o)}})}pasteFromClipboard(){let t=this.a;if(this.storageLocation!=="memory"){let n=new V;try{let o=K[this.storageLocation];if(!o)return n;let r=o.getItem(this.d1),a=o.getItem(this.g1);if(r===null||r===""||a!==t.model.dataFormat)return n;{let h=new Y;h.model=dt.fromJson(r);let l=new V;l.addAll(h.parts).addAll(h.nodes).addAll(h.links);let u=t.copyParts(l,t,!1);return this.Fc(u),new V().addAll(u.iteratorValues)}}catch{return n}}let e=new V,i=Y.xp;if(i===null||Y._b!==t.model.dataFormat)return e;let s=null;try{s=t.copyParts(i,t,!1),this.Fc(s)}finally{if(s!==null){let n=s.iterator;for(;n.next();){let o=n.value,r=n.key;o.location.isReal()||(r.location.isReal()?o.location=r.location:!o.position.isReal()&&r.position.isReal()&&(o.position=r.position)),e.add(o)}}}return e}async pasteSelectionAsync(t){let e=this.a;if(K.navigator.clipboard===void 0){m.ne('Cannot paste with storageLocation "clipboard", window.isSecureContext may be false.');return}try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Paste");let i=null,s=await K.navigator.clipboard.readText();try{let o=s;if(!(o===null||o==="")){let r=new Y;r.model=dt.fromJson(o);let a=new V;a.addAll(r.parts).addAll(r.nodes).addAll(r.links);let h=e.copyParts(a,e,!1);this.Fc(h),i=new V().addAll(h.iteratorValues)}}catch{}if(i===null)return;i.count>0&&e.clearSelection(!0);let n=i.iterator;for(;n.next();){let o=n.value;o.isSelected=!0}if(t){let o=e.computePartsBounds(e.selection);if(o.isReal()){let r=this.computeEffectiveCollection(e.selection,e.ld);e.Sx(r,new P(t.x-o.centerX,t.y-o.centerY),e.ld,!1)}}e.T("ClipboardPasted",i)}finally{e.commitTransaction("Paste"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}pasteSelection(t){if(this.storageLocation==="systemClipboard"){this.pasteSelectionAsync(t);return}let e=this.a;try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Paste");let i=this.pasteFromClipboard();i.count>0&&e.clearSelection(!0);let s=i.iterator;for(;s.next();){let n=s.value;n.isSelected=!0}if(t){let n=e.computePartsBounds(e.selection);if(n.isReal()){let o=this.computeEffectiveCollection(e.selection,e.ld);e.Sx(o,new P(t.x-n.centerX,t.y-n.centerY),e.ld,!1)}}e.T("ClipboardPasted",i)}finally{e.commitTransaction("Paste"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}canPasteSelection(t){let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowInsert||!e.allowClipboard)return!1;if(this.storageLocation==="systemClipboard")return!0;if(this.storageLocation!=="memory")try{let i=K[this.storageLocation];if(!i)return!1;let s=i.getItem(this.d1),n=i.getItem(this.g1);return!(s===null||s===""||n!==e.model.dataFormat)}catch{return!1}return!(Y.xp===null||Y.xp.count===0||Y._b!==e.model.dataFormat)}undo(){this.a.undoManager.undo()}canUndo(){let t=this.a;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.a.undoManager.redo()}canRedo(){let t=this.a;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);let e=this.a;if(e.autoScale!==1)return;let i=e.scale*t;i<e.minScale||i>e.maxScale||(e.scale=i)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);let e=this.a;if(e.autoScale!==1)return!1;let i=e.scale*t;return i<e.minScale||i>e.maxScale?!1:e.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);let e=this.a;if(e.autoScale!==1)return;let i=e.scale*t;i<e.minScale||i>e.maxScale||(e.scale=i)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);let e=this.a;if(e.autoScale!==1)return!1;let i=e.scale*t;return i<e.minScale||i>e.maxScale?!1:e.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);let e=this.a;t<e.minScale||t>e.maxScale||(e.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);let e=this.a;return t<e.minScale||t>e.maxScale?!1:e.allowZoom}zoomToFit(t){let e=this.a,i=e.animationManager;i.stopAnimation(),e.redraw();let s=e.position.copy(),n=e.scale;if(i.Kl("Zoom To Fit"),!t&&this.isZoomToFitRestoreEnabled&&n===this.w1&&!isNaN(this.m1)&&this.p1.isReal()&&e.documentBounds.equals(this.b1))e.scale=this.m1,e.position=this.p1,this.w1=NaN,this.b1=I.tm;else{if(this.m1=n,this.p1=s,t){let o=t.copy();if(o.width>0&&o.height>0){let r=e.viewportBounds,a=r.width*n,h=r.height*n,l=Math.min(a/o.width,h/o.height),u=a/l,c=h/l;o.width<u&&(o.x-=(u-o.width)/2),o.height<c&&(o.y-=(c-o.height)/2)}e.zoomToRect(o,2)}else e.zoomToFit();this.w1=e.scale,this.b1=e.documentBounds.copy()}i.kM()}canZoomToFit(t){return this.a.allowZoom}JO(t,e,i){let s=this.a;t==="ArrowUp"?s.allowVerticalScroll&&(e?s.scroll("pixel","up"):s.scroll("line","up")):t==="ArrowDown"?s.allowVerticalScroll&&(e?s.scroll("pixel","down"):s.scroll("line","down")):t==="ArrowLeft"?s.allowHorizontalScroll&&(e?s.scroll("pixel","left"):s.scroll("line","left")):t==="ArrowRight"&&s.allowHorizontalScroll&&(e?s.scroll("pixel","right"):s.scroll("line","right"))}scrollToPart(t){t===void 0&&(t=null),t!==null&&m.se(t,pt,jt,"part");let e=this.a;if(e.ensureBounds(),t===null){try{this.Ko!==null&&(this.Ko.next()?t=this.Ko.value:this.Ko=null)}catch{this.Ko=null}t===null&&(e.highlighteds.count>0?this.Ko=e.highlighteds.iterator:e.selection.count>0&&(this.Ko=e.selection.iterator),this.Ko!==null&&this.Ko.next()&&(t=this.Ko.value))}if(t!==null){let i=e.animationManager;i.Kl("Scroll To Part");let s=this.scrollToPartPause;if(s>0){let n=this.uf(t,[t]);if(n.length===1)e.startTransaction(),e.centerRect(t.actualBounds),e.commitTransaction("Scroll To Part");else{let o=()=>{e.startTransaction();let a=n.pop();for(;n.length>0&&a instanceof $&&a.isTreeExpanded&&(!(a instanceof ht)||a.isSubGraphExpanded);)a=n.pop();n.length>0?(a instanceof pt&&e.scrollToRect(a.actualBounds),a instanceof $&&!a.isTreeExpanded&&(a.isTreeExpanded=!0),a instanceof ht&&!a.isSubGraphExpanded&&(a.isSubGraphExpanded=!0)):(a instanceof pt&&e.centerRect(a.actualBounds),e.removeDiagramListener("LayoutCompleted",r)),e.commitTransaction("Scroll To Part")},r=()=>{m.dn(o,(i.isEnabled?i.duration:0)+s)};e.addDiagramListener("LayoutCompleted",r),o()}}else{let n=e.position.copy();e.centerRect(t.actualBounds),n.equalsApprox(e.position)&&i.stopAnimation()}}}uf(t,e){if(t.isVisible())return e;if(t instanceof vt){let i=t.adornedPart;i!==null&&this.uf(i,e)}else if(t instanceof j){let i=t.fromNode;i!==null&&this.uf(i,e);let s=t.toNode;s!==null&&this.uf(s,e)}else{if(t instanceof $){let s=t.labeledLink;s!==null&&this.uf(s,e);let n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&e.push(n),this.uf(n,e))}let i=t.containingGroup;i!==null&&(!i.isSubGraphExpanded&&!i.wasSubGraphExpanded&&e.push(i),this.uf(i,e))}return e}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof pt))return!1;let e=this.a;return e.selection.count===0&&e.highlighteds.count===0?!1:e.allowHorizontalScroll&&e.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);let e=this.a,i="Collapse Tree";try{e.startTransaction(i),e.animationManager.Kl(i);let s=new q;if(t!==null&&t.isTreeExpanded)t.collapseTree(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof $&&o.isTreeExpanded&&(o.collapseTree(),s.add(o))}}e.T("TreeCollapsed",s)}finally{e.commitTransaction(i)}}canCollapseTree(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null){if(!(t instanceof $)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof $){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);let e=this.a,i="Expand Tree";try{e.startTransaction(i),e.animationManager.Kl(i);let s=new q;if(t!==null&&!t.isTreeExpanded)t.expandTree(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof $&&(o.isTreeExpanded||(o.expandTree(),s.add(o)))}}e.T("TreeExpanded",s)}finally{e.commitTransaction(i)}}canExpandTree(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null){if(!(t instanceof $)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof $){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){let t=this.a,e=t.model;if(!e.Ah())return;let i=this.archetypeGroupData;if(i===null)return;let s=null;try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),t.startTransaction("Group");let n=new q,o=t.selection.iterator;for(;o.next();){let l=o.value;l.Di()&&l.canGroup()&&n.add(l)}let r=new q,a=n.iterator;for(;a.next();){let l=a.value,u=!1,c=n.iterator;for(;c.next();){let d=c.value;if(l.isMemberOf(d)){u=!0;break}}u||r.add(l)}let h=r.first();if(h!==null){let l=h.containingGroup;if(l!==null)for(;l!==null;){let u=!1,c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(l)){u=!0;break}if(u)l=l.containingGroup;else break}if(i instanceof ht)i.It(),s=i.copy(),s!==null&&t.add(s);else if(e.isGroupForData(i)){let u=e.copyNodeData(i);e.addNodeData(u),s=t.findNodeForData(u)}if(s!==null){l!==null&&this.isValidMember(l,s)&&(s.containingGroup=l);let u=r.iterator;for(;u.next();){let c=u.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.T("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.T("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){let t=this.a;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.Ah()||this.archetypeGroupData===null)return!1;let e=t.selection.iterator;for(;e.next();){let i=e.value;if(i.Di()&&i.canGroup())return!0}return!1}yC(t){let e=m.st();if(Array.isArray(t))t.forEach(n=>{n instanceof j||n instanceof pt&&e.push(n)});else{let n=t.iterator;for(;n.next();){let o=n.value;o instanceof j||o instanceof pt&&e.push(o)}}let i=new V,s=e.length;for(let n=0;n<s;n++){let o=e[n],r=!0;for(let a=0;a<s;a++)if(o.isMemberOf(e[a])){r=!1;break}r&&i.add(o)}return m.Z(e),i}isValidMember(t,e){if(e===null||t===e||e instanceof j)return!1;let i;return t!==null&&(t===e||t.isMemberOf(e)||(i=t.memberValidation,i!==null&&!i(t,e))||t.data===null&&e.data!==null||t.data!==null&&e.data===null)?!1:(i=this.memberValidation,i!==null?i(t,e):!0)}ungroupSelection(t){t===void 0&&(t=null);let e=this.a,i=e.model;if(i.Ah())try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Ungroup");let s=new q;if(t!==null)s.add(t);else{let o=e.selection.iterator;for(;o.next();){let r=o.value;r instanceof ht&&r.canUngroup()&&s.add(r)}}let n=new q;if(s.count>0){e.clearSelection(!0);let o=s.iterator;for(;o.next();){let r=o.value;r.expandSubGraph();let a=r.containingGroup,h=a!==null&&a.data!==null?i.getKeyForNodeData(a.data):void 0;n.addAll(r.memberParts);let l=n.iterator;for(;l.next();){let u=l.value;if(u.isSelected=!0,u instanceof j)continue;let c=u.data;c!==null?i.setGroupForData(c,h):u.containingGroup=a}e.remove(r)}}e.T("SelectionUngrouped",s,n)}finally{e.commitTransaction("Ungroup"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowDelete||!e.allowUngroup||!e.model.Ah())return!1;if(t!==null){if(!(t instanceof ht))return!1;if(t.canUngroup())return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ht&&s.canUngroup())return!0}}return!1}addTopLevelParts(t,e){let i=this.yC(t),s=!0,n=i.iterator;for(;n.next();){let o=n.value;o.containingGroup!==null&&(!e||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);let e=this.a,i="Collapse SubGraph";try{e.startTransaction(i),e.animationManager.Kl(i);let s=new q;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof ht&&o.isSubGraphExpanded&&(o.collapseSubGraph(),s.add(o))}}e.T("SubGraphCollapsed",s)}finally{e.commitTransaction(i)}}canCollapseSubGraph(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null)return!(!(t instanceof ht)||!t.isSubGraphExpanded);{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ht&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);let e=this.a,i="Expand SubGraph",s=new q;try{if(e.startTransaction(i),e.animationManager.Kl(i),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof ht&&(o.isSubGraphExpanded||(o.expandSubGraph(),s.add(o)))}}e.T("SubGraphExpanded",s)}finally{for(let n of s)this.zT(e,n);t&&this.zT(e,t),e.commitTransaction(i)}}zT(t,e){for(let i of e.memberParts)i instanceof $&&t.Yc(i,e)}canExpandSubGraph(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null)return!(!(t instanceof ht)||t.isSubGraphExpanded);{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ht&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&m.se(t,lt,jt,"editTextBlock");let e=this.a,i=e.toolManager.findTool("TextEditing");if(i!==null){if(t===null){let s=null,n=e.selection.iterator;for(;n.next();){let o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof lt&&o.editable)}t!==null&&(e.currentTool=null,i.textBlock=t,e.currentTool=i)}}canEditTextBlock(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowTextEdit||e.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof lt))return!1;let i=t.part;if(i!==null&&i.canEdit())return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof lt&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){let e=this.a,i=e.toolManager.findTool("ContextMenu");if(i===null)return;t===void 0&&(t=null),t===null&&(e.selection.count>0?t=e.selection.first():t=e);let s=i.findObjectWithContextMenu(t);if(s!==null){let n=e.lastInput,o;if(s instanceof J?o=s.getDocumentPoint(T.Center):e.viewportBounds.containsPoint(n.documentPoint)?o=P.mn:o=e.viewportBounds.center,o.isReal()){let r=new te;r.diagram=e,r.viewPoint=e.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,e.lastInput=r}e.currentTool=i,i.openMenu(!1,s)}}canShowContextMenu(t){let e=this.a,i=e.toolManager.findTool("ContextMenu");return!(i===null||(t===void 0&&(t=null),t===null&&(e.selection.count>0?t=e.selection.first():t=e),i.findObjectWithContextMenu(t)===null))}downloadSvg(t){let e=this.a,i={scale:1,background:e.div?e.div.style.backgroundColor:"white",name:this.$O("svg")};t&&Object.assign(i,t);let s=e.makeSvg(i);if(s!==null){let n=new XMLSerializer().serializeToString(s);this.ZO(i.name,"image/svg+xml",n)}}downloadSVG(t){this.downloadSvg(t)}canDownloadSvg(t){return this.a!==null}ZO(t,e,i){let s=null,n=null;try{let o=new Blob([i],{type:e});s=K.URL.createObjectURL(o),n=m.Ci("a"),n.style.display="none",n.href=s,n.download=t,K.document.body.appendChild(n),requestAnimationFrame(()=>{try{n!==null&&n.click()}finally{s!==null&&K.URL.revokeObjectURL(s),n!==null&&K.document.body.removeChild(n)}})}catch{s!==null&&K.URL.revokeObjectURL(s),n!==null&&K.document.body.removeChild(n)}}$O(t){let e="."+t,i=this.diagram.model.name;return i?i.endsWith(e)&&(i=i.substring(0,i.length-e.length)):i="diagram",i+=e,i}get copiesClipboardData(){return this.H2}set copiesClipboardData(t){this.H2=!!t}get copiesConnectedLinks(){return this.q2}set copiesConnectedLinks(t){this.q2=!!t}get deletesConnectedLinks(){return this.j2}set deletesConnectedLinks(t){this.j2=!!t}get copiesTree(){return this.W2}set copiesTree(t){this.W2=!!t}get deletesTree(){return this.J2}set deletesTree(t){this.J2=!!t}get copiesParentKey(){return this.$2}set copiesParentKey(t){this.$2=!!t}get copiesGroupKey(){return this.Z2}set copiesGroupKey(t){this.Z2=!!t}get storageLocation(){return this.Q2}set storageLocation(t){t||(t="memory"),t!=="memory"&&t!=="sessionStorage"&&t!=="localStorage"&&t!=="systemClipboard"&&m.o("Invalid new value for CommandHandler.storageLocation: "+t),this.Q2=t}get archetypeGroupData(){return this._2}set archetypeGroupData(t){t!==null&&m.wc(t,jt,"archetypeGroupData");let e=this.a;this._2=t}get memberValidation(){return this.da}set memberValidation(t){t!==null&&m.S(t,jt,"memberValidation"),this.da=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.tC}set zoomFactor(t){t>1||m.o("zoomFactor must be larger than 1.0, not: "+t),this.tC=t}get isZoomToFitRestoreEnabled(){return this.eC}set isZoomToFitRestoreEnabled(t){this.eC=!!t}get scrollToPartPause(){return this.iC}set scrollToPartPause(t){this.iC=t}computeEffectiveCollection(t,e){let i=this.a,s=i.toolManager.findTool("Dragging"),n=i.currentTool===s;e===void 0&&(e=i.Cp());let o=new Mt;if(t===null)return o;let r=t.iterator;for(;r.next();){let a=r.value;i.tl(o,a,n,e)}if(i.draggedLink!==null&&e.dragsLink)return o;for(r=t.iterator;r.next();){let a=r.value;if(a instanceof j){let h=a.fromNode;if(h!==null&&!o.has(h))o.delete(a);else{let l=a.toNode;l!==null&&!o.has(l)&&o.delete(a)}}}return o}static getModifierNames(){return jt.pd}static setModifierNames(t){jt.pd=t}static KO(t){let e="";return t&1&&(e+=jt.pd[0]||""),t&4&&(e+=jt.pd[1]||""),t&2&&(e+=jt.pd[2]||""),t&8&&(e+=jt.pd[3]||""),e}static YO(t){return t===1?jt.XO:t===2?jt.GO:jt.VT}static mC(t,e,i){var s=new P(i,0).rotate(t-e/2),n=new wt().add(new zt(-i,-i)).add(new zt(i,i)).add(new zt(s.x,s.y).add(new mt(5,t-e/2,e,0,0,i,i)));return n.offset(i,i),n}HO(t){t.isTransactionFinished&&this.updateFocusBox()}qO(t){if(t.subject.scale===this.diagram.scale)return;let e=4/this.diagram.scale,i=this.focusBox.findObject("SHAPE");i!==null&&(i.strokeWidth=e);let s=this.focusBox.findObject("SHAPE2");s!==null&&(s.strokeWidth=e,s.strokeDashArray=[e,e]);let n=this.focusBox.placeholder;n!==null&&(n.padding=e)}jO(t){this.focus===null?m.dn(()=>{this.focus=this.findFirstFocus()},500):this.onFocusChanged(this.focus,this.focus)}WO(t){this.isVirtualPointerShown=!1}get isFocusEnabled(){return this.sC}set isFocusEnabled(t){t=!!t;let e=this.isFocusEnabled;t!==e&&(t||(this.isVirtualPointerShown=!1,this.uC=this.focus,this.focus=null),this.sC=t,t&&(this.focus=this.uC,this.updateFocusBox()))}get focusBox(){return this.vp}set focusBox(t){if(!(t instanceof vt))return;let e=this.vp;if(t!==e&&(this.vp=t,e.adornedObject!==null)){let i=e.adornedPart;i!==null&&i.removeAdornment("Focus"),t.adornedObject=e.adornedObject,i!==null&&i.addAdornment("Focus",t)}}get focus(){return this.vp.adornedObject}set focus(t){let e=this.focus;if(t!==e){let i=this.a;if(!i||!this.isFocusEnabled||t!==null&&t.diagram!==i)return;i.currentTool instanceof It||this.cancelVirtualPointer();let s=this.focusBox.adornedPart;s&&s.removeAdornment("Focus"),t===null?(this.md=null,this.virtualPointerLocation=i.viewportBounds.center,this.focusBox.adornedObject=null):(this.virtualPointerLocation=t.getDocumentPoint(T.Center),this.focusBox.adornedObject=t,this.updateFocusBox()),this.onFocusChanged(e,t)}}onFocusChanged(t,e){let i=this.a;if(i&&(this.focusChanged!==null?this.focusChanged(t,e,this):this.QO(this.describe(t,e)),e!==null&&e.part!==null)){let s=e.getDocumentBounds();i.viewportBounds.containsRect(s)||(e instanceof pt?i.commandHandler.scrollToPart(e):i.scrollToRect(s))}}get focusChanged(){return this.nC}set focusChanged(t){t!==null&&m.S(t,jt,"focusChanged"),this.nC=t}get liveElementId(){return this.k1||this.oC}set liveElementId(t){let e=this.k1;t!==e&&(this.k1=t,this.wC())}wC(){let t=this.diagram;if(!t||!Y.isUsingDOM())return;let e=t.lt?.bt;if(!e)return;let i=this.liveElementId,s=K.document.getElementById(i);this.isUsingAriaLive?(e.removeAttribute("aria-labelledby"),s&&s.setAttribute("aria-live","polite")):(i&&e.setAttribute("aria-labelledby",i),s&&s.removeAttribute("aria-live"))}get isUsingAriaLive(){return this.P1}set isUsingAriaLive(t){let e=this.P1;t!==e&&(this.P1=t,this.wC())}QO(t){let e=this.diagram;if(!e||!Y.isUsingDOM()||!e.div)return;let i=this.liveElementId;if(!i){let n=m.Ci("span"),o=n.style;for(o.opacity="0",o.position="absolute",o.right="-9999px",o.bottom="-9999px",o.width="0px",o.height="0px",o.overflow="hidden",o.border="0",i=(e.div.id||"diagram")+"_aria";K.document.getElementById(i);)i+=Math.floor(Math.random()*10);n.id=i,this.oC=i,e.div.appendChild(n),this.wC()}let s=K.document.getElementById(i);s&&(s.textContent=t)}describe(t,e){let i="";e instanceof $?e instanceof ht?i="Group":i="Node":e instanceof j?i="Link":e instanceof pt?i="Part":e&&(e.click?i="button":e instanceof lt&&e.editable&&(i="editable"),e.portId!==null&&(i&&(i+=" "),i+="port",e.portId&&(i+=" "+e.portId)));let s=this.xC(e);s&&(i+=" "+s);let n=e;if(t&&n instanceof j&&n.fromNode&&n.toNode){if(t instanceof $&&t.part===n.fromNode||t instanceof j&&t.fromNode===n.fromNode){i+=" to "+this.xC(n.toNode,!0);let o=n.toPort?.portId;o&&(i+=" port "+o)}else if(t instanceof $&&t.part===n.toNode||t instanceof j&&t.toNode===n.toNode){i+=" from "+this.xC(n.fromNode,!0);let o=n.fromPort?.portId;o&&(i+=" port "+o)}}return i}xC(t,e){if(e===void 0&&(e=!1),!t)return"";if(t instanceof lt&&t.text)return t.text;if(t instanceof G){let i="";return t instanceof pt&&t.text&&(i=t.text),e&&i||t.walkVisualTreeFrom(t,(s,n)=>{n.isVisibleObject()&&n instanceof lt&&n.text&&(!e||!i)&&i!==n.text&&(i+=" "+n.text)}),i}return""}updateFocusBox(){let t=this.focus;if(t!==null)if(t.diagram!==null&&(t instanceof pt?t.isVisible():t.isVisibleObject()&&t.part?.isVisible()))this.focusBox.adornedObject=t,t.part?.addAdornment("Focus",this.focusBox);else{let e=null;if(t instanceof pt||(e=t.part),e instanceof pt&&e.isVisible())this.focus=e;else{if(e instanceof $&&!e.isVisible()){let i=e.findTreeParentNode();if(i!==null)e=i;else{let s=e.labeledLink;s!==null&&(e=s)}}for(;e instanceof pt&&!e.isVisible();)e=e.containingGroup;e instanceof pt&&e.isVisible()?this.focus=e:this.focus=null}}}findFirstFocus(){let t=this.a;if(t===null||!t.isEnabled)return null;if(this.focus!==null)return this.focus;if(this.isFocusEnabled)if(t.selection.count>0)this.focus=t.selection.first();else{let e=this.XT(t.isTreePathToChildren).first();if(e!==null)return e}return null}get isVirtualPointerEnabled(){return this.rC}set isVirtualPointerEnabled(t){t=!!t;let e=this.isVirtualPointerEnabled;if(t!==e&&(this.rC=t,t)){let i=this.Op;i&&(this.Op=null,i.commandHandler.Ps=null,i.commandHandler.cancelVirtualPointer())}}get isVirtualPointerShown(){return this.lC}set isVirtualPointerShown(t){t=!!t;let e=this.isVirtualPointerShown;if(t!==e){let i=this.a;if(!i||!this.isVirtualPointerEnabled)return;this.lC=t;let s=this.focus;t?this.virtualPointerBox.diagram===null&&(this.virtualPointerLocation.isReal()||(s!==null?this.virtualPointerLocation=s.getDocumentPoint(T.Center):this.virtualPointerLocation=i.viewportBounds.center),i.add(this.virtualPointerBox),this.ma()):this.virtualPointerBox.diagram!==null&&(i.remove(this.virtualPointerBox),this.ma())}}cancelVirtualPointer(){let t=this.a;t&&(this.pC(),this.isVirtualPointerShown=!1,t.currentTool.doCancel(),this.isVirtualPointerDown=!1,this.bC())}bC(){let t=this.Ps;if(t!==null){this.Ps=null;let e=t.commandHandler;e.Ps=null,e.Op=null,e.isVirtualPointerShown=!1,e.isVirtualPointerDown=!1,e.pC(),this.S1&&(e.isVirtualPointerEnabled=!1),this.S1=!1}}pC(){this.Oi.button=0,this.Oi.modifiers=0,this.Oi.clickCount=1,this.Oi.down=!1,this.ma()}ma(){this.virtualPointerChanged!==null&&this.virtualPointerChanged(this.virtualPointerBox,this),this.updateVirtualPointer()}updateVirtualPointer(){let t=this.virtualPointerBox.diagram;t&&(this.virtualPointerBox.scale=1/t.scale),this.virtualPointerBox.updateTargetBindings()}get virtualPointerBox(){return this.gd}set virtualPointerBox(t){if(!(t instanceof pt))return;let e=this.gd;t!==e&&(e!==null&&(t.location=e.location,e.diagram!==null&&e.diagram.remove(e)),this.gd=t,this.isVirtualPointerShown&&this.diagram&&(this.diagram.add(t),t.data=e.data),this.ma())}get virtualPointerChanged(){return this.aC}set virtualPointerChanged(t){t!==null&&m.S(t,jt,"virtualPointerChanged"),this.aC=t}get virtualPointerLocation(){return this.virtualPointerBox.location}set virtualPointerLocation(t){this.virtualPointerLocation.equals(t)||this.GT(t.x,t.y)}get isVirtualPointerDown(){return this.virtualPointerBox.data?this.virtualPointerBox.data.down:!1}set isVirtualPointerDown(t){t=!!t;let e=this.isVirtualPointerDown;if(t!==e){let i=this.a;if(!i||!this.isVirtualPointerEnabled||(this.virtualPointerBox.data===null&&(this.gd.data=this.Oi),this.virtualPointerBox.data.down=t,this.ma(),!this.isVirtualPointerShown))return;let s=i.lastInput,n=new te;n.diagram=i,this.YT(n,t),t?n.down=!0:n.up=!0,n.clickCount=1,n.button=this.Oi.button,n.modifiers=this.Oi.modifiers,t&&(i.firstInput=n.copy()),this.yd(n,!0),t||this.Oi.clickCount===2&&(n.clickCount=2,n.down=!0,n.up=!1,this.yd(n,!0),n.down=!1,n.up=!0,this.yd(n,!0),this.KT(1)),i.lastInput=s}}get virtualPointerShiftMove(){return this.Fp}set virtualPointerShiftMove(t){this.Fp=t}get virtualPointerControlMove(){return this.Rp}set virtualPointerControlMove(t){this.Rp=t}Ip(t,e){this.GT(this.virtualPointerLocation.x+t,this.virtualPointerLocation.y+e)}GT(t,e){this.virtualPointerBox.moveTo(t,e,!0);let i=this.a;if(!i||!this.isVirtualPointerEnabled||!this.isVirtualPointerShown)return;i.ensureBounds();let s=i.lastInput,n=new te;n.diagram=i,this.YT(n,this.isVirtualPointerDown),n.button=this.Oi.button,n.modifiers=this.Oi.modifiers,this.yd(n,!0),i.lastInput=s,this.isVirtualPointerDown&&(i.remove(this.virtualPointerBox),i.add(this.virtualPointerBox)),this.ma()}YT(t,e){let i=this.a;if(i){if(t.targetDiagram=i,t.documentPoint=this.virtualPointerLocation,i.allowDragOut){let s=i.div.getBoundingClientRect(),n=i.transformDocToView(this.virtualPointerLocation),o=s.x+n.x,r=s.y+n.y,a=K.document.elementFromPoint(o,r)||null;a instanceof HTMLCanvasElement&&(a=a.parentElement),a!==null&&a.shadowRoot&&(a=a.shadowRoot.elementFromPoint(o,r)||null,a instanceof HTMLCanvasElement&&(a=a.parentElement));let h=null;if(a instanceof HTMLElement&&(h=Y.Ji.get(a))&&h!==i&&h.div){let l=h.div.getBoundingClientRect(),u=new P(n.x-(l.x-s.x),n.y-(l.y-s.y));this.Ps!==null&&this.Ps!==h&&this.bC(),t.targetDiagram=h,t.viewPoint=u,t.documentPoint=h.transformViewToDoc(u),t.viewPoint=h.transformDocToView(t.documentPoint),this.Ps=h;let c=h.commandHandler;this.S1=!c.isVirtualPointerEnabled,c.isVirtualPointerEnabled=!0,c.isVirtualPointerDown=e,c.virtualPointerLocation=t.documentPoint,c.isVirtualPointerShown=!0,c.Op=i;return}}this.Ps!==null&&this.bC(),t.viewPoint=i.transformDocToView(t.documentPoint)}}yd(t,e){this.doVirtualPointerEvent(t,e)}doVirtualPointerEvent(t,e){let i=this.a;i&&(t.timestamp=Date.now(),i.lastInput=t,e&&(t.up?i.doMouseUp():t.down?i.doMouseDown():i.doMouseMove()),this.onVirtualPointerEvent(t,e))}onVirtualPointerEvent(t,e){let i=this.a;i&&(t.up?this.isVirtualPointerDown&&!i.viewportBounds.containsPoint(this.virtualPointerLocation)&&(this.virtualPointerLocation=this.focus instanceof J?this.focus.getDocumentPoint(T.Center):i.viewportBounds.center):t.down)}doVirtualFocusKeyDown(){let t=this.a;if(!t)return!1;let e=t.lastInput,i=e.commandKey;if(this.isVirtualPointerEnabled&&(i==="ShiftLeft"||i==="ShiftRight"))return this.isVirtualPointerShown=!0,!0;if(this.BT.indexOf(i)>=0)if(e.shift&&this.isVirtualPointerShown){let s=this.M1(i),n=e.control||e.meta?this.Rp:this.Fp;s===270?this.Ip(0,-n):s===90?this.Ip(0,n):s===180?this.Ip(-n,0):this.Ip(n,0)}else this._O();else if(e.shift&&this.isVirtualPointerShown&&(i==="Numpad1"||i==="Numpad2"||i==="Numpad3"||i==="Numpad4"||i==="Numpad6"||i==="Numpad7"||i==="Numpad8"||i==="Numpad9")){let s=e.control||e.meta?this.Rp:this.Fp,n=0;i==="Numpad1"||i==="Numpad4"||i==="Numpad7"?n=-s:(i==="Numpad3"||i==="Numpad6"||i==="Numpad9")&&(n=s);let o=0;i==="Numpad7"||i==="Numpad8"||i==="Numpad9"?o=-s:(i==="Numpad1"||i==="Numpad2"||i==="Numpad3")&&(o=s),this.Ip(n,o)}else if(i==="Enter"||i==="NumpadEnter"||i==="Numpad5")e.shift&&this.isVirtualPointerShown?this.isVirtualPointerDown=!this.isVirtualPointerDown:this.tI();else if(i==="Escape")this.eI();else if(i==="Space")this.iI();else if(i==="ContextMenu"||e.shift&&i==="F10"||(e.control||e.meta)&&e.shift&&i==="Backslash")this.sI();else if(e.shift&&i==="c")this.C1(1);else if(e.shift&&i==="a")this.C1(2);else if(e.shift&&i==="KeyS")this.C1(4);else if(e.shift&&i==="KeyM")this.C1(8);else if(e.shift&&i==="Digit1")this.N1(0);else if(e.shift&&i==="Digit2")this.N1(1);else if(e.shift&&i==="Digit3")this.N1(2);else if(e.shift&&i==="Numpad0"){let s=this.Oi.button;this.N1(s===2?0:2)}else if(e.shift&&(i==="KeyD"||i==="NumpadDecimal")){let s=this.Oi.clickCount;this.KT(s===2?1:2)}else if(e.shift&&i==="KeyF"){let s=this.nextFocusFormula;this.nextFocusFormula=s==="distance"?"linear":"distance"}else if(e.shift&&i==="y")this.isUsingAriaLive=!this.isUsingAriaLive;else return!1;return!0}doVirtualFocusKeyUp(){let t=this.a;if(!t)return!1;let e=t.lastInput.commandKey;return this.isVirtualPointerEnabled&&(e==="ShiftLeft"||e==="ShiftRight")&&(this.isVirtualPointerShown=!1),!0}M1(t){switch(t){case"ArrowDown":return 90;case"ArrowLeft":return 180;case"ArrowUp":return 270;default:return 0}}BT=["ArrowRight","ArrowDown","ArrowLeft","ArrowUp"];C1(t){let e=this.Oi.modifiers;this.Oi.modifiers=e&t?e&~t:e|t,this.ma()}KT(t){this.Oi.clickCount=t,this.ma()}N1(t){this.Oi.button=t,this.ma()}_O(){let t=this.a;if(!t)return;let e=t.lastInput,i=this.focus;if(i===null){let s=this.XT(t.isTreePathToChildren).first();s!==null&&(this.focus=s)}else if(i instanceof j)this.nI(i);else if(i instanceof $)this.oI(i);else{i instanceof pt&&(this.md=null);let s=this.M1(e.commandKey);s===270?this.focus=this.findNextFocus(270):s===90?this.focus=this.findNextFocus(90):s===180?this.focus=this.findNextFocus(180):this.focus=this.findNextFocus(0)}}nI(t){let e=this.a;if(!e)return;let i=e.lastInput,s=this.M1(i.commandKey),n=null,o=this.md;if(o!==null){let r=this.gC;if(s===r)n=t.getOtherNode(o);else if(s===C.Ee(r+180))n=o;else{let a=r===0||r===180?90:0,h=r===0||r===180?270:180;if(s===a){let l=this.kC(o,r,!0),u=l.indexOf(t);u>=0&&u<l.count-1&&(this.focus=l.elt(u+1))}else if(s===h){let l=this.kC(o,r,!0),u=l.indexOf(t);u>0&&(this.focus=l.elt(u-1))}}}else{let r=t.fromNode,a=t.toNode;if(!r||!a)return;s===270?n=r.location.y<a.location.y?r:a:s==90?n=r.location.y>a.location.y?r:a:s===180?n=r.location.x<a.location.x?r:a:n=r.location.x>a.location.x?r:a}for(;n!==null&&!n.isVisible();)n=n.containingGroup;n!==null&&(this.focus=n)}oI(t){let e=this.a;if(!e)return;let i=e.lastInput,s=this.M1(i.commandKey);if(i.control||i.meta){let n=this.kC(t,s,!0).first();n&&(this.md=t,this.gC=s,this.focus=n)}else this.md=null,this.focus=this.findNextFocus(s)}kC(t,e,i){if(t===null)return new q;let s=t.actualBounds;if(!s.isReal())return new q;let n=new Set;(t instanceof ht?t.findExternalLinksConnected():t.findLinksConnected()).each(r=>{if(!r.isVisible())return;let a=null;if(r.fromNode===t?a=r.toNode:r.toNode===t?a=r.fromNode:t instanceof ht&&(r.fromNode?.isMemberOf(t)?a=r.toNode:r.toNode?.isMemberOf(t)&&(a=r.fromNode)),a===null||a.isMemberOf(t))return;for(;a!==null&&!a.isVisible();)a=a.containingGroup;if(a===null)return;let h=a.location;if(h.isReal()&&!(e===270&&(a!==t?h.y>=s.top:r.midPoint.y>=s.top))){if(e===90&&(a!==t?h.y<=s.bottom:r.midPoint.y<=s.bottom)||e===180&&(a!==t?h.x>=s.left:r.midPoint.x>=s.left)||e===0&&(a!==t?h.x<=s.right:r.midPoint.x<=s.right))return;i&&r.actualBounds.isReal()?n.add(r):n.add(a)}});let o=new q(n);return e===90||e===270?o.sort((r,a)=>r.actualBounds.centerX-a.actualBounds.centerX):o.sort((r,a)=>r.actualBounds.centerY-a.actualBounds.centerY),o}findNextFocus(t){t=C.Ee(t);let e=this.focus,i=e instanceof $?e.location:e.getDocumentPoint(T.Center),s=1/0,n=e,o=(r,a,h,l)=>{if(this.nextFocusFormula==="linear"){let u=1/0;t===0&&h>i.x||t===180&&h<i.x?u=Math.abs(h-i.x):(t===90&&l>i.y||t===270&&l<i.y)&&(u=Math.abs(l-i.y)),u<s&&(s=u,n=r)}else{if(t===0&&(a.right<i.x||(a.centerX-i.x)**2>s)||t===90&&(a.bottom<i.y||(a.centerY-i.y)**2>s)||t===180&&(a.x>i.x||(i.x-a.centerX)**2>s)||t===270&&(a.y>i.y||(i.y-a.centerY)**2>s))return;let u=i.direction(h,l),c=C.jF(t,u);if(t===90||t===270?c<=45:c<45){let d=i.distanceSquared(h,l);d<s&&(s=d,n=r)}}};if(e instanceof pt&&e.diagram!==null){let r=e.containingGroup;r!==null?r.memberParts.each(a=>{a===e||a instanceof j||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}):(e.diagram.nodes.each(a=>{a===e||!a.isTopLevel||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}),e.diagram.parts.each(a=>{a===e||!a.isTopLevel||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}))}else if(e.part!==null){let r=new I;this.PC(e.part).each(a=>{a!==e&&(a.getDocumentBounds(r),o(a,r,r.centerX,r.centerY))})}return n}get nextFocusFormula(){return this.dC}set nextFocusFormula(t){this.dC=t}tI(){let t=this.a;if(!t)return;let e=t.currentTool;if(e instanceof It){let n=e.currentObject;this.L1(this.focus),e.maybeStopTool(this.focus),t.currentTool instanceof It||(this.focus=n);return}let i=this.focus,s=t.lastInput;if(i===null)s.control||s.meta?this.L1(null):this.focus=this.findFirstFocus();else if(i instanceof pt)if(s.control||s.meta)this.L1(i);else{let n=this.PC(i);if(n.count>0)this.focus=n.first();else if(i instanceof j&&i.isLabeledLink){let o=i.labelNodes.first();o!==null&&o.isVisible()&&(this.focus=o)}else if(i instanceof ht&&i.isSubGraphExpanded){let o=i.memberParts.first();o!==null&&o.isVisible()&&(this.focus=o)}}else this.L1(i)}XT(t){let e=new q,i=this.a;if(!i)return e;let s=0;for(;e.count===0&&s<i.nodes.count;){let n=i.nodes;for(;n.next();){let o=n.value;o.isTopLevel&&o.isVisible()&&(t?o.findNodesInto():o.findNodesOutOf()).count===s&&e.add(o)}s++}return e}PC(t){return t instanceof pt?this.Sn(t,new q):new q}Sn(t,e){return!(t instanceof pt)&&t.isVisibleObject()&&t.isEnabledObject()&&(t.contextMenu||t.click||t instanceof lt&&t.editable||t.part instanceof $&&t.portId!==null&&(t.portId!==""||t.part.ports.count>1)||t.toolTip)&&e.add(t),t instanceof G&&t.elements.each(i=>this.Sn(i,e)),e}L1(t){let e=this.a;if(!e)return;let i=e.lastInput,s=t instanceof J?t:e;if(s.click){let n=new te;n.diagram=e,n.documentPoint=t instanceof J?t.getDocumentPoint(T.Center):e.viewportBounds.center,n.viewPoint=e.transformDocToView(n.documentPoint),n.button=0,n.clickCount=1,n.targetObject=t,this.yd(n,!1),s instanceof J?s.click(n,s):s.click(n),e.lastInput=i}else s instanceof lt&&s.editable?this.editTextBlock(s):this.HT(t)}eI(){let t=this.a;if(!t)return;let e=t.currentTool;if(e instanceof oe&&e.currentToolTip!==null){e.hideToolTip();return}else if(e instanceof It){let i=e.currentObject;e.doKeyDown(),this.focus=i;return}if(this.focus instanceof pt){let i=this.focus;i instanceof $&&i.labeledLink!==null?this.focus=i.labeledLink:i.containingGroup!==null?this.focus=i.containingGroup:this.focus=null}else if(this.focus instanceof J){let i=this.focus.part;if(i instanceof j&&i.isLabeledLink){let s=i.labelNodes.first();if(s!==null&&s.isVisible()){this.focus=s;return}}else if(i instanceof ht&&i.isSubGraphExpanded){let s=i.memberParts.first();if(s!==null&&s.isVisible()){this.focus=s;return}}this.focus=i}else this.cancelVirtualPointer(),this.stopCommand()}iI(){let t=this.a;if(t)if(t.lastInput.shift&&this.isVirtualPointerShown){let e=t.findPartAt(this.virtualPointerLocation);e!==null&&(e===this.focus?this.qT():this.focus=e)}else this.qT()}qT(){let t=this.a;if(!t)return;let e=t.lastInput,i=this.focus;if(i instanceof pt){let s=i.part;if(e.control||e.meta){for(t.raiseDiagramEvent("ChangingSelection",t.selection);s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.raiseDiagramEvent("ChangedSelection",t.selection)}else if(e.shift){if(s!==null&&!s.isSelected){for(t.raiseDiagramEvent("ChangingSelection",t.selection);s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.raiseDiagramEvent("ChangedSelection",t.selection)}}else if(s!==null&&!s.isSelected){for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}this.HT(i),this.onFocusChanged(i,i)}HT(t){let e=this.a;if(!e)return;e.toolManager.hideToolTip();let i=e.lastInput,s=t instanceof J?t:e;for(;s instanceof J&&!s.toolTip;)s=s.panel;if(s&&s.toolTip){let n=new te;n.diagram=e,n.documentPoint=t!==null?t.getDocumentPoint(T.Center):e.viewportBounds.center,n.viewPoint=e.transformDocToView(n.documentPoint),n.targetObject=t,this.yd(n,!1),e.toolManager.showToolTip(s.toolTip,t),e.lastInput=i}}sI(){let t=this.a;if(!t)return;let e=this.focus;if(this.canShowContextMenu(e)){this.showContextMenu(e);let i=t.toolManager.contextMenuTool.currentContextMenu;if(i instanceof vt){let s=this.PC(i);s.count>0&&(this.focus=s.first())}}}}var Bi=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Vertical=4]="Vertical",x[x.Horizontal=5]="Horizontal",x[x.Fill=2]="Fill",x))(Bi||{}),Vi=(x=>(x[x.None=0]="None",x[x.Along=21]="Along",x[x.Plus90=22]="Plus90",x[x.Minus90=23]="Minus90",x[x.Opposite=24]="Opposite",x[x.Upright=25]="Upright",x[x.Plus90Upright=26]="Plus90Upright",x[x.Minus90Upright=27]="Minus90Upright",x[x.Upright45=28]="Upright45",x))(Vi||{}),Ks=(x=>(x[x.None=0]="None",x[x.Vertical=1]="Vertical",x[x.Horizontal=2]="Horizontal",x[x.Both=3]="Both",x))(Ks||{});class J{n;Ep;Up;pa;w;so;ft;ct;hi;Zt;Vp;Zs;Nt;cs;il;ya;Me;Th;et;Xt;sl;ve;Ke;wd;de;xd;Ot;he;nl;A1;wa;df;constructor(){V.Je(this),this.n=30723,this.Zt=1,this.Vp="",this.Zs=null,this.Nt=null,this.ct=new P(NaN,NaN).k(),this.cs=nt.jw,this.il=new Nt,this.ya=new Nt,this.Me=null,this.Th=1,this.et=1,this.Xt=0,this.sl=Dt.em,this.hi=new I(NaN,NaN,NaN,NaN).k(),this.ve=new I(NaN,NaN,NaN,NaN).k(),this.Ke=new I(0,0,NaN,NaN).k(),this.wd=null,this.Ep=null,this.ft=null,this.de=T.Default,this.xd=T.Default,this.Up=0,this.pa=0,this.Ot=null,this.w=null,this.so=null,this.he=null,this.A1=null,this.wa=null,this.nl=null,this.df=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Zt=this.Zt,t.Vp=this.Vp,t.Nt=this.Nt,t.ct.h(this.ct),t.cs=this.cs.C(),this.Me!==null?t.Me=this.Me.copy():t.Me=null,t.et=this.et,t.Xt=this.Xt,t.sl=this.sl.C(),t.hi.h(this.hi),t.ve.h(this.ve),t.Ke.h(this.Ke),t.Ep=this.Ep,this.ft!==null&&(t.ft=this.ft.copy()),t.de=this.de.C(),t.xd=this.xd.C(),t.Up=this.Up,t.pa=this.pa,this.Ot!==null&&(t.Ot=this.Ot.copy()),this.w!==null&&(this.w.me?t.w=this.w:t.w=this.w.copy()),this.so!==null&&(t.so=this.so.slice()),this.he!==null&&(t.he=this.he.copy())}addCopyProperty(t){let e=this.so;if(!Array.isArray(e))e=[],this.so=e;else for(let i=0;i<e.length;i++)if(e[i]===t)return;e.push(t)}Ho(t){t.wd=null,t.nl=null,t.f()}clone(){let t=new this.constructor;return this.cloneProtected(t),this.jT(t),t}jT(t){if(this.so!==null)for(let e=0;e<this.so.length;e++){let i=this.so[e];t[i]=this[i]}}rI(){if(this.so!==null)for(let t=0;t<this.so.length;t++){let e=this.so[t];delete this[e]}}copy(){return this.clone()}WS(){let t=this.Fe;if(t!==null){this.Fe=null;for(let e of t)e.bd()&&(e.isToData?this.themeData(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter):e.isToObject?this.themeObject(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter,e.sourceName):e.isToModel?this.themeModel(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter):this.theme(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter))}return this}fe(t){t in Vi?this.segmentOrientation=t:t in Bi?this.stretch=t:m.ur(this,t)}toString(){return m.Yn(this.constructor)+"#"+V.xs(this)}static None=0;static Default=1;static Fill=2;static Vertical;static Horizontal;static Uniform=6;static UniformToFill=7;static FlipVertical=1;static FlipHorizontal=2;static FlipBoth=3;xa(){this.w!==null&&(this.w.me=!0)}Yt(){return this.w===null?this.w=new Ke:this.w.me&&(this.w=this.w.copy()),this.w}$i(){if(this.ft===null){let t=new Ni;t.Dh=T.None,t.vh=T.None,t.Fh=10,t.Rh=10,t.Oh=0,t.Ih=0,this.ft=t}return this.ft}raiseChangedEvent(t,e,i,s,n,o,r){let a=this.part;if(a!==null){a.gf(t,e,i,s,n,o,r),i===this&&t===2&&this.mf()&&this.Eh(a,e);let h=this.diagram;if(this.Ts!==null&&h!==null&&h.Za&&!h.undoManager.isUndoingRedoing&&!h.animationManager.Uu){let l=this.Ts.get(e);if(l!==null&&h.animationManager.isEnabled&&!h.animationManager.isTicking){this.df===null&&(this.df=new Mt);let u=h.undoManager.transactionLevel===0;if(l.startCondition===2?u=!0:l.startCondition===3&&(u=!1),u){let c=new xe;l.OR(c);let d=this.df.get(l);d!==null&&d.stop(),this.df.set(l,c),c.Zx=this,c.AM=l,c.add(this,e,s,n),c.start()}else h.animationManager.getBundleAnimation().add(this,e,s,n)}}if(this instanceof G&&i===a&&a.SC()&&a.data!==null){let l=this.D.r,u=l.length;for(let c=0;c<u;c++){let d=l[c];d instanceof G&&d.Sn(f=>{f.data!==null&&f.SC()&&f.updateTargetBindings(e)})}}}}DR(t){this.df&&this.df.delete(t)}Go(){if(this.diagram!==null&&this.findBindingPanel()===null&&this.Fe!==null){let t=this.diagram.model,e=this.Fe.iterator;for(;e.next();){let i=e.value;if(!i.isToTheme)continue;let s=null,n=i.sourceName;i.isToObject&&(s=this.WT(n));let o=this,r=i.targetId;r!==-1&&(o=this.Bp(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),i.updateTarget(o,s,void 0,t))}}}Eh(t,e){let i=this.findBindingPanel();if(i!==null){let s=t.diagram,n=this.Fe.iterator;for(;n.next();){let o=n.value,r=null;if(o.isToObject){if(r=o.JT(i,this),r===null)continue;o.updateSource(this,r,e,null)}else if(o.isToModel)s!==null&&!s.wi&&o.updateSource(this,s.model.modelData,e,i);else if(!o.isToTheme){let a=i.data;if(a===null)continue;s!==null&&!s.wi&&o.updateSource(this,a,e,i)}if(r===this){let a=o.targetId,h=i.Bp(a);h!==null&&o.updateTarget(h,r,e,s?.model)}}}}Bp(t){return this.no===t?this:null}WT(t){let e;return t===""?e=this:t==="/"?e=this:t==="."?e=this:t===".."?e=this:e=this.part.findObject(t),e}get no(){return this.w!==null?this.w.no:-1}set no(t){this.no!==t&&(this.w===null&&(this.w=new Ke),this.w.no=t)}get Fe(){return this.w!==null?this.w.Fe:null}set Fe(t){this.Fe!==t&&(this.w===null&&(this.w=new Ke),this.w.Fe=t)}get oo(){return this.w!==null?this.w.oo:null}set oo(t){this.oo!==t&&(this.w===null&&(this.w=new Ke),this.w.oo=t)}raiseChanged(t,e,i){this.raiseChangedEvent(2,t,this,e,i)}t(t,e,i){this.raiseChangedEvent(2,t,this,e,i)}ro(t,e,i,s){let n=this.hi;if(n.e(t,e,i,s),this.et!==1||this.Xt!==0){this.Me===null&&(this.Me=new Nt);let o=this.Me;o.Ue(),this.zp(o,t,e,i,s),o.im(n)}}$T(t,e,i){return this.pickable===!1?!1:(i.bc(this.v),e?this.intersectsRect(t,i):this.containedInRect(t,i))}ZT(t,e,i){if(this.pickable===!1)return!1;let s=this.naturalBounds,n=t.distanceSquaredPoint(e);return i?P.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||P.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||P.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||P.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}Cn(){return!0}containsPoint(t){let e=P.l();e.h(t),this.v.gt(e);let i=this.actualBounds;if(!i.isReal())return P.i(e),!1;let s=this.diagram;if(s!==null&&s.fp){let o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),a=r/2,h=this.naturalBounds,l=this.getDocumentScale()*s.scale,u=1/l;if(h.width*l<o&&h.height*l<o){let c=I.contains(i.x-a*u,i.y-a*u,i.width+r*u,i.height+r*u,e.x,e.y);return P.i(e),c}}let n=!1;return(this instanceof vt||this instanceof it?I.contains(i.x-5,i.y-5,i.width+10,i.height+10,e.x,e.y):i.containsPoint(e))&&(this.he&&!this.he.containsPoint(e)?n=!1:this.Nt!==null&&this.Ke.containsPoint(t)?n=!0:n=this.ba(t)),P.i(e),n}ba(t){let e=this.naturalBounds;return I.contains(0,0,e.width,e.height,t.x,t.y)}containsRect(t){if(this.angle===0)return this.actualBounds.containsRect(t);let e=this.naturalBounds,i=I.z(0,0,e.width,e.height),s=this.v,n=!1,o=P.z(t.x,t.y);return i.containsPoint(s.Ni(o))&&(o.e(t.x,t.bottom),i.containsPoint(s.Ni(o))&&(o.e(t.right,t.bottom),i.containsPoint(s.Ni(o))&&(o.e(t.right,t.y),i.containsPoint(s.Ni(o))&&(n=!0)))),P.i(o),I.i(i),n}containedInRect(t,e){if(e===void 0)return t.containsRect(this.actualBounds);let i=this.naturalBounds,s=e,n=!1,o=P.z(0,0);return t.containsPoint(s.gt(o))&&(o.e(0,i.height),t.containsPoint(s.gt(o))&&(o.e(i.width,i.height),t.containsPoint(s.gt(o))&&(o.e(i.width,0),t.containsPoint(s.gt(o))&&(n=!0)))),P.i(o),n}intersectsRect(t,e){if(e===void 0&&(e=this.v,this.angle===0))return t.intersectsRect(this.actualBounds);let i=this.naturalBounds,s=e,n=P.z(0,0),o=P.z(0,i.height),r=P.z(i.width,i.height),a=P.z(i.width,0),h=!1;if(t.containsPoint(s.gt(n))||t.containsPoint(s.gt(o))||t.containsPoint(s.gt(r))||t.containsPoint(s.gt(a)))h=!0;else{let l=I.z(0,0,i.width,i.height),u=P.z(t.x,t.y);l.containsPoint(s.Ni(u))?h=!0:(u.e(t.x,t.bottom),l.containsPoint(s.Ni(u))?h=!0:(u.e(t.right,t.bottom),l.containsPoint(s.Ni(u))?h=!0:(u.e(t.right,t.y),l.containsPoint(s.Ni(u))&&(h=!0)))),P.i(u),I.i(l),h||(C.tx(t,n,o)||C.tx(t,o,r)||C.tx(t,r,a)||C.tx(t,a,n))&&(h=!0)}return P.i(n),P.i(o),P.i(r),P.i(a),h}getDocumentPoint(t,e){if(e===void 0&&(e=new P),t instanceof T){let i=t,s=this.naturalBounds;return e.e(i.x*s.width+i.offsetX,i.y*s.height+i.offsetY),this.Js.gt(e),e}else return e.set(t),this.Js.gt(e),e}getDocumentBounds(t){t===void 0&&(t=new I);let e=this.naturalBounds,i=this.Js,s=P.z(0,0).v(i);return t.e(s.x,s.y,0,0),s.e(e.width,0).v(i),t.re(s.x,s.y,0,0),s.e(e.width,e.height).v(i),t.re(s.x,s.y,0,0),s.e(0,e.height).v(i),t.re(s.x,s.y,0,0),P.i(s),t}getDocumentAngle(){return this.Js.KF()}getDocumentScale(){if(this.Xp()===!1)return this.Th;let t=this.et;return this.panel!==null?t*this.panel.getDocumentScale():t}getLocalPoint(t,e){return e===void 0&&(e=new P),e.h(t),this.Js.Ni(e),e}getNearestIntersectionPoint(t,e,i){return this.pf(t.x,t.y,e.x,e.y,i)}pf(t,e,i,s,n){let o=this.v,r=1/(o.m11*o.m22-o.m12*o.m21),a=o.m22*r,h=-o.m12*r,l=-o.m21*r,u=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),d=r*(o.m12*o.dx-o.m11*o.dy),f=t*a+e*l+c,p=t*h+e*u+d,g=i*a+s*l+c,y=i*h+s*u+d;n.e(0,0);let b=this.naturalBounds,v=C.Al(0,0,b.width,b.height,f,p,g,y,n);return n.v(o),v}ht(t,e,i,s){if(this.Xo()===!1)return;let n=this.sl,o=n.right+n.left,r=n.top+n.bottom;t=Math.max(t-o,0),e=Math.max(e-r,0),i=i||0,s=s||0,i=Math.max(i-o,0),s=Math.max(s-r,0);let a=this.angle,h=0,l=this.desiredSize,u=this.Gp();a===90||a===270?(t=isFinite(l.height)?l.height+u:t,e=isFinite(l.width)?l.width+u:e):(t=isFinite(l.width)?l.width+u:t,e=isFinite(l.height)?l.height+u:e);let c=i||0,d=s||0,f=this instanceof G;switch(this.Qs(!0)){case 0:c=0,d=0,f&&(t=1/0,e=1/0);break;case 2:isFinite(t)&&t>i&&(c=t),isFinite(e)&&e>s&&(d=e);break;case 5:isFinite(t)&&t>i&&(c=t),d=0,f&&(e=1/0);break;case 4:isFinite(e)&&e>s&&(d=e),c=0,f&&(t=1/0);break}let p=this.maxSize,g=this.minSize;c>p.width&&g.width<p.width&&(c=p.width),d>p.height&&g.height<p.height&&(d=p.height),i=Math.max(c,g.width),s=Math.max(d,g.height),p.width<i&&(i=Math.min(g.width,i)),p.height<s&&(s=Math.min(g.height,s)),t=Math.min(p.width,t),e=Math.min(p.height,e),t=Math.max(i,t),e=Math.max(s,e),(a===90||a===270)&&(h=t,t=e,e=h,h=i,i=s,s=h),this.hi.ce(),this.kd(t,e,i,s),this.hi.k(),this.hi.isReal()||m.o("Non-real measuredBounds has been set. Object "+this+", measuredBounds: "+this.hi.toString()),this.xi(!1)}kd(t,e,i,s){}_s(){return!1}Ut(t,e,i,s,n){this.yf();let o=I.l();o.h(this.ve),this.ve.ce(),this.as()===!1?this.ve.e(t,e,i,s):this.ka(t,e,i,s),this.ve.k(),n===void 0?this.he=null:this.he=n;let r=!1;if(n!==void 0)r=!0;else{let a=this.panel;if(a!==null&&a.ol()&&(a=a.panel),a!==null){let h=a.Ke,l=this.measuredBounds,u=e+l.height,c=t+l.width;if(r=!(0<=t+.05&&c<=h.width+.05&&0<=e+.05&&u<=h.height+.05),this instanceof lt){let d=this.naturalBounds;(this.Yp>d.height||this.pe>d.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.ve.isReal()||m.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.ve.toString()),this.Pd(o,this.ve),this.lo(!1),I.i(o)}ka(t,e,i,s){}commonArrange(t,e,i,s){if(this.ve.e(t,e,i,s),this.desiredSize.isReal())return;let n=this.hi,o=this.sl,r=o.right+o.left,a=o.top+o.bottom,h=n.width+r,l=n.height+a;i+=r,s+=a;let u=this.Qs(!0);switch(h===i&&l===s&&(u=0),u){case 0:(h>i||l>s)&&(this.xi(!0),this.ht(h>i?i:h,l>s?s:l,0,0));break;case 2:this.xi(!0),this.ht(i,s,0,0);break;case 5:this.xi(!0),this.ht(i,l,0,0);break;case 4:this.xi(!0),this.ht(h,s,0,0);break}}Pd(t,e){let i=this.part;i!==null&&i.diagram!==null&&((i.selectionObject===this||i.resizeObject===this||i.rotateObject===this)&&i.MC(!0),this.N(),!t.equalsApproxClose(e)&&(i.Pa(),this.Kp(i)))}Kp(t){this.portId!==null&&(t.MC(!0),t instanceof $&&t.invalidateConnectedLinks(void 0,this))}get shadowVisible(){return this.w!==null?this.w.Hp:null}set shadowVisible(t){let e=this.shadowVisible;e!==t&&(this.Yt().Hp=t,this.Zi(!0),this.N(),this.t("shadowVisible",e,t))}lI(t,e){let i=this.naturalBounds,s=this.ya,n=s.m11,o=s.m21,r=s.dx,a=s.m12,h=s.m22,l=s.dy,u=0,c=0,d=u,f=c;u=d*n+f*o+r,c=d*a+f*h+l;let p=u,g=c,y=0,b=0;d=i.width+e,f=0,u=d*n+f*o+r,c=d*a+f*h+l;let v=Math.min(p,u),w=Math.min(g,c);y=Math.max(p+y,u)-v,b=Math.max(g+b,c)-w,p=v,g=w,d=i.width+e,f=i.height+e,u=d*n+f*o+r,c=d*a+f*h+l,v=Math.min(p,u),w=Math.min(g,c),y=Math.max(p+y,u)-v,b=Math.max(g+b,c)-w,p=v,g=w,d=0,f=i.height+e,u=d*n+f*o+r,c=d*a+f*h+l,v=Math.min(p,u),w=Math.min(g,c),y=Math.max(p+y,u)-v,b=Math.max(g+b,c)-w,p=v,g=w;let k=t.viewportBounds,S=k.x,N=k.y,D=k.width,L=k.height;return p>D+S||S>y+p||g>L+N||N>b+g}Ge(t,e){if(this.aI(t,e)||!this.visible)return;let i=this.opacity;if(i===0)return;let s=1;i!==1&&(s=t.globalAlpha,t.globalAlpha=s*i);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);let o=this.v,r=this.panel;this.Xp()===!0&&this.T1();let a=this.part,h=!1,l=0;if(a&&e.getRenderingHint("drawShadows")&&(h=a.isShadowed,h)){let g=a.shadowOffset;l=Math.max(g.y,g.x)*e.scale*e.$e}let u=this instanceof G&&this.ol(),c=this.ve;if(u&&(this.QT(h,t,!1,r),this.hI(t,e),this._T(h,t,!1,r),this.tD(h,t,!1)),u||!u&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=this._s();if(!e.mh&&d&&this.lI(e,l)){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let f=(this.n&256)!==0;if(t.clipInsteadOfFill&&(f=!1),this instanceof lt&&(t.font=this.font),f){let g=r.Cn()?r.naturalBounds:r.actualBounds,y=Math.max(c.x,g.x),b=Math.max(c.y,g.y),v=Math.min(c.right,g.right)-y,w=Math.min(c.bottom,g.bottom)-b,k=this.he;if(k!==null&&(y=k.x,b=k.y,v=k.width,w=k.height),y>c.width+c.x||c.x>g.width+g.x){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(y,b,v,w),t.clip()}if(d){if(!a.isVisible()){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){let g=a.shadowOffset;t.shadowsSet(g.x*e.scale*this.scale*e.$e,g.y*e.scale*this.scale*e.$e,a.shadowBlur),t.shadowsOn(),t.shadowColor=a.shadowColor}}let p=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.QT(h,t,d,r),this.Nt!==null&&(t.commitTransform(),this.D1(t,p,c)),this._T(h,t,d,r),this.Sa(t,e),this.tD(h,t,d),f&&(t.restore(),t.clearContextCache(this instanceof G)),!o.TP()){let g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}QT(t,e,i,s){t&&this.shadowVisible===!0?e.shadowsOn():t&&this.shadowVisible===!1&&e.shadowsOff(),t&&this.v1(s)&&this.shadowVisible===null&&e.shadowsOff()}_T(t,e,i,s){t&&(this.Nt!==null||this.v1(s))?(this.F1(!0),this.shadowVisible===null&&e.shadowsOff()):this.F1(!1)}tD(t,e,i){t&&this.CC()===!0&&e.shadowsOn(),i&&t&&e.shadowsOff()}cI(t,e,i){let s=this.part,n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),e.clipInsteadOfFill&&(n=!1),this._s()&&n&&e.shadowsOn(),n&&this.shadowVisible===!0?e.shadowsOn():n&&this.shadowVisible===!1&&e.shadowsOff();let o=this.panel;if(n&&this.v1(o)&&this.shadowVisible===null&&e.shadowsOff(),e.rl){let r=t.computePixelRatio(),a=`drop-shadow(${e.shadowOffsetX/r}px ${e.shadowOffsetY/r}px ${e.shadowBlur/r/2}px ${e.shadowColor})`;this.background!==null&&i.Nt.setAttributeNS(null,"filter",a)}return n&&(this.Nt!==null||this.v1(o))?(this.F1(!0),this.shadowVisible===null&&e.shadowsOff()):this.F1(!1),n}fI(t,e,i,s){if(i.rl){let n=e.computePixelRatio(),o=`drop-shadow(${i.shadowOffsetX/n}px ${i.shadowOffsetY/n}px ${i.shadowBlur/n/2}px ${i.shadowColor})`;this.NC(t,o)}s&&this.CC()===!0&&i.shadowsOn(),this._s()&&i.shadowsOff()}v1(t){return t===null?!1:(t.ol()&&(t=t.panel),t.CC()||(t.type===G.Auto||t.type===G.Spot)&&t.findMainElement()!==this)}NC(t,e){}D1(t,e,i){let s=this.Gp(),n=e.x,o=e.y,r=e.width+s,a=e.height+s;this.kn(t,this.Nt,!0,!1,e,i),this.Nt instanceof R&&this.Nt.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,a),t.fillContext(this.Nt,!1,null)):t.fillRect(n-s/2,o-s/2,r,a)}eD(t,e){let i=t.uI(this),s=t.wa!==null?t.wa:t.svg;if(s!==null&&i!==-1){for(;i!==0&&!t.elt(i-1).isVisibleObject();)i--;if(i===0)this.dI(t,e,s);else{let n=t.elt(i-1).svg;n!==null?n.after(e):s.appendChild(e)}}}dI(t,e,i){if(t.type===G.Table){let s=i.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(e)}else i.Nt?i.Nt.after(e):i.prepend(e)}aI(t,e){if(!(t instanceof ae))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;let i=this.ve;if(this._s()&&(!this.isVisible()||i.width===0||i.height===0||isNaN(i.x)||isNaN(i.y)))return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;t.setCurrentTransform(1,0,0,1,0,0);let s=this.panel,n=this.Sd(t);if(this.wf(t,e,n))return this.iD(this.svg),this.svg.parentElement!==null?(this._s()&&(t.lastDrawnPart=this.svg),!0):(this._s()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):s&&this.eD(s,this.svg),!0);if(this.Zi(!1),this._s()&&this.isShadowed){let p=this.shadowOffset;t.shadowsSet(p.x*e.scale*this.scale*e.$e,p.y*e.scale*this.scale*e.$e,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof lt&&(t.font=this.font),t.currentElement=null;let o=this.v,r=this instanceof G,a=this instanceof G?this.ol():!1,h=this.svg;if(this.Xp()===!0&&this.T1(),t.outerGroup=!1,n)if(t.outerGroup=!0,r&&a)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(r&&this.isClipping){let p=this.findMainElement(),g=0,y=0;p!==null&&(g=p.actualBounds.x,y=p.actualBounds.y),t.newGroup(o.m11,o.m12,o.m21,o.m22,o.dx+g,o.dy+y),this.svg=t.lastCreatedElement,p!==null&&t.createOrUpdateClipGroup(this,p.actualBounds),t.currentElement=t.lastCreatedElement}else r?(t.newGroup(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);let l=this.naturalBounds;r||t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.background!==null&&(r?(a&&t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.D1(t,l,i),a&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.D1(t,l,i)),t.currentElement.Nt=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));let u=this.cI(e,t,t.currentElement);this.Sa(t,e),r&&t.endGroup(),t.outerGroup&&t.endGroup();let c=t.surface.dd,d=r?this.svg:t.currentElement;if(h!==null&&h.parentNode!==null&&d!==h&&(this.panel===null||h.parentNode===this.panel.svg)){let p=this.svg.getAttribute("filter");return p!==null&&d.setAttribute("filter",p),this.filter!==""&&d.setAttributeNS(null,"filter",this.filter),h.replaceWith(d),this.svg=d,d!==null&&this.qp(t,s,i,d),!0}if(this.svg=d,c!==null&&d===null&&t.dummyGroup(),d===null)return!0;this.qp(t,s,i,d),this.fI(d,e,t,u);let f=this._s()?this.opacity*t.globalAlpha:this.opacity;if(f!==1&&d.setAttributeNS(null,"opacity",f.toString()),this.filter!==""&&d.setAttributeNS(null,"filter",this.filter),this._s()){if(h!==null&&d!==h&&h.parentNode===t.diagramGroup){let p=h.getAttribute("filter");p!==null&&d.setAttribute("filter",p),h.replaceWith(d)}else t.lastDrawnPart?t.lastDrawnPart.after(d):t.diagramGroup.prepend(d);t.lastDrawnPart=d}else s!==null&&this.eD(s,d);return c!==null&&c(this,d),this.iD(d),!0}iD(t){let e=this,i=t.dataset;e instanceof J&&(e.portId!==null&&(i.portId=e.portId),e instanceof G&&(isNaN(e.itemIndex)||(i.itemIndex=e.itemIndex.toString()),e instanceof pt&&(i.className=m.Yn(e),e.key!==void 0&&(i.key=e.key.toString()),e.containingGroup!==null&&(i.group=e.containingGroup.key.toString()),e instanceof j&&(e.fromNode!==null&&e.fromNode.key!==void 0&&(i.fromKey=e.fromNode.key.toString()),e.fromPortId!==""&&(i.fromPortId=e.fromPortId),e.toNode!==null&&e.toNode.key!==void 0&&(i.toKey=e.toNode.key.toString()),e.toPortId!==""&&(i.toPortId=e.toPortId)))))}qp(t,e,i,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path");return}let o=e.Cn()?e.naturalBounds:e.actualBounds,r=Math.max(i.x,o.x),a=Math.max(i.y,o.y),h=Math.min(i.right,o.right)-r,l=Math.min(i.bottom,o.bottom)-a,u=this.he;u!==null&&(r=u.x,a=u.y,h=u.width,l=u.height);let c=I.z(r,a,Math.max(h,0),Math.max(l,0));if(this instanceof G){let d=Nt.l();d.set(this.v),d.Zw(),d.im(c),Nt.i(d)}s.setAttributeNS(null,"clip-path",`path(' M ${c.x},${c.y} L ${c.width+c.x} ${c.y} L ${c.width+c.x} ${c.height+c.y} L ${c.x} ${c.height+c.y} z') view-box`),I.i(c)}gI(){if(this.svg===null)return;let t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),e=this.svg.ownerDocument;if(t!==null)for(let i of t){let s=e.getElementById(i.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}hI(t,e){let i=this.ve,s=this.Ke,n=this.Nt;n!==null&&t.commitTransform(),n!==null&&(this.kn(t,n,!0,!1,s,i),n instanceof R&&n.type===3?(t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fillContext(n,!1,null)):t.fillRect(i.x,i.y,i.width,i.height)),this.Sa(t,e)}Sa(t,e){}xf(){this.Zi(!0)}wf(t,e,i){let s=this.svg;if(this.mI()){if(this.xf(),this.Zi(!1),s===null)return!1;let u=s.getAttribute("clip-path");if(u!==null&&u.includes("url")){let c=t.svg.getElementById(u.split("#")[1].slice(0,-1));c!==null&&c.remove()}return s.getAttribute("filter")&&s.removeAttribute("filter"),!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&i||s.nodeName==="g"&&!i)return!1;let n=this.v,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof G,a=r?this.ol():!1;if(!(r&&a))if(this instanceof Bt){let u=this.R1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),u!==null&&t.amendImageTransform(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7]),i?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(i&&!r)if(this instanceof it){let u=s.getElementsByTagName("path");for(let c=0;c<u.length;c++)u[c].setAttributeNS(null,"transform",o)}else if(this instanceof lt){let u=s.getElementsByTagName("text"),c=typeof this.stroke=="string"?this.stroke:null;for(let d=0;d<u.length;d++)u[d].setAttributeNS(null,"transform",o),c&&u[d].setAttributeNS(null,"fill",c)}else(s.lastElementChild||s).setAttributeNS(null,"transform",o);else if(r&&this.isClipping&&this.wa){let u=this.findMainElement(),c=u!==null?u.actualBounds.x:0,d=u!==null?u.actualBounds.y:0;this.wa.setAttributeNS(null,"transform","matrix(1,0,0,1,"+-c+", "+-d+")"),s.setAttributeNS(null,"transform","matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+(n.dx+c)+", "+(n.dy+d)+")")}else s.setAttributeNS(null,"transform",o);let h=this._s()?this.opacity*t.globalAlpha:this.opacity;h===1?s.removeAttribute("opacity"):s.setAttributeNS(null,"opacity",h.toString()),t.setCurrentTransform(1,0,0,1,0,0);let l=this.wa?this.wa:this.A1;if(this.background!==null||l.Nt!==void 0){let u=l.Nt;if(this.background===null)t.removeOldGradient(this,l.Nt,"fill"),l.Nt.remove(),l.Nt=void 0;else{if((a||i&&!(this instanceof G))&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.D1(t,this.naturalBounds,this.actualBounds),l.Nt){t.removeOldGradient(this,l.Nt,"fill");let c=l.Nt.getAttribute("filter");c!==null&&t.lastCreatedElement.setAttribute("filter",c),l.Nt.replaceWith(t.lastCreatedElement)}else l.prepend(t.lastCreatedElement);l.Nt=t.lastCreatedElement}u&&t.removeOldGradient(this,u,"fill")}return this.qp(t,this.panel,this.actualBounds,s),!0}Sd(t){if(this.background!==null)return!0;let e=(this.n&256)!==0;return t.clipInsteadOfFill&&(e=!1),!!e}static VU(t,e,i,s,n,o,r){let a=.001,h=o.length;t.moveTo(e,i);let l=s-e,u=n-i;l===0&&(l=.001);let c=u/l,d=Math.sqrt(l*l+u*u),f=0,p=!0;a=o[f%h];let g=r!==0;for(;d>=.1;){if(g){for(a=o[f++%h],a-=r;a<0;)a+=o[f++%h],p=!p;g=!1}else a=o[f++%h];a>d&&(a=d);let y=Math.sqrt(a*a/(1+c*c));l<0&&(y=-y),e+=y,i+=c*y,p?t.lineTo(e,i):t.moveTo(e,i),d-=a,p=!p}}kn(t,e,i,s,n,o){let r=1,a=1;if(typeof e=="string"){i?t.fillStyle=e:t.strokeStyle=e;return}else if(e.type===1){i?t.fillStyle=e.color:t.strokeStyle=e.color;return}let h,l=this.Gp();r=n.width,a=n.height,s?(r=o.width,a=o.height):i||(r+=l,a+=l);let u=t instanceof ci;if(u&&e.Nn&&(e.type===4||e.bf===r&&e.O1===a))h=e.Nn;else{let c=0,d=0,f=0,p=0,g=0,y=0,b=0,v=0;if(s?(b=o.x,v=o.y):i||(b-=l/2,v-=l/2),c=e.start.x*r+e.start.offsetX+b,d=e.start.y*a+e.start.offsetY+v,f=e.end.x*r+e.end.offsetX+b,p=e.end.y*a+e.end.offsetY+v,e.type===2)h=t.createLinearGradient(c,d,f,p);else if(e.type===3)y=isNaN(e.endRadius)?Math.max(r,a)/2:e.endRadius,isNaN(e.startRadius)?(g=0,y=Math.max(r,a)/2):g=e.startRadius,h=t.createRadialGradient(c,d,g,f,p,y);else if(e.type===4)try{h=t.createPattern(e.pattern,"repeat")}catch{h=null}else m.si(e.type,"Brush type");if(e.type!==4){let w=e.colorStops;if(w!==null){let k=w.iterator;for(;k.next();)h.addColorStop(k.key,k.value)}}if(u&&(e.Nn=h,h!==null&&(e.bf=r,e.O1=a),h===null&&e.type===4&&e.bf!==-1)){e.bf=-1;let w=this.diagram;w!==null&&e.bf===-1&&m.dn(()=>{w.redraw()},600)}}i?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof G?this.pI(this,t):!1}pI(t,e){if(t===e||e===null)return!1;let i=t.panel;for(;i!==null;){if(i===e)return!0;i=i.panel}return!1}isVisibleObject(){if(!this.visible)return!1;let t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof G?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.w!==null?this.w.jp:null}set enabledChanged(t){let e=this.enabledChanged;e!==t&&(t!==null&&m.S(t,J,"enabledChanged"),this.Yt().jp=t,this.t("enabledChanged",e,t))}T1(){if(this.I1()===!0){let t=this.il;if(t.Ue(),!this.ve.isReal()||!this.hi.isReal()){this.Md(!1),this.Ma(!1);return}if(t.Gs(this.ve.x-this.hi.x,this.ve.y-this.hi.y),this.scale!==1||this.angle!==0){let e=this.naturalBounds;this.zp(t,e.x,e.y,e.width,e.height)}this.Md(!1),this.Ma(!0)}if(this.Xp()===!0){let t=this.panel;if(t===null)this.ya.set(this.il),this.Th=this.scale;else if(t.Js!==null){let e=this.ya;e.Ue(),t.Cn()?e.bc(t.ya):t.panel!==null&&e.bc(t.panel.ya),e.bc(this.il),this.Th=this.scale*t.Th}this.Ma(!1)}}zp(t,e,i,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;let o=P.l();o.setSpot(e,i,s,n,T.Center),t.ks(this.Xt,o.x,o.y),P.i(o)}f(t){if(this.Xo())return;t===void 0&&(t=!1),this.xi(!0),this.lo(!0);let e=this.panel;e!==null&&!t&&e.f()}kf(){this.Xo()||(this.xi(!0),this.lo(!0))}Pf(t){if(this.as())return;let e=this.panel;!t&&e!==null&&e.f(),this.lo(!0)}yf(){this.I1()===!1&&(this.Md(!0),this.Ma(!0))}LC(){this.Ma(!0)}N(){let t=this.part;t!==null&&t.N()}Qs(t){let e=this.stretch,i=this.panel;if(i===null)return this.qo(e===1?0:e,t);if(i.type===G.Table)return this.Wp(i.getRowDefinition(this.row),i.getColumnDefinition(this.column),t);if(i.type===G.Auto&&i.findMainElement()===this)return this.qo(2,t);if(e===1){if(i.type===G.Spot&&i.findMainElement()===this)return this.qo(2,t);let s=i.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(e,t)}Wp(t,e,i){let s=this.stretch;if(s!==1)return this.qo(s,i);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(e.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}let r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,i):n===!0?this.qo(5,i):o===!0?this.qo(4,i):this.qo(0,i)}qo(t,e){if(e)return t;if(t===0)return 0;let i=this.desiredSize;if(i.isReal())return 0;let s=!isNaN(i.width),n=!isNaN(i.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ot!==null?this.Ot.Jp:0}set segmentOrientation(t){let e=this.segmentOrientation;e!==t&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.Jp=t,this.f(),this.t("segmentOrientation",e,t),t===0&&(this.angle=0))}yI(){this.segmentOrientation=21}get segmentIndex(){return this.Ot!==null?this.Ot.$p:-1/0}set segmentIndex(t){t=Math.round(t);let e=this.segmentIndex;e!==t&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.$p=t,this.f(),this.t("segmentIndex",e,t))}get segmentFraction(){return this.Ot!==null?this.Ot.Zp:0}set segmentFraction(t){t<0?t=0:t>1&&(t=1);let e=this.segmentFraction;e!==t&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.Zp=t,this.f(),this.t("segmentFraction",e,t))}get segmentOffset(){return this.Ot!==null?this.Ot.Qp:P.gn}set segmentOffset(t){let e=this.segmentOffset;e.equals(t)||(t=t.C(),this.Ot===null&&(this.Ot=new Oe),this.Ot.Qp=t,this.f(),this.t("segmentOffset",e,t))}get stretch(){return this.w!==null?this.w.ao:1}set stretch(t){let e=this.stretch;e!==t&&(this.Yt().ao=t,this.f(),this.t("stretch",e,t))}get name(){return this.w!==null?this.w.Pt:""}set name(t){let e=this.name;e!==t&&(this.Yt().Pt=t,this.part!==null&&this.part._p(),this.t("name",e,t))}get opacity(){return this.Zt}set opacity(t){t<0?t=0:t>1&&(t=1);let e=this.opacity;if(e!==t){this.Zt=t,this.t("opacity",e,t);let i=this.diagram,s=this.part;i!==null&&s!==null&&i.N(s.ah(s.actualBounds))}}get filter(){return this.Vp}set filter(t){let e=this.filter;if(e!==t){this.Vp=t,this.Zi(!0),this.t("filter",e,t);let i=this.diagram,s=this.part;i!==null&&s!==null&&i.N(s.ah(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){let e=(this.n&1)!==0;if(e!==t){this.n=this.n^1,this.xf(),this.t("visible",e,t);let i=this.panel;i!==null?i.f():this._s()&&this.Xe(t),this.N(),this.sD()}}get pickable(){return(this.n&2)!==0}set pickable(t){let e=(this.n&2)!==0;e!==t&&(this.n=this.n^2,this.t("pickable",e,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){let e=(this.n&4)!==0;e!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",e,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){let e=(this.n&8)!==0;e!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",e,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){let e=(this.n&16)!==0;e!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",e,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){let e=(this.n&32)!==0;e!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",e,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){let e=(this.n&64)!==0;e!==t&&(this.n=this.n^64,this.f(),this.t("isPanelMain",e,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){let e=(this.n&128)!==0;e!==t&&(this.n=this.n^128,this.t("isActionable",e,t))}get background(){return this.Nt}set background(t){let e=this.background;e!==t&&(t!==null&&R.Cd(t,"GraphObject.background"),t instanceof R&&t.k(),this.Nt=t,this.N(),this.t("background",e,t))}CC(){return(this.n&512)!==0}F1(t){t?this.n|=512:this.n&=-513}mf(){return(this.n&1024)!==0}AC(t){t?this.n|=1024:this.n&=-1025}I1(){return(this.n&2048)!==0}Md(t){t?this.n|=2048:this.n&=-2049}Xp(){return(this.n&4096)!==0}Ma(t){t?this.n|=4096:this.n&=-4097}Xo(){return(this.n&8192)!==0}xi(t){t?this.n|=8192:this.n&=-8193}as(){return(this.n&16384)!==0}lo(t){t?this.n|=16384:this.n&=-16385}mI(){return(this.n&32768)!==0}Zi(t){t?this.n|=32768:this.n&=-32769}get part(){if(this._s())return this;if(this.nl!==null)return this.nl;let t=this;for(t=t.panel;t;){if(t instanceof pt)return this.nl=t,t;t=t.panel}return null}get svg(){return this.A1}set svg(t){this.A1=t}Wc(){this.svg=null}get panel(){return this.Zs}Uh(t){this.Zs=t,this.svg!==null&&this.svg.remove()}get layer(){let t=this.part;return t!==null?t.layer:null}get diagram(){let t=this.part;return t!==null?t.diagram:null}get position(){return this.ct}set position(t){let e=t.x,i=t.y,s=this.position,n=s.x,o=s.y;n!==e&&(!isNaN(n)||!isNaN(e))||o!==i&&(!isNaN(o)||!isNaN(i))?(t=t.copy(),this.TC(t,n,o)&&this.t("position",new P(n,o),t.copy())):this.DC()}DC(){}TC(t,e,i){return this.ct=t,this.Pf(),!0}Uc(t,e,i){this.ct.x===t&&this.ct.y===e||(this.ct.e(t,e),this.yf())}get actualBounds(){return this.ve}get scale(){return this.et}set scale(t){let e=this.scale;e!==t&&(t<=0&&m.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.et=t,this.f(),this.t("scale",e,t))}get angle(){return this.Xt}set angle(t){let e=this.angle;if(e!==t){if(t=t%360,t<0&&(t+=360),e===t)return;this.Xt=t,this.sD(),this.f(),this.t("angle",e,t)}}get desiredSize(){return this.cs}set desiredSize(t){let e=t.width,i=t.height,s=this.desiredSize,n=s.width,o=s.height;if((n!==e&&(!isNaN(n)||!isNaN(e))||o!==i&&(!isNaN(o)||!isNaN(i)))&&(t=t.C(),this.cs=t,this.f(),this instanceof it&&this.ai(),this.t("desiredSize",s,t),this.mf())){let r=this.part;r!==null&&(this.Eh(r,"width"),this.Eh(r,"height"))}}get width(){return this.cs.width}set width(t){let e=this.cs.width;if(e!==t&&(!isNaN(e)||!isNaN(t))){let i=this.cs,s=new nt(t,this.cs.height).k();if(this.cs=s,this.f(),this instanceof it&&this.ai(),this.t("desiredSize",i,s),this.mf()){let n=this.part;n!==null&&this.Eh(n,"width")}}}get height(){return this.cs.height}set height(t){let e=this.cs.height;if(e!==t&&(!isNaN(e)||!isNaN(t))){let i=this.cs,s=new nt(this.cs.width,t).k();if(this.cs=s,this.f(),this instanceof it&&this.ai(),this.t("desiredSize",i,s),this.mf()){let n=this.part;n!==null&&this.Eh(n,"height")}}}get minSize(){return this.w!==null?this.w.Cr:nt.xc}set minSize(t){let e=this.minSize;e.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.k(),this.Yt().Cr=t,this.f(),this.t("minSize",e,t))}get maxSize(){return this.w!==null?this.w.Nr:nt.NP}set maxSize(t){let e=this.maxSize;e.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.k(),this.Yt().Nr=t,this.f(),this.t("maxSize",e,t))}get measuredBounds(){return this.hi}get naturalBounds(){return this.Ke}Gp(){return 0}get margin(){return this.sl}set margin(t){typeof t=="number"&&(t=new Dt(t));let e=this.sl;e.equals(t)||(t=t.C(),this.sl=t,this.f(),this.t("margin",e,t))}get v(){return this.I1()===!0&&this.T1(),this.il}get Js(){return this.Xp()===!0&&this.T1(),this.ya}trigger(t,e,i){let s=null;return typeof t=="string"?s=new ai(t,e,i):s=t,s.Ti=this,this.Ts===null&&(this.Ts=new Mt),this.Ts.set(s.propertyName,s),this}get Ts(){return this.w!==null?this.w.Ts:null}set Ts(t){this.Ts!==t&&(this.Yt().Ts=t)}get Mr(){return this.w!==null?this.w.Mr:0}set Mr(t){this.Mr!==t&&(this.Yt().Mr=t)}get alignment(){return this.de}set alignment(t){let e=this.alignment;e.equals(t)||(t.isNoSpot()&&!t.isDefault()&&m.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.C(),this.de=t,this.Pf(),this.t("alignment",e,t))}get column(){return this.pa}set column(t){t=Math.round(t);let e=this.column;e!==t&&(t<0&&m.J(t,">= 0",J,"column"),this.pa=t,this.f(),this.t("column",e,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.w!==null?this.w.t0:1}set columnSpan(t){t=Math.round(t);let e=this.columnSpan;e!==t&&(t<1&&m.J(t,">= 1",J,"columnSpan"),this.Yt().t0=t,this.f(),this.t("columnSpan",e,t))}get row(){return this.Up}set row(t){t=Math.round(t);let e=this.row;e!==t&&(t<0&&m.J(t,">= 0",J,"row"),this.Up=t,this.f(),this.t("row",e,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.w!==null?this.w.e0:1}set rowSpan(t){t=Math.round(t);let e=this.rowSpan;e!==t&&(t<1&&m.J(t,">= 1",J,"rowSpan"),this.Yt().e0=t,this.f(),this.t("rowSpan",e,t))}get spanAllocation(){return this.w!==null?this.w.i0:null}set spanAllocation(t){let e=this.spanAllocation;e!==t&&(t!==null&&m.S(t,J,"spanAllocation"),this.Yt().i0=t,this.f(),this.t("spanAllocation",e,t))}get alignmentFocus(){return this.xd}set alignmentFocus(t){let e=this.alignmentFocus;e.equals(t)||(t=t.C(),this.xd=t,this.f(),this.t("alignmentFocus",e,t))}get portId(){return this.Ep}set portId(t){let e=this.portId;if(e!==t){let i=this.part;i!==null&&!(i instanceof $)&&m.o("Cannot set portID on a Link: "+t);let s=i;e!==null&&s!==null&&s.vC(this),this.Ep=t,t!==null&&s!==null&&(s.Ln=!0,s.nD(this)),this.t("portId",e,t)}}Vh(){let t=this.part;if(t instanceof $&&(this.portId!==null||this===t.port)){let e=t.diagram;e!==null&&!e.undoManager.isUndoingRedoing&&t.invalidateConnectedLinks(void 0,this)}}sD(){let t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof G?this instanceof $?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,e=>{e.Vh()}):this.Vh())}get toSpot(){return this.ft!==null?this.ft.vh:T.None}set toSpot(t){let e=this.toSpot;e.equals(t)||(t=t.C(),this.$i().vh=t,this.t("toSpot",e,t),this.Vh())}get toEndSegmentLength(){return this.ft!==null?this.ft.Rh:10}set toEndSegmentLength(t){let e=this.toEndSegmentLength;e!==t&&(t<0&&m.J(t,">= 0",J,"toEndSegmentLength"),this.$i().Rh=t,this.t("toEndSegmentLength",e,t),this.Vh())}get toShortLength(){return this.ft!==null?this.ft.Ih:0}set toShortLength(t){let e=this.toShortLength;e!==t&&(this.$i().Ih=t,this.t("toShortLength",e,t),this.Vh())}get toLinkable(){return this.ft!==null?this.ft.s0:null}set toLinkable(t){let e=this.toLinkable;e!==t&&(this.$i().s0=t,this.t("toLinkable",e,t))}get toMaxLinks(){return this.ft!==null?this.ft.o0:1/0}set toMaxLinks(t){let e=this.toMaxLinks;e!==t&&(t<0&&m.J(t,">= 0",J,"toMaxLinks"),this.$i().o0=t,this.t("toMaxLinks",e,t))}get fromSpot(){return this.ft!==null?this.ft.Dh:T.None}set fromSpot(t){let e=this.fromSpot;e.equals(t)||(t=t.C(),this.$i().Dh=t,this.t("fromSpot",e,t),this.Vh())}get fromEndSegmentLength(){return this.ft!==null?this.ft.Fh:10}set fromEndSegmentLength(t){let e=this.fromEndSegmentLength;e!==t&&(t<0&&m.J(t,">= 0",J,"fromEndSegmentLength"),this.$i().Fh=t,this.t("fromEndSegmentLength",e,t),this.Vh())}get fromShortLength(){return this.ft!==null?this.ft.Oh:0}set fromShortLength(t){let e=this.fromShortLength;e!==t&&(this.$i().Oh=t,this.t("fromShortLength",e,t),this.Vh())}get fromLinkable(){return this.ft!==null?this.ft.r0:null}set fromLinkable(t){let e=this.fromLinkable;e!==t&&(this.$i().r0=t,this.t("fromLinkable",e,t))}get fromMaxLinks(){return this.ft!==null?this.ft.l0:1/0}set fromMaxLinks(t){let e=this.fromMaxLinks;e!==t&&(t<0&&m.J(t,">= 0",J,"fromMaxLinks"),this.$i().l0=t,this.t("fromMaxLinks",e,t))}get cursor(){return this.w!==null?this.w.Ul:""}set cursor(t){let e=this.cursor;e!==t&&(m.s(t,"string",J,"cursor"),this.Yt().Ul=t,this.t("cursor",e,t))}get click(){return this.w!==null?this.w.Er:null}set click(t){let e=this.click;e!==t&&(t!==null&&m.S(t,J,"click"),this.Yt().Er=t,this.t("click",e,t))}get doubleClick(){return this.w!==null?this.w.Ur:null}set doubleClick(t){let e=this.doubleClick;e!==t&&(t!==null&&m.S(t,J,"doubleClick"),this.Yt().Ur=t,this.t("doubleClick",e,t))}get contextClick(){return this.w!==null?this.w.Vr:null}set contextClick(t){let e=this.contextClick;e!==t&&(t!==null&&m.S(t,J,"contextClick"),this.Yt().Vr=t,this.t("contextClick",e,t))}get mouseEnter(){return this.w!==null?this.w.Yr:null}set mouseEnter(t){let e=this.mouseEnter;e!==t&&(t!==null&&m.S(t,J,"mouseEnter"),this.Yt().Yr=t,this.t("mouseEnter",e,t))}get mouseLeave(){return this.w!==null?this.w.Kr:null}set mouseLeave(t){let e=this.mouseLeave;e!==t&&(t!==null&&m.S(t,J,"mouseLeave"),this.Yt().Kr=t,this.t("mouseLeave",e,t))}get mouseOver(){return this.w!==null?this.w.Br:null}set mouseOver(t){let e=this.mouseOver;e!==t&&(t!==null&&m.S(t,J,"mouseOver"),this.Yt().Br=t,this.t("mouseOver",e,t))}get mouseHover(){return this.w!==null?this.w.zr:null}set mouseHover(t){let e=this.mouseHover;e!==t&&(t!==null&&m.S(t,J,"mouseHover"),this.Yt().zr=t,this.t("mouseHover",e,t))}get mouseHold(){return this.w!==null?this.w.Xr:null}set mouseHold(t){let e=this.mouseHold;e!==t&&(t!==null&&m.S(t,J,"mouseHold"),this.Yt().Xr=t,this.t("mouseHold",e,t))}get mouseDragEnter(){return this.w!==null?this.w.a0:null}set mouseDragEnter(t){let e=this.mouseDragEnter;e!==t&&(t!==null&&m.S(t,J,"mouseDragEnter"),this.Yt().a0=t,this.t("mouseDragEnter",e,t))}get mouseDragLeave(){return this.w!==null?this.w.h0:null}set mouseDragLeave(t){let e=this.mouseDragLeave;e!==t&&(t!==null&&m.S(t,J,"mouseDragLeave"),this.Yt().h0=t,this.t("mouseDragLeave",e,t))}get mouseDrop(){return this.w!==null?this.w.Gr:null}set mouseDrop(t){let e=this.mouseDrop;e!==t&&(t!==null&&m.S(t,J,"mouseDrop"),this.Yt().Gr=t,this.t("mouseDrop",e,t))}get actionDown(){return this.w!==null?this.w.c0:null}set actionDown(t){let e=this.actionDown;e!==t&&(t!==null&&m.S(t,J,"actionDown"),this.Yt().c0=t,this.t("actionDown",e,t))}get actionMove(){return this.w!==null?this.w.f0:null}set actionMove(t){let e=this.actionMove;e!==t&&(t!==null&&m.S(t,J,"actionMove"),this.Yt().f0=t,this.t("actionMove",e,t))}get actionUp(){return this.w!==null?this.w.u0:null}set actionUp(t){let e=this.actionUp;e!==t&&(t!==null&&m.S(t,J,"actionUp"),this.Yt().u0=t,this.t("actionUp",e,t))}get actionCancel(){return this.w!==null?this.w.d0:null}set actionCancel(t){let e=this.actionCancel;e!==t&&(t!==null&&m.S(t,J,"actionCancel"),this.Yt().d0=t,this.t("actionCancel",e,t))}get toolTip(){return this.w!==null?this.w.Hr:null}set toolTip(t){let e=this.toolTip;e!==t&&(this.Yt().Hr=t,this.t("toolTip",e,t))}get contextMenu(){return this.w!==null?this.w.qr:null}set contextMenu(t){let e=this.contextMenu;e!==t&&(this.Yt().qr=t,this.t("contextMenu",e,t))}findBindingPanel(){let t=this instanceof G?this:this.panel;for(;t!==null;){if(t.FC())return t;t=t.panel}return null}bind(t,e,i,s){return this.Sf(t,e,i,s),this}bindTwoWay(t,e,i,s){return this.Sf(t,e,i,s).makeTwoWay(),this}bindModel(t,e,i,s){return this.Sf(t,e,i,s).ofModel(),this}bindObject(t,e,i,s,n){return this.Sf(t,e,i,s).ofObject(n),this}theme(t,e,i,s,n){return this.Ca(t,e,i,s,n),this}themeData(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofData(),this}themeObject(t,e,i,s,n,o){return this.Ca(t,e,i,s,n).ofObject(o),this}themeModel(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofModel(),this}Sf(t,e,i,s){let n=null;return typeof t=="string"?n=new ie(t,e,i,s):n=t,this.g0(n),n}Ca(t,e,i,s,n){let o=null;return typeof t=="string"?o=new ii(t,e,i,s,n):o=t,this.g0(o),o}g0(t){t.Ti=this;let e=this.findBindingPanel();e!==null&&e.oD()&&m.o("Cannot add a Binding to a template that has already been copied: "+t),this.Fe===null&&(this.Fe=new q),this.Fe.add(t)}set(t){return t?(Object.assign(this,t),this):this}attach(t){return J.RC(this,t),this}apply(t,...e){return t.apply(this,[this,...e]),this}setProperties(t){return Y.Mp(this,t),this}static make(t,...e){let i=arguments,s=null,n=null;if(m.it(t))n=t;else if(typeof t=="string"){let r=J.E1.get(t);m.it(r)?(i=Array.prototype.slice.call(i),s=r(i),m.$(s)||m.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=K.go[t]}s===null&&((n==null||!n.constructor)&&m.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Y&&i.length>1){let r=s,a=i[1];(typeof a=="string"||a instanceof HTMLDivElement)&&(r.g2(a),o++)}for(let r=o;r<i.length;r++){let a=i[r];a===void 0?m.o("Undefined value at argument "+r+" for object being constructed by GraphObject.make: "+s):s&&J.RC(s,a)}return s}static RC(t,e){if(typeof e=="number")J.wI(t,e);else if(typeof e=="string")J.xI(t,e);else if(e instanceof J)t instanceof G||m.o("A GraphObject can only be added to a Panel, not to: "+t),t.add(e);else if(e instanceof Kt){let i=null;e.isRow&&m.it(t.getRowDefinition)?i=t.getRowDefinition(e.index):!e.isRow&&m.it(t.getColumnDefinition)&&(i=t.getColumnDefinition(e.index)),i instanceof Kt?i.U1(e):m.o("A RowColumnDefinition can only be added to an object that implements getRowDefinition/getColumnDefinition, not to: "+t)}else if(e instanceof Lt){let i=t;i.type=e}else if(e instanceof ie)t instanceof J||t instanceof Kt?t.bind(e):m.o("A Binding can only be applied to a GraphObject or RowColumnDefinition, not to: "+t);else if(e instanceof ai)t instanceof J?t.trigger(e):m.o("An AnimationTrigger can only be applied to a GraphObject, not to: "+t);else if(e instanceof zt)t instanceof wt&&t.type===4?t.figures.add(e):m.o("A PathFigure can only be added to a Path Geometry, not to: "+t);else if(e instanceof mt)t instanceof zt?t.segments.add(e):m.o("A PathSegment can only be added to a PathFigure, not to: "+t);else if(e instanceof ee)t instanceof Y||t instanceof ht?t.layout=e:m.o("A Layout can only be assigned to a Diagram or a Group, not to: "+t);else if(Array.isArray(e))for(let i=0;i<e.length;i++){let s=e[i];J.RC(t,s)}else m.$(e)?J.bI(t,e):m.o('Unknown initializer "'+e+'" for object being constructed by GraphObject.make: '+t)}static xI(t,e){if(t instanceof lt)t.text=e;else if(t instanceof it)t.figure=e;else if(t instanceof Bt)t.source=e;else if(t instanceof G){let i=Lt.fs.get(e);i!==null&&(t.type=i)}else if(t instanceof R){let i=m.Ja(Fe,e);i!==null?t.type=i:m.o("Unknown Brush type as an argument to GraphObject.make: "+e)}else if(t instanceof wt){let i=m.Ja(Ve,e);i!==null&&(t.type=i)}else if(t instanceof mt){let i=m.Ja(ni,e);i!==null&&(t.type=i)}}static wI(t,e){m.it(t.fe)?t.fe(e):m.ur(t,e)}static bI(t,e){if(t instanceof R){let i=new yt;for(let s in e){let n=parseFloat(s);isNaN(n)?i[s]=e[s]:t.addColorStop(n,e[s])}Y.Mp(t,i)}else if(t instanceof Kt){if(e.row!==void 0){let s=e.row;(s==null||s===1/0||isNaN(s)||s<0)&&m.o("Must specify non-negative integer row for RowColumnDefinition "+e+", not: "+s),t.isRow=!0,t.index=s}else if(e.column!==void 0){let s=e.column;(s==null||s===1/0||isNaN(s)||s<0)&&m.o("Must specify non-negative integer column for RowColumnDefinition "+e+", not: "+s),t.isRow=!1,t.index=s}let i=new yt;for(let s in e)s==="row"||s==="column"||(i[s]=e[s]);Y.Mp(t,i)}else Y.Mp(t,e)}static build(t,e,...i){let s=J.E1.get(t);if(m.it(s)){let n=s([t].concat(i));if(n instanceof J)return e&&n.setProperties(e),n}m.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static defineBuilder(t,e){m.s(t,"string",J,"defineBuilder:name"),m.S(e,J,"defineBuilder:func");let i=t.toLowerCase();J.E1.set(t,e)}static isBuilderDefined(t){return J.E1.has(t)}static takeBuilderArgument(t,e,i){i===void 0&&(i=null);let s=t[1];return(m.it(i)?i(s):typeof s=="string")?(t.splice(1,1),s):(e===void 0&&m.o("no "+(m.it(i)?"satisfactory":"string")+" argument for GraphObject builder "+t[0]),e)}static E1=new Mt}J.Vertical=4,J.Horizontal=5,J.defineBuilder("Button",x=>{let t="#f5f5f5",e="#737373",i="#d4d4d4",s="#737373",n="#a3a3a3",o=2.76142374915397,r=2.761423749153969,a=new G(G.Auto,{isActionable:!0,enabledChanged:(h,l)=>{if(h instanceof G){let u=h.findObject("ButtonBorder");if(u!==null)if(h._buttonFillNormal===void 0&&(h._buttonFillNormal=u.fill),l){let c=null;h.layer!==null&&h.diagram!==null&&h.isVisibleObject()&&(c=h.layer.findObjectAt(h.diagram.lastInput.documentPoint)),c===h||c!==null&&c.isContainedBy(h)?u.fill=h._buttonFillOver:u.fill=h._buttonFillNormal}else u.fill=h._buttonFillDisabled}},cursor:"pointer"}).attach({_buttonFillNormal:void 0,_buttonStrokeNormal:void 0,_buttonFillOver:i,_buttonStrokeOver:s,_buttonFillDisabled:n}).add(new it("RoundedRectangle",{name:"ButtonBorder",spot1:new T(0,0,o,r),spot2:new T(1,1,-o,-r),parameter1:2,fill:t,stroke:e}));return a.mouseEnter=(h,l,u)=>{if(!l.isEnabledObject()||!(l instanceof G))return;let c=l.findObject("ButtonBorder");c instanceof it&&(l._buttonFillNormal===void 0&&(l._buttonFillNormal=c.fill),c.fill=l._buttonFillOver,l._buttonStrokeNormal===void 0&&(l._buttonStrokeNormal=c.stroke),c.stroke=l._buttonStrokeOver)},a.mouseLeave=(h,l,u)=>{if(!l.isEnabledObject()||!(l instanceof G))return;let c=l.findObject("ButtonBorder");c instanceof it&&(l._buttonFillNormal!==void 0&&(c.fill=l._buttonFillNormal),l._buttonStrokeNormal!==void 0&&(c.stroke=l._buttonStrokeNormal))},a}),J.defineBuilder("TreeExpanderButton",x=>{let t=J.build("Button");return t.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),t.add(new it("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:nt.Su}).bindObject("figure","isTreeExpanded",(e,i)=>{let s=i.panel;return e?s._treeExpandedFigure:s._treeCollapsedFigure})),t.bindObject("visible","isTreeLeaf",e=>!e),t.click=(e,i)=>{let s=i.part;if(s instanceof vt&&(s=s.adornedPart),!(s instanceof $))return;let n=s.diagram;if(n===null)return;let o=n.commandHandler;if(s.isTreeExpanded){if(!o.canCollapseTree(s))return}else if(!o.canExpandTree(s))return;e.handled=!0,s.isTreeExpanded?o.collapseTree(s):o.expandTree(s)},t}),J.defineBuilder("SubGraphExpanderButton",x=>{let t=J.build("Button");return t.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),t.add(new it("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:nt.Su}).bindObject("figure","isSubGraphExpanded",(e,i)=>{let s=i.panel;return e?s._subGraphExpandedFigure:s._subGraphCollapsedFigure})),t.click=(e,i)=>{let s=i.part;if(s instanceof vt&&(s=s.adornedPart),!(s instanceof ht))return;let n=s.diagram;if(n===null)return;let o=n.commandHandler;if(s.isSubGraphExpanded){if(!o.canCollapseSubGraph(s))return}else if(!o.canExpandSubGraph(s))return;e.handled=!0,s.isSubGraphExpanded?o.collapseSubGraph(s):o.expandSubGraph(s)},t}),J.defineBuilder("ToolTip",x=>new vt(G.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new P(0,2),mouseOver:(t,e)=>{let i=t.diagram.toolManager;i.extendToolTip(i.toolTipDuration)}}).add(new it("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new T(0,0,4,6),spot2:new T(1,1,-4,-4)}))),J.defineBuilder("ContextMenu",x=>new vt(G.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new P(0,2)}).bindObject("background","",t=>t.adornedPart!==null&&t.hasPlaceholder()?null:"#f5f5f5")),J.defineBuilder("ContextMenuButton",x=>{let t=J.build("Button");t.stretch=5;let e=t.findObject("ButtonBorder");return e instanceof it&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new T(0,0,4,6),e.spot2=new T(1,1,-4,-4)),t}),J.defineBuilder("PanelExpanderButton",x=>{let t=J.takeBuilderArgument(x,"COLLAPSIBLE"),e=J.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8","ButtonBorder.fill":"rgba(0, 0, 0, 0)",_buttonFillNormal:"rgba(0, 0, 0, 0)","ButtonBorder.stroke":null,_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new it({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",s=>s?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,t));let i=e.findObject("ButtonBorder");return i instanceof it&&(i.stroke=null,i.fill="rgba(0, 0, 0, 0)"),e.click=(s,n)=>{if(!(n instanceof G))return;let o=n.diagram;if(o===null||o.isReadOnly)return;let r=n.findBindingPanel();if(r===null&&(r=n.part),r!==null){let a=r.findObject(t);a!==null&&(s.handled=!0,o.startTransaction("Collapse/Expand Panel"),a.visible=!a.visible,o.commitTransaction("Collapse/Expand Panel"))}},e}),J.defineBuilder("CheckBoxButton",x=>{let t=J.takeBuilderArgument(x),e=J.build("Button",{desiredSize:new nt(14,14)});e.attach({"ButtonBorder.spot1":new T(0,0,1,1),"ButtonBorder.spot2":new T(1,1,-1,-1)});let i=new it({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return t!==""&&i.bindTwoWay("visible",t),e.add(i),e.click=(s,n)=>{if(!(n instanceof G))return;let o=s.diagram;if(o===null||o.isReadOnly||t!==""&&o.model.isReadOnly)return;s.handled=!0;let r=n.findObject("ButtonIcon");o.startTransaction("checkbox"),r!==null&&(r.visible=!r.visible),m.it(n._doClick)&&n._doClick(s,n),o.commitTransaction("checkbox")},e}),J.defineBuilder("CheckBox",x=>{let t=J.takeBuilderArgument(x),e=J.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Dt(0,1,0,0)},t),i=new G("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Dt(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return i.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,i}),J.defineBuilder("AutoRepeatButton",x=>{let t=J.takeBuilderArgument(x,50,r=>typeof r=="number"),e=J.takeBuilderArgument(x,500,r=>typeof r=="number");function i(r,a){n(r,a),a.click&&(a.Nd=m.dn(()=>s(r,a),e))}function s(r,a){a.Nd&&m.yc(a.Nd),a.click&&(a.Nd=m.dn(()=>{a.click&&(a.click(r,a),s(r,a))},t))}function n(r,a){a.Nd&&(m.yc(a.Nd),a.Nd=void 0)}let o=J.build("Button");return o.actionDown=(r,a)=>i(r,a),o.actionUp=(r,a)=>n(r,a),o.actionCancel=(r,a)=>n(r,a),o}),J.defineBuilder("ToggleSwitch",function(x){let t=J.takeBuilderArgument(x);t||m.o("ToggleSwitch must be data-bound to a property name, not: "+t);let e=J.takeBuilderArgument(x,!1,r=>typeof r=="boolean"),i="gray",s="transparent",n="white",o=new G("Auto",{width:e?15:28,height:e?28:15}).attach({_buttonFillOff:i,_buttonBorderOff:s,_buttonIconFillOff:n,_buttonFillOn:"green",_buttonBorderOn:"transparent",_buttonIconFillOn:"white"}).add(new it("Capsule",{name:"ButtonBorder",fill:i,stroke:s,strokeWidth:1}).bind("fill",t,(r,a)=>r?a.panel._buttonFillOn:a.panel._buttonFillOff).bind("stroke",t,(r,a)=>r?a.panel._buttonBorderOn:a.panel._buttonBorderOff)).add(new it("Circle",{name:"ButtonIcon",width:11,height:11,fill:n,stroke:null,alignment:e?T.Bottom:T.Left}).bind("fill",t,(r,a)=>r?a.panel._buttonIconFillOn:a.panel._buttonIconFillOff).bind("alignment",t,r=>r?e?T.Top:T.Right:e?T.Bottom:T.Left));return o.click=function(r,a){if(!a.isEnabledObject())return;let h=r.diagram;if(h===null||h.isReadOnly||t!==""&&h.model.isReadOnly)return;r.handled=!0;let l=a.findBindingPanel();l!==null&&(h.startTransaction("toggle switch"),h.model.set(l.data,t,!l.data[t]),typeof a._doClick=="function"&&a._doClick(r,a),h.commitTransaction("toggle switch"))},o}),J.defineBuilder("Toggle",function(x){let t=J.takeBuilderArgument(x),e=J.build("ToggleSwitch",{name:"Button"},t),i=new G("Horizontal",{cursor:e.cursor,margin:1,mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonClick:e.click}).add(e);return e.mouseEnter=null,e.mouseLeave=null,e.click=null,i});class Ke{me;Pt;no;Fe;oo;Ds;Ul;Er;Ur;Vr;Yr;Kr;Br;zr;Xr;a0;h0;Gr;c0;f0;u0;d0;Hr;qr;jp;i0;Ts;Cr;Nr;ao;e0;t0;Mr;Hp;m0;p0;constructor(){this.me=!1,this.Pt="",this.no=-1,this.Fe=null,this.oo=null,this.Ds=null,this.Ul="",this.Er=null,this.Ur=null,this.Vr=null,this.Yr=null,this.Kr=null,this.Br=null,this.zr=null,this.Xr=null,this.a0=null,this.h0=null,this.Gr=null,this.c0=null,this.f0=null,this.u0=null,this.d0=null,this.Hr=null,this.qr=null,this.jp=null,this.i0=null,this.Ts=null,this.Cr=nt.xc,this.Nr=nt.NP,this.ao=1,this.e0=1,this.t0=1,this.Mr=0,this.Hp=null,this.m0=null,this.p0="category"}copy(){let t=new Ke;return t.Pt=this.Pt,t.no=this.no,t.Fe=this.Fe,t.Ds=this.Ds,t.Ul=this.Ul,t.Er=this.Er,t.Ur=this.Ur,t.Vr=this.Vr,t.Yr=this.Yr,t.Kr=this.Kr,t.Br=this.Br,t.zr=this.zr,t.Xr=this.Xr,t.a0=this.a0,t.h0=this.h0,t.Gr=this.Gr,t.c0=this.c0,t.f0=this.f0,t.u0=this.u0,t.d0=this.d0,t.Hr=this.Hr,t.qr=this.qr,t.jp=this.jp,t.i0=this.i0,t.Ts=this.Ts,t.Cr=this.Cr.C(),t.Nr=this.Nr.C(),t.ao=this.ao,t.e0=this.e0,t.t0=this.t0,t.Mr=this.Mr,t.Hp=this.Hp,t.m0=this.m0,t.p0=this.p0,t}}class Si{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){let t=new Si;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,e){this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e}scale(t,e){this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e}rotate(t,e,i){if(t=C.Ee(t),t===0)return;this.translate(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,a=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=a,this.m[3]=h,this.translate(-e,-i)}}class li{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,e){this.colors.push({offset:t,color:e})}}class ui{bt;_t;el;dd;OC;constructor(t,e,i){let s=e===void 0?K.document:e;this.el=s,this.OC="http://www.w3.org/2000/svg";let n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.bt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",i||(this.style.position="absolute"),this.bt.setAttributeNS(n,"xmlns",this.OC),this.bt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.dd=null,this._t=new ae(this,i)}resize(t,e,i,s){return this.width!==t||this.height!==e?(this.width=t,this.height=e,this.style.width=i+"px",this.style.height=s+"px",this.bt.setAttributeNS(null,"width",i+"px"),this.bt.setAttributeNS(null,"height",s+"px"),this.bt.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),this._t.IC.firstElementChild.setAttributeNS(null,"width",i+"px"),this._t.IC.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,e,i){let s=this.el.createElementNS(this.OC,t);if(m.$(e))for(let n in e)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,e[n]);return i!==void 0&&(s.textContent=i),s}getBoundingClientRect(){return this.bt.getBoundingClientRect()}focus(){this.bt.focus()}get width(){return parseInt(this.bt.getAttribute("width")||"1")}set width(t){this.bt.setAttribute("width",t+"px")}get height(){return parseInt(this.bt.getAttribute("height")||"1")}set height(t){this.bt.setAttribute("height",t+"px")}dispose(){this.el=null}get style(){return this.bt.style}}class ae{Mf;Cf;An;Re;Qi;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;Nf;Lf;surface;svg;IC;rD;V1;jo;Na;Bh;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;rl;vr;filter;letterSpacing;wordSpacing;partClipRect;constructor(t,e){if(this.surface=t,this.svg=t.bt,this.Nf=[],this.Lf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.rl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.Mf=0,this.Cf=0,this.An=0,this.lastCreatedElement=null,this.currentElement=null,this.Re=[],this.pathAttributes={},this.V1=!1,this.jo=null,this.Na=0,this.rD={},this.vr=!!e,this.filter="",this.partClipRect=null,this.Qi=new Si,this.letterSpacing="0px",this.wordSpacing="0px",t.el===null||t.el===void 0)return;this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;let i=V.Kw++,s=this.makeElement("clipPath",{id:"mainClip"+i}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.IC=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+i+")")}setDiagramPosScale(t,e,i,s,n,o){this.diagramGroup===void 0?this.newGroup(t,e,i,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+e+", "+i+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,e,i,s,n,o,r,a){let h=2*Math.PI,l=1e-6,u=h-l,c=i*Math.cos(s),d=i*Math.sin(s),f=t+c,p=e+d,g=o?0:1,y=o?s-n:n-s;(Math.abs(r-f)>l||Math.abs(a-p)>l)&&this.Re.push(["L",f,+p]),y<0&&(y=y%h+h),y>u?(this.Re.push(["A",i,i,0,1,g,t-c,e-d]),this.Re.push(["A",i,i,0,1,g,f,p])):y>l&&this.Re.push(["A",i,i,0,+(y>=Math.PI),g,t+i*Math.cos(n),e+i*Math.sin(n)])}beginPath(){this.Re=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.kI(this.Re,this.Qi,t||0)}bezierCurveTo(t,e,i,s,n,o){this.Re.push(["C",t,e,i,s,n,o])}clearRect(t,e,i,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Re.push(["z"])}createLinearGradient(t,e,i,s){let n=new li("linear");return n.x1=t,n.y1=e,n.x2=i,n.y2=s,n}createPattern(t,e){let i="";t instanceof HTMLCanvasElement&&(i=t.toDataURL()),t instanceof HTMLImageElement&&(i=t.getAttribute("src"));let s=this.rD;if(s[i])return"url(#"+s[i]+")";let n="PATTERN"+V.Kw++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:i},a=this.makeElement("pattern",o);return a.appendChild(this.makeElement(Y.img,r)),this.svg.appendChild(a),s[i]=n,"url(#"+n+")"}createRadialGradient(t,e,i,s,n,o){let r=new li("radial");return r.x1=t,r.y1=e,r.r1=i,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,e,i,s,n,o,r,a){let h=r/i,l=a/s;(n!==0||o!==0)&&this.Qi.translate(n,o),(h!==1||l!==1)&&this.Qi.scale(h,l),(t!==0||e!==0)&&this.Qi.translate(-t,-e)}drawImage(t,e,i,s,n,o,r,a,h){let l="",u=t.width,c=t.height;typeof t.toDataURL=="function"?t.toDataURL():(l=t.getAttribute("src"),u=t.naturalWidth,c=t.naturalHeight),s===void 0&&(o=e,r=i,a=s=u,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,a=a||0,h=h||0,this.amendImageTransform(e,i,s,n,o,r,a,h);let d={x:0,y:0,width:u||s,height:c||n,href:l};!C.X(s,a)||!C.X(n,h)?d.preserveAspectRatio="none":l.toLowerCase().indexOf(".svg")===-1&&l.toLowerCase().indexOf("data:image/svg")===-1&&(d.preserveAspectRatio="xMidYMid slice"),(e!==0||i!==0||s!==u||n!==c)&&(s+=e,n+=i,d["clip-path"]=`path('M ${e},${i} L ${s} ${i} L ${s} ${n} L ${e} ${n} z')`),this.processCommon(Y.img,d,this.Qi),this.Ld(Y.img,d)}fill(t,e){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,e,i){this.clipInsteadOfFill?this.clip():this.fill(e,i)}createOrUpdateClipGroup(t,e){let i=this.newGroup(1,0,0,1,-e.x,-e.y);i.setAttributeNS(null,"class","spotClip"),t.wa=i}fillRect(t,e,i,s){this.addRect("fill",[t,e,i,s],this.Qi)}fillBackground(t,e,i,s){let n={x:t,y:e,width:i,height:s};this.processCommon("fill",n,this.Qi),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,e,i){this.addText("fill",[t,e,i],this.Qi)}lineTo(t,e){this.Re.push(["L",t,e])}moveTo(t,e){this.Re.push(["M",t,e])}quadraticCurveTo(t,e,i,s){this.Re.push(["Q",t,e,i,s])}rect(t,e,i,s){this.Re.push(["M",t,e],["L",t+i,e],["L",t+i,e+s],["L",t,e+s],["z"])}restore(){this.Qi=this.Nf.pop(),this.Re=this.Nf.pop();let t=this.Nf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect,this.letterSpacing=t.letterSpacing,this.wordSpacing=t.wordSpacing}save(){let t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.Nf.push(t);let e=[];for(let i=0;i<this.Re.length;i++)e.push(this.Re[i]);this.Nf.push(e),this.Nf.push(this.Qi.copy())}setTransform(t,e,i,s,n,o){t===1&&e===0&&i===0&&s===1&&n===0&&o===0||this.newGroup(t,e,i,s,n,o)}setCurrentTransform(t,e,i,s,n,o){this.Qi.m=[t,e,i,s,n,o]}getCurrentTransform(){let t=this.Qi.m;return"matrix("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"}scale(t,e){this.Qi.scale(t,e)}translate(t,e){this.Qi.translate(t,e)}transform(t,e,i,s,n,o){}commitTransform(){}stroke(){this.setStroke(this.pathAttributes)}strokeContext(){this.clipInsteadOfFill||this.stroke()}strokeRect(t,e,i,s){this.addRect("stroke",[t,e,i,s],this.Qi)}makeElement(t,e,i){return this.surface.makeElement(t,e,i)}Ld(t,e,i){let s=this.makeElement(t,e,i);return this.currentElement!==null?this.currentElement.appendChild(s):this.currentElement=s,this.lastCreatedElement=s,s}processCommon(t,e,i){if(t==="fill"?this.setFill(e):t==="stroke"&&this.setStroke(e),i!==null){let s=i.m;e.transform="matrix("+s[0]+", "+s[1]+", "+s[2]+", "+s[3]+", "+s[4]+", "+s[5]+")"}}setFill(t){if(this.fillStyle instanceof li){t.fill=this.addGradient(this.fillStyle,"fill");return}if(/^rgba\(/.test(this.fillStyle)){let e=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.fillStyle);t.fill="rgb("+e[1]+","+e[2]+","+e[3]+")",t["fill-opacity"]=e[4]}else t.fill=this.fillStyle}setFillOrStrokeInPlace(t,e){let i=e?"fill":"stroke";if(this.fillStyle instanceof li){t.setAttributeNS(null,"fill",this.addGradient(this.fillStyle,i));return}if(/^rgba\(/.test(this.fillStyle)){let s=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.fillStyle);t.setAttributeNS(null,i,"rgb("+s[1]+","+s[2]+","+s[3]+")"),t.setAttributeNS(null,i+"-opacity",s[4])}else t.setAttributeNS(null,i,this.fillStyle)}setStroke(t){if(this.strokeStyle instanceof li)t.stroke=this.addGradient(this.strokeStyle,"stroke");else if(/^rgba\(/.test(this.strokeStyle)){let e=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.strokeStyle);t.stroke="rgb("+e[1]+","+e[2]+","+e[3]+")",t["stroke-opacity"]=e[4]}else t.stroke=this.strokeStyle;t["stroke-width"]=this.lineWidth,t["stroke-linecap"]=this.lineCap,t["stroke-linejoin"]=this.lineJoin,t["stroke-miterlimit"]=this.miterLimit,this.V1&&(t["stroke-dasharray"]=this.jo.toString(),t["stroke-dashoffset"]=this.Na)}addGradient(t,e){let i="",s=this.currentPath!==null?this.currentPath.getAttribute(e):null;if(s!==null&&s.indexOf("GRAD")!==-1){i=s.split("#")[1].slice(0,-1);let a=this.svg.getElementById(i);a!==null&&a.remove()}else i="GRAD"+V.Kw++;let n;if(t.type==="linear"){let a={x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,id:i,gradientUnits:"userSpaceOnUse"};n=this.makeElement("linearGradient",a)}else if(t.type==="radial"){let a={x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,r1:t.r1,r2:t.r2,id:i};n=this.makeElement("radialGradient",a)}else m.o("invalid gradient");let o=t.colors.sort((a,h)=>a.offset>h.offset?1:-1),r=o.length;for(let a=0;a<r;a++){let h=o[a],l=h.color;n.appendChild(this.makeElement("stop",{offset:h.offset,"stop-color":l}))}return this.svg.appendChild(n),"url(#"+i+")"}addRect(t,e,i){let s={x:e[0],y:e[1],width:e[2],height:e[3]};this.processCommon(t,s,i),this.Ld("rect",s)}addText(t,e,i){let s=this.textAlign;s==="left"?s="start":s==="right"?s="end":s==="center"&&(s="middle");let n={x:e[1],y:e[2],style:"font: "+this.font,"text-anchor":s};n["letter-spacing"]=this.letterSpacing,n["word-spacing"]=this.wordSpacing,this.processCommon(t,n,i),this.Ld("text",n,e[0])}kI(t,e,i){let s=this.SI(t),n=this.pathAttributes;if(n.clipPath){this.Lf.length>1&&this.Lf[this.Lf.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,e),this.currentPath!==null){let o=this.currentPath;if(o.nodeName!=="g")for(let r in n)r!=="transform"&&o.setAttributeNS(null,r,n[r]);else{let r=o.getElementsByTagName("path");for(let a in n)a!=="transform"&&r[i].setAttributeNS(null,a,n[a])}}else this.Ld("path",n)}SI(t){let e=[];for(let i=0;i<t.length;i++){let s=t[i].slice(),n=[s.shift()];if(n[0]==="A")n.push(s.shift()+","+s.shift(),s.shift(),s.shift()+","+s.shift(),s.shift()+","+s.shift());else for(;s.length;)n.push(s.shift()+","+s.shift());e.push(n.join(" "))}return e.join(" ")}newGroup(t,e,i,s,n,o){let r=new Si;r.m=[t,e,i,s,n,o];let a={};this.processCommon("g",a,r);let h=this.Ld("g",a);return this.Lf.push(h),h}newGroup2(t){let e={};t&&(e.class=t);let i=this.Ld("g",e);return this.Lf.push(i),i}endGroup(){return this.Lf.pop()}dummyGroup(){return this.newGroup2(),this.endGroup()}shadowsSet(t,e,i){this.Mf=t,this.Cf=e,this.An=i}shadowsOff(){this.rl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.rl=!0,this.shadowOffsetX=this.Mf,this.shadowOffsetY=this.Cf,this.shadowBlur=this.An}enableDash(t,e){this.V1=!0,this.jo=t,this.Na=e}disableDash(){this.V1=!1}clearContextCache(t){}setImageSmoothingEnabled(t){}rotate(t){this.Qi.rotate(t*57.2958,0,0)}getImageData(t,e,i,s){return null}measureText(t){return null}removeOldGradient(t,e,i){let s=e.getAttribute(i);if(s===null)return;let n=s.split("#");if(n.length===1)return;let o=this.svg.getElementById(n[1].slice(0,-1));if(o!==null){let r=new RegExp(o.id,"g");this.svg.innerHTML.match(r).length===1&&o.remove()}}removePartFromView(t){t.svg!==null&&t.svg.parentNode===this.diagramGroup&&t.svg.remove()}}class De{bt;_t;el;dd;constructor(t,e,i,s){let n=e===void 0?K.document:e;this.el=n,this.dd=null;let o=n.createElement("canvas");o.tabIndex=0,this.bt=o,this._t=new ci(o,i,s),t&&Y.Ji.set(o,t)}resize(t,e,i,s){return this.width!==t||this.height!==e?(this.width=t,this.height=e,this.style.width=i+"px",this.style.height=s+"px",!0):!1}toDataURL(t,e){return this.bt.toDataURL(t,e)}getBoundingClientRect(){return this.bt.getBoundingClientRect()}focus(){this.bt.focus()}get width(){return this.bt.width}set width(t){this.bt.width=t}get height(){return this.bt.height}set height(t){this.bt.height=t}dispose(){Y.Ji.delete(this.bt),this.el=null}get style(){return this.bt.style}}class ci{F;B1;z1;X1;clipInsteadOfFill;Mf;Cf;An;Bh;rl;vr;constructor(t,e,i){t.getContext||m.o("Browser does not support HTML Canvas Element"),this.F=t.getContext("2d",e),this.B1="",this.z1="",this.X1="",this.clipInsteadOfFill=!1,this.Mf=0,this.Cf=0,this.An=0,this.rl=!1,this.Bh=new Nt,this.vr=!!i}createOrUpdateClipGroup(t,e){}setImageSmoothingEnabled(t){this.F.imageSmoothingEnabled=t}get fillStyle(){return this.F.fillStyle}set fillStyle(t){this.X1!==t&&(this.F.fillStyle=t,this.X1=t)}get font(){return this.F.font}set font(t){this.B1!==t&&(this.F.font=t,this.B1=t)}get globalAlpha(){return this.F.globalAlpha}set globalAlpha(t){this.F.globalAlpha=t}get lineCap(){return this.F.lineCap}set lineCap(t){this.F.lineCap=t}get lineDashOffset(){return this.F.lineDashOffset}set lineDashOffset(t){this.F.lineDashOffset=t}get lineJoin(){return this.F.lineJoin}set lineJoin(t){this.F.lineJoin=t}get lineWidth(){return this.F.lineWidth}set lineWidth(t){this.F.lineWidth=t}get miterLimit(){return this.F.miterLimit}set miterLimit(t){this.F.miterLimit=t}get shadowBlur(){return this.F.shadowBlur}set shadowBlur(t){this.F.shadowBlur=t}get shadowColor(){return this.F.shadowColor}set shadowColor(t){this.F.shadowColor=t}get shadowOffsetX(){return this.F.shadowOffsetX}set shadowOffsetX(t){this.F.shadowOffsetX=t}get shadowOffsetY(){return this.F.shadowOffsetY}set shadowOffsetY(t){this.F.shadowOffsetY=t}get strokeStyle(){return this.F.strokeStyle}set strokeStyle(t){this.z1!==t&&(this.F.strokeStyle=t,this.z1=t)}get textAlign(){return this.F.textAlign}set textAlign(t){this.F.textAlign=t}get imageSmoothingEnabled(){return this.F.imageSmoothingEnabled}set imageSmoothingEnabled(t){this.F.imageSmoothingEnabled=t}get filter(){return this.F.filter}set filter(t){t===""?this.F.filter="none":this.F.filter=t}get letterSpacing(){return this.F.letterSpacing}set letterSpacing(t){this.F.letterSpacing=t}get wordSpacing(){return this.F.wordSpacing}set wordSpacing(t){this.F.wordSpacing=t}arc(t,e,i,s,n,o,r,a){this.F.arc(t,e,i,s,n,o)}beginPath(){this.F.beginPath()}endPath(){}bezierCurveTo(t,e,i,s,n,o){this.F.bezierCurveTo(t,e,i,s,n,o)}clearRect(t,e,i,s){this.commitTransform(),this.F.clearRect(t,e,i,s)}clip(t){t?this.F.clip(t):this.F.clip()}closePath(){this.F.closePath()}createLinearGradient(t,e,i,s){return this.F.createLinearGradient(t,e,i,s)}createPattern(t,e){return this.F.createPattern(t,e)}createRadialGradient(t,e,i,s,n,o){return this.F.createRadialGradient(t,e,i,s,n,o)}drawImage(t,e,i,s,n,o,r,a,h){s===void 0?this.F.drawImage(t,e,i):this.F.drawImage(t,e,i,s,n,o,r,a,h)}fill(t,e){e?this.F.fill(e,t?"evenodd":"nonzero"):this.F.fill(t?"evenodd":"nonzero")}fillRect(t,e,i,s){this.F.fillRect(t,e,i,s)}fillBackground(t,e,i,s){this.F.fillRect(t,e,i,s)}fillText(t,e,i){this.F.fillText(t,e,i)}getImageData(t,e,i,s){return this.F.getImageData(t,e,i,s)}lineTo(t,e){this.F.lineTo(t,e)}measureText(t){return this.F.measureText(t)}moveTo(t,e){this.F.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this.F.quadraticCurveTo(t,e,i,s)}rect(t,e,i,s){this.F.rect(t,e,i,s)}restore(){this.F.restore()}save(){this.commitTransform(),this.F.save()}rotate(t){this.Bh.ks(t*57.2958,0,0)}setTransform(t,e,i,s,n,o){this.Bh.setTo(t,e,i,s,n,o)}scale(t,e){this.Bh.et(t,e)}translate(t,e){this.Bh.Gs(t,e)}stroke(t){t?this.F.stroke(t):this.F.stroke()}transform(t,e,i,s,n,o){if(t===1&&e===0&&i===0&&s===1&&n===0&&o===0)return;let r=this.Bh,a=r.m11*t+r.m21*e,h=r.m12*t+r.m22*e,l=r.m11*i+r.m21*s,u=r.m12*i+r.m22*s;r.dx=r.m11*n+r.m21*o+r.dx,r.dy=r.m12*n+r.m22*o+r.dy,r.m11=a,r.m12=h,r.m21=l,r.m22=u}commitTransform(){let t=this.Bh;this.F.setTransform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy)}fillContext(t,e,i){this.radialFill(t,e,i)||this.fillOrClip(e,i)}radialFill(t,e,i){if(!(t instanceof R)||t.type!==3)return!1;let s=t.bf,n=t.O1;return n>s?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(e,i),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,e){this.clipInsteadOfFill?this.clip(e):this.fill(t,e)}shadowsSet(t,e,i){this.Mf=t,this.Cf=e,this.An=i}shadowsOff(){this.rl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.rl=!0,this.shadowOffsetX=this.Mf,this.shadowOffsetY=this.Cf,this.shadowBlur=this.An}enableDash(t,e){let i=this.F;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=e)}disableDash(){let t=this.F;t.setLineDash!==void 0&&(t.setLineDash(ci.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.B1=""),this.z1="",this.X1=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var Fe=(x=>(x[x.Solid=1]="Solid",x[x.Linear=2]="Linear",x[x.Radial=3]="Radial",x[x.Pattern=4]="Pattern",x))(Fe||{}),Ys=(x=>(x[x.Lab=1]="Lab",x[x.HSL=2]="HSL",x[x.Oklch=3]="Oklch",x))(Ys||{});class _e{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class R{u;W;zh;ae;Ns;y0;w0;Wo;x0;Nn;bf;O1;constructor(t,e){if(V.Je(this),this.u=!1,t===void 0)this.W=1,this.zh="black";else if(typeof t=="string"){let s=m.Ja(Fe,t);s!==null?(this.W=s,this.zh="black"):(this.W=1,this.zh=t)}else Object.keys(Fe).hasOwnProperty(t)?(this.W=t,this.zh="black"):typeof t=="object"&&(this.W=1,e=t);let i=this.W;if(i===2?(this.ae=T.TopCenter,this.Ns=T.BottomCenter):i===3?(this.ae=T.Center,this.Ns=T.Center):(this.ae=T.None,this.Ns=T.None),this.y0=0,this.w0=NaN,this.Wo=null,this.x0=null,this.Nn=null,this.bf=0,this.O1=0,e){let s={};for(let n in e)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),e[n]):s[n]=e[n];Object.assign(this,s)}}copy(){let t=new R;return t.W=this.W,t.zh=this.zh,t.ae=this.ae.C(),t.Ns=this.Ns.C(),t.y0=this.y0,t.w0=this.w0,this.Wo!==null&&(t.Wo=this.Wo.copy()),t.x0=this.x0,t}k(){return this.u=!0,this.Wo!==null&&this.Wo.k(),this}fe(t){t in Fe?this.type=t:m.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){let e=this.colorStops.iterator;for(;e.next();){let i=e.key,s=e.value;t+=" "+i+":"+s}}return t+=")",t}addColorStop(t,e){return this.u&&m.L(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&m.J(t,"0 <= loc <= 1",R,"addColorStop:loc"),m.s(e,"string",R,"addColorStop:color"),this.Wo===null&&(this.Wo=new Mt),this.Wo.set(t,e),this.W===1&&(this.type=2),this.Nn=null,this}get type(){return this.W}set type(t){this.u&&m.L(this,t),this.W=t,this.start.isNoSpot()&&(t===2?this.start=T.TopCenter:t===3&&(this.start=T.Center)),this.end.isNoSpot()&&(t===2?this.end=T.BottomCenter:t===3&&(this.end=T.Center)),this.Nn=null}get color(){return this.zh}set color(t){this.u&&m.L(this,t),this.zh=t,this.Nn=null}get start(){return this.ae}set start(t){this.u&&m.L(this,t),this.ae=t.C(),this.Nn=null}get end(){return this.Ns}set end(t){this.u&&m.L(this,t),this.Ns=t.C(),this.Nn=null}get startRadius(){return this.y0}set startRadius(t){this.u&&m.L(this,t),t<0&&m.J(t,">= zero",R,"startRadius"),this.y0=t,this.Nn=null}get endRadius(){return this.w0}set endRadius(t){this.u&&m.L(this,t),t<0&&m.J(t,">= zero",R,"endRadius"),this.w0=t,this.Nn=null}get colorStops(){return this.Wo}set colorStops(t){this.u&&m.L(this,t),this.Wo=t,this.Nn=null}get pattern(){return this.x0}set pattern(t){this.u&&m.L(this,t),this.x0=t,this.Nn=null}static randomColor(t,e){t===void 0&&(t=128),e===void 0&&(e=Math.max(t,255));let i=Math.abs(e-t),s=Math.floor(t+Math.random()*i).toString(16),n=Math.floor(t+Math.random()*i).toString(16),o=Math.floor(t+Math.random()*i).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return K.CSS?K.CSS.supports("color",t):!0}static lighten(t){return R.lightenBy(t)}lightenBy(t,e){this.u&&m.L(this);let i=t===void 0||typeof t!="number"?.2:t,s=e===void 0?3:e;if(this.type===1)R.Eo(this.color),this.color=R.Ad(i,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){let n=this.colorStops.iterator;for(;n.next();)R.Eo(n.value),this.addColorStop(n.key,R.Ad(i,s))}return this}static lightenBy(t,e,i){let s=e===void 0||typeof e!="number"?.2:e,n=i===void 0?3:i;return R.Eo(t),R.Ad(s,n)}static darken(t){return R.darkenBy(t)}darkenBy(t,e){this.u&&m.L(this);let i=t===void 0||typeof t!="number"?.2:t,s=e===void 0?3:e;if(this.type===1)R.Eo(this.color),this.color=R.Ad(-i,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){let n=this.colorStops.iterator;for(;n.next();)R.Eo(n.value),this.addColorStop(n.key,R.Ad(-i,s))}return this}static darkenBy(t,e,i){let s=e===void 0||typeof e!="number"?.2:e,n=i===void 0?3:i;return R.Eo(t),R.Ad(-s,n)}static mix(t,e,i){R.Eo(t);let s=R.Y.n0,n=R.Y.n1,o=R.Y.n2,r=R.Y.n3;R.Eo(e),i===void 0&&(i=.5);let a=Math.round((R.Y.n0-s)*i+s),h=Math.round((R.Y.n1-n)*i+n),l=Math.round((R.Y.n2-o)*i+o),u=Math.round((R.Y.n3-r)*i+r);return`rgba(${a}, ${h}, ${l}, ${u})`}isDark(){if(this.type===1)return R.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){let t=this.colorStops;if(this.type===3){let a=t.first();return a?R.isDark(a.value):!1}if(t.get(.5)!==null)return R.isDark(t.get(.5));if(t.count===2){let a=t.toArray();return R.isDark(R.mix(a[0].value,a[1].value))}let e=t.iterator,i=-1,s=-1,n=1,o=1;for(;e.next();){let a=e.key,h=Math.abs(.5-e.key);n>o&&h<n?(i=a,n=h):o>=n&&h<o&&(s=a,o=h)}if(i>s){let a=i;i=s,s=a,a=n,n=o,o=a}let r=s-i;return R.isDark(R.mix(t.get(i),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof R?t.isDark():(R.Eo(t),(299*R.Y.n0+587*R.Y.n1+114*R.Y.n2)/1e3<128):!1}static Ad(t,e){switch(e){case 1:return R.MI(),R.ho.n0=Math.min(100,Math.max(0,R.ho.n0+100*t)),R.CI(),"rgba("+R.Y.n0+", "+R.Y.n1+", "+R.Y.n2+", "+R.Y.n3+")";case 2:return R.FM(),R.ze.n2=Math.min(100,Math.max(0,R.ze.n2+100*t)),"hsla("+R.ze.n0+", "+R.ze.n1+"%, "+R.ze.n2+"%, "+R.ze.n3+")";case 3:return R.NI(),R.co.n0=Math.min(100,Math.max(0,R.co.n0+100*t)),R.LI(),"rgba("+R.Y.n0+", "+R.Y.n1+", "+R.Y.n2+", "+R.Y.n3+")";default:m.o("Unknown color space: "+e)}}static Eo(t){R.b0===!1&&(R.b0=!0,R.us=Y.isUsingDOM()?new De(null,void 0,{willReadFrequently:!0})._t:null);let e=R.us;if(e===null)return;e.clearRect(0,0,1,1),e.fillStyle="#000000";let i=e.fillStyle;if(e.fillStyle=t,e.fillStyle!==i){e.fillRect(0,0,1,1);let s=e.getImageData(0,0,1,1).data;R.Y.n0=s[0],R.Y.n1=s[1],R.Y.n2=s[2],R.Y.n3=s[3]/255}else{e.fillStyle="#FFFFFF";let s=e.fillStyle;e.fillStyle=t,e.fillStyle,R.Y.n0=0,R.Y.n1=0,R.Y.n2=0,R.Y.n3=1}}static FM(){let t=R.Y.n0/255,e=R.Y.n1/255,i=R.Y.n2/255,s=Math.max(t,e,i),n=Math.min(t,e,i),o=s-n,r,a,h=(s+n)/2;if(o===0)r=a=0;else{switch(s){case t:r=(e-i)/o%6;break;case e:r=(i-t)/o+2;break;case i:r=(t-e)/o+4;break;default:r=0;break}r*=60,r<0&&(r+=360),a=o/(1-Math.abs(2*h-1))}R.ze.n0=Math.round(r),R.ze.n1=Math.round(a*100),R.ze.n2=Math.round(h*100),R.ze.n3=R.Y.n3}static BU(){let t=R.ze.n0,e=R.ze.n1/100,i=R.ze.n2/100,s,n,o,r=(1-Math.abs(2*i-1))*e,a=t/60,h=r*(1-Math.abs(a%2-1));a>=0&&a<1?(s=r,n=h,o=0):a>=1&&a<2?(s=h,n=r,o=0):a>=2&&a<3?(s=0,n=r,o=h):a>=3&&a<4?(s=0,n=h,o=r):a>=4&&a<5?(s=h,n=0,o=r):(s=r,n=0,o=h);let l=i-.5*r;s+=l,n+=l,o+=l,R.Y.n0=Math.round(s*255),R.Y.n1=Math.round(n*255),R.Y.n2=Math.round(o*255),R.Y.n3=R.ze.n3}static MI(){R.lD(),R.AI()}static CI(){R.TI(),R.aD()}static EC(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static UC(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static lD(){let t=R.EC(R.Y.n0),e=R.EC(R.Y.n1),i=R.EC(R.Y.n2);R.At.n0=.4124564*t+.3575761*e+.1804375*i,R.At.n1=.2126729*t+.7151522*e+.072175*i,R.At.n2=.0193339*t+.119192*e+.9503041*i,R.At.n3=R.Y.n3}static aD(){let t=3.2404542*R.At.n0+-1.5371385*R.At.n1+-.4985314*R.At.n2,e=-.969266*R.At.n0+1.8760108*R.At.n1+.041556*R.At.n2,i=.0556434*R.At.n0+-.2040259*R.At.n1+1.0572252*R.At.n2;R.Y.n0=R.UC(t)*255,R.Y.n1=R.UC(e)*255,R.Y.n2=R.UC(i)*255,R.Y.n3=R.At.n3,R.Y.n0=Math.round(R.Y.n0),R.Y.n0>255?R.Y.n0=255:R.Y.n0<0&&(R.Y.n0=0),R.Y.n1=Math.round(R.Y.n1),R.Y.n1>255?R.Y.n1=255:R.Y.n1<0&&(R.Y.n1=0),R.Y.n2=Math.round(R.Y.n2),R.Y.n2>255?R.Y.n2=255:R.Y.n2<0&&(R.Y.n2=0)}static VC=216/24389;static G1=24389/27;static Td=[95.047,100,108.883];static BC(t){return t>R.VC?Math.pow(t,1/3):(R.G1*t+16)/116}static AI(){let t=R.BC(R.At.n0*100/R.Td[0]),e=R.BC(R.At.n1*100/R.Td[1]),i=R.BC(R.At.n2*100/R.Td[2]);R.ho.n0=116*e-16,R.ho.n1=500*(t-e),R.ho.n2=200*(e-i),R.ho.n3=R.At.n3}static hD(t){let e=t*t*t;return e>R.VC?e:(116*t-16)/R.G1}static TI(){let t=(R.ho.n0+16)/116,e=R.ho.n1/500+t,i=t-R.ho.n2/200;R.At.n0=R.Td[0]/100*R.hD(e),R.At.n1=R.Td[1]/100*(R.ho.n0>R.G1*R.VC?Math.pow(t,3):R.ho.n0/R.G1),R.At.n2=R.Td[2]/100*R.hD(i),R.At.n3=R.ho.n3}static DI(){let t=.8190224*R.At.n0+.3619062*R.At.n1+-.1288737*R.At.n2,e=.03298366*R.At.n0+.9292868*R.At.n1+.03614466*R.At.n2,i=.04817719*R.At.n0+.2642395*R.At.n1+.6335478*R.At.n2;t=Math.cbrt(t),e=Math.cbrt(e),i=Math.cbrt(i),R.ge.n0=.2104542*t+.7936177*e+-.004072046*i,R.ge.n1=1.977998*t+-2.428592*e+.4505937*i,R.ge.n2=.02590403*t+.7827717*e+-.8086757*i,R.ge.n3=R.At.n3,R.ge.n0*=100}static vI(){R.ge.n0/=100;let t=.9999999*R.ge.n0+.3963377*R.ge.n1+.2158037*R.ge.n2,e=1.000000009*R.ge.n0+-.1055613*R.ge.n1+-.06385417*R.ge.n2,i=1.00000005*R.ge.n0+-.08948418*R.ge.n1+-1.291485*R.ge.n2;t=t**3,e=e**3,i=i**3,R.At.n0=1.2268798*t+-.5578149*e+.281391*i,R.At.n1=-.04057576*t+1.112286*e+-.07171106*i,R.At.n2=-.07637294*t+-.4214933*e+1.586924*i,R.At.n3=R.ge.n3}static FI(){let t=Math.atan2(R.ge.n2,R.ge.n1)*180/Math.PI;R.co.n0=R.ge.n0,R.co.n1=Math.sqrt(R.ge.n1**2+R.ge.n2**2),R.co.n2=t>=0?t:t+360,R.co.n3=R.ge.n3}static RI(){R.ge.n0=R.co.n0,R.ge.n1=R.co.n1*Math.cos(R.co.n2*Math.PI/180),R.ge.n2=R.co.n1*Math.sin(R.co.n2*Math.PI/180),R.ge.n3=R.co.n3}static NI(){R.lD(),R.DI(),R.FI()}static LI(){R.RI(),R.vI(),R.aD()}static Cd(t,e){typeof t=="string"||t instanceof R||m.o("Value for "+e+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static us=null;static b0=!1;static Y=new _e;static ze=new _e;static At=new _e;static ho=new _e;static ge=new _e;static co=new _e}class Lt{Pt="Base";static fs=new Mt;static Tn(t,e){e.name=t,Lt.fs.set(t,e)}get name(){return this.Pt}set name(t){this.Pt=t}constructor(){}get classType(){return G}measure(t,e,i,s,n,o,r){}measureElement(t,e,i,s,n){t.ht(e,i,s,n)}arrange(t,e,i){}arrangeElement(t,e,i,s,n,o){t.Ut(e,i,s,n,o)}remeasureObject(t){t.kf()}Ge(t,e,i){}}class In extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=t.Jo();for(let l=0;l<a;l++){let u=s[l];if(!u.visible&&u!==h)continue;let c=u.margin,d=c.right+c.left,f=c.top+c.bottom;u.ht(e,i,o,r);let p=u.measuredBounds,g=Math.max(p.width+d,0),y=Math.max(p.height+f,0),b=u.position.x,v=u.position.y;if(isFinite(b)||(b=0),isFinite(v)||(v=0),u instanceof it&&u.isGeometryPositioned){let w=u.strokeWidth/2;b-=w,v-=w}n.re(b,v,g,y)}}arrange(t,e,i){let s=e.length,n=t.padding,o=i.x-n.left,r=i.y-n.top;for(let a=0;a<s;a++){let h=e[a],l=h.measuredBounds,u=h.margin,c=h.position.x,d=h.position.y,f=isNaN(c)?-o:c-o,p=isNaN(d)?-r:d-r;if(h instanceof it&&h.isGeometryPositioned){let g=h.strokeWidth/2;f-=g,p-=g}h.visible&&h.Ut(f+u.left,p+u.top,l.width,l.height)}}}Lt.Tn("Position",new In);class Bn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=m.st(),l=t.Jo();for(let c=0;c<a;c++){let d=s[c];if(!d.visible&&d!==l)continue;let f=d.Qs(!1);if(f!==0&&f!==5){h.push(d);continue}d.ht(1/0,i,0,r);let p=d.margin,g=d.measuredBounds,y=Math.max(g.width+p.right+p.left,0),b=Math.max(g.height+p.top+p.bottom,0);n.Kn(n.width+y,Math.max(n.height,b))}let u=h.length;t.desiredSize.height?i=Math.min(t.desiredSize.height,t.maxSize.height):n.height!==0&&(i=Math.min(n.height,t.maxSize.height));for(let c=0;c<u;c++){let d=h[c];if(!d.visible&&d!==l)continue;let f=d.margin,p=f.right+f.left,g=f.top+f.bottom;d.ht(1/0,i,0,r);let y=d.measuredBounds,b=Math.max(y.width+p,0),v=Math.max(y.height+g,0);n.width+=b,n.height=Math.max(n.height,v)}m.Z(h)}arrange(t,e,i){let s=e.length,n=t.padding,o=n.top,r=t.isOpposite,a=r?i.width:n.left;for(let h=0;h<s;h++){let l=o,u=e[h];if(!u.visible)continue;let c=u.measuredBounds,d=u.margin,f=d.top+d.bottom,p=o+n.bottom,g=c.height,y=u.Qs(!1);(isNaN(u.desiredSize.height)&&y===2||y===4)&&(g=Math.max(i.height-f-p,0));let b=g+f+p,v=u.alignment;v.isDefault()&&(v=t.defaultAlignment),v.isSpot()||(v=T.Center),r&&(a-=c.width+d.left+d.right),u.Ut(a+v.offsetX+d.left,l+v.offsetY+d.top+(i.height*v.y-b*v.y),c.width,g),r||(a+=c.width+d.left+d.right)}}}Lt.Tn("Horizontal",new Bn);class Vn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=m.st(),l=t.Jo();for(let c=0;c<a;c++){let d=s[c];if(!d.visible&&d!==l)continue;let f=d.Qs(!1);if(f!==0&&f!==4){h.push(d);continue}d.ht(e,1/0,o,0);let p=d.margin,g=d.measuredBounds,y=Math.max(g.width+p.right+p.left,0),b=Math.max(g.height+p.top+p.bottom,0);n.Kn(Math.max(n.width,y),n.height+b)}let u=h.length;t.desiredSize.width?e=Math.min(t.desiredSize.width,t.maxSize.width):n.width!==0&&(e=Math.min(n.width,t.maxSize.width));for(let c=0;c<u;c++){let d=h[c];if(!d.visible&&d!==l)continue;let f=d.margin,p=f.right+f.left,g=f.top+f.bottom;d.ht(e,1/0,o,0);let y=d.measuredBounds,b=Math.max(y.width+p,0),v=Math.max(y.height+g,0);n.width=Math.max(n.width,b),n.height+=v}m.Z(h)}arrange(t,e,i){let s=e.length,n=t.padding,o=n.left,r=t.isOpposite,a=r?i.height:n.top;for(let h=0;h<s;h++){let l=o,u=e[h];if(!u.visible)continue;let c=u.measuredBounds,d=u.margin,f=d.left+d.right,p=o+n.right,g=c.width,y=u.Qs(!1);(isNaN(u.desiredSize.width)&&y===2||y===5)&&(g=Math.max(i.width-f-p,0));let b=g+f+p,v=u.alignment;v.isDefault()&&(v=t.defaultAlignment),v.isSpot()||(v=T.Center),r&&(a-=c.height+d.bottom+d.top),u.Ut(l+v.offsetX+d.left+(i.width*v.x-b*v.x),a+v.offsetY+d.top,g,c.height),r||(a+=c.height+d.bottom+d.top)}}}Lt.Tn("Vertical",new Vn);class Mi extends Lt{constructor(){super()}static cD=!1;measure(t,e,i,s,n,o,r){let a=s.length;if(a===0)return;let h=t.findMainElement(),l=h.margin,u=0,c=0,d=l.right+l.left,f=l.top+l.bottom;h.ht(e,i,o,r);let p=h.measuredBounds,g=p.width,y=p.height,b=Math.max(g+d,0),v=Math.max(y+f,0),w=t.isClipping;w&&h.Gp()!==0&&!Mi.cD&&(Mi.cD=!0,m.ne("Main Shape for Spot Panel with isClipping = true must have a zero strokeWidth: "+t.toString()));let k=I.z(-l.left,-l.top,b,v),S=I.z(0,0,g,y);this.zC(h,S,!0),g=S.width,y=S.height;let N=!0,D=t.Jo(),L;for(let M=0;M<a;M++){let A=s[M],F=e,O=i;if(A===h||!A.visible&&A!==D)continue;l=A.margin;let E=l.left,B=l.top;switch(u=l.right+l.left,c=l.top+l.bottom,L=A.Qs(!1),L){case 2:F=g,O=y,u=0,c=0,E=0,B=0;break;case 5:F=g,u=0,E=0;break;case 4:O=y,c=0,B=0;break}A.ht(F,O,0,0),p=A.measuredBounds,b=Math.max(p.width+u,0),v=Math.max(p.height+c,0);let X=A.alignment;X.isDefault()&&(X=t.defaultAlignment),X.isSpot()||(X=T.Center);let z=A.alignmentFocus;z.isDefault()&&(z=T.Center);let U=null;A instanceof G&&A.fo!==""&&(U=A.findObject(A.fo),U===A&&(U=null));let tt=S.x-E,st=S.y-B;if(U!==null){A.Ut(0,0,p.width,p.height);let Z=U.actualBounds,et=P.z(Z.x+(z.x*Z.width-z.offsetX),Z.y+(z.y*Z.height-z.offsetY));for(U=U.panel;U!==null&&U!==A;)U.v.gt(et),U=U.panel;tt+=X.x*g+X.offsetX-et.x,st+=X.y*y+X.offsetY-et.y,P.i(et)}else tt+=X.x*g+X.offsetX-(z.x*p.width+z.offsetX),st+=X.y*y+X.offsetY-(z.y*p.height+z.offsetY);N?(N=!1,n.e(tt,st,b,v)):n.re(tt,st,b,v)}switch(N?n.h(k):w?n.intersect(S.x,S.y,S.width,S.height):n.re(k.x,k.y,k.width,k.height),I.i(k),I.i(S),L=h.stretch,L===1&&(L=h.Qs(!1)),L){case 0:return;case 2:if(!isFinite(e)&&!isFinite(i))return;break;case 5:if(!isFinite(e))return;break;case 4:if(!isFinite(i))return;break}p=h.measuredBounds,g=p.width,y=p.height,b=Math.max(g+d,0),v=Math.max(y+f,0),l=h.margin,S=I.z(-l.left,-l.top,b,v),this.zC(h,S,!0),g=S.width,y=S.height;for(let M=0;M<a;M++){let A=s[M];if(A===h||!A.visible&&A!==D)continue;l=A.margin,u=l.right+l.left,c=l.top+l.bottom,p=A.measuredBounds,b=Math.max(p.width+u,0),v=Math.max(p.height+c,0);let F=A.alignment;F.isDefault()&&(F=t.defaultAlignment),F.isSpot()||(F=T.Center);let O=A.alignmentFocus;O.isDefault()&&(O=T.Center),N?(N=!1,n.e(F.x*g+F.offsetX-(O.x*p.width+O.offsetX)-l.left,F.y*y+F.offsetY-(O.y*p.height+O.offsetY)-l.top,b,v)):n.re(F.x*g+F.offsetX-(O.x*p.width+O.offsetX)-l.left,F.y*y+F.offsetY-(O.y*p.height+O.offsetY)-l.top,b,v)}N?n.h(k):w?n.intersect(S.x,S.y,S.width,S.height):n.re(k.x,k.y,k.width,k.height),I.i(S)}arrange(t,e,i){let s=e.length;if(s===0)return;let n=t.findMainElement(),o=n.measuredBounds,r=o.width,a=o.height,h=t.padding,l=h.left,u=h.top,c=l-i.x,d=u-i.y;n.Ut(c,d,r,a);let f=I.z(0,0,r,a);this.zC(n,f,!1);for(let p=0;p<s;p++){let g=e[p];if(g===n)continue;let y=g.measuredBounds,b=y.width,v=y.height,w=g.alignment;w.isDefault()&&(w=t.defaultAlignment),w.isSpot()||(w=T.Center);let k=g.alignmentFocus;k.isDefault()&&(k=T.Center);let S=null;if(g instanceof G&&g.fo!==""&&(S=g.findObject(g.fo),S===g&&(S=null)),S!==null){let N=S.actualBounds,D=P.z(N.x+(k.x*N.width-k.offsetX),N.y+(k.y*N.height-k.offsetY));for(S=S.panel;S!==null&&S!==g;)S.v.gt(D),S=S.panel;c=w.x*f.width+w.offsetX-D.x,d=w.y*f.height+w.offsetY-D.y,P.i(D)}else c=w.x*f.width+w.offsetX-(k.x*b+k.offsetX),d=w.y*f.height+w.offsetY-(k.y*v+k.offsetY);c+=f.x-i.x,d+=f.y-i.y,g.visible&&g.Ut(l+c,u+d,b,v)}I.i(f)}zC(t,e,i){let s=null;if(t instanceof G&&t.fo!==""&&(s=t.findObject(t.fo),s===t&&(s=null)),s!==null)for(i&&t.Ut(0,0,e.width,e.height),e.h(s.actualBounds),s=s.panel;s!==null&&s!==t;)s.v.im(e),s=s.panel}}Lt.Tn("Spot",new Mi);class zn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length;if(a===0)return;let h=t.findMainElement(),l=h.margin,u=e,c=i,d=l.right+l.left,f=l.top+l.bottom;h.ht(e,i,o,r);let p=h.measuredBounds,g=0,y=null;h instanceof it&&(y=h,g=y.strokeWidth*y.scale);let b=Math.max(p.width+d,0),v=Math.max(p.height+f,0),w=t.XC(h),k=w.x*b+w.offsetX,S=w.y*v+w.offsetY,N=t.GC(h),D=N.x*b+N.offsetX,L=N.y*v+N.offsetY;isFinite(e)&&(u=Math.max(Math.abs(k-D)-g,0)),isFinite(i)&&(c=Math.max(Math.abs(S-L)-g,0));let M=0,A=0;o>0&&(M=Math.max(Math.abs(w.x*o+w.offsetX-(N.x*o+N.offsetX))-g,0)),r>0&&(A=Math.max(Math.abs(w.y*r+w.offsetY-(N.y*r+N.offsetY))-g,0));let F=nt.l();F.e(0,0);let O=t.Jo();for(let z=0;z<a;z++){let U=s[z];if(U===h||!U.visible&&U!==O)continue;l=U.margin;let tt=l.right+l.left,st=l.top+l.bottom;U.ht(u,c,M,A),p=U.measuredBounds,b=Math.max(p.width+tt,0),v=Math.max(p.height+st,0),F.e(Math.max(b,F.width),Math.max(v,F.height))}if(a===1){p=h.measuredBounds,n.width=b,n.height=v,nt.i(F);return}w=t.XC(h),N=t.GC(h);let E=0,B=0;N.x!==w.x&&N.y!==w.y&&(E=F.width/Math.abs(N.x-w.x),B=F.height/Math.abs(N.y-w.y)),nt.i(F),g=0,y!==null&&(g=y.strokeWidth*y.scale,y.ZS()===6&&(E=B=Math.max(E,B))),E+=Math.abs(w.offsetX)+Math.abs(N.offsetX)+g,B+=Math.abs(w.offsetY)+Math.abs(N.offsetY)+g;let X=h.stretch;switch(X===1&&(X=h.Qs(!1)),X){case 0:o=0,r=0;break;case 2:isFinite(e)&&(E=e),isFinite(i)&&(B=i);break;case 5:isFinite(e)&&(E=e),r=0;break;case 4:o=0,isFinite(i)&&(B=i);break}h.kf(),h.ht(E,B,o,r),n.width=h.measuredBounds.width+d,n.height=h.measuredBounds.height+f}arrange(t,e,i){let s=e.length;if(s===0)return;let n=t.findMainElement(),o=n.measuredBounds,r=I.l();r.e(0,0,1,1);let a=n.margin,h=a.left,l=a.top,u=t.padding,c=u.left,d=u.top,f=h,p=l,g=o.width,y=o.height;n.Ut(c+f,d+p,g,y);let b=t.XC(n),v=t.GC(n),w=0+b.x*o.width+b.offsetX,k=0+b.y*o.height+b.offsetY,S=0+v.x*o.width+v.offsetX,N=0+v.y*o.height+v.offsetY;r.x=w,r.y=k,r.re(S,N,0,0),r.x+=h+c,r.y+=l+d;for(let D=0;D<s;D++){let L=e[D];if(L===n)continue;let M=L.measuredBounds;a=L.margin;let A=Math.max(M.width+a.right+a.left,0),F=Math.max(M.height+a.top+a.bottom,0),O=L.alignment;O.isDefault()&&(O=t.defaultAlignment),O.isSpot()||(O=T.Center),f=r.width*O.x+O.offsetX-A*O.x+a.left+r.x,p=r.height*O.y+O.offsetY-F*O.y+a.top+r.y,g=r.width,y=r.height,L.visible&&(I.contains(r.x,r.y,r.width,r.height,f,p,M.width,M.height)?L.Ut(f,p,M.width,M.height):L.Ut(f,p,M.width,M.height,new I(r.x,r.y,r.width,r.height)))}I.i(r)}}Lt.Tn("Auto",new zn);class Xn extends Lt{constructor(){super(),this.name="Table"}measure(t,e,i,s,n,o,r){let a=s.length,h=m.st(),l=m.st();for(let ot=0;ot<a;ot++){let H=s[ot],gt=H instanceof G?H:null;if(gt!==null&>.ol()&&H.visible){l.push(gt);let At=gt.D.r,$t=At.length;for(let Ut=0;Ut<$t;Ut++){let Gt=At[Ut];gt.type===G.TableRow?Gt.row=H.row:gt.type===G.TableColumn&&(Gt.column=H.column),h.push(Gt)}}else h.push(H)}a=h.length,a===0&&(t.getRowDefinition(0),t.getColumnDefinition(0));let u=[];for(let ot=0;ot<a;ot++){let H=h[ot];H.visible&&(H.xi(!0),H.lo(!0),u[H.row]||(u[H.row]=[]),u[H.row][H.column]||(u[H.row][H.column]=[]),u[H.row][H.column].push(H))}m.Z(h);let c=m.st(),d=m.st(),f=m.st(),p={count:0},g={count:0},y=e,b=i,v=t.Ii,w=t.Ei,k;a=v.length;for(let ot=0;ot<a;ot++)k=v[ot],k!==void 0&&(k.actual=0,k.ye=0);a=w.length;for(let ot=0;ot<a;ot++)k=w[ot],k!==void 0&&(k.actual=0,k.ye=0);let S=u.length,N=0;for(let ot=0;ot<S;ot++)u[ot]&&(N=Math.max(N,u[ot].length));let D=Math.min(t.topIndex,S-1),L=Math.min(t.leftIndex,N-1),M=0,A;S=u.length;let F=t.Jo();for(let ot=0;ot<S;ot++){if(!u[ot])continue;N=u[ot].length;let H=t.getRowDefinition(ot);H.actual=0,H.ye=0;for(let gt=0;gt<N;gt++){if(!u[ot][gt])continue;let At=t.getColumnDefinition(gt);c[gt]===void 0&&(At.actual=0,At.ye=0,c[gt]=!0);let $t=u[ot][gt],Ut=$t.length;for(let Gt=0;Gt<Ut;Gt++){let Wt=$t[Gt];if(!Wt.visible&&Wt!==F)continue;let ve=Wt.rowSpan>1,ce=Wt.columnSpan>1;(ve||ce)&&!(ot<D)&&!(gt<L)&&d.push(Wt);let fe=Wt.margin,Jt=fe.right+fe.left,Qt=fe.top+fe.bottom;A=Wt.Wp(H,At,!1);let pe=Wt.desiredSize,Ft=!isNaN(pe.width),qt=!isNaN(pe.height);if(A!==0&&!(Ft&&qt)&&!(ot<D)&&!(gt<L)&&(!ce&&p[gt]===void 0&&(A===2||A===5)&&(p[gt]=-1,p.count++),!ve&&g[ot]===void 0&&(A===2||A===4)&&(g[ot]=-1,g.count++),!ve&&!ce&&f.push(Wt)),Wt.ht(1/0,1/0,0,0),ot<D||gt<L)continue;let Ht=Wt.measuredBounds,ke=Math.max(Ht.width+Jt,0),Ae=Math.max(Ht.height+Qt,0);if(Wt.rowSpan===1&&(A===0||A===5)){k=t.getRowDefinition(ot);let Pe=k.computeEffectiveSpacing(),mi=k.q===0;M=Math.max(Ae-k.actual,0),M+(mi?Pe:0)>b&&(M=Math.max(b-Pe,0)),k.ye=k.ye+M,k.actual=k.q+M,b=Math.max(b-(M+(mi?Pe:0)),0)}if(Wt.columnSpan===1&&(A===0||A===4)){k=t.getColumnDefinition(gt);let Pe=k.computeEffectiveSpacing(),mi=k.q===0;M=Math.max(ke-k.actual,0),M+(mi?Pe:0)>y&&(M=Math.max(y-Pe,0)),k.ye=k.ye+M,k.actual=k.q+M,y=Math.max(y-(M+(mi?Pe:0)),0)}(ve||ce)&&Wt.kf()}}}m.Z(c);let O=0,E=0;a=t.columnCount;for(let ot=0;ot<a;ot++){let H=w[ot];H!==void 0&&(O+=isNaN(H.ki)?H.ye:H.ki,H.ye!==0&&(O+=H.computeEffectiveSpacing()))}a=t.rowCount;for(let ot=0;ot<a;ot++){let H=v[ot];H!==void 0&&(E+=isNaN(H.ki)?H.ye:H.ki,H.ye!==0&&(E+=H.computeEffectiveSpacing()))}y=Math.max(e-O,0),b=Math.max(i-E,0);let B=b,X=y;a=f.length;for(let ot=0;ot<a;ot++){let H=f[ot],gt=t.getRowDefinition(H.row),At=t.getColumnDefinition(H.column),$t=H.measuredBounds,Ut=H.margin,Gt=Ut.right+Ut.left,Wt=Ut.top+Ut.bottom;At.ye===0&&p[H.column]!==void 0?p[H.column]=Math.max($t.width+Gt,p[H.column]):p[H.column]=null,gt.ye===0&&g[H.row]!==void 0?g[H.row]=Math.max($t.height+Wt,g[H.row]):g[H.row]=null}let z=0,U=0,tt;for(tt in g)tt!=="count"&&(z+=g[tt]);for(tt in p)tt!=="count"&&(U+=p[tt]);let st=nt.l();for(let ot=0;ot<a;ot++){let H=f[ot];if(!H.visible&&H!==F)continue;let gt=t.getRowDefinition(H.row),At=t.getColumnDefinition(H.column),$t=0;isFinite(At.width)?$t=At.width:(isFinite(y)&&p[H.column]!==null?U===0?$t=At.actual+y:$t=p[H.column]/U*X:p[H.column]!==null?$t=y:$t=At.actual||y,$t=Math.max(0,$t-At.computeEffectiveSpacing()));let Ut=0;switch(isFinite(gt.height)?Ut=gt.height:(isFinite(b)&&g[H.row]!==null?z===0?Ut=gt.actual+b:Ut=g[H.row]/z*B:g[H.row]!==null?Ut=b:Ut=gt.actual||b,Ut=Math.max(0,Ut-gt.computeEffectiveSpacing())),st.e(Math.max(At.minimum,Math.min($t,At.maximum)),Math.max(gt.minimum,Math.min(Ut,gt.maximum))),A=H.Wp(gt,At,!1),A){case 5:st.height=Math.max(st.height,gt.actual+b);break;case 4:st.width=Math.max(st.width,At.actual+y);break}let Gt=H.margin,Wt=Gt.right+Gt.left,ve=Gt.top+Gt.bottom;H.kf();let ce=At.minimum,fe=gt.minimum,Jt=H.measuredBounds;Jt.width===0&&p[H.column]!==null&&(ce=Math.max(ce,p[H.column])),Jt.height===0&&g[H.row]!==null&&(fe=Math.max(ce,g[H.row])),H.ht(st.width,st.height,ce,fe);let Qt=H.measuredBounds,pe=Math.max(Qt.width+Wt,0),Ft=Math.max(Qt.height+ve,0);isFinite(y)&&(pe=Math.min(pe,st.width)),isFinite(b)&&(Ft=Math.min(Ft,st.height));let qt=0;qt=gt.actual,gt.actual=Math.max(gt.actual,Ft),gt.ye=Math.max(gt.ye,Ft),M=gt.actual-qt,b=Math.max(b-M,0),g[H.row]===null&&(B=Math.max(B-M,0)),qt=At.actual,At.actual=Math.max(At.actual,pe),At.ye=Math.max(At.ye,pe),M=At.actual-qt,y=Math.max(y-M,0),p[H.column]===null&&(X=Math.max(X-M,0))}m.Z(f);let Z=nt.l(),et=m.st(),Q=m.st();if(a=d.length,a!==0)for(let ot=0;ot<S;ot++){if(!u[ot])continue;N=u[ot].length;let H=t.getRowDefinition(ot);et[ot]=H.actual;for(let gt=0;gt<N;gt++){if(!u[ot][gt])continue;let At=t.getColumnDefinition(gt);Q[gt]=At.actual}}for(let ot=0;ot<a;ot++){let H=d[ot];if(!H.visible&&H!==F)continue;let gt=t.getRowDefinition(H.row),At=t.getColumnDefinition(H.column);switch(st.e(Math.max(At.minimum,Math.min(e,At.maximum)),Math.max(gt.minimum,Math.min(i,gt.maximum))),A=H.Wp(gt,At,!1),A){case 2:Q[At.index]!==0&&(st.width=Math.min(st.width,Q[At.index])),et[gt.index]!==0&&(st.height=Math.min(st.height,et[gt.index]));break;case 5:Q[At.index]!==0&&(st.width=Math.min(st.width,Q[At.index]));break;case 4:et[gt.index]!==0&&(st.height=Math.min(st.height,et[gt.index]));break}if(A===2||A===4){let Ft=0;for(let qt=0;qt<t.rowCount;qt++){if(qt>=H.row&&qt<H.row+H.rowSpan)continue;let Ht=t.Ii[qt];Ht!==void 0&&(Ft+=et[qt]||0,Ht.ye!==0&&(Ft+=Ht.computeEffectiveSpacing()))}st.height=Math.max(st.height-Ft,0)}if(A===2||A===5){let Ft=0;for(let qt=0;qt<t.columnCount;qt++){if(qt>=H.column&&qt<H.column+H.columnSpan)continue;let Ht=t.Ei[qt];Ht!==void 0&&(Ft+=Q[qt]||0,Ht.ye!==0&&(Ft+=Ht.computeEffectiveSpacing()))}st.width=Math.max(st.width-Ft,0)}isFinite(At.width)&&(st.width=At.width),isFinite(gt.height)&&(st.height=gt.height),Z.e(0,0);let $t=At.minimum,Ut=gt.minimum;for(let Ft=1;Ft<H.rowSpan&&!(H.row+Ft>=t.rowCount);Ft++){if(k=t.getRowDefinition(H.row+Ft),M=0,A===2||A===4){if(k.q===0)continue;M=Math.max(k.minimum,k.q===0?k.maximum:Math.min(k.q,k.maximum))}else M=Math.max(k.minimum,isNaN(k.ki)?k.maximum:Math.min(k.ki,k.maximum));Z.height+=M,Ut+=k.minimum}for(let Ft=1;Ft<H.columnSpan&&!(H.column+Ft>=t.columnCount);Ft++){if(k=t.getColumnDefinition(H.column+Ft),M=0,A===2||A===5){if(k.q===0)continue;M=Math.max(k.minimum,k.q===0?k.maximum:Math.min(k.q,k.maximum))}else M=Math.max(k.minimum,isNaN(k.ki)?k.maximum:Math.min(k.ki,k.maximum));Z.width+=M,$t+=k.minimum}st.width+=Z.width,st.height+=Z.height;let Gt=H.margin,Wt=Gt.right+Gt.left,ve=Gt.top+Gt.bottom;H.ht(st.width,st.height,$t,Ut);let ce=H.measuredBounds,fe=Math.max(ce.width+Wt,0),Jt=Math.max(ce.height+ve,0),Qt=0;for(let Ft=0;Ft<H.rowSpan&&!(H.row+Ft>=t.rowCount);Ft++)k=t.getRowDefinition(H.row+Ft),Qt+=k.total||0;if(Qt<Jt){let Ft=Jt-Qt,qt=Jt-Qt;if(H.spanAllocation!==null){let Ht=H.spanAllocation;for(let ke=0;ke<H.rowSpan&&!(Ft<=0||H.row+ke>=t.rowCount);ke++){k=t.getRowDefinition(H.row+ke);let Ae=k.q||0,Pe=Ht(H,k,qt);k.actual=Math.min(k.maximum,Ae+Pe),k.q!==Ae&&(Ft-=k.q-Ae)}}for(;Ft>0&&k!==void 0;){let Ht=k.q||0;if(isNaN(k.height)&&k.maximum>Ht&&(k.actual=Math.min(k.maximum,Ht+Ft),k.q!==Ht&&(Ft-=k.q-Ht)),k.index===0)break;k=t.getRowDefinition(k.index-1)}}let pe=0;for(let Ft=0;Ft<H.columnSpan&&!(H.column+Ft>=t.columnCount);Ft++)k=t.getColumnDefinition(H.column+Ft),pe+=k.total||0;if(pe<fe){let Ft=fe-pe,qt=fe-pe;if(H.spanAllocation!==null){let Ht=H.spanAllocation;for(let ke=0;ke<H.columnSpan&&!(Ft<=0||H.column+ke>=t.columnCount);ke++){k=t.getColumnDefinition(H.column+ke);let Ae=k.q||0,Pe=Ht(H,k,qt);k.actual=Math.min(k.maximum,Ae+Pe),k.q!==Ae&&(Ft-=k.q-Ae)}}for(;Ft>0&&k!==void 0;){let Ht=k.q||0;if(isNaN(k.width)&&k.maximum>Ht&&(k.actual=Math.min(k.maximum,Ht+Ft),k.q!==Ht&&(Ft-=k.q-Ht)),k.index===0)break;k=t.getColumnDefinition(k.index-1)}}}m.Z(d),nt.i(Z),nt.i(st),et!==void 0&&m.Z(et),Q!==void 0&&m.Z(Q);let rt=0,ft=0,xt=t.desiredSize,Ct=t.maxSize;A=t.Qs(!0),O=0,E=0;let _=0,St=0;a=t.columnCount;for(let ot=0;ot<a;ot++)if(w[ot]!==void 0){if(k=t.getColumnDefinition(ot),isFinite(k.width)){_+=k.width,_+=k.computeEffectiveSpacing();continue}else if(k.Y1()===2){_+=k.q,_+=k.computeEffectiveSpacing();continue}k.q!==0&&(O+=k.q,O+=k.computeEffectiveSpacing())}isFinite(xt.width)?rt=Math.min(xt.width,Ct.width):A!==0&&isFinite(e)?rt=e:rt=O,rt=Math.max(rt,isFinite(e)?Math.min(o,e):o),rt=Math.max(rt-_,0);let bt=O===0?1:Math.max(rt/O,1);for(let ot=0;ot<a;ot++)w[ot]!==void 0&&(k=t.getColumnDefinition(ot),!isFinite(k.width)&&k.Y1()!==2&&(k.actual=k.q*bt),k.position=n.width,k.q!==0&&(n.width+=k.q,n.width+=k.computeEffectiveSpacing()));a=t.rowCount;for(let ot=0;ot<a;ot++)if(v[ot]!==void 0){if(k=t.getRowDefinition(ot),isFinite(k.height)){St+=k.height,St+=k.computeEffectiveSpacing();continue}else if(k.Y1()===2){St+=k.q,St+=k.computeEffectiveSpacing();continue}k.q!==0&&(E+=k.q,E+=k.computeEffectiveSpacing())}isFinite(xt.height)?ft=Math.min(xt.height,Ct.height):A!==0&&isFinite(i)?ft=i:ft=E,ft=Math.max(ft,isFinite(i)?Math.min(r,i):r),ft=Math.max(ft-St,0);let Yt=E===0?1:Math.max(ft/E,1);for(let ot=0;ot<a;ot++)v[ot]!==void 0&&(k=t.getRowDefinition(ot),!isFinite(k.height)&&k.Y1()!==2&&(k.actual=k.q*Yt),k.position=n.height,k.q!==0&&(n.height+=k.q,n.height+=k.computeEffectiveSpacing()));a=l.length;for(let ot=0;ot<a;ot++){let H=l[ot],gt=0,At=0;H.type===G.TableRow?(gt=n.width,k=t.getRowDefinition(H.row),At=k.actual):(k=t.getColumnDefinition(H.column),gt=k.actual,At=n.height),H.measuredBounds.e(0,0,gt,At),H.xi(!1)}m.Z(l),t.La=u}arrange(t,e,i){let s=e.length,n=t.padding,o=n.left,r=n.top,a=t.La;if(a===null)return;let h=0,l=0,u=a.length,c=0;for(let L=0;L<u;L++)a[L]&&(c=Math.max(c,a[L].length));let d=t.Ii,f=t.Ei,p=0,g=0,y=Math.min(t.topIndex,u-1);if(d.length>0){for(;y!==u&&(d[y]===void 0||d[y].q===0);)y++;y=Math.max(Math.min(y,u-1),0),p=-d[y].position}let b=Math.min(t.leftIndex,c-1);if(f.length>0){for(;b!==c&&(f[b]===void 0||f[b].q===0);)b++;b=Math.max(Math.min(b,c-1),0),g=-f[b].position}let v=0,w=0;for(;v!==u&&d[v]===void 0;)v++;for(;w!==u&&f[w]===void 0;)w++;let k=t.part,S=t.getRowDefinition(v),N=t.getColumnDefinition(w);for(let L=0;L<e.length;L++){let M=e[L];if(!(M instanceof G&&M.visible&&M.ol()))continue;M.type===G.TableRow?(S=t.getRowDefinition(M.row),N=t.getColumnDefinition(w)):(S=t.getRowDefinition(v),N=t.getColumnDefinition(M.column)),l=S.position+p+r,S.q!==0&&(l+=S.computeEffectiveSpacingTop(Math.max(v,y))),h=N.position+g+o,N.q!==0&&(h+=N.computeEffectiveSpacingTop(Math.max(w,b)));let A=M.measuredBounds;M.yf(),M.actualBounds.ce();let F=M.actualBounds,O=I.z(F.x,F.y,F.width,F.height);if(F.x=M.type===G.TableRow?o:h,F.y=M.type===G.TableColumn?r:l,F.width=A.width,F.height=A.height,M.actualBounds.k(),M.lo(!1),O.equalsApproxClose(F)){I.i(O);continue}k!==null&&(k.Pa(),M.Kp(k)),I.i(O)}let D=nt.l();for(let L=0;L<u;L++){if(!a[L])continue;c=a[L].length;let M=t.getRowDefinition(L);l=M.position+p+r,M.q!==0&&(l+=M.computeEffectiveSpacingTop(Math.max(v,y)));for(let A=0;A<c;A++){if(!a[L][A])continue;let F=t.getColumnDefinition(A);h=F.position+g+o,F.q!==0&&(h+=F.computeEffectiveSpacingTop(Math.max(w,b)));let O=a[L][A],E=O.length;for(let B=0;B<E;B++){let X=O[B],z=X.measuredBounds;D.e(0,0);for(let Jt=1;Jt<X.rowSpan&&!(L+Jt>=t.rowCount);Jt++){let Qt=t.getRowDefinition(L+Jt);Qt.q!==0&&(D.height+=Qt.total)}for(let Jt=1;Jt<X.columnSpan&&!(A+Jt>=t.columnCount);Jt++){let Qt=t.getColumnDefinition(A+Jt);Qt.q!==0&&(D.width+=Qt.total)}let U=F.q+D.width,tt=M.q+D.height,st=h,Z=l,et=U,Q=tt,rt=h,ft=l,xt=U,Ct=tt;h+U>i.width&&(xt=Math.max(i.width-h,0)),l+tt>i.height&&(Ct=Math.max(i.height-l,0));let _=X.alignment,St=0,bt=0,Yt=0,ot=0;if(_.isDefault()){_=t.defaultAlignment,_.isSpot()||(_=T.Center),St=_.x,bt=_.y,Yt=_.offsetX,ot=_.offsetY;let Jt=F.alignment,Qt=M.alignment;Jt.isSpot()&&(St=Jt.x,Yt=Jt.offsetX),Qt.isSpot()&&(bt=Qt.y,ot=Qt.offsetY)}else St=_.x,bt=_.y,Yt=_.offsetX,ot=_.offsetY;(isNaN(St)||isNaN(bt))&&(St=.5,bt=.5,Yt=0,ot=0);let H=z.width,gt=z.height,At=X.margin,$t=At.left+At.right,Ut=At.top+At.bottom,Gt=X.Wp(M,F,!1);isNaN(X.desiredSize.width)&&(Gt===2||Gt===5)&&(H=Math.max(U-$t,0)),isNaN(X.desiredSize.height)&&(Gt===2||Gt===4)&&(gt=Math.max(tt-Ut,0));let Wt=X.maxSize,ve=X.minSize;H=Math.min(Wt.width,H),gt=Math.min(Wt.height,gt),H=Math.max(ve.width,H),gt=Math.max(ve.height,gt);let ce=H+$t,fe=gt+Ut;st+=et*St-ce*St+Yt+At.left,Z+=Q*bt-fe*bt+ot+At.top,X.visible&&(I.contains(rt,ft,xt,Ct,st,Z,z.width,z.height)?X.Ut(st,Z,H,gt):X.Ut(st,Z,H,gt,new I(rt,ft,xt,Ct)))}}}nt.i(D);for(let L=0;L<s;L++){let M=e[L],A=M instanceof G?M:null;if(A!==null&&A.ol()){let F=M.actualBounds;M.naturalBounds.ce(),M.naturalBounds.e(0,0,F.width,F.height),M.naturalBounds.k()}}}}Lt.Tn("Table",new Xn);class Kn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){}arrange(t,e,i){}}Lt.Tn("TableRow",new Kn);class Yn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){}arrange(t,e,i){}}Lt.Tn("TableColumn",new Yn);class Un extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){s.length!==1&&m.o("Viewbox Panel must contain exactly one GraphObject.");let a=s[0];a.et=1,a.kf(),a.ht(1/0,1/0,o,r);let h=a.measuredBounds,l=a.margin,u=l.right+l.left,c=l.top+l.bottom;if(isFinite(e)||isFinite(i)){let d=a.scale,f=h.width,p=h.height,g=Math.max(e-u,0),y=Math.max(i-c,0),b=1;t.viewboxStretch===6?(f!==0&&p!==0&&(b=Math.min(g/f,y/p)),b===0&&(b=1e-4),a.et*=b):(f!==0&&p!==0&&(b=Math.max(g/f,y/p)),b===0&&(b=1e-4),a.et*=b),d!==a.scale&&(a.xi(!0),a.ht(1/0,1/0,o,r))}h=a.measuredBounds,n.width=isFinite(e)?e:Math.max(h.width+u,0),n.height=isFinite(i)?i:Math.max(h.height+c,0)}arrange(t,e,i){let s=e[0],n=s.measuredBounds,o=s.margin,r=o.right+o.left,a=o.top+o.bottom,h=Math.max(n.width+r,0),l=Math.max(n.height+a,0),u=s.alignment;u.isDefault()&&(u=t.defaultAlignment),u.isSpot()||(u=T.Center),s.Ut(i.width*u.x-h*u.x+u.offsetX,i.height*u.y-l*u.y+u.offsetY,n.width,n.height)}}Lt.Tn("Viewbox",new Un);class jn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){t.Se===null&&(t.Se=new ti),this.OI(t),this.II(t)}arrange(t,e,i){}Ge(t,e,i){let s=t.naturalBounds;e.save(),e.beginPath(),e.rect(0,0,s.width,s.height),e.clip(),e.endPath(),this.EI(t,e,i),e.restore(),e.clearContextCache(!1)}EI(t,e,i){let s=t.getDocumentScale()*i.scale;s<=0&&(s=1);let n=t.gridCellSize,o=n.width,r=n.height,a=t.naturalBounds,h=t.actualBounds,l=a.width,u=a.height,c=Math.ceil(l/o),d=Math.ceil(u/r),f=t.gridOrigin,p=f.x,g=f.y,y=t.Se.k0,b=t.D.r,v=b.length;for(let w=0;w<v;w++){let k=b[w];if(!k.visible)continue;let S=k.interval||1,N=Math.abs(S);if(o*N*s<2)continue;let D=k.segmentIndex;(!isFinite(D)||isNaN(D))&&(D=0),D<0&&(D=N-Math.min(-D,N)),D=Math.round(D%N);let L=k.opacity,M=1;if(L!==1){if(L===0)continue;M=e.globalAlpha,e.globalAlpha=M*L}let A=y[w],F=!1,O=k.strokeDashArray;if(O!==null&&(F=!0,e.enableDash(O,k.strokeDashOffset)),k.stroke!==null&&k.strokeWidth>0&&(k.figure==="LineV"||k.figure==="LineH")){if(e.lineWidth=k.strokeWidth,t.kn(e,k.stroke,!1,!1,a,h),e.beginPath(),k.figure==="LineV"){let E=Math.floor((p-o)/o);for(let B=E;B<=E+c;B++){let X=B*o+p;0<=X&&X<=l&&this.K1(B,S,D,A)&&(e.moveTo(X,0),e.lineTo(X,u))}}else if(k.figure==="LineH"){let E=Math.floor((g-r)/r);for(let B=E;B<=E+d;B++){let X=B*r+g;0<=X&&X<=u&&this.K1(B,S,D,A)&&(e.moveTo(0,X),e.lineTo(l,X))}}e.stroke(),e.endPath()}else if(k.fill!==null){if(t.kn(e,k.fill,!0,!1,a,h),k.figure==="BarV"){let E=k.width;isNaN(E)&&(E=o);let B=Math.floor((p-o)/o);for(let X=B;X<=B+c;X++){let z=X*o+p;0<=z+E&&z<=l&&this.K1(X,S,D,A)&&e.fillRect(z,0,E,u)}}else if(k.figure==="BarH"){let E=k.height;isNaN(E)&&(E=r);let B=Math.floor((g-r)/r);for(let X=B;X<=B+d;X++){let z=X*r+g;0<=z+E&&z<=u&&this.K1(X,S,D,A)&&e.fillRect(0,z,l,E)}}}F&&e.disableDash(),L!==1&&(e.globalAlpha=M)}}K1(t,e,i,s){if(e<0)return t%e===i;if(t%e!==i)return!1;let n=s.length;for(let o=0;o<n;o++){let r=s[o];if(t%r===i)return!1}return!0}II(t){let e=[],i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n],r=[];if(e.push(r),!o.visible)continue;let a=o.interval;if(a<0)continue;let h=o.figure,l=this.YC(h);for(let u=0;u<s;u++){if(u===n)continue;let c=i[u];if(!c.visible)continue;let d=c.figure;if(this.YC(d)!==l)continue;let f=c.interval;f>a&&r.push(f)}}t.Se.k0=e}YC(t){return t==="LineV"||t==="BarV"}OI(t){let e=1,i=1,s=t.D.r,n=s.length;for(let a=0;a<n;a++){let h=s[a],l=Math.abs(h.interval);l<2||(this.YC(h.figure)?i=i*l/C.HL(i,l):e=e*l/C.HL(e,l))}let o=t.gridCellSize,r=t.Se;r.hf.isReal()?r.hf.e(i*o.width,e*o.height):r.hf=new nt(i*o.width,e*o.height)}}Lt.Tn("Grid",new jn);class Gn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length;if(!(t instanceof vt||t instanceof j))return;let h=null,l=null;if(t instanceof j&&(h=t),t instanceof vt&&(l=t,h=l.adornedPart,t.Af===null&&(t.Af=[])),!(h instanceof j))return;let u=h;if(a===0){t.naturalBounds.Kn(0,0),t.measuredBounds.e(0,0,0,0);return}let c=t instanceof vt?null:h.path,d=h.routeBounds,f=t.$o;f.e(0,0,d.width,d.height);let p=u.points,g=h.pointsCount;l!==null?l.Dd(!1):h!==null&&h.Dd(!1);let y=d.width,b=d.height,v=t.Af;if(v.length=0,c!==null){this.measureLinkPath(t,y,b,c);let N=c.measuredBounds;f.unionRect(N),v.push(N)}let w=Nt.l(),k=P.l(),S=P.l();for(let N=0;N<a;N++){let D=s[N];if(D===c)continue;let L=D.measuredBounds;if(D.isPanelMain&&D instanceof it){this.measureLinkPath(t,y,b,D),L=D.measuredBounds,f.unionRect(L),v.push(L);continue}if(g<2){D.ht(1/0,1/0,0,0),L=D.measuredBounds,f.unionRect(L),v.push(L);continue}let M=D.segmentIndex,A=D.segmentFraction,F=D.alignmentFocus;F.isNoSpot()&&(F=T.Center);let O=D.segmentOrientation,E=D.segmentOffset,B=0,X=0,z=0,U=0;if(isNaN(M)){let _=u.ut,St=m.st();_.getPointAndAngleAlongPath(A,St);let bt=P.z(St[0],St[1]);U=St[2],O!==0&&(z=u.computeAngle(D,O,U),D.Xt=z,D.xi(!0),D.lo(!0)),B=bt.x,X=bt.y,P.i(bt),m.Z(St)}else if(M<-g||M>=g){let _=P.l();u.KC(_),U=u.midAngle,O!==0&&(z=u.computeAngle(D,O,U),D.Xt=z,D.xi(!0),D.lo(!0)),B=_.x-d.x,X=_.y-d.y,P.i(_)}else{let _,St,bt=0;if(M>=0?(_=p.elt(M),St=M<g-1?p.elt(M+1):_):(bt=g+M,_=p.elt(bt),St=bt>0?p.elt(bt-1):_),_.equalsApprox(St)){let Yt,ot;M>=0?(Yt=M>0?p.elt(M-1):_,ot=M<g-2?p.elt(M+2):St):(Yt=bt<g-1?p.elt(bt+1):_,ot=bt>1?p.elt(bt-2):St);let H=Yt.distanceSquaredPoint(_),gt=St.distanceSquaredPoint(ot);H>gt+10?U=M>=0?Yt.directionPoint(_):_.directionPoint(Yt):gt>H+10?U=M>=0?St.directionPoint(ot):ot.directionPoint(St):U=M>=0?Yt.directionPoint(ot):ot.directionPoint(Yt)}else U=M>=0?_.directionPoint(St):St.directionPoint(_);O!==0&&(z=u.computeAngle(D,O,U),D.Xt=z,D.xi(!0),D.lo(!0)),B=_.x+(St.x-_.x)*A-d.x,X=_.y+(St.y-_.y)*A-d.y}D.ht(1/0,1/0,0,0),L=D.measuredBounds;let tt=D.naturalBounds,st=0;D instanceof it&&(st=D.strokeWidth);let Z=tt.width+st,et=tt.height+st;w.Ue(),w.Gs(-L.x,-L.y),w.et(D.scale,D.scale),w.ks(O===0?D.angle:U,Z/2,et/2),(O===22||O===26)&&w.ks(90,Z/2,et/2),(O===23||O===27)&&w.ks(-90,Z/2,et/2),O===28&&(U>45&&U<135||U>225&&U<315)&&w.ks(-U,Z/2,et/2);let Q=new I(0,0,Z,et);k.setRectSpot(Q,F),w.gt(k);let rt=-k.x+st/2*D.scale,ft=-k.y+st/2*D.scale;S.h(E);let xt=isNaN(E.x),Ct=isNaN(E.y);if(xt||Ct){let _=Z/2+j.H1,St=et/2+j.H1,bt=U>=45&&U<=135,Yt=U>=225&&U<=315;O===0&&(bt||Yt)?(S.x=Ct?_:E.y,S.y=xt?St:E.x,bt?M>=0||isNaN(M)&&A<.5||xt&&(S.y=-St):Yt&&((M>=0||isNaN(M)&&A<.5)&&xt&&(S.y=-St),Ct&&(S.x=-_))):(xt&&(M>=0||isNaN(M)&&A<.5?S.x=_:S.x=-_),Ct&&(S.y=-St),S.rotate(U))}else S.rotate(U);B+=S.x,X+=S.y,Q.e(B+rt,X+ft,L.width,L.height),v.push(Q),f.unionRect(Q)}if(h!==null){let N=h.labelNodes;for(;N.next();)N.value.ht(1/0,1/0)}t.$o=f,t.position.e(d.x+f.x,d.y+f.y),n.Kn(f.width||0,f.height||0),Nt.i(w),P.i(k),P.i(S)}arrange(t,e,i){let s=e.length;if(!(t instanceof vt||t instanceof j))return;let n=t,o=null;t instanceof vt&&(o=t,n=o.adornedPart);let r=t,a=t instanceof vt?null:n.path,h=t.Af;if(h.length!==0){let d=0;if(a!==null&&d<h.length){let f=h[d];d++,a.Ut(f.x-r.$o.x,f.y-r.$o.y,f.width,f.height)}for(let f=0;f<s;f++){let p=e[f];if(p!==a&&d<h.length){let g=h[d];d++,p.Ut(g.x-r.$o.x,g.y-r.$o.y,g.width,g.height)}}}let l=n.points,u=l.count;if(u>=2&&r instanceof j){let d=r.labelNodes;for(;d.next();){let f=d.value;r.UI(f,u,l)}}o!==null?o.Dd(!1):n.Dd(!1);let c=t.fD(P.l());t.location.e(t.position.x+c.x,t.position.y+c.y),P.i(c)}measureLinkPath(t,e,i,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof vt&&t.type===G.Link&&t.adornedObject instanceof it&&(n=t.adornedObject.strokeWidth),n=n*s.et,t instanceof j&&t.ut!==null){let o=t.geometry.bounds;s.ro(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof vt&&t.adornedPart.ut!==null){let o=t.adornedPart.ut.bounds;s.ro(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.ro(-(n/2),-(n/2),e+n,i+n);s.VI(),s.xi(!1)}}Lt.Tn("Link",new Gn);class qn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=t.findMainElement();if(!(a instanceof it))return;t._i=[];let h=a.margin,l=h.right+h.left,u=h.top+h.bottom;a.ht(e,i,o,r);let c=a.measuredBounds,d=c.width,f=c.height,p=Math.max(d+l,0),g=Math.max(f+u,0),y=new I(-h.left,-h.top,p,g);t._i.push(y),n.h(y),this.determineGraduatedMarks(t,a);let b=t.vs;if(b===null)return;let v=s.length;for(let w=0;w<v;w++){let k=s[w],S=b[w];!k.visible||k===a||S.length===0||(k instanceof it?this.measureGraduatedTicks(t,k,S,n):k instanceof lt&&this.measureGraduatedLabels(t,k,S,n),k.xi(!1))}}arrange(t,e,i){if(t._i===null)return;let s=t.findMainElement(),n=t.vs;if(n===null)return;let o=t._i,r=0,a=o[r];r++,s!==null&&s.Ut(a.x-i.x,a.y-i.y,a.width,a.height);let h=e.length;for(let l=0;l<h;l++){let u=e[l],c=n[l];!u.visible||u===s||c.length===0||(a=o[r],r++,u.Ut(a.x-i.x,a.y-i.y,a.width,a.height))}t._i=null}measureGraduatedTicks(t,e,i,s){let n=e.alignmentFocus;n.isNoSpot()&&(n=T.TopCenter);let o=e.angle;e.Xt=0,e.ht(1/0,1/0,0,0),e.Xt=o;let r=e.measuredBounds,a=r.width,h=r.height,l=I.z(0,0,a,h),u=P.l();u.setRectSpot(l,n),I.i(l);let c=-u.x,d=-u.y,f=new I,p=i.length;for(let g=0;g<p;g++){let y=i[g],b=y.pt.x,v=y.pt.y,w=y.angle;for(let k=0;k<4;k++){switch(k){case 0:u.e(c,d);break;case 1:u.e(c+a,d);break;case 2:u.e(c,d+h);break;case 3:u.e(c+a,d+h);break}u.rotate(w+e.angle),u.offset(b,v),g===0&&k===0?f.e(u.x,u.y,0,0):f.unionPoint(u),u.offset(-b,-v),u.rotate(-w-e.angle)}}P.i(u),t._i!==null&&t._i.push(f),s.re(f.x,f.y,f.width,f.height)}measureGraduatedLabels(t,e,i,s){t.vi===null&&(t.vi=new lt);let n=t.vi;this.uD(e,n);let o=e.alignmentFocus;o.isNoSpot()&&(o=T.TopCenter);let r=e.segmentOrientation,a=e.segmentOffset,h=new I,l=0,u=0,c=0,d=0,f=0,p=i.length;for(let g=0;g<p;g++){let y=i[g];l=y.pt.x,u=y.pt.y,c=y.angle,d=e.angle,f=e.angle,r!==0&&(r===21||r===25?f=c+e.angle:f=c,d=j.computeAngle(r,f)),n.Xt=d,n.text=y.text||"",n.ht(1/0,1/0,0,0);let b=n.measuredBounds,v=n.naturalBounds,w=v.width,k=v.height,S=Nt.l();S.Ue(),S.Gs(-b.x,-b.y),S.et(n.scale,n.scale),S.ks(f,w/2,k/2),(r===22||r===26)&&S.ks(90,w/2,k/2),(r===23||r===27)&&S.ks(-90,w/2,k/2),r===28&&(c>45&&c<135||c>225&&c<315)&&S.ks(-c,w/2,k/2);let N=I.z(0,0,w,k),D=P.l();D.setRectSpot(N,o),S.gt(D);let L=-D.x,M=-D.y,A=P.l();A.h(a),isNaN(A.x)&&(A.x=w/2+3),isNaN(A.y)&&(A.y=-(k/2+3)),A.rotate(c),l+=A.x+L,u+=A.y+M;let F=new I(l,u,b.width,b.height),O=new I(b.x,b.y,b.width,b.height),E=new I(v.x,v.y,v.width,v.height);y.labelAngle=d,y.lineCount=n.lineCount,y.lines=n.getMetrics(),y.actualBounds=F,y.measuredBounds=O,y.naturalBounds=E,g===0?h.h(F):h.unionRect(F),P.i(A),P.i(D),I.i(N),Nt.i(S)}t._i!==null&&t._i.push(h),s.re(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,e){let i=e.geometry,s=e.strokeWidth,n=i.flattenedSegments,o=i.flattenedLengths,r=i.flattenedTotalLength,a=n.length,h=0,l=0,u=m.st();for(let v=0;v<a;v++){let w=n[v],k=[];h=0,l=0;let S=w.length;for(let N=0;N<S;N+=2){let D=w[N],L=w[N+1];if(N===0){h=D,l=L;continue}let M=Math.atan2(L-l,D-h)*180/Math.PI;M<0&&(M+=360),k.push(M),h=D,l=L}u.push(k)}let c=this.BI(t),d=t.D.r,f=d.length,p=0,g=0,y=r;t.vs=[];let b;for(let v=0;v<f;v++){let w=d[v];if(b=[],!w.visible||w===e){t.vs.push(b);continue}let k=Math.abs(w.interval),S=t.graduatedTickUnit;if(S*k*r/t.graduatedRange<2&&w.graduatedSkip===null){t.vs.push(b);continue}let N=o[0][0],D=0,L=0;g=r*w.graduatedStart-1e-4,y=r*w.graduatedEnd+1e-4;let M=S*k,A=t.graduatedTickBase;if(A<t.graduatedMin){let B=(t.graduatedMin-A)/M;B=B%1===0?B:Math.floor(B+1),A+=B*M}else if(A>t.graduatedMin+M){let B=Math.floor((A-t.graduatedMin)/M);A-=B*M}let F=c[v],O=A,E=t.graduatedMax*1e-6;for(let B=1;A<=t.graduatedMax+E;B++){if(this.zI(t,A-t.graduatedTickBase,F)&&(A>t.graduatedMax&&(A=t.graduatedMax),(w.graduatedSkip===null||w instanceof lt&&!w.graduatedSkip(A,w)||w instanceof it&&!w.graduatedSkip(A,w))&&(p=(A-t.graduatedMin)*r/t.graduatedRange,p>r&&(p=r),g<=p&&p<=y))){let X=u[D][L],z=o[D][L];for(;D<o.length;){for(;p>N&&L<o[D].length-1;)L++,X=u[D][L],z=o[D][L],N+=z;if(p<=N)break;D++,L=0,X=u[D][L],z=o[D][L],N+=z}let U=n[D],tt=U[L*2],st=U[L*2+1],Z=U[L*2+2],et=U[L*2+3],Q=(p-(N-z))/z,rt=new P(tt+(Z-tt)*Q+s/2-i.bounds.x,st+(et-st)*Q+s/2-i.bounds.y);if(rt.scale(e.scale,e.scale),X=this.XI(X,Q,U,u[D],L),w instanceof lt){let ft="";w.graduatedFunction!==null?(ft=w.graduatedFunction(A,w),ft=ft!=null?ft.toString():""):ft=(+A.toFixed(2)).toString(),ft!==""&&b.push({pt:rt,angle:X,text:ft})}else b.push({pt:rt,angle:X})}A=O+B*M}t.vs.push(b)}m.Z(u)}XI(t,e,i,s,n){if(e<.5005&&e>.4995)return t;let o=t;if(e<.5?n>0?o=s[n-1]:C.X(i[0],i[i.length-2])&&C.X(i[1],i[i.length-1])&&(o=s[s.length-1]):e>.5&&(n+1<s.length?o=s[n+1]:C.X(i[0],i[i.length-2])&&C.X(i[1],i[i.length-1])&&(o=s[0])),t!==o){let r=Math.abs(t-o);if(r>180&&(t<o?t+=360:o+=360,r=Math.abs(t-o)),e<5e-4||e>.9995)return(t+o)/2%360;if(r<10){let a=1-Math.abs(.5-e);return(t*a+o*(1-a))%360}}return t}BI(t){if(t.ds===null){let e=[],i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n],r=[];if(e.push(r),!o.visible)continue;let a=o.interval;if(!(a<0))for(let h=0;h<s;h++){if(h===n)continue;let l=i[h];if(!l.visible||o.constructor!==l.constructor)continue;let u=l.interval;u>a&&r.push(u)}}t.ds=e}return t.ds}zI(t,e,i){let s=i.length;for(let n=0;n<s;n++){let o=i[n]*t.graduatedTickUnit,r=e%o,a=t.graduatedTickUnit*1e-6;if(r<a&&r>-a)return!1}return!0}Ge(t,e,i){let s=i.mh;i.mh=!0;let n=t.naturalBounds,o=n.width,r=n.height,a=e instanceof ae;e.save(),e.beginPath(),e.rect(-1,-1,o+1,r+1),e.clip(),e.endPath();let h=t.findMainElement();h.Ge(e,i);let l=t.getDocumentScale()*i.scale;l<=0&&(l=1);let u=h.actualBounds,c=t.D.r,d=t.vs,f=c.length;for(let p=0;p<f;p++){let g=c[p],y=d[p],b=y.length;if(!(!g.visible||g===h||y.length===0)){if(g instanceof it){if(t.graduatedTickUnit*g.interval*h.geometry.flattenedTotalLength/t.graduatedRange*l<2&&g.graduatedSkip===null)continue;let v=g.measuredBounds,w=g.strokeWidth*g.scale,k=g.alignmentFocus;k.isNoSpot()&&(k=T.TopCenter);for(let S=0;S<b;S++){let N=y[S].pt,D=y[S].angle;this.GI(g,N,u,D,v,w,k),g.Ge(e,i),a&&(t.svg.appendChild(g.svg),g.svg=null),g.il.Ue()}}else if(g instanceof lt){t.vi===null&&(t.vi=new lt);let v=t.vi;this.uD(g,v),v.HC=!0;for(let w=0;w<b;w++){let k=y[w];if(k.actualBounds&&k.measuredBounds&&k.naturalBounds){v.YI(k);let S=k.actualBounds;v.Ut(S.x,S.y,S.width,S.height),this.KI(v,u,S,k.measuredBounds,k.naturalBounds),v.nl=g.part,v.Zs=g.panel,v.Ge(e,i),v.Zs=null,v.nl=null,a&&(t.svg.appendChild(v.svg),v.svg=null)}}}}}i.mh=s,e.restore(),e.clearContextCache(!0)}GI(t,e,i,s,n,o,r){let a=t.il;a.Ue(),a.Gs(e.x+i.x,e.y+i.y),a.ks(s+t.angle,0,0),a.Gs(-n.width*r.x+r.offsetX+o/2,-n.height*r.y+r.offsetY+o/2),a.et(t.scale,t.scale),t.Md(!1),t.ya.set(t.il),t.Th=t.scale,t.Ma(!1)}KI(t,e,i,s,n){let o=t.il;o.Ue(),o.Gs(i.x+e.x,i.y+e.y),o.Gs(-s.x,-s.y),t.zp(o,n.x,n.y,n.width,n.height),t.Md(!1),t.ya.set(t.il),t.Th=t.scale,t.Ma(!1)}uD(t,e){e.HI(t)}}Lt.Tn("Graduated",new qn);var Us=(x=>(x[x.Uniform=6]="Uniform",x[x.UniformToFill=7]="UniformToFill",x))(Us||{});class G extends J{W;D;Qt;vd;$n;ll;fo;$o;qC;O;Fd;ot;Se;te;Rd;Aa;tn;constructor(t,e){if(super(),t===void 0)this.W=G.Position;else if(typeof t=="string"){let i=Lt.fs.get(t);i!==null?this.W=i:m.o("PanelLayout not loaded: "+t)}else t instanceof Lt?this.W=t:(this.W=G.Position,t&&(e=t));this.n|=4194304|(this.W===G.Grid?1048576:0),this.D=new q,this.Qt=Dt.em,this.vd=T.Default,this.$n=1,this.ll=null,this.fo="",this.$o=new I(NaN,NaN,NaN,NaN),this.qC=null,this.O=null,this.Fd=6,this.Se=null,this.ot=null,this.te=null,this.Rd=NaN,this.Aa=null,this.tn=null,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.W=this.W,t.Qt=this.Qt.C(),t.vd=this.vd.C(),t.$n=this.$n,t.fo=this.fo,t.$o.h(this.$o),this.O!==null&&(t.O=this.O.copy(t)),t.Fd=this.Fd,this.ot!==null&&(t.ot=this.ot.copy()),this.Se!==null&&(t.Se=this.Se.copy()),t.te=this.te,t.Rd=this.Rd,t.Aa=this.Aa}Ho(t){super.Ho(t),t.D=this.D;let e=t.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s];n.Zs=t}t.ll=null}copy(){let t=super.copy(),e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s].copy();t.qI(n)}return t}toString(){return"Panel("+this.type.name+")#"+V.xs(this)}get type(){return this.W}set type(t){let e=this.W;e!==t&&(this.W=t,this.Tf=this.W===G.Grid,this.f(),this.t("type",e,t))}get elements(){return this.D.iterator}get naturalBounds(){return this.Ke}get padding(){return this.Qt}set padding(t){typeof t=="number"?(t<0&&m.J(t,">= 0",G,"padding"),t=new Dt(t)):(t.left<0&&m.J(t.left,">= 0",G,"padding:value.left"),t.right<0&&m.J(t.right,">= 0",G,"padding:value.right"),t.top<0&&m.J(t.top,">= 0",G,"padding:value.top"),t.bottom<0&&m.J(t.bottom,">= 0",G,"padding:value.bottom"));let e=this.Qt;e.equals(t)||(t=t.C(),this.Qt=t,this.f(),this.t("padding",e,t))}get defaultAlignment(){return this.vd}set defaultAlignment(t){let e=this.vd;e.equals(t)||(t=t.C(),this.vd=t,this.f(),this.t("defaultAlignment",e,t))}get defaultStretch(){return this.$n}set defaultStretch(t){let e=this.$n;e!==t&&(this.$n=t,this.f(),this.t("defaultStretch",e,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.P0:Dt.em}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Dt(t));let e=this.defaultSeparatorPadding;e.equals(t)||(t=t.C(),this.O===null&&(this.O=new ne),this.O.P0=t,this.f(),this.t("defaultSeparatorPadding",e,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O.S0:null}set defaultRowSeparatorStroke(t){let e=this.defaultRowSeparatorStroke;e!==t&&(t===null||typeof t=="string"||t instanceof R)&&(t instanceof R&&t.k(),this.O===null&&(this.O=new ne),this.O.S0=t,this.N(),this.t("defaultRowSeparatorStroke",e,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.M0:1}set defaultRowSeparatorStrokeWidth(t){let e=this.defaultRowSeparatorStrokeWidth;e!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new ne),this.O.M0=t,this.f(),this.t("defaultRowSeparatorStrokeWidth",e,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.C0:null}set defaultRowSeparatorDashArray(t){let e=this.defaultRowSeparatorDashArray;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",G,"defaultRowSeparatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&m.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.O===null&&(this.O=new ne),this.O.C0=t,this.N(),this.t("defaultRowSeparatorDashArray",e,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.N0:null}set defaultColumnSeparatorStroke(t){let e=this.defaultColumnSeparatorStroke;e!==t&&(t===null||typeof t=="string"||t instanceof R)&&(t instanceof R&&t.k(),this.O===null&&(this.O=new ne),this.O.N0=t,this.N(),this.t("defaultColumnSeparatorStroke",e,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.L0:1}set defaultColumnSeparatorStrokeWidth(t){let e=this.defaultColumnSeparatorStrokeWidth;e!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new ne),this.O.L0=t,this.f(),this.t("defaultColumnSeparatorStrokeWidth",e,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.A0:null}set defaultColumnSeparatorDashArray(t){let e=this.defaultColumnSeparatorDashArray;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",G,"defaultColumnSeparatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&m.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.O===null&&(this.O=new ne),this.O.A0=t,this.N(),this.t("defaultColumnSeparatorDashArray",e,t)}}get La(){return this.O!==null?this.O.La:null}set La(t){this.O===null&&(this.O=new ne),this.O.La=t}get viewboxStretch(){return this.Fd}set viewboxStretch(t){let e=this.Fd;e!==t&&(this.Fd=t,this.f(),this.t("viewboxStretch",e,t))}get gridCellSize(){return this.Se!==null?this.Se.Od:nt.OL}set gridCellSize(t){this.Se===null&&(this.Se=new ti);let e=this.Se.Od;if(!e.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&m.o("Invalid Panel.gridCellSize: "+t),this.Se.Od=t.C();let i=this.diagram;i!==null&&this===i.grid&&i.cd(),this.N(),this.t("gridCellSize",e,t)}}get gridOrigin(){return this.Se!==null?this.Se.Id:P.gn}set gridOrigin(t){this.Se===null&&(this.Se=new ti);let e=this.Se.Id;if(!e.equals(t)){t.isReal()||m.o("Invalid Panel.gridOrigin: "+t),this.Se.Id=t.C();let i=this.diagram;i!==null&&this===i.grid&&i.cd(),this.N(),this.t("gridOrigin",e,t)}}get graduatedMin(){return this.ot!==null?this.ot.T0:0}set graduatedMin(t){let e=this.graduatedMin;if(e!==t&&(this.ot===null&&(this.ot=new Se),this.ot.T0=t,this.f(),this.t("graduatedMin",e,t),this.mf())){let i=this.part;i!==null&&this.Eh(i,"graduatedRange")}}get graduatedMax(){return this.ot!==null?this.ot.D0:100}set graduatedMax(t){let e=this.graduatedMax;if(e!==t&&(this.ot===null&&(this.ot=new Se),this.ot.D0=t,this.f(),this.t("graduatedMax",e,t),this.mf())){let i=this.part;i!==null&&this.Eh(i,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ot!==null?this.ot.v0:10}set graduatedTickUnit(t){let e=this.graduatedTickUnit;e!==t&&t>0&&(this.ot===null&&(this.ot=new Se),this.ot.v0=t,this.f(),this.t("graduatedTickUnit",e,t))}get graduatedTickBase(){return this.ot!==null?this.ot.F0:0}set graduatedTickBase(t){let e=this.graduatedTickBase;e!==t&&(this.ot===null&&(this.ot=new Se),this.ot.F0=t,this.f(),this.t("graduatedTickBase",e,t))}get vs(){return this.ot!==null?this.ot.vs:null}set vs(t){this.ot!==null?this.ot.vs=t:t!==null&&(this.ot=new Se,this.ot.vs=t)}get _i(){return this.ot!==null?this.ot._i:null}set _i(t){this.ot!==null?this.ot._i=t:t!==null&&(this.ot=new Se,this.ot._i=t)}get ds(){return this.ot!==null?this.ot.ds:null}set ds(t){this.ot!==null?this.ot.ds=t:t!==null&&(this.ot=new Se,this.ot.ds=t)}get vi(){return this.ot!==null?this.ot.vi:null}set vi(t){this.ot!==null?this.ot.vi=t:t!==null&&(this.ot=new Se,this.ot.vi=t)}Kp(t){super.Kp(t);let e=this.D.r,i=e.length;for(let s=0;s<i;s++)e[s].Kp(t)}Sa(t,e){if(this.W===G.Grid){t.commitTransform(),this.W.Ge(this,t,e);return}if(this.W===G.Graduated){t.commitTransform(),this.W.Ge(this,t,e);return}if(this.W===G.Table)if(t.commitTransform(),t instanceof ae){let r=t.currentElement;t.currentElement=t.newGroup2("gojs-ts"),this.jC(t,e),t.endGroup(),t.currentElement=r}else this.jC(t,e);let i=this.isClipping&&this.W===G.Spot;i&&t.save();let s=this.findMainElement(),n=this.D.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];i&&a===s&&(t.clipInsteadOfFill=!0),a.Ge(t,e),i&&a===s&&(t.clipInsteadOfFill=!1)}i&&(t.restore(),t.clearContextCache(!0))}jC(t,e){t.lineCap="butt";let i=this.rowCount>0?this.Ii:null,s=this.columnCount>0?this.Ei:null;i!==null&&this.q1(t,e,!0,i,!0),s!==null&&this.q1(t,e,!1,s,!0),i!==null&&this.dD(t,!0,i),s!==null&&this.dD(t,!1,s),i!==null&&this.q1(t,e,!0,i,!1),s!==null&&this.q1(t,e,!1,s,!1)}dD(t,e,i){let s=i.length,n=this.actualBounds,o=this.naturalBounds,r=!0;for(let a=0;a<s;a++){let h=i[a];if(h===void 0||h.actual===0)continue;if(r){r=!1;continue}if(e){if(h.position>o.height)continue}else if(h.position>o.width)continue;let l=h.separatorStrokeWidth;isNaN(l)&&(l=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let u=h.separatorStroke;if(u===null&&(u=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),l===0||u===null)continue;this.kn(t,u,!1,!1,o,n);let c=!1,d=h.separatorDashArray;d===null&&(d=e?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),d!==null&&(c=!0,t.enableDash(d,0)),t.beginPath();let f=h.position+l;e?f>o.height&&(l-=f-o.height):f>o.width&&(l-=f-o.width);let p=h.position+l/2;t.lineWidth=l;let g=this.Qt;if(e){p+=g.top;let y=g.left,b=o.width-g.right;t.moveTo(y,p),t.lineTo(b,p)}else{p+=g.left;let y=g.top,b=o.height-g.bottom;t.moveTo(p,y),t.lineTo(p,b)}t.stroke(),t.endPath(),c&&t.disableDash()}}q1(t,e,i,s,n){let o=s.length,r=this.actualBounds,a=this.naturalBounds,h=this.gD(!0),l=this.gD(!1);for(let u=0;u<o;u++){let c=s[u];if(c===void 0||c.background===null||c.coversSeparators===n||c.actual===0)continue;let d=i?r.height:r.width;if(c.position>d)continue;let f=c.computeEffectiveSpacing(),p=c.separatorStrokeWidth;isNaN(p)&&(p=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(i?h:l))&&(p=0),f-=p;let y=c.position+p,b=f+c.actual;if(y+b>d&&(b=d-y),b<=0)continue;let v=this.Qt;this.kn(t,c.background,!0,!1,a,r),i?t.fillRect(v.left,y+v.top,r.width-(v.left+v.right),b):t.fillRect(y+v.left,v.top,b,r.height-(v.top+v.bottom))}}gD(t){let e=t?this.rowCount:this.columnCount;for(let i=0;i<e;i++){let s=t?this.Ii[i]:this.Ei[i];if(s!==void 0)return s.index}return 0}xf(){let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].xf();this.Zi(!0)}wf(t,e,i){let s=this.svg;if(s===null)return!1;if(this.type===G.Table){let r=s.getElementsByClassName("gojs-ts"),a=r.length!==0?r[0]:null;a!==null&&(a.innerHTML=""),t.currentElement=a,this.jC(t,e),t.currentElement=null}else{if(this.W===G.Grid||this.W===G.Graduated)return s.innerHTML="",s.remove(),!1;if(this.W===G.Spot&&this.isClipping)return s.innerHTML="",s.remove(),this.wa=null,this.xf(),!1}if(!super.wf(t,e,i))return!1;let n=this.D.r,o=n.length;for(let r=0;r<o;r++)n[r].Ge(t,e);return!0}Sd(t){return!0}qp(t,e,i,s){if(!this.isClipping){if(this._s()&&t.partClipRect!==null){let n=t.partClipRect,o=this.D.r,r=0,a=0;for(let h=0;h<o.length;h++){if(!o[h].isVisibleObject())continue;let l=o[h].actualBounds;r=h===0?l.x:Math.min(l.x,r),a=h===0?l.y:Math.min(l.y,a)}s.setAttributeNS(null,"clip-path",`path('M ${n.x-i.x-r},${n.y-i.y-a} l ${n.width} 0 l 0 ${n.height} l -${n.width} 0 z')`);return}super.qp(t,e,i,s)}}pf(t,e,i,s,n){let o=this.Cn(),r=this.v,a=1/(r.m11*r.m22-r.m12*r.m21),h=r.m22*a,l=-r.m12*a,u=-r.m21*a,c=r.m11*a,d=a*(r.m21*r.dy-r.m22*r.dx),f=a*(r.m12*r.dx-r.m11*r.dy);if(this.background!==null){let p=t*h+e*u+d,g=t*l+e*c+f,y=i*h+s*u+d,b=i*l+s*c+f;n.e(0,0);let v=this.naturalBounds,w=C.Al(0,0,v.width,v.height,p,g,y,b,n);return n.v(r),w}else{o||(h=1,l=0,u=0,c=1,d=0,f=0);let p=t*h+e*u+d,g=t*l+e*c+f,y=i*h+s*u+d,b=i*l+s*c+f;n.e(y,b);let v=(y-p)**2+(b-g)**2,w=!1,k=this.D.r,S=k.length,N=P.l(),D=null,L=1/0,M=null,A=this.isClipping&&this.W===G.Spot;A&&(M=P.l(),D=this.findMainElement(),w=D.pf(p,g,y,b,M),w&&(L=(p-M.x)**2+(g-M.y)**2));for(let F=0;F<S;F++){let O=k[F];if(!O.visible||O===D||!O.pf(p,g,y,b,N))continue;w=!0;let E=(p-N.x)**2+(g-N.y)**2;E<v&&(v=E,n.set(N))}return A&&(L>v&&n.set(M),P.i(M)),P.i(N),o&&n.v(r),w}}Wc(){let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].Wc();super.Wc()}f(t){if(this.Xo())return;super.f(t);let e=null;(this.W===G.Auto||this.W===G.Link)&&(e=this.findMainElement());let i=this.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];if((o===e||o.isPanelMain)&&o.f(!0),o.desiredSize.isReal()||!o.visible)continue;let r=o.Qs(!1);!(o instanceof ue)&&!(o instanceof G)&&!(o instanceof lt)&&r===0||o.f(!0)}}kf(){if(this.Xo())return;this.xi(!0),this.lo(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].kf()}yf(){if(this.I1()===!1){this.Md(!0),this.Ma(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].LC()}}LC(){this.Ma(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].LC()}kd(t,e,i,s){let n=this.$o;n.e(0,0,0,0);let o=this.desiredSize,r=this.minSize;i===void 0&&(i=r.width,s=r.height),i=Math.max(i,r.width),s=Math.max(s,r.height);let a=this.maxSize;isNaN(o.width)||(t=Math.min(o.width,a.width)),isNaN(o.height)||(e=Math.min(o.height,a.height)),t=Math.max(i,t),e=Math.max(s,e);let h=this.Qt;t=Math.max(t-h.left-h.right,0),e=Math.max(e-h.top-h.bottom,0);let l=this.D.r;this.W.measure(this,t,e,l,n,i,s);let u=n.width+h.left+h.right,c=n.height+h.top+h.bottom;isFinite(o.width)&&(u=o.width),isFinite(o.height)&&(c=o.height),u=Math.min(a.width,u),c=Math.min(a.height,c),u=Math.max(r.width,u),c=Math.max(r.height,c),u=Math.max(i,u),c=Math.max(s,c),n.Kn(u,c),this.naturalBounds.Kn(u,c),this.ro(0,0,u,c)}findMainElement(){if(this.ll===null){let t=this.D.r,e=t.length;if(e===0)return null;for(let i=0;i<e;i++){let s=t[i];if(s.isPanelMain===!0)return this.ll=s,s}this.ll=t[0]}return this.ll}Jo(){return this.part!==null?this.part.locationObject:null}get panelLayoutState(){return this.qC}set panelLayoutState(t){this.qC=t}ka(t,e,i,s){let n=this.D.r;if(this.actualBounds.e(t,e,i,s),!this.desiredSize.isReal()){let o=this.Qs(!0),r=this.measuredBounds,a=r.width,h=r.height,l=this.sl,u=l.left+l.right,c=l.top+l.bottom;switch(a===i&&h===s&&(o=0),o){case 0:(a>i||h>s)&&(this.f(),this.ht(a>i?i:a,h>s?s:h,0,0));break;case 2:this.f(!0),this.ht(i+u,s+c,0,0);break;case 5:this.f(!0),this.ht(i+u,h+c,0,0);break;case 4:this.f(!0),this.ht(a+u,s+c,0,0);break}}this.W.arrange(this,n,this.$o)}ba(t){let e=this.naturalBounds,i=this.Jo();if(I.contains(0,0,e.width,e.height,t.x,t.y)){let s=this.D.r,n=s.length,o=P.z(0,0);for(let r=n;r--;){let a=s[r];if(!(!a.visible&&a!==i)&&(o.set(t).Hi(a.v),a.containsPoint(o)))return P.i(o),!0}return P.i(o),this.Nt!==null}return!1}Bp(t){if(this.no===t)return this;let e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s].Bp(t);if(n!==null)return n}return null}walkVisualTreeFrom(t,e){if(e(this,t),t instanceof G){let i=t.D.r,s=i.length;for(let n=0;n<s;n++)this.walkVisualTreeFrom(i[n],e)}}Sn(t){this.mD(this,t)}mD(t,e){e(t);let i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];o instanceof G&&this.mD(o,e)}}jI(t){this.pD(this,t)}pD(t,e){if(e(t),t instanceof G){let i=t.D.r,s=i.length;for(let n=0;n<s;n++)this.pD(i[n],e)}}findInVisualTree(t){return this.yD(this,t)}yD(t,e){if(e(t))return t;if(t instanceof G){let i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=this.yD(i[n],e);if(o!==null)return o}}return null}findObject(t){if(this.name===t)return this;let e=this.D.r,i=e.length;this.Aa!==null&&(i=this.R0());for(let s=0;s<i;s++){let n=e[s];if(n instanceof G){let o=n.findObject(t);if(o!==null)return o}if(n.name===t)return n}return null}wD(){let t=this.D.r,e=t.length,i=0;for(let s=0;s<e;s++){let n=t[s];n instanceof G?i=Math.max(i,n.wD()):n instanceof it&&(i=Math.max(i,n.WI()))}return i}Cn(){return!(this.type===G.TableRow||this.type===G.TableColumn)}ol(){return this.type===G.TableRow||this.type===G.TableColumn}BA(t,e,i){if(this.pickable===!1||(e===void 0&&(e=null),i===void 0&&(i=null),this.as()))return null;let s=this.naturalBounds,n=1/this.getDocumentScale(),o=this.Cn(),r=o?t:P.z(t.x,t.y).Hi(this.v),a=this.diagram,h=10,l=5;if(a!==null&&(h=a.getInputOption("extraTouchArea"),l=h/2),I.contains(-(l*n),-(l*n),s.width+h*n,s.height+h*n,r.x,r.y)){if(!this.Tf){let c=this.D.r,d=c.length,f=P.l(),p=this.isClipping&&this.W===G.Spot,g=p?this.findMainElement():null;if(p&&g&&(g.Cn()?f.set(t).Hi(g.v):f.set(t),!g.containsPoint(f)))return P.i(f),o||P.i(r),null;let y=this.Jo();for(let b=d;b--;){let v=c[b];if(!v.visible&&v!==y||(v.Cn()?f.set(t).Hi(v.v):f.set(t),p&&v===g))continue;let w=null;if(v instanceof G?w=v.BA(f,e,i):v.pickable===!0&&v.containsPoint(f)&&(w=v),w!==null&&(e!==null&&(w=e(w)),w!==null&&(i===null||i(w))))return P.i(f),o||P.i(r),w}P.i(f)}if(this.background===null)return o||P.i(r),null;let u=I.contains(0,0,s.width,s.height,r.x,r.y)?this:null;return o||P.i(r),u}return o||P.i(r),null}zA(t,e,i,s){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let n=this.naturalBounds,o=this.Cn(),r=o?t:P.z(t.x,t.y).Hi(this.v),a=this.ol(),h=I.contains(0,0,n.width,n.height,r.x,r.y);if(a||h){if(!this.Tf){let l=this.D.r,u=l.length,c=P.l(),d=this.Jo();for(let f=u;f--;){let p=l[f];if(!p.visible&&p!==d)continue;p.Cn()?c.set(t).Hi(p.v):c.set(t);let g=p,y=p instanceof G?p:null;if(y!==null?y.zA(c,e,i,s):g.containsPoint(c)){if(g.pickable===!1)continue;e!==null&&(g=e(g)),g!==null&&(i===null||i(g))&&s.add(g)}}P.i(c)}return o||P.i(r),h&&this.background!==null}return o||P.i(r),!1}jm(t,e,i,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let r=o;if(r===void 0&&(r=Nt.l(),r.Ue()),r.bc(this.v),this.containedInRect(t,r))return this.WC(e,i,n),o===void 0&&Nt.i(r),!0;if(this.intersectsRect(t,r)){if(!this.Tf){let a=this.Jo(),h=this.D.r,l=h.length;for(let u=l;u--;){let c=h[u];if(!c.visible&&c!==a)continue;let d=c.actualBounds,f=this.naturalBounds;if(d.x>f.width||d.y>f.height||d.x+d.width<0||d.y+d.height<0)continue;let p=c,g=c instanceof G?c:null,y=Nt.l();y.set(r),(g!==null?g.jm(t,e,i,s,n,y):p.$T(t,s,y))&&(e!==null&&(p=e(p)),p!==null&&(i===null||i(p))&&n.add(p)),Nt.i(y)}}return o===void 0&&Nt.i(r),s}return o===void 0&&Nt.i(r),!1}WC(t,e,i){let s=this.D.r,n=s.length;for(let o=n;o--;){let r=s[o];if(!r.visible)continue;let a=r.actualBounds,h=this.naturalBounds;if(a.x>h.width||a.y>h.height||a.x+a.width<0||a.y+a.height<0)continue;r instanceof G&&r.WC(t,e,i);let l=r;t!==null&&(l=t(l)),l!==null&&(e===null||e(l))&&i.add(l)}}XA(t,e,i,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),s===void 0&&(s=null);let r=this.naturalBounds,a=this.Cn(),h=a?t:P.z(t.x,t.y).Hi(this.v),l=a?e:P.z(e.x,e.y).Hi(this.v),u=h.distanceSquaredPoint(l),c=h.x>0&&h.x<r.width&&h.y>0&&h.y<r.height||P.distanceLineSegmentSquared(h.x,h.y,0,0,0,r.height)<=u||P.distanceLineSegmentSquared(h.x,h.y,0,r.height,r.width,r.height)<=u||P.distanceLineSegmentSquared(h.x,h.y,r.width,r.height,r.width,0)<=u||P.distanceLineSegmentSquared(h.x,h.y,r.width,0,0,0)<=u,d=h.distanceSquared(0,0)<=u&&h.distanceSquared(0,r.height)<=u&&h.distanceSquared(r.width,0)<=u&&h.distanceSquared(r.width,r.height)<=u;if(a||(P.i(h),P.i(l)),c){if(!this.Tf){let f=P.l(),p=P.l(),g=this.Jo(),y=this.D.r,b=y.length;for(let v=b;v--;){let w=y[v];if(!w.visible&&w!==g)continue;let k=w.actualBounds,S=this.naturalBounds;if(a&&(k.x>S.width||k.y>S.height||k.x+k.width<0||k.y+k.height<0))continue;if(w.Cn()){let L=w.v;f.set(t).Hi(L),p.set(e).Hi(L)}else f.set(t),p.set(e);let N=w,D=w instanceof G?w:null;(D!==null?D.XA(f,p,i,s,n,o):N.ZT(f,p,n))&&(i!==null&&(N=i(N)),N!==null&&(s===null||s(N))&&o.add(N))}P.i(f),P.i(p)}return n?c:d}return!1}XC(t){let e=null;if(t instanceof it){e=t.spot1,e===T.Default&&(e=null);let i=t.geometry;i!==null&&e===null&&(e=i.spot1)}return e===null&&(e=T.TopLeft),e}GC(t){let e=null;if(t instanceof it){e=t.spot2,e===T.Default&&(e=null);let i=t.geometry;i!==null&&e===null&&(e=i.spot2)}return e===null&&(e=T.BottomRight),e}add(...t){for(let e=0;e<t.length;e++)this.insertAt(this.D.count,t[e]);return this}elt(t){return this.D.elt(t)}insertAt(t,e){e instanceof pt&&m.o("Cannot add a Part to a Panel: "+e+"; use a Panel instead"),(this===e||this.isContainedBy(e))&&(this===e&&m.o("Cannot make a Panel contain itself: "+this.toString()),m.o("Cannot make a Panel indirectly contain itself: "+this.toString()+" already contains "+e.toString()));let i=e.panel;if(i!==null&&i!==this&&m.o("Cannot add a GraphObject that already belongs to another Panel to this Panel: "+e.toString()+", already contained by "+i.toString()+", cannot be shared by this Panel: "+this.toString()),this.W===G.Grid&&!(e instanceof it)&&m.o("Can only add Shapes to a Grid Panel, not: "+e),this.W===G.Graduated&&!(e instanceof it||e instanceof lt)&&m.o("Can only add Shapes or TextBlocks to a Graduated Panel, not: "+e),e.Uh(this),e.nl=null,this.itemArray!==null){let r=e.data;m.$(r)&&(this.tn===null&&(this.tn=new Mt),this.tn.set(r,e))}let s=this.D,n=-1;if(i===this){let r=-1,a=this.D.r,h=a.length;for(let l=0;l<h;l++)if(a[l]===e){r=l;break}if(r!==-1){if(r===t||r+1>=s.count&&t>=s.count)return;s.removeAt(r),n=r}else m.o("element "+e.toString()+" has panel "+i.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,e),(t===0||e.isPanelMain)&&(this.ll=null),this.Xo()||this.f(),e.f(!1),e.portId!==null?this.Ln=!0:e instanceof G&&e.Ln===!0&&(this.Ln=!0),this.ds=null,this.isEnabledObject()||this.j1(e,!1);let o=this.part;if(o!==null){o._p(),o.Df(),this.Ln&&o instanceof $&&(o.Ln=!0),o.Ln&&o instanceof $&&(o.ci=null);let r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,e,null,n,null),o.raiseChangedEvent(3,"elements",this,null,e,null,t)}}get Ln(){return(this.n&8388608)!==0}set Ln(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}SC(){return(this.n&16777216)!==0}JC(t){t?this.n|=16777216:this.n&=-16777217}qI(t){t.Uh(this),t.nl=null;let e=this.D,i=e.count;e.insertAt(i,t);let s=this.part;if(s!==null){s._p(),t.portId!==null&&s instanceof $&&(s.Ln=!0);let n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,i)}}uI(t){let e=this.D.r,i=e.length,s=-1;for(let n=0;n<i;n++)if(e[n]===t){s=n;break}return s}remove(t){let e=this.D.r,i=e.length,s=-1;for(let n=0;n<i;n++)if(e[n]===t){s=n;break}s!==-1&&this.ri(s,!0)}removeAt(t){t>=0&&this.ri(t,!0)}ri(t,e){let i=this.D,s=i.elt(t);if(s.nl=null,s.Uh(null),this.tn!==null){let o=s.data;m.$(o)&&this.tn.delete(o)}i.removeAt(t),this.xi(!1),this.f(),this.ll===s&&(this.ll=null),this.ds=null;let n=this.part;if(n!==null){n._p(),n.Df(),n.invalidateAdornments(),n instanceof $&&(s instanceof G?s.walkVisualTreeFrom(s,(r,a)=>n.vC(a,e)):n.vC(s,e));let o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ii(){return this.O===null&&(this.O=new ne),this.O.Ii}get rowCount(){return this.O===null?0:this.Ii.length}getRowDefinition(t){t<0&&m.J(t,">= 0",G,"getRowDefinition:idx"),t=Math.round(t);let e=this.Ii;if(e[t]===void 0){let i=new Kt;i.Uh(this),i.isRow=!0,i.index=t,e[t]=i,this.raiseChangedEvent(3,"rowdefs",this,null,i,null,t)}return e[t]}removeRowDefinition(t){if(t<0&&m.J(t,">= 0",G,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);let e=this.Ii,i=e[t];if(i){e[t]=void 0;let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--;this.raiseChangedEvent(4,"rowdefs",this,i,null,t,null),this.f()}}xT(t,e){let i=this.Ii;if(!(t<0)){if(i[t]=e instanceof Kt?e:void 0,!e){let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--}this.f()}}get Ei(){return this.O===null&&(this.O=new ne),this.O.Ei}get columnCount(){return this.O===null?0:this.Ei.length}getColumnDefinition(t){t<0&&m.J(t,">= 0",G,"getColumnDefinition:idx"),t=Math.round(t);let e=this.Ei;if(e[t]===void 0){let i=new Kt;i.Uh(this),i.isRow=!1,i.index=t,e[t]=i,this.raiseChangedEvent(3,"coldefs",this,null,i,null,t)}return e[t]}removeColumnDefinition(t){if(t<0&&m.J(t,">= 0",G,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);let e=this.Ei,i=e[t];if(i){e[t]=void 0;let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--;this.raiseChangedEvent(4,"coldefs",this,i,null,t,null),this.f()}}bT(t,e){let i=this.Ei;if(!(t<0)){if(i[t]=e instanceof Kt?e:void 0,!e){let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--}this.f()}}addRowColumnDefinition(t){let e=null;return t.isRow?e=this.getRowDefinition(t.index):t.isRow||(e=this.getColumnDefinition(t.index)),e&&e.U1(t),this}addRowDefinition(t,e){let i=this.getRowDefinition(t);return i&&i.U1(new Kt(e)),this}addColumnDefinition(t,e){let i=this.getColumnDefinition(t);return i&&i.U1(new Kt(e)),this}get rowSizing(){return this.O!==null?this.O.O0:3}set rowSizing(t){let e=this.rowSizing;e!==t&&(this.O===null&&(this.O=new ne),this.O.O0=t,this.f(),this.t("rowSizing",e,t))}get columnSizing(){return this.O!==null?this.O.I0:3}set columnSizing(t){let e=this.columnSizing;e!==t&&(this.O===null&&(this.O=new ne),this.O.I0=t,this.f(),this.t("columnSizing",e,t))}get topIndex(){return this.O!==null?this.O.E0:0}set topIndex(t){let e=this.topIndex;e!==t&&((!isFinite(t)||t<0)&&m.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new ne),this.O.E0=t,this.f(),this.t("topIndex",e,t))}get leftIndex(){return this.O!==null?this.O.U0:0}set leftIndex(t){let e=this.leftIndex;e!==t&&((!isFinite(t)||t<0)&&m.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new ne),this.O.U0=t,this.f(),this.t("leftIndex",e,t))}findRowForLocalY(t){if(t<0||this.type!==G.Table||this.rowCount===0)return-1;let e=0,i=this.Ii,s=i.length,n=this.topIndex;for(;n<s;n++){let o=i[n];if(o!==void 0&&(e+=o.total,t<e))return n}return n}findColumnForLocalX(t){if(t<0||this.type!==G.Table||this.columnCount===0)return-1;let e=0,i=this.Ei,s=i.length,n=this.leftIndex;for(;n<s;n++){let o=i[n];if(o!==void 0&&(e+=o.total,t<e))return n}return n}graduatedPointForValue(t,e){if(e===void 0&&(e=new P(NaN,NaN)),this.type!==G.Graduated)return e.e(NaN,NaN),e;t=Math.min(Math.max(t,this.graduatedMin),this.graduatedMax);let i=this.findMainElement();return i.geometry.getPointAlongPath((t-this.graduatedMin)/this.graduatedRange,e),i.v.gt(e)}graduatedValueForPoint(t){if(this.type!==G.Graduated)return NaN;let e=this.findMainElement();return e.v.Ni(t),e.geometry.getFractionForPoint(t)*this.graduatedRange+this.graduatedMin}get data(){return this.te}set data(t){let e=this.te;if(e!==t){let i=this instanceof pt&&!(this instanceof vt);i&&m.s(t,"object",G,"data"),this.It(),this.te=t;let s=this.diagram;if(s!==null)if(i){s.partManager.JI(this,e,t);let n=this.adornments;for(;n.next();){let o=n.value,r=o.adornedObject;if(r!==null){let a=r.findBindingPanel();a!==null&&(o.data=a.data)}}}else{let n=this.panel;n!==null&&n.tn!==null&&(e!==null&&n.tn.delete(e),t!==null&&n.tn.set(t,this))}if(this.t("data",e,t),s!==null&&s.undoManager.isUndoingRedoing)return;t!==null&&this.updateTargetBindings()}}get itemIndex(){return this.Rd}set itemIndex(t){let e=this.Rd;e!==t&&(this.Rd=t,this.t("itemIndex",e,t))}get Ds(){return this.w!==null?this.w.Ds:null}set Ds(t){this.Fe!==t&&(this.w===null&&(this.w=new Ke),this.w.Ds=t)}FC(){return this.Ds!==null}oD(){let t=this.Ds;return t!==null&&t.u}freezeBindings(){return this.It()}It(){let t=this.Ds;if(t===null)this.data!==null&&m.o("Template cannot have .data be non-null: "+this),this.Ds=t=new q;else if(t.u)return this;let e=new q;this.JC(!1),this.walkVisualTreeFrom(this,(n,o)=>{o.xa();let r=o.Fe;if(r!==null){o.AC(!1);let a=r.iterator;for(;a.next();){let h=a.value;h.mode===2&&o.AC(!0);let l=h.sourceName;if(h.isToObject){l==="/"&&n.JC(!0);let u=h.JT(n,o);u!==null&&(e.add(u),u.oo===null&&(u.oo=new q),u.oo.add(h))}t.add(h)}}if(o instanceof G&&o.type===G.Table){if(o.rowCount>0){let a=o.Ii,h=a.length;for(let l=0;l<h;l++){let u=a[l];if(u!==void 0&&u.Fs!==null){let c=u.Fs.iterator;for(;c.next();){let d=c.value;d.Ti=u,d.Ed=2,d.vf=u.index,t.add(d)}}}}if(o.columnCount>0){let a=o.Ei,h=a.length;for(let l=0;l<h;l++){let u=a[l];if(u!==void 0&&u.Fs!==null){let c=u.Fs.iterator;for(;c.next();){let d=c.value;d.Ti=u,d.Ed=1,d.vf=u.index,t.add(d)}}}}}});let i=e.iterator;for(;i.next();){let n=i.value;if(n.oo!==null){n.AC(!0);let o=n.oo.iterator;for(;o.next();){let r=o.value;n.Fe===null&&(n.Fe=new q),n.Fe.add(r)}}n.oo=null}let s=t.iterator;for(;s.next();){let n=s.value,o=n.Ti;if(o!==null){n.Ti=null;let r=n.targetProperty,a=r.indexOf(".");if(a>0&&o instanceof G){let h=r.substring(0,a),l=r.substring(a+1),u=o.findObject(h);u!==null?(o=u,n.targetProperty=l):(m.ne('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof Kt){let h=V.xs(o.panel);n.targetId=h===void 0?-1:h,o.panel.no=n.targetId}else if(o instanceof J){let h=V.xs(o);n.targetId=h===void 0?-1:h,o.no=n.targetId}else m.o("Unknown type of binding target: "+o);n.check(o)}}return t.k(),this instanceof pt&&this.Di()&&this.ensureBounds(),this}static zU=!1;copyTemplate(t){t===void 0&&(t=!1);let e=this.copy();return e.jI(i=>{i instanceof G&&(i.Ds=null,i.te=null);let s=i.Fe;s!==null&&(i.Fe=null,s.each(o=>i.bind(o.copy())));let n=i.Ts;n!==null&&(i.Ts=null,n.each(o=>i.trigger(o.value.copy())))}),t&&e.It(),e}updateTargetBindings(t){let e=this.Ds;if(e===null)return;t===void 0&&(t="");let i=this.diagram?.model,s=e.iterator;for(;s.next();){let n=s.value,o=this.$C(n,t);if(o===null)continue;let{data:r,elt:a}=o;n.isToTheme&&this.diagram===null||a!==void 0&&n.updateTarget(a,r,void 0,i)}}$I(t){if(t===""){this.updateTargetBindings(t);return}let e=this.Ds;if(e===null)return;let i=this.diagram?.model,s=e.iterator;for(;s.next();){let n=s.value;if(n.isToData&&n.sourceProperty!=="")continue;let o=this.$C(n,"");if(o===null)continue;let{data:r,elt:a}=o;a!==void 0&&n.updateTarget(a,r,void 0,i)}}Go(){if(this.diagram!==null)if(this.FC()){let t=this.diagram.model,e=this.Ds.iterator;for(;e.next();){let i=e.value;if(!i.isToTheme)continue;let s=this.$C(i);if(s===null)continue;let{data:n,elt:o}=s;o!==void 0&&i.updateTarget(o,n,void 0,t)}}else{let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].Go()}}$C(t,e=""){let i=t.sourceProperty;if(e!==""&&i!==""&&i!==e)return null;let s=t.targetProperty;if(t.converter===null&&s==="")return null;let n=this.data,o=t.sourceName;if(t.isToObject){if(n=this.WT(o),n===null)return null}else if(t.isToModel){let l=this.diagram;if(l===null)return null;n=l.model.modelData}let r=this,a=t.targetId;if(a!==-1){if(r=this.Bp(a),r===null)return null}else t.Ti!==null&&(r=t.Ti);o==="/"?n=r.part:o==="."?n=r:o===".."&&(n=r.panel);let h=t.Ed;if(h!==0){if(!(r instanceof G))return null;h===1?r=r.getColumnDefinition(t.vf):h===2&&(r=r.getRowDefinition(t.vf))}return{data:n,elt:r}}get itemArray(){return this.Aa}set itemArray(t){let e=this.Aa;if(e!==t||t!==null&&this.ZI(t)){let i=this.diagram;if(e!==t&&(i!==null&&e!==null&&i.partManager.C2(this,i),this.Aa=t,i!==null&&t!==null&&i.partManager.M2(this,i)),this.t("itemArray",e,t),i!==null&&i.undoManager.isUndoingRedoing)return;this.xD(e,t)}}findItemPanelForData(t){return t==null||this.tn===null?null:(m.wc(t,G,"findItemPanelForData"),this.tn.get(t))}ZI(t){let e=this.D.r,i=e.length,s=t.length,n=0,o=null;for(;n<i&&(o=e[n],!(o instanceof G)||o.data===null);)n++,o=e[n];if(i-n!==s)return!0;if(o===null)return s>0;let r=0;for(;n<i&&r<s;){if(o=e[n],!(o instanceof G)||o.data!==t[r])return!0;n++,r++}return!1}R0(){if(this.type===G.Spot||this.type===G.Auto)return Math.min(this.D.length,1);if(this.type===G.Link){let t=this.D,e=t.length,i=0;for(;i<e;i++){let s=t.elt(i);if(!(s instanceof it)||!s.isPanelMain)return i}return i}if(this.type===G.Table&&this.D.length>0){let t=this.D.elt(0);if(t.isPanelMain&&t instanceof G&&t.ol())return 1}return 0}rebuildItemElements(){let t=this.R0();for(;this.D.length>t;)this.ri(this.D.length-1,!1);this.xD(null,this.itemArray)}xD(t,e){let i=this.R0(),s=e;if(s===null||s.length===0){for(;this.D.length>i;)this.ri(this.D.length-1,!1);return}if(this.D.length<=i){let n=s.length;for(let o=0;o<n;o++)this.W1(s[o],o,!0)}else{let n=i;for(let r=0;r<s.length;r++,n++){let a=s[r],h=n<this.D.length?this.D.elt(n):null;if(h instanceof G){if(h.data!==a){let l=this.ZC(h.data,r),u=this.ZC(a,r),c=u!==l;if(!c){let d=this.QC(h.data,r,l);c=this.QC(a,r,u)!==d}c?(this.ri(n,!1),this.W1(a,r,!1)):h.data=a}}else this.W1(a,r,!1)}for(;n<this.D.length;)this.ri(n,!1);this.ll=null,this._C(i,0),this.Xo()||this.f(),this.ds=null,this.isEnabledObject()||this.j1(this,!1);let o=this.part;o!==null&&(o._p(),o.Df(),this.Ln&&o instanceof $&&(o.Ln=!0),o.Ln&&o instanceof $&&(o.ci=null))}}W1(t,e,i){if(t==null||e<0)return;let s=this.ZC(t,e),n=this.QC(t,e,s);if(n!==null){n.It();let o=n.copy();if(o.SC()){let a=this.findBindingPanel();a!==null&&a.JC(!0)}m.$(t)&&(this.tn===null&&(this.tn=new Mt),this.tn.set(t,o));let r=e+this.R0();this.insertAt(r,o),i&&(o.te=t,this._C(r,e),o.te=null),o.data=t}}QI(t){if(t<0)return;let e=t+this.R0();this.ri(e,!0),this._C(e,t)}_C(t,e){let i=this.D,s=t,n=e;for(;s<i.length;){let o=i.elt(s);o instanceof G&&o._I(s,n),s++,n++}}_I(t,e){this.type===G.TableRow?this.row=t:this.type===G.TableColumn&&(this.column=t),this.itemIndex=e}get itemTemplate(){let t=this.itemTemplateMap;if(t!==null){let e=t.get("");if(e)return e}return G.bD()}set itemTemplate(t){let e=this.itemTemplate;if(e!==t){(t instanceof pt||t.isPanelMain)&&m.o("Panel.itemTemplate must not be a Part or be Panel.isPanelMain: "+t),this.itemTemplateMap===null&&(this.itemTemplateMap=new Mt),this.itemTemplateMap.set("",t),this.t("itemTemplate",e,t);let i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.rebuildItemElements()}}get itemTemplateMap(){return this.w!==null?this.w.m0:null}set itemTemplateMap(t){let e=this.itemTemplateMap;if(e!==t){let i=t.iterator;for(;i.next();){let n=i.value}this.Yt().m0=t,this.t("itemTemplateMap",e,t);let s=this.diagram;if(s!==null&&s.undoManager.isUndoingRedoing)return;this.rebuildItemElements()}}get itemCategoryProperty(){return this.w!==null?this.w.p0:"category"}set itemCategoryProperty(t){let e=this.itemCategoryProperty;e!==t&&(typeof t!="string"&&!m.it(t)&&m.si(t,"string or function",G,"itemCategoryProperty"),this.Yt().p0=t,this.t("itemCategoryProperty",e,t))}ZC(t,e){if(t===null)return"";let i=this.itemCategoryProperty,s="";if(m.it(i))s=i(t);else if(typeof i=="string"&&m.$(t)){if(i==="")return"";let n=this.diagram,o=n!==null?n.model:null;o?s=o.Lt(t,i):s=dt.Lt(t,i)}else return"";if(s===void 0)return"";if(typeof s=="string")return s;m.o("Panel.getCategoryForItemData found a non-string category for "+t+": "+s)}static kD=!1;static tN;static bD(){return G.tN||(G.tN=new G().add(new lt().bind("text","",m.toString).theme("stroke","text"))),G.tN}QC(t,e,i){let s=null,n=this.itemTemplateMap;return n!==null&&(s=n.get(i),s===null&&(s=n.get(""))),s===null&&(G.kD||(G.kD=!0,m.ne('No item template Panel found for category "'+i+'" on '+this),m.ne(" Using default item template.")),s=G.bD()),s}get Tf(){return(this.n&1048576)!==0}set Tf(t){let e=(this.n&1048576)!==0;e!==t&&(m.s(t,"boolean",G,"isAtomic"),this.n=this.n^1048576,this.t("isAtomic",e,t))}get isClipping(){return(this.n&2097152)!==0}set isClipping(t){let e=(this.n&2097152)!==0;e!==t&&(this.xf(),this.n=this.n^2097152,this instanceof ht&&(this.he=null),this.f(),this.t("isClipping",e,t))}get isOpposite(){return(this.n&33554432)!==0}set isOpposite(t){let e=(this.n&33554432)!==0;e!==t&&(this.n=this.n^33554432,this.f(),this.t("isOpposite",e,t))}get isEnabled(){return(this.n&4194304)!==0}set isEnabled(t){let e=(this.n&4194304)!==0;if(e!==t){let i=this.panel===null||this.panel.isEnabledObject();this.n=this.n^4194304,this.t("isEnabled",e,t);let s=this.diagram;if(s!==null&&s.undoManager.isUndoingRedoing)return;i&&this.j1(this,t)}}j1(t,e){let i=t.enabledChanged;if(i!==null&&i(t,e),t instanceof G){let s=t.D.r,n=s.length;for(let o=0;o<n;o++){let r=s[o];e&&r instanceof G&&!r.isEnabled||this.j1(r,e)}}}get alignmentFocusName(){return this.fo}set alignmentFocusName(t){let e=this.fo;e!==t&&(this.fo=t,this.f(),this.t("alignmentFocusName",e,t))}static definePanelLayout(t,e){Lt.Tn(t,e)}static isLayoutDefined(t){return Lt.fs.has(t)}static Position=Lt.fs.get("Position");static Horizontal=Lt.fs.get("Horizontal");static Vertical=Lt.fs.get("Vertical");static Spot=Lt.fs.get("Spot");static Auto=Lt.fs.get("Auto");static Table=Lt.fs.get("Table");static Viewbox=Lt.fs.get("Viewbox");static TableRow=Lt.fs.get("TableRow");static TableColumn=Lt.fs.get("TableColumn");static Link=Lt.fs.get("Link");static Grid=Lt.fs.get("Grid");static Graduated=Lt.fs.get("Graduated")}G.definePanelLayout=G.definePanelLayout;class Se{T0;D0;v0;F0;vs;_i;ds;vi;constructor(){this.T0=0,this.D0=100,this.v0=10,this.F0=0,this.vs=null,this._i=null,this.ds=null,this.vi=null}copy(){let t=new Se;return t.T0=this.T0,t.D0=this.D0,t.v0=this.v0,t.F0=this.F0,t.vs=this.vs,t._i=this._i,t.ds=this.ds,t.vi=this.vi,t}}class ti{Od;Id;hf;k0;constructor(){this.Od=nt.OL,this.Id=P.gn,this.hf=nt.jw,this.k0=[]}copy(){let t=new ti;return t.Od=this.Od.copy(),t.Id=this.Id.copy(),t.hf=this.hf.copy(),t.k0=this.k0,t}}class ne{Ii;Ei;O0;I0;E0;U0;P0;M0;S0;C0;L0;N0;A0;La;constructor(){this.Ii=[],this.Ei=[],this.O0=3,this.I0=3,this.E0=0,this.U0=0,this.P0=Dt.em,this.M0=1,this.S0=null,this.C0=null,this.L0=1,this.N0=null,this.A0=null,this.La=null}copy(t){let e=new ne,i=this.Ii,s=i.length,n=e.Ii;for(let h=0;h<s;h++){let l=i[h];if(l===void 0)continue;let u=l.copy();u.Uh(t),n[h]=u}let o=this.Ei,r=o.length,a=e.Ei;for(let h=0;h<r;h++){let l=o[h];if(l===void 0)continue;let u=l.copy();u.Uh(t),a[h]=u}return e.O0=this.O0,e.I0=this.I0,e.E0=this.E0,e.U0=this.U0,e.P0=this.P0.C(),e.M0=this.M0,e.S0=this.S0,e.C0=this.C0,e.L0=this.L0,e.N0=this.N0,e.A0=this.A0,e.La=this.La,e}}var zi=(x=>(x[x.Default=1]="Default",x[x.None=2]="None",x[x.ProportionalExtra=3]="ProportionalExtra",x))(zi||{});class Kt{Zs;V0;Tt;Xh;Gh;de;ct;Ud;ao;al;Vd;Bd;Yh;Nt;zd;Fs;q;ye;ki;constructor(t){V.Je(this),this.Zs=null,this.V0=!0,this.Tt=0,this.ki=NaN,this.Xh=0,this.Gh=1/0,this.de=T.Default,this.q=0,this.ye=0,this.ct=0,this.Fs=null,this.Ud=1,this.ao=1,this.al=null,this.Vd=null,this.Bd=NaN,this.Yh=null,this.Nt=null,this.zd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){let t=new Kt;return t.V0=this.V0,t.Tt=this.Tt,t.ki=this.ki,t.Xh=this.Xh,t.Gh=this.Gh,t.de=this.de,t.q=this.q,t.ye=this.ye,t.ct=this.ct,t.ao=this.ao,t.Ud=this.Ud,this.al===null?t.al=null:t.al=this.al.C(),t.Vd=this.Vd,t.Bd=this.Bd,t.Yh=null,this.Yh!==null&&(t.separatorDashArray=this.Yh.slice()),t.Nt=this.Nt,t.zd=this.zd,t.Fs=this.Fs,t}U1(t){t.isRow?t.height!==void 0&&(this.height=t.height):t.width!==void 0&&(this.width=t.width),t.minimum!==void 0&&(this.minimum=t.minimum),t.maximum!==void 0&&(this.maximum=t.maximum),t.alignment!==void 0&&(this.alignment=t.alignment),t.stretch!==void 0&&(this.stretch=t.stretch),t.sizing!==void 0&&(this.sizing=t.sizing),t.separatorPadding!==void 0&&(this.separatorPadding=t.separatorPadding),t.separatorStroke!==void 0&&(this.separatorStroke=t.separatorStroke),t.separatorStrokeWidth!==void 0&&(this.separatorStrokeWidth=t.separatorStrokeWidth),t.separatorDashArray!==void 0&&(this.Yh=t.separatorDashArray),t.background!==void 0&&(this.background=t.background),t.coversSeparators!==void 0&&(this.coversSeparators=t.coversSeparators),t.Fs!==void 0&&(this.Fs=t.Fs)}fe(t){t in zi?this.sizing=t:m.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+V.xs(this)}static Default=1;static None=2;static ProportionalExtra=3;Uh(t){this.Zs=t}computeEffectiveSpacingTop(t){let e=0,i=this.Zs;if(this.index!==t){let n=this.separatorStroke;n===null&&i!==null&&(n=this.isRow?i.defaultRowSeparatorStroke:i.defaultColumnSeparatorStroke),n!==null&&(e=this.separatorStrokeWidth,isNaN(e)&&(i!==null?e=this.isRow?i.defaultRowSeparatorStrokeWidth:i.defaultColumnSeparatorStrokeWidth:e=0))}let s=this.al;if(s===null)if(i!==null)s=i.defaultSeparatorPadding;else return e;return e+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0,e=this.Zs,i=0,s=this.isRow;if(e!==null&&e.type===G.Table){let o=s?e.Ii.length:e.Ei.length;for(let r=0;r<o;r++){let a=s?e.Ii[r]:e.Ei[r];if(a!==void 0&&a.q!==0){i=a.index;break}}}if(this.index!==i){let o=this.separatorStroke;o===null&&e!==null&&(o=s?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),o!==null&&(t=this.separatorStrokeWidth,isNaN(t)&&(e!==null?t=s?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:t=0))}let n=this.al;if(n===null)if(e!==null)n=e.defaultSeparatorPadding;else return t;return t+(this.isRow?n.top+n.bottom:n.left+n.right)}t(t,e,i,s,n){let o=this.Zs;if(o!==null&&(o.raiseChangedEvent(2,t,this,e,i,s,n),this.Fs!==null)){let r=o.diagram;if(r!==null&&!r.wi){let a=o.findBindingPanel();if(a!==null){let h=a.data;if(h!==null){let l=this.Fs.iterator;for(;l.next();)l.value.updateSource(this,h,t,a)}}}}}get panel(){return this.Zs}get isRow(){return this.V0}set isRow(t){this.V0=t}get index(){return this.Tt}set index(t){this.Tt=t}get height(){return this.ki}set height(t){let e=this.ki;e!==t&&(t<0&&m.J(t,">= 0",Kt,"height"),this.ki=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("height",e,t))}get width(){return this.ki}set width(t){let e=this.ki;e!==t&&(t<0&&m.J(t,">= 0",Kt,"width"),this.ki=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("width",e,t))}get minimum(){return this.Xh}set minimum(t){let e=this.Xh;e!==t&&((t<0||!isFinite(t))&&m.J(t,">= 0",Kt,"minimum"),this.Xh=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("minimum",e,t))}get maximum(){return this.Gh}set maximum(t){let e=this.Gh;e!==t&&(t<0&&m.J(t,">= 0",Kt,"maximum"),this.Gh=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("maximum",e,t))}get alignment(){return this.de}set alignment(t){let e=this.de;e.equals(t)||(this.de=t.C(),this.panel!==null&&this.panel.f(),this.t("alignment",e,t))}get stretch(){return this.ao}set stretch(t){let e=this.ao;e!==t&&(this.ao=t,this.panel!==null&&this.panel.f(),this.t("stretch",e,t))}get separatorPadding(){return this.al}set separatorPadding(t){typeof t=="number"&&(t=new Dt(t));let e=this.al;(t===null||e===null||!e.equals(t))&&(t!==null&&(t=t.C()),this.al=t,this.panel!==null&&this.panel.f(),this.t("separatorPadding",e,t))}get separatorStroke(){return this.Vd}set separatorStroke(t){let e=this.Vd;e!==t&&(t!==null&&R.Cd(t,"RowColumnDefinition.separatorStroke"),t instanceof R&&t.k(),this.Vd=t,this.panel!==null&&this.panel.f(),this.t("separatorStroke",e,t))}get separatorStrokeWidth(){return this.Bd}set separatorStrokeWidth(t){let e=this.Bd;e!==t&&(this.Bd=t,this.panel!==null&&this.panel.f(),this.t("separatorStrokeWidth",e,t))}get separatorDashArray(){return this.Yh}set separatorDashArray(t){let e=this.Yh;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",Kt,"separatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&m.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.Yh=t,this.panel!==null&&this.panel.N(),this.t("separatorDashArray",e,t)}}get background(){return this.Nt}set background(t){let e=this.Nt;e!==t&&(t!==null&&R.Cd(t,"RowColumnDefinition.background"),t instanceof R&&t.k(),this.Nt=t,this.panel!==null&&this.panel.N(),this.t("background",e,t))}get coversSeparators(){return this.zd}set coversSeparators(t){let e=this.zd;e!==t&&(m.s(t,"boolean",Kt,"coversSeparators"),this.zd=t,this.panel!==null&&this.panel.N(),this.t("coversSeparators",e,t))}get sizing(){return this.Ud}set sizing(t){let e=this.Ud;e!==t&&(this.Ud=t,this.panel!==null&&this.panel.f(),this.t("sizing",e,t))}Y1(){if(this.sizing===1){let t=this.Zs;return t===null?2:this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.q}set actual(t){isNaN(this.ki)?this.q=Math.max(Math.min(this.Gh,t),this.Xh):this.q=Math.max(Math.min(this.Gh,this.ki),this.Xh)}get measured(){return this.ye}set measured(t){this.ye=t}get total(){return this.q+this.computeEffectiveSpacing()}get position(){return this.ct}set position(t){this.ct=t}bind(t,e,i,s){return this.Sf(t,e,i,s),this}bindTwoWay(t,e,i,s){let n=this.Sf(t,e,i,s);return s===void 0&&n.makeTwoWay(),this}theme(t,e,i,s,n){return this.Ca(t,e,i,s,n),this}themeData(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofData(),this}themeObject(t,e,i,s,n,o){return this.Ca(t,e,i,s,n).ofObject(o),this}themeModel(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofModel(),this}Sf(t,e,i,s){let n;return typeof t=="string"?n=new ie(t,e,i,s):n=t,this.g0(n),n}Ca(t,e,i,s,n){let o;return typeof t=="string"?o=new ii(t,e,i,s,n):o=t,this.g0(o),o}g0(t){t.Ti=this;let e=this.panel;if(e!==null){let i=e.findBindingPanel();i!==null&&i.oD()&&m.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+e)}this.Fs===null&&(this.Fs=new q),this.Fs.add(t)}}class it extends J{ut;en;Xd;Kh;Qe;Zo;jo;Kt;Gd;Yd;K;constructor(t,e){super(),this.ut=null,this.en=null,this.Xd="None",this.Kh="black",this.Qe="black",this.Zo=1,this.jo=null,this.Kt=null,this.Gd=NaN,this.Yd=NaN,this.K=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.ut=this.ut,t.en=this.en,t.Xd=this.Xd,t.Kh=this.Kh,t.Qe=this.Qe,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Kt!==null&&(this.Kt.me?t.Kt=this.Kt:t.Kt=this.Kt.copy()),t.Gd=this.Gd,t.Yd=this.Yd,this.K!==null&&(t.K=this.K.copy())}Hh(){return this.Kt===null?this.Kt=new Xi:this.Kt.me&&(this.Kt=this.Kt.copy()),this.Kt}xa(){super.xa(),this.Kt!==null&&(this.Kt.me=!0)}fe(t){t in Ri?this.geometryStretch=t:super.fe(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+V.xs(this)}tE(t,e){let i=this.pathPattern;if(i===null)return;i.ht(1/0,1/0);let s=i.measuredBounds;i.Ut(0,0,s.width,s.height);let n=this.geometry;if(n===null)return;t.save(),t.beginPath();let o=m.st();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Kd(t,e,o,i);else if(n.type===4){let r=n.figures.iterator;for(;r.next();){let a=r.value;o.length=0,o.push(a.startX),o.push(a.startY);let h=a.startX,l=a.startY,u=h,c=l,d=a.segments.r,f=d.length;for(let p=0;p<f;p++){let g=d[p];switch(g.type){case 1:this.Kd(t,e,o,i),o.length=0,o.push(g.endX),o.push(g.endY),h=g.endX,l=g.endY,u=h,c=l;break;case 2:o.push(g.endX),o.push(g.endY),h=g.endX,l=g.endY;break;case 3:C.qn(h,l,g.point1X,g.point1Y,g.point2X,g.point2Y,g.endX,g.endY,.5,o),h=g.endX,l=g.endY;break;case 4:C.sm(h,l,g.point1X,g.point1Y,g.endX,g.endY,.5,o),h=g.endX,l=g.endY;break;case 5:{let y=g.vo(a),b=y.length;if(b===0){o.push(g.centerX),o.push(g.centerY),h=g.centerX,l=g.centerY;break}for(let v=0;v<b;v++){let w=y[v];C.qn(h,l,w[2],w[3],w[4],w[5],w[6],w[7],.5,o),h=w[6],l=w[7]}break}case 6:{let y=g.$a(a,h,l),b=y.length;if(b===0){o.push(g.endX),o.push(g.endY),h=g.endX,l=g.endY;break}for(let v=0;v<b;v++){let w=y[v];C.qn(h,l,w[2],w[3],w[4],w[5],w[6],w[7],.5,o),h=w[6],l=w[7]}break}default:m.o("Segment not of valid type: "+g.type)}g.isClosed&&(o.push(u),o.push(c),this.Kd(t,e,o,i))}this.Kd(t,e,o,i)}}else if(n.type===2)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.startY),o.push(n.endX),o.push(n.endY),o.push(n.startX),o.push(n.endY),o.push(n.startX),o.push(n.startY),this.Kd(t,e,o,i);else if(n.type===3){let r=new zt;r.startX=n.endX,r.startY=(n.startY+n.endY)/2;let a=new mt(5);a.startAngle=0,a.sweepAngle=360,a.centerX=(n.startX+n.endX)/2,a.centerY=(n.startY+n.endY)/2,a.radiusX=Math.abs(n.startX-n.endX)/2,a.radiusY=Math.abs(n.startY-n.endY)/2,r.add(a);let h=a.vo(r),l=h.length;if(l===0)o.push(a.centerX),o.push(a.centerY);else{let u=r.startX,c=r.startY;for(let d=0;d<l;d++){let f=h[d];C.qn(u,c,f[2],f[3],f[4],f[5],f[6],f[7],.5,o),u=f[6],c=f[7]}}this.Kd(t,e,o,i)}m.Z(o),t.restore(),t.clearContextCache(!1)}eE(t){let e=t.measuredBounds.width;return t instanceof it&&(e-=t.strokeWidth),e<1&&(e=1),e}Kd(t,e,i,s){let n=i.length;if(n<4)return;let o=s.measuredBounds,r=Math.max(1,o.width),a=o.height,h=i[0],l=i[1],u=0,c=0,d=0,f=0,p=0,g=0,y=0,b=0,v=m.st();for(let A=2;A<n;A+=2)u=i[A],c=i[A+1],d=u-h,f=c-l,d===0&&(d=.001),p=f/d,g=Math.atan2(f,d),y=Math.sqrt(d*d+f*f),v.push([d,g,p,y]),b+=y,h=u,l=c;h=i[0],l=i[1];let w=this.eE(s),k=w,S=r/2,N=S!==0,D=0,L=v[D];d=L[0],g=L[1],p=L[2],y=L[3];let M=0;for(;b>=.1;){if(M===0&&(N?(k=w,k-=S,b-=S,N=!1):k=w,k===0&&(k=1)),k>b){k=b,m.Z(v);return}k>y?(M=k-y,k=y):M=0;let A=Math.sqrt(k*k/(1+p*p));if(d<0&&(A=-A),h+=A,l+=p*A,t.translate(h,l),t.rotate(g),t.translate(-(r/2),-(a/2)),M===0&&s.Sa(t,e),t.translate(r/2,a/2),t.rotate(-g),t.translate(-h,-l),b-=k,y-=k,M!==0){if(D++,D===v.length){m.Z(v);return}L=v[D],d=L[0],g=L[1],p=L[2],y=L[3],k=M}}m.Z(v)}Sa(t,e){let i=t instanceof ae,s=this.Qe,n=this.Kh;if(s===null&&n===null)return;let o=this.ut;if(o===null)return;t.commitTransform();let r=this.actualBounds,a=this.naturalBounds;n!==null&&this.kn(t,n,!0,!1,a,r);let h=this.part,l=this.Zo;s!==null&&l===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(l=h.iE()),l===0&&(s=null),s!==null&&l!==0&&(this.kn(t,s,!1,!1,a,r),t.lineWidth=l,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let u=!1;h&&e.getRenderingHint("drawShadows")&&(u=h.isShadowed),t.rl===!1&&(u=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let d=!1,f=this.strokeDashArray;if(f!==null&&(d=!0,t.enableDash(f,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){let p=o.startX,g=o.startY,y=o.endX,b=o.endY,v=Math.min(p,y),w=Math.min(g,b),k=Math.abs(y-p),S=Math.abs(b-g);t.beginPath(),t.rect(v,w,k,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&u&&t.shadowsOff(),t.strokeContext(),c&&u&&t.shadowsOn()),t.endPath()}else if(o.type===3){let p=o.startX,g=o.startY,y=o.endX,b=o.endY,v=Math.abs(y-p)/2,w=Math.abs(b-g)/2,k=Math.min(p,y)+v,S=Math.min(g,b)+w;t.beginPath(),t.moveTo(k,S-w),t.bezierCurveTo(k+C.Hn*v,S-w,k+v,S-C.Hn*w,k+v,S),t.bezierCurveTo(k+v,S+C.Hn*w,k+C.Hn*v,S+w,k,S+w),t.bezierCurveTo(k-C.Hn*v,S+w,k-v,S+C.Hn*w,k-v,S),t.bezierCurveTo(k-v,S-C.Hn*w,k-C.Hn*v,S-w,k,S-w),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&u&&t.shadowsOff(),t.strokeContext(),c&&u&&t.shadowsOn()),t.endPath()}else if(o.type===4){let p=o.figures,g=p.length;for(let y=0;y<g;y++){let b=p.r[y];i?(t.beginPath(),this.PD(t,b)):b.ji===null&&(b.ji=new Path2D,this.PD(b.ji,b));let v=b.isFilled;u?b.isShadowed?(v===!0&&n!=="transparent"&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&(v&&c&&t.shadowsOff(),t.stroke(b.ji),v&&c&&t.shadowsOn())):(t.shadowsOff(),v&&n!=="transparent"&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&t.stroke(b.ji),t.shadowsOn()):(v&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&t.stroke(b.ji)),t.endPath(y)}}d&&t.disableDash(),this.tE(t,e)}PD(t,e){t.moveTo(e.startX,e.startY);let i=e.segments.r,s=i.length,n=null;for(let o=0;o<s;o++){let r=i[o];switch(r.type){case 1:t.moveTo(r.endX,r.endY);break;case 2:t.lineTo(r.endX,r.endY);break;case 3:t.bezierCurveTo(r.point1X,r.point1Y,r.point2X,r.point2Y,r.endX,r.endY);break;case 4:t.quadraticCurveTo(r.point1X,r.point1Y,r.endX,r.endY);break;case 5:if(r.radiusX===r.radiusY){let a=n!==null?n.endX:e.startX,h=n!==null?n.endY:e.startY,l=Math.PI/180;t.arc(r.point1X,r.point1Y,r.radiusX,r.startAngle*l,(r.startAngle+r.sweepAngle)*l,r.sweepAngle<0,a,h)}else{let a=r.vo(e),h=a.length;if(h===0){t.lineTo(r.centerX,r.centerY);break}for(let l=0;l<h;l++){let u=a[l];l===0&&t.lineTo(u[0],u[1]),t.bezierCurveTo(u[2],u[3],u[4],u[5],u[6],u[7])}}break;case 6:{let a=0,h=0,l;if(n!==null&&n.type===5){l=n.vo(e);let c=l.length;if(c===0){t.lineTo(r.endX,r.endY);break}let d=l[c-1]||null;d!==null&&(a=d[6],h=d[7])}else a=n!==null?n.endX:e.startX,h=n!==null?n.endY:e.startY;l=r.$a(e,a,h);let u=l.length;if(u===0){t.lineTo(r.endX,r.endY);break}for(let c=0;c<u;c++){let d=l[c];t.bezierCurveTo(d[2],d[3],d[4],d[5],d[6],d[7])}break}}r.isClosed&&t.closePath(),n=r}}wf(t,e,i){if(!super.wf(t,e,i)||this.Qe===null&&this.Kh===null||this.ut===null||this.pathPattern!==null)return!1;let s=this.svg.getElementsByTagName("path");return this.geometry.figures.length!==s.length?!1:(t.currentPath=this.svg,this.Sa(t,e),t.currentPath=null,!0)}Sd(t){return this.geometry!==null&&this.geometry.figures.length>1||this.pathPattern!==null?!0:super.Sd(t)}NC(t,e){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",e);else{let i=t.getElementsByTagName("path");for(let s=0;s<i.length;s++)i[s].setAttributeNS(null,"filter",e)}}getDocumentPoint(t,e){if(e===void 0&&(e=new P),t instanceof T){let i=t;i.isNoSpot()&&m.o("getDocumentPoint Spot must be a real, specific Spot, not: "+i.toString());let s=this.naturalBounds,n=this.strokeWidth;return e.e(i.x*(s.width+n)-n/2+s.x+i.offsetX,i.y*(s.height+n)-n/2+s.y+i.offsetY),this.Js.gt(e),e}else return e.set(t),this.Js.gt(e),e}getDocumentBounds(t){t===void 0&&(t=new I);let e=this.naturalBounds,i=this.Js,s=I.z(e.x,e.y,e.width,e.height),n=this.strokeWidth;s.inflate(n/2,n/2);let o=P.z(s.x,s.y).v(i);return t.e(o.x,o.y,0,0),o.e(s.right,s.y).v(i),t.re(o.x,o.y,0,0),o.e(s.right,s.bottom).v(i),t.re(o.x,o.y,0,0),o.e(s.x,s.bottom).v(i),t.re(o.x,o.y,0,0),I.i(s),P.i(o),t}ba(t,e){let i=this.geometry;if(i===null||this.fill===null&&this.stroke===null)return!1;let s=i.bounds,n=this.strokeWidth/2;i.type===1&&!e&&(n+=2);let o=I.l();if(o.h(s),o.inflate(n+2,n+2),!o.containsPoint(t))return I.i(o),!1;let r=n+1e-4;if(i.type===1){if(this.stroke===null)return!1;let a=(i.startX-i.endX)*(t.x-i.endX)+(i.startY-i.endY)*(t.y-i.endY),h=(i.endX-i.startX)*(t.x-i.startX)+(i.endY-i.startY)*(t.y-i.startY);return a<0||h<0?!1:(I.i(o),C.Ve(i.startX,i.startY,i.endX,i.endY,n,t.x,t.y))}else if(i.type===2){let a=i.startX,h=i.startY,l=i.endX,u=i.endY;if(o.x=Math.min(a,l),o.y=Math.min(h,u),o.width=Math.abs(l-a),o.height=Math.abs(u-h),this.fill===null){if(o.inflate(-r,-r),o.containsPoint(t))return I.i(o),!1;o.inflate(r,r)}this.stroke!==null&&o.inflate(n,n);let c=o.containsPoint(t);return I.i(o),c}else if(i.type===3){let a=i.startX,h=i.startY,l=i.endX,u=i.endY,c=Math.min(a,l),d=Math.min(h,u),f=Math.abs(l-a),p=Math.abs(u-h),g=f/2,y=p/2;if(c=t.x-(c+g),d=t.y-(d+y),this.fill===null){if(g-=r,y-=r,g<=0||y<=0||c*c/(g*g)+d*d/(y*y)<=1)return I.i(o),!1;g+=r,y+=r}return this.stroke!==null&&(g+=r,y+=r),I.i(o),g<=0||y<=0?!1:c*c/(g*g)+d*d/(y*y)<=1}else{if(i.type===4)return I.i(o),this.fill===null?i.ZL(t.x,t.y,n):i.OP(t,n,this.strokeWidth>1,e);m.o("Unknown Geometry type: "+i.type)}}kd(t,e,i,s){let n=this.desiredSize,o=this.Zo;t=Math.max(t,0),e=Math.max(e,0);let r;if(this.en!==null)r=this.geometry.bounds;else{let p=this.figure,g=it.eN[p];if(g===void 0){let y=C.jn[p];typeof y=="string"&&(y=C.jn[y]),m.it(y)?(g=y(null,100,100),it.eN[p]=g):m.o("Unsupported Figure: "+p)}r=g.bounds}let a=r.width,h=r.height,l=r.width,u=r.height;switch(this.Qs(!0)){case 0:i=0,s=0;break;case 2:l=Math.max(t-o,0),u=Math.max(e-o,0);break;case 5:l=Math.max(t-o,0),s=0;break;case 4:i=0,u=Math.max(e-o,0);break}isFinite(n.width)&&(l=n.width),isFinite(n.height)&&(u=n.height);let c=this.maxSize,d=this.minSize;i=Math.max(i-o,d.width),s=Math.max(s-o,d.height),l=Math.min(c.width,l),u=Math.min(c.height,u),l=isFinite(l)?Math.max(i,l):Math.max(a,i),u=isFinite(u)?Math.max(s,u):Math.max(h,s);let f=this.ZS();switch(f){case 0:break;case 2:a=l,h=u;break;case 6:{let p=Math.min(l/a,u/h);isFinite(p)||(p=1),a=a*p,h=h*p;break}default:m.o(f+" is not a valid geometryStretch.")}if(this.en!==null){a===0&&(a=.001),h===0&&(h=.001);let p=this.en.nR(a,h);this.ut=p}else(this.ut===null||!C.X(this.ut.Pc,t-o)||!C.X(this.ut.Sc,e-o))&&(this.ut=it.sE(this,a,h));r=this.ut.bounds,t===1/0||e===1/0?this.ro(r.x-o/2,r.y-o/2,t===0&&a===0?0:r.width+o,e===0&&h===0?0:r.height+o):this.ro(-(o/2),-(o/2),l+o,u+o),n.isReal()?(l=n.width,u=n.height,l=Math.min(c.width,l),u=Math.min(c.height,u),l=Math.max(d.width,l),u=Math.max(d.height,u),this.Ke.e(0,0,l,u)):this.Ke.h(r)}ZS(){let t=this.geometryStretch;return this.en!==null?t===1?2:t:t===1?it.eN[this.figure].defaultStretch:t}ka(t,e,i,s){this.commonArrange(t,e,i,s)}getNearestIntersectionPoint(t,e,i){return this.pf(t.x,t.y,e.x,e.y,i)}pf(t,e,i,s,n){let o=this.v,r=1/(o.m11*o.m22-o.m12*o.m21),a=o.m22*r,h=-o.m12*r,l=-o.m21*r,u=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),d=r*(o.m12*o.dx-o.m11*o.dy),f=t*a+e*l+c,p=t*h+e*u+d,g=i*a+s*l+c,y=i*h+s*u+d,b=this.Zo/2,v=this.ut;v===null&&(this.ht(1/0,1/0),v=this.ut);let w=v.bounds,k=!1;if(v.type===1)if(this.strokeWidth<=1.5)k=C.Do(v.startX,v.startY,v.endX,v.endY,f,p,g,y,n);else{let S=0,N=0;if(v.startX===v.endX)S=b,N=0;else{let F=(v.endY-v.startY)/(v.endX-v.startX);N=b/Math.sqrt(1+F*F),S=N*F}let D=m.st(),L=new P;C.Do(v.startX+S,v.startY+N,v.endX+S,v.endY+N,f,p,g,y,L)&&D.push(L),L=new P,C.Do(v.startX-S,v.startY-N,v.endX-S,v.endY-N,f,p,g,y,L)&&D.push(L),L=new P,C.Do(v.startX+S,v.startY+N,v.startX-S,v.startY-N,f,p,g,y,L)&&D.push(L),L=new P,C.Do(v.endX+S,v.endY+N,v.endX-S,v.endY-N,f,p,g,y,L)&&D.push(L);let M=D.length;if(M===0)return m.Z(D),!1;k=!0;let A=1/0;for(let F=0;F<M;F++){let O=D[F],E=(O.x-f)**2+(O.y-p)**2;E<A&&(A=E,n.x=O.x,n.y=O.y)}m.Z(D)}else if(v.type===2)k=C.Al(w.x-b,w.y-b,w.x+w.width+b,w.y+w.height+b,f,p,g,y,n);else if(v.type===3){let S=I.z(w.x,w.y,w.width,w.height).inflate(b,b);k=this.nE(S,f,p,g,y,n),I.i(S)}else if(v.type===4){let S=0,N=0,D=0,L=0,M=P.l(),A=g-f,F=y-p,O=A*A+F*F,E=f,B=p;if(O>0&&w.contains(E,B)&&(M.x=E,M.y=B,this.containsPoint(M)))for(A!==0&&Math.abs(A)<.5?(F*=.5/A,A=.5):F!==0&&Math.abs(F)<.5&&(A*=.5/F,F=.5),E-=A,B-=F;w.contains(E,B);)E-=A,B-=F;let X=.6;n.x=g,n.y=y;for(let st=0;st<v.figures.count;st++){let Z=v.figures.r[st],et=Z.isFilled?E:f,Q=Z.isFilled?B:p,rt=Z.segments;S=Z.startX,N=Z.startY;let ft=S,xt=N;for(let Ct=0;Ct<rt.count;Ct++){let _=rt.r[Ct],St=_.type;D=_.endX,L=_.endY;let bt=!1;switch(St){case 1:ft=D,xt=L;break;case 2:bt=this.J1(S,N,D,L,et,Q,g,y,M);break;case 3:{bt=C.nm(S,N,_.point1X,_.point1Y,_.point2X,_.point2Y,D,L,et,Q,g,y,X,M);break}case 4:{bt=C.nm(S,N,S+2/3*(_.point1X-S),N+2/3*(_.point1Y-N),D+2/3*(_.point1X-D),L+2/3*(_.point1Y-L),D,L,et,Q,g,y,X,M);break}case 5:case 6:{let Yt=_.type===5?_.vo(Z):_.$a(Z,S,N),ot=Yt.length;if(ot===0){bt=this.J1(S,N,_.type===5?_.centerX:_.endX,_.type===5?_.centerY:_.endY,et,Q,g,y,M);break}let H=null;for(let gt=0;gt<ot;gt++){if(H=Yt[gt],gt===0&&this.J1(S,N,H[0],H[1],et,Q,g,y,M)){let At=this.$1(et,Q,M,O,n);At<O&&(O=At,k=!0)}if(C.nm(H[0],H[1],H[2],H[3],H[4],H[5],H[6],H[7],et,Q,g,y,X,M)){let At=this.$1(et,Q,M,O,n);At<O&&(O=At,k=!0)}}D=H[6],L=H[7];break}default:m.o("Unknown Segment type: "+St)}if(S=D,N=L,bt){let Yt=this.$1(et,Q,M,O,n);Yt<O&&(O=Yt,k=!0)}if(_.isClosed&&(D=ft,L=xt,this.J1(S,N,D,L,et,Q,g,y,M))){let Yt=this.$1(et,Q,M,O,n);Yt<O&&(O=Yt,k=!0)}}}let z=i-t,U=s-e,tt=Math.sqrt(z*z+U*U);tt!==0&&(z/=tt,U/=tt),n.x-=z*b,n.y-=U*b,P.i(M)}else m.o("Unknown Geometry type: "+v.type);return k?(this.v.gt(n),!0):!1}$1(t,e,i,s,n){let o=i.x-t,r=i.y-e,a=o*o+r*r;return a<s?(n.x=i.x,n.y=i.y,a):s}J1(t,e,i,s,n,o,r,a,h){if(C.X(t,i)&&C.X(e,s)||C.X(n,r)&&C.X(o,a))return!1;let l=!1,u=(n-r)*(e-s)-(o-a)*(t-i);if(u===0)return!1;if(h.x=((n*a-o*r)*(t-i)-(n-r)*(t*s-e*i))/u,h.y=((n*a-o*r)*(e-s)-(o-a)*(t*s-e*i))/u,(t>i?t-i:i-t)<(e>s?e-s:s-e)){let c=e<s?e:s,d=e<s?s:e;(h.y>c||C.X(h.y,c))&&(h.y<d||C.X(h.y,d))&&(l=!0)}else{let c=t<i?t:i,d=t<i?i:t;(h.x>c||C.X(h.x,c))&&(h.x<d||C.X(h.x,d))&&(l=!0)}return l}oE(t,e,i){return this.pickable===!1?!1:(i.bc(this.v),e?this.rE(t,i):this.containedInRect(t,i))}containedInRect(t,e){if(e===void 0)return t.containsRect(this.actualBounds);let i=this.ut;i===null&&(this.ht(1/0,1/0),i=this.ut);let s=i.bounds,n=this.strokeWidth/2,o=!1,r=P.l();return r.e(s.x-n,s.y-n),t.containsPoint(e.gt(r))&&(r.e(s.x-n,s.bottom+n),t.containsPoint(e.gt(r))&&(r.e(s.right+n,s.bottom+n),t.containsPoint(e.gt(r))&&(r.e(s.right+n,s.y-n),t.containsPoint(e.gt(r))&&(o=!0)))),P.i(r),o}intersectsRect(t,e){if(this.containedInRect(t,e)||e===void 0&&(e=this.v,t.containsRect(this.actualBounds)))return!0;let i=Nt.l();i.set(e),i.Zw();let s=t.left,n=t.right,o=t.top,r=t.bottom,a=P.l();if(a.e(s,o),i.gt(a),this.ba(a,!0)||(a.e(n,o),i.gt(a),this.ba(a,!0))||(a.e(s,r),i.gt(a),this.ba(a,!0))||(a.e(n,r),i.gt(a),this.ba(a,!0)))return P.i(a),!0;let h=P.l(),l=P.l();i.set(e),i.zL(this.v),i.Zw(),h.x=n,h.y=o,h.v(i),a.x=s,a.y=o,a.v(i);let u=!1;return this.qh(a,h,l)?u=!0:(a.x=n,a.y=r,a.v(i),this.qh(a,h,l)?u=!0:(h.x=s,h.y=r,h.v(i),this.qh(a,h,l)?u=!0:(a.x=s,a.y=o,a.v(i),this.qh(a,h,l)&&(u=!0)))),P.i(a),Nt.i(i),P.i(h),P.i(l),u}qh(t,e,i){if(!this.getNearestIntersectionPoint(t,e,i))return!1;let s=t.x,n=t.y,o=e.x,r=e.y,a=i.x,h=i.y;if(s===o){let l=0,u=0;return n<r?(l=n,u=r):(l=r,u=n),h>=l&&h<=u}else{let l=0,u=0;return s<o?(l=s,u=o):(l=o,u=s),a>=l&&a<=u}}rE(t,e){if(this.containedInRect(t,e)||e===void 0&&(e=this.v,t.containsRect(this.actualBounds)))return!0;let i=t.left,s=t.right,n=t.top,o=t.bottom,r=P.l(),a=P.l(),h=P.l(),l=Nt.l();l.set(e),l.zL(this.v),l.Zw(),a.x=s,a.y=n,a.v(l),r.x=i,r.y=n,r.v(l);let u=!1;return this.qh(r,a,h)?u=!0:(r.x=s,r.y=o,r.v(l),this.qh(r,a,h)?u=!0:(a.x=i,a.y=o,a.v(l),this.qh(r,a,h)?u=!0:(r.x=i,r.y=n,r.v(l),this.qh(r,a,h)&&(u=!0)))),Nt.i(l),P.i(r),P.i(a),P.i(h),u}ZT(t,e,i){if(i&&this.fill!==null&&this.ba(t,!0))return!0;let s=t.distanceSquaredPoint(e),n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ut;if(o===null&&(this.ht(1/0,1/0),o=this.ut,o===null))return!1;if(!i){let c=o.bounds,d=c.x,f=c.y,p=c.x+c.width,g=c.y+c.height;if(P.distanceSquared(t.x,t.y,d,f)<=s&&P.distanceSquared(t.x,t.y,p,f)<=s&&P.distanceSquared(t.x,t.y,d,g)<=s&&P.distanceSquared(t.x,t.y,p,g)<=s)return!0}function r(c,d){let f=c.length;for(let p=0;p<f;p+=2)if(d.distanceSquared(c[p],c[p+1])>s)return!0;return!1}let a=o.startX,h=o.startY,l=o.endX,u=o.endY;if(o.type===1){let c=P.distanceLineSegmentSquared(t.x,t.y,a,h,l,u),d=(l-a)*(t.x-a)+(u-h)*(t.y-h),f=(a-l)*(t.x-l)+(h-u)*(t.y-u),p=d>=0&&f>=0?s:n;return c<=p}else if(o.type===2){let c=!1;return i&&(c=P.distanceLineSegmentSquared(t.x,t.y,a,h,a,u)<=s||P.distanceLineSegmentSquared(t.x,t.y,a,h,l,h)<=s||P.distanceLineSegmentSquared(t.x,t.y,l,h,l,u)<=s||P.distanceLineSegmentSquared(t.x,t.y,a,u,l,u)<=s),c}else if(o.type===3){let c=(a+l)/2,d=(h+u)/2,f=t.x-c,p=t.y-d,g=Math.abs(l-a)/2,y=Math.abs(u-h)/2;if(g===0||y===0)return P.distanceLineSegmentSquared(t.x,t.y,a,h,l,u)<=s;if(i){let b=C.JF(g,y,f,p);return b*b<=s}else return!(P.distanceSquared(f,p,-g,0)>=s||P.distanceSquared(f,p,0,-y)>=s||P.distanceSquared(f,p,0,y)>=s||P.distanceSquared(f,p,g,0)>=s)}else if(o.type===4){let c=o.bounds,d=c.x,f=c.y,p=c.x+c.width,g=c.y+c.height;if(t.x>p&&t.x<d&&t.y>g&&t.y<f&&P.distanceLineSegmentSquared(t.x,t.y,d,f,d,g)>s&&P.distanceLineSegmentSquared(t.x,t.y,d,f,p,f)>s&&P.distanceLineSegmentSquared(t.x,t.y,p,g,d,g)>s&&P.distanceLineSegmentSquared(t.x,t.y,p,g,p,f)>s)return!1;let y=Math.sqrt(s);if(i){if(this.fill===null?o.ZL(t.x,t.y,y):o.OP(t,y,!0,!1))return!0}else{let b=o.figures;for(let v=0;v<b.count;v++){let w=b.r[v],k=w.startX,S=w.startY;if(t.distanceSquared(k,S)>s)return!1;let N=w.segments.r,D=N.length;for(let L=0;L<D;L++){let M=N[L];switch(M.type){case 1:case 2:if(k=M.endX,S=M.endY,t.distanceSquared(k,S)>s)return!1;break;case 3:{let A=m.st();C.qn(k,S,M.point1X,M.point1Y,M.point2X,M.point2Y,M.endX,M.endY,.8,A);let F=r(A,t);if(m.Z(A),F||(k=M.endX,S=M.endY,t.distanceSquared(k,S)>s))return!1;break}case 4:{let A=m.st();C.sm(k,S,M.point1X,M.point1Y,M.endX,M.endY,.8,A);let F=r(A,t);if(m.Z(A),F||(k=M.endX,S=M.endY,t.distanceSquared(k,S)>s))return!1;break}case 5:case 6:{let A=M.type===5?M.vo(w):M.$a(w,k,S),F=A.length;if(F===0){if(k=M.type===5?M.centerX:M.endX,S=M.type===5?M.centerY:M.endY,t.distanceSquared(k,S)>s)return!1;break}let O=null,E=m.st();for(let B=0;B<F;B++)if(O=A[B],E.length=0,C.qn(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],.8,E),r(E,t))return m.Z(E),!1;m.Z(E),O!==null&&(k=O[6],S=O[7]);break}default:m.o("Unknown Segment type: "+M.type)}}}return!0}}return!1}nE(t,e,i,s,n,o){if(t.width===0)return C.Do(t.x,t.y,t.x,t.y+t.height,e,i,s,n,o);if(t.height===0)return C.Do(t.x,t.y,t.x+t.width,t.y,e,i,s,n,o);{let r=t.width/2,a=t.height/2,h=t.x+r,l=t.y+a,u=9999;if(e!==s&&(u=(i-n)/(e-s)),Math.abs(u)<9999){let c=i-l-u*(e-h);if(r*r*(u*u)+a*a-c*c<0)return o.x=NaN,o.y=NaN,!1;let d=Math.sqrt(r*r*(u*u)+a*a-c*c),f=(-(r*r*u*c)+r*a*d)/(a*a+r*r*(u*u))+h,p=(-(r*r*u*c)-r*a*d)/(a*a+r*r*(u*u))+h,g=u*(f-h)+c+l,y=u*(p-h)+c+l,b=Math.abs((e-f)**2)+Math.abs((i-g)**2),v=Math.abs((e-p)**2)+Math.abs((i-y)**2);b<v?(o.x=f,o.y=g):(o.x=p,o.y=y)}else{let c=a*a,d=r*r,f=e-h,p=c-c/d*(f*f);if(p<0)return o.x=NaN,o.y=NaN,!1;let g=Math.sqrt(p),y=l+g,b=l-g,v=Math.abs(y-i),w=Math.abs(b-i);v<w?(o.x=e,o.y=y):(o.x=e,o.y=b)}return!0}}WI(){return this.Zo/2*this.strokeMiterLimit*this.getDocumentScale()}get geometry(){return this.ut!==null?this.ut:this.en}set geometry(t){let e=this.ut,i=this.en;if(e===t)return;t!==null?(this.ut=t.k(),this.en=this.ut):(this.ut=null,this.en=null);let s=this.part;if(s!==null&&s.Df(),this.f(),this.t("geometry",e||i,t),this.mf()){let n=this.part;n!==null&&this.Eh(n,"geometryString")}}get geometryString(){return this.geometry===null?"":this.geometry.toString()}set geometryString(t){let e=wt.parse(t),i=e.normalize();this.geometry=e;let s=P.z(-i.x,-i.y);this.position=s,P.i(s)}get isGeometryPositioned(){return(this.n&1048576)!==0}set isGeometryPositioned(t){let e=(this.n&1048576)!==0;e!==t&&(this.n=this.n^1048576,this.f(),this.t("isGeometryPositioned",e,t))}ai(){this.ut=null}get fill(){return this.Kh}set fill(t){let e=this.Kh;e!==t&&(t!==null&&R.Cd(t,"Shape.fill"),t instanceof R&&t.k(),this.Kh=t,this.N(),this.t("fill",e,t))}get stroke(){return this.Qe}set stroke(t){let e=this.Qe;e!==t&&(t!==null&&R.Cd(t,"Shape.stroke"),t instanceof R&&t.k(),this.Qe=t,this.N(),this.t("stroke",e,t))}get strokeWidth(){return this.Zo}set strokeWidth(t){let e=this.Zo;if(e!==t)if(t>=0){this.Zo=t,this.f();let i=this.part;i!==null&&i.Df(),this.t("strokeWidth",e,t)}else m.J(t,"value >= 0",it,"strokeWidth:value")}Gp(){return this.Zo}get strokeCap(){return this.Kt!==null?this.Kt.B0:"butt"}set strokeCap(t){let e=this.strokeCap;e!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Hh().B0=t,this.N(),this.t("strokeCap",e,t)):m.J(t,'"butt", "round", or "square"',it,"strokeCap"))}get strokeJoin(){return this.Kt!==null?this.Kt.z0:"miter"}set strokeJoin(t){let e=this.strokeJoin;e!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Hh().z0=t,this.N(),this.t("strokeJoin",e,t)):m.J(t,'"miter", "bevel", or "round"',it,"strokeJoin"))}get strokeMiterLimit(){return this.Kt!==null?this.Kt.X0:10}set strokeMiterLimit(t){let e=this.strokeMiterLimit;if(e!==t&&t>=1){this.Hh().X0=t,this.N();let i=this.part;i!==null&&i.Df(),this.t("strokeMiterLimit",e,t)}}get strokeDashArray(){return this.jo}set strokeDashArray(t){let e=this.jo;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",it,"strokeDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(!(o>=0)||!isFinite(o))&&m.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.jo=t,this.N(),this.t("strokeDashArray",e,t)}}get strokeDashOffset(){return this.Kt!==null?this.Kt.Na:0}set strokeDashOffset(t){let e=this.strokeDashOffset;e!==t&&t>=0&&(this.Hh().Na=t,this.N(),this.t("strokeDashOffset",e,t))}get figure(){return this.Xd}set figure(t){let e=this.Xd;if(e!==t){let i=C.jn[t];if(m.it(i)?i=t:(i=C.jn[t.toLowerCase()],(!i||typeof i=="function")&&m.o("Unknown Shape.figure: "+t)),e!==i){let s=this.part;s!==null&&s.Df(),this.Xd=i,this.en=null,this.ai(),this.f(),this.t("figure",e,i)}}}get toArrow(){return this.Ot!==null?this.Ot.G0:"None"}set toArrow(t){let e=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),e!==t){let i=it.SD(t);i===null?m.o("Unknown Shape.toArrow: "+t):e!==i&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.G0=i,this.en=null,this.ai(),this.f(),this.MD(i),this.t("toArrow",e,i))}}get fromArrow(){return this.Ot!==null?this.Ot.Y0:"None"}set fromArrow(t){let e=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),e!==t){let i=it.SD(t);i===null?m.o("Unknown Shape.fromArrow: "+t):e!==i&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.Y0=i,this.en=null,this.ai(),this.f(),this.MD(i),this.t("fromArrow",e,i))}}MD(t){let e=this.diagram;e!==null&&e.undoManager.isUndoingRedoing||(this.yI(),this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=T.Right):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=T.Left))}get spot1(){return this.Kt!==null?this.Kt.Wn:T.Default}set spot1(t){let e=this.spot1;e.equals(t)||(t=t.C(),this.Hh().Wn=t,this.f(),this.t("spot1",e,t))}get spot2(){return this.Kt!==null?this.Kt.Jn:T.Default}set spot2(t){let e=this.spot2;e.equals(t)||(t=t.C(),this.Hh().Jn=t,this.f(),this.t("spot2",e,t))}get parameter1(){return this.Gd}set parameter1(t){let e=this.Gd;e!==t&&(this.Gd=t,this.ai(),this.f(),this.t("parameter1",e,t))}get parameter2(){return this.Yd}set parameter2(t){let e=this.Yd;e!==t&&(this.Yd=t,this.ai(),this.f(),this.t("parameter2",e,t))}get naturalBounds(){return this.Ke}VI(){let t=this.desiredSize;if(!t.isReal()&&this.ut!==null){let e=this.ut.bounds;this.Ke.h(e)}else this.Ke.e(0,0,t.width,t.height)}get pathPattern(){return this.Kt!==null?this.Kt.K0:null}set pathPattern(t){let e=this.pathPattern;e!==t&&(this.Hh().K0=t,this.N(),this.t("pathPattern",e,t))}get geometryStretch(){return this.Kt!==null?this.Kt.H0:1}set geometryStretch(t){let e=this.geometryStretch;e!==t&&(this.Hh().H0=t,this.f(),this.t("geometryStretch",e,t))}get interval(){return this.K!==null?this.K.Ff:1}set interval(t){let e=this.interval;if(t=Math.round(t),e!==t&&t!==0&&isFinite(t)){this.K===null&&(this.K=new be),this.K.Ff=t;let i=this.panel;if(i!==null){i.ds=null,i.f();let s=this.diagram;s!==null&&i===s.grid&&s.cd()}this.t("interval",e,t)}}get graduatedStart(){return this.K!==null?this.K.Rf:0}set graduatedStart(t){let e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Rf=t,this.f(),this.t("graduatedStart",e,t))}get graduatedEnd(){return this.K!==null?this.K.Of:1}set graduatedEnd(t){let e=this.graduatedEnd;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Of=t,this.f(),this.t("graduatedEnd",e,t))}get graduatedSkip(){return this.K!==null?this.K.If:null}set graduatedSkip(t){let e=this.graduatedSkip;e!==t&&(t!==null&&m.S(t,it,"graduatedSkip"),this.K===null&&(this.K=new be),this.K.If=t,this.f(),this.t("graduatedSkip",e,t))}polygonContainsRect(t){let e=this;if(!e.part||!e.part.actualBounds.containsRect(t))return!1;let i=e.geometry;if(!i)return!1;let s=t.x,n=t.y,o=t.width,r=t.height,a=P.l();if(a.x=s,a.y=n,e.getLocalPoint(a,a),!i.containsPoint(a)||o>0&&r>0&&(a.x=s+o,a.y=n+r,e.getLocalPoint(a,a),!i.containsPoint(a))||o>0&&(a.x=s+o,a.y=n,e.getLocalPoint(a,a),!i.containsPoint(a))||r>0&&(a.x=s,a.y=n+r,e.getLocalPoint(a,a),!i.containsPoint(a))||i.type===1)return!1;if(i.type===4){let h=i.figures.iterator;for(;h.next();){let l=h.value;if(!l.isFilled)continue;a.x=l.startX,a.y=l.startY,e.getDocumentPoint(a,a);let u=a.x,c=a.y,d=u,f=c,p=u,g=c,y=l.segments.iterator;for(;y.next();){let b=y.value;if(a.x=b.endX,a.y=b.endY,e.getDocumentPoint(a,a),p=a.x,g=a.y,b.type===1)u=p,c=g;else if(b.type!==5&&(I.intersectsLineSegment(s,n,o,r,d,f,p,g)||b.isClosed&&I.intersectsLineSegment(s,n,o,r,p,g,u,c)))return!1;d=p,f=g}}}return P.i(a),!0}static sE(t,e,i){let s=null;if(t.toArrow!=="None")s=it.Dn[t.toArrow];else if(t.fromArrow!=="None")s=it.Dn[t.fromArrow];else{let n=C.jn[t.figure];typeof n=="string"&&(n=C.jn[n]),n===void 0&&m.o("Unknown Shape.figure: "+t.figure),s=n(t,e,i),s.Pc=e,s.Sc=i}if(s===null){let n=C.jn.Rectangle;m.it(n)&&(s=n(t,e,i))}return s}static getFigureGenerators(){let t=new Mt;for(let e in C.jn){if(e===e.toLowerCase())continue;let i=C.jn[e];t.set(e,i)}return t.k(),t}static defineFigureGenerator(t,e){m.s(t,"string",it,"defineFigureGenerator:name"),typeof e=="string"||m.S(e,it,"defineFigureGenerator:func");let i=t.toLowerCase(),s=C.jn;s[t]=e,s[i]=t}static isFigureDefined(t){return t in C.jn}static getArrowheadGeometries(){let t=new Mt;for(let e in C.rm)if(it.Dn[e]===void 0){let i=wt.parse(C.rm[e],!1);it.Dn[e]=i;let s=e.toLowerCase();s!==e&&(it.Dn[s]=e)}for(let e in it.Dn){if(e===e.toLowerCase())continue;let i=it.Dn[e];i instanceof wt&&t.set(e,i)}return t.k(),t}static defineArrowheadGeometry(t,e){m.s(t,"string",it,"defineArrowheadGeometry:name");let i=null;typeof e=="string"?(m.s(e,"string",it,"defineArrowheadGeometry:pathstr"),i=wt.parse(e,!1)):i=e;let s=t.toLowerCase();(s==="none"||t===s)&&m.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);let n=it.Dn;n[t]=i,n[s]=t}static isArrowheadDefined(t){return it.Dn.has(t)}static Dn=new yt;static eN=new yt;static SD(t){let e=it.Dn[t];if(e===void 0){let i=t.toLowerCase();if(i==="none")return"None";if(e=it.Dn[i],e===void 0){let s=null;for(let n in C.rm)if(n.toLowerCase()===i){s=n;break}if(s!==null){let n=wt.parse(C.rm[s],!1);return it.Dn[s]=n,i!==s&&(it.Dn[i]=s),s}}}return typeof e=="string"?e:e instanceof wt?t:null}}class Xi{me;B0;z0;X0;Na;K0;H0;Wn;Jn;constructor(){this.me=!1,this.B0="butt",this.z0="miter",this.X0=10,this.Na=0,this.K0=null,this.H0=1,this.Wn=T.Default,this.Jn=T.Default}copy(){let t=new Xi;return t.B0=this.B0,t.z0=this.z0,t.X0=this.X0,t.Na=this.Na,t.K0=this.K0,t.H0=this.H0,t.Wn=this.Wn.C(),t.Jn=this.Jn.C(),t}}var Ki=(x=>(x[x.None=0]="None",x[x.Fit=1]="Fit",x[x.DesiredSize=2]="DesiredSize",x[x.BreakAll=3]="BreakAll",x))(Ki||{}),js=(x=>(x[x.Clip=0]="Clip",x[x.Ellipsis=1]="Ellipsis",x))(js||{}),Yi=(x=>(x[x.Trim=0]="Trim",x[x.None=1]="None",x))(Yi||{});class lt extends J{ue;Qe;vn;Pi;pe;Yp;Hd;K;tt;Yl;uo;Fn;Ui;we;Rn;constructor(t,e){return super(),lt.b0===!1&&(lt.b0=!0,lt.us=Y.isUsingDOM()?new De(null)._t:null),this.n|=2097152,this.ue="",this.Qe="black",this.vn="13px sans-serif",this.Pi=0,this.pe=0,this.Yp=0,this.Hd=null,this.K=null,this.tt=null,this.Yl=0,this.uo=null,this.Fn=0,this.Ui=null,this.we=null,this.Rn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),e&&Object.assign(this,e),this}cloneProtected(t){super.cloneProtected(t),t.ue=this.ue,t.Qe=this.Qe,t.vn=this.vn,t.Pi=this.Pi,t.pe=this.pe,t.Yp=this.Yp,t.Hd=this.Hd,this.K!==null&&(t.K=this.K.copy()),this.tt!==null&&(this.tt.me?t.tt=this.tt:t.tt=this.tt.copy()),t.Yl=this.Yl,t.uo=this.uo,t.Fn=this.Fn,t.Ui=this.Ui,t.we=this.we,t.Rn=this.Rn}Rs(){return this.tt===null?this.tt=new Ui:this.tt.me&&(this.tt=this.tt.copy()),this.tt}xa(){super.xa(),this.tt!==null&&(this.tt.me=!0)}HI(t){this.n=t.n|2048|4096,this.Zt=t.opacity,this.Nt=t.background,this.cs=t.desiredSize.C(),this.minSize=t.minSize.C(),this.maxSize=t.maxSize.C(),t.Me!==null?this.Me=t.Me.copy():this.Me=null,this.et=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.sl=t.margin.C(),this.de=t.alignment.C(),this.xd=t.alignmentFocus.C(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.C(),this.segmentOrientation=t.segmentOrientation,t.he!==null&&(this.he=t.he.copy()),this.shadowVisible=t.shadowVisible,this.ue=t.ue,this.Qe=t.Qe,this.vn=t.vn,this.K!==null&&(this.K=t.K.copy()),t.tt!==null&&(t.tt.me?this.tt=t.tt:this.tt=t.tt.copy()),this.Yl=t.Yl}YI(t){if(this.ue=t.text||"",this.Xt=t.labelAngle||0,this.Pi=t.lineCount||0,this.lE(t.lines),t.naturalBounds&&(this.Ke=t.naturalBounds),t.actualBounds){let e=t.actualBounds;this.Ut(e.x,e.y,e.width,e.height)}}fe(t){t in Ki?this.wrap=t:super.fe(t)}toString(){return this.ue.length>22?'TextBlock("'+this.ue.substring(0,20)+'"...)':'TextBlock("'+this.ue+'")'}static getEllipsis(){return lt.q0}static setEllipsis(t){lt.q0=t,lt.Z1=new yt,lt.iN=0}static getBaseline(){return lt.Q1}static setBaseline(t){lt.Q1=t}static Q1=null;static getUnderline(){return lt._1}static setUnderline(t){lt._1=t}static _1=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;f(){super.f(),this.Zi(!0)}get font(){return this.vn}set font(t){let e=this.vn;e!==t&&(this.vn=t,this.uo=null,this.f(),this.t("font",e,t))}static isValidFont(t){return K.CSS?K.CSS.supports("font",t):!0}get text(){return this.ue}set text(t){let e=this.ue;t!=null?t=t.toString():t="",e!==t&&(this.ue=t,this.f(),this.t("text",e,t))}get textAlign(){return this.tt!==null?this.tt.j0:"start"}set textAlign(t){let e=this.textAlign;e!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Rs().j0=t,this.N(),this.t("textAlign",e,t))}get flip(){return this.tt!==null?this.tt.go:0}set flip(t){let e=this.flip;e!==t&&(this.Rs().go=t,this.N(),this.t("flip",e,t))}get verticalAlignment(){return this.tt!==null?this.tt.hl:T.Top}set verticalAlignment(t){let e=this.verticalAlignment;e.equals(t)||(t=t.C(),this.Rs().hl=t,this.Pf(),this.t("verticalAlignment",e,t))}get naturalBounds(){if(!this.Ke.isReal()){let t=nt.l();this.sN(this.ue,999999,t);let e=t.width;nt.i(t);let i=this.CD(e),s=this.desiredSize;isNaN(s.width)||(e=s.width),isNaN(s.height)||(i=s.height),this.Ke.Kn(e,i)}return this.Ke}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){let e=(this.n&2097152)!==0;e!==t&&(this.n=this.n^2097152,this.f(),this.t("isMultiline",e,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){let e=(this.n&4194304)!==0;e!==t&&(this.n=this.n^4194304,this.Zi(!0),this.N(),this.t("isUnderline",e,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){let e=(this.n&8388608)!==0;e!==t&&(this.n=this.n^8388608,this.Zi(!0),this.N(),this.t("isStrikethrough",e,t))}get wrap(){return this.tt!==null?this.tt.W0:2}set wrap(t){let e=this.wrap;e!==t&&(this.Rs().W0=t,this.f(),this.t("wrap",e,t))}get overflow(){return this.tt!==null?this.tt.J0:0}set overflow(t){let e=this.overflow;e!==t&&(this.Rs().J0=t,this.f(),this.t("overflow",e,t))}get isOverflowed(){return(this.n&16777216)!==0}nN(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Qe}set stroke(t){let e=this.Qe;e!==t&&(t!==null&&R.Cd(t,"TextBlock.stroke"),t instanceof R&&t.k(),this.Qe=t,typeof t!="string"&&this.xf(),this.N(),this.t("stroke",e,t))}get lineCount(){return this.Pi}get lineHeight(){return this.$0()}get editable(){return(this.n&1048576)!==0}set editable(t){let e=(this.n&1048576)!==0;e!==t&&(this.n=this.n^1048576,this.t("editable",e,t))}get HC(){return(this.n&33554432)!==0}set HC(t){this.n=this.n^33554432}get textEditor(){return this.tt!==null?this.tt.Z0:null}set textEditor(t){let e=this.textEditor;e!==t&&(this.Rs().Z0=t,this.t("textEditor",e,t))}get errorFunction(){return this.tt!==null?this.tt.gs:null}set errorFunction(t){let e=this.errorFunction;e!==t&&(t!==null&&m.S(t,lt,"errorFunction"),this.Rs().gs=t,this.t("errorFunction",e,t))}get interval(){return this.K!==null?this.K.Ff:1}set interval(t){let e=this.interval;if(t=Math.round(t),e!==t&&t!==0&&isFinite(t)){this.K===null&&(this.K=new be),this.K.Ff=t,this.f();let i=this.panel;i!==null&&(i.ds=null),this.t("interval",e,t)}}get graduatedStart(){return this.K!==null?this.K.Rf:0}set graduatedStart(t){let e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Rf=t,this.f(),this.t("graduatedStart",e,t))}get graduatedEnd(){return this.K!==null?this.K.Of:1}set graduatedEnd(t){let e=this.graduatedEnd;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Of=t,this.f(),this.t("graduatedEnd",e,t))}get graduatedFunction(){return this.K!==null?this.K.Q0:null}set graduatedFunction(t){let e=this.graduatedFunction;e!==t&&(t!==null&&m.S(t,lt,"graduatedFunction"),this.K===null&&(this.K=new be),this.K.Q0=t,this.f(),this.t("graduatedFunction",e,t))}get graduatedSkip(){return this.K!==null?this.K.If:null}set graduatedSkip(t){let e=this.graduatedSkip;e!==t&&(t!==null&&m.S(t,lt,"graduatedSkip"),this.K===null&&(this.K=new be),this.K.If=t,this.f(),this.t("graduatedSkip",e,t))}Sa(t,e){if(this.Qe===null||this.ue.length===0||this.vn===null)return;let i=this.naturalBounds,s=this.actualBounds,n=i.width,o=i.height,r=this.$0(),a=t.textAlign=this.textAlign,h=e.rd;a==="start"?a=h?"right":"left":a==="end"&&(a=h?"left":"right");let l=this.isUnderline,u=this.isStrikethrough;this.kn(t,this.Qe,!0,!1,i,s),(l||u)&&this.kn(t,this.Qe,!1,!1,i,s);let c=0,d=0,f=n,p=!1;e.Wt===t&&!(e.Wt instanceof ae)&&!this.HC&&e.getRenderingHint("textGreeking")===!0&&r*this.Th*e.scale<3&&(p=!0);let g=this.spacingAbove,y=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();let b=this.Pi,v=(g+r+y)*b;if(o>v){let w=this.verticalAlignment;d=w.y*o-w.y*v+w.offsetY}if(lt.tk&&(t.letterSpacing=this.letterSpacing,t.wordSpacing=this.wordSpacing),b===1&&this.Rn!==null){let w=this.pe;w>f&&(w=f),d+=g,this.ND(this.Rn,t,c,d,f,r,w,p,a,l,u)}else if(this.Ui!==null&&this.we!==null)for(let w=0;w<b;w++){let k=this.Ui[w];k>f&&(k=f),d+=g,this.ND(this.we[w],t,c,d,f,r,k,p,a,l,u),d+=r+y}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}ND(t,e,i,s,n,o,r,a,h,l,u){let c=0;if(a){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);let p=e.globalAlpha;e.globalAlpha=p/2,e.fillRect(i+c,s+o/4,r,o/2),e.globalAlpha=p;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);let d=lt.Q1!==null?lt.Q1(this,o):o*.75;e.fillText(t,i+c,s+d);let f=o/20|0;if(f===0&&(f=1),h==="right"?c-=r:h==="center"&&(c-=r/2),l){let p=lt._1!==null?lt._1(this,o):o*.8;this.LD(i+c,s+p,i+c+r,s+p,f,e),e instanceof ae&&e.lastCreatedElement.classList.add("gojs-td")}if(u){let p=s+o-o/2.2|0;f%2!==0&&(p+=.5),this.LD(i+c,p,i+c+r,p,f,e),e instanceof ae&&e.lastCreatedElement.classList.add("gojs-td")}}LD(t,e,i,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,e),o.lineTo(i,s),o.stroke(),o.endPath()}wf(t,e,i){if(!super.wf(t,e,i))return!1;if(this.kn(t,this.Qe,!0,!1,this.naturalBounds,this.actualBounds),i){if(this.svg.getElementsByTagName("text").length===0)return!0;let s=this.svg.getElementsByClassName("gojs-td");for(let n=0;n<s.length;n++)t.setFillOrStrokeInPlace(s[n],!1)}else this.aE(this.svg,this.we?this.we[0]:this.text,t);return!0}aE(t,e,i){t.innerHTML=e,i.setFillOrStrokeInPlace(t,!0)}Sd(t){return this.lineCount>1||this.isUnderline||this.isStrikethrough?!0:super.Sd(t)}NC(t,e){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",e);else{let i=t.getElementsByTagName("text");for(let s=0;s<i.length;s++)i[s].setAttributeNS(null,"filter",e)}}hE(){this.Fn=0,this.pe=0,this.uo=null,this.Ui=null,this.we=null,this.Rn=null}kd(t,e,i,s){let n=this.Pi;this.Yl=t,this.nN(!1);let o=this.vn;lt.us!==null&&(lt.AD!==o&&(lt.us.font=o,lt.AD=o),lt.tk&&(lt.us.letterSpacing=this.letterSpacing,lt.us.wordSpacing=this.wordSpacing)),this.hE();let r=0,a=0;isNaN(this.desiredSize.width)?(r=this.cE(),r=Math.min(r,t/this.scale)):r=this.desiredSize.width,this.panel!==null&&(r=Math.min(r,this.panel.maxSize.width)),a=this.CD(r),isNaN(this.desiredSize.height)?a=Math.min(a,e/this.scale):a=this.desiredSize.height,this.fE(t,a),(this.wrap===1||isNaN(this.desiredSize.width))&&(r=isNaN(t)?this.pe:Math.min(t,this.pe)),r=Math.max(i,r),a=Math.max(s,a),this.Ke.Kn(r,a),this.ro(0,0,r,a),this.svg!==null&&n!==this.Pi&&this.Zi(!0)}ka(t,e,i,s){this.commonArrange(t,e,i,s)}On(t,e){this.Rn===null?(this.Rn=t,this.pe=e):((this.we===null||this.Ui===null)&&(this.we=[],this.Ui=[],this.we.push(this.Rn),this.Ui.push(this.pe)),this.we.push(t),this.Ui.push(e),this.we.length>this.maxLines&&(this.n|=16777216))}sN(t,e,i){let s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0,a=this.vn,h=this.spacingAbove+this.spacingBelow,l=Math.max(0,this.$0()+h),u=this.overflow===1?this.TD(a):0;if(this.Pi>=this.maxLines){i!==void 0&&i.e(0,l);return}let c=t;if(this.wrap===0){if(this.Fn=1,o=this.getStringWidth(t),u===0||o<=e){this.pe=Math.max(this.pe,o),this.On(t,this.pe),i!==void 0&&i.e(o,l);return}let f=this.qd(c);c=c.substring(f.length);let p=this.qd(c);for(o=this.getStringWidth(f+p),r=0;p.length>0&&o<=e;){f+=p,c=c.substring(p.length),p=this.qd(c),r=o;let g=f+p;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(p=p.trim()),f+=p,e=Math.max(1,e-u);this.getStringWidth(f)>e&&f.length>1;)f=f.substring(0,f.length-1);this.nN(!0),f+=lt.q0,r=this.getStringWidth(f),this.pe=r,this.On(f,r),i!==void 0&&i.e(r,l);return}let d=0;for(c.length===0&&(d=1,this.On(c,0));c.length>0;){let f=this.qd(c);for(c=c.substring(f.length);this.getStringWidth(f)>e;){let y=1;for(o=this.getStringWidth(f.substring(0,y)),r=0;o<=e;)y++,r=o,o=this.getStringWidth(f.substring(0,y));let b=0;y===1?(b=o,n=Math.max(n,o)):(b=r,n=Math.max(n,r)),y--,y<1&&(y=1);let v=f.substring(0,y);if(this.On(v,b),d++,f=f.substring(y),this.Pi+d>this.maxLines)break}let p=this.qd(c);for(o=this.getStringWidth(f+p),r=0;p.length>0&&o<=e;){f+=p,c=c.substring(p.length),p=this.qd(c),r=o;let y=f+p;s&&(y=y.trim()),o=this.getStringWidth(y)}if(s&&(f=f.trim()),f==="")continue;f[f.length-1]==="\xAD"&&(f=f.substring(0,f.length-1)+"\u2010");let g=0;if(p.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(f),g=r,n=Math.max(n,r)),this.On(f,g),d++,this.Pi+d>this.maxLines)break}this.Fn=Math.min(this.maxLines-this.Pi,d),this.pe=Math.max(this.pe,n),i!==void 0&&i.e(this.pe,l*this.Fn)}fE(t,e){if(this.pe===0||this.Ui===null||this.we===null||this.overflow!==1)return;let i=this.vn,s=this.overflow===1?this.TD(i):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.$0()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(e/o+.01)-1,0));if(r+1>=this.we.length)return;this.nN(!0);let a=this.we[r],h=Math.max(1,t-s);for(;this.getStringWidth(a)>h&&a.length>1;)a=a.substring(0,a.length-1);a+=lt.q0;let l=this.getStringWidth(a);this.we[r]=a,this.we=this.we.slice(0,r+1),this.Ui[r]=l,this.Ui=this.Ui.slice(0,r+1),this.Fn=this.we.length,this.pe=Math.max(this.pe,l),this.Pi=this.Fn,this.Pi===1&&(this.Rn=this.we[0])}qd(t){if(this.wrap===3)return t.substring(0,1);let e=t.length,i=0,s=lt.uE;for(;i<e&&!s.test(t.charAt(i));)i++;for(this.formatting===1&&(e=Math.min(e,i+1));i<e&&s.test(t.charAt(i));)i++;return i>=t.length?t:t.substring(0,i)}getStringWidth(t){return lt.us===null?t.length*8:lt.us.measureText(t).width}$0(){if(this.uo!==null)return this.uo;let t=this.vn,e=0;if(lt.us===null)return e=16,this.uo=e,e;if(lt.oN[t]!==void 0&<.DD<5e3)e=lt.oN[t];else{lt.us.letterSpacing="0px";let i=lt.us.measureText("M");lt.us.letterSpacing=this.letterSpacing,e=i.width*1.3,lt.oN[t]=e,lt.DD++}return this.uo=e,e}TD(t){if(lt.us===null)return 6;let e=0;return lt.Z1[t]!==void 0&<.iN<5e3?e=lt.Z1[t]:(e=lt.us.measureText(lt.q0).width,lt.Z1[t]=e,lt.iN++),e}ek(t,e){return t.indexOf(`
|
|
7
|
+
`+n.toString(t-1)}return i}static $A(t){Y.Wb=t}static Fm(){return Y.Wb}static fromDiv(t){let e=t;if(typeof t=="string"&&(e=K.document.getElementById(t)),e instanceof HTMLDivElement){let i=Y.Ji.get(e);if(i)return i}return null}get div(){return this.Mt}set div(t){if(t!==null&&m.se(t,HTMLDivElement,Y,"div"),this.Mt!==t){let e=this.Mt;if(e!==null){if(Y.Ji.delete(e),e.goDiagram=void 0,e.go=void 0,e.innerHTML="",this.lt!==null){let s=this.lt.bt;this.Ae(s,"pointermove",this.wh,!1),this.Ae(s,"pointerdown",this.ha,!1),this.Ae(s,"pointerup",this.xh,!1),this.Ae(s,"pointerout",this.bh,!1),this.Ae(s,"pointercancel",this.kh,!1),this.lt.dispose()}this.sf&&(this.sf.disconnect(),this.sf=null);let i=this.toolManager;i!==null&&(i.mouseDownTools.each(s=>s.cancelWaitAfter()),i.mouseMoveTools.each(s=>s.cancelWaitAfter()),i.mouseUpTools.each(s=>s.cancelWaitAfter())),i.cancelWaitAfter(),this.currentTool.doCancel(),this.lt=null,this.Ae(K,"resize",this.jb,!1),this.Ae(K,"wheel",this.yh,!0),Y.Fm()===this&&Y.$A(null)}else this.ha===null&&(this.io=!1);if(this.Mt=null,t!==null){let i=Y.Ji.get(t);i&&(i.div=null),this.g2(t),this.Eu(),this.themeManager&&this.themeManager.eO()}else this.themeManager&&this.themeManager.iO()}}setupRouters(){this.rf.push(new _n)}g2(t){let e=this;if(!Y.isUsingDOM())return;t==null&&m.o("Diagram setup requires an argument DIV."),e.Mt!==null&&m.o("Diagram has already completed setup."),typeof t=="string"?e.Mt=K.document.getElementById(t):t instanceof HTMLDivElement?e.Mt=t:m.o("No DIV or DIV id supplied: "+t),e.Mt===null&&m.o("Invalid DIV id; could not get element with id: "+t);let i=Y.Ji.get(e.Mt);if(i&&i!==this&&m.o("Invalid div id; div already has a Diagram associated with it."),!e.sf&&K.ResizeObserver){let u=K.ResizeObserver,c=m.PP(()=>e.requestUpdate(),250,!1);e.sf=new u(()=>c()),e.sf.observe(e.Mt)}K.getComputedStyle(e.Mt,null).position==="static"&&(e.Mt.style.position="relative");let s=5,n="rgba(2"+s+"5, 255, 255, 0)";s--,e.Mt.style["-webkit-tap-highlight-color"]=n,e.Mt.innerHTML="",Y.Ji.set(e.Mt,e),e.Mt.goDiagram=e,e.Mt.go=K.go;let o=new De(e);o.style!==void 0&&(o.style.position="absolute",o.style.top="0px",o.style.left="0px",K.getComputedStyle(e.Mt,null).getPropertyValue("direction")==="rtl"&&(e.rd=!0),o.style.zIndex="2",o.style.userSelect="none",o.style.MozUserSelect="none",o.style.touchAction="none",o.style.letterSpacing="normal !important",o.style.wordSpacing="normal !important",o.style.lang="unknown"),o.bt.setAttribute("role","application"),e.lt=o,e.Wt=o._t;let r=e.Wt;e.$e=e.computePixelRatio(),e.viewSize.isReal()||(e.wt=e.Mt.clientWidth||1,e.xt=e.Mt.clientHeight||1),e.oT(e.wt,e.xt);let a=e;e.Mt.insertBefore(o.bt,e.Mt.firstChild);let h=new De(null);if(h.width=1,h.height=1,e.KR=h,e.HR=h._t,Y.isUsingDOM()){let u=m.Ci("div"),c=m.Ci("div");u.style.position="absolute",u.style.overflow="auto",u.style.width=e.wt+"px",u.style.height=e.xt+"px",u.style.zIndex="1",c.style.position="absolute",c.style.width="1px",c.style.height="1px",e.Mt.appendChild(u),u.appendChild(c),u.onscroll=Y.sO,u.addEventListener("pointerdown",Y.nO),u.a=e,u.oO=!0,u.rO=!0,e.Hb=u,e.qb=c}e.Eu=m.PP(()=>{e.El=null,e.N()},300,!1),e.jb=m.PP(()=>{e.PM()},250,!1),e.nh=u=>(u.preventDefault(),!1),e.yh=u=>{if(!a.isEnabled)return;let c=a.lf(u,!0);c.bubbles=!0;let d=0,f=0;c.delta=0,u.deltaX!==void 0?(u.deltaX!==0&&(d=u.deltaX>0?1:-1),u.deltaY!==0&&(f=u.deltaY>0?1:-1),c.delta=Math.abs(u.deltaX)>Math.abs(u.deltaY)?-d:-f):u.wheelDeltaX!==void 0?(u.wheelDeltaX!==0&&(d=u.wheelDeltaX>0?-1:1),u.wheelDeltaY!==0&&(f=u.wheelDeltaY>0?-1:1),c.delta=Math.abs(u.wheelDeltaX)>Math.abs(u.wheelDeltaY)?-d:-f):u.wheelDelta!==void 0&&u.wheelDelta!==0&&(c.delta=u.wheelDelta>0?1:-1),a.doMouseWheel(),a.Ph(c,u)},e.WA=u=>{if(!a.isEnabled)return;e.nf=!1,a.lf(u,!0);let c=a.currentTool;c.cancelWaitAfter(),c.standardMouseOver()},e.ha=u=>{if(!a.isEnabled)return;e.nf=!0;let c=a.Kb;c[u.pointerId]===void 0&&(c[u.pointerId]=u);let d=a.ph,f=!1;if(d[0]!==null&&(d[0].pointerId===u.pointerId||d[0].pointerType!==u.pointerType))d[0]=u;else if(d[1]!==null&&d[1].pointerId===u.pointerId)d[1]=u,f=!0;else if(d[0]===null)d[0]=u;else if(d[1]===null)d[1]=u,f=!0;else{u.preventDefault();return}let p=u.pointerType==="touch"||u.pointerType==="pen";p&&(a.xx=!1,a.fp=!0);let g=a.lO(u,u,f),y=a.o2,b=p?25:10;if(u.timeStamp-a.s2<a.jA&&!(Math.abs(y.x-u.screenX)>b||Math.abs(y.y-u.screenY)>b)?a.cp++:a.cp=1,g.clickCount=a.cp,a.s2=u.timeStamp,a.o2.setTo(u.screenX,u.screenY),a.doMouseDown(),u.button===1){u.preventDefault();return}a.Ph(g,u)},e.wh=u=>{if(!a.isEnabled)return;e.nf=!0;let c=a.ph;if(c[0]!==null&&(c[0].pointerId===u.pointerId||c[0].pointerType!==u.pointerType))c[0]=u;else if(c[1]!==null&&c[1].pointerId===u.pointerId){c[1]=u;return}else if(c[0]===null)c[0]=u;else return;if(c[0].pointerId!==u.pointerId)return;let d=a.aO(u,u,c[1]!==null);a.doMouseMove(),a.Ph(d,u)},e.xh=u=>{if(!a.isEnabled)return;e.nf=!0;let c=u.pointerType==="touch"||u.pointerType==="pen",d=a.Kb;if(c&&a.xx){delete d[u.pointerId],u.preventDefault();return}let f=a.ph;if(f[0]!==null&&(f[0].pointerId===u.pointerId||f[0].pointerType!==u.pointerType))f[0]=null;else if(f[1]!==null&&f[1].pointerId===u.pointerId){f[1]=null;return}else return;let p=a.m2(u,!1,!0,!1,!0,!1),g=K.document.elementFromPoint(u.clientX,u.clientY)||null;g!==null&&g.shadowRoot&&(g=g.shadowRoot.elementFromPoint(u.clientX,u.clientY)||null),g!==null&&g.a instanceof Y&&g.a!==a&&g.a.bp(u,p),g===null&&(g=u.target),a.bp(u,p),p.clickCount=a.cp,p.targetDiagram=a.t1(u,g),p.targetObject=null,a.doMouseUp(),a.Ph(p,u),c&&(a.fp=!1)},e.bh=u=>{if(!a.isEnabled)return;e.nf=!1;let c=a.Kb;c[u.pointerId]&&delete c[u.pointerId];let d=a.ph;if(d[0]!==null&&d[0].pointerId===u.pointerId&&(d[0]=null),d[1]!==null&&d[1].pointerId===u.pointerId&&(d[1]=null),u.pointerType==="touch"||u.pointerType==="pen")return;let f=a.currentTool;f.cancelWaitAfter(),f.standardMouseOver()},e.kh=u=>{let c=a.ph;c[0]!==null&&c[0].pointerId===u.pointerId?(c[0]=null,a.fp=!1):c[1]!==null&&c[1].pointerId===u.pointerId&&(c[1]=null)};let l=r;if(e.hp=l.F[m.We("7eba17a4ca3b1a8346")][m.We("78a118b7")](l.F,Y.Sh,s,s),r.clearContextCache(!0),e.hO(),this.tf==="svg"){let u=this.zo.get("svg");this.Mt&&this.Mt.appendChild(u.bt),this.Wt=u._t}}addEventListener(t,e,i,s){t.addEventListener(e,i,{capture:s,passive:!1})}Et(t,e,i,s){t.addEventListener(e,i,{capture:s,passive:!1})}removeEventListener(t,e,i,s){t.removeEventListener(e,i,{capture:s})}Ae(t,e,i,s){t.removeEventListener(e,i,{capture:s})}hO(){let t=this,e=this.lt.bt;e instanceof HTMLCanvasElement||(e=t.div),this.Et(e,"pointerdown",t.ha,!1),this.Et(e,"pointermove",t.wh,!1),this.Et(e,"pointerup",t.xh,!1),this.Et(e,"pointerout",t.bh,!1),this.Et(e,"pointercancel",t.kh,!1),this.Et(e,"pointerenter",t.cO,!1),this.Et(e,"pointerleave",t.fO,!1),this.Et(e,"wheel",t.yh,!1),this.Et(e,"keydown",t.uO,!1),this.Et(e,"keyup",t.dO,!1),this.Et(e,"blur",t.gO,!1),this.Et(e,"focus",t.mO,!1),this.Et(e,"selectstart",i=>(i.preventDefault(),!1),!1),this.Et(e,"contextmenu",i=>(i.preventDefault(),!1),!1),this.Et(K,"resize",t.jb,!1)}Px(){this.dp>30&&(this.El=1)}gS(t){this.El!==null&&(this.El=null,t&&this.Eu(),this.dp=0,this.h2=[0,0,0,0,0],this.gp=0)}computePixelRatio(){return this.El!==null?this.El:K.devicePixelRatio||1}get avgSpf(){return this.dp}doMouseDown(){this.currentTool.doMouseDown()}doMouseMove(){this.currentTool.doMouseMove()}doMouseUp(){this.currentTool.doMouseUp()}doMouseWheel(){this.currentTool.doMouseWheel()}doKeyDown(){let t=this.commandHandler;if(!this.toggleKeyboardControl()){if((t.isFocusEnabled||t.isVirtualPointerEnabled)&&t.doVirtualFocusKeyDown()){let e=this.lastInput;e.bubbles=!1;let i=e.event;i&&(i.stopPropagation&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault());return}this.currentTool.doKeyDown()}}toggleKeyboardControl(){let t=this.lastInput,e=t.commandKey;if((t.control||t.meta)&&t.alt&&(e==="Enter"||e==="NumpadEnter")){let i=this.commandHandler,s=i.isFocusEnabled||i.isVirtualPointerEnabled;return i.isFocusEnabled=!s,i.isVirtualPointerEnabled=!s,i.focus=i.findFirstFocus(),this.T("FocusOrVirtualPointerEnabledChanged"),!0}return!1}doKeyUp(){let t=this.commandHandler;if((t.isFocusEnabled||t.isVirtualPointerEnabled)&&t.doVirtualFocusKeyUp()){let e=this.lastInput;e.bubbles=!1;let i=e.event;i&&(i.stopPropagation&&i.stopPropagation(),i.cancelable!==!1&&i.preventDefault());return}this.currentTool.doKeyUp()}ad(t,e){if(e)for(let i in e)i!=="sourceDiagram"&&(t[i]=e[i])}emitMouseDown(t,e,i,s){if(typeof t!="number"||typeof e!="number")throw new Error("Robot.mouseDown first two args must be X,Y numbers");i===void 0&&(i=0);let n=this;if(s&&s.sourceDiagram&&(n=s.sourceDiagram),!n.isEnabled)return this;let o=new te;return o.diagram=n,o.documentPoint=new P(t,e),o.viewPoint=n.transformDocToView(o.documentPoint),o.timestamp=i,o.down=!0,this.ad(o,s),n.lastInput=o,n.firstInput=o.copy(),n.doMouseDown(),this}emitMouseMove(t,e,i,s){if(typeof t!="number"||typeof e!="number")throw new Error("Robot.mouseMove first two args must be X,Y numbers");i===void 0&&(i=0);let n=this;if(s&&s.sourceDiagram&&(n=s.sourceDiagram),!n.isEnabled)return this;let o=new te;return o.diagram=n,o.documentPoint=new P(t,e),o.viewPoint=n.transformDocToView(o.documentPoint),o.timestamp=i,this.ad(o,s),n.lastInput=o,n.doMouseMove(),this}emitMouseUp(t,e,i,s){if(typeof t!="number"||typeof e!="number")throw new Error("Robot.mouseUp first two args must be X,Y numbers");i===void 0&&(i=0);let n=this;if(s&&s.sourceDiagram&&(n=s.sourceDiagram),!n.isEnabled)return this;let o=new te;return o.diagram=n,o.documentPoint=new P(t,e),o.viewPoint=n.transformDocToView(o.documentPoint),o.timestamp=i,o.up=!0,n.firstInput.documentPoint.equals(o.documentPoint)&&(o.clickCount=1),this.ad(o,s),n.lastInput=o,n.doMouseUp(),this}emitMouseWheel(t,e,i){if(typeof t!="number")throw new Error("Robot.mouseWheel first arg must be DELTA number");e===void 0&&(e=0);let s=this;if(!s.isEnabled)return this;let n=new te;return n.diagram=s,n.documentPoint=s.lastInput.documentPoint,n.viewPoint=s.lastInput.viewPoint,n.delta=t,n.timestamp=e,this.ad(n,i),s.lastInput=n,s.doMouseWheel(),this}emitKeyDown(t,e,i){if(typeof t!="string"&&typeof t!="number")throw new Error("Robot.keyDown first arg must be a string or a number");e===void 0&&(e=0);let s=this;if(!s.isEnabled)return this;let n=new te;return n.diagram=s,n.documentPoint=s.lastInput.documentPoint,n.viewPoint=s.lastInput.viewPoint,typeof t=="string"?n.key=t:typeof t=="number"&&(n.key=String.fromCharCode(t)),n.timestamp=e,n.down=!0,this.ad(n,i),s.lastInput=n,s.doKeyDown(),this}emitKeyUp(t,e,i){if(typeof t!="string"&&typeof t!="number")throw new Error("Robot.keyUp first arg must be a string or a number");e===void 0&&(e=0);let s=this;if(!s.isEnabled)return this;let n=new te;return n.diagram=s,n.documentPoint=s.lastInput.documentPoint,n.viewPoint=s.lastInput.viewPoint,typeof t=="string"?n.key=t:typeof t=="number"&&(n.key=String.fromCharCode(t)),n.timestamp=e,n.up=!0,this.ad(n,i),s.lastInput=n,s.doKeyUp(),this}doFocus(){this.focus()}focus(){if(this.lt)if(this.scrollsPageOnFocus)this.lt.focus();else{let t=K.scrollX,e=K.scrollY;this.lt.focus(),K.scrollTo(t,e)}}mO(t){let e=Y.Ji.get(this);e&&e.T("GainedFocus")}gO(t){let e=Y.Ji.get(this);e&&e.T("LostFocus")}PM(){if(this.lt===null)return;let t=this.Mt;if(t===null||t.clientWidth===0||t.clientHeight===0)return;this.UM||this.setScrollWidth();let e=this.eo?this.jt:0,i=this.Pn?this.jt:0,s=this.$e;if(this.$e=this.computePixelRatio(),this.$e!==s&&(this.$u=!0,this.requestUpdate()),t.clientWidth!==this.wt+e||t.clientHeight!==this.xt+i){this.Mh(),this.Wi=!0;let n=this.layout;n!==null&&n.isViewportSized&&this.autoScale===1&&(this.Zc=!0,n.p()),this.As||this.requestUpdate()}}QA(){let t=0,e=new Et;e.name="Grid",e.allowSelect=!1,e.pickable=!1,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="ViewportBackground",e.isViewportAligned=!0,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="Background",this.Zr(e,t++),e=new Et,e.name="",this.Zr(e,t++),e=new Et,e.name="Foreground",this.Zr(e,t++),e=new Et,e.name="ViewportForeground",e.isViewportAligned=!0,e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="Adornment",e.isTemporary=!0,e.isInDocumentBounds=!1,this.Zr(e,t++),e=new Et,e.name="Tool",e.isTemporary=!0,e.isInDocumentBounds=!0,this.Zr(e,t++)}rT(){let t=new G(G.Grid,{name:"GRID"}).add(new it("LineH",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new it("LineV",{stroke:"lightgray",strokeWidth:.5,interval:1}).theme("stroke","gridMinor"),new it("LineH",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new it("LineV",{stroke:"gray",strokeWidth:.5,interval:5}).theme("stroke","gridMajor"),new it("LineH",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor"),new it("LineV",{stroke:"gray",strokeWidth:1,interval:10}).theme("stroke","gridMajor")),e=new pt({layerName:"Grid",zOrder:0,isInDocumentBounds:!1,isAnimated:!1,pickable:!1,locationObjectName:"GRID"}).add(t);return this.add(e),this.partManager.parts.delete(e),t.visible=!1,t}static sO(){let t=Y.Ji.get(this.parentElement||this);if(t){if(t.Eb){t.Eb=!1;return}if(!t.isEnabled){t.lT();return}t.diagramScroll(this)}}static nO(t){if(!this.a.isEnabled){this.a.updateScroll();return}this.a.Ub=t.target.scrollTop,this.a.Vb=t.target.scrollLeft}diagramScroll(t){if(this.lt===null)return;let e=this.Hb,i=this.qb;this.ip=!0;let s=this.documentBounds,n=this.viewportBounds,o=this.ch,r=s.x-o.left,a=s.y-o.top,h=s.width+o.left+o.right,l=s.height+o.top+o.bottom,u=s.right+o.right,c=s.bottom+o.bottom,d=n.x,f=n.y,p=n.width,g=n.height,y=n.right,b=n.bottom,v=this.scale,w,k=t.scrollLeft;if(this.rd)switch(this.nb){case"negative":k=k+t.scrollWidth-t.clientWidth;break;case"reverse":k=t.scrollWidth-k-t.clientWidth;break}let S=k;if(p<h||g<l){w=P.z(this.position.x,this.position.y),this.allowHorizontalScroll&&this.Vb!==S&&(w.x=S/v+r,this.Vb=S),this.allowVerticalScroll&&this.Ub!==t.scrollTop&&(w.y=t.scrollTop/v+a,this.Ub=t.scrollTop),this.position=w,P.i(w),this.ip=!1,this.td=!1;return}if(w=P.l(),t.oO&&this.allowHorizontalScroll&&(r<d&&(this.position=w.e(S+r,this.position.y)),u>y)){let N=e.scrollWidth-this.wt;this.position=w.e(-N+S-this.wt/v+u,this.position.y)}if(t.rO&&this.allowVerticalScroll&&(a<f&&(this.position=w.e(this.position.x,t.scrollTop+a)),c>b)){let N=e.scrollHeight-this.xt;this.position=w.e(this.position.x,-N+t.scrollTop-this.xt/v+c)}P.i(w),this.Qr(),this.ip=!1,this.td=!1,s=this.documentBounds,n=this.viewportBounds,u=s.right,y=n.right,c=s.bottom,b=n.bottom,r=s.x,d=n.x,a=s.y,f=n.y,p>=h&&r>=d&&u<=y&&(i.style.width="1px"),g>=l&&a>=f&&c<=b&&(i.style.height="1px")}computeBounds(t){return t===void 0&&(t=new I),this.De(),this.aT(t)}aT(t){if(this.fixedBounds.isReal())return t.h(this.fixedBounds),t.addMargin(this.Qt),t;let e=!0,i=this.Vt.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];if(!o.visible||!o.isInDocumentBounds)continue;let r=o.Ct.r,a=r.length;for(let h=0;h<a;h++){let l=r[h];if(!l.isInDocumentBounds||!l.isVisible())continue;let u=l.actualBounds;u.isReal()&&(e?(e=!1,t.h(u)):t.unionRect(u))}}return e&&t.e(0,0,0,0),t.addMargin(this.Qt),t}computePartsBounds(t,e){e===void 0&&(e=!1);let i;if(Array.isArray(t))for(let s=0;s<t.length;s++){let n=t[s];!e&&n instanceof j||(n.ensureBounds(),i===void 0?i=n.actualBounds.copy():i.unionRect(n.actualBounds))}else{let s=t.iterator;for(;s.next();){let n=s.value;!e&&n instanceof j||(n.ensureBounds(),i===void 0?i=n.actualBounds.copy():i.unionRect(n.actualBounds))}}return i===void 0?new I(NaN,NaN,0,0):i}$s(t){if(!t&&!this.io||this.Ht||this.lt===null||!this.documentBounds.isReal())return;if(this.Ht=!0,t){let c=this.initialPosition;if(c.isReal()){this.Ht=!1,this.position=c;return}let d=this.initialDocumentSpot,f=this.initialViewportSpot;d.isNoSpot()&&(d=T.TopLeft),f.isNoSpot()&&(f=T.TopLeft);let p=P.l();p.setRectSpot(this.documentBounds,d);let g=this.viewportBounds,y=I.z(0,0,g.width,g.height),b=P.l();b.setRectSpot(y,f),b.e(p.x-b.x,p.y-b.y),this.Ht=!1,this.position=b,I.i(y),P.i(b)}let e=this.na;t&&this.Rr!==1&&(e=this.Rr);let i=e!==1?this.hd(e):this.scale,s=this.ct.x,n=this.ct.y,o=this.wt/i,r=this.xt/i,a=this.Jc,h=this.Qm;if(t&&!a.isSpot()&&(h.isSpot()||h.isDefault())){let c=this.initialDocumentSpot.isSpot()&&this.initialViewportSpot.isSpot();a=h.isDefault()&&!c?T.Center:h}this.p2(this.documentBounds,o,r,a,t);let l=this.scale;this.scale=i,this.Ht=!1;let u=this.viewportBounds;u.equalsApproxTo(s,n,o,r)||this.onViewportBoundsChanged(new I(s,n,o,r),u,l,!1)}hd(t){let e=this.ap;if(this.lt===null)return e;if(t===1)return this.scale;this.ensureBounds();let i=this.documentBounds;if(!i.isReal())return e;let s=i.width,n=i.height,o=this.wt+(this.eo?this.jt:0),r=this.xt+(this.Pn?this.jt:0),a=o/s,h=r/n,l=this.ch,u=l.left+l.right!==0,c=l.top+l.bottom!==0;(u||c)&&(h===a?(h=(r-this.jt)/n,a=(o-this.jt)/s):h>a?h=(r-this.jt)/n:a=(o-this.jt)/s);let d=0;return t===2?d=Math.min(h,a):t===3&&(h>a?d=(r-this.jt)/n:d=(o-this.jt)/s),d>e&&(d=e),d<this.minScale&&(d=this.minScale),d>this.maxScale&&(d=this.maxScale),d}zoomToFit(){let t=this.lh;this.lh=1,this.scale=this.hd(2),this.alignDocument(T.Center,T.Center),t!==1&&(this.$s(!1),this.p2(this.documentBounds,this.wt/this.et,this.xt/this.et,this.Jc,!1)),this.lh=t}zoomToRect(t,e){e===void 0&&(e=2);let i=t.width,s=t.height;if(i===0||s===0||isNaN(i)&&isNaN(s))return;let n=1;if(e===2||e===3)if(isNaN(i))n=this.viewportBounds.height*this.scale/s;else if(isNaN(s))n=this.viewportBounds.width*this.scale/i;else{let o=this.wt,r=this.xt;e===3?r/s>o/i?n=(r-(this.Pn?this.jt:0))/s:n=(o-(this.eo?this.jt:0))/i:n=Math.min(r/s,o/i)}this.scale=n,this.position=new P(t.x,t.y)}get pO(){return this.Ht}set pO(t){this.Ht=t}alignDocument(t,e){this.ensureBounds();let i=this.documentBounds,s=this.viewportBounds;this.position=new P(i.x+(t.x*i.width+t.offsetX)-(e.x*s.width-e.offsetX),i.y+(t.y*i.height+t.offsetY)-(e.y*s.height-e.offsetY))}focusObject(t){if(t instanceof J){this.mp=t;let e=P.l();this.pp=this.transformDocToView(t.getDocumentPoint(T.TopLeft,e)),P.i(e)}else this.mp=null,this.pp=P.mn}p2(t,e,i,s,n){let o=P.z(this.ct.x,this.ct.y),r=o.x,a=o.y;if(this.mp!==null){let h=P.l();h=this.mp.getDocumentPoint(T.TopLeft,h),r=h.x-this.pp.x/this.scale,a=h.y-this.pp.y/this.scale,s=T.None,P.i(h)}if(n||this.scrollMode===1){s.isSpot()&&(e>t.width&&(r=t.x+(s.x*t.width+s.offsetX)-(s.x*e-s.offsetX)),i>t.height&&(a=t.y+(s.y*t.height+s.offsetY)-(s.y*i-s.offsetY)));let h=this.ch,l=e-t.width;if(e<t.width+h.left+h.right){let c=r+e/2;c=Math.min(c,t.right+Math.max(l,h.right)-e/2),c=Math.max(c,t.left-Math.max(l,h.left)+e/2),r=c-e/2}else r>t.left?r=t.left:r<t.right-e&&(r=t.right-e);let u=i-t.height;if(i<t.height+h.top+h.bottom){let c=a+i/2;c=Math.min(c,t.bottom+Math.max(u,h.bottom)-i/2),c=Math.max(c,t.top-Math.max(u,h.top)+i/2),a=c-i/2}else a>t.top?a=t.top:a<t.bottom-i&&(a=t.bottom-i)}if(o.x=isFinite(r)?r:-this.Qt.left,o.y=isFinite(a)?a:-this.Qt.top,this.positionComputation!==null){let h=this.positionComputation(this,o);o.x=h.x,o.y=h.y}this.Cs.IA(this.ct,o),this.ct.e(o.x,o.y),this.kp(),this.ca(),this.yO(),P.i(o)}findPartAt(t,e){if(e===void 0&&(e=!0),e){let i=this.wS(t,s=>s.part,s=>s.canSelect());if(i instanceof pt)return i}else{let i=this.wS(t,s=>s.part);if(i instanceof pt)return i}return null}findObjectAt(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null),this.De();let s=this.Vt.iteratorBackwards;for(;s.next();){let n=s.value;if(!n.visible)continue;let o=n.findObjectAt(t,e,i);if(o!==null)return o}return null}wS(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null),this.De();let s=this.Vt.iteratorBackwards;for(;s.next();){let n=s.value;if(!n.visible||n.isTemporary)continue;let o=n.findObjectAt(t,e,i);if(o!==null)return o}return null}findPartsAt(t,e,i){return e===void 0&&(e=!0),this.wO(t,s=>s.part,e?s=>s instanceof pt&&s.canSelect():null,i)}wO(t,e,i,s){e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof q)&&!(s instanceof V)&&(s=new V),this.De();let n=this.Vt.iteratorBackwards;for(;n.next();){let o=n.value;!o.visible||o.isTemporary||o.findObjectsAt(t,e,i,s)}return s}findObjectsAt(t,e,i,s){e===void 0&&(e=null),i===void 0&&(i=null),!(s instanceof q)&&!(s instanceof V)&&(s=new V),this.De();let n=this.Vt.iteratorBackwards;for(;n.next();){let o=n.value;o.visible&&o.findObjectsAt(t,e,i,s)}return s}findPartsIn(t,e,i,s){return e===void 0&&(e=!1),i===void 0&&(i=!0),this.xO(t,null,n=>n instanceof pt&&(!i||n.canSelect()),e,s)}findObjectsIn(t,e,i,s,n){e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof q)&&!(n instanceof V)&&(n=new V),this.De();let o=this.Vt.iteratorBackwards;for(;o.next();){let r=o.value;r.visible&&r.findObjectsIn(t,e,i,s,n)}return n}kS(t,e,i,s,n,o){let r=new V;this.De();let a=this.Vt.iteratorBackwards;for(;a.next();){let h=a.value;h.visible&&h.kS(t,e,i,s,r,n,o)}return r}xO(t,e,i,s,n){e===void 0&&(e=null),i===void 0&&(i=null),s===void 0&&(s=!1),!(n instanceof q)&&!(n instanceof V)&&(n=new V),this.De();let o=this.Vt.iteratorBackwards;for(;o.next();){let r=o.value;!r.visible||r.isTemporary||r.findObjectsIn(t,e,i,s,n)}return n}findPartsNear(t,e,i,s,n){return i===void 0&&(i=!0),s===void 0&&(s=!0),this.bO(t,e,null,o=>o instanceof pt&&(!s||o.canSelect()),i,n)}findObjectsNear(t,e,i,s,n,o){i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof q||n instanceof V)&&(o=n),n=!0),!(o instanceof q)&&!(o instanceof V)&&(o=new V),this.De();let r=this.Vt.iteratorBackwards;for(;r.next();){let a=r.value;a.visible&&a.findObjectsNear(t,e,i,s,n,o)}return o}bO(t,e,i,s,n,o){i===void 0&&(i=null),s===void 0&&(s=null),n===void 0&&(n=!0),n!==!1&&n!==!0&&((n instanceof q||n instanceof V)&&(o=n),n=!0),!(o instanceof q)&&!(o instanceof V)&&(o=new V),this.De();let r=this.Vt.iteratorBackwards;for(;r.next();){let a=r.value;!a.visible||a.isTemporary||a.findObjectsNear(t,e,i,s,n,o)}return o}acceptEvent(t){return this.lf(t,t instanceof MouseEvent)}lf(t,e){let i=this.Wr;this.Wr=this.dh,this.dh=i,i.diagram=this,i.event=t,e?this.bp(t,i):(i.viewPoint=this.Wr.viewPoint,i.documentPoint=this.Wr.documentPoint);let s=0,n=t;return n.ctrlKey&&(s+=1),n.altKey&&(s+=2),n.shiftKey&&(s+=4),n.metaKey&&(s+=8),i.modifiers=s,i.button=n.button,n.buttons!==void 0&&(i.buttons=n.buttons),m.fr&&n.button===0&&n.ctrlKey&&(i.button=2),i.down=!1,i.up=!1,i.clickCount=1,i.delta=0,i.handled=!1,i.bubbles=!1,i.timestamp=t.timeStamp,i.isMultiTouch=!1,i.targetDiagram=this.t1(t,t.target),i.targetObject=null,i}t1(t,e){if(e===null)return null;let i=Y.Ji.get(e);if(i)return i;let s=t.path;if(!s&&m.it(t.composedPath)&&(s=t.composedPath()),s&&s[0]){let n=Y.Ji.get(s[0]);if(n)return n}return null}lO(t,e,i){let s=this.m2(t,!0,!1,!1,!0,i);return this.bp(e,s),s.targetDiagram=this.t1(t,t.target),s.targetObject=null,i||s.clone(this.lp),s}aO(t,e,i){let s=this.m2(t,!1,!1,!1,!1,i),n=K.document.elementFromPoint(e.clientX,e.clientY)||null;n!==null&&n.shadowRoot&&(n=n.shadowRoot.elementFromPoint(e.clientX,e.clientY)||null);let o=this,r=t;if(n){let a=this.t1(t,n);a&&(r=e,o=a)}return s.targetDiagram=o,this.bp(r,s),s.targetObject=null,s}m2(t,e,i,s,n,o){let r=this.Wr;this.Wr=this.dh,this.dh=r,r.diagram=this,r.clickCount=1,r.delta=0;let a=0;return t.ctrlKey&&(a+=1),t.altKey&&(a+=2),t.shiftKey&&(a+=4),t.metaKey&&(a+=8),r.modifiers=a,r.event=t,r.timestamp=t.timeStamp,r.button=i?this.firstInput.button:t.button,r.buttons=t.buttons,m.fr&&t.button===0&&t.ctrlKey&&(r.button=2),r.down=e,r.up=i,r.handled=s,r.bubbles=n,r.isMultiTouch=o,r}Ph(t,e){return t.bubbles?!0:(e.stopPropagation!==void 0&&e.stopPropagation(),e.cancelable!==!1&&e.preventDefault(),e.cancelBubble=!0,!1)}uO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!1);return i.key=t.key,i.code=t.code,i.down=!0,e.doKeyDown(),e.Ph(i,t)}dO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!1);return i.key=t.key,i.code=t.code,i.up=!0,e.doKeyUp(),e.Ph(i,t)}cO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!0);return e.mouseEnter!==null&&e.mouseEnter(i),e.currentTool.standardMouseOver(),e.Ph(i,t)}fO(t){let e=Y.Ji.get(this);if(!e||!e.isEnabled)return!1;let i=e.lf(t,!0);return e.mouseLeave!==null&&e.mouseLeave(i),e.Ph(i,t)}getMouse(t){let e=this.lt;if(e===null)return new P(0,0);let i=e.getBoundingClientRect(),s=(t.clientX-i.left)*(this.wt/i.width),n=(t.clientY-i.top)*(this.xt/i.height);return new P(s,n).Hi(this.v)}bp(t,e){let i=this.lt,s=0,n=0;if(i!==null){let r=i.getBoundingClientRect();s=(t.clientX-r.left)*(this.wt/r.width),n=(t.clientY-r.top)*(this.xt/r.height)}e.viewPoint.e(s,n);let o=P.z(s,n);this.v.Ni(o),e.documentPoint.h(o),P.i(o)}_L(t,e,i){let s;if(this.ph[0]!==null)s=this.ph[e];else return;let n=this.lt;if(n!==null){let o=n.getBoundingClientRect();i.e((s.clientX-o.left)*(this.wt/o.width),(s.clientY-o.top)*(this.xt/o.height))}}invalidateDocumentBounds(){this.gh||(this.gh=!0,this.requestUpdate(!1))}kO(){this.As||this.De(),this.ensureBounds()}redraw(){this.Ht||this.As||(this.N(),this.maybeUpdate())}isUpdateRequested(){return this.Tr}delayInitialization(t){t===void 0&&(t=null);let e=this.animationManager,i=e.isEnabled;e.stopAnimation(),e.isEnabled=!1,this.Pr(),this.io=!1,this.Yx=new P(NaN,NaN),e.isEnabled=i,this.As=!0;let s=this;t!==null&&m.dn(()=>{s.As=!1,e.Kl("Model"),t(s)},1)}requestUpdate(t){if(t===void 0&&(t=!1),this.Tr===!0||this.Ht||t===!1&&this.As)return;this.Tr=!0;let e=this;K.requestAnimationFrame(()=>{e.Tr&&e.maybeUpdate()})}maybeUpdate(){this.Zu&&!this.Tr||(this.Zu&&(this.Zu=!1),this.Pr())}w2(t,e){!this.td||this.Ht||this.animationManager.defaultAnimation.isAnimating||this.lT()||(t&&this.De(),e&&this.$s(!1))}Pr(t){if(this.As||(this.Tr=!1,this.Mt===null&&!this.ed.isReal()))return;this.As=!0;let e=this.animationManager,i=this.od;if(!e.isAnimating&&i.length!==0){let u=i.r,c=u.length;for(let d=0;d<c;d++){let f=u[d];f.xi(!1),f.f()}i.clear()}let s=this.i2;s.count>0&&(s.each(u=>u.b2()),s.clear());let n=!1,o=!1;e.defaultAnimation.isAnimating&&(o=!0,n=this.skipsUndoManager,this.skipsUndoManager=!0),e.Pe||this.PM(),t||this.w2(!1,!0);let r=!this.undoManager.isUndoingRedoing&&(this.Ol||this.rf.count!==0&&this.Or.size!==0),a=!this.io||this.Jr;this.De(!0);let h=!1;(a||r)&&(this.io?this.k2(!this.Zc,r):(this.startTransaction("Initial Layout"),e.isEnabled===!1&&e.stopAnimation(),this.k2(!1,r)),h=a),this.Zc=!1,this.Ol=!1,this.De(),this.Mb||this.kO(),t||this.w2(!0,!1);let l=!1;if(h){let u=I.l();u.h(this.viewportBounds),this.io||(this.io=!0,l=!0,this.skipsUndoManager||(this.undoManager.yx=!0),this.undoManager.wx=!0,this.PO()),this.SO(),this.De(!1),t||this.w2(!0,!0),I.i(u)}else if(e.zc&&e.Gx){if(this.Rr!==1)this.scale=this.hd(this.Rr);else if(this.na!==1)this.scale=this.hd(this.na);else{let u=this.initialScale;isFinite(u)&&u>0&&(this.scale=u)}this.$s(!0)}h&&l&&this.commitTransaction("Initial Layout"),this.ls!==null&&(this.ls.visible&&!this._c&&(this.P2(),this._c=!0),!this.ls.visible&&this._c&&(this._c=!1)),t||this.Ge(this.Wt),o&&(this.skipsUndoManager=n),this.As=!1}get Za(){return this.io}PO(){if(this.Rr!==1)this.scale=this.hd(this.Rr);else if(this.na!==1)this.scale=this.hd(this.na);else{let e=this.initialScale;isFinite(e)&&e>0&&(this.scale=e)}this.$s(!0);let t=this.Vt.r;this.rs(t,t.length,this,this.viewportBounds),this.T("InitialLayoutCompleted"),this.Yx.h(this.ct),this.cd()}SO(){this.T("LayoutCompleted")}Pp(t){this._n.add(t)}addInvalidRoute(t){this.Uo?this.fh.add(t):this.Or.add(t)}De(t){if(this._n.size!==0&&!(!this.As&&this.animationManager.isTicking)){if(this.As||(this.Ol=!0),t){this.hT(this._n);return}for(let e=0;e<23&&this._n.size!==0;e++){let i=new Set(this._n);this._n.clear(),this.b2(i,this._n)}this.nodes.each(e=>{e instanceof ht&&e.cT(!1)})}}hT(t,e){for(let i of t)!i.Di()||i instanceof ht||(i._r()?(i.ht(1/0,1/0),i.Ut()):e&&e.add(i));for(let i of t)if(i instanceof ht){if(!i.isVisible())continue;this.e1(i)}}b2(t,e){this.hT(t,e);for(let i of t){if(!(i instanceof j))continue;let s=i;s.isVisible()&&(s._r()?(s.ht(1/0,1/0),s.Ut()):e.add(s))}for(let i of t)i instanceof vt&&i.isVisible()&&(i._r()?(i.ht(1/0,1/0),i.Ut()):e.add(i))}fd(t){let e=t instanceof Y,i=e?t.links:t.memberParts,s=this._n;if(e)this.De(!0);else{for(;i.next();){let n=i.value;s.has(n)&&(!n.Di()||n instanceof ht||n._r()&&(n.ht(1/0,1/0),n.Ut()))}for(i.reset();i.next();){let n=i.value;if(s.has(n)&&n instanceof ht){if(!n.isVisible())continue;this.e1(n)}}i.reset()}for(;i.next();){let n=i.value;n instanceof j&&s.has(n)&&n.isVisible()&&n._r()&&(n.ht(1/0,1/0),n.Ut())}}e1(t){let e=m.st(),i=m.st(),s=t.memberParts;for(;s.next();){let o=s.value;o.isVisible()&&(o instanceof ht?(o.Xo()||o.as()||o.fa())&&this.e1(o):o instanceof j?o.fromNode===t||o.toNode===t?i.push(o):e.push(o):(o.ht(1/0,1/0),o.Ut()))}let n=e.length;for(let o=0;o<n;o++){let r=e[o];r.ht(1/0,1/0),r.Ut()}m.Z(e),t.ht(1/0,1/0),t.Ut(),n=i.length;for(let o=0;o<n;o++){let r=i[o];r.ht(1/0,1/0),r.Ut()}m.Z(i)}rs(t,e,i,s){if(!(!this.ef&&!this.animationManager.isAnimating)){for(let n=0;n<e;n++)t[n].rs(i,s);this.De()}}Ge(t){this.Mt!==null&&(this.lt===null&&m.o("No canvas specified"),this.tf==="svg"?this.MO(t):this.CO(t))}CO(t){let e=this.animationManager;if(e.Pe||e.isAnimating&&!e.isTicking)return;let i=new Date;if(this.Sp(),this.Mt&&this.Mt.style.opacity==="0")return;let s=t!==this.Wt,n=this.Vt.r,o=n.length,r=this;if(this.rs(n,o,r,r.viewportBounds),s)t.clearContextCache(!0),this.Qr();else if(!this.Wi&&!e.isAnimating)return;let a=this.v,h=this.$e;t.setTransform(h,0,0,h,0,0),t.clearRect(0,0,this.wt,this.xt),this.Zt!==1&&(t.globalAlpha=this.Zt),this.S2(t);for(let f=0;f<o;f++)t.setTransform(h,0,0,h,0,0),t.transform(a.m11,a.m12,a.m21,a.m22,a.dx,a.dy),t.commitTransform(),n[f].Ge(t,r);let l=!1;this.of?this.of.Sh(this,t)&&(l=this.hp()):l=!0,l&&(Nt.prototype.Ni=Nt.prototype.Mu),s?(this.Wt.clearContextCache(!0),this.Qr()):(this.ef=!1,this.Wi=!1);let u=+new Date-+i,c=!1,d=this.h2;if(c||this.El===null){d[this.gp]=u,this.gp=(this.gp+1)%d.length;let f=0;for(let p=0;p<d.length;p++)f+=d[p];this.dp=f/d.length}if(this.Zt!==1&&(t.globalAlpha=1),c){t.setTransform(1,0,0,1,0,0);for(let f=0;f<d.length;f++)t.fillText(d[f].toString(),20,150+ +(f*20))}}MO(t){if(this.Mt===null)return;let e=this.animationManager;if(e.Pe||e.isAnimating&&!e.isTicking)return;this.Sp();let i=this.wt,s=this.xt;t.surface.resize(i,s,i,s);let n=this.Vt.r,o=n.length,r=this;if(this.rs(n,o,r,r.viewportBounds),!this.Wi&&!e.isAnimating)return;let a=this.v;t.lastDrawnPart=null,t.setDiagramPosScale(a.m11,a.m12,a.m21,a.m22,a.dx,a.dy),this.Zt!==1&&(t.globalAlpha=this.Zt),this.S2(t);let h=this.$e,l=this.lt._t;l.setTransform(h,0,0,h,0,0),l.clearRect(0,0,this.wt,this.xt);for(let c=0;c<o;c++)n[c].Ge(t,r);let u=!1;this.of?this.of.Sh(this,l)&&(u=this.hp()):u=!0,u&&(Nt.prototype.Ni=Nt.prototype.Mu),this.ef=!1,this.Wi=!1}i1(t,e,i,s,n,o,r,a,h){o===void 0&&(o=null),r===void 0&&(r=null),a===void 0&&(a=!1),h===void 0&&(h=!1),this.Sp(),t.clearContextCache(!0),this.Qr(),this.mh=!0;let l=this.et;this.et=s;let u=this,c=this.Vt.r,d=c.length;try{let f=new I(n.x,n.y,i.width/s,i.height/s),p=f.copy();p.addMargin(e),this.P2(p),this.De(),this.rs(c,d,u,f),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,i.width,i.height),r!==null&&r!==""&&(t.fillStyle=r,t.fillBackground(0,0,i.width,i.height));let g=Nt.l();g.Ue(),g.Gs(e.left,e.top),g.et(s),(n.x!==0||n.y!==0)&&g.Gs(-n.x,-n.y),t.setTransform(g.m11,g.m12,g.m21,g.m22,g.dx,g.dy),t.commitTransform(),t instanceof ae&&t.setDiagramPosScale(g.m11,g.m12,g.m21,g.m22,g.dx,g.dy),Nt.i(g),this.S2(t),t.globalAlpha=this.Zt;let y=this.findLayer("Grid");if(o){let b=new V,v=o.iterator;for(v.reset();v.next();){let w=v.value;w instanceof pt&&(!h&&w.layer===y||(w.Wc(),b.add(w)))}for(let w=0;w<d;w++)c[w].ER(t,u,b,a);b.each(w=>w.Wc())}else for(let b=0;b<d;b++){let v=c[b];v===y?h&&v.Ge(t,u,!0):v.Ge(t,u,a)}this.mh=!1,this.of&&this.Wt&&this.of.Sh(this,this.Wt)&&this.hp()}finally{this.et=l,t.clearContextCache(!0),this.Qr(),this.rs(c,d,u,u.viewportBounds),this.cd(),this.Wt instanceof ae&&(this.Wt.diagramGroup.replaceChildren(),this.redraw())}}getRenderingHint(t){return this.Fr[t]}setRenderingHint(t,e){t==="minDrawingLength"&&(this.Jm=e),this.Fr[t]=e,this.redraw()}resetRenderingHints(){this.Fr=new yt,this.Fr.drawShadows=!0,this.Fr.textGreeking=!0,this.Fr.viewportOptimizations=!m.fr,this.Fr.temporaryPixelRatio=!0,this.Fr.pictureRatioOptimization=!0,this.Fr.minDrawingLength=1,this.Jm=1}S2(t){let e=this.Fr;if(e===null)return;if(e.imageSmoothingEnabled!==void 0){let s=!!e.imageSmoothingEnabled;t.setImageSmoothingEnabled(s)}let i=e.defaultFont;i!=null&&(t.font=i)}getInputOption(t){return this.Ju[t]}setInputOption(t,e){this.Ju[t]=e}QR(){this.Ju=new yt,this.Ju.extraTouchArea=10,this.Ju.extraTouchThreshold=10,this.Ju.hasGestureZoom=!0}set(t){return t?(Object.assign(this,t),this):this}attach(t){return this.setProperties(t)}setProperties(t){return Y.Mp(this,t),this}static Mp(t,e){if(!e)return;let i=t instanceof G,s=t instanceof Y;for(let n in e){n===""&&m.o("Setting properties requires non-empty property names");let o=t,r=n;if(i||s){let h=n.indexOf(".");if(h>0){let l=n.substring(0,h);i?o=t.findObject(l):(o=t[l],o==null&&(o=t.toolManager[l])),m.$(o)?r=n.substring(h+1):m.o("Unable to find object named: "+l+" in "+t.toString()+" when trying to set property: "+n)}}if(r[0]!=="_"&&!m.Gw(o,r))if(s&&r==="ModelChanged"){t.addModelChangedListener(e[r]);continue}else if(s&&r==="Changed"){t.addChangedListener(e[r]);continue}else if(s&&m.Gw(t.toolManager,r))o=t.toolManager;else if(s&&t.fT(r)){t.addDiagramListener(r,e[r]);continue}else if(t instanceof dt&&r==="Changed"){t.addChangedListener(e[r]);continue}else m.o('Trying to set undefined property "'+r+'" on object: '+o.toString());let a=e[n];o[r]=a,r[0]==="_"&&o instanceof J&&o.addCopyProperty(r)}}VA(){if(this.aa.count!==0&&!(this.undoManager.transactionLevel>1)){for(;this.aa.count>0;){let t=this.aa;this.aa=new Mt;let e=t.iterator;for(;e.next();){let i=e.key;i.invalidateOtherJumpOvers(e.value),i.ai()}}this.N()}}N(t){if(t===void 0)this.Wi=!0,this.requestUpdate();else{let e=this.viewportBounds;t.isReal()&&e.intersectsRect(t)&&(this.Wi=!0,this.requestUpdate())}this.T("InvalidateDraw")}invalidateViewport(t,e){if(this.Wi!==!0){if(this.Wi=!0,this.tf==="svg"){this.maybeUpdate();return}this.getRenderingHint("temporaryPixelRatio")===!0?(this.Px(),this.maybeUpdate(),this.gS(!0)):this.maybeUpdate()}}Mh(){this.td=!0}Qr(){this.ef=!0}Sp(){this.$u!==!1&&(this.$u=!1,this.oT(this.wt,this.xt))}oT(t,e){this.ca();let i=this.$e,s=t*i,n=e*i;this.lt.resize(s,n,t,e)&&(this.Wi=!0,this.Wt.clearContextCache(!0))}lT(){let t=this.lt;if(t===null||this.ed.isReal())return!0;let e=this.wt,i=this.xt,s=this.Mt,n=!1,o=this.eo?this.jt:0,r=this.Pn?this.jt:0,a=s.clientWidth||e+o,h=s.clientHeight||i+r,l=this.viewportBounds,u=l.x,c=l.y,d=l.width,f=l.height;if((a!==e+o||h!==i+r)&&(this.eo=!1,this.Pn=!1,o=0,r=0,this.wt=a,this.xt=h,this.$u=!0,n=!0,this.ca()),!this.io||!this.viewportBounds.isReal())return!0;let p=this.Hb,g=this.qb;if(this.td=!1,!n&&!this.eo&&!this.Pn&&!this.Qu&&!this._u)return!0;let y=this.documentBounds,b=0,v=0,w=0,k=0,S=l.width,N=l.height,D=this.ch;this.contentAlignment.isSpot()?(y.width>S&&(b=D.left,v=D.right),y.height>N&&(w=D.top,k=D.bottom)):(b=D.left,v=D.right,w=D.top,k=D.bottom);let L=y.width+b+v,M=y.height+w+k,A=this.scale,F=A,O=L>a/A,E=M>h/A;if(!n&&!this.eo&&!this.Pn&&!O&&!E)return!0;let B=y.x-b,X=l.x,z=y.right+v,U=l.right+o,tt=y.y-w,st=l.y,Z=y.bottom+k,et=l.bottom+r,Q="1px",rt="1px";if(this.scrollMode===1&&(O||E)){if(O&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let _=1;B+1<X&&(_=Math.max((X-B)*A+this.wt,_)),z>U+1&&(_=Math.max((z-U)*A+this.wt,_)),S+o+1<L&&(_=Math.max((L-S)*A+this.wt,_)),Q=_.toString()+"px"}if(E&&this.hasVerticalScrollbar&&this.allowVerticalScroll){let _=1;tt+1<st&&(_=Math.max((st-tt)*A+this.xt,_)),Z>et+1&&(_=Math.max((Z-et)*A+this.xt,_)),N+r+1<M&&(_=Math.max((M-N)*A+this.xt,_)),rt=_.toString()+"px"}}let ft=Q!=="1px",xt=rt!=="1px";if(!(ft&&xt)&&(ft||xt)){if(O=!(L<S+o),E=!(M<N+r),xt&&(U-=this.jt),ft&&(et-=this.jt),O&&this.hasHorizontalScrollbar&&this.allowHorizontalScroll){let St=1;B+1<X&&(St=Math.max((X-B)*A+this.wt,St)),z>U+1&&(St=Math.max((z-U)*A+this.wt,St)),S+1<L&&(St=Math.max((L-S)*A+this.wt,St)),Q=St.toString()+"px"}ft=Q!=="1px";let _=this.xt;if(ft!==this.Pn&&(_=ft?this.xt-this.jt:this.xt+this.jt),E&&this.hasVerticalScrollbar&&this.allowVerticalScroll){let St=1;tt+1<st&&(St=Math.max((st-tt)*A+_,St)),Z>et+1&&(St=Math.max((Z-et)*A+_,St)),N+1<M&&(St=Math.max((M-N)*A+_,St)),rt=St.toString()+"px"}xt=rt!=="1px"}if(this.ip&&!(ft!==this.Pn||xt!==this.eo))return(e!==this.wt||i!==this.xt)&&this.maybeUpdate(),!1;if(ft!==this.Pn&&(Q==="1px"?this.xt=this.xt+this.jt:this.xt=Math.max(this.xt-this.jt,1),n=!0),this.Pn=ft,g.style.width=Q,xt!==this.eo&&(rt==="1px"?this.wt=this.wt+this.jt:this.wt=Math.max(this.wt-this.jt,1),n=!0,this.rd)){let _=P.l();xt?(t.style.left=this.jt+"px",this.position=_.e(this.ct.x+this.jt/this.scale,this.ct.y)):(t.style.left="0px",this.position=_.e(this.ct.x-this.jt/this.scale,this.ct.y)),P.i(_)}n&&this.ca(),this.eo=xt,g.style.height=rt,this.Eb=!0,n&&(this.$u=!0);let Ct=p.scrollLeft;if(this.hasHorizontalScrollbar&&this.allowHorizontalScroll&&(S+1<L?Ct=(this.position.x-B)*A:B+1<X?Ct=p.scrollWidth-p.clientWidth:z>U+1&&(Ct=this.position.x*A)),this.rd)switch(this.nb){case"negative":Ct=-(p.scrollWidth-Ct-p.clientWidth);break;case"reverse":Ct=p.scrollWidth-Ct-p.clientWidth;break}if(p.scrollLeft=Ct,this.hasVerticalScrollbar&&this.allowVerticalScroll&&(N+1<M?p.scrollTop=(this.position.y-tt)*A:tt+1<st?p.scrollTop=p.scrollHeight-p.clientHeight:Z>et+1&&(p.scrollTop=this.position.y*A)),a=this.wt,h=this.xt,p.style.width=a+(this.eo?this.jt:0)+"px",p.style.height=h+(this.Pn?this.jt:0)+"px",e!==a||i!==h||this.animationManager.Pe){let _=I.z(u,c,d,f);return this.onViewportBoundsChanged(_,this.viewportBounds,F,n),I.i(_),!1}return!0}add(t){let e=t.diagram;if(e===this)return;e!==null&&m.o("Cannot add part "+t.toString()+" to "+this.toString()+". It is already a part of "+e.toString());let i=this.findLayer(t.layerName);if(i===null&&(i=this.findLayer("")),i===null&&m.o('Cannot add a Part when unable find a Layer named "'+t.layerName+'" and there is no default Layer'),t.layer===i)return;let s=i.hh(99999999,t,t.diagram===this);s>=0&&this.raiseChangedEvent(3,"parts",i,null,t,null,s),i.isTemporary||this.invalidateDocumentBounds(),t.invalidateLayout(1);let n=t.layerChanged;n!==null&&n(t,null,i)}hh(t){this.partManager.hh(t);let e=this;Y.isUsingDOM()&&t.Sn(i=>e.uT(i)),t.data||t.Go(),t.hasPlaceholder()&&t.f(),t.data!==null&&t.Sn(i=>e.partManager.M2(i,null)),(t.as()===!0||t.fa()===!0)&&this.Pp(t),t.dT(!0,this),t instanceof $&&t.canAvoid()&&this.ud(t),t.gT()?(t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.yp!==null&&this.yp(this,t),this.requestUpdate()}ri(t){t.clearAdornments(),this.partManager.ri(t);let e=this;t.data!==null&&t.Sn(i=>e.partManager.C2(i,e)),this._n.delete(t),t instanceof j?this.Or.delete(t):t instanceof $&&t.canAvoid()&&this.ud(t),t.gT()?(t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.invalidateDocumentBounds()):t.isVisible()&&t.actualBounds.isReal()&&this.N(t.ah(t.actualBounds)),this.wp!==null&&this.wp(this,t),this.requestUpdate()}remove(t){this.N2(t,!0)}N2(t,e){let i=t.layer;if(i===null||i.diagram!==this)return;t.isSelected=!1,t.isHighlighted=!1,t.invalidateLayout(2),e&&t.af();let s=i.ri(-1,t,!1);s>=0&&this.raiseChangedEvent(4,"parts",i,t,null,s,null);let n=t.layerChanged;n!==null&&n(t,i,null)}removeParts(t,e){if(e===void 0&&(e=!1),Array.isArray(t)){let i=t.length;for(let s=0;s<i;s++){let n=t[s];e&&!n.canDelete()||this.remove(n)}}else{let i=new V;i.addAll(t);let s=i.iterator;for(;s.next();){let n=s.value;e&&!n.canDelete()||this.remove(n)}}}copyParts(t,e,i){return i===void 0&&(i=!1),this.partManager.copyParts(t,e,i)}moveParts(t,e,i,s){if(i===void 0&&(i=!1),s===void 0&&(s=this.Cp()),this.toolManager===null)return;let n=new Mt;if(t!==null)if(Array.isArray(t))for(let o=0;o<t.length;o++)this.tl(n,t[o],i,s);else{let o=t.iterator;for(;o.next();)this.tl(n,o.value,i,s)}else{let o=this.parts;for(;o.next();){let r=o.value;this.tl(n,r,i,s)}for(o=this.nodes;o.next();){let r=o.value;this.tl(n,r,i,s)}for(o=this.links;o.next();){let r=o.value;this.tl(n,r,i,s)}}this.Sx(n,e,s,i)}tl(t,e,i,s,n){if(!t.has(e)&&(n===void 0&&(n=!1),!(i&&!n&&!e.canMove()&&!e.canCopy())))if(s===void 0&&(s=this.Cp()),e instanceof $){if(t.set(e,this.Ws(s,e,e.location)),e instanceof ht&&(e.hasPlaceholder()||s.dragsMembers)){let r=e.memberParts;for(;r.next();){let a=r.value;this.tl(t,a,i,s,s.groupsAlwaysMove)}}let o=e.linksConnected;for(;o.next();){let r=o.value;if(t.has(r))continue;let a=r.fromNode,h=r.toNode;a!==null&&t.has(a)&&h!==null&&t.has(h)&&this.tl(t,r,i,s)}if(s.dragsTree){let r=e.findTreeChildrenNodes();for(;r.next();){let a=r.value;this.tl(t,a,i,s)}}}else if(e instanceof j){t.set(e,this.Ws(s,e));let o=e.labelNodes;for(;o.next();){let r=o.value;this.tl(t,r,i,s)}}else e instanceof vt||t.set(e,this.Ws(s,e,e.location))}Sx(t,e,i,s){if(t===null||t.count===0)return;let n=P.l(),o=P.l();o.h(e),isNaN(o.x)&&(o.x=0),isNaN(o.y)&&(o.y=0);let r=this.Jb;r||this.uA(t);let a=m.st(),h=m.st(),l=t.iterator,u=P.l();for(;l.next();){let g=l.key,y=l.value;if(g.Di()){let b=this.mT(g,t);if(b!==null)a.push(new On(g,y,b));else if(!s||g.canMove()){let v=y.point;n.h(v),this.computeMove(g,n.add(o),i,u),g.location=u,y.shifted===void 0&&(y.shifted=new P),y.shifted.h(u.subtract(v))}}else l.key instanceof j&&h.push(new ye(l.key,l.value))}P.i(u);let c=a.length;for(let g=0;g<c;g++){let y=a[g],b=y.pT.point;n.h(b),y.s1.shifted===void 0&&(y.s1.shifted=new P),y.Ri.location=n.add(y.s1.shifted)}let d=P.l(),f=P.l(),p=h.length;for(let g=0;g<p;g++){let y=h[g],b=y.key;if(b instanceof j){if(b.suspendsRouting){b.Dr=null;let v=b.fromNode,w=b.toNode;if(this.draggedLink!==null&&i.dragsLink){let k=y.value.point;if(b.dragComputation===null){t.set(b,this.Ws(i,b,o));let S=o.x-k.x,N=o.y-k.y;b.kr(S,N)}else{let S=P.z(0,0),N=b.getPoint(0);N&&N.isReal()&&S.h(N),u=P.l().h(S).add(o);let D=u;i.isGridSnapEnabled&&(i.isGridSnapRealtime||this.lastInput.up)&&(D=P.l(),this.oM(b,u,D,i)),u.h(b.dragComputation(b,u,D)).subtract(S),t.set(b,this.Ws(i,b,u));let L=u.x-k.x,M=u.y-k.y;b.kr(L,M),P.i(S),P.i(u),D!==u&&P.i(D)}}else{if(v!==null){d.h(v.location);let k=t.get(v);k!==null&&d.subtract(k.point)}if(w!==null){f.h(w.location);let k=t.get(w);k!==null&&f.subtract(k.point)}if(v!==null&&w!==null){let k=y.value.point;if(d.equalsApprox(f)||b.computeAdjusting()!==0){let S=n;S.h(d),S.subtract(k),t.set(b,this.Ws(i,b,d)),b.kr(S.x,S.y)}else b.suspendsRouting=!1,b.$t()}else{let k=y.value.point,S;v!==null?S=d:w!==null?S=f:S=o,t.set(b,this.Ws(i,b,S));let N=S.x-k.x,D=S.y-k.y;b.kr(N,D)}}}else if(b.fromNode===null||b.toNode===null){let v=y.value.point;t.set(b,this.Ws(i,b,o));let w=o.x-v.x,k=o.y-v.y;b.kr(w,k)}}}P.i(n),P.i(o),P.i(d),P.i(f),m.Z(a),m.Z(h),r||(this.De(),this.dS(t))}computeMove(t,e,i,s){if(s===void 0&&(s=new P),s.h(e),t===null)return s;let n=e,o=i.isGridSnapEnabled;o&&(i.isGridSnapRealtime||this.lastInput.up)&&(n=P.l(),this.oM(t,e,n,i));let r=t.dragComputation!==null?t.dragComputation(t,e,n):n,a=t.minLocation,h=a.x;isNaN(h)&&(h=o?Math.round(t.location.x*1e3)/1e3:t.location.x);let l=a.y;isNaN(l)&&(l=o?Math.round(t.location.y*1e3)/1e3:t.location.y);let u=t.maxLocation,c=u.x;isNaN(c)&&(c=o?Math.round(t.location.x*1e3)/1e3:t.location.x);let d=u.y;return isNaN(d)&&(d=o?Math.round(t.location.y*1e3)/1e3:t.location.y),s.e(Math.max(h,Math.min(r.x,c)),Math.max(l,Math.min(r.y,d))),n!==e&&P.i(n),s}Cp(){let t=this.toolManager.findTool("Dragging");return t instanceof Tt?t.dragOptions:this.ld}oM(t,e,i,s){if(s===void 0&&(s=this.Cp()),i.h(e),t===null)return i;let n=this.grid,o=s.gridSnapCellSize,r=o.width,a=o.height,h=s.gridSnapOrigin,l=h.x,u=h.y,c=s.gridSnapCellSpot;if(n!==null){let f=n.gridCellSize;isNaN(r)&&(r=f.width),isNaN(a)&&(a=f.height);let p=n.gridOrigin;isNaN(l)&&(l=p.x),isNaN(u)&&(u=p.y)}let d=P.z(0,0);return d.setSpot(0,0,r,a,c),C._g(e.x,e.y,l+d.x,u+d.y,r,a,i),P.i(d),i}uA(t){if(t===null)return;this.Jb=!0;let e=t.iterator;for(;e.next();){let i=e.key;i instanceof j&&(i.suspendsRouting=!0)}}dS(t){if(t===null)return;let e=t.iterator;for(;e.next();){let i=e.key;i instanceof j&&(i.suspendsRouting=!1,i.yT()&&i.$t())}this.Jb=!1}get draggedLink(){return this.$b}set draggedLink(t){this.$b!==t&&(this.$b=t,t!==null&&(this.Zb=t.fromPort,this.Qb=t.toPort))}get xS(){return this.Zb}set xS(t){this.Zb=t}get bS(){return this.Qb}set bS(t){this.Qb=t}mT(t,e){let i=t.containingGroup;if(i!==null){let s=this.mT(i,e);if(s!==null||(s=e.get(i),s!==null))return s}return null}Ws(t,e,i){if(i===void 0)return new Xe(P.gn);let s=t.isGridSnapEnabled;return!t.groupsSnapMembers&&e.containingGroup!==null&&(s=!1),s?new Xe(new P(Math.round(i.x*1e3)/1e3,Math.round(i.y*1e3)/1e3)):new Xe(i.copy())}L2(t,e){if(t.diagram!==null&&t.diagram!==this&&m.o("Cannot share a Layer with another Diagram: "+t+" of "+t.diagram),e===null?t.diagram!==null&&m.o("Cannot add an existing Layer to this Diagram again: "+t):(e.diagram!==this&&m.o("Existing Layer must be in this Diagram: "+e+" not in "+e.diagram),t===e&&m.o("Cannot move a Layer before or after itself: "+t)),t.diagram===this)return;let i=t.name,s=this.Vt,n=s.count;for(let o=0;o<n;o++)s.elt(o).name===i&&m.o("Cannot add Layer with the name '"+i+"'; a Layer with the same name is already present in this Diagram.")}addLayer(t){this.L2(t,null),t.Io(this);let e=this.Vt,i=e.count-1;if(!t.isTemporary)for(;i>=0&&e.elt(i).isTemporary;)i--;return e.insertAt(i+1,t),this.Le!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,i+1),this.N(),this.invalidateDocumentBounds(),this}addLayerBefore(t,e){this.L2(t,e),t.Io(this);let i=this.Vt,s=i.indexOf(t);s>=0&&(i.delete(t),this.Le!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));let n=i.count,o;for(o=0;o<n;o++)if(i.elt(o)===e){i.insertAt(o,t);break}return this.Le!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,o),this.N(),s<0&&this.invalidateDocumentBounds(),this}addLayerAfter(t,e){this.L2(t,e),t.Io(this);let i=this.Vt,s=i.indexOf(t);s>=0&&(i.delete(t),this.Le!==null&&this.raiseChangedEvent(4,"layers",this,t,null,s,null));let n=i.count,o;for(o=0;o<n;o++)if(i.elt(o)===e){i.insertAt(o+1,t);break}return this.Le!==null&&this.raiseChangedEvent(3,"layers",this,null,t,null,o+1),this.N(),s<0&&this.invalidateDocumentBounds(),this}Zr(t,e){t.Io(this),this.Vt.insertAt(e,t)}wT(t){this.Vt.removeAt(t)}removeLayer(t){if(t.diagram!==this&&m.o("Cannot remove a Layer from another Diagram: "+t+" of "+t.diagram),t.name==="")return;let e=this.Vt,i=e.indexOf(t);if(e.delete(t)){let s=t.Ct.copy().iterator;for(;s.next();){let n=s.value,o=n.layerName;o!==t.name?n.layerName=o:n.layerName=""}this.Le!==null&&this.raiseChangedEvent(4,"layers",this,t,null,i,null),this.N(),this.invalidateDocumentBounds()}}findLayer(t){let e=this.layers;for(;e.next();){let i=e.value;if(i.name===t)return i}return null}findRouter(t){for(let e of this.rf)if(e.name===t)return e;return null}addModelChangedListener(t){return m.S(t,Y,"addModelChangedListener:listener"),this.to===null&&(this.to=new q),this.to.add(t),this.model&&this.model.addChangedListener(t),this}removeModelChangedListener(t){m.S(t,Y,"removeModelChangedListener:listener"),this.to!==null&&(this.to.delete(t),this.to.count===0&&(this.to=null)),this.model.removeChangedListener(t)}addChangedListener(t){return m.S(t,Y,"addChangedListener:listener"),this.Ir===null&&(this.Ir=new q),this.Ir.add(t),this}removeChangedListener(t){m.S(t,Y,"removeChangedListener:listener"),this.Ir!==null&&(this.Ir.delete(t),this.Ir.count===0&&(this.Ir=null))}A2(t){if(!this.skipsUndoManager&&!this.model.skipsUndoManager&&this.model.undoManager.handleChanged(t),t.change!==1&&(this.isModified=!0),this.Ir!==null){let e=this.Ir,i=e.length;for(let s=0;s<i;s++)e.elt(s)(t)}}raiseChangedEvent(t,e,i,s,n,o,r){o===void 0&&(o=null),r===void 0&&(r=null);let a=new ze;a.diagram=this,a.change=t,a.propertyName=e,a.object=i,a.oldValue=s,a.oldParam=o,a.newValue=n,a.newParam=r,this.A2(a)}raiseChanged(t,e,i,s,n){this.raiseChangedEvent(2,t,this,e,i,s,n)}t(t,e,i,s,n){this.raiseChangedEvent(2,t,this,e,i,s,n)}get partAdded(){return this.yp}set partAdded(t){this.partAdded!==t&&(this.yp=t)}get partRemoved(){return this.wp}set partRemoved(t){this.partRemoved!==t&&(this.wp=t)}get animationManager(){return this.Cs}get undoManager(){return this.Le.undoManager}get skipsUndoManager(){return this.Vo}set skipsUndoManager(t){m.s(t,"boolean",Y,"skipsUndoManager"),this.Vo=t,this.Le.skipsUndoManager=t}get delaysLayout(){return this.Cb}set delaysLayout(t){this.Cb=t}tA(t,e){if(t===null||t.diagram!==this)return;let i=this.wi;try{this.wi=!0;let s=t.change;if(s===2){let n=t.object,o=t.propertyName,r=t.getValue(e);if(t.diagram.model.nt(n,o,r),n instanceof J){let a=n.part;a!==null&&(a.invalidateAdornments(),a instanceof j&&(a.fromNode?.Ze(a.fromPort),a.toNode?.Ze(a.toPort)))}this.isModified=!0}else if(s===3){let n=t.object,o=t.newParam,r=t.newValue;if(n instanceof G)if(typeof o=="number"&&r instanceof J){e?n.ri(o):n.insertAt(o,r);let a=n.part;a!==null&&a.invalidateAdornments()}else typeof o=="number"&&r instanceof Kt&&(r.isRow?n.xT(o,e?void 0:r):n.bT(o,e?void 0:r));else if(n instanceof Et){let a=t.oldParam===!0;typeof o=="number"&&r instanceof pt&&(e?(a||(r.isSelected=!1,r.isHighlighted=!1,r.invalidateAdornments()),n.ri(a?o:-1,r,a)):n.hh(o,r,a))}else n instanceof Y?typeof o=="number"&&r instanceof Et&&(e?this.wT(o):this.Zr(r,o)):m.o("unknown ChangeType.Insert object: "+t.toString());this.isModified=!0}else if(s===4){let n=t.object,o=t.oldParam,r=t.oldValue;if(n instanceof G)typeof o=="number"&&r instanceof J?e?n.insertAt(o,r):n.ri(o):typeof o=="number"&&r instanceof Kt&&(r.isRow?n.xT(o,e?r:void 0):n.bT(o,e?r:void 0));else if(n instanceof Et){let a=t.newParam===!0;typeof o=="number"&&r instanceof pt&&(e?n.Ct.indexOf(r)<0&&n.hh(o,r,a):(a||(r.isSelected=!1,r.isHighlighted=!1,r.invalidateAdornments()),n.ri(a?o:-1,r,a)))}else n instanceof Y?typeof o=="number"&&r instanceof Et&&(e?this.Zr(r,o):this.wT(o)):m.o("unknown ChangeType.Remove object: "+t.toString());this.isModified=!0}else s===1||m.o("unknown ChangedEvent: "+t.toString())}finally{this.wi=i}}startTransaction(t){return this.undoManager.startTransaction(t)}commitTransaction(t){return this.undoManager.commitTransaction(t)}rollbackTransaction(){return this.undoManager.rollbackTransaction()}commit(t,e){let i=e;i===void 0&&(i="");let s=this.skipsUndoManager;i===null&&(this.skipsUndoManager=!0,i=""),this.undoManager.startTransaction(i);let n=!1;try{t(this),n=!0}finally{n?this.undoManager.commitTransaction(i):this.undoManager.rollbackTransaction(),this.skipsUndoManager=s}}updateAllTargetBindings(t){this.partManager.updateAllTargetBindings(t)}updateAllThemeBindings(){if(this.partManager.updateAllThemeBindings(),this.ls!==null){let t=this.ls.part;t!==null&&t.Go()}}setDivBackground(t){this.div&&(this.div.style.backgroundColor=t)}updateAllRelationshipsFromData(){this.partManager.updateAllRelationshipsFromData()}kp(){let t=this.v,e=this.et,i=this.ct;t.Ue(),e!==1&&t.et(e),(i.x!==0||i.y!==0)&&t.Gs(-i.x,-i.y)}kT(t,e){let i=this.animationManager;if(this.Ht||this.As){this.et=e,this.ca(),this.N(),this.Mh(),i.EA(t,this.et),this.kp();return}if(this.lt===null){this.et=e,this.kp();return}this.Ht=!0;let s=this.viewportBounds.copy(),n=this.wt,o=this.xt,r=this.zoomPoint.x,a=this.zoomPoint.y,h=this.contentAlignment;isNaN(r)&&(h.isSide()?h.includesSide(T.LeftSide)?r=0:h.includesSide(T.RightSide)&&(r=n-1):h.isSpot()?r=h.x*(n-1):r=n/2),isNaN(a)&&(h.isSide()?h.includesSide(T.TopSide)?a=0:h.includesSide(T.BottomSide)&&(a=o-1):h.isSpot()?a=h.y*(o-1):a=o/2),this.scaleComputation!==null&&!this.animationManager.defaultAnimation.isAnimating&&(e=this.scaleComputation(this,e)),e<this.minScale&&(e=this.minScale),e>this.maxScale&&(e=this.maxScale);let l=P.z(this.ct.x+r/t-r/e,this.ct.y+a/t-a/e);this.position=l,P.i(l),this.et=e,this.kp(),this.ca(),this.Ht=!1,this.onViewportBoundsChanged(s,this.viewportBounds,t,!1),this.$s(!1),i.EA(t,this.et),this.N()}yO(){let t=this.Vt.r;for(let e=0;e<t.length;e++)t[e].YA()}onViewportBoundsChanged(t,e,i,s){if(t.equals(e))return;s===void 0&&(s=!1),s||this.Mh(),this.Qr();let n=this.layout;n!==null&&n.isViewportSized&&this.autoScale===1&&(t.width!==e.width||t.height!==e.height)&&n.p();let o=this.currentTool;this.nf===!0&&o instanceof oe&&!this.animationManager.isTicking&&(this.lastInput.documentPoint=this.transformViewToDoc(this.lastInput.viewPoint),o.cA(this)),this.Ht||this.invalidateViewport(t,e),this.cd();let r=this.Vt.r;this.rs(r,r.length,this,this.viewportBounds),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.canvasSize.width=Math.round(t.width*i),this.Ye.canvasSize.height=Math.round(t.height*i),this.Ye.newCanvasSize.width=this.wt,this.Ye.newCanvasSize.height=this.xt,this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t),this.isVirtualized&&this.links.each(a=>{a.isAvoiding&&a.actualBounds.intersectsRect(e)&&a.$t()})}cd(){this._c=!1,this.N()}P2(t){let e=this.ls;if(e===null||!e.visible)return;let i=e.part;if(i===null||i.layer===null)return;let s=t!==void 0?t:this.zb;if(!s.isReal())return;let n=s.width,o=s.height;if(e.scale=1,e.angle=0,i.layer.isViewportAligned)e.width=n*this.scale,e.height=o*this.scale,i.alignment=T.TopLeft;else{e.Se===null&&(e.Se=new ti);let r=e.Se.hf;if(!r.isReal())return;e.width=n+r.width*2,e.height=o+r.height*2,this.Qr();let a=P.l();C._g(s.x,s.y,0,0,r.width,r.height,a),a.offset(-r.width,-r.height),i.location=a,P.i(a)}}clearSelection(t){t===void 0&&(t=!1);let e=this.selection;if(e.count===0)return;t||this.T("ChangingSelection",e);let i=e.toArray(),s=i.length;for(let n=0;n<s;n++){let o=i[n];o.isSelected=!1}e.ce(),e.clear(),e.k(),t||this.T("ChangedSelection",e)}select(t){t!==null&&t.diagram===this&&(!t.isSelected||this.selection.count>1)&&(this.T("ChangingSelection",this.selection),this.clearSelection(!0),t.isSelected=!0,this.T("ChangedSelection",this.selection))}selectCollection(t){if(this.T("ChangingSelection",this.selection),this.clearSelection(!0),Array.isArray(t)){let e=t.length;for(let i=0;i<e;i++){let s=t[i];s instanceof pt||m.o("Diagram.selectCollection given something that is not a Part: "+s),s.isSelected=!0}}else{let e=t.iterator;for(;e.next();){let i=e.value;i instanceof pt||m.o("Diagram.selectCollection given something that is not a Part: "+i),i.isSelected=!0}}this.T("ChangedSelection",this.selection)}clearHighlighteds(){let t=this.highlighteds;if(t.count>0){let e=t.toArray(),i=e.length;for(let s=0;s<i;s++){let n=e[s];n.isHighlighted=!1}t.ce(),t.clear(),t.k()}}highlight(t){t!==null&&t.diagram===this&&(!t.isHighlighted||this.highlighteds.count>1)&&(this.clearHighlighteds(),t.isHighlighted=!0)}highlightCollection(t){let e=new V().addAll(t),i=this.highlighteds.copy().removeAll(e).iterator;for(;i.next();){let n=i.value;n.isHighlighted=!1}let s=e.iterator;for(;s.next();){let n=s.value;n instanceof pt||m.o("Diagram.highlightCollection given something that is not a Part: "+n),n.isHighlighted=!0}}scroll(t,e,i){i===void 0&&(i=1);let s=e==="up"||e==="down",n=0,o=P.l();if(t==="pixel")n=i;else if(t==="line")n=i*(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange);else if(t==="page"){let a=s?this.viewportBounds.height:this.viewportBounds.width;if(a*=this.scale,a!==0){let h=Math.max(a-(s?this.scrollVerticalLineChange:this.scrollHorizontalLineChange),0);n=i*h}}else if(t==="document"){let a=this.documentBounds,h=this.viewportBounds;e==="up"?this.position=o.e(h.x,a.y):e==="left"?this.position=o.e(a.x,h.y):e==="down"?this.position=o.e(h.x,a.bottom-h.height):e==="right"&&(this.position=o.e(a.right-h.width,h.y)),P.i(o);return}else m.o("scrolling unit must be 'pixel', 'line', 'page', or 'document', not: "+t);n/=this.scale;let r=this.position;e==="up"?this.position=o.e(r.x,r.y-n):e==="down"?this.position=o.e(r.x,r.y+n):e==="left"?this.position=o.e(r.x-n,r.y):e==="right"?this.position=o.e(r.x+n,r.y):m.o("scrolling direction must be 'up', 'down', 'left', or 'right', not: "+e),P.i(o)}scrollToRect(t){let e=this.viewportBounds;if(e.containsRect(t))return;let i=t.center;i.x-=e.width/2,i.y-=e.height/2,this.position=i}centerRect(t){let e=this.viewportBounds,i=t.center;i.x-=e.width/2,i.y-=e.height/2,this.position=i}transformDocToView(t){return t.copy().v(this.v)}transformViewToDoc(t){return t.copy().Hi(this.v)}YR(t){return t.Hi(this.v)}static None=1;static Uniform=2;static UniformToFill=3;static CycleAll=1;static CycleNotDirected=2;static CycleNotDirectedFast=3;static CycleNotUndirected=4;static CycleDestinationTree=5;static CycleSourceTree=6;static DocumentScroll=1;static InfiniteScroll=2;static TreeParentCollapsed=1;static AllParentsCollapsed=2;static AnyParentsCollapsed=3;get opacity(){return this.Zt}set opacity(t){let e=this.Zt;e!==t&&(m.s(t,"number",Y,"opacity"),(t<0||t>1)&&m.J(t,"0 <= value <= 1",Y,"opacity"),this.Zt=t,this.t("opacity",e,t),this.N())}get validCycle(){return this.xb}set validCycle(t){let e=this.xb;e!==t&&(this.xb=t,this.t("validCycle",e,t))}get layers(){return this.Vt.iterator}get isModelReadOnly(){let t=this.Le;return t===null?!1:t.isReadOnly}set isModelReadOnly(t){let e=this.Le;e!==null&&(e.isReadOnly=t)}get isReadOnly(){return this.Bo}set isReadOnly(t){let e=this.Bo;e!==t&&(m.s(t,"boolean",Y,"isReadOnly"),this.Bo=t,this.t("isReadOnly",e,t))}get isEnabled(){return this.Be}set isEnabled(t){let e=this.Be;e!==t&&(m.s(t,"boolean",Y,"isEnabled"),this.Be=t,this.t("isEnabled",e,t))}get allowClipboard(){return this.Nb}set allowClipboard(t){let e=this.Nb;e!==t&&(m.s(t,"boolean",Y,"allowClipboard"),this.Nb=t,this.t("allowClipboard",e,t))}get allowCopy(){return this.Hl}set allowCopy(t){let e=this.Hl;e!==t&&(m.s(t,"boolean",Y,"allowCopy"),this.Hl=t,this.t("allowCopy",e,t))}get allowDelete(){return this.ql}set allowDelete(t){let e=this.ql;e!==t&&(m.s(t,"boolean",Y,"allowDelete"),this.ql=t,this.t("allowDelete",e,t))}get allowDragOut(){return this.Lb}set allowDragOut(t){let e=this.Lb;e!==t&&(m.s(t,"boolean",Y,"allowDragOut"),this.Lb=t,this.t("allowDragOut",e,t))}get allowDrop(){return this.Ab}set allowDrop(t){let e=this.Ab;e!==t&&(m.s(t,"boolean",Y,"allowDrop"),this.Ab=t,this.t("allowDrop",e,t))}get allowTextEdit(){return this.jl}set allowTextEdit(t){let e=this.jl;e!==t&&(m.s(t,"boolean",Y,"allowTextEdit"),this.jl=t,this.t("allowTextEdit",e,t))}get allowGroup(){return this.Wl}set allowGroup(t){let e=this.Wl;e!==t&&(m.s(t,"boolean",Y,"allowGroup"),this.Wl=t,this.t("allowGroup",e,t))}get allowUngroup(){return this.Jl}set allowUngroup(t){let e=this.Jl;e!==t&&(m.s(t,"boolean",Y,"allowUngroup"),this.Jl=t,this.t("allowUngroup",e,t))}get allowInsert(){return this.Tb}set allowInsert(t){let e=this.Tb;e!==t&&(m.s(t,"boolean",Y,"allowInsert"),this.Tb=t,this.t("allowInsert",e,t))}get allowLink(){return this.$l}set allowLink(t){let e=this.$l;e!==t&&(m.s(t,"boolean",Y,"allowLink"),this.$l=t,this.t("allowLink",e,t))}get allowRelink(){return this.Zl}set allowRelink(t){let e=this.Zl;e!==t&&(m.s(t,"boolean",Y,"allowRelink"),this.Zl=t,this.t("allowRelink",e,t))}get allowMove(){return this.Ql}set allowMove(t){let e=this.Ql;e!==t&&(m.s(t,"boolean",Y,"allowMove"),this.Ql=t,this.t("allowMove",e,t))}get allowReshape(){return this._l}set allowReshape(t){let e=this._l;e!==t&&(m.s(t,"boolean",Y,"allowReshape"),this._l=t,this.t("allowReshape",e,t))}get allowResize(){return this.ta}set allowResize(t){let e=this.ta;e!==t&&(m.s(t,"boolean",Y,"allowResize"),this.ta=t,this.t("allowResize",e,t))}get allowRotate(){return this.ea}set allowRotate(t){let e=this.ea;e!==t&&(m.s(t,"boolean",Y,"allowRotate"),this.ea=t,this.t("allowRotate",e,t))}get allowSelect(){return this.ia}set allowSelect(t){let e=this.ia;e!==t&&(m.s(t,"boolean",Y,"allowSelect"),this.ia=t,this.t("allowSelect",e,t))}get allowUndo(){return this.Db}set allowUndo(t){let e=this.Db;e!==t&&(m.s(t,"boolean",Y,"allowUndo"),this.Db=t,this.t("allowUndo",e,t))}get allowZoom(){return this.vb}set allowZoom(t){let e=this.vb;e!==t&&(m.s(t,"boolean",Y,"allowZoom"),this.vb=t,this.t("allowZoom",e,t))}get hasVerticalScrollbar(){return this._u}set hasVerticalScrollbar(t){let e=this._u;e!==t&&(m.s(t,"boolean",Y,"hasVerticalScrollbar"),this._u=t,this.Mh(),this.N(),this.t("hasVerticalScrollbar",e,t),this.$s(!1))}get hasHorizontalScrollbar(){return this.Qu}set hasHorizontalScrollbar(t){let e=this.Qu;e!==t&&(m.s(t,"boolean",Y,"hasHorizontalScrollbar"),this.Qu=t,this.Mh(),this.N(),this.t("hasHorizontalScrollbar",e,t),this.$s(!1))}get allowHorizontalScroll(){return this.Fb}set allowHorizontalScroll(t){let e=this.Fb;e!==t&&(m.s(t,"boolean",Y,"allowHorizontalScroll"),this.Fb=t,this.t("allowHorizontalScroll",e,t),this.$s(!1))}get allowVerticalScroll(){return this.Rb}set allowVerticalScroll(t){let e=this.Rb;e!==t&&(m.s(t,"boolean",Y,"allowVerticalScroll"),this.Rb=t,this.t("allowVerticalScroll",e,t),this.$s(!1))}get scrollHorizontalLineChange(){return this.Ob}set scrollHorizontalLineChange(t){let e=this.Ob;e!==t&&(m.s(t,"number",Y,"scrollHorizontalLineChange"),t<0&&m.J(t,">= 0",Y,"scrollHorizontalLineChange"),this.Ob=t,this.t("scrollHorizontalLineChange",e,t))}get scrollVerticalLineChange(){return this.Ib}set scrollVerticalLineChange(t){let e=this.Ib;e!==t&&(m.s(t,"number",Y,"scrollVerticalLineChange"),t<0&&m.J(t,">= 0",Y,"scrollVerticalLineChange"),this.Ib=t,this.t("scrollVerticalLineChange",e,t))}get lastInput(){return this.dh}set lastInput(t){this.dh=t}get previousInput(){return this.Wr}set previousInput(t){this.Wr=t}get firstInput(){return this.lp}set firstInput(t){this.lp=t}get currentCursor(){return this.bb}set currentCursor(t){if(t===""&&(t=this.ep),this.bb!==t){m.s(t,"string",Y,"currentCursor");let e=this.lt,i=this.Mt;if(e===null||i===null)return;this.bb=t;let s=e.style.cursor;e.style.cursor=t,i.style.cursor=t,e.style.cursor===s&&(e.style.cursor="-webkit-"+t,i.style.cursor="-webkit-"+t,e.style.cursor===s&&(e.style.cursor="-moz-"+t,i.style.cursor="-moz-"+t,e.style.cursor===s&&(e.style.cursor=t,i.style.cursor=t)))}}get defaultCursor(){return this.ep}set defaultCursor(t){t===""&&(t="auto");let e=this.ep;e!==t&&(m.s(t,"string",Y,"defaultCursor"),this.ep=t,this.t("defaultCursor",e,t))}get click(){return this.Er}set click(t){let e=this.Er;e!==t&&(t!==null&&m.S(t,Y,"click"),this.Er=t,this.t("click",e,t))}get doubleClick(){return this.Ur}set doubleClick(t){let e=this.Ur;e!==t&&(t!==null&&m.S(t,Y,"doubleClick"),this.Ur=t,this.t("doubleClick",e,t))}get contextClick(){return this.Vr}set contextClick(t){let e=this.Vr;e!==t&&(t!==null&&m.S(t,Y,"contextClick"),this.Vr=t,this.t("contextClick",e,t))}get mouseOver(){return this.Br}set mouseOver(t){let e=this.Br;e!==t&&(t!==null&&m.S(t,Y,"mouseOver"),this.Br=t,this.t("mouseOver",e,t))}get mouseHover(){return this.zr}set mouseHover(t){let e=this.zr;e!==t&&(t!==null&&m.S(t,Y,"mouseHover"),this.zr=t,this.t("mouseHover",e,t))}get mouseHold(){return this.Xr}set mouseHold(t){let e=this.Xr;e!==t&&(t!==null&&m.S(t,Y,"mouseHold"),this.Xr=t,this.t("mouseHold",e,t))}get mouseDragOver(){return this.kb}set mouseDragOver(t){let e=this.kb;e!==t&&(t!==null&&m.S(t,Y,"mouseDragOver"),this.kb=t,this.t("mouseDragOver",e,t))}get mouseDrop(){return this.Gr}set mouseDrop(t){let e=this.Gr;e!==t&&(this.Gr=t,this.t("mouseDrop",e,t))}get handlesDragDropForTopLevelParts(){return this.Pb}set handlesDragDropForTopLevelParts(t){let e=this.Pb;e!==t&&(m.s(t,"boolean",Y,"handlesDragDropForTopLevelParts"),this.Pb=t,this.t("handlesDragDropForTopLevelParts",e,t))}get mouseEnter(){return this.Yr}set mouseEnter(t){let e=this.Yr;e!==t&&(t!==null&&m.S(t,Y,"mouseEnter"),this.Yr=t,this.t("mouseEnter",e,t))}get mouseLeave(){return this.Kr}set mouseLeave(t){let e=this.Kr;e!==t&&(t!==null&&m.S(t,Y,"mouseLeave"),this.Kr=t,this.t("mouseLeave",e,t))}get toolTip(){return this.Hr}set toolTip(t){let e=this.Hr;e!==t&&(this.Hr=t,this.t("toolTip",e,t))}get contextMenu(){return this.qr}set contextMenu(t){let e=this.qr;e!==t&&(this.qr=t,this.t("contextMenu",e,t))}get commandHandler(){return this.KM}set commandHandler(t){let e=this.KM;e!==t&&(e&&e.doStop(),this.KM=t,t.Io(this),t.doStart())}get toolManager(){return this.XM}set toolManager(t){this.XM!==t&&(this.XM=t,t.diagram=this)}get defaultTool(){return this.GM}set defaultTool(t){let e=this.GM;e!==t&&(this.GM=t,t.diagram=this,this.currentTool===e&&(this.currentTool=t))}get currentTool(){return this.YM}set currentTool(t){let e=this.YM;e&&(e.isActive&&e.doDeactivate(),e.cancelWaitAfter(),e.doStop()),t===null&&(t=this.defaultTool),t!==null&&(this.YM=t,t.diagram=this,t.doStart())}get selection(){return this.KA}get maxSelectionCount(){return this.Bb}set maxSelectionCount(t){let e=this.Bb;if(e!==t)if(m.s(t,"number",Y,"maxSelectionCount"),t>=0&&!isNaN(t)){if(this.Bb=t,this.t("maxSelectionCount",e,t),!this.undoManager.isUndoingRedoing){let i=this.selection.count-t;if(i>0){this.T("ChangingSelection",this.selection);let s=this.selection.toArray();for(let n=0;n<i;n++)s[n].isSelected=!1;this.T("ChangedSelection",this.selection)}}}else m.J(t,">= 0",Y,"maxSelectionCount")}get nodeSelectionAdornmentTemplate(){return this.op}set nodeSelectionAdornmentTemplate(t){let e=this.op;e!==t&&(this.op=t.It(),this.t("nodeSelectionAdornmentTemplate",e,t))}get groupSelectionAdornmentTemplate(){return this.Gb}set groupSelectionAdornmentTemplate(t){let e=this.Gb;e!==t&&(this.Gb=t.It(),this.t("groupSelectionAdornmentTemplate",e,t))}get linkSelectionAdornmentTemplate(){return this.Yb}set linkSelectionAdornmentTemplate(t){let e=this.Yb;e!==t&&(this.Yb=t.It(),this.t("linkSelectionAdornmentTemplate",e,t))}get highlighteds(){return this.HA}get isModified(){let t=this.undoManager;return t.isEnabled?t.currentTransaction!==null?!0:this.sd&&this.qs!==t.historyIndex:this.sd}set isModified(t){if(this.sd!==t){m.s(t,"boolean",Y,"isModified"),this.sd=t;let e=this.undoManager;!t&&e.isEnabled&&(this.qs=e.historyIndex),t||this.PT()}}PT(){let t=this.isModified;this.WM!==t&&(this.WM=t,this.T("Modified"))}get model(){return this.Le}set model(t){let e=this.Le;if(e!==t){this.currentTool.doCancel(),e&&e.undoManager!==t.undoManager&&e.undoManager.isInTransaction&&m.o("Do not replace a Diagram.model while a transaction is in progress.");let i=this.sT(!0);this.io=!1,this.Zu=!0,this.qs=-2,this.Tr=!1;let s=this.Ht;this.Ht=!0,this.animationManager.Kl("Model"),e&&(this.to!==null&&this.to.each(n=>e.removeChangedListener(n)),e.removeChangedListener(this.Qc)),this.Le=t,this.partManager=this.NO(this.Le.type),this.initializePartManager(this.partManager);for(let n=0;n<i.length;n++)this.add(i[n]);t.addChangedListener(this.jM),this.partManager.T2(),t.removeChangedListener(this.jM),t.addChangedListener(this.Qc),this.to!==null&&this.to.each(n=>t.addChangedListener(n)),this.Ht=s,this.invalidateDocumentBounds(),this.Ht||this.N(),e&&t.undoManager.copyProperties(e.undoManager)}}get themeManager(){return this.f2}set themeManager(t){let e=this.f2;e!==t&&(e&&e.removeDiagram(this),this.f2=t,t!==null&&t.addDiagram(this))}initializePartManager(t){}static u2(t,e){Y.JA.set(t,e)}static get licenseKey(){return Y.D2.last()}static set licenseKey(t){Y.D2.add(t.replace(/\s/g,""))}static get version(){return Y.LO}static D2=new q;static LO="3.1.9";NO(t){let e=Y.JA.get(t);return e!==null?new e:new me}get G(){return this.qM}set G(t){this.qM=t}get eb(){return this.qA}AO(t){if(t.model!==this.model)return;let e=t.change,i=t.propertyName;if(e===1&&i[0]==="S"){if(i==="StartingFirstTransaction"){let s=this,n=this.toolManager;n.mouseDownTools.each(o=>o.diagram=s),n.mouseMoveTools.each(o=>o.diagram=s),n.mouseUpTools.each(o=>o.diagram=s),this.routers.each(o=>o.diagram=s),!this.As&&!this.io&&(this.Zc=!0,this.Zu&&(this.Tr=!0))}else if(i==="StartingUndo"||i==="StartingRedo"){let s=this.animationManager;this.skipsUndoManager||(s.defaultAnimation.isAnimating&&s.stopAnimation(),s.getBundleAnimation().isAnimating&&s.getBundleAnimation().stop()),this.T("ChangingSelection",this.selection)}else if(i==="StartedTransaction"){let s=this.animationManager;s.defaultAnimation.isAnimating&&!this.skipsUndoManager&&s.stopAnimation()}return}if(this.G){this.G=!1;try{if(t.modelChange===""&&e===1){(i==="FinishedUndo"||i==="FinishedRedo")&&(this.T("ChangedSelection",this.selection),this.De());let s=this.animationManager;i==="RolledBackTransaction"&&s.stopAnimation(),this.VA(),this.Zc=!0,this.maybeUpdate(),(this.undoManager.transactionLevel===0||this.undoManager.transactionLevel===1)&&s.kM(),i==="CommittedTransaction"&&this.undoManager.isJustDiscarded&&(this.qs=Math.min(this.qs,this.undoManager.historyIndex-1)),(i==="CommittedTransaction"||i==="RolledBackTransaction")&&this.undoManager.wx&&m.dn(()=>{this.isModified=!1},1);let n=t.isTransactionFinished;if(n&&(this.PT(),this.eb.clear(),this.animationManager.LR()),!this.Sb&&n&&this.lastInput.targetDiagram){this.Sb=!0;let o=this;m.dn(()=>{o.currentTool.standardMouseOver(),o.Sb=!1},10)}}}finally{this.G=!0}}}get wi(){return this.HM}set wi(t){this.HM=t}get Ou(){return this.Mb}set Ou(t){this.Mb=t}uT(t){let e=t.D.r;for(let i of e)i instanceof Bt&&this.v2(i)}v2(t){let e=t.element;if(e===null||!K.HTMLImageElement||!(e instanceof HTMLImageElement)||(e.hs instanceof V&&e.hs.add(this),t.TO(),!e.Np))return;let i=e.getAttribute("src")||"",s=this.la.get(i);if(s===null){Bt.ST(t,e);let n=[];n.push(t),this.la.set(i,n)}else{for(let n=0;n<s.length;n++)if(s[n]===t)return;s.push(t)}}DO(t){let e=t.D.r,i=e.length;for(let s=0;s<i;s++)this.F2(e[s])}F2(t){if(!(t instanceof Bt))return;let e=t.element;if(e===null||!K.HTMLImageElement||!(e instanceof HTMLImageElement)||!e.Np)return;let i=e.getAttribute("src")||"",s=this.la.get(i);if(s!==null){for(let n=0;n<s.length;n++)if(s[n]===t){s.splice(n,1),s.length===0&&(this.la.delete(i),Bt.vO(e),e.hs instanceof V&&e.hs.delete(this));return}}}nT(){Bt.clearCache(),this.la.clear()}rebuildParts(){this.partManager.rebuildParts()}Kc(t,e){this.Cs.Kc(t,e)}Yc(t,e){this.Cs.Yc(t,e)}findPartForKey(t){return this.partManager.findPartForKey(t)}findNodeForKey(t){return this.partManager.findNodeForKey(t)}findLinkForKey(t){return this.partManager.findLinkForKey(t)}findPartForData(t){return this.partManager.findPartForData(t)}findNodeForData(t){return this.partManager.findNodeForData(t)}findLinkForData(t){return this.partManager.findLinkForData(t)}findNodesByExample(...t){return this.partManager.findNodesByExample(...t)}findLinksByExample(...t){return this.partManager.findLinksByExample(...t)}get nodeTemplate(){return this.jr.get("")}set nodeTemplate(t){let e=this.jr.get("");e!==t&&(this.jr.set("",t),this.t("nodeTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get nodeTemplateMap(){return this.jr}set nodeTemplateMap(t){let e=this.jr;e!==t&&(this.jr=t,this.t("nodeTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get groupTemplate(){return this.uh.get("")}set groupTemplate(t){let e=this.uh.get("");e!==t&&(this.uh.set("",t),this.t("groupTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get groupTemplateMap(){return this.uh}set groupTemplateMap(t){let e=this.uh;e!==t&&(this.uh=t,this.t("groupTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get linkTemplate(){return this.ra.get("")}set linkTemplate(t){let e=this.ra.get("");e!==t&&(this.ra.set("",t),this.t("linkTemplate",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get linkTemplateMap(){return this.ra}set linkTemplateMap(t){let e=this.ra;e!==t&&(this.ra=t,this.t("linkTemplateMap",e,t),this.undoManager.isUndoingRedoing||this.rebuildParts())}get isMouseCaptured(){return this.JM}set isMouseCaptured(t){let e=this.lt;if(e===null)return;let i=e.bt;i instanceof SVGElement||(t?(this.lastInput.bubbles=!1,this.Ae(i,"pointermove",this.wh,!1),this.Ae(i,"pointerdown",this.ha,!1),this.Ae(i,"pointerup",this.xh,!1),this.Ae(i,"pointerout",this.bh,!1),this.Ae(i,"pointercancel",this.kh,!1),this.Et(K,"pointermove",this.wh,!0),this.Et(K,"pointerdown",this.ha,!0),this.Et(K,"pointerup",this.xh,!0),this.Et(K,"pointerout",this.bh,!0),this.Et(K,"pointercancel",this.kh,!0),this.Ae(i,"wheel",this.yh,!1),this.Et(K,"wheel",this.yh,!0),this.Et(K,"selectstart",this.nh,!1)):(this.Ae(K,"pointermove",this.wh,!0),this.Ae(K,"pointerdown",this.ha,!0),this.Ae(K,"pointerup",this.xh,!0),this.Ae(K,"pointerout",this.bh,!0),this.Ae(K,"pointercancel",this.kh,!0),this.Et(i,"pointermove",this.wh,!1),this.Et(i,"pointerdown",this.ha,!1),this.Et(i,"pointerup",this.xh,!1),this.Et(i,"pointerout",this.bh,!1),this.Et(i,"pointercancel",this.kh,!1),this.Ae(K,"wheel",this.yh,!0),this.Ae(K,"selectstart",this.nh,!1),this.Et(i,"wheel",this.yh,!1)),this.JM=t)}get position(){return this.ct}set position(t){if(this.ct.equals(t))return;let e=P.l().h(this.ct),i=this.viewportBounds.copy();if(this.ct.h(t),this.animationManager.IA(e,this.ct),!this.Ht&&!(this.lt===null&&!this.ed.isReal())){this.Ht=!0;let s=this.scale,n=this.wt/s,o=this.xt/s;this.p2(this.np,n,o,this.Jc,!1),this.Ht=!1}else this.ca(),this.kp();if(!this.Ht){let s=this.viewportBounds;this.onViewportBoundsChanged(i,s,this.et,!1)}P.i(e)}get initialPosition(){return this.ob}set initialPosition(t){this.ob.equals(t)||(this.ob=t.C())}get initialScale(){return this.rb}set initialScale(t){this.rb!==t&&(m.s(t,"number",Y,"initialScale"),this.rb=t)}get grid(){return this.ls===null&&(this.ls=this.rT()),this.ls}set grid(t){let e=this.ls;if(e!==t){e===null&&(this.ls=this.rT(),e=this.ls),t.type!==G.Grid&&m.o("Diagram.grid must be a Panel of type Panel.Grid");let i=e.panel;i!==null&&i.remove(e),this.ls=t,t.name="GRID",i!==null&&i.add(t),this._c=!1,this.N(),this.t("grid",e,t)}}get viewportBounds(){return this.zb}ca(){let t=this.zb,e=this.ct,i=this.et;t.e(e.x,e.y,Math.max(this.wt,0)/i,Math.max(this.xt,0)/i),this.Qr()}get viewSize(){return this.ed}set viewSize(t){let e=this.viewSize;if(!e.equals(t)){t=t.C(),this.ed=t;let i=0,s=0;t.isReal()?(i=t.width,s=t.height):this.Mt!==null&&(i=this.Mt.clientWidth||1,s=this.Mt.clientHeight||1),this.wt=i,this.xt=s,this.ca(),this.invalidateDocumentBounds(),this.t("viewSize",e,t),this.N()}}get fixedBounds(){return this.cb}set fixedBounds(t){let e=this.cb;e.equals(t)||((t.width===-1/0||t.height===1/0||t.height===-1/0)&&m.o("fixedBounds width/height must not be Infinity"),t=t.C(),this.cb=t,this.invalidateDocumentBounds(),this.t("fixedBounds",e,t))}get scrollMargin(){return this.ch}set scrollMargin(t){typeof t=="number"&&(t=new Dt(t));let e=this.ch;e.equals(t)||(t=t.C(),this.ch=t,this.t("scrollMargin",e,t),this.Eu())}get scrollMode(){return this.lh}set scrollMode(t){let e=this.lh;e!==t&&(this.lh=t,t===1&&this.$s(!1),this.t("scrollMode",e,t),this.Mh(),this.N())}get scrollsPageOnFocus(){return this.fb}set scrollsPageOnFocus(t){let e=this.fb;e!==t&&(m.s(t,"boolean",Y,"scrollsPageOnFocus"),this.fb=t,this.t("scrollsPageOnFocus",e,t))}get positionComputation(){return this.ub}set positionComputation(t){let e=this.ub;e!==t&&(t!==null&&m.S(t,Y,"positionComputation"),this.ub=t,this.$s(!1),this.t("positionComputation",e,t))}get scaleComputation(){return this.db}set scaleComputation(t){let e=this.db;e!==t&&(t!==null&&m.S(t,Y,"scaleComputation"),this.db=t,this.kT(this.scale,this.scale),this.t("scaleComputation",e,t))}get documentBounds(){return this.np}MT(t){this.gh=!1;let e=this.np;e.equals(t)||(e=e.copy(),this.np.h(t),this.$s(!1),this.T("DocumentBoundsChanged",void 0,e),this.Mh(),this.N())}ensureBounds(){if(this.gh){let t=I.l();this.MT(this.computeBounds(t)),I.i(t)}}get isVirtualized(){return this.Xb}set isVirtualized(t){let e=this.Xb;e!==t&&(m.s(t,"boolean",Y,"isVirtualized"),this.Xb=t,this.t("isVirtualized",e,t))}get scale(){return this.et}set scale(t){let e=this.et;e!==t&&this.kT(e,t)}get defaultScale(){return this.ap}set defaultScale(t){this.ap=t}get autoScale(){return this.na}set autoScale(t){let e=this.na;e!==t&&(this.na=t,this.t("autoScale",e,t),t!==1&&this.$s(!1))}get initialAutoScale(){return this.Rr}set initialAutoScale(t){let e=this.Rr;e!==t&&(this.Rr=t,this.t("initialAutoScale",e,t))}get initialViewportSpot(){return this.pb}set initialViewportSpot(t){let e=this.pb;e!==t&&(t.isSpot()||m.o("initialViewportSpot must be a specific Spot: "+t),this.pb=t,this.t("initialViewportSpot",e,t))}get initialDocumentSpot(){return this.gb}set initialDocumentSpot(t){let e=this.gb;e!==t&&(t.isSpot()||m.o("initialViewportSpot must be a specific Spot: "+t),this.gb=t,this.t("initialDocumentSpot",e,t))}get minScale(){return this.lb}set minScale(t){let e=this.lb;e!==t&&(t>0?(this.lb=t,this.t("minScale",e,t),t>this.scale&&(this.scale=t)):m.J(t,"> 0",Y,"minScale"))}get maxScale(){return this.ab}set maxScale(t){let e=this.ab;e!==t&&(t>0?(this.ab=t,this.t("maxScale",e,t),t<this.scale&&(this.scale=t)):m.J(t,"> 0",Y,"maxScale"))}get zoomPoint(){return this.hb}set zoomPoint(t){this.hb.equals(t)||(t=t.C(),this.hb=t)}get contentAlignment(){return this.Jc}set contentAlignment(t){let e=this.Jc;e.equals(t)||(t=t.C(),this.Jc=t,this.t("contentAlignment",e,t),this.$s(!1))}get initialContentAlignment(){return this.Qm}set initialContentAlignment(t){let e=this.Qm;e.equals(t)||(t=t.C(),this.Qm=t,this.t("initialContentAlignment",e,t))}get padding(){return this.Qt}set padding(t){typeof t=="number"&&(t=new Dt(t));let e=this.Qt;e.equals(t)||(t=t.C(),this.Qt=t,this.invalidateDocumentBounds(),this.t("padding",e,t))}get partManager(){return this.t2}set partManager(t){let e=this.t2;e!==t&&(t.diagram!==null&&m.o("Cannot share PartManagers between Diagrams: "+t.toString()),e&&e.Io(null),this.t2=t,t.Io(this))}get nodes(){return this.partManager.nodes.iterator}get links(){return this.partManager.links.iterator}get parts(){return this.partManager.parts.iterator}findTopLevelNodesAndLinks(){let t=new V,e=this.nodes;for(;e.next();){let s=e.value;s.isTopLevel&&t.add(s)}let i=this.links;for(;i.next();){let s=i.value;s.isTopLevel&&t.add(s)}return t.iterator}findTopLevelGroups(){return this.$r.iterator}get routers(){return this.rf}doLinkRouting(t){this.Uo=!0;let e=this.rf.r;for(let i=0;i<e.length;i++)e[i].canRoute(t)&&e[i].routeLinks(this.Or,t);this.Uo=!1}get layout(){return this.li}set layout(t){let e=this.li;e!==t&&(this.li=t,t.diagram=this,t.group=null,this.Jr=!0,this.t("layout",e,t),this.requestUpdate())}layoutDiagram(t){this.De(),t&&this.o1(!0),this.As?this.k2(!1,this.Ol||this.rf.count!==0&&this._n.size!==0):(this.Zc=!0,this.Pr())}o1(t){let e=this.$r.iterator;for(;e.next();)this.CT(e.value,t);this.layout&&(t?this.layout.isValidLayout=!1:this.layout.p())}CT(t,e){if(t===null)return;let i=t.Ch.iterator;for(;i.next();){let s=i.value;this.CT(s,e)}t.layout!==null&&(e?t.layout.isValidLayout=!1:t.layout.p())}k2(t,e){if(this.Cb)return;let i=this.G;this.G=!0;let s="Layout",n=this.undoManager.transactionLevel,o=this.layout,r=this.animationManager;try{n===0&&(this.undoManager.Fl=!0,this.startTransaction(s)),n<=1&&!r.defaultAnimation.isAnimating&&!r.Pe&&(t||r.Kl(s)),this.Jr=!1;let a=this.$r.iterator;for(;a.next();)this.fd(a.value),this.NT(a.value,t,n,e);let h=!1;if(o.isValidLayout||(!t||o.isRealtime||o.isRealtime===null||n===0?(o.doLayout(this),this.fd(this),h=!0,o.isValidLayout=!0):this.Jr=!0),h||this.fd(this),this.doLinkRouting(this),this.Or.clear(),this.fh.size!==0){for(let l=0;l<23&&this.fh.size!==0;l++){for(a=this.$r.iterator;a.next();)this.LT(a.value);let u=this.Or;this.Or=this.fh,this.fh=u,this.fd(this),this.doLinkRouting(this)}this.Or.clear(),this.fh.clear()}}finally{let a=this.undoManager.Fl;n===0&&(this.commitTransaction(s),this.undoManager.Fl=!1),a&&(n===0||n===1)&&r.kM(),this.Jr&&(this.Jr=!o.isValidLayout),this.G=i}}NT(t,e,i,s){let n=t.Ch.iterator;for(;n.next();)this.NT(n.value,e,i,s);let o=t.layout;o!==null&&!o.isValidLayout?!e||o.isRealtime||i===0?(t.Nh=!t.location.isReal(),o.doLayout(t),t.invalidateLayout(32),this.e1(t),this.fd(t),this.doLinkRouting(t),o.isValidLayout=!0):(this.doLinkRouting(t),this.Jr=!0):s&&this.doLinkRouting(t)}LT(t){let e=t.Ch.iterator;for(;e.next();)this.LT(e.value);this.fd(t),this.doLinkRouting(t)}get isTreePathToChildren(){return this.yb}set isTreePathToChildren(t){let e=this.yb;if(e!==t&&(m.s(t,"boolean",Y,"isTreePathToChildren"),this.yb=t,this.t("isTreePathToChildren",e,t),!this.undoManager.isUndoingRedoing)){let i=this.nodes;for(;i.next();)i.value.Lp()}}findTreeRoots(){let t=new q,e=this.nodes;for(;e.next();){let i=e.value;i.isTopLevel&&i.findTreeParentLink()===null&&t.add(i)}return t.iterator}get treeCollapsePolicy(){return this.wb}set treeCollapsePolicy(t){let e=this.wb;e!==t&&(t!==1&&t!==2&&t!==3&&m.o("Unknown Diagram.treeCollapsePolicy: "+t),this.wb=t,this.t("treeCollapsePolicy",e,t))}get isCollapsingExpanding(){return this.zM}set isCollapsingExpanding(t){this.zM=t}_R(){let t=new Mt,e=new Mt;function i(s){let n=s.toLowerCase(),o=new q;t.set(s,o),t.set(n,o),e.set(s,s),e.set(n,s)}i("InitialAnimationStarting"),i("AnimationStarting"),i("AnimationFinished"),i("BackgroundSingleClicked"),i("BackgroundDoubleClicked"),i("BackgroundContextClicked"),i("ClipboardChanged"),i("ClipboardPasted"),i("DocumentBoundsChanged"),i("ExternalObjectsDropped"),i("FocusOrVirtualPointerEnabledChanged"),i("GainedFocus"),i("InitialLayoutCompleted"),i("LayoutCompleted"),i("LinkDrawn"),i("LinkRelinked"),i("LinkReshaped"),i("LostFocus"),i("Modified"),i("ObjectSingleClicked"),i("ObjectDoubleClicked"),i("ObjectContextClicked"),i("PartCreated"),i("PartResized"),i("PartRotated"),i("SelectionMoved"),i("SelectionCopied"),i("SelectionDeleting"),i("SelectionDeleted"),i("SelectionGrouped"),i("SelectionUngrouped"),i("ChangingSelection"),i("ChangedSelection"),i("SubGraphCollapsed"),i("SubGraphExpanded"),i("TextEdited"),i("ThemeChanged"),i("TreeCollapsed"),i("TreeExpanded"),i("ViewportBoundsChanged"),i("InvalidateDraw"),this.VM=t,this.BM=e}fT(t){let e=this.BM.get(t);return e!==null?e:this.BM.get(t.toLowerCase())}R2(t){let e=this.VM.get(t);if(e!==null)return e;let i=t.toLowerCase();if(e=this.VM.get(i),e!==null)return e;m.o("Unknown DiagramEvent name: "+t)}addDiagramListener(t,e){m.s(t,"string",Y,"addDiagramListener:name"),m.S(e,Y,"addDiagramListener:listener");let i=this.R2(t);return i!==null&&i.add(e),this}removeDiagramListener(t,e){m.s(t,"string",Y,"removeDiagramListener:name"),m.S(e,Y,"addDiagramListener:listener");let i=this.R2(t);i!==null&&i.delete(e)}raiseDiagramEvent(t,e,i){this.T(t,e,i)}T(t,e,i){let s=this.R2(t),n=new wi;n.diagram=this;let o=this.fT(t);o!==null&&(n.name=o),e!==void 0&&(n.subject=e),i!==void 0&&(n.parameter=i);let r=s.length;if(r===1)s.elt(0)(n);else if(r!==0){let a=s.toArray();for(let h=0;h<r;h++){let l=a[h];l(n)}}}isUnoccupied(t,e){return this.getPositions(!1,null,e||null).isUnoccupied(t.x,t.y,t.width,t.height)}computeOccupiedArea(t){return this.isVirtualized?this.viewportBounds.copy():this.gh?this.aT(t):t.h(this.documentBounds)}getPositions(t,e,i){let s=this.oa;s===null&&(this.oa=s=new Ot(this.avoidanceCellSize));let n=e;if(s.Yo||s.Lh!==n||s.O2!==i){if(s.I2=Math.max(s.cf+1,Math.floor(this.avoidanceLimit/this.avoidanceCellSize.width)),s.E2=Math.max(s.cf+1,Math.floor(this.avoidanceLimit/this.avoidanceCellSize.height)),n!==null&&(n=this.AT(n)),n===null){let o=I.l();this.computeOccupiedArea(o),o.inflate(100,100),s.l1(o);let r=this.nodes;for(;r.next();){let a=r.value,h=a.layer;h===null||!h.visible||h.isTemporary||this.U2(a,i,o)}I.i(o)}else{if(n.memberParts.count>0){let a=this.computePartsBounds(n.memberParts,!1);a.inflate(20,20),s.l1(a)}let o=I.l(),r=n.memberParts;for(;r.next();){let a=r.value;a instanceof $&&this.U2(a,i,o)}I.i(o)}s.Lh=n,s.O2=i,s.Yo=!1}else t&&s.TT();return s}get avoidanceCellSize(){return this.$M}set avoidanceCellSize(t){this.oa=null,this.$M=new nt(Math.max(1,t.width),Math.max(1,t.height))}get avoidanceLimit(){return this.ZM}set avoidanceLimit(t){this.ZM=Math.max(1,t)}AT(t){return t.canAvoid()?t:t.containingGroup!==null?this.AT(t.containingGroup):null}U2(t,e,i){if(t===e||!t.isVisible())return;let s=t.canAvoid();if(s){let n=t.getAvoidableRect(i);this.oa.FO(n.x,n.y,n.width,n.height)}if(t instanceof ht&&(!s||t.avoidableMembers)){let n=t.memberParts;for(;n.next();){let o=n.value;o instanceof $&&this.U2(o,e,i)}}}ud(t){this.oa!==null&&!this.oa.Yo&&(t===void 0||t.canAvoid())&&(this.oa.Yo=!0)}get autoScrollInterval(){return this._m}set autoScrollInterval(t){let e=this._m;e!==t&&(this._m=t,this.t("autoScrollInterval",e,t))}get autoScrollRegion(){return this.tp}set autoScrollRegion(t){typeof t=="number"&&(t=new Dt(t));let e=this.tp;e.equals(t)||(t=t.C(),this.tp=t,this.invalidateDocumentBounds(),this.t("autoScrollRegion",e,t))}doAutoScroll(t){this.rp.h(t);let e=P.l();this.computeAutoScrollPosition(this.rp,e).equalsApprox(this.position)?this.stopAutoScroll():this.DT(),P.i(e)}DT(){if(this.$c!==-1)return;let t=this._m,e=this;this.$c=m.dn(()=>{if(e.$c===-1||(e.stopAutoScroll(),e.lastInput.event===null))return;let i=P.l(),s=e.computeAutoScrollPosition(e.rp,i);if(!s.equalsApprox(e.position)){e.position=s,e.lastInput.documentPoint=e.transformViewToDoc(e.rp),e.doMouseMove(),e.gh=!0;let n=I.l();e.computeBounds(n),n.unionRect(e.documentBounds),e.MT(n),I.i(n),e.Wi=!0,e.maybeUpdate(),e.DT()}P.i(i)},t)}stopAutoScroll(){this.$c!==-1&&(m.yc(this.$c),this.$c=-1)}computeAutoScrollPosition(t,e){let i=this.position;e===void 0&&(e=new P),e.h(i);let s=this.tp;if(s.top<=0&&s.left<=0&&s.right<=0&&s.bottom<=0)return e;let n=this.viewportBounds,o=this.scale,r=I.z(0,0,n.width*o,n.height*o),a=P.z(0,0);if(t.x>=r.x&&t.x<r.x+s.left&&this.allowHorizontalScroll){let h=Math.max(this.scrollHorizontalLineChange,1);h=h|0,a.x-=h,t.x<r.x+s.left/2&&(a.x-=h),t.x<r.x+s.left/4&&(a.x-=4*h)}else if(t.x<=r.x+r.width&&t.x>r.x+r.width-s.right&&this.allowHorizontalScroll){let h=Math.max(this.scrollHorizontalLineChange,1);h=h|0,a.x+=h,t.x>r.x+r.width-s.right/2&&(a.x+=h),t.x>r.x+r.width-s.right/4&&(a.x+=4*h)}if(t.y>=r.y&&t.y<r.y+s.top&&this.allowVerticalScroll){let h=Math.max(this.scrollVerticalLineChange,1);h=h|0,a.y-=h,t.y<r.y+s.top/2&&(a.y-=h),t.y<r.y+s.top/4&&(a.y-=4*h)}else if(t.y<=r.y+r.height&&t.y>r.y+r.height-s.bottom&&this.allowVerticalScroll){let h=Math.max(this.scrollVerticalLineChange,1);h=h|0,a.y+=h,t.y>r.y+r.height-s.bottom/2&&(a.y+=h),t.y>r.y+r.height-s.bottom/4&&(a.y+=4*h)}return a.equalsApprox(P.gn)||(e.x=i.x+a.x/o,e.y=i.y+a.y/o),I.i(r),P.i(a),e}makeSvg(t){this.zo.has("SVG")||this.addRenderer("SVG",new ui(this,K.document));let e=new ui(this,K.document,!0);t===void 0&&(t={});let i=this;function s(n,o){let r=i.vT(n,"SVG",e),a=r!==null?r.svg:null,h=n.svgFinished;return a&&h&&h(a),m.it(o)?(o(a),null):a}return this.FT(s,t)}makeSVG(t){return this.makeSvg(t)}addRenderer(t,e){this.zo.set(t,e)}removeRenderer(t){this.zo.delete(t)}cacheGroupExternalLinks(t){this.c2=t,t||this.nodes.each(e=>{e instanceof ht&&(e.Ap=null)})}FT(t,e){let i=e.callback,s=!0,n=this.la.iterator;for(;n.next();)if(!n.value[0].Mn){s=!1;break}if(!m.it(i)||s)return t(e,i,this);let o=this;function r(){let l=+new Date;for(s=!0,n.reset();n.next();)if(!n.value[0].Mn){s=!1;break}if(s||l-h>a){t(e,i,o);return}K.requestAnimationFrame(r)}let a=e.callbackTimeout||300,h=+new Date;return K.requestAnimationFrame(()=>r()),null}makeImage(t){return Y.isUsingDOM()?(t===void 0&&(t={}),t.returnType="Image",this.makeImageData(t)):null}makeImageData(t){return t===void 0&&(t={}),this.FT(this.RO,t)}static img="image";RO(t,e,i){let s=i.vT(t,"canvas",null);if(s===null)return null;let n=s.F.canvas,o=null;if(n!==null){let r=t.returnType;switch(r===void 0?r="string":r=r.toLowerCase(),r){case Y.img+"data":o=s.getImageData(0,0,n.width,n.height);break;case Y.img:let a=(t.document||document).createElement("img");a.src=n.toDataURL(t.type,t.details),o=a;break;case"blob":{let h=n;return m.it(e)||(o="",m.o('Error: Diagram.makeImageData called with "returnType: toBlob", but no required "callback" function property defined.')),m.it(h.toBlob)?(h.toBlob(e,t.type,t.details),"toBlob"):(e(null),null)}case"string":default:o=n.toDataURL(t.type,t.details)}}return m.it(e)?(e(o),null):o}static OO=!1;vT(t,e,i){this.animationManager.stopAnimation(),this.maybeUpdate(),m.$(t)||m.o("properties argument must be an Object.");let s=!1,n=t.size||null,o=t.scale||null;t.scale!==void 0&&isNaN(t.scale)&&(o="NaN");let r=t.maxSize;t.maxSize===void 0&&(s=!0,e==="SVG"?r=new nt(1/0,1/0):r=new nt(2e3,2e3));let a=t.position||null,h=t.parts||null;Array.isArray(h)&&(h=new q(h));let l=t.padding===void 0?1:t.padding,u=t.background||null,c=t.omitTemporary;c===void 0&&(c=!0);let d=t.document||K.document,f=t.elementFinished||null,p=t.showTemporary;p===void 0&&(p=!c);let g=t.showGrid;g===void 0&&(g=p),n!==null&&isNaN(n.width)&&isNaN(n.height)&&(n=null),typeof l=="number"?l=new Dt(l):l instanceof Dt||m.o("MakeImage padding must be a Margin or a number."),l.left=Math.max(l.left,0),l.right=Math.max(l.right,0),l.top=Math.max(l.top,0),l.bottom=Math.max(l.bottom,0),this.Wt&&this.Wt.clearContextCache(!0);let y=new De(null,d,void 0,!0),b=y._t;if(!(n||o||h||a))return y.width=this.wt+Math.ceil(l.left+l.right),y.height=this.xt+Math.ceil(l.top+l.bottom),e==="SVG"?i===null?null:(i.resize(y.width,y.height,y.width,y.height),i.el=d,i.dd=f,this.i1(i._t,l,new nt(y.width,y.height),this.et,this.ct,h,u,p,g),i._t):(this.nd=!1,this.i1(b,l,new nt(y.width,y.height),this.et,this.ct,h,u,p,g),this.nd=!0,y._t);let v=this.ap,w=this.documentBounds.copy();if(w.subtractMargin(this.Qt),p){let F=this.Vt.r,O=F.length;for(let E=0;E<O;E++){let B=F[E];if(!B.visible||!B.isTemporary)continue;let X=B.Ct.r,z=X.length;for(let U=0;U<z;U++){let tt=X[U];if(!tt.isInDocumentBounds||!tt.isVisible())continue;let st=tt.actualBounds;st.isReal()&&w.unionRect(st)}}}let k=new P(w.x,w.y);if(h!==null){let F=new I(0,0,0,0),O=!0,E=h.iterator;for(E.reset();E.next();){let B=E.value;if(!(B instanceof pt))continue;let X=B.layer;if(X!==null&&!X.visible||X!==null&&!p&&X.isTemporary||!B.isVisible())continue;let z=B.actualBounds;z.isReal()&&(O?(O=!1,F.h(z)):F.unionRect(z))}w.width=F.width,w.height=F.height,k.x=F.x,k.y=F.y}a!==null&&a.isReal()&&(k=a,o||(o=v));let S=0,N=0;l!==null&&(S=l.left+l.right,N=l.top+l.bottom);let D=0,L=0;n!==null&&(D=n.width,L=n.height,isFinite(D)&&(D=Math.max(0,D-S)),isFinite(L)&&(L=Math.max(0,L-N)));let M=0,A=0;if(n!==null&&o!==null?(o==="NaN"&&(o=v),n.isReal()?(M=D,A=L):isNaN(L)?(M=D,A=w.height*o):(M=w.width*o,A=L)):n!==null?n.isReal()?(o=Math.min(D/w.width,L/w.height),M=D,A=L):isNaN(L)?(o=D/w.width,M=D,A=w.height*o):(o=L/w.height,M=w.width*o,A=L):o!==null?o==="NaN"&&r.isReal()?(o=Math.min((r.width-S)/w.width,(r.height-N)/w.height),o>v?(o=v,M=w.width,A=w.height):(M=r.width,A=r.height)):(M=w.width*o,A=w.height*o):(o=v,M=w.width,A=w.height),l!==null?(M+=S,A+=N):l=new Dt(0),r!==null){let F=r.width,O=r.height;e!=="SVG"&&s&&Y.OO,isNaN(F)&&(F=2e3),isNaN(O)&&(O=2e3),isFinite(F)&&(M=Math.min(M,F)),isFinite(O)&&(A=Math.min(A,O))}return y.width=Math.ceil(M),y.height=Math.ceil(A),e==="SVG"?i===null?null:(i.resize(y.width,y.height,y.width,y.height),i.el=d,i.dd=f,this.i1(i._t,l,new nt(Math.ceil(M),Math.ceil(A)),o,k,h,u,p,g),i._t):(this.nd=!1,this.i1(b,l,new nt(Math.ceil(M),Math.ceil(A)),o,k,h,u,p,g),this.nd=!0,y._t)}static Sh=null;static V2="5da73c80a36555d5038e4972187c3cae51fd22";static IO="5da73c80a36555d503aa5c72106c30b35bb2006b9cd041b259";static Yw=!1;static DP=()=>{if(Y.V2[5]===void 0&&(Nt.prototype.Ni=Nt.prototype.Mu),!Y.isUsingDOM())return;let t=m.Ci("canvas");t.width=350;let e=t.getContext("2d"),i=m.We("7ca11abfd022028846"),s="7ca11abfd7330390",n=[Y.V2,m.Yw+"4ae6247590da4bb21c324ba3a84e385776",Nt.DP+"fb236cdfda5de14c134ba1a95a2d4c7cc6f93c1387",C.za];e.scale(2,2);let o=8;for(let r=1;r<5;r++)e[m.We(s)](m.We(n[r-1]),o,r*15);e[i]=m.We("39f046ebb36e4b");for(let r=1;r<5;r++)e[m.We(s)](m.We(n[r-1]),o,r*15);(n.length!==4||n[0][0]!=="5"||n[3][0]!=="7")&&(Nt.prototype.Ni=Nt.prototype.Mu),Y.Sh=t};static EO=()=>{if(Y.V2[5]===void 0&&(Nt.prototype.Ni=Nt.prototype.Mu),!Y.isUsingDOM())return;let t=m.Ci("canvas"),e=t.getContext("2d"),i=m.We("7ca11abfd022028846"),s="7ca11abfd7330390",n=[Y.IO,C.za],o=5;e.scale(2,2);for(let r=1;r<3;r++)e[m.We(s)](m.We(n[r-1]),o,r*11);e[i]=m.We("39f046ebb36e4b");for(let r=1;r<3;r++)e[m.We(s)](m.We(n[r-1]),o,r*11);(n.length!==2||n[0][0]!=="5")&&(Nt.prototype.Ni=Nt.prototype.Mu),Y.Sh=t}}class Fn{RT;OT;B2;bi;constructor(t){if(this.RT=null,this.OT="63ad05bbe23a1786468a4c741b6d2",this.B2="@onz",this.OT===this._tk){this.B2=!0,this.bi=this.B2;return}this.bi=null}UO(t,e){let i="f",s=K[m.We("76a715b2f73f148a")][m.We("72ba13b5")]||"",n=m.We;if(this.bi=!0,!Y.isUsingDOM())return;let o=Y[n("76a115b6ed251eaf4692")];if(!o){let a=s[n("76ad18b4f73e")];for(let l=s[n("73a612b6fb191d")](n("35e7"))+2;l<a;l++)i+=s[l];let h=i[n("73a612b6fb191d")](n("7da71ca0ad381e90"));this.bi=!(h>=0&&h<i[n("73a612b6fb191d")](n("35")));return}let r=Y.D2.iterator;for(;r.next();){o=r.value;let a=n(o).split(n("39e9")),h=a.length===7?1:0;if(a.length===1&&o.includes(n("5b8b3797c61b32a7"))){if(Y.EO(),!t.lt)return;t.hp=t.lt._t.F[m.We("7eba17a4ca3b1a8346")][m.We("78a118b7")](t.lt._t.F,Y.Sh,4,4)}if(a.length<6)return;let l=n(a[1+h]).split(".");if(a[4+h]!=="7da71ca0")return;let u=n(m[n("6cae19")]).split(".");if(!(l[0]>u[0]||l[0]===u[0]&&l[1]>=u[1]))continue;let c="73a612b6fb191d",d=K[n("74a900bae4370f8b51")][n("6fbb13a1c2311e8a57")].toLowerCase(),f=d[n(c)](n("3aad1ab6e022098b4dc4")),p=n(a[2+h]);if(f>-1){let M=d[n(c)](p.toLowerCase()+"/");if(this.bi=!(M>-1&&M<f),!this.bi)return}let g=s[n("76ad18b4f73e")];for(let M=s[n(c)](n("35e7"))+2;M<g;M++)i+=s[M];let y=i[n(c)](p);if(y<0&&p!==n("7da71ca0ad381e90")&&(y=i[n(c)](n("76a715b2ef3e149757"))),y<0&&(y=i[n(c)](n("76a715b2ef3e149757"))),y<0&&(y=i[n(c)](n("2bfa41fdb3784bca12"))),y<0&&(y=s[n(c)](n("7baa19a6f76c1988428554"))),y<0&&(y=s[n(c)](n("7ea902b2b9221e9c57c45767196566"))),this.bi=!(y>=0&&y<i[n(c)](n("35"))||i[n(c)](n("35"))===-1),!this.bi||s[n(c)](n("7fb002b6ed25128b4da25b2e"))&&(this.bi=!(s[n(c)](p)>-1),!this.bi))return;let b=K[m.We("76a715b2f73f148a")][m.We("69ad17a1e03e")],v=b[n(c)](n("7fb002b6ed25128b4da25b2e"));if(v>-1&&(this.bi=!(b[n(c)](p)>v),!this.bi))return;let w=p;if(w[0]!=="#")continue;let k=m.Ci("div"),S=a[0+h].replace(/[A-Za-z]/g,"");for(;S.length<4;)S+="9";let N=S;S=S.substring(S.length-4);let D=parseInt(u[0]),L=parseInt(u[1]);if(D>3||D===3&&L>=1){let M=parseInt(N)%40+30,A=parseInt(w.substring(1,5),16);if(j.IT===M+A){this.bi=!1;return}}else{let M="",A=["gsh","gsf"],F=["Header","Background","Display","Feedback"];if(M+=A[parseInt(S.substring(0,1),10)%2],M+=F[parseInt(S.substring(0,1),10)%4],k[n("79a417a0f0181a8946")]=M,K.document[n("78a712aa")]){K.document[n("78a712aa")][n("7bb806b6ed32388c4a875b")](k);let O=K.getComputedStyle(k).getPropertyValue(n("78a704b7e62456904c9b12701b6532a8")),E=K.getComputedStyle(k).getPropertyValue(n("75b817b0ea2202"));if(K.document[n("78a712aa")][n("68ad1bbcf533388c4a875b")](k),!O)continue;let B=K[n("77a902b0eb1b1e804a8a")],X="0."+parseInt(N,10)%100;if(E===X||O.indexOf(parseInt(w[1]+w[2],16).toString())!==-1&&O.indexOf(parseInt(w[3]+w[4],16).toString())!==-1){this.bi=!1;return}else if(B&&B(n("32ae19a1e0331fc94084537c067a67fa59f1386b89d006")).matches){M="."+M;for(let z=0;z<K.document.styleSheets.length;z++){let U=K.document.styleSheets[z].rules||K.document.styleSheets[z].cssRules;for(let tt in U)if(M===U[tt].selectorText){this.bi=!1;return}}}}else this.bi=null,e&&(this.bi=!1)}}}Sh(t,e){return e.setTransform(t.$e/2,0,0,t.$e/2,0,0),e.commitTransform(),this.bi===null&&this.UO(t,!0),0<this.bi&&this!==this.RT}}class Xe{z2;X2;constructor(t){this.z2=t===void 0?new P:t,this.X2=new P}get point(){return this.z2}set point(t){this.z2=t}get shifted(){return this.X2}set shifted(t){this.X2=t}}class On{Ri;pT;s1;constructor(t,e,i){this.Ri=t,this.pT=e,this.s1=i}}class Pi{isGridSnapEnabled;isGridSnapRealtime;gridSnapCellSize;gridSnapCellSpot;gridSnapOrigin;dragsLink;dragsTree;groupsSnapMembers;groupsAlwaysMove;dragsMembers;constructor(t){this.Ue(),t&&Object.assign(this,t)}Ue(){this.isGridSnapEnabled=!1,this.isGridSnapRealtime=!0,this.gridSnapCellSize=new nt(NaN,NaN).k(),this.gridSnapCellSpot=T.TopLeft,this.gridSnapOrigin=new P(NaN,NaN).k(),this.dragsLink=!1,this.dragsTree=!1,this.groupsSnapMembers=!1,this.groupsAlwaysMove=!0,this.dragsMembers=!0}}class Rn extends Y{constructor(t,e){let i;return t===void 0||typeof t=="string"||K.Element&&t instanceof Element?i=t:m.$(t)&&(e=t),super(i),this.ET(),e&&this.setProperties(e),this}ET(){this.allowDragOut=!0,this.allowMove=!1,this.isReadOnly=!0,this.contentAlignment=T.TopCenter,this.layout=new Ye}setupRouters(){}reset(){super.reset(),this.ET()}}class hi extends Y{a1;h1;c1;f1;Tp;ff;Xl;G2;Y2;u1;K2;constructor(t,e){let i;return t===void 0||typeof t=="string"||K.Element&&t instanceof Element?i=t:m.$(t)&&(e=t),super(i),this.animationManager.isEnabled=!1,this.Ht=!0,this.a1=null,this.Qu=!1,this._u=!1,this.h1=!0,this.c1=!0,this.f1=0,this.Tp=!1,this.ff=null,this.setRenderingHint("drawShadows",!1),this.Xl=new pt({selectable:!0,selectionAdorned:!1,selectionObjectName:"BOXSHAPE",locationObjectName:"BOXSHAPE",resizeObjectName:"BOXSHAPE",cursor:"move"}).add(new it({name:"BOXSHAPE",fill:"transparent",stroke:"magenta",strokeWidth:2}).theme("stroke","overviewBox")).It(),this.allowCopy=!1,this.allowDelete=!1,this.allowDrop=!1,this.allowSelect=!0,this.autoScrollRegion=new Dt(0,0,0,0),this.ct.e(0,0),this.toolManager.Jt("Dragging",new En,this.toolManager.mouseMoveTools),this.click=()=>{let s=this.observed;if(s===null)return;let n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new P(o.x-n.width/2,o.y-n.height/2)},this.G2=s=>{this.invalidateDocumentBounds(),this.Dp()},this.Y2=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.N())},this.u1=s=>{this.updateDelay<1?this.N():this.Tp||(this.Tp=!0,m.dn(()=>this.redraw(),this.updateDelay))},this.K2=s=>{this.observed!==null&&this.Dp()},this.autoScale=2,this.Ht=!1,e&&this.setProperties(e),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.Tp&&this.updateDelay>=1&&(this.Tp=!1,this.VO()),super.redraw()}Ge(){if(this.Mt===null&&m.o("No div specified"),this.lt===null&&m.o("No canvas specified"),this.lt instanceof ui||(this.box.EM(),!this.Wi))return;let t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.Za)return;this.Sp();let e=this.lt,i=this.Wt;if(i.clearContextCache(!0),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),this.updateDelay<1)this.UT();else if(this.ff!==null){i.drawImage(this.ff.bt,0,0);let o=this.v;i.scale(this.$e,this.$e),i.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),i.commitTransform()}let s=this.Vt.r,n=s.length;for(let o=0;o<n;o++)s[o].Ge(i,this);this.ef=!1,this.Wi=!1}VO(){let t=this.lt,e=this.Wt;if(!(t===null||e===null)){if(this.Sp(),this.ff===null){let i=new De(null);i.width=t.width,i.height=t.height,this.ff=i}try{this.lt=this.ff,this.Wt=this.lt._t,this.Wt.clearContextCache(!0),this.Wt.setTransform(1,0,0,1,0,0),this.Wt.clearRect(0,0,this.lt.width,this.lt.height),this.UT()}finally{this.lt=t,this.Wt=e}}}UT(){let t=this.observed;if(t===null)return;let e=this.drawsTemporaryLayers,i=this.drawsGrid&&e,s=t.grid;if(i&&s!==null&&s.visible&&!(isNaN(s.width)||isNaN(s.height))){let u=I.l().h(this.viewportBounds).unionRect(t.viewportBounds);t.P2(u),I.i(u),t.De()}let n=this.v,o=this.Wt;o.scale(this.$e,this.$e),o.transform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),o.commitTransform();let r=this.viewportBounds,a=t.Vt.r,h=a.length,l=this.Vt.r;this.rs(l,l.length,this,this.viewportBounds);for(let u=0;u<h;u++)a[u].UR(o,r,this,e,i)}get observed(){return this.a1}set observed(t){let e=this.a1;if(t!==null&&m.se(t,Y,hi,"observed"),t instanceof hi&&m.o("Overview.observed Diagram may not be an Overview itself: "+t),e!==t){if(e!==null&&this.BO(e),this.a1=t,t!==null&&this.zO(t),this.invalidateDocumentBounds(),t===null){this.ff=null;let i=this.lt,s=this.Wt;i&&s&&(s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,i.width,i.height))}else this.u1(null),this.Dp(),this.N();this.t("observed",e,t)}}get box(){return this.Xl}set box(t){let e=this.Xl;e!==t&&(t.It(),this.Xl=t,this.remove(e),this.add(this.Xl),this.Dp(),this.t("box",e,t))}get drawsTemporaryLayers(){return this.h1}set drawsTemporaryLayers(t){this.h1!==t&&(this.h1=t,this.redraw())}get drawsGrid(){return this.c1}set drawsGrid(t){this.c1!==t&&(this.c1=t,this.redraw())}get updateDelay(){return this.f1}set updateDelay(t){t<0&&(t=0),this.f1!==t&&(this.f1=t)}zO(t){t!==null&&(t.addDiagramListener("ViewportBoundsChanged",this.G2),t.addDiagramListener("DocumentBoundsChanged",this.Y2),t.addDiagramListener("InvalidateDraw",this.u1),t.addDiagramListener("AnimationFinished",this.K2),this.add(this.box))}BO(t){t!==null&&(this.remove(this.box),t.removeDiagramListener("ViewportBoundsChanged",this.G2),t.removeDiagramListener("DocumentBoundsChanged",this.Y2),t.removeDiagramListener("InvalidateDraw",this.u1),t.removeDiagramListener("AnimationFinished",this.K2))}Dp(){let t=this.box,e=this.observed;if(e===null)return;this.Wi=!0;let i=e.viewportBounds,s=t.selectionObject,n=nt.l();n.e(i.width,i.height),s.desiredSize=n,nt.i(n);let o=2/this.scale;s instanceof it&&(s.strokeWidth=o),t.location=new P(i.x-o/2,i.y-o/2),t.isSelected=!0}computeBounds(){let t=this.observed;if(t===null)return I.tm;let e=t.documentBounds.copy();return e.unionRect(t.viewportBounds),e}invalidateViewport(t,e){this.Wi!==!0&&(this.Wi=!0,this.requestUpdate())}onViewportBoundsChanged(t,e,i,s){this.Ht||(this.Qr(),this.N(),this.Mh(),this.invalidateDocumentBounds(),this.Dp(),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t))}}class En extends Tt{ua;constructor(){super(),this.ua=P.mn}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||!t.allowMove||!t.allowSelect)return!1;let e=t.observed;if(e===null)return!1;let i=t.lastInput;if(!i.left||t.currentTool!==this&&(!this.isBeyondDragSize()||i.isTouchEvent&&i.timestamp-t.firstInput.timestamp<this.delay))return!1;if(this.findDraggablePart()===null){let s=e.viewportBounds;this.ua=new P(s.width/2,s.height/2);let n=t.firstInput.documentPoint;e.position=new P(n.x-this.ua.x,n.y-this.ua.y)}return!0}doActivate(){this.ua=P.mn,super.doActivate()}doUpdateCursor(t){let e=this.diagram,i=e.box;i!==null&&i.cursor&&(e.currentCursor=i.cursor)}moveParts(t,e,i){i===void 0&&(i=!1);let s=this.diagram,n=s.observed;if(n===null)return;let o=s.box;if(o===null)return;if(!this.ua.isReal()){let a=s.firstInput.documentPoint,h=o.location;this.ua=new P(a.x-h.x,a.y-h.y)}let r=s.lastInput.documentPoint;n.position=new P(r.x-this.ua.x,r.y-this.ua.y)}}class jt{a;d1="go._clipboard";g1="go._clipboardFormat";H2;q2;j2;W2;J2;$2;Z2;Q2;_2;da;tC;m1;p1;w1;b1;eC;Ko;iC;sC;vp;nC;k1;oC;P1;rC;lC;gd;Fp;Rp;aC;Qc;hC;cC;fC;uC;dC;md;gC;Oi;Ps;S1;Op;static pd=["Ctrl","Shft","Alt","Meta"];static VT=jt.mC(230,40,15);static XO=jt.mC(270,40,15);static GO=jt.mC(310,40,15);constructor(t){V.Je(this),this.a=Y.Fm(),this.H2=!0,this.q2=!0,this.j2=!0,this.W2=!1,this.J2=!1,this.$2=!1,this.Z2=!1,this.Q2="memory",this._2=null,this.da=null,this.tC=1.05,this.m1=NaN,this.p1=P.mn,this.w1=NaN,this.b1=I.tm,this.eC=!1,this.Ko=null,this.iC=200,this.sC=!1,this.vp=new vt("Auto",{layerName:"Tool",pickable:!1,selectable:!1}).add(new G("Spot").add(new it({name:"SHAPE",fill:null,stroke:"lime",strokeWidth:4}).bindObject("stroke","adornedPart",e=>e.isSelected?"darkcyan":"lime"),new it({name:"SHAPE2",stretch:2,fill:null,stroke:"magenta",strokeWidth:4,strokeDashArray:[4,4]})),new ue({padding:4})),this.nC=null,this.k1="",this.oC="",this.P1=m.fr,this.rC=!1,this.lC=!1,this.gd=new pt({layerName:"Tool",isInDocumentBounds:!1,locationObjectName:"CIRCLE",locationSpot:T.Center,pickable:!1,selectable:!1}).add(new it("Circle",{isGeometryPositioned:!0,width:30,height:30,fill:null,stroke:"darkcyan",strokeWidth:6,visible:!1}).bind("visible","down"),new it({isGeometryPositioned:!0,geometryString:"M15 0L15 30",stroke:"magenta"}),new it({isGeometryPositioned:!0,geometryString:"M0 15L30 15",stroke:"magenta"}),new it("Circle",{name:"CIRCLE",isGeometryPositioned:!0,width:20,height:20,fill:null,stroke:"magenta",position:new P(5,5)}),new it({isGeometryPositioned:!0,geometry:jt.VT,fill:null,stroke:"cyan",strokeWidth:4}).bind("geometry","button",jt.YO),new lt({position:new P(12,0),font:"bold 10pt sans-serif"}).bind("text","clickCount",e=>e>1?e.toString():""),new lt({position:new P(0,16)}).bind("text","modifiers",jt.KO)).freezeBindings(),this.Fp=10,this.Rp=1,this.aC=null,this.Qc=e=>this.HO(e),this.hC=e=>this.qO(e),this.cC=e=>this.jO(e),this.fC=e=>this.WO(e),this.uC=null,this.dC="distance",this.md=null,this.gC=0,this.Oi={},this.Ps=null,this.S1=!1,this.Op=null,this.pC(),this.gd.data=this.Oi,t&&Object.assign(this,t)}toString(){return"CommandHandler"}get diagram(){return this.a}Io(t){this.a=t}doStart(){let t=this.a;t&&(t.addModelChangedListener(this.Qc),t.addDiagramListener("ViewportBoundsChanged",this.hC),t.addDiagramListener("GainedFocus",this.cC),t.addDiagramListener("LostFocus",this.fC))}doStop(){let t=this.a;t&&(t.removeDiagramListener("ViewportBoundsChanged",this.hC),t.removeDiagramListener("GainedFocus",this.cC),t.removeDiagramListener("LostFocus",this.fC),t.removeModelChangedListener(this.Qc))}doKeyDown(){let t=this.a,e=t.lastInput,i=e.control||e.meta,s=e.shift,n=e.alt,o=e.commandKey;i&&(o==="Insert"||o==="c")?this.canCopySelection()&&this.copySelection():i&&o==="x"||s&&o==="Delete"?this.canCutSelection()&&this.cutSelection():i&&o==="v"||s&&o==="Insert"?this.canPasteSelection()&&this.pasteSelection():i&&o==="y"||i&&s&&o==="z"||n&&s&&o==="Backspace"?this.canRedo()&&this.redo():i&&o==="z"||n&&o==="Backspace"?this.canUndo()&&this.undo():o==="Delete"||o==="Backspace"?this.canDeleteSelection()&&this.deleteSelection():i&&o==="a"?this.canSelectAll()&&this.selectAll():o==="Escape"?this.canStopCommand()&&this.stopCommand():this.BT.indexOf(o)>=0?this.JO(o,i,s):o==="PageUp"?s&&t.allowHorizontalScroll?t.scroll("page","left"):t.allowVerticalScroll&&t.scroll("page","up"):o==="PageDown"?s&&t.allowHorizontalScroll?t.scroll("page","right"):t.allowVerticalScroll&&t.scroll("page","down"):o==="Home"?i&&t.allowVerticalScroll?t.scroll("document","up"):!i&&t.allowHorizontalScroll&&t.scroll("document","left"):o==="End"?i&&t.allowVerticalScroll?t.scroll("document","down"):!i&&t.allowHorizontalScroll&&t.scroll("document","right"):o==="Space"?this.canScrollToPart()&&this.scrollToPart():o==="Minus"||o==="NumpadSubtract"?this.canDecreaseZoom()&&this.decreaseZoom():o==="Equal"||o==="NumpadAdd"?this.canIncreaseZoom()&&this.increaseZoom():i&&o==="Digit0"?this.canResetZoom()&&this.resetZoom():s&&o==="z"?this.canZoomToFit()&&this.zoomToFit():i&&!s&&o==="g"?this.canGroupSelection()&&this.groupSelection():i&&s&&o==="g"?this.canUngroupSelection()&&this.ungroupSelection():o==="F2"?this.canEditTextBlock()&&this.editTextBlock():o==="ContextMenu"||s&&o==="F10"||i&&s&&o==="Backslash"?this.canShowContextMenu()&&this.showContextMenu():e.bubbles=!0}doKeyUp(){let t=this.a.lastInput;t.bubbles=!0}stopCommand(){let t=this.a,e=t.currentTool;if(e instanceof oe){if(e.currentToolTip!==null){e.hideToolTip();return}t.allowSelect&&t.clearSelection()}e!==null&&e.doCancel()}canStopCommand(){return!0}selectAll(){let t=this.a;t.N();try{t.currentCursor="wait",t.T("ChangingSelection",t.selection);let e=t.parts;for(;e.next();){let n=e.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}let i=t.nodes;for(;i.next();){let n=i.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}let s=t.links;for(;s.next();){let n=s.value;n.canSelect()&&!n.layer.isTemporary&&(n.isSelected=!0)}}finally{t.T("ChangedSelection",t.selection),t.currentCursor=""}}canSelectAll(){return this.a.allowSelect}deleteSelection(){let t=this.a;try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),t.startTransaction("Delete"),t.T("SelectionDeleting",t.selection);let e=new V,i=t.selection.iterator;for(;i.next();){let s=i.value;pt.ga(e,s,!0,this.deletesTree?1/0:0,this.deletesConnectedLinks?null:!1,n=>n.canDelete())}t.removeParts(e,!0),t.T("SelectionDeleted",e)}finally{t.commitTransaction("Delete"),t.T("ChangedSelection",t.selection),t.currentCursor=""}}canDeleteSelection(){let t=this.a;return!(t.isReadOnly||t.isModelReadOnly||!t.allowDelete||t.selection.count===0)}copySelection(){let t=this.a;try{let e=new V,i=t.selection.iterator;for(;i.next();){let s=i.value;pt.ga(e,s,!0,this.copiesTree?1/0:0,this.copiesConnectedLinks,n=>n.canCopy())}this.copyToClipboard(e)}finally{}}canCopySelection(){let t=this.a;return!(!t.allowCopy||!t.allowClipboard||t.selection.count===0)}cutSelection(){this.copySelection(),this.deleteSelection()}canCutSelection(){let t=this.a;return!(t.isReadOnly||t.isModelReadOnly||!t.allowCopy||!t.allowDelete||!t.allowClipboard||t.selection.count===0)}copyToClipboard(t){let e=this.a,i=this.storageLocation==="systemClipboard";if(i||this.storageLocation!=="memory")try{if(t===null)if(i&&K.navigator.clipboard)K.navigator.clipboard.writeText("");else{let n=K[this.storageLocation];if(!n)return;n.setItem(this.d1,""),n.setItem(this.g1,"")}else{let n=new Y;n.isTreePathToChildren=e.isTreePathToChildren,n.toolManager.draggingTool.dragsLink=e.toolManager.draggingTool.dragsLink,n.model=e.model.copy();let o=e.copyParts(t,n,!1);if(this.Fc(o),i&&K.navigator.clipboard)K.navigator.clipboard.writeText(n.model.toJson());else{let r=K[this.storageLocation];if(!r)return;r.setItem(this.d1,n.model.toJson()),r.setItem(this.g1,n.model.dataFormat)}}e.T("ClipboardChanged",t);return}catch{return}let s=null;if(t===null)Y.iT();else{let n=null;try{n=e.copyParts(t,null,!0),this.Fc(n)}finally{s=new q,n!==null&&s.addAll(n.iteratorValues),Y.xp=s,Y._b=e.model.dataFormat}}e.T("ClipboardChanged",s)}Fc(t){let e=this.diagram.model;this.copiesParentKey&&e.Mx()?t.each(i=>{let s=i.key,n=i.value;if(s instanceof $&&n instanceof $&&s.data&&n.data){let o=e.getParentKeyForNodeData(s.data),r=this.diagram.findNodeForKey(o);r!==null&&!t.has(r)&&e.setParentKeyForNodeData(n.data,o)}}):this.copiesGroupKey&&e.Ah()&&t.each(i=>{let s=i.key,n=i.value;if(!(s instanceof j)&&!(n instanceof j)&&s.data&&n.data){let o=e.getGroupForData(s.data),r=this.diagram.findNodeForKey(o);r!==null&&!t.has(r)&&e.setGroupForData(n.data,o)}})}pasteFromClipboard(){let t=this.a;if(this.storageLocation!=="memory"){let n=new V;try{let o=K[this.storageLocation];if(!o)return n;let r=o.getItem(this.d1),a=o.getItem(this.g1);if(r===null||r===""||a!==t.model.dataFormat)return n;{let h=new Y;h.model=dt.fromJson(r);let l=new V;l.addAll(h.parts).addAll(h.nodes).addAll(h.links);let u=t.copyParts(l,t,!1);return this.Fc(u),new V().addAll(u.iteratorValues)}}catch{return n}}let e=new V,i=Y.xp;if(i===null||Y._b!==t.model.dataFormat)return e;let s=null;try{s=t.copyParts(i,t,!1),this.Fc(s)}finally{if(s!==null){let n=s.iterator;for(;n.next();){let o=n.value,r=n.key;o.location.isReal()||(r.location.isReal()?o.location=r.location:!o.position.isReal()&&r.position.isReal()&&(o.position=r.position)),e.add(o)}}}return e}async pasteSelectionAsync(t){let e=this.a;if(K.navigator.clipboard===void 0){m.ne('Cannot paste with storageLocation "clipboard", window.isSecureContext may be false.');return}try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Paste");let i=null,s=await K.navigator.clipboard.readText();try{let o=s;if(!(o===null||o==="")){let r=new Y;r.model=dt.fromJson(o);let a=new V;a.addAll(r.parts).addAll(r.nodes).addAll(r.links);let h=e.copyParts(a,e,!1);this.Fc(h),i=new V().addAll(h.iteratorValues)}}catch{}if(i===null)return;i.count>0&&e.clearSelection(!0);let n=i.iterator;for(;n.next();){let o=n.value;o.isSelected=!0}if(t){let o=e.computePartsBounds(e.selection);if(o.isReal()){let r=this.computeEffectiveCollection(e.selection,e.ld);e.Sx(r,new P(t.x-o.centerX,t.y-o.centerY),e.ld,!1)}}e.T("ClipboardPasted",i)}finally{e.commitTransaction("Paste"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}pasteSelection(t){if(this.storageLocation==="systemClipboard"){this.pasteSelectionAsync(t);return}let e=this.a;try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Paste");let i=this.pasteFromClipboard();i.count>0&&e.clearSelection(!0);let s=i.iterator;for(;s.next();){let n=s.value;n.isSelected=!0}if(t){let n=e.computePartsBounds(e.selection);if(n.isReal()){let o=this.computeEffectiveCollection(e.selection,e.ld);e.Sx(o,new P(t.x-n.centerX,t.y-n.centerY),e.ld,!1)}}e.T("ClipboardPasted",i)}finally{e.commitTransaction("Paste"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}canPasteSelection(t){let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowInsert||!e.allowClipboard)return!1;if(this.storageLocation==="systemClipboard")return!0;if(this.storageLocation!=="memory")try{let i=K[this.storageLocation];if(!i)return!1;let s=i.getItem(this.d1),n=i.getItem(this.g1);return!(s===null||s===""||n!==e.model.dataFormat)}catch{return!1}return!(Y.xp===null||Y.xp.count===0||Y._b!==e.model.dataFormat)}undo(){this.a.undoManager.undo()}canUndo(){let t=this.a;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canUndo()}redo(){this.a.undoManager.redo()}canRedo(){let t=this.a;return t.isReadOnly||t.isModelReadOnly?!1:t.allowUndo&&t.undoManager.canRedo()}decreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);let e=this.a;if(e.autoScale!==1)return;let i=e.scale*t;i<e.minScale||i>e.maxScale||(e.scale=i)}canDecreaseZoom(t){t===void 0&&(t=1/this.zoomFactor);let e=this.a;if(e.autoScale!==1)return!1;let i=e.scale*t;return i<e.minScale||i>e.maxScale?!1:e.allowZoom}increaseZoom(t){t===void 0&&(t=this.zoomFactor);let e=this.a;if(e.autoScale!==1)return;let i=e.scale*t;i<e.minScale||i>e.maxScale||(e.scale=i)}canIncreaseZoom(t){t===void 0&&(t=this.zoomFactor);let e=this.a;if(e.autoScale!==1)return!1;let i=e.scale*t;return i<e.minScale||i>e.maxScale?!1:e.allowZoom}resetZoom(t){t===void 0&&(t=this.defaultScale);let e=this.a;t<e.minScale||t>e.maxScale||(e.scale=t)}canResetZoom(t){t===void 0&&(t=this.defaultScale);let e=this.a;return t<e.minScale||t>e.maxScale?!1:e.allowZoom}zoomToFit(t){let e=this.a,i=e.animationManager;i.stopAnimation(),e.redraw();let s=e.position.copy(),n=e.scale;if(i.Kl("Zoom To Fit"),!t&&this.isZoomToFitRestoreEnabled&&n===this.w1&&!isNaN(this.m1)&&this.p1.isReal()&&e.documentBounds.equals(this.b1))e.scale=this.m1,e.position=this.p1,this.w1=NaN,this.b1=I.tm;else{if(this.m1=n,this.p1=s,t){let o=t.copy();if(o.width>0&&o.height>0){let r=e.viewportBounds,a=r.width*n,h=r.height*n,l=Math.min(a/o.width,h/o.height),u=a/l,c=h/l;o.width<u&&(o.x-=(u-o.width)/2),o.height<c&&(o.y-=(c-o.height)/2)}e.zoomToRect(o,2)}else e.zoomToFit();this.w1=e.scale,this.b1=e.documentBounds.copy()}i.kM()}canZoomToFit(t){return this.a.allowZoom}JO(t,e,i){let s=this.a;t==="ArrowUp"?s.allowVerticalScroll&&(e?s.scroll("pixel","up"):s.scroll("line","up")):t==="ArrowDown"?s.allowVerticalScroll&&(e?s.scroll("pixel","down"):s.scroll("line","down")):t==="ArrowLeft"?s.allowHorizontalScroll&&(e?s.scroll("pixel","left"):s.scroll("line","left")):t==="ArrowRight"&&s.allowHorizontalScroll&&(e?s.scroll("pixel","right"):s.scroll("line","right"))}scrollToPart(t){t===void 0&&(t=null),t!==null&&m.se(t,pt,jt,"part");let e=this.a;if(e.ensureBounds(),t===null){try{this.Ko!==null&&(this.Ko.next()?t=this.Ko.value:this.Ko=null)}catch{this.Ko=null}t===null&&(e.highlighteds.count>0?this.Ko=e.highlighteds.iterator:e.selection.count>0&&(this.Ko=e.selection.iterator),this.Ko!==null&&this.Ko.next()&&(t=this.Ko.value))}if(t!==null){let i=e.animationManager;i.Kl("Scroll To Part");let s=this.scrollToPartPause;if(s>0){let n=this.uf(t,[t]);if(n.length===1)e.startTransaction(),e.centerRect(t.actualBounds),e.commitTransaction("Scroll To Part");else{let o=()=>{e.startTransaction();let a=n.pop();for(;n.length>0&&a instanceof $&&a.isTreeExpanded&&(!(a instanceof ht)||a.isSubGraphExpanded);)a=n.pop();n.length>0?(a instanceof pt&&e.scrollToRect(a.actualBounds),a instanceof $&&!a.isTreeExpanded&&(a.isTreeExpanded=!0),a instanceof ht&&!a.isSubGraphExpanded&&(a.isSubGraphExpanded=!0)):(a instanceof pt&&e.centerRect(a.actualBounds),e.removeDiagramListener("LayoutCompleted",r)),e.commitTransaction("Scroll To Part")},r=()=>{m.dn(o,(i.isEnabled?i.duration:0)+s)};e.addDiagramListener("LayoutCompleted",r),o()}}else{let n=e.position.copy();e.centerRect(t.actualBounds),n.equalsApprox(e.position)&&i.stopAnimation()}}}uf(t,e){if(t.isVisible())return e;if(t instanceof vt){let i=t.adornedPart;i!==null&&this.uf(i,e)}else if(t instanceof j){let i=t.fromNode;i!==null&&this.uf(i,e);let s=t.toNode;s!==null&&this.uf(s,e)}else{if(t instanceof $){let s=t.labeledLink;s!==null&&this.uf(s,e);let n=t.findTreeParentNode();n!==null&&(!n.isTreeExpanded&&!n.wasTreeExpanded&&e.push(n),this.uf(n,e))}let i=t.containingGroup;i!==null&&(!i.isSubGraphExpanded&&!i.wasSubGraphExpanded&&e.push(i),this.uf(i,e))}return e}canScrollToPart(t){if(t===void 0&&(t=null),t!==null&&!(t instanceof pt))return!1;let e=this.a;return e.selection.count===0&&e.highlighteds.count===0?!1:e.allowHorizontalScroll&&e.allowVerticalScroll}collapseTree(t){t===void 0&&(t=null);let e=this.a,i="Collapse Tree";try{e.startTransaction(i),e.animationManager.Kl(i);let s=new q;if(t!==null&&t.isTreeExpanded)t.collapseTree(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof $&&o.isTreeExpanded&&(o.collapseTree(),s.add(o))}}e.T("TreeCollapsed",s)}finally{e.commitTransaction(i)}}canCollapseTree(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null){if(!(t instanceof $)||!t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof $){if(!s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}expandTree(t){t===void 0&&(t=null);let e=this.a,i="Expand Tree";try{e.startTransaction(i),e.animationManager.Kl(i);let s=new q;if(t!==null&&!t.isTreeExpanded)t.expandTree(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof $&&(o.isTreeExpanded||(o.expandTree(),s.add(o)))}}e.T("TreeExpanded",s)}finally{e.commitTransaction(i)}}canExpandTree(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null){if(!(t instanceof $)||t.isTreeExpanded)return!1;if(t.findTreeChildrenLinks().count>0)return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof $){if(s.isTreeExpanded)continue;if(s.findTreeChildrenLinks().count>0)return!0}}}return!1}groupSelection(){let t=this.a,e=t.model;if(!e.Ah())return;let i=this.archetypeGroupData;if(i===null)return;let s=null;try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),t.startTransaction("Group");let n=new q,o=t.selection.iterator;for(;o.next();){let l=o.value;l.Di()&&l.canGroup()&&n.add(l)}let r=new q,a=n.iterator;for(;a.next();){let l=a.value,u=!1,c=n.iterator;for(;c.next();){let d=c.value;if(l.isMemberOf(d)){u=!0;break}}u||r.add(l)}let h=r.first();if(h!==null){let l=h.containingGroup;if(l!==null)for(;l!==null;){let u=!1,c=r.iterator;for(;c.next();)if(!c.value.isMemberOf(l)){u=!0;break}if(u)l=l.containingGroup;else break}if(i instanceof ht)i.It(),s=i.copy(),s!==null&&t.add(s);else if(e.isGroupForData(i)){let u=e.copyNodeData(i);e.addNodeData(u),s=t.findNodeForData(u)}if(s!==null){l!==null&&this.isValidMember(l,s)&&(s.containingGroup=l);let u=r.iterator;for(;u.next();){let c=u.value;this.isValidMember(s,c)&&(c.containingGroup=s)}t.clearSelection(!0),s.isSelected=!0}}t.T("SelectionGrouped",s)}finally{t.commitTransaction("Group"),t.T("ChangedSelection",t.selection),t.currentCursor=""}}canGroupSelection(){let t=this.a;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowGroup||!t.model.Ah()||this.archetypeGroupData===null)return!1;let e=t.selection.iterator;for(;e.next();){let i=e.value;if(i.Di()&&i.canGroup())return!0}return!1}yC(t){let e=m.st();if(Array.isArray(t))t.forEach(n=>{n instanceof j||n instanceof pt&&e.push(n)});else{let n=t.iterator;for(;n.next();){let o=n.value;o instanceof j||o instanceof pt&&e.push(o)}}let i=new V,s=e.length;for(let n=0;n<s;n++){let o=e[n],r=!0;for(let a=0;a<s;a++)if(o.isMemberOf(e[a])){r=!1;break}r&&i.add(o)}return m.Z(e),i}isValidMember(t,e){if(e===null||t===e||e instanceof j)return!1;let i;return t!==null&&(t===e||t.isMemberOf(e)||(i=t.memberValidation,i!==null&&!i(t,e))||t.data===null&&e.data!==null||t.data!==null&&e.data===null)?!1:(i=this.memberValidation,i!==null?i(t,e):!0)}ungroupSelection(t){t===void 0&&(t=null);let e=this.a,i=e.model;if(i.Ah())try{e.currentCursor="wait",e.T("ChangingSelection",e.selection),e.startTransaction("Ungroup");let s=new q;if(t!==null)s.add(t);else{let o=e.selection.iterator;for(;o.next();){let r=o.value;r instanceof ht&&r.canUngroup()&&s.add(r)}}let n=new q;if(s.count>0){e.clearSelection(!0);let o=s.iterator;for(;o.next();){let r=o.value;r.expandSubGraph();let a=r.containingGroup,h=a!==null&&a.data!==null?i.getKeyForNodeData(a.data):void 0;n.addAll(r.memberParts);let l=n.iterator;for(;l.next();){let u=l.value;if(u.isSelected=!0,u instanceof j)continue;let c=u.data;c!==null?i.setGroupForData(c,h):u.containingGroup=a}e.remove(r)}}e.T("SelectionUngrouped",s,n)}finally{e.commitTransaction("Ungroup"),e.T("ChangedSelection",e.selection),e.currentCursor=""}}canUngroupSelection(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowDelete||!e.allowUngroup||!e.model.Ah())return!1;if(t!==null){if(!(t instanceof ht))return!1;if(t.canUngroup())return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ht&&s.canUngroup())return!0}}return!1}addTopLevelParts(t,e){let i=this.yC(t),s=!0,n=i.iterator;for(;n.next();){let o=n.value;o.containingGroup!==null&&(!e||this.isValidMember(null,o)?o.containingGroup=null:s=!1)}return s}collapseSubGraph(t){t===void 0&&(t=null);let e=this.a,i="Collapse SubGraph";try{e.startTransaction(i),e.animationManager.Kl(i);let s=new q;if(t!==null&&t.isSubGraphExpanded)t.collapseSubGraph(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof ht&&o.isSubGraphExpanded&&(o.collapseSubGraph(),s.add(o))}}e.T("SubGraphCollapsed",s)}finally{e.commitTransaction(i)}}canCollapseSubGraph(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null)return!(!(t instanceof ht)||!t.isSubGraphExpanded);{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ht&&s.isSubGraphExpanded)return!0}}return!1}expandSubGraph(t){t===void 0&&(t=null);let e=this.a,i="Expand SubGraph",s=new q;try{if(e.startTransaction(i),e.animationManager.Kl(i),t!==null&&!t.isSubGraphExpanded)t.expandSubGraph(),s.add(t);else if(t===null){let n=e.selection.iterator;for(;n.next();){let o=n.value;o instanceof ht&&(o.isSubGraphExpanded||(o.expandSubGraph(),s.add(o)))}}e.T("SubGraphExpanded",s)}finally{for(let n of s)this.zT(e,n);t&&this.zT(e,t),e.commitTransaction(i)}}zT(t,e){for(let i of e.memberParts)i instanceof $&&t.Yc(i,e)}canExpandSubGraph(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly)return!1;if(t!==null)return!(!(t instanceof ht)||t.isSubGraphExpanded);{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s instanceof ht&&!s.isSubGraphExpanded)return!0}}return!1}editTextBlock(t){t===void 0&&(t=null),t!==null&&m.se(t,lt,jt,"editTextBlock");let e=this.a,i=e.toolManager.findTool("TextEditing");if(i!==null){if(t===null){let s=null,n=e.selection.iterator;for(;n.next();){let o=n.value;if(o.canEdit()){s=o;break}}if(s===null)return;t=s.findInVisualTree(o=>o instanceof lt&&o.editable)}t!==null&&(e.currentTool=null,i.textBlock=t,e.currentTool=i)}}canEditTextBlock(t){t===void 0&&(t=null);let e=this.a;if(e.isReadOnly||e.isModelReadOnly||!e.allowTextEdit||e.toolManager.findTool("TextEditing")===null)return!1;if(t!==null){if(!(t instanceof lt))return!1;let i=t.part;if(i!==null&&i.canEdit())return!0}else{let i=e.selection.iterator;for(;i.next();){let s=i.value;if(s.canEdit()&&(t=s.findInVisualTree(n=>n instanceof lt&&n.editable),t!==null))return!0}}return!1}showContextMenu(t){let e=this.a,i=e.toolManager.findTool("ContextMenu");if(i===null)return;t===void 0&&(t=null),t===null&&(e.selection.count>0?t=e.selection.first():t=e);let s=i.findObjectWithContextMenu(t);if(s!==null){let n=e.lastInput,o;if(s instanceof J?o=s.getDocumentPoint(T.Center):e.viewportBounds.containsPoint(n.documentPoint)?o=P.mn:o=e.viewportBounds.center,o.isReal()){let r=new te;r.diagram=e,r.viewPoint=e.transformDocToView(o),r.documentPoint=o,r.button=2,r.up=!0,e.lastInput=r}e.currentTool=i,i.openMenu(!1,s)}}canShowContextMenu(t){let e=this.a,i=e.toolManager.findTool("ContextMenu");return!(i===null||(t===void 0&&(t=null),t===null&&(e.selection.count>0?t=e.selection.first():t=e),i.findObjectWithContextMenu(t)===null))}downloadSvg(t){let e=this.a,i={scale:1,background:e.div?e.div.style.backgroundColor:"white",name:this.$O("svg")};t&&Object.assign(i,t);let s=e.makeSvg(i);if(s!==null){let n=new XMLSerializer().serializeToString(s);this.ZO(i.name,"image/svg+xml",n)}}downloadSVG(t){this.downloadSvg(t)}canDownloadSvg(t){return this.a!==null}ZO(t,e,i){let s=null,n=null;try{let o=new Blob([i],{type:e});s=K.URL.createObjectURL(o),n=m.Ci("a"),n.style.display="none",n.href=s,n.download=t,K.document.body.appendChild(n),requestAnimationFrame(()=>{try{n!==null&&n.click()}finally{s!==null&&K.URL.revokeObjectURL(s),n!==null&&K.document.body.removeChild(n)}})}catch{s!==null&&K.URL.revokeObjectURL(s),n!==null&&K.document.body.removeChild(n)}}$O(t){let e="."+t,i=this.diagram.model.name;return i?i.endsWith(e)&&(i=i.substring(0,i.length-e.length)):i="diagram",i+=e,i}get copiesClipboardData(){return this.H2}set copiesClipboardData(t){this.H2=!!t}get copiesConnectedLinks(){return this.q2}set copiesConnectedLinks(t){this.q2=!!t}get deletesConnectedLinks(){return this.j2}set deletesConnectedLinks(t){this.j2=!!t}get copiesTree(){return this.W2}set copiesTree(t){this.W2=!!t}get deletesTree(){return this.J2}set deletesTree(t){this.J2=!!t}get copiesParentKey(){return this.$2}set copiesParentKey(t){this.$2=!!t}get copiesGroupKey(){return this.Z2}set copiesGroupKey(t){this.Z2=!!t}get storageLocation(){return this.Q2}set storageLocation(t){t||(t="memory"),t!=="memory"&&t!=="sessionStorage"&&t!=="localStorage"&&t!=="systemClipboard"&&m.o("Invalid new value for CommandHandler.storageLocation: "+t),this.Q2=t}get archetypeGroupData(){return this._2}set archetypeGroupData(t){t!==null&&m.wc(t,jt,"archetypeGroupData");let e=this.a;this._2=t}get memberValidation(){return this.da}set memberValidation(t){t!==null&&m.S(t,jt,"memberValidation"),this.da=t}get defaultScale(){return this.diagram.defaultScale}set defaultScale(t){this.diagram.defaultScale=t}get zoomFactor(){return this.tC}set zoomFactor(t){t>1||m.o("zoomFactor must be larger than 1.0, not: "+t),this.tC=t}get isZoomToFitRestoreEnabled(){return this.eC}set isZoomToFitRestoreEnabled(t){this.eC=!!t}get scrollToPartPause(){return this.iC}set scrollToPartPause(t){this.iC=t}computeEffectiveCollection(t,e){let i=this.a,s=i.toolManager.findTool("Dragging"),n=i.currentTool===s;e===void 0&&(e=i.Cp());let o=new Mt;if(t===null)return o;let r=t.iterator;for(;r.next();){let a=r.value;i.tl(o,a,n,e)}if(i.draggedLink!==null&&e.dragsLink)return o;for(r=t.iterator;r.next();){let a=r.value;if(a instanceof j){let h=a.fromNode;if(h!==null&&!o.has(h))o.delete(a);else{let l=a.toNode;l!==null&&!o.has(l)&&o.delete(a)}}}return o}static getModifierNames(){return jt.pd}static setModifierNames(t){jt.pd=t}static KO(t){let e="";return t&1&&(e+=jt.pd[0]||""),t&4&&(e+=jt.pd[1]||""),t&2&&(e+=jt.pd[2]||""),t&8&&(e+=jt.pd[3]||""),e}static YO(t){return t===1?jt.XO:t===2?jt.GO:jt.VT}static mC(t,e,i){var s=new P(i,0).rotate(t-e/2),n=new wt().add(new zt(-i,-i)).add(new zt(i,i)).add(new zt(s.x,s.y).add(new mt(5,t-e/2,e,0,0,i,i)));return n.offset(i,i),n}HO(t){t.isTransactionFinished&&this.updateFocusBox()}qO(t){if(t.subject.scale===this.diagram.scale)return;let e=4/this.diagram.scale,i=this.focusBox.findObject("SHAPE");i!==null&&(i.strokeWidth=e);let s=this.focusBox.findObject("SHAPE2");s!==null&&(s.strokeWidth=e,s.strokeDashArray=[e,e]);let n=this.focusBox.placeholder;n!==null&&(n.padding=e)}jO(t){this.focus===null?m.dn(()=>{this.focus=this.findFirstFocus()},500):this.onFocusChanged(this.focus,this.focus)}WO(t){this.isVirtualPointerShown=!1}get isFocusEnabled(){return this.sC}set isFocusEnabled(t){t=!!t;let e=this.isFocusEnabled;t!==e&&(t||(this.isVirtualPointerShown=!1,this.uC=this.focus,this.focus=null),this.sC=t,t&&(this.focus=this.uC,this.updateFocusBox()))}get focusBox(){return this.vp}set focusBox(t){if(!(t instanceof vt))return;let e=this.vp;if(t!==e&&(this.vp=t,e.adornedObject!==null)){let i=e.adornedPart;i!==null&&i.removeAdornment("Focus"),t.adornedObject=e.adornedObject,i!==null&&i.addAdornment("Focus",t)}}get focus(){return this.vp.adornedObject}set focus(t){let e=this.focus;if(t!==e){let i=this.a;if(!i||!this.isFocusEnabled||t!==null&&t.diagram!==i)return;i.currentTool instanceof It||this.cancelVirtualPointer();let s=this.focusBox.adornedPart;s&&s.removeAdornment("Focus"),t===null?(this.md=null,this.virtualPointerLocation=i.viewportBounds.center,this.focusBox.adornedObject=null):(this.virtualPointerLocation=t.getDocumentPoint(T.Center),this.focusBox.adornedObject=t,this.updateFocusBox()),this.onFocusChanged(e,t)}}onFocusChanged(t,e){let i=this.a;if(i&&(this.focusChanged!==null?this.focusChanged(t,e,this):this.QO(this.describe(t,e)),e!==null&&e.part!==null)){let s=e.getDocumentBounds();i.viewportBounds.containsRect(s)||(e instanceof pt?i.commandHandler.scrollToPart(e):i.scrollToRect(s))}}get focusChanged(){return this.nC}set focusChanged(t){t!==null&&m.S(t,jt,"focusChanged"),this.nC=t}get liveElementId(){return this.k1||this.oC}set liveElementId(t){let e=this.k1;t!==e&&(this.k1=t,this.wC())}wC(){let t=this.diagram;if(!t||!Y.isUsingDOM())return;let e=t.lt?.bt;if(!e)return;let i=this.liveElementId,s=K.document.getElementById(i);this.isUsingAriaLive?(e.removeAttribute("aria-labelledby"),s&&s.setAttribute("aria-live","polite")):(i&&e.setAttribute("aria-labelledby",i),s&&s.removeAttribute("aria-live"))}get isUsingAriaLive(){return this.P1}set isUsingAriaLive(t){let e=this.P1;t!==e&&(this.P1=t,this.wC())}QO(t){let e=this.diagram;if(!e||!Y.isUsingDOM()||!e.div)return;let i=this.liveElementId;if(!i){let n=m.Ci("span"),o=n.style;for(o.opacity="0",o.position="absolute",o.right="-9999px",o.bottom="-9999px",o.width="0px",o.height="0px",o.overflow="hidden",o.border="0",i=(e.div.id||"diagram")+"_aria";K.document.getElementById(i);)i+=Math.floor(Math.random()*10);n.id=i,this.oC=i,e.div.appendChild(n),this.wC()}let s=K.document.getElementById(i);s&&(s.textContent=t)}describe(t,e){let i="";e instanceof $?e instanceof ht?i="Group":i="Node":e instanceof j?i="Link":e instanceof pt?i="Part":e&&(e.click?i="button":e instanceof lt&&e.editable&&(i="editable"),e.portId!==null&&(i&&(i+=" "),i+="port",e.portId&&(i+=" "+e.portId)));let s=this.xC(e);s&&(i+=" "+s);let n=e;if(t&&n instanceof j&&n.fromNode&&n.toNode){if(t instanceof $&&t.part===n.fromNode||t instanceof j&&t.fromNode===n.fromNode){i+=" to "+this.xC(n.toNode,!0);let o=n.toPort?.portId;o&&(i+=" port "+o)}else if(t instanceof $&&t.part===n.toNode||t instanceof j&&t.toNode===n.toNode){i+=" from "+this.xC(n.fromNode,!0);let o=n.fromPort?.portId;o&&(i+=" port "+o)}}return i}xC(t,e){if(e===void 0&&(e=!1),!t)return"";if(t instanceof lt&&t.text)return t.text;if(t instanceof G){let i="";return t instanceof pt&&t.text&&(i=t.text),e&&i||t.walkVisualTreeFrom(t,(s,n)=>{n.isVisibleObject()&&n instanceof lt&&n.text&&(!e||!i)&&i!==n.text&&(i+=" "+n.text)}),i}return""}updateFocusBox(){let t=this.focus;if(t!==null)if(t.diagram!==null&&(t instanceof pt?t.isVisible():t.isVisibleObject()&&t.part?.isVisible()))this.focusBox.adornedObject=t,t.part?.addAdornment("Focus",this.focusBox);else{let e=null;if(t instanceof pt||(e=t.part),e instanceof pt&&e.isVisible())this.focus=e;else{if(e instanceof $&&!e.isVisible()){let i=e.findTreeParentNode();if(i!==null)e=i;else{let s=e.labeledLink;s!==null&&(e=s)}}for(;e instanceof pt&&!e.isVisible();)e=e.containingGroup;e instanceof pt&&e.isVisible()?this.focus=e:this.focus=null}}}findFirstFocus(){let t=this.a;if(t===null||!t.isEnabled)return null;if(this.focus!==null)return this.focus;if(this.isFocusEnabled)if(t.selection.count>0)this.focus=t.selection.first();else{let e=this.XT(t.isTreePathToChildren).first();if(e!==null)return e}return null}get isVirtualPointerEnabled(){return this.rC}set isVirtualPointerEnabled(t){t=!!t;let e=this.isVirtualPointerEnabled;if(t!==e&&(this.rC=t,t)){let i=this.Op;i&&(this.Op=null,i.commandHandler.Ps=null,i.commandHandler.cancelVirtualPointer())}}get isVirtualPointerShown(){return this.lC}set isVirtualPointerShown(t){t=!!t;let e=this.isVirtualPointerShown;if(t!==e){let i=this.a;if(!i||!this.isVirtualPointerEnabled)return;this.lC=t;let s=this.focus;t?this.virtualPointerBox.diagram===null&&(this.virtualPointerLocation.isReal()||(s!==null?this.virtualPointerLocation=s.getDocumentPoint(T.Center):this.virtualPointerLocation=i.viewportBounds.center),i.add(this.virtualPointerBox),this.ma()):this.virtualPointerBox.diagram!==null&&(i.remove(this.virtualPointerBox),this.ma())}}cancelVirtualPointer(){let t=this.a;t&&(this.pC(),this.isVirtualPointerShown=!1,t.currentTool.doCancel(),this.isVirtualPointerDown=!1,this.bC())}bC(){let t=this.Ps;if(t!==null){this.Ps=null;let e=t.commandHandler;e.Ps=null,e.Op=null,e.isVirtualPointerShown=!1,e.isVirtualPointerDown=!1,e.pC(),this.S1&&(e.isVirtualPointerEnabled=!1),this.S1=!1}}pC(){this.Oi.button=0,this.Oi.modifiers=0,this.Oi.clickCount=1,this.Oi.down=!1,this.ma()}ma(){this.virtualPointerChanged!==null&&this.virtualPointerChanged(this.virtualPointerBox,this),this.updateVirtualPointer()}updateVirtualPointer(){let t=this.virtualPointerBox.diagram;t&&(this.virtualPointerBox.scale=1/t.scale),this.virtualPointerBox.updateTargetBindings()}get virtualPointerBox(){return this.gd}set virtualPointerBox(t){if(!(t instanceof pt))return;let e=this.gd;t!==e&&(e!==null&&(t.location=e.location,e.diagram!==null&&e.diagram.remove(e)),this.gd=t,this.isVirtualPointerShown&&this.diagram&&(this.diagram.add(t),t.data=e.data),this.ma())}get virtualPointerChanged(){return this.aC}set virtualPointerChanged(t){t!==null&&m.S(t,jt,"virtualPointerChanged"),this.aC=t}get virtualPointerLocation(){return this.virtualPointerBox.location}set virtualPointerLocation(t){this.virtualPointerLocation.equals(t)||this.GT(t.x,t.y)}get isVirtualPointerDown(){return this.virtualPointerBox.data?this.virtualPointerBox.data.down:!1}set isVirtualPointerDown(t){t=!!t;let e=this.isVirtualPointerDown;if(t!==e){let i=this.a;if(!i||!this.isVirtualPointerEnabled||(this.virtualPointerBox.data===null&&(this.gd.data=this.Oi),this.virtualPointerBox.data.down=t,this.ma(),!this.isVirtualPointerShown))return;let s=i.lastInput,n=new te;n.diagram=i,this.YT(n,t),t?n.down=!0:n.up=!0,n.clickCount=1,n.button=this.Oi.button,n.modifiers=this.Oi.modifiers,t&&(i.firstInput=n.copy()),this.yd(n,!0),t||this.Oi.clickCount===2&&(n.clickCount=2,n.down=!0,n.up=!1,this.yd(n,!0),n.down=!1,n.up=!0,this.yd(n,!0),this.KT(1)),i.lastInput=s}}get virtualPointerShiftMove(){return this.Fp}set virtualPointerShiftMove(t){this.Fp=t}get virtualPointerControlMove(){return this.Rp}set virtualPointerControlMove(t){this.Rp=t}Ip(t,e){this.GT(this.virtualPointerLocation.x+t,this.virtualPointerLocation.y+e)}GT(t,e){this.virtualPointerBox.moveTo(t,e,!0);let i=this.a;if(!i||!this.isVirtualPointerEnabled||!this.isVirtualPointerShown)return;i.ensureBounds();let s=i.lastInput,n=new te;n.diagram=i,this.YT(n,this.isVirtualPointerDown),n.button=this.Oi.button,n.modifiers=this.Oi.modifiers,this.yd(n,!0),i.lastInput=s,this.isVirtualPointerDown&&(i.remove(this.virtualPointerBox),i.add(this.virtualPointerBox)),this.ma()}YT(t,e){let i=this.a;if(i){if(t.targetDiagram=i,t.documentPoint=this.virtualPointerLocation,i.allowDragOut){let s=i.div.getBoundingClientRect(),n=i.transformDocToView(this.virtualPointerLocation),o=s.x+n.x,r=s.y+n.y,a=K.document.elementFromPoint(o,r)||null;a instanceof HTMLCanvasElement&&(a=a.parentElement),a!==null&&a.shadowRoot&&(a=a.shadowRoot.elementFromPoint(o,r)||null,a instanceof HTMLCanvasElement&&(a=a.parentElement));let h=null;if(a instanceof HTMLElement&&(h=Y.Ji.get(a))&&h!==i&&h.div){let l=h.div.getBoundingClientRect(),u=new P(n.x-(l.x-s.x),n.y-(l.y-s.y));this.Ps!==null&&this.Ps!==h&&this.bC(),t.targetDiagram=h,t.viewPoint=u,t.documentPoint=h.transformViewToDoc(u),t.viewPoint=h.transformDocToView(t.documentPoint),this.Ps=h;let c=h.commandHandler;this.S1=!c.isVirtualPointerEnabled,c.isVirtualPointerEnabled=!0,c.isVirtualPointerDown=e,c.virtualPointerLocation=t.documentPoint,c.isVirtualPointerShown=!0,c.Op=i;return}}this.Ps!==null&&this.bC(),t.viewPoint=i.transformDocToView(t.documentPoint)}}yd(t,e){this.doVirtualPointerEvent(t,e)}doVirtualPointerEvent(t,e){let i=this.a;i&&(t.timestamp=Date.now(),i.lastInput=t,e&&(t.up?i.doMouseUp():t.down?i.doMouseDown():i.doMouseMove()),this.onVirtualPointerEvent(t,e))}onVirtualPointerEvent(t,e){let i=this.a;i&&(t.up?this.isVirtualPointerDown&&!i.viewportBounds.containsPoint(this.virtualPointerLocation)&&(this.virtualPointerLocation=this.focus instanceof J?this.focus.getDocumentPoint(T.Center):i.viewportBounds.center):t.down)}doVirtualFocusKeyDown(){let t=this.a;if(!t)return!1;let e=t.lastInput,i=e.commandKey;if(this.isVirtualPointerEnabled&&(i==="ShiftLeft"||i==="ShiftRight"))return this.isVirtualPointerShown=!0,!0;if(this.BT.indexOf(i)>=0)if(e.shift&&this.isVirtualPointerShown){let s=this.M1(i),n=e.control||e.meta?this.Rp:this.Fp;s===270?this.Ip(0,-n):s===90?this.Ip(0,n):s===180?this.Ip(-n,0):this.Ip(n,0)}else this._O();else if(e.shift&&this.isVirtualPointerShown&&(i==="Numpad1"||i==="Numpad2"||i==="Numpad3"||i==="Numpad4"||i==="Numpad6"||i==="Numpad7"||i==="Numpad8"||i==="Numpad9")){let s=e.control||e.meta?this.Rp:this.Fp,n=0;i==="Numpad1"||i==="Numpad4"||i==="Numpad7"?n=-s:(i==="Numpad3"||i==="Numpad6"||i==="Numpad9")&&(n=s);let o=0;i==="Numpad7"||i==="Numpad8"||i==="Numpad9"?o=-s:(i==="Numpad1"||i==="Numpad2"||i==="Numpad3")&&(o=s),this.Ip(n,o)}else if(i==="Enter"||i==="NumpadEnter"||i==="Numpad5")e.shift&&this.isVirtualPointerShown?this.isVirtualPointerDown=!this.isVirtualPointerDown:this.tI();else if(i==="Escape")this.eI();else if(i==="Space")this.iI();else if(i==="ContextMenu"||e.shift&&i==="F10"||(e.control||e.meta)&&e.shift&&i==="Backslash")this.sI();else if(e.shift&&i==="c")this.C1(1);else if(e.shift&&i==="a")this.C1(2);else if(e.shift&&i==="KeyS")this.C1(4);else if(e.shift&&i==="KeyM")this.C1(8);else if(e.shift&&i==="Digit1")this.N1(0);else if(e.shift&&i==="Digit2")this.N1(1);else if(e.shift&&i==="Digit3")this.N1(2);else if(e.shift&&i==="Numpad0"){let s=this.Oi.button;this.N1(s===2?0:2)}else if(e.shift&&(i==="KeyD"||i==="NumpadDecimal")){let s=this.Oi.clickCount;this.KT(s===2?1:2)}else if(e.shift&&i==="KeyF"){let s=this.nextFocusFormula;this.nextFocusFormula=s==="distance"?"linear":"distance"}else if(e.shift&&i==="y")this.isUsingAriaLive=!this.isUsingAriaLive;else return!1;return!0}doVirtualFocusKeyUp(){let t=this.a;if(!t)return!1;let e=t.lastInput.commandKey;return this.isVirtualPointerEnabled&&(e==="ShiftLeft"||e==="ShiftRight")&&(this.isVirtualPointerShown=!1),!0}M1(t){switch(t){case"ArrowDown":return 90;case"ArrowLeft":return 180;case"ArrowUp":return 270;default:return 0}}BT=["ArrowRight","ArrowDown","ArrowLeft","ArrowUp"];C1(t){let e=this.Oi.modifiers;this.Oi.modifiers=e&t?e&~t:e|t,this.ma()}KT(t){this.Oi.clickCount=t,this.ma()}N1(t){this.Oi.button=t,this.ma()}_O(){let t=this.a;if(!t)return;let e=t.lastInput,i=this.focus;if(i===null){let s=this.XT(t.isTreePathToChildren).first();s!==null&&(this.focus=s)}else if(i instanceof j)this.nI(i);else if(i instanceof $)this.oI(i);else{i instanceof pt&&(this.md=null);let s=this.M1(e.commandKey);s===270?this.focus=this.findNextFocus(270):s===90?this.focus=this.findNextFocus(90):s===180?this.focus=this.findNextFocus(180):this.focus=this.findNextFocus(0)}}nI(t){let e=this.a;if(!e)return;let i=e.lastInput,s=this.M1(i.commandKey),n=null,o=this.md;if(o!==null){let r=this.gC;if(s===r)n=t.getOtherNode(o);else if(s===C.Ee(r+180))n=o;else{let a=r===0||r===180?90:0,h=r===0||r===180?270:180;if(s===a){let l=this.kC(o,r,!0),u=l.indexOf(t);u>=0&&u<l.count-1&&(this.focus=l.elt(u+1))}else if(s===h){let l=this.kC(o,r,!0),u=l.indexOf(t);u>0&&(this.focus=l.elt(u-1))}}}else{let r=t.fromNode,a=t.toNode;if(!r||!a)return;s===270?n=r.location.y<a.location.y?r:a:s==90?n=r.location.y>a.location.y?r:a:s===180?n=r.location.x<a.location.x?r:a:n=r.location.x>a.location.x?r:a}for(;n!==null&&!n.isVisible();)n=n.containingGroup;n!==null&&(this.focus=n)}oI(t){let e=this.a;if(!e)return;let i=e.lastInput,s=this.M1(i.commandKey);if(i.control||i.meta){let n=this.kC(t,s,!0).first();n&&(this.md=t,this.gC=s,this.focus=n)}else this.md=null,this.focus=this.findNextFocus(s)}kC(t,e,i){if(t===null)return new q;let s=t.actualBounds;if(!s.isReal())return new q;let n=new Set;(t instanceof ht?t.findExternalLinksConnected():t.findLinksConnected()).each(r=>{if(!r.isVisible())return;let a=null;if(r.fromNode===t?a=r.toNode:r.toNode===t?a=r.fromNode:t instanceof ht&&(r.fromNode?.isMemberOf(t)?a=r.toNode:r.toNode?.isMemberOf(t)&&(a=r.fromNode)),a===null||a.isMemberOf(t))return;for(;a!==null&&!a.isVisible();)a=a.containingGroup;if(a===null)return;let h=a.location;if(h.isReal()&&!(e===270&&(a!==t?h.y>=s.top:r.midPoint.y>=s.top))){if(e===90&&(a!==t?h.y<=s.bottom:r.midPoint.y<=s.bottom)||e===180&&(a!==t?h.x>=s.left:r.midPoint.x>=s.left)||e===0&&(a!==t?h.x<=s.right:r.midPoint.x<=s.right))return;i&&r.actualBounds.isReal()?n.add(r):n.add(a)}});let o=new q(n);return e===90||e===270?o.sort((r,a)=>r.actualBounds.centerX-a.actualBounds.centerX):o.sort((r,a)=>r.actualBounds.centerY-a.actualBounds.centerY),o}findNextFocus(t){t=C.Ee(t);let e=this.focus,i=e instanceof $?e.location:e.getDocumentPoint(T.Center),s=1/0,n=e,o=(r,a,h,l)=>{if(this.nextFocusFormula==="linear"){let u=1/0;t===0&&h>i.x||t===180&&h<i.x?u=Math.abs(h-i.x):(t===90&&l>i.y||t===270&&l<i.y)&&(u=Math.abs(l-i.y)),u<s&&(s=u,n=r)}else{if(t===0&&(a.right<i.x||(a.centerX-i.x)**2>s)||t===90&&(a.bottom<i.y||(a.centerY-i.y)**2>s)||t===180&&(a.x>i.x||(i.x-a.centerX)**2>s)||t===270&&(a.y>i.y||(i.y-a.centerY)**2>s))return;let u=i.direction(h,l),c=C.jF(t,u);if(t===90||t===270?c<=45:c<45){let d=i.distanceSquared(h,l);d<s&&(s=d,n=r)}}};if(e instanceof pt&&e.diagram!==null){let r=e.containingGroup;r!==null?r.memberParts.each(a=>{a===e||a instanceof j||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}):(e.diagram.nodes.each(a=>{a===e||!a.isTopLevel||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}),e.diagram.parts.each(a=>{a===e||!a.isTopLevel||!a.isVisible()||o(a,a.actualBounds,a.location.x,a.location.y)}))}else if(e.part!==null){let r=new I;this.PC(e.part).each(a=>{a!==e&&(a.getDocumentBounds(r),o(a,r,r.centerX,r.centerY))})}return n}get nextFocusFormula(){return this.dC}set nextFocusFormula(t){this.dC=t}tI(){let t=this.a;if(!t)return;let e=t.currentTool;if(e instanceof It){let n=e.currentObject;this.L1(this.focus),e.maybeStopTool(this.focus),t.currentTool instanceof It||(this.focus=n);return}let i=this.focus,s=t.lastInput;if(i===null)s.control||s.meta?this.L1(null):this.focus=this.findFirstFocus();else if(i instanceof pt)if(s.control||s.meta)this.L1(i);else{let n=this.PC(i);if(n.count>0)this.focus=n.first();else if(i instanceof j&&i.isLabeledLink){let o=i.labelNodes.first();o!==null&&o.isVisible()&&(this.focus=o)}else if(i instanceof ht&&i.isSubGraphExpanded){let o=i.memberParts.first();o!==null&&o.isVisible()&&(this.focus=o)}}else this.L1(i)}XT(t){let e=new q,i=this.a;if(!i)return e;let s=0;for(;e.count===0&&s<i.nodes.count;){let n=i.nodes;for(;n.next();){let o=n.value;o.isTopLevel&&o.isVisible()&&(t?o.findNodesInto():o.findNodesOutOf()).count===s&&e.add(o)}s++}return e}PC(t){return t instanceof pt?this.Sn(t,new q):new q}Sn(t,e){return!(t instanceof pt)&&t.isVisibleObject()&&t.isEnabledObject()&&(t.contextMenu||t.click||t instanceof lt&&t.editable||t.part instanceof $&&t.portId!==null&&(t.portId!==""||t.part.ports.count>1)||t.toolTip)&&e.add(t),t instanceof G&&t.elements.each(i=>this.Sn(i,e)),e}L1(t){let e=this.a;if(!e)return;let i=e.lastInput,s=t instanceof J?t:e;if(s.click){let n=new te;n.diagram=e,n.documentPoint=t instanceof J?t.getDocumentPoint(T.Center):e.viewportBounds.center,n.viewPoint=e.transformDocToView(n.documentPoint),n.button=0,n.clickCount=1,n.targetObject=t,this.yd(n,!1),s instanceof J?s.click(n,s):s.click(n),e.lastInput=i}else s instanceof lt&&s.editable?this.editTextBlock(s):this.HT(t)}eI(){let t=this.a;if(!t)return;let e=t.currentTool;if(e instanceof oe&&e.currentToolTip!==null){e.hideToolTip();return}else if(e instanceof It){let i=e.currentObject;e.doKeyDown(),this.focus=i;return}if(this.focus instanceof pt){let i=this.focus;i instanceof $&&i.labeledLink!==null?this.focus=i.labeledLink:i.containingGroup!==null?this.focus=i.containingGroup:this.focus=null}else if(this.focus instanceof J){let i=this.focus.part;if(i instanceof j&&i.isLabeledLink){let s=i.labelNodes.first();if(s!==null&&s.isVisible()){this.focus=s;return}}else if(i instanceof ht&&i.isSubGraphExpanded){let s=i.memberParts.first();if(s!==null&&s.isVisible()){this.focus=s;return}}this.focus=i}else this.cancelVirtualPointer(),this.stopCommand()}iI(){let t=this.a;if(t)if(t.lastInput.shift&&this.isVirtualPointerShown){let e=t.findPartAt(this.virtualPointerLocation);e!==null&&(e===this.focus?this.qT():this.focus=e)}else this.qT()}qT(){let t=this.a;if(!t)return;let e=t.lastInput,i=this.focus;if(i instanceof pt){let s=i.part;if(e.control||e.meta){for(t.raiseDiagramEvent("ChangingSelection",t.selection);s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.raiseDiagramEvent("ChangedSelection",t.selection)}else if(e.shift){if(s!==null&&!s.isSelected){for(t.raiseDiagramEvent("ChangingSelection",t.selection);s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.raiseDiagramEvent("ChangedSelection",t.selection)}}else if(s!==null&&!s.isSelected){for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}this.HT(i),this.onFocusChanged(i,i)}HT(t){let e=this.a;if(!e)return;e.toolManager.hideToolTip();let i=e.lastInput,s=t instanceof J?t:e;for(;s instanceof J&&!s.toolTip;)s=s.panel;if(s&&s.toolTip){let n=new te;n.diagram=e,n.documentPoint=t!==null?t.getDocumentPoint(T.Center):e.viewportBounds.center,n.viewPoint=e.transformDocToView(n.documentPoint),n.targetObject=t,this.yd(n,!1),e.toolManager.showToolTip(s.toolTip,t),e.lastInput=i}}sI(){let t=this.a;if(!t)return;let e=this.focus;if(this.canShowContextMenu(e)){this.showContextMenu(e);let i=t.toolManager.contextMenuTool.currentContextMenu;if(i instanceof vt){let s=this.PC(i);s.count>0&&(this.focus=s.first())}}}}var Bi=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Vertical=4]="Vertical",x[x.Horizontal=5]="Horizontal",x[x.Fill=2]="Fill",x))(Bi||{}),Vi=(x=>(x[x.None=0]="None",x[x.Along=21]="Along",x[x.Plus90=22]="Plus90",x[x.Minus90=23]="Minus90",x[x.Opposite=24]="Opposite",x[x.Upright=25]="Upright",x[x.Plus90Upright=26]="Plus90Upright",x[x.Minus90Upright=27]="Minus90Upright",x[x.Upright45=28]="Upright45",x))(Vi||{}),Ks=(x=>(x[x.None=0]="None",x[x.Vertical=1]="Vertical",x[x.Horizontal=2]="Horizontal",x[x.Both=3]="Both",x))(Ks||{});class J{n;Ep;Up;pa;w;so;ft;ct;hi;Zt;Vp;Zs;Nt;cs;il;ya;Me;Th;et;Xt;sl;ve;Ke;wd;de;xd;Ot;he;nl;A1;wa;df;constructor(){V.Je(this),this.n=30723,this.Zt=1,this.Vp="",this.Zs=null,this.Nt=null,this.ct=new P(NaN,NaN).k(),this.cs=nt.jw,this.il=new Nt,this.ya=new Nt,this.Me=null,this.Th=1,this.et=1,this.Xt=0,this.sl=Dt.em,this.hi=new I(NaN,NaN,NaN,NaN).k(),this.ve=new I(NaN,NaN,NaN,NaN).k(),this.Ke=new I(0,0,NaN,NaN).k(),this.wd=null,this.Ep=null,this.ft=null,this.de=T.Default,this.xd=T.Default,this.Up=0,this.pa=0,this.Ot=null,this.w=null,this.so=null,this.he=null,this.A1=null,this.wa=null,this.nl=null,this.df=null}cloneProtected(t){t.n=(this.n|2048|4096)&-32769,t.Zt=this.Zt,t.Vp=this.Vp,t.Nt=this.Nt,t.ct.h(this.ct),t.cs=this.cs.C(),this.Me!==null?t.Me=this.Me.copy():t.Me=null,t.et=this.et,t.Xt=this.Xt,t.sl=this.sl.C(),t.hi.h(this.hi),t.ve.h(this.ve),t.Ke.h(this.Ke),t.Ep=this.Ep,this.ft!==null&&(t.ft=this.ft.copy()),t.de=this.de.C(),t.xd=this.xd.C(),t.Up=this.Up,t.pa=this.pa,this.Ot!==null&&(t.Ot=this.Ot.copy()),this.w!==null&&(this.w.me?t.w=this.w:t.w=this.w.copy()),this.so!==null&&(t.so=this.so.slice()),this.he!==null&&(t.he=this.he.copy())}addCopyProperty(t){let e=this.so;if(!Array.isArray(e))e=[],this.so=e;else for(let i=0;i<e.length;i++)if(e[i]===t)return;e.push(t)}Ho(t){t.wd=null,t.nl=null,t.f()}clone(){let t=new this.constructor;return this.cloneProtected(t),this.jT(t),t}jT(t){if(this.so!==null)for(let e=0;e<this.so.length;e++){let i=this.so[e];t[i]=this[i]}}rI(){if(this.so!==null)for(let t=0;t<this.so.length;t++){let e=this.so[t];delete this[e]}}copy(){return this.clone()}WS(){let t=this.Fe;if(t!==null){this.Fe=null;for(let e of t)e.bd()&&(e.isToData?this.themeData(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter):e.isToObject?this.themeObject(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter,e.sourceName):e.isToModel?this.themeModel(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter):this.theme(e.targetProperty,e.sourceProperty,e.themeSource,e.converter,e.themeConverter))}return this}fe(t){t in Vi?this.segmentOrientation=t:t in Bi?this.stretch=t:m.ur(this,t)}toString(){return m.Yn(this.constructor)+"#"+V.xs(this)}static None=0;static Default=1;static Fill=2;static Vertical;static Horizontal;static Uniform=6;static UniformToFill=7;static FlipVertical=1;static FlipHorizontal=2;static FlipBoth=3;xa(){this.w!==null&&(this.w.me=!0)}Yt(){return this.w===null?this.w=new Ke:this.w.me&&(this.w=this.w.copy()),this.w}$i(){if(this.ft===null){let t=new Ni;t.Dh=T.None,t.vh=T.None,t.Fh=10,t.Rh=10,t.Oh=0,t.Ih=0,this.ft=t}return this.ft}raiseChangedEvent(t,e,i,s,n,o,r){let a=this.part;if(a!==null){a.gf(t,e,i,s,n,o,r),i===this&&t===2&&this.mf()&&this.Eh(a,e);let h=this.diagram;if(this.Ts!==null&&h!==null&&h.Za&&!h.undoManager.isUndoingRedoing&&!h.animationManager.Uu){let l=this.Ts.get(e);if(l!==null&&h.animationManager.isEnabled&&!h.animationManager.isTicking){this.df===null&&(this.df=new Mt);let u=h.undoManager.transactionLevel===0;if(l.startCondition===2?u=!0:l.startCondition===3&&(u=!1),u){let c=new xe;l.OR(c);let d=this.df.get(l);d!==null&&d.stop(),this.df.set(l,c),c.Zx=this,c.AM=l,c.add(this,e,s,n),c.start()}else h.animationManager.getBundleAnimation().add(this,e,s,n)}}if(this instanceof G&&i===a&&a.SC()&&a.data!==null){let l=this.D.r,u=l.length;for(let c=0;c<u;c++){let d=l[c];d instanceof G&&d.Sn(f=>{f.data!==null&&f.SC()&&f.updateTargetBindings(e)})}}}}DR(t){this.df&&this.df.delete(t)}Go(){if(this.diagram!==null&&this.findBindingPanel()===null&&this.Fe!==null){let t=this.diagram.model,e=this.Fe.iterator;for(;e.next();){let i=e.value;if(!i.isToTheme)continue;let s=null,n=i.sourceName;i.isToObject&&(s=this.WT(n));let o=this,r=i.targetId;r!==-1&&(o=this.Bp(r),o===null)||(n==="/"?s=o.part:n==="."?s=o:n===".."&&(s=o.panel),i.updateTarget(o,s,void 0,t))}}}Eh(t,e){let i=this.findBindingPanel();if(i!==null){let s=t.diagram,n=this.Fe.iterator;for(;n.next();){let o=n.value,r=null;if(o.isToObject){if(r=o.JT(i,this),r===null)continue;o.updateSource(this,r,e,null)}else if(o.isToModel)s!==null&&!s.wi&&o.updateSource(this,s.model.modelData,e,i);else if(!o.isToTheme){let a=i.data;if(a===null)continue;s!==null&&!s.wi&&o.updateSource(this,a,e,i)}if(r===this){let a=o.targetId,h=i.Bp(a);h!==null&&o.updateTarget(h,r,e,s?.model)}}}}Bp(t){return this.no===t?this:null}WT(t){let e;return t===""?e=this:t==="/"?e=this:t==="."?e=this:t===".."?e=this:e=this.part.findObject(t),e}get no(){return this.w!==null?this.w.no:-1}set no(t){this.no!==t&&(this.w===null&&(this.w=new Ke),this.w.no=t)}get Fe(){return this.w!==null?this.w.Fe:null}set Fe(t){this.Fe!==t&&(this.w===null&&(this.w=new Ke),this.w.Fe=t)}get oo(){return this.w!==null?this.w.oo:null}set oo(t){this.oo!==t&&(this.w===null&&(this.w=new Ke),this.w.oo=t)}raiseChanged(t,e,i){this.raiseChangedEvent(2,t,this,e,i)}t(t,e,i){this.raiseChangedEvent(2,t,this,e,i)}ro(t,e,i,s){let n=this.hi;if(n.e(t,e,i,s),this.et!==1||this.Xt!==0){this.Me===null&&(this.Me=new Nt);let o=this.Me;o.Ue(),this.zp(o,t,e,i,s),o.im(n)}}$T(t,e,i){return this.pickable===!1?!1:(i.bc(this.v),e?this.intersectsRect(t,i):this.containedInRect(t,i))}ZT(t,e,i){if(this.pickable===!1)return!1;let s=this.naturalBounds,n=t.distanceSquaredPoint(e);return i?P.distanceLineSegmentSquared(t.x,t.y,0,0,0,s.height)<=n||P.distanceLineSegmentSquared(t.x,t.y,0,s.height,s.width,s.height)<=n||P.distanceLineSegmentSquared(t.x,t.y,s.width,s.height,s.width,0)<=n||P.distanceLineSegmentSquared(t.x,t.y,s.width,0,0,0)<=n:t.distanceSquared(0,0)<=n&&t.distanceSquared(0,s.height)<=n&&t.distanceSquared(s.width,0)<=n&&t.distanceSquared(s.width,s.height)<=n}Cn(){return!0}containsPoint(t){let e=P.l();e.h(t),this.v.gt(e);let i=this.actualBounds;if(!i.isReal())return P.i(e),!1;let s=this.diagram;if(s!==null&&s.fp){let o=s.getInputOption("extraTouchThreshold"),r=s.getInputOption("extraTouchArea"),a=r/2,h=this.naturalBounds,l=this.getDocumentScale()*s.scale,u=1/l;if(h.width*l<o&&h.height*l<o){let c=I.contains(i.x-a*u,i.y-a*u,i.width+r*u,i.height+r*u,e.x,e.y);return P.i(e),c}}let n=!1;return(this instanceof vt||this instanceof it?I.contains(i.x-5,i.y-5,i.width+10,i.height+10,e.x,e.y):i.containsPoint(e))&&(this.he&&!this.he.containsPoint(e)?n=!1:this.Nt!==null&&this.Ke.containsPoint(t)?n=!0:n=this.ba(t)),P.i(e),n}ba(t){let e=this.naturalBounds;return I.contains(0,0,e.width,e.height,t.x,t.y)}containsRect(t){if(this.angle===0)return this.actualBounds.containsRect(t);let e=this.naturalBounds,i=I.z(0,0,e.width,e.height),s=this.v,n=!1,o=P.z(t.x,t.y);return i.containsPoint(s.Ni(o))&&(o.e(t.x,t.bottom),i.containsPoint(s.Ni(o))&&(o.e(t.right,t.bottom),i.containsPoint(s.Ni(o))&&(o.e(t.right,t.y),i.containsPoint(s.Ni(o))&&(n=!0)))),P.i(o),I.i(i),n}containedInRect(t,e){if(e===void 0)return t.containsRect(this.actualBounds);let i=this.naturalBounds,s=e,n=!1,o=P.z(0,0);return t.containsPoint(s.gt(o))&&(o.e(0,i.height),t.containsPoint(s.gt(o))&&(o.e(i.width,i.height),t.containsPoint(s.gt(o))&&(o.e(i.width,0),t.containsPoint(s.gt(o))&&(n=!0)))),P.i(o),n}intersectsRect(t,e){if(e===void 0&&(e=this.v,this.angle===0))return t.intersectsRect(this.actualBounds);let i=this.naturalBounds,s=e,n=P.z(0,0),o=P.z(0,i.height),r=P.z(i.width,i.height),a=P.z(i.width,0),h=!1;if(t.containsPoint(s.gt(n))||t.containsPoint(s.gt(o))||t.containsPoint(s.gt(r))||t.containsPoint(s.gt(a)))h=!0;else{let l=I.z(0,0,i.width,i.height),u=P.z(t.x,t.y);l.containsPoint(s.Ni(u))?h=!0:(u.e(t.x,t.bottom),l.containsPoint(s.Ni(u))?h=!0:(u.e(t.right,t.bottom),l.containsPoint(s.Ni(u))?h=!0:(u.e(t.right,t.y),l.containsPoint(s.Ni(u))&&(h=!0)))),P.i(u),I.i(l),h||(C.tx(t,n,o)||C.tx(t,o,r)||C.tx(t,r,a)||C.tx(t,a,n))&&(h=!0)}return P.i(n),P.i(o),P.i(r),P.i(a),h}getDocumentPoint(t,e){if(e===void 0&&(e=new P),t instanceof T){let i=t,s=this.naturalBounds;return e.e(i.x*s.width+i.offsetX,i.y*s.height+i.offsetY),this.Js.gt(e),e}else return e.set(t),this.Js.gt(e),e}getDocumentBounds(t){t===void 0&&(t=new I);let e=this.naturalBounds,i=this.Js,s=P.z(0,0).v(i);return t.e(s.x,s.y,0,0),s.e(e.width,0).v(i),t.re(s.x,s.y,0,0),s.e(e.width,e.height).v(i),t.re(s.x,s.y,0,0),s.e(0,e.height).v(i),t.re(s.x,s.y,0,0),P.i(s),t}getDocumentAngle(){return this.Js.KF()}getDocumentScale(){if(this.Xp()===!1)return this.Th;let t=this.et;return this.panel!==null?t*this.panel.getDocumentScale():t}getLocalPoint(t,e){return e===void 0&&(e=new P),e.h(t),this.Js.Ni(e),e}getNearestIntersectionPoint(t,e,i){return this.pf(t.x,t.y,e.x,e.y,i)}pf(t,e,i,s,n){let o=this.v,r=1/(o.m11*o.m22-o.m12*o.m21),a=o.m22*r,h=-o.m12*r,l=-o.m21*r,u=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),d=r*(o.m12*o.dx-o.m11*o.dy),f=t*a+e*l+c,p=t*h+e*u+d,g=i*a+s*l+c,y=i*h+s*u+d;n.e(0,0);let b=this.naturalBounds,v=C.Al(0,0,b.width,b.height,f,p,g,y,n);return n.v(o),v}ht(t,e,i,s){if(this.Xo()===!1)return;let n=this.sl,o=n.right+n.left,r=n.top+n.bottom;t=Math.max(t-o,0),e=Math.max(e-r,0),i=i||0,s=s||0,i=Math.max(i-o,0),s=Math.max(s-r,0);let a=this.angle,h=0,l=this.desiredSize,u=this.Gp();a===90||a===270?(t=isFinite(l.height)?l.height+u:t,e=isFinite(l.width)?l.width+u:e):(t=isFinite(l.width)?l.width+u:t,e=isFinite(l.height)?l.height+u:e);let c=i||0,d=s||0,f=this instanceof G;switch(this.Qs(!0)){case 0:c=0,d=0,f&&(t=1/0,e=1/0);break;case 2:isFinite(t)&&t>i&&(c=t),isFinite(e)&&e>s&&(d=e);break;case 5:isFinite(t)&&t>i&&(c=t),d=0,f&&(e=1/0);break;case 4:isFinite(e)&&e>s&&(d=e),c=0,f&&(t=1/0);break}let p=this.maxSize,g=this.minSize;c>p.width&&g.width<p.width&&(c=p.width),d>p.height&&g.height<p.height&&(d=p.height),i=Math.max(c,g.width),s=Math.max(d,g.height),p.width<i&&(i=Math.min(g.width,i)),p.height<s&&(s=Math.min(g.height,s)),t=Math.min(p.width,t),e=Math.min(p.height,e),t=Math.max(i,t),e=Math.max(s,e),(a===90||a===270)&&(h=t,t=e,e=h,h=i,i=s,s=h),this.hi.ce(),this.kd(t,e,i,s),this.hi.k(),this.hi.isReal()||m.o("Non-real measuredBounds has been set. Object "+this+", measuredBounds: "+this.hi.toString()),this.xi(!1)}kd(t,e,i,s){}_s(){return!1}Ut(t,e,i,s,n){this.yf();let o=I.l();o.h(this.ve),this.ve.ce(),this.as()===!1?this.ve.e(t,e,i,s):this.ka(t,e,i,s),this.ve.k(),n===void 0?this.he=null:this.he=n;let r=!1;if(n!==void 0)r=!0;else{let a=this.panel;if(a!==null&&a.ol()&&(a=a.panel),a!==null){let h=a.Ke,l=this.measuredBounds,u=e+l.height,c=t+l.width;if(r=!(0<=t+.05&&c<=h.width+.05&&0<=e+.05&&u<=h.height+.05),this instanceof lt){let d=this.naturalBounds;(this.Yp>d.height||this.pe>d.width)&&(r=!0)}}}r?this.n|=256:this.n&=-257,this.ve.isReal()||m.o("Non-real actualBounds has been set. Object "+this+", actualBounds: "+this.ve.toString()),this.Pd(o,this.ve),this.lo(!1),I.i(o)}ka(t,e,i,s){}commonArrange(t,e,i,s){if(this.ve.e(t,e,i,s),this.desiredSize.isReal())return;let n=this.hi,o=this.sl,r=o.right+o.left,a=o.top+o.bottom,h=n.width+r,l=n.height+a;i+=r,s+=a;let u=this.Qs(!0);switch(h===i&&l===s&&(u=0),u){case 0:(h>i||l>s)&&(this.xi(!0),this.ht(h>i?i:h,l>s?s:l,0,0));break;case 2:this.xi(!0),this.ht(i,s,0,0);break;case 5:this.xi(!0),this.ht(i,l,0,0);break;case 4:this.xi(!0),this.ht(h,s,0,0);break}}Pd(t,e){let i=this.part;i!==null&&i.diagram!==null&&((i.selectionObject===this||i.resizeObject===this||i.rotateObject===this)&&i.MC(!0),this.N(),!t.equalsApproxClose(e)&&(i.Pa(),this.Kp(i)))}Kp(t){this.portId!==null&&(t.MC(!0),t instanceof $&&t.invalidateConnectedLinks(void 0,this))}get shadowVisible(){return this.w!==null?this.w.Hp:null}set shadowVisible(t){let e=this.shadowVisible;e!==t&&(this.Yt().Hp=t,this.Zi(!0),this.N(),this.t("shadowVisible",e,t))}lI(t,e){let i=this.naturalBounds,s=this.ya,n=s.m11,o=s.m21,r=s.dx,a=s.m12,h=s.m22,l=s.dy,u=0,c=0,d=u,f=c;u=d*n+f*o+r,c=d*a+f*h+l;let p=u,g=c,y=0,b=0;d=i.width+e,f=0,u=d*n+f*o+r,c=d*a+f*h+l;let v=Math.min(p,u),w=Math.min(g,c);y=Math.max(p+y,u)-v,b=Math.max(g+b,c)-w,p=v,g=w,d=i.width+e,f=i.height+e,u=d*n+f*o+r,c=d*a+f*h+l,v=Math.min(p,u),w=Math.min(g,c),y=Math.max(p+y,u)-v,b=Math.max(g+b,c)-w,p=v,g=w,d=0,f=i.height+e,u=d*n+f*o+r,c=d*a+f*h+l,v=Math.min(p,u),w=Math.min(g,c),y=Math.max(p+y,u)-v,b=Math.max(g+b,c)-w,p=v,g=w;let k=t.viewportBounds,S=k.x,N=k.y,D=k.width,L=k.height;return p>D+S||S>y+p||g>L+N||N>b+g}Ge(t,e){if(this.aI(t,e)||!this.visible)return;let i=this.opacity;if(i===0)return;let s=1;i!==1&&(s=t.globalAlpha,t.globalAlpha=s*i);let n="";this.filter!==""&&(n=t.filter,t.filter=this.filter);let o=this.v,r=this.panel;this.Xp()===!0&&this.T1();let a=this.part,h=!1,l=0;if(a&&e.getRenderingHint("drawShadows")&&(h=a.isShadowed,h)){let g=a.shadowOffset;l=Math.max(g.y,g.x)*e.scale*e.$e}let u=this instanceof G&&this.ol(),c=this.ve;if(u&&(this.QT(h,t,!1,r),this.hI(t,e),this._T(h,t,!1,r),this.tD(h,t,!1)),u||!u&&(c.width===0||c.height===0||isNaN(c.x)||isNaN(c.y))){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let d=this._s();if(!e.mh&&d&&this.lI(e,l)){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}let f=(this.n&256)!==0;if(t.clipInsteadOfFill&&(f=!1),this instanceof lt&&(t.font=this.font),f){let g=r.Cn()?r.naturalBounds:r.actualBounds,y=Math.max(c.x,g.x),b=Math.max(c.y,g.y),v=Math.min(c.right,g.right)-y,w=Math.min(c.bottom,g.bottom)-b,k=this.he;if(k!==null&&(y=k.x,b=k.y,v=k.width,w=k.height),y>c.width+c.x||c.x>g.width+g.x){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}t.save(),t.beginPath(),t.rect(y,b,v,w),t.clip()}if(d){if(!a.isVisible()){i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n);return}if(h){let g=a.shadowOffset;t.shadowsSet(g.x*e.scale*this.scale*e.$e,g.y*e.scale*this.scale*e.$e,a.shadowBlur),t.shadowsOn(),t.shadowColor=a.shadowColor}}let p=this.naturalBounds;if(t.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.QT(h,t,d,r),this.Nt!==null&&(t.commitTransform(),this.D1(t,p,c)),this._T(h,t,d,r),this.Sa(t,e),this.tD(h,t,d),f&&(t.restore(),t.clearContextCache(this instanceof G)),!o.TP()){let g=1/(o.m11*o.m22-o.m12*o.m21);t.transform(o.m22*g,-o.m12*g,-o.m21*g,o.m11*g,g*(o.m21*o.dy-o.m22*o.dx),g*(o.m12*o.dx-o.m11*o.dy))}i!==1&&(t.globalAlpha=s),this.filter!==""&&(t.filter=n)}QT(t,e,i,s){t&&this.shadowVisible===!0?e.shadowsOn():t&&this.shadowVisible===!1&&e.shadowsOff(),t&&this.v1(s)&&this.shadowVisible===null&&e.shadowsOff()}_T(t,e,i,s){t&&(this.Nt!==null||this.v1(s))?(this.F1(!0),this.shadowVisible===null&&e.shadowsOff()):this.F1(!1)}tD(t,e,i){t&&this.CC()===!0&&e.shadowsOn(),i&&t&&e.shadowsOff()}cI(t,e,i){let s=this.part,n=!1;s&&t.getRenderingHint("drawShadows")&&(n=s.isShadowed),e.clipInsteadOfFill&&(n=!1),this._s()&&n&&e.shadowsOn(),n&&this.shadowVisible===!0?e.shadowsOn():n&&this.shadowVisible===!1&&e.shadowsOff();let o=this.panel;if(n&&this.v1(o)&&this.shadowVisible===null&&e.shadowsOff(),e.rl){let r=t.computePixelRatio(),a=`drop-shadow(${e.shadowOffsetX/r}px ${e.shadowOffsetY/r}px ${e.shadowBlur/r/2}px ${e.shadowColor})`;this.background!==null&&i.Nt.setAttributeNS(null,"filter",a)}return n&&(this.Nt!==null||this.v1(o))?(this.F1(!0),this.shadowVisible===null&&e.shadowsOff()):this.F1(!1),n}fI(t,e,i,s){if(i.rl){let n=e.computePixelRatio(),o=`drop-shadow(${i.shadowOffsetX/n}px ${i.shadowOffsetY/n}px ${i.shadowBlur/n/2}px ${i.shadowColor})`;this.NC(t,o)}s&&this.CC()===!0&&i.shadowsOn(),this._s()&&i.shadowsOff()}v1(t){return t===null?!1:(t.ol()&&(t=t.panel),t.CC()||(t.type===G.Auto||t.type===G.Spot)&&t.findMainElement()!==this)}NC(t,e){}D1(t,e,i){let s=this.Gp(),n=e.x,o=e.y,r=e.width+s,a=e.height+s;this.kn(t,this.Nt,!0,!1,e,i),this.Nt instanceof R&&this.Nt.type===3?(t.beginPath(),t.rect(n-s/2,o-s/2,r,a),t.fillContext(this.Nt,!1,null)):t.fillRect(n-s/2,o-s/2,r,a)}eD(t,e){let i=t.uI(this),s=t.wa!==null?t.wa:t.svg;if(s!==null&&i!==-1){for(;i!==0&&!t.elt(i-1).isVisibleObject();)i--;if(i===0)this.dI(t,e,s);else{let n=t.elt(i-1).svg;n!==null?n.after(e):s.appendChild(e)}}}dI(t,e,i){if(t.type===G.Table){let s=i.getElementsByClassName("gojs-ts"),n=s.length!==0?s[0]:null;n!==null&&n.after(e)}else i.Nt?i.Nt.after(e):i.prepend(e)}aI(t,e){if(!(t instanceof ae))return!1;if(!this.visible||this.opacity===0)return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;let i=this.ve;if(this._s()&&(!this.isVisible()||i.width===0||i.height===0||isNaN(i.x)||isNaN(i.y)))return this.svg!==null&&this.svg.parentNode!==null&&this.svg.remove(),!0;t.setCurrentTransform(1,0,0,1,0,0);let s=this.panel,n=this.Sd(t);if(this.wf(t,e,n))return this.iD(this.svg),this.svg.parentElement!==null?(this._s()&&(t.lastDrawnPart=this.svg),!0):(this._s()?(t.lastDrawnPart!==null?t.lastDrawnPart.after(this.svg):t.diagramGroup.prepend(this.svg),t.lastDrawnPart=this.svg):s&&this.eD(s,this.svg),!0);if(this.Zi(!1),this._s()&&this.isShadowed){let p=this.shadowOffset;t.shadowsSet(p.x*e.scale*this.scale*e.$e,p.y*e.scale*this.scale*e.$e,this.shadowBlur),t.shadowsOn(),t.shadowColor=this.shadowColor}this instanceof lt&&(t.font=this.font),t.currentElement=null;let o=this.v,r=this instanceof G,a=this instanceof G?this.ol():!1,h=this.svg;if(this.Xp()===!0&&this.T1(),t.outerGroup=!1,n)if(t.outerGroup=!0,r&&a)t.newGroup(1,0,0,1,0,0),this.svg=t.lastCreatedElement;else if(r&&this.isClipping){let p=this.findMainElement(),g=0,y=0;p!==null&&(g=p.actualBounds.x,y=p.actualBounds.y),t.newGroup(o.m11,o.m12,o.m21,o.m22,o.dx+g,o.dy+y),this.svg=t.lastCreatedElement,p!==null&&t.createOrUpdateClipGroup(this,p.actualBounds),t.currentElement=t.lastCreatedElement}else r?(t.newGroup(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.svg=t.lastCreatedElement):t.newGroup(1,0,0,1,0,0);let l=this.naturalBounds;r||t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.background!==null&&(r?(a&&t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.D1(t,l,i),a&&t.setCurrentTransform(1,0,0,1,0,0)):(t.setCurrentTransform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),this.D1(t,l,i)),t.currentElement.Nt=t.lastCreatedElement,t.currentElement.prepend(t.lastCreatedElement));let u=this.cI(e,t,t.currentElement);this.Sa(t,e),r&&t.endGroup(),t.outerGroup&&t.endGroup();let c=t.surface.dd,d=r?this.svg:t.currentElement;if(h!==null&&h.parentNode!==null&&d!==h&&(this.panel===null||h.parentNode===this.panel.svg)){let p=this.svg.getAttribute("filter");return p!==null&&d.setAttribute("filter",p),this.filter!==""&&d.setAttributeNS(null,"filter",this.filter),h.replaceWith(d),this.svg=d,d!==null&&this.qp(t,s,i,d),!0}if(this.svg=d,c!==null&&d===null&&t.dummyGroup(),d===null)return!0;this.qp(t,s,i,d),this.fI(d,e,t,u);let f=this._s()?this.opacity*t.globalAlpha:this.opacity;if(f!==1&&d.setAttributeNS(null,"opacity",f.toString()),this.filter!==""&&d.setAttributeNS(null,"filter",this.filter),this._s()){if(h!==null&&d!==h&&h.parentNode===t.diagramGroup){let p=h.getAttribute("filter");p!==null&&d.setAttribute("filter",p),h.replaceWith(d)}else t.lastDrawnPart?t.lastDrawnPart.after(d):t.diagramGroup.prepend(d);t.lastDrawnPart=d}else s!==null&&this.eD(s,d);return c!==null&&c(this,d),this.iD(d),!0}iD(t){let e=this,i=t.dataset;e instanceof J&&(e.portId!==null&&(i.portId=e.portId),e instanceof G&&(isNaN(e.itemIndex)||(i.itemIndex=e.itemIndex.toString()),e instanceof pt&&(i.className=m.Yn(e),e.key!==void 0&&(i.key=e.key.toString()),e.containingGroup!==null&&(i.group=e.containingGroup.key.toString()),e instanceof j&&(e.fromNode!==null&&e.fromNode.key!==void 0&&(i.fromKey=e.fromNode.key.toString()),e.fromPortId!==""&&(i.fromPortId=e.fromPortId),e.toNode!==null&&e.toNode.key!==void 0&&(i.toKey=e.toNode.key.toString()),e.toPortId!==""&&(i.toPortId=e.toPortId)))))}qp(t,e,i,s){let n=(this.n&256)!==0;if(t.clipInsteadOfFill&&(n=!1),!n){s.removeAttributeNS(null,"clip-path");return}let o=e.Cn()?e.naturalBounds:e.actualBounds,r=Math.max(i.x,o.x),a=Math.max(i.y,o.y),h=Math.min(i.right,o.right)-r,l=Math.min(i.bottom,o.bottom)-a,u=this.he;u!==null&&(r=u.x,a=u.y,h=u.width,l=u.height);let c=I.z(r,a,Math.max(h,0),Math.max(l,0));if(this instanceof G){let d=Nt.l();d.set(this.v),d.Zw(),d.im(c),Nt.i(d)}s.setAttributeNS(null,"clip-path",`path(' M ${c.x},${c.y} L ${c.width+c.x} ${c.y} L ${c.width+c.x} ${c.height+c.y} L ${c.x} ${c.height+c.y} z') view-box`),I.i(c)}gI(){if(this.svg===null)return;let t=this.svg.innerHTML.match(/url\(#((CLIP|GRAD).+?)\)/g),e=this.svg.ownerDocument;if(t!==null)for(let i of t){let s=e.getElementById(i.split("#")[1].slice(0,-1));s!==null&&s.remove()}this.svg.remove()}hI(t,e){let i=this.ve,s=this.Ke,n=this.Nt;n!==null&&t.commitTransform(),n!==null&&(this.kn(t,n,!0,!1,s,i),n instanceof R&&n.type===3?(t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fillContext(n,!1,null)):t.fillRect(i.x,i.y,i.width,i.height)),this.Sa(t,e)}Sa(t,e){}xf(){this.Zi(!0)}wf(t,e,i){let s=this.svg;if(this.mI()){if(this.xf(),this.Zi(!1),s===null)return!1;let u=s.getAttribute("clip-path");if(u!==null&&u.includes("url")){let c=t.svg.getElementById(u.split("#")[1].slice(0,-1));c!==null&&c.remove()}return s.getAttribute("filter")&&s.removeAttribute("filter"),!1}if(s===null)return!1;if(!this.visible)return s.remove(),!1;if(s.nodeName!=="g"&&i||s.nodeName==="g"&&!i)return!1;let n=this.v,o="matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+n.dx+", "+n.dy+")",r=this instanceof G,a=r?this.ol():!1;if(!(r&&a))if(this instanceof Bt){let u=this.R1;t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),u!==null&&t.amendImageTransform(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7]),i?s.lastElementChild.setAttributeNS(null,"transform",t.getCurrentTransform()):s.setAttributeNS(null,"transform",t.getCurrentTransform())}else if(i&&!r)if(this instanceof it){let u=s.getElementsByTagName("path");for(let c=0;c<u.length;c++)u[c].setAttributeNS(null,"transform",o)}else if(this instanceof lt){let u=s.getElementsByTagName("text"),c=typeof this.stroke=="string"?this.stroke:null;for(let d=0;d<u.length;d++)u[d].setAttributeNS(null,"transform",o),c&&u[d].setAttributeNS(null,"fill",c)}else(s.lastElementChild||s).setAttributeNS(null,"transform",o);else if(r&&this.isClipping&&this.wa){let u=this.findMainElement(),c=u!==null?u.actualBounds.x:0,d=u!==null?u.actualBounds.y:0;this.wa.setAttributeNS(null,"transform","matrix(1,0,0,1,"+-c+", "+-d+")"),s.setAttributeNS(null,"transform","matrix("+n.m11+", "+n.m12+", "+n.m21+", "+n.m22+", "+(n.dx+c)+", "+(n.dy+d)+")")}else s.setAttributeNS(null,"transform",o);let h=this._s()?this.opacity*t.globalAlpha:this.opacity;h===1?s.removeAttribute("opacity"):s.setAttributeNS(null,"opacity",h.toString()),t.setCurrentTransform(1,0,0,1,0,0);let l=this.wa?this.wa:this.A1;if(this.background!==null||l.Nt!==void 0){let u=l.Nt;if(this.background===null)t.removeOldGradient(this,l.Nt,"fill"),l.Nt.remove(),l.Nt=void 0;else{if((a||i&&!(this instanceof G))&&t.setCurrentTransform(n.m11,n.m12,n.m21,n.m22,n.dx,n.dy),this.D1(t,this.naturalBounds,this.actualBounds),l.Nt){t.removeOldGradient(this,l.Nt,"fill");let c=l.Nt.getAttribute("filter");c!==null&&t.lastCreatedElement.setAttribute("filter",c),l.Nt.replaceWith(t.lastCreatedElement)}else l.prepend(t.lastCreatedElement);l.Nt=t.lastCreatedElement}u&&t.removeOldGradient(this,u,"fill")}return this.qp(t,this.panel,this.actualBounds,s),!0}Sd(t){if(this.background!==null)return!0;let e=(this.n&256)!==0;return t.clipInsteadOfFill&&(e=!1),!!e}static VU(t,e,i,s,n,o,r){let a=.001,h=o.length;t.moveTo(e,i);let l=s-e,u=n-i;l===0&&(l=.001);let c=u/l,d=Math.sqrt(l*l+u*u),f=0,p=!0;a=o[f%h];let g=r!==0;for(;d>=.1;){if(g){for(a=o[f++%h],a-=r;a<0;)a+=o[f++%h],p=!p;g=!1}else a=o[f++%h];a>d&&(a=d);let y=Math.sqrt(a*a/(1+c*c));l<0&&(y=-y),e+=y,i+=c*y,p?t.lineTo(e,i):t.moveTo(e,i),d-=a,p=!p}}kn(t,e,i,s,n,o){let r=1,a=1;if(typeof e=="string"){i?t.fillStyle=e:t.strokeStyle=e;return}else if(e.type===1){i?t.fillStyle=e.color:t.strokeStyle=e.color;return}let h,l=this.Gp();r=n.width,a=n.height,s?(r=o.width,a=o.height):i||(r+=l,a+=l);let u=t instanceof ci;if(u&&e.Nn&&(e.type===4||e.bf===r&&e.O1===a))h=e.Nn;else{let c=0,d=0,f=0,p=0,g=0,y=0,b=0,v=0;if(s?(b=o.x,v=o.y):i||(b-=l/2,v-=l/2),c=e.start.x*r+e.start.offsetX+b,d=e.start.y*a+e.start.offsetY+v,f=e.end.x*r+e.end.offsetX+b,p=e.end.y*a+e.end.offsetY+v,e.type===2)h=t.createLinearGradient(c,d,f,p);else if(e.type===3)y=isNaN(e.endRadius)?Math.max(r,a)/2:e.endRadius,isNaN(e.startRadius)?(g=0,y=Math.max(r,a)/2):g=e.startRadius,h=t.createRadialGradient(c,d,g,f,p,y);else if(e.type===4)try{h=t.createPattern(e.pattern,"repeat")}catch{h=null}else m.si(e.type,"Brush type");if(e.type!==4){let w=e.colorStops;if(w!==null){let k=w.iterator;for(;k.next();)h.addColorStop(k.key,k.value)}}if(u&&(e.Nn=h,h!==null&&(e.bf=r,e.O1=a),h===null&&e.type===4&&e.bf!==-1)){e.bf=-1;let w=this.diagram;w!==null&&e.bf===-1&&m.dn(()=>{w.redraw()},600)}}i?t.fillStyle=h:t.strokeStyle=h}isContainedBy(t){return t instanceof G?this.pI(this,t):!1}pI(t,e){if(t===e||e===null)return!1;let i=t.panel;for(;i!==null;){if(i===e)return!0;i=i.panel}return!1}isVisibleObject(){if(!this.visible)return!1;let t=this.panel;return t!==null?t.isVisibleObject():!0}isEnabledObject(){let t=this instanceof G?this:this.panel;for(;t!==null&&t.isEnabled;)t=t.panel;return t===null}get enabledChanged(){return this.w!==null?this.w.jp:null}set enabledChanged(t){let e=this.enabledChanged;e!==t&&(t!==null&&m.S(t,J,"enabledChanged"),this.Yt().jp=t,this.t("enabledChanged",e,t))}T1(){if(this.I1()===!0){let t=this.il;if(t.Ue(),!this.ve.isReal()||!this.hi.isReal()){this.Md(!1),this.Ma(!1);return}if(t.Gs(this.ve.x-this.hi.x,this.ve.y-this.hi.y),this.scale!==1||this.angle!==0){let e=this.naturalBounds;this.zp(t,e.x,e.y,e.width,e.height)}this.Md(!1),this.Ma(!0)}if(this.Xp()===!0){let t=this.panel;if(t===null)this.ya.set(this.il),this.Th=this.scale;else if(t.Js!==null){let e=this.ya;e.Ue(),t.Cn()?e.bc(t.ya):t.panel!==null&&e.bc(t.panel.ya),e.bc(this.il),this.Th=this.scale*t.Th}this.Ma(!1)}}zp(t,e,i,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;let o=P.l();o.setSpot(e,i,s,n,T.Center),t.ks(this.Xt,o.x,o.y),P.i(o)}f(t){if(this.Xo())return;t===void 0&&(t=!1),this.xi(!0),this.lo(!0);let e=this.panel;e!==null&&!t&&e.f()}kf(){this.Xo()||(this.xi(!0),this.lo(!0))}Pf(t){if(this.as())return;let e=this.panel;!t&&e!==null&&e.f(),this.lo(!0)}yf(){this.I1()===!1&&(this.Md(!0),this.Ma(!0))}LC(){this.Ma(!0)}N(){let t=this.part;t!==null&&t.N()}Qs(t){let e=this.stretch,i=this.panel;if(i===null)return this.qo(e===1?0:e,t);if(i.type===G.Table)return this.Wp(i.getRowDefinition(this.row),i.getColumnDefinition(this.column),t);if(i.type===G.Auto&&i.findMainElement()===this)return this.qo(2,t);if(e===1){if(i.type===G.Spot&&i.findMainElement()===this)return this.qo(2,t);let s=i.defaultStretch;return s===1?this.qo(0,t):this.qo(s,t)}return this.qo(e,t)}Wp(t,e,i){let s=this.stretch;if(s!==1)return this.qo(s,i);let n=null,o=null;switch(t.stretch){case 1:case 5:break;case 4:o=!0;break;case 2:o=!0;break}switch(e.stretch){case 1:case 4:break;case 5:n=!0;break;case 2:n=!0;break}let r=this.panel.defaultStretch;return n===null&&(n=r===5||r===2),o===null&&(o=r===4||r===2),n===!0&&o===!0?this.qo(2,i):n===!0?this.qo(5,i):o===!0?this.qo(4,i):this.qo(0,i)}qo(t,e){if(e)return t;if(t===0)return 0;let i=this.desiredSize;if(i.isReal())return 0;let s=!isNaN(i.width),n=!isNaN(i.height),o=this.angle;if(s)if(o!==90&&o!==270){if(t===5)return 0;if(t===2)return 4}else{if(t===4)return 0;if(t===2)return 5}if(n)if(o!==90&&o!==270){if(t===4)return 0;if(t===2)return 5}else{if(t===5)return 0;if(t===2)return 4}return t}get segmentOrientation(){return this.Ot!==null?this.Ot.Jp:0}set segmentOrientation(t){let e=this.segmentOrientation;e!==t&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.Jp=t,this.f(),this.t("segmentOrientation",e,t),t===0&&(this.angle=0))}yI(){this.segmentOrientation=21}get segmentIndex(){return this.Ot!==null?this.Ot.$p:-1/0}set segmentIndex(t){t=Math.round(t);let e=this.segmentIndex;e!==t&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.$p=t,this.f(),this.t("segmentIndex",e,t))}get segmentFraction(){return this.Ot!==null?this.Ot.Zp:0}set segmentFraction(t){t<0?t=0:t>1&&(t=1);let e=this.segmentFraction;e!==t&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.Zp=t,this.f(),this.t("segmentFraction",e,t))}get segmentOffset(){return this.Ot!==null?this.Ot.Qp:P.gn}set segmentOffset(t){let e=this.segmentOffset;e.equals(t)||(t=t.C(),this.Ot===null&&(this.Ot=new Oe),this.Ot.Qp=t,this.f(),this.t("segmentOffset",e,t))}get stretch(){return this.w!==null?this.w.ao:1}set stretch(t){let e=this.stretch;e!==t&&(this.Yt().ao=t,this.f(),this.t("stretch",e,t))}get name(){return this.w!==null?this.w.Pt:""}set name(t){let e=this.name;e!==t&&(this.Yt().Pt=t,this.part!==null&&this.part._p(),this.t("name",e,t))}get opacity(){return this.Zt}set opacity(t){t<0?t=0:t>1&&(t=1);let e=this.opacity;if(e!==t){this.Zt=t,this.t("opacity",e,t);let i=this.diagram,s=this.part;i!==null&&s!==null&&i.N(s.ah(s.actualBounds))}}get filter(){return this.Vp}set filter(t){let e=this.filter;if(e!==t){this.Vp=t,this.Zi(!0),this.t("filter",e,t);let i=this.diagram,s=this.part;i!==null&&s!==null&&i.N(s.ah(s.actualBounds))}}get visible(){return(this.n&1)!==0}set visible(t){let e=(this.n&1)!==0;if(e!==t){this.n=this.n^1,this.xf(),this.t("visible",e,t);let i=this.panel;i!==null?i.f():this._s()&&this.Xe(t),this.N(),this.sD()}}get pickable(){return(this.n&2)!==0}set pickable(t){let e=(this.n&2)!==0;e!==t&&(this.n=this.n^2,this.t("pickable",e,t))}get fromLinkableDuplicates(){return(this.n&4)!==0}set fromLinkableDuplicates(t){let e=(this.n&4)!==0;e!==t&&(this.n=this.n^4,this.t("fromLinkableDuplicates",e,t))}get fromLinkableSelfNode(){return(this.n&8)!==0}set fromLinkableSelfNode(t){let e=(this.n&8)!==0;e!==t&&(this.n=this.n^8,this.t("fromLinkableSelfNode",e,t))}get toLinkableDuplicates(){return(this.n&16)!==0}set toLinkableDuplicates(t){let e=(this.n&16)!==0;e!==t&&(this.n=this.n^16,this.t("toLinkableDuplicates",e,t))}get toLinkableSelfNode(){return(this.n&32)!==0}set toLinkableSelfNode(t){let e=(this.n&32)!==0;e!==t&&(this.n=this.n^32,this.t("toLinkableSelfNode",e,t))}get isPanelMain(){return(this.n&64)!==0}set isPanelMain(t){let e=(this.n&64)!==0;e!==t&&(this.n=this.n^64,this.f(),this.t("isPanelMain",e,t))}get isActionable(){return(this.n&128)!==0}set isActionable(t){let e=(this.n&128)!==0;e!==t&&(this.n=this.n^128,this.t("isActionable",e,t))}get background(){return this.Nt}set background(t){let e=this.background;e!==t&&(t!==null&&R.Cd(t,"GraphObject.background"),t instanceof R&&t.k(),this.Nt=t,this.N(),this.t("background",e,t))}CC(){return(this.n&512)!==0}F1(t){t?this.n|=512:this.n&=-513}mf(){return(this.n&1024)!==0}AC(t){t?this.n|=1024:this.n&=-1025}I1(){return(this.n&2048)!==0}Md(t){t?this.n|=2048:this.n&=-2049}Xp(){return(this.n&4096)!==0}Ma(t){t?this.n|=4096:this.n&=-4097}Xo(){return(this.n&8192)!==0}xi(t){t?this.n|=8192:this.n&=-8193}as(){return(this.n&16384)!==0}lo(t){t?this.n|=16384:this.n&=-16385}mI(){return(this.n&32768)!==0}Zi(t){t?this.n|=32768:this.n&=-32769}get part(){if(this._s())return this;if(this.nl!==null)return this.nl;let t=this;for(t=t.panel;t;){if(t instanceof pt)return this.nl=t,t;t=t.panel}return null}get svg(){return this.A1}set svg(t){this.A1=t}Wc(){this.svg=null}get panel(){return this.Zs}Uh(t){this.Zs=t,this.svg!==null&&this.svg.remove()}get layer(){let t=this.part;return t!==null?t.layer:null}get diagram(){let t=this.part;return t!==null?t.diagram:null}get position(){return this.ct}set position(t){let e=t.x,i=t.y,s=this.position,n=s.x,o=s.y;n!==e&&(!isNaN(n)||!isNaN(e))||o!==i&&(!isNaN(o)||!isNaN(i))?(t=t.copy(),this.TC(t,n,o)&&this.t("position",new P(n,o),t.copy())):this.DC()}DC(){}TC(t,e,i){return this.ct=t,this.Pf(),!0}Uc(t,e,i){this.ct.x===t&&this.ct.y===e||(this.ct.e(t,e),this.yf())}get actualBounds(){return this.ve}get scale(){return this.et}set scale(t){let e=this.scale;e!==t&&(t<=0&&m.o("GraphObject.scale for "+this+" must be greater than zero, not: "+t),this.et=t,this.f(),this.t("scale",e,t))}get angle(){return this.Xt}set angle(t){let e=this.angle;if(e!==t){if(t=t%360,t<0&&(t+=360),e===t)return;this.Xt=t,this.sD(),this.f(),this.t("angle",e,t)}}get desiredSize(){return this.cs}set desiredSize(t){let e=t.width,i=t.height,s=this.desiredSize,n=s.width,o=s.height;if((n!==e&&(!isNaN(n)||!isNaN(e))||o!==i&&(!isNaN(o)||!isNaN(i)))&&(t=t.C(),this.cs=t,this.f(),this instanceof it&&this.ai(),this.t("desiredSize",s,t),this.mf())){let r=this.part;r!==null&&(this.Eh(r,"width"),this.Eh(r,"height"))}}get width(){return this.cs.width}set width(t){let e=this.cs.width;if(e!==t&&(!isNaN(e)||!isNaN(t))){let i=this.cs,s=new nt(t,this.cs.height).k();if(this.cs=s,this.f(),this instanceof it&&this.ai(),this.t("desiredSize",i,s),this.mf()){let n=this.part;n!==null&&this.Eh(n,"width")}}}get height(){return this.cs.height}set height(t){let e=this.cs.height;if(e!==t&&(!isNaN(e)||!isNaN(t))){let i=this.cs,s=new nt(this.cs.width,t).k();if(this.cs=s,this.f(),this instanceof it&&this.ai(),this.t("desiredSize",i,s),this.mf()){let n=this.part;n!==null&&this.Eh(n,"height")}}}get minSize(){return this.w!==null?this.w.Cr:nt.xc}set minSize(t){let e=this.minSize;e.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=0),isNaN(t.height)&&(t.height=0),t.k(),this.Yt().Cr=t,this.f(),this.t("minSize",e,t))}get maxSize(){return this.w!==null?this.w.Nr:nt.NP}set maxSize(t){let e=this.maxSize;e.equals(t)||(t=t.copy(),isNaN(t.width)&&(t.width=1/0),isNaN(t.height)&&(t.height=1/0),t.k(),this.Yt().Nr=t,this.f(),this.t("maxSize",e,t))}get measuredBounds(){return this.hi}get naturalBounds(){return this.Ke}Gp(){return 0}get margin(){return this.sl}set margin(t){typeof t=="number"&&(t=new Dt(t));let e=this.sl;e.equals(t)||(t=t.C(),this.sl=t,this.f(),this.t("margin",e,t))}get v(){return this.I1()===!0&&this.T1(),this.il}get Js(){return this.Xp()===!0&&this.T1(),this.ya}trigger(t,e,i){let s=null;return typeof t=="string"?s=new ai(t,e,i):s=t,s.Ti=this,this.Ts===null&&(this.Ts=new Mt),this.Ts.set(s.propertyName,s),this}get Ts(){return this.w!==null?this.w.Ts:null}set Ts(t){this.Ts!==t&&(this.Yt().Ts=t)}get Mr(){return this.w!==null?this.w.Mr:0}set Mr(t){this.Mr!==t&&(this.Yt().Mr=t)}get alignment(){return this.de}set alignment(t){let e=this.alignment;e.equals(t)||(t.isNoSpot()&&!t.isDefault()&&m.o("GraphObject.alignment for "+this+" must be a real Spot or Spot.Default, not: "+t),t=t.C(),this.de=t,this.Pf(),this.t("alignment",e,t))}get column(){return this.pa}set column(t){t=Math.round(t);let e=this.column;e!==t&&(t<0&&m.J(t,">= 0",J,"column"),this.pa=t,this.f(),this.t("column",e,t),this.svg!==null&&this.svg.remove())}get columnSpan(){return this.w!==null?this.w.t0:1}set columnSpan(t){t=Math.round(t);let e=this.columnSpan;e!==t&&(t<1&&m.J(t,">= 1",J,"columnSpan"),this.Yt().t0=t,this.f(),this.t("columnSpan",e,t))}get row(){return this.Up}set row(t){t=Math.round(t);let e=this.row;e!==t&&(t<0&&m.J(t,">= 0",J,"row"),this.Up=t,this.f(),this.t("row",e,t),this.svg!==null&&this.svg.remove())}get rowSpan(){return this.w!==null?this.w.e0:1}set rowSpan(t){t=Math.round(t);let e=this.rowSpan;e!==t&&(t<1&&m.J(t,">= 1",J,"rowSpan"),this.Yt().e0=t,this.f(),this.t("rowSpan",e,t))}get spanAllocation(){return this.w!==null?this.w.i0:null}set spanAllocation(t){let e=this.spanAllocation;e!==t&&(t!==null&&m.S(t,J,"spanAllocation"),this.Yt().i0=t,this.f(),this.t("spanAllocation",e,t))}get alignmentFocus(){return this.xd}set alignmentFocus(t){let e=this.alignmentFocus;e.equals(t)||(t=t.C(),this.xd=t,this.f(),this.t("alignmentFocus",e,t))}get portId(){return this.Ep}set portId(t){let e=this.portId;if(e!==t){let i=this.part;i!==null&&!(i instanceof $)&&m.o("Cannot set portID on a Link: "+t);let s=i;e!==null&&s!==null&&s.vC(this),this.Ep=t,t!==null&&s!==null&&(s.Ln=!0,s.nD(this)),this.t("portId",e,t)}}Vh(){let t=this.part;if(t instanceof $&&(this.portId!==null||this===t.port)){let e=t.diagram;e!==null&&!e.undoManager.isUndoingRedoing&&t.invalidateConnectedLinks(void 0,this)}}sD(){let t=this.diagram;t===null||t.undoManager.isUndoingRedoing||(this instanceof G?this instanceof $?this.invalidateConnectedLinks():this.walkVisualTreeFrom(this,e=>{e.Vh()}):this.Vh())}get toSpot(){return this.ft!==null?this.ft.vh:T.None}set toSpot(t){let e=this.toSpot;e.equals(t)||(t=t.C(),this.$i().vh=t,this.t("toSpot",e,t),this.Vh())}get toEndSegmentLength(){return this.ft!==null?this.ft.Rh:10}set toEndSegmentLength(t){let e=this.toEndSegmentLength;e!==t&&(t<0&&m.J(t,">= 0",J,"toEndSegmentLength"),this.$i().Rh=t,this.t("toEndSegmentLength",e,t),this.Vh())}get toShortLength(){return this.ft!==null?this.ft.Ih:0}set toShortLength(t){let e=this.toShortLength;e!==t&&(this.$i().Ih=t,this.t("toShortLength",e,t),this.Vh())}get toLinkable(){return this.ft!==null?this.ft.s0:null}set toLinkable(t){let e=this.toLinkable;e!==t&&(this.$i().s0=t,this.t("toLinkable",e,t))}get toMaxLinks(){return this.ft!==null?this.ft.o0:1/0}set toMaxLinks(t){let e=this.toMaxLinks;e!==t&&(t<0&&m.J(t,">= 0",J,"toMaxLinks"),this.$i().o0=t,this.t("toMaxLinks",e,t))}get fromSpot(){return this.ft!==null?this.ft.Dh:T.None}set fromSpot(t){let e=this.fromSpot;e.equals(t)||(t=t.C(),this.$i().Dh=t,this.t("fromSpot",e,t),this.Vh())}get fromEndSegmentLength(){return this.ft!==null?this.ft.Fh:10}set fromEndSegmentLength(t){let e=this.fromEndSegmentLength;e!==t&&(t<0&&m.J(t,">= 0",J,"fromEndSegmentLength"),this.$i().Fh=t,this.t("fromEndSegmentLength",e,t),this.Vh())}get fromShortLength(){return this.ft!==null?this.ft.Oh:0}set fromShortLength(t){let e=this.fromShortLength;e!==t&&(this.$i().Oh=t,this.t("fromShortLength",e,t),this.Vh())}get fromLinkable(){return this.ft!==null?this.ft.r0:null}set fromLinkable(t){let e=this.fromLinkable;e!==t&&(this.$i().r0=t,this.t("fromLinkable",e,t))}get fromMaxLinks(){return this.ft!==null?this.ft.l0:1/0}set fromMaxLinks(t){let e=this.fromMaxLinks;e!==t&&(t<0&&m.J(t,">= 0",J,"fromMaxLinks"),this.$i().l0=t,this.t("fromMaxLinks",e,t))}get cursor(){return this.w!==null?this.w.Ul:""}set cursor(t){let e=this.cursor;e!==t&&(m.s(t,"string",J,"cursor"),this.Yt().Ul=t,this.t("cursor",e,t))}get click(){return this.w!==null?this.w.Er:null}set click(t){let e=this.click;e!==t&&(t!==null&&m.S(t,J,"click"),this.Yt().Er=t,this.t("click",e,t))}get doubleClick(){return this.w!==null?this.w.Ur:null}set doubleClick(t){let e=this.doubleClick;e!==t&&(t!==null&&m.S(t,J,"doubleClick"),this.Yt().Ur=t,this.t("doubleClick",e,t))}get contextClick(){return this.w!==null?this.w.Vr:null}set contextClick(t){let e=this.contextClick;e!==t&&(t!==null&&m.S(t,J,"contextClick"),this.Yt().Vr=t,this.t("contextClick",e,t))}get mouseEnter(){return this.w!==null?this.w.Yr:null}set mouseEnter(t){let e=this.mouseEnter;e!==t&&(t!==null&&m.S(t,J,"mouseEnter"),this.Yt().Yr=t,this.t("mouseEnter",e,t))}get mouseLeave(){return this.w!==null?this.w.Kr:null}set mouseLeave(t){let e=this.mouseLeave;e!==t&&(t!==null&&m.S(t,J,"mouseLeave"),this.Yt().Kr=t,this.t("mouseLeave",e,t))}get mouseOver(){return this.w!==null?this.w.Br:null}set mouseOver(t){let e=this.mouseOver;e!==t&&(t!==null&&m.S(t,J,"mouseOver"),this.Yt().Br=t,this.t("mouseOver",e,t))}get mouseHover(){return this.w!==null?this.w.zr:null}set mouseHover(t){let e=this.mouseHover;e!==t&&(t!==null&&m.S(t,J,"mouseHover"),this.Yt().zr=t,this.t("mouseHover",e,t))}get mouseHold(){return this.w!==null?this.w.Xr:null}set mouseHold(t){let e=this.mouseHold;e!==t&&(t!==null&&m.S(t,J,"mouseHold"),this.Yt().Xr=t,this.t("mouseHold",e,t))}get mouseDragEnter(){return this.w!==null?this.w.a0:null}set mouseDragEnter(t){let e=this.mouseDragEnter;e!==t&&(t!==null&&m.S(t,J,"mouseDragEnter"),this.Yt().a0=t,this.t("mouseDragEnter",e,t))}get mouseDragLeave(){return this.w!==null?this.w.h0:null}set mouseDragLeave(t){let e=this.mouseDragLeave;e!==t&&(t!==null&&m.S(t,J,"mouseDragLeave"),this.Yt().h0=t,this.t("mouseDragLeave",e,t))}get mouseDrop(){return this.w!==null?this.w.Gr:null}set mouseDrop(t){let e=this.mouseDrop;e!==t&&(t!==null&&m.S(t,J,"mouseDrop"),this.Yt().Gr=t,this.t("mouseDrop",e,t))}get actionDown(){return this.w!==null?this.w.c0:null}set actionDown(t){let e=this.actionDown;e!==t&&(t!==null&&m.S(t,J,"actionDown"),this.Yt().c0=t,this.t("actionDown",e,t))}get actionMove(){return this.w!==null?this.w.f0:null}set actionMove(t){let e=this.actionMove;e!==t&&(t!==null&&m.S(t,J,"actionMove"),this.Yt().f0=t,this.t("actionMove",e,t))}get actionUp(){return this.w!==null?this.w.u0:null}set actionUp(t){let e=this.actionUp;e!==t&&(t!==null&&m.S(t,J,"actionUp"),this.Yt().u0=t,this.t("actionUp",e,t))}get actionCancel(){return this.w!==null?this.w.d0:null}set actionCancel(t){let e=this.actionCancel;e!==t&&(t!==null&&m.S(t,J,"actionCancel"),this.Yt().d0=t,this.t("actionCancel",e,t))}get toolTip(){return this.w!==null?this.w.Hr:null}set toolTip(t){let e=this.toolTip;e!==t&&(this.Yt().Hr=t,this.t("toolTip",e,t))}get contextMenu(){return this.w!==null?this.w.qr:null}set contextMenu(t){let e=this.contextMenu;e!==t&&(this.Yt().qr=t,this.t("contextMenu",e,t))}findBindingPanel(){let t=this instanceof G?this:this.panel;for(;t!==null;){if(t.FC())return t;t=t.panel}return null}bind(t,e,i,s){return this.Sf(t,e,i,s),this}bindTwoWay(t,e,i,s){return this.Sf(t,e,i,s).makeTwoWay(),this}bindModel(t,e,i,s){return this.Sf(t,e,i,s).ofModel(),this}bindObject(t,e,i,s,n){return this.Sf(t,e,i,s).ofObject(n),this}theme(t,e,i,s,n){return this.Ca(t,e,i,s,n),this}themeData(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofData(),this}themeObject(t,e,i,s,n,o){return this.Ca(t,e,i,s,n).ofObject(o),this}themeModel(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofModel(),this}Sf(t,e,i,s){let n=null;return typeof t=="string"?n=new ie(t,e,i,s):n=t,this.g0(n),n}Ca(t,e,i,s,n){let o=null;return typeof t=="string"?o=new ii(t,e,i,s,n):o=t,this.g0(o),o}g0(t){t.Ti=this;let e=this.findBindingPanel();e!==null&&e.oD()&&m.o("Cannot add a Binding to a template that has already been copied: "+t),this.Fe===null&&(this.Fe=new q),this.Fe.add(t)}set(t){return t?(Object.assign(this,t),this):this}attach(t){return J.RC(this,t),this}apply(t,...e){return t.apply(this,[this,...e]),this}setProperties(t){return Y.Mp(this,t),this}static make(t,...e){let i=arguments,s=null,n=null;if(m.it(t))n=t;else if(typeof t=="string"){let r=J.E1.get(t);m.it(r)?(i=Array.prototype.slice.call(i),s=r(i),m.$(s)||m.o('GraphObject.make invoked object builder "'+t+'", but it did not return an Object')):n=K.go[t]}s===null&&((n==null||!n.constructor)&&m.o("GraphObject.make requires a class function or GoJS class name or name of an object builder, not: "+t),s=new n);let o=1;if(s instanceof Y&&i.length>1){let r=s,a=i[1];(typeof a=="string"||a instanceof HTMLDivElement)&&(r.g2(a),o++)}for(let r=o;r<i.length;r++){let a=i[r];a===void 0?m.o("Undefined value at argument "+r+" for object being constructed by GraphObject.make: "+s):s&&J.RC(s,a)}return s}static RC(t,e){if(typeof e=="number")J.wI(t,e);else if(typeof e=="string")J.xI(t,e);else if(e instanceof J)t instanceof G||m.o("A GraphObject can only be added to a Panel, not to: "+t),t.add(e);else if(e instanceof Kt){let i=null;e.isRow&&m.it(t.getRowDefinition)?i=t.getRowDefinition(e.index):!e.isRow&&m.it(t.getColumnDefinition)&&(i=t.getColumnDefinition(e.index)),i instanceof Kt?i.U1(e):m.o("A RowColumnDefinition can only be added to an object that implements getRowDefinition/getColumnDefinition, not to: "+t)}else if(e instanceof Lt){let i=t;i.type=e}else if(e instanceof ie)t instanceof J||t instanceof Kt?t.bind(e):m.o("A Binding can only be applied to a GraphObject or RowColumnDefinition, not to: "+t);else if(e instanceof ai)t instanceof J?t.trigger(e):m.o("An AnimationTrigger can only be applied to a GraphObject, not to: "+t);else if(e instanceof zt)t instanceof wt&&t.type===4?t.figures.add(e):m.o("A PathFigure can only be added to a Path Geometry, not to: "+t);else if(e instanceof mt)t instanceof zt?t.segments.add(e):m.o("A PathSegment can only be added to a PathFigure, not to: "+t);else if(e instanceof ee)t instanceof Y||t instanceof ht?t.layout=e:m.o("A Layout can only be assigned to a Diagram or a Group, not to: "+t);else if(Array.isArray(e))for(let i=0;i<e.length;i++){let s=e[i];J.RC(t,s)}else m.$(e)?J.bI(t,e):m.o('Unknown initializer "'+e+'" for object being constructed by GraphObject.make: '+t)}static xI(t,e){if(t instanceof lt)t.text=e;else if(t instanceof it)t.figure=e;else if(t instanceof Bt)t.source=e;else if(t instanceof G){let i=Lt.fs.get(e);i!==null&&(t.type=i)}else if(t instanceof R){let i=m.Ja(Fe,e);i!==null?t.type=i:m.o("Unknown Brush type as an argument to GraphObject.make: "+e)}else if(t instanceof wt){let i=m.Ja(Ve,e);i!==null&&(t.type=i)}else if(t instanceof mt){let i=m.Ja(ni,e);i!==null&&(t.type=i)}}static wI(t,e){m.it(t.fe)?t.fe(e):m.ur(t,e)}static bI(t,e){if(t instanceof R){let i=new yt;for(let s in e){let n=parseFloat(s);isNaN(n)?i[s]=e[s]:t.addColorStop(n,e[s])}Y.Mp(t,i)}else if(t instanceof Kt){if(e.row!==void 0){let s=e.row;(s==null||s===1/0||isNaN(s)||s<0)&&m.o("Must specify non-negative integer row for RowColumnDefinition "+e+", not: "+s),t.isRow=!0,t.index=s}else if(e.column!==void 0){let s=e.column;(s==null||s===1/0||isNaN(s)||s<0)&&m.o("Must specify non-negative integer column for RowColumnDefinition "+e+", not: "+s),t.isRow=!1,t.index=s}let i=new yt;for(let s in e)s==="row"||s==="column"||(i[s]=e[s]);Y.Mp(t,i)}else Y.Mp(t,e)}static build(t,e,...i){let s=J.E1.get(t);if(m.it(s)){let n=s([t].concat(i));if(n instanceof J)return e&&n.setProperties(e),n}m.o('GraphObject.build invoked object builder "'+t+'", but it did not return an Object')}static defineBuilder(t,e){m.s(t,"string",J,"defineBuilder:name"),m.S(e,J,"defineBuilder:func");let i=t.toLowerCase();J.E1.set(t,e)}static isBuilderDefined(t){return J.E1.has(t)}static takeBuilderArgument(t,e,i){i===void 0&&(i=null);let s=t[1];return(m.it(i)?i(s):typeof s=="string")?(t.splice(1,1),s):(e===void 0&&m.o("no "+(m.it(i)?"satisfactory":"string")+" argument for GraphObject builder "+t[0]),e)}static E1=new Mt}J.Vertical=4,J.Horizontal=5,J.defineBuilder("Button",x=>{let t="#f5f5f5",e="#737373",i="#d4d4d4",s="#737373",n="#a3a3a3",o=2.76142374915397,r=2.761423749153969,a=new G(G.Auto,{isActionable:!0,enabledChanged:(h,l)=>{if(h instanceof G){let u=h.findObject("ButtonBorder");if(u!==null)if(h._buttonFillNormal===void 0&&(h._buttonFillNormal=u.fill),l){let c=null;h.layer!==null&&h.diagram!==null&&h.isVisibleObject()&&(c=h.layer.findObjectAt(h.diagram.lastInput.documentPoint)),c===h||c!==null&&c.isContainedBy(h)?u.fill=h._buttonFillOver:u.fill=h._buttonFillNormal}else u.fill=h._buttonFillDisabled}},cursor:"pointer"}).attach({_buttonFillNormal:void 0,_buttonStrokeNormal:void 0,_buttonFillOver:i,_buttonStrokeOver:s,_buttonFillDisabled:n}).add(new it("RoundedRectangle",{name:"ButtonBorder",spot1:new T(0,0,o,r),spot2:new T(1,1,-o,-r),parameter1:2,fill:t,stroke:e}));return a.mouseEnter=(h,l,u)=>{if(!l.isEnabledObject()||!(l instanceof G))return;let c=l.findObject("ButtonBorder");c instanceof it&&(l._buttonFillNormal===void 0&&(l._buttonFillNormal=c.fill),c.fill=l._buttonFillOver,l._buttonStrokeNormal===void 0&&(l._buttonStrokeNormal=c.stroke),c.stroke=l._buttonStrokeOver)},a.mouseLeave=(h,l,u)=>{if(!l.isEnabledObject()||!(l instanceof G))return;let c=l.findObject("ButtonBorder");c instanceof it&&(l._buttonFillNormal!==void 0&&(c.fill=l._buttonFillNormal),l._buttonStrokeNormal!==void 0&&(c.stroke=l._buttonStrokeNormal))},a}),J.defineBuilder("TreeExpanderButton",x=>{let t=J.build("Button");return t.attach({_treeExpandedFigure:"MinusLine",_treeCollapsedFigure:"PlusLine",visible:!1}),t.add(new it("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:nt.Su}).bindObject("figure","isTreeExpanded",(e,i)=>{let s=i.panel;return e?s._treeExpandedFigure:s._treeCollapsedFigure})),t.bindObject("visible","isTreeLeaf",e=>!e),t.click=(e,i)=>{let s=i.part;if(s instanceof vt&&(s=s.adornedPart),!(s instanceof $))return;let n=s.diagram;if(n===null)return;let o=n.commandHandler;if(s.isTreeExpanded){if(!o.canCollapseTree(s))return}else if(!o.canExpandTree(s))return;e.handled=!0,s.isTreeExpanded?o.collapseTree(s):o.expandTree(s)},t}),J.defineBuilder("SubGraphExpanderButton",x=>{let t=J.build("Button");return t.attach({_subGraphExpandedFigure:"MinusLine",_subGraphCollapsedFigure:"PlusLine"}),t.add(new it("MinusLine",{name:"ButtonIcon",stroke:"#0a0a0a",strokeWidth:2,desiredSize:nt.Su}).bindObject("figure","isSubGraphExpanded",(e,i)=>{let s=i.panel;return e?s._subGraphExpandedFigure:s._subGraphCollapsedFigure})),t.click=(e,i)=>{let s=i.part;if(s instanceof vt&&(s=s.adornedPart),!(s instanceof ht))return;let n=s.diagram;if(n===null)return;let o=n.commandHandler;if(s.isSubGraphExpanded){if(!o.canCollapseSubGraph(s))return}else if(!o.canExpandSubGraph(s))return;e.handled=!0,s.isSubGraphExpanded?o.collapseSubGraph(s):o.expandSubGraph(s)},t}),J.defineBuilder("ToolTip",x=>new vt(G.Auto,{isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new P(0,2),mouseOver:(t,e)=>{let i=t.diagram.toolManager;i.extendToolTip(i.toolTipDuration)}}).add(new it("RoundedRectangle",{name:"Border",parameter1:1,fill:"#f5f5f5",strokeWidth:0,spot1:new T(0,0,4,6),spot2:new T(1,1,-4,-4)}))),J.defineBuilder("ContextMenu",x=>new vt(G.Vertical,{background:"#f5f5f5",isShadowed:!0,shadowColor:"rgba(0, 0, 0, .4)",shadowOffset:new P(0,2)}).bindObject("background","",t=>t.adornedPart!==null&&t.hasPlaceholder()?null:"#f5f5f5")),J.defineBuilder("ContextMenuButton",x=>{let t=J.build("Button");t.stretch=5;let e=t.findObject("ButtonBorder");return e instanceof it&&(e.figure="Rectangle",e.strokeWidth=0,e.spot1=new T(0,0,4,6),e.spot2=new T(1,1,-4,-4)),t}),J.defineBuilder("PanelExpanderButton",x=>{let t=J.takeBuilderArgument(x,"COLLAPSIBLE"),e=J.build("Button");e.attach({_buttonExpandedFigure:"M0 0 M0 6 L4 2 8 6 M8 8",_buttonCollapsedFigure:"M0 0 M0 2 L4 6 8 2 M8 8","ButtonBorder.fill":"rgba(0, 0, 0, 0)",_buttonFillNormal:"rgba(0, 0, 0, 0)","ButtonBorder.stroke":null,_buttonStrokeNormal:null,_buttonFillOver:"rgba(0, 0, 0, .2)",_buttonStrokeOver:null}),e.add(new it({name:"ButtonIcon",strokeWidth:2}).bindObject("geometryString","visible",s=>s?e._buttonExpandedFigure:e._buttonCollapsedFigure,void 0,t));let i=e.findObject("ButtonBorder");return i instanceof it&&(i.stroke=null,i.fill="rgba(0, 0, 0, 0)"),e.click=(s,n)=>{if(!(n instanceof G))return;let o=n.diagram;if(o===null||o.isReadOnly)return;let r=n.findBindingPanel();if(r===null&&(r=n.part),r!==null){let a=r.findObject(t);a!==null&&(s.handled=!0,o.startTransaction("Collapse/Expand Panel"),a.visible=!a.visible,o.commitTransaction("Collapse/Expand Panel"))}},e}),J.defineBuilder("CheckBoxButton",x=>{let t=J.takeBuilderArgument(x),e=J.build("Button",{desiredSize:new nt(14,14)});e.attach({"ButtonBorder.spot1":new T(0,0,1,1),"ButtonBorder.spot2":new T(1,1,-1,-1)});let i=new it({name:"ButtonIcon",geometryString:"M0 0 M0 8.85 L4.9 13.75 16.2 2.45 M16.2 16.2",strokeWidth:2,stretch:2,geometryStretch:6,visible:!1});return t!==""&&i.bindTwoWay("visible",t),e.add(i),e.click=(s,n)=>{if(!(n instanceof G))return;let o=s.diagram;if(o===null||o.isReadOnly||t!==""&&o.model.isReadOnly)return;s.handled=!0;let r=n.findObject("ButtonIcon");o.startTransaction("checkbox"),r!==null&&(r.visible=!r.visible),m.it(n._doClick)&&n._doClick(s,n),o.commitTransaction("checkbox")},e}),J.defineBuilder("CheckBox",x=>{let t=J.takeBuilderArgument(x),e=J.build("CheckBoxButton",{name:"Button",isActionable:!1,margin:new Dt(0,1,0,0)},t),i=new G("Horizontal",{isActionable:!0,cursor:e.cursor,margin:new Dt(1),mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonFillNormal:e._buttonFillNormal,_buttonStrokeNormal:e._buttonStrokeNormal,_buttonFillOver:e._buttonFillOver,_buttonStrokeOver:e._buttonStrokeOver,_buttonFillDisabled:e._buttonFillDisabled,_buttonClick:e.click});return i.add(e),e.mouseEnter=null,e.mouseLeave=null,e.click=null,i}),J.defineBuilder("AutoRepeatButton",x=>{let t=J.takeBuilderArgument(x,50,r=>typeof r=="number"),e=J.takeBuilderArgument(x,500,r=>typeof r=="number");function i(r,a){n(r,a),a.click&&(a.Nd=m.dn(()=>s(r,a),e))}function s(r,a){a.Nd&&m.yc(a.Nd),a.click&&(a.Nd=m.dn(()=>{a.click&&(a.click(r,a),s(r,a))},t))}function n(r,a){a.Nd&&(m.yc(a.Nd),a.Nd=void 0)}let o=J.build("Button");return o.actionDown=(r,a)=>i(r,a),o.actionUp=(r,a)=>n(r,a),o.actionCancel=(r,a)=>n(r,a),o}),J.defineBuilder("ToggleSwitch",function(x){let t=J.takeBuilderArgument(x);t||m.o("ToggleSwitch must be data-bound to a property name, not: "+t);let e=J.takeBuilderArgument(x,!1,r=>typeof r=="boolean"),i="gray",s="transparent",n="white",o=new G("Auto",{width:e?15:28,height:e?28:15}).attach({_buttonFillOff:i,_buttonBorderOff:s,_buttonIconFillOff:n,_buttonFillOn:"green",_buttonBorderOn:"transparent",_buttonIconFillOn:"white"}).add(new it("Capsule",{name:"ButtonBorder",fill:i,stroke:s,strokeWidth:1}).bind("fill",t,(r,a)=>r?a.panel._buttonFillOn:a.panel._buttonFillOff).bind("stroke",t,(r,a)=>r?a.panel._buttonBorderOn:a.panel._buttonBorderOff)).add(new it("Circle",{name:"ButtonIcon",width:11,height:11,fill:n,stroke:null,alignment:e?T.Bottom:T.Left}).bind("fill",t,(r,a)=>r?a.panel._buttonIconFillOn:a.panel._buttonIconFillOff).bind("alignment",t,r=>r?e?T.Top:T.Right:e?T.Bottom:T.Left));return o.click=function(r,a){if(!a.isEnabledObject())return;let h=r.diagram;if(h===null||h.isReadOnly||t!==""&&h.model.isReadOnly)return;r.handled=!0;let l=a.findBindingPanel();l!==null&&(h.startTransaction("toggle switch"),h.model.set(l.data,t,!l.data[t]),typeof a._doClick=="function"&&a._doClick(r,a),h.commitTransaction("toggle switch"))},o}),J.defineBuilder("Toggle",function(x){let t=J.takeBuilderArgument(x),e=J.build("ToggleSwitch",{name:"Button"},t),i=new G("Horizontal",{cursor:e.cursor,margin:1,mouseEnter:e.mouseEnter,mouseLeave:e.mouseLeave,click:e.click}).attach({_buttonClick:e.click}).add(e);return e.mouseEnter=null,e.mouseLeave=null,e.click=null,i});class Ke{me;Pt;no;Fe;oo;Ds;Ul;Er;Ur;Vr;Yr;Kr;Br;zr;Xr;a0;h0;Gr;c0;f0;u0;d0;Hr;qr;jp;i0;Ts;Cr;Nr;ao;e0;t0;Mr;Hp;m0;p0;constructor(){this.me=!1,this.Pt="",this.no=-1,this.Fe=null,this.oo=null,this.Ds=null,this.Ul="",this.Er=null,this.Ur=null,this.Vr=null,this.Yr=null,this.Kr=null,this.Br=null,this.zr=null,this.Xr=null,this.a0=null,this.h0=null,this.Gr=null,this.c0=null,this.f0=null,this.u0=null,this.d0=null,this.Hr=null,this.qr=null,this.jp=null,this.i0=null,this.Ts=null,this.Cr=nt.xc,this.Nr=nt.NP,this.ao=1,this.e0=1,this.t0=1,this.Mr=0,this.Hp=null,this.m0=null,this.p0="category"}copy(){let t=new Ke;return t.Pt=this.Pt,t.no=this.no,t.Fe=this.Fe,t.Ds=this.Ds,t.Ul=this.Ul,t.Er=this.Er,t.Ur=this.Ur,t.Vr=this.Vr,t.Yr=this.Yr,t.Kr=this.Kr,t.Br=this.Br,t.zr=this.zr,t.Xr=this.Xr,t.a0=this.a0,t.h0=this.h0,t.Gr=this.Gr,t.c0=this.c0,t.f0=this.f0,t.u0=this.u0,t.d0=this.d0,t.Hr=this.Hr,t.qr=this.qr,t.jp=this.jp,t.i0=this.i0,t.Ts=this.Ts,t.Cr=this.Cr.C(),t.Nr=this.Nr.C(),t.ao=this.ao,t.e0=this.e0,t.t0=this.t0,t.Mr=this.Mr,t.Hp=this.Hp,t.m0=this.m0,t.p0=this.p0,t}}class Si{m;constructor(){this.m=[1,0,0,1,0,0]}copy(){let t=new Si;return t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5],t}translate(t,e){this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e}scale(t,e){this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e}rotate(t,e,i){if(t=C.Ee(t),t===0)return;this.translate(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m[0]*s+this.m[2]*n,r=this.m[1]*s+this.m[3]*n,a=this.m[0]*-n+this.m[2]*s,h=this.m[1]*-n+this.m[3]*s;this.m[0]=o,this.m[1]=r,this.m[2]=a,this.m[3]=h,this.translate(-e,-i)}}class li{type;x1;y1;r1;x2;y2;r2;colors;pattern;constructor(t){this.type=t,this.x1=0,this.y1=0,this.r1=0,this.x2=0,this.y2=0,this.r2=0,this.colors=[],this.pattern=null}addColorStop(t,e){this.colors.push({offset:t,color:e})}}class ui{bt;_t;el;dd;OC;constructor(t,e,i){let s=e===void 0?K.document:e;this.el=s,this.OC="http://www.w3.org/2000/svg";let n="http://www.w3.org/2000/xmlns/";s!==void 0&&(this.bt=this.makeElement("svg",{width:"1px",height:"1px",viewBox:"0 0 1 1"}),this.style.display="block",this.style.letterSpacing="normal",this.style.wordSpacing="normal",i||(this.style.position="absolute"),this.bt.setAttributeNS(n,"xmlns",this.OC),this.bt.setAttributeNS(n,"xmlns:xlink","http://www.w3.org/1999/xlink")),this.dd=null,this._t=new ae(this,i)}resize(t,e,i,s){return this.width!==t||this.height!==e?(this.width=t,this.height=e,this.style.width=i+"px",this.style.height=s+"px",this.bt.setAttributeNS(null,"width",i+"px"),this.bt.setAttributeNS(null,"height",s+"px"),this.bt.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),this._t.IC.firstElementChild.setAttributeNS(null,"width",i+"px"),this._t.IC.firstElementChild.setAttributeNS(null,"height",s+"px"),!0):!1}makeElement(t,e,i){let s=this.el.createElementNS(this.OC,t);if(m.$(e))for(let n in e)s.setAttributeNS(n==="href"?"http://www.w3.org/1999/xlink":"",n,e[n]);return i!==void 0&&(s.textContent=i),s}getBoundingClientRect(){return this.bt.getBoundingClientRect()}focus(){this.bt.focus()}get width(){return parseInt(this.bt.getAttribute("width")||"1")}set width(t){this.bt.setAttribute("width",t+"px")}get height(){return parseInt(this.bt.getAttribute("height")||"1")}set height(t){this.bt.setAttribute("height",t+"px")}dispose(){this.el=null}get style(){return this.bt.style}}class ae{Mf;Cf;An;Re;Qi;fillStyle;font;globalAlpha;lineCap;lineDashOffset;lineJoin;lineWidth;miterLimit;shadowBlur;shadowColor;shadowOffsetX;shadowOffsetY;strokeStyle;textAlign;imageSmoothingEnabled;clipInsteadOfFill;lastCreatedElement;Nf;Lf;surface;svg;IC;rD;V1;jo;Na;Bh;currentElement;clipPathGroup;diagramGroup;lastDrawnPart;currentPath;outerGroup;pathAttributes;rl;vr;filter;letterSpacing;wordSpacing;partClipRect;constructor(t,e){if(this.surface=t,this.svg=t.bt,this.Nf=[],this.Lf=[],this.fillStyle="#000000",this.font="10px sans-serif",this.globalAlpha=1,this.lineCap="butt",this.lineDashOffset=0,this.lineJoin="miter",this.lineWidth=1,this.miterLimit=10,this.shadowBlur=0,this.shadowColor="rgba(0, 0, 0, 0)",this.shadowOffsetX=0,this.shadowOffsetY=0,this.rl=!1,this.strokeStyle="#000000",this.textAlign="start",this.clipInsteadOfFill=!1,this.Mf=0,this.Cf=0,this.An=0,this.lastCreatedElement=null,this.currentElement=null,this.Re=[],this.pathAttributes={},this.V1=!1,this.jo=null,this.Na=0,this.rD={},this.vr=!!e,this.filter="",this.partClipRect=null,this.Qi=new Si,this.letterSpacing="0px",this.wordSpacing="0px",t.el===null||t.el===void 0)return;this.clipPathGroup=this.newGroup2(),this.diagramGroup=this.newGroup2("gojs-diagram"),this.lastDrawnPart=null,this.currentPath=null;let i=V.Kw++,s=this.makeElement("clipPath",{id:"mainClip"+i}),n={x:0,y:0,width:t.width,height:t.height};s.appendChild(this.makeElement("rect",n)),this.IC=s,this.svg.appendChild(this.clipPathGroup),this.clipPathGroup.appendChild(this.diagramGroup),this.svg.appendChild(s),this.clipPathGroup.setAttributeNS(null,"clip-path","url(#mainClip"+i+")")}setDiagramPosScale(t,e,i,s,n,o){this.diagramGroup===void 0?this.newGroup(t,e,i,s,n,o):this.diagramGroup.setAttribute("transform","matrix("+t+", "+e+", "+i+", "+s+", "+n+", "+o+")")}resetInnerSVG(){this.diagramGroup!==null&&(this.diagramGroup.innerHTML="")}arc(t,e,i,s,n,o,r,a){let h=2*Math.PI,l=1e-6,u=h-l,c=i*Math.cos(s),d=i*Math.sin(s),f=t+c,p=e+d,g=o?0:1,y=o?s-n:n-s;(Math.abs(r-f)>l||Math.abs(a-p)>l)&&this.Re.push(["L",f,+p]),y<0&&(y=y%h+h),y>u?(this.Re.push(["A",i,i,0,1,g,t-c,e-d]),this.Re.push(["A",i,i,0,1,g,f,p])):y>l&&this.Re.push(["A",i,i,0,+(y>=Math.PI),g,t+i*Math.cos(n),e+i*Math.sin(n)])}beginPath(){this.Re=[],this.pathAttributes={stroke:"none",fill:"none"}}endPath(t){this.kI(this.Re,this.Qi,t||0)}bezierCurveTo(t,e,i,s,n,o){this.Re.push(["C",t,e,i,s,n,o])}clearRect(t,e,i,s){}clip(){this.pathAttributes.clipPath=!0}closePath(){this.Re.push(["z"])}createLinearGradient(t,e,i,s){let n=new li("linear");return n.x1=t,n.y1=e,n.x2=i,n.y2=s,n}createPattern(t,e){let i="";t instanceof HTMLCanvasElement&&(i=t.toDataURL()),t instanceof HTMLImageElement&&(i=t.getAttribute("src"));let s=this.rD;if(s[i])return"url(#"+s[i]+")";let n="PATTERN"+V.Kw++,o={width:t.width,height:t.height,id:n,patternUnits:"userSpaceOnUse"},r={x:0,y:0,width:t.width,height:t.height,href:i},a=this.makeElement("pattern",o);return a.appendChild(this.makeElement(Y.img,r)),this.svg.appendChild(a),s[i]=n,"url(#"+n+")"}createRadialGradient(t,e,i,s,n,o){let r=new li("radial");return r.x1=t,r.y1=e,r.r1=i,r.x2=s,r.y2=n,r.r2=o,r}amendImageTransform(t,e,i,s,n,o,r,a){let h=r/i,l=a/s;(n!==0||o!==0)&&this.Qi.translate(n,o),(h!==1||l!==1)&&this.Qi.scale(h,l),(t!==0||e!==0)&&this.Qi.translate(-t,-e)}drawImage(t,e,i,s,n,o,r,a,h){let l="",u=t.width,c=t.height;typeof t.toDataURL=="function"?t.toDataURL():(l=t.getAttribute("src"),u=t.naturalWidth,c=t.naturalHeight),s===void 0&&(o=e,r=i,a=s=u,h=n=c),s=s||0,n=n||0,o=o||0,r=r||0,a=a||0,h=h||0,this.amendImageTransform(e,i,s,n,o,r,a,h);let d={x:0,y:0,width:u||s,height:c||n,href:l};!C.X(s,a)||!C.X(n,h)?d.preserveAspectRatio="none":l.toLowerCase().indexOf(".svg")===-1&&l.toLowerCase().indexOf("data:image/svg")===-1&&(d.preserveAspectRatio="xMidYMid slice"),(e!==0||i!==0||s!==u||n!==c)&&(s+=e,n+=i,d["clip-path"]=`path('M ${e},${i} L ${s} ${i} L ${s} ${n} L ${e} ${n} z')`),this.processCommon(Y.img,d,this.Qi),this.Ld(Y.img,d)}fill(t,e){t&&(this.pathAttributes["fill-rule"]="evenodd"),this.setFill(this.pathAttributes)}fillContext(t,e,i){this.clipInsteadOfFill?this.clip():this.fill(e,i)}createOrUpdateClipGroup(t,e){let i=this.newGroup(1,0,0,1,-e.x,-e.y);i.setAttributeNS(null,"class","spotClip"),t.wa=i}fillRect(t,e,i,s){this.addRect("fill",[t,e,i,s],this.Qi)}fillBackground(t,e,i,s){let n={x:t,y:e,width:i,height:s};this.processCommon("fill",n,this.Qi),this.setFill(n),this.svg.prepend(this.makeElement("rect",n))}fillText(t,e,i){this.addText("fill",[t,e,i],this.Qi)}lineTo(t,e){this.Re.push(["L",t,e])}moveTo(t,e){this.Re.push(["M",t,e])}quadraticCurveTo(t,e,i,s){this.Re.push(["Q",t,e,i,s])}rect(t,e,i,s){this.Re.push(["M",t,e],["L",t+i,e],["L",t+i,e+s],["L",t,e+s],["z"])}restore(){this.Qi=this.Nf.pop(),this.Re=this.Nf.pop();let t=this.Nf.pop();this.fillStyle=t.fillStyle,this.font=t.font,this.globalAlpha=t.globalAlpha,this.lineCap=t.lineCap,this.lineDashOffset=t.lineDashOffset,this.lineJoin=t.lineJoin,this.lineWidth=t.lineWidth,this.miterLimit=t.miterLimit,this.shadowBlur=t.shadowBlur,this.shadowColor=t.shadowColor,this.shadowOffsetX=t.shadowOffsetX,this.shadowOffsetY=t.shadowOffsetY,this.strokeStyle=t.strokeStyle,this.textAlign=t.textAlign,this.partClipRect=t.partClipRect,this.letterSpacing=t.letterSpacing,this.wordSpacing=t.wordSpacing}save(){let t={fillStyle:this.fillStyle,font:this.font,globalAlpha:this.globalAlpha,lineCap:this.lineCap,lineDashOffset:this.lineDashOffset,lineJoin:this.lineJoin,lineWidth:this.lineWidth,miterLimit:this.miterLimit,shadowBlur:this.shadowBlur,shadowColor:this.shadowColor,shadowOffsetX:this.shadowOffsetX,shadowOffsetY:this.shadowOffsetY,strokeStyle:this.strokeStyle,textAlign:this.textAlign,partClipRect:this.partClipRect};this.Nf.push(t);let e=[];for(let i=0;i<this.Re.length;i++)e.push(this.Re[i]);this.Nf.push(e),this.Nf.push(this.Qi.copy())}setTransform(t,e,i,s,n,o){t===1&&e===0&&i===0&&s===1&&n===0&&o===0||this.newGroup(t,e,i,s,n,o)}setCurrentTransform(t,e,i,s,n,o){this.Qi.m=[t,e,i,s,n,o]}getCurrentTransform(){let t=this.Qi.m;return"matrix("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"}scale(t,e){this.Qi.scale(t,e)}translate(t,e){this.Qi.translate(t,e)}transform(t,e,i,s,n,o){}commitTransform(){}stroke(){this.setStroke(this.pathAttributes)}strokeContext(){this.clipInsteadOfFill||this.stroke()}strokeRect(t,e,i,s){this.addRect("stroke",[t,e,i,s],this.Qi)}makeElement(t,e,i){return this.surface.makeElement(t,e,i)}Ld(t,e,i){let s=this.makeElement(t,e,i);return this.currentElement!==null?this.currentElement.appendChild(s):this.currentElement=s,this.lastCreatedElement=s,s}processCommon(t,e,i){if(t==="fill"?this.setFill(e):t==="stroke"&&this.setStroke(e),i!==null){let s=i.m;e.transform="matrix("+s[0]+", "+s[1]+", "+s[2]+", "+s[3]+", "+s[4]+", "+s[5]+")"}}setFill(t){if(this.fillStyle instanceof li){t.fill=this.addGradient(this.fillStyle,"fill");return}if(/^rgba\(/.test(this.fillStyle)){let e=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.fillStyle);t.fill="rgb("+e[1]+","+e[2]+","+e[3]+")",t["fill-opacity"]=e[4]}else t.fill=this.fillStyle}setFillOrStrokeInPlace(t,e){let i=e?"fill":"stroke";if(this.fillStyle instanceof li){t.setAttributeNS(null,"fill",this.addGradient(this.fillStyle,i));return}if(/^rgba\(/.test(this.fillStyle)){let s=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.fillStyle);t.setAttributeNS(null,i,"rgb("+s[1]+","+s[2]+","+s[3]+")"),t.setAttributeNS(null,i+"-opacity",s[4])}else t.setAttributeNS(null,i,this.fillStyle)}setStroke(t){if(this.strokeStyle instanceof li)t.stroke=this.addGradient(this.strokeStyle,"stroke");else if(/^rgba\(/.test(this.strokeStyle)){let e=/^\s*rgba\s*\(([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^,\s]+)\)\s*$/i.exec(this.strokeStyle);t.stroke="rgb("+e[1]+","+e[2]+","+e[3]+")",t["stroke-opacity"]=e[4]}else t.stroke=this.strokeStyle;t["stroke-width"]=this.lineWidth,t["stroke-linecap"]=this.lineCap,t["stroke-linejoin"]=this.lineJoin,t["stroke-miterlimit"]=this.miterLimit,this.V1&&(t["stroke-dasharray"]=this.jo.toString(),t["stroke-dashoffset"]=this.Na)}addGradient(t,e){let i="",s=this.currentPath!==null?this.currentPath.getAttribute(e):null;if(s!==null&&s.indexOf("GRAD")!==-1){i=s.split("#")[1].slice(0,-1);let a=this.svg.getElementById(i);a!==null&&a.remove()}else i="GRAD"+V.Kw++;let n;if(t.type==="linear"){let a={x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,id:i,gradientUnits:"userSpaceOnUse"};n=this.makeElement("linearGradient",a)}else if(t.type==="radial"){let a={x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2,r1:t.r1,r2:t.r2,id:i};n=this.makeElement("radialGradient",a)}else m.o("invalid gradient");let o=t.colors.sort((a,h)=>a.offset>h.offset?1:-1),r=o.length;for(let a=0;a<r;a++){let h=o[a],l=h.color;n.appendChild(this.makeElement("stop",{offset:h.offset,"stop-color":l}))}return this.svg.appendChild(n),"url(#"+i+")"}addRect(t,e,i){let s={x:e[0],y:e[1],width:e[2],height:e[3]};this.processCommon(t,s,i),this.Ld("rect",s)}addText(t,e,i){let s=this.textAlign;s==="left"?s="start":s==="right"?s="end":s==="center"&&(s="middle");let n={x:e[1],y:e[2],style:"font: "+this.font,"text-anchor":s};n["letter-spacing"]=this.letterSpacing,n["word-spacing"]=this.wordSpacing,this.processCommon(t,n,i),this.Ld("text",n,e[0])}kI(t,e,i){let s=this.SI(t),n=this.pathAttributes;if(n.clipPath){this.Lf.length>1&&this.Lf[this.Lf.length-2].setAttributeNS(null,"clip-path",'path("'+s+'") view-box');return}if(n.d=s,this.processCommon("",n,e),this.currentPath!==null){let o=this.currentPath;if(o.nodeName!=="g")for(let r in n)r!=="transform"&&o.setAttributeNS(null,r,n[r]);else{let r=o.getElementsByTagName("path");for(let a in n)a!=="transform"&&r[i].setAttributeNS(null,a,n[a])}}else this.Ld("path",n)}SI(t){let e=[];for(let i=0;i<t.length;i++){let s=t[i].slice(),n=[s.shift()];if(n[0]==="A")n.push(s.shift()+","+s.shift(),s.shift(),s.shift()+","+s.shift(),s.shift()+","+s.shift());else for(;s.length;)n.push(s.shift()+","+s.shift());e.push(n.join(" "))}return e.join(" ")}newGroup(t,e,i,s,n,o){let r=new Si;r.m=[t,e,i,s,n,o];let a={};this.processCommon("g",a,r);let h=this.Ld("g",a);return this.Lf.push(h),h}newGroup2(t){let e={};t&&(e.class=t);let i=this.Ld("g",e);return this.Lf.push(i),i}endGroup(){return this.Lf.pop()}dummyGroup(){return this.newGroup2(),this.endGroup()}shadowsSet(t,e,i){this.Mf=t,this.Cf=e,this.An=i}shadowsOff(){this.rl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.rl=!0,this.shadowOffsetX=this.Mf,this.shadowOffsetY=this.Cf,this.shadowBlur=this.An}enableDash(t,e){this.V1=!0,this.jo=t,this.Na=e}disableDash(){this.V1=!1}clearContextCache(t){}setImageSmoothingEnabled(t){}rotate(t){this.Qi.rotate(t*57.2958,0,0)}getImageData(t,e,i,s){return null}measureText(t){return null}removeOldGradient(t,e,i){let s=e.getAttribute(i);if(s===null)return;let n=s.split("#");if(n.length===1)return;let o=this.svg.getElementById(n[1].slice(0,-1));if(o!==null){let r=new RegExp(o.id,"g");this.svg.innerHTML.match(r).length===1&&o.remove()}}removePartFromView(t){t.svg!==null&&t.svg.parentNode===this.diagramGroup&&t.svg.remove()}}class De{bt;_t;el;dd;constructor(t,e,i,s){let n=e===void 0?K.document:e;this.el=n,this.dd=null;let o=n.createElement("canvas");o.tabIndex=0,this.bt=o,this._t=new ci(o,i,s),t&&Y.Ji.set(o,t)}resize(t,e,i,s){return this.width!==t||this.height!==e?(this.width=t,this.height=e,this.style.width=i+"px",this.style.height=s+"px",!0):!1}toDataURL(t,e){return this.bt.toDataURL(t,e)}getBoundingClientRect(){return this.bt.getBoundingClientRect()}focus(){this.bt.focus()}get width(){return this.bt.width}set width(t){this.bt.width=t}get height(){return this.bt.height}set height(t){this.bt.height=t}dispose(){Y.Ji.delete(this.bt),this.el=null}get style(){return this.bt.style}}class ci{F;B1;z1;X1;clipInsteadOfFill;Mf;Cf;An;Bh;rl;vr;constructor(t,e,i){t.getContext||m.o("Browser does not support HTML Canvas Element"),this.F=t.getContext("2d",e),this.B1="",this.z1="",this.X1="",this.clipInsteadOfFill=!1,this.Mf=0,this.Cf=0,this.An=0,this.rl=!1,this.Bh=new Nt,this.vr=!!i}createOrUpdateClipGroup(t,e){}setImageSmoothingEnabled(t){this.F.imageSmoothingEnabled=t}get fillStyle(){return this.F.fillStyle}set fillStyle(t){this.X1!==t&&(this.F.fillStyle=t,this.X1=t)}get font(){return this.F.font}set font(t){this.B1!==t&&(this.F.font=t,this.B1=t)}get globalAlpha(){return this.F.globalAlpha}set globalAlpha(t){this.F.globalAlpha=t}get lineCap(){return this.F.lineCap}set lineCap(t){this.F.lineCap=t}get lineDashOffset(){return this.F.lineDashOffset}set lineDashOffset(t){this.F.lineDashOffset=t}get lineJoin(){return this.F.lineJoin}set lineJoin(t){this.F.lineJoin=t}get lineWidth(){return this.F.lineWidth}set lineWidth(t){this.F.lineWidth=t}get miterLimit(){return this.F.miterLimit}set miterLimit(t){this.F.miterLimit=t}get shadowBlur(){return this.F.shadowBlur}set shadowBlur(t){this.F.shadowBlur=t}get shadowColor(){return this.F.shadowColor}set shadowColor(t){this.F.shadowColor=t}get shadowOffsetX(){return this.F.shadowOffsetX}set shadowOffsetX(t){this.F.shadowOffsetX=t}get shadowOffsetY(){return this.F.shadowOffsetY}set shadowOffsetY(t){this.F.shadowOffsetY=t}get strokeStyle(){return this.F.strokeStyle}set strokeStyle(t){this.z1!==t&&(this.F.strokeStyle=t,this.z1=t)}get textAlign(){return this.F.textAlign}set textAlign(t){this.F.textAlign=t}get imageSmoothingEnabled(){return this.F.imageSmoothingEnabled}set imageSmoothingEnabled(t){this.F.imageSmoothingEnabled=t}get filter(){return this.F.filter}set filter(t){t===""?this.F.filter="none":this.F.filter=t}get letterSpacing(){return this.F.letterSpacing}set letterSpacing(t){this.F.letterSpacing=t}get wordSpacing(){return this.F.wordSpacing}set wordSpacing(t){this.F.wordSpacing=t}arc(t,e,i,s,n,o,r,a){this.F.arc(t,e,i,s,n,o)}beginPath(){this.F.beginPath()}endPath(){}bezierCurveTo(t,e,i,s,n,o){this.F.bezierCurveTo(t,e,i,s,n,o)}clearRect(t,e,i,s){this.commitTransform(),this.F.clearRect(t,e,i,s)}clip(t){t?this.F.clip(t):this.F.clip()}closePath(){this.F.closePath()}createLinearGradient(t,e,i,s){return this.F.createLinearGradient(t,e,i,s)}createPattern(t,e){return this.F.createPattern(t,e)}createRadialGradient(t,e,i,s,n,o){return this.F.createRadialGradient(t,e,i,s,n,o)}drawImage(t,e,i,s,n,o,r,a,h){s===void 0?this.F.drawImage(t,e,i):this.F.drawImage(t,e,i,s,n,o,r,a,h)}fill(t,e){e?this.F.fill(e,t?"evenodd":"nonzero"):this.F.fill(t?"evenodd":"nonzero")}fillRect(t,e,i,s){this.F.fillRect(t,e,i,s)}fillBackground(t,e,i,s){this.F.fillRect(t,e,i,s)}fillText(t,e,i){this.F.fillText(t,e,i)}getImageData(t,e,i,s){return this.F.getImageData(t,e,i,s)}lineTo(t,e){this.F.lineTo(t,e)}measureText(t){return this.F.measureText(t)}moveTo(t,e){this.F.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this.F.quadraticCurveTo(t,e,i,s)}rect(t,e,i,s){this.F.rect(t,e,i,s)}restore(){this.F.restore()}save(){this.commitTransform(),this.F.save()}rotate(t){this.Bh.ks(t*57.2958,0,0)}setTransform(t,e,i,s,n,o){this.Bh.setTo(t,e,i,s,n,o)}scale(t,e){this.Bh.et(t,e)}translate(t,e){this.Bh.Gs(t,e)}stroke(t){t?this.F.stroke(t):this.F.stroke()}transform(t,e,i,s,n,o){if(t===1&&e===0&&i===0&&s===1&&n===0&&o===0)return;let r=this.Bh,a=r.m11*t+r.m21*e,h=r.m12*t+r.m22*e,l=r.m11*i+r.m21*s,u=r.m12*i+r.m22*s;r.dx=r.m11*n+r.m21*o+r.dx,r.dy=r.m12*n+r.m22*o+r.dy,r.m11=a,r.m12=h,r.m21=l,r.m22=u}commitTransform(){let t=this.Bh;this.F.setTransform(t.m11,t.m12,t.m21,t.m22,t.dx,t.dy)}fillContext(t,e,i){this.radialFill(t,e,i)||this.fillOrClip(e,i)}radialFill(t,e,i){if(!(t instanceof R)||t.type!==3)return!1;let s=t.bf,n=t.O1;return n>s?(this.scale(s/n,1),this.translate((n-s)/2,0)):s>n&&(this.scale(1,n/s),this.translate(0,(s-n)/2)),this.fillOrClip(e,i),n>s?(this.translate(-(n-s)/2,0),this.scale(1/(s/n),1)):s>n&&(this.translate(0,-(s-n)/2),this.scale(1,1/(n/s))),!0}strokeContext(){this.clipInsteadOfFill||this.stroke()}fillOrClip(t,e){this.clipInsteadOfFill?this.clip(e):this.fill(t,e)}shadowsSet(t,e,i){this.Mf=t,this.Cf=e,this.An=i}shadowsOff(){this.rl=!1,this.shadowOffsetX=0,this.shadowOffsetY=0,this.shadowBlur=0}shadowsOn(){this.rl=!0,this.shadowOffsetX=this.Mf,this.shadowOffsetY=this.Cf,this.shadowBlur=this.An}enableDash(t,e){let i=this.F;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=e)}disableDash(){let t=this.F;t.setLineDash!==void 0&&(t.setLineDash(ci.EmptyArray),t.lineDashOffset=0)}clearContextCache(t){t&&(this.B1=""),this.z1="",this.X1=""}removePartFromView(t){}static EmptyArray=Object.freeze([])}var Fe=(x=>(x[x.Solid=1]="Solid",x[x.Linear=2]="Linear",x[x.Radial=3]="Radial",x[x.Pattern=4]="Pattern",x))(Fe||{}),Ys=(x=>(x[x.Lab=1]="Lab",x[x.HSL=2]="HSL",x[x.Oklch=3]="Oklch",x))(Ys||{});class _e{n0;n1;n2;n3;constructor(){this.n0=0,this.n1=0,this.n2=0,this.n3=0}}class R{u;W;zh;ae;Ns;y0;w0;Wo;x0;Nn;bf;O1;constructor(t,e){if(V.Je(this),this.u=!1,t===void 0)this.W=1,this.zh="black";else if(typeof t=="string"){let s=m.Ja(Fe,t);s!==null?(this.W=s,this.zh="black"):(this.W=1,this.zh=t)}else Object.keys(Fe).hasOwnProperty(t)?(this.W=t,this.zh="black"):typeof t=="object"&&(this.W=1,e=t);let i=this.W;if(i===2?(this.ae=T.TopCenter,this.Ns=T.BottomCenter):i===3?(this.ae=T.Center,this.Ns=T.Center):(this.ae=T.None,this.Ns=T.None),this.y0=0,this.w0=NaN,this.Wo=null,this.x0=null,this.Nn=null,this.bf=0,this.O1=0,e){let s={};for(let n in e)isFinite(parseFloat(n))?this.addColorStop(parseFloat(n),e[n]):s[n]=e[n];Object.assign(this,s)}}copy(){let t=new R;return t.W=this.W,t.zh=this.zh,t.ae=this.ae.C(),t.Ns=this.Ns.C(),t.y0=this.y0,t.w0=this.w0,this.Wo!==null&&(t.Wo=this.Wo.copy()),t.x0=this.x0,t}k(){return this.u=!0,this.Wo!==null&&this.Wo.k(),this}fe(t){t in Fe?this.type=t:m.ur(this,t)}toString(){let t="Brush(";if(this.type===1)t+=this.color;else if(this.type===2?t+="Linear ":this.type===3?t+="Radial ":this.type===4?t+="Pattern ":t+="(unknown) ",t+=this.start+" "+this.end,this.colorStops!==null){let e=this.colorStops.iterator;for(;e.next();){let i=e.key,s=e.value;t+=" "+i+":"+s}}return t+=")",t}addColorStop(t,e){return this.u&&m.L(this),(typeof t!="number"||!isFinite(t)||t>1||t<0)&&m.J(t,"0 <= loc <= 1",R,"addColorStop:loc"),m.s(e,"string",R,"addColorStop:color"),this.Wo===null&&(this.Wo=new Mt),this.Wo.set(t,e),this.W===1&&(this.type=2),this.Nn=null,this}get type(){return this.W}set type(t){this.u&&m.L(this,t),this.W=t,this.start.isNoSpot()&&(t===2?this.start=T.TopCenter:t===3&&(this.start=T.Center)),this.end.isNoSpot()&&(t===2?this.end=T.BottomCenter:t===3&&(this.end=T.Center)),this.Nn=null}get color(){return this.zh}set color(t){this.u&&m.L(this,t),this.zh=t,this.Nn=null}get start(){return this.ae}set start(t){this.u&&m.L(this,t),this.ae=t.C(),this.Nn=null}get end(){return this.Ns}set end(t){this.u&&m.L(this,t),this.Ns=t.C(),this.Nn=null}get startRadius(){return this.y0}set startRadius(t){this.u&&m.L(this,t),t<0&&m.J(t,">= zero",R,"startRadius"),this.y0=t,this.Nn=null}get endRadius(){return this.w0}set endRadius(t){this.u&&m.L(this,t),t<0&&m.J(t,">= zero",R,"endRadius"),this.w0=t,this.Nn=null}get colorStops(){return this.Wo}set colorStops(t){this.u&&m.L(this,t),this.Wo=t,this.Nn=null}get pattern(){return this.x0}set pattern(t){this.u&&m.L(this,t),this.x0=t,this.Nn=null}static randomColor(t,e){t===void 0&&(t=128),e===void 0&&(e=Math.max(t,255));let i=Math.abs(e-t),s=Math.floor(t+Math.random()*i).toString(16),n=Math.floor(t+Math.random()*i).toString(16),o=Math.floor(t+Math.random()*i).toString(16);return s.length<2&&(s="0"+s),n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),"#"+s+n+o}static isValidColor(t){return K.CSS?K.CSS.supports("color",t):!0}static lighten(t){return R.lightenBy(t)}lightenBy(t,e){this.u&&m.L(this);let i=t===void 0||typeof t!="number"?.2:t,s=e===void 0?3:e;if(this.type===1)R.Eo(this.color),this.color=R.Ad(i,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){let n=this.colorStops.iterator;for(;n.next();)R.Eo(n.value),this.addColorStop(n.key,R.Ad(i,s))}return this}static lightenBy(t,e,i){let s=e===void 0||typeof e!="number"?.2:e,n=i===void 0?3:i;return R.Eo(t),R.Ad(s,n)}static darken(t){return R.darkenBy(t)}darkenBy(t,e){this.u&&m.L(this);let i=t===void 0||typeof t!="number"?.2:t,s=e===void 0?3:e;if(this.type===1)R.Eo(this.color),this.color=R.Ad(-i,s);else if((this.type===2||this.type===3)&&this.colorStops!==null){let n=this.colorStops.iterator;for(;n.next();)R.Eo(n.value),this.addColorStop(n.key,R.Ad(-i,s))}return this}static darkenBy(t,e,i){let s=e===void 0||typeof e!="number"?.2:e,n=i===void 0?3:i;return R.Eo(t),R.Ad(-s,n)}static mix(t,e,i){R.Eo(t);let s=R.Y.n0,n=R.Y.n1,o=R.Y.n2,r=R.Y.n3;R.Eo(e),i===void 0&&(i=.5);let a=Math.round((R.Y.n0-s)*i+s),h=Math.round((R.Y.n1-n)*i+n),l=Math.round((R.Y.n2-o)*i+o),u=Math.round((R.Y.n3-r)*i+r);return`rgba(${a}, ${h}, ${l}, ${u})`}isDark(){if(this.type===1)return R.isDark(this.color);if((this.type===2||this.type===3)&&this.colorStops!==null){let t=this.colorStops;if(this.type===3){let a=t.first();return a?R.isDark(a.value):!1}if(t.get(.5)!==null)return R.isDark(t.get(.5));if(t.count===2){let a=t.toArray();return R.isDark(R.mix(a[0].value,a[1].value))}let e=t.iterator,i=-1,s=-1,n=1,o=1;for(;e.next();){let a=e.key,h=Math.abs(.5-e.key);n>o&&h<n?(i=a,n=h):o>=n&&h<o&&(s=a,o=h)}if(i>s){let a=i;i=s,s=a,a=n,n=o,o=a}let r=s-i;return R.isDark(R.mix(t.get(i),t.get(s),1-o/r))}return!1}static isDark(t){return t?t instanceof R?t.isDark():(R.Eo(t),(299*R.Y.n0+587*R.Y.n1+114*R.Y.n2)/1e3<128):!1}static Ad(t,e){switch(e){case 1:return R.MI(),R.ho.n0=Math.min(100,Math.max(0,R.ho.n0+100*t)),R.CI(),"rgba("+R.Y.n0+", "+R.Y.n1+", "+R.Y.n2+", "+R.Y.n3+")";case 2:return R.FM(),R.ze.n2=Math.min(100,Math.max(0,R.ze.n2+100*t)),"hsla("+R.ze.n0+", "+R.ze.n1+"%, "+R.ze.n2+"%, "+R.ze.n3+")";case 3:return R.NI(),R.co.n0=Math.min(100,Math.max(0,R.co.n0+100*t)),R.LI(),"rgba("+R.Y.n0+", "+R.Y.n1+", "+R.Y.n2+", "+R.Y.n3+")";default:m.o("Unknown color space: "+e)}}static Eo(t){R.b0===!1&&(R.b0=!0,R.us=Y.isUsingDOM()?new De(null,void 0,{willReadFrequently:!0})._t:null);let e=R.us;if(e===null)return;e.clearRect(0,0,1,1),e.fillStyle="#000000";let i=e.fillStyle;if(e.fillStyle=t,e.fillStyle!==i){e.fillRect(0,0,1,1);let s=e.getImageData(0,0,1,1).data;R.Y.n0=s[0],R.Y.n1=s[1],R.Y.n2=s[2],R.Y.n3=s[3]/255}else{e.fillStyle="#FFFFFF";let s=e.fillStyle;e.fillStyle=t,e.fillStyle,R.Y.n0=0,R.Y.n1=0,R.Y.n2=0,R.Y.n3=1}}static FM(){let t=R.Y.n0/255,e=R.Y.n1/255,i=R.Y.n2/255,s=Math.max(t,e,i),n=Math.min(t,e,i),o=s-n,r,a,h=(s+n)/2;if(o===0)r=a=0;else{switch(s){case t:r=(e-i)/o%6;break;case e:r=(i-t)/o+2;break;case i:r=(t-e)/o+4;break;default:r=0;break}r*=60,r<0&&(r+=360),a=o/(1-Math.abs(2*h-1))}R.ze.n0=Math.round(r),R.ze.n1=Math.round(a*100),R.ze.n2=Math.round(h*100),R.ze.n3=R.Y.n3}static BU(){let t=R.ze.n0,e=R.ze.n1/100,i=R.ze.n2/100,s,n,o,r=(1-Math.abs(2*i-1))*e,a=t/60,h=r*(1-Math.abs(a%2-1));a>=0&&a<1?(s=r,n=h,o=0):a>=1&&a<2?(s=h,n=r,o=0):a>=2&&a<3?(s=0,n=r,o=h):a>=3&&a<4?(s=0,n=h,o=r):a>=4&&a<5?(s=h,n=0,o=r):(s=r,n=0,o=h);let l=i-.5*r;s+=l,n+=l,o+=l,R.Y.n0=Math.round(s*255),R.Y.n1=Math.round(n*255),R.Y.n2=Math.round(o*255),R.Y.n3=R.ze.n3}static MI(){R.lD(),R.AI()}static CI(){R.TI(),R.aD()}static EC(t){return t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}static UC(t){return t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055}static lD(){let t=R.EC(R.Y.n0),e=R.EC(R.Y.n1),i=R.EC(R.Y.n2);R.At.n0=.4124564*t+.3575761*e+.1804375*i,R.At.n1=.2126729*t+.7151522*e+.072175*i,R.At.n2=.0193339*t+.119192*e+.9503041*i,R.At.n3=R.Y.n3}static aD(){let t=3.2404542*R.At.n0+-1.5371385*R.At.n1+-.4985314*R.At.n2,e=-.969266*R.At.n0+1.8760108*R.At.n1+.041556*R.At.n2,i=.0556434*R.At.n0+-.2040259*R.At.n1+1.0572252*R.At.n2;R.Y.n0=R.UC(t)*255,R.Y.n1=R.UC(e)*255,R.Y.n2=R.UC(i)*255,R.Y.n3=R.At.n3,R.Y.n0=Math.round(R.Y.n0),R.Y.n0>255?R.Y.n0=255:R.Y.n0<0&&(R.Y.n0=0),R.Y.n1=Math.round(R.Y.n1),R.Y.n1>255?R.Y.n1=255:R.Y.n1<0&&(R.Y.n1=0),R.Y.n2=Math.round(R.Y.n2),R.Y.n2>255?R.Y.n2=255:R.Y.n2<0&&(R.Y.n2=0)}static VC=216/24389;static G1=24389/27;static Td=[95.047,100,108.883];static BC(t){return t>R.VC?Math.pow(t,1/3):(R.G1*t+16)/116}static AI(){let t=R.BC(R.At.n0*100/R.Td[0]),e=R.BC(R.At.n1*100/R.Td[1]),i=R.BC(R.At.n2*100/R.Td[2]);R.ho.n0=116*e-16,R.ho.n1=500*(t-e),R.ho.n2=200*(e-i),R.ho.n3=R.At.n3}static hD(t){let e=t*t*t;return e>R.VC?e:(116*t-16)/R.G1}static TI(){let t=(R.ho.n0+16)/116,e=R.ho.n1/500+t,i=t-R.ho.n2/200;R.At.n0=R.Td[0]/100*R.hD(e),R.At.n1=R.Td[1]/100*(R.ho.n0>R.G1*R.VC?Math.pow(t,3):R.ho.n0/R.G1),R.At.n2=R.Td[2]/100*R.hD(i),R.At.n3=R.ho.n3}static DI(){let t=.8190224*R.At.n0+.3619062*R.At.n1+-.1288737*R.At.n2,e=.03298366*R.At.n0+.9292868*R.At.n1+.03614466*R.At.n2,i=.04817719*R.At.n0+.2642395*R.At.n1+.6335478*R.At.n2;t=Math.cbrt(t),e=Math.cbrt(e),i=Math.cbrt(i),R.ge.n0=.2104542*t+.7936177*e+-.004072046*i,R.ge.n1=1.977998*t+-2.428592*e+.4505937*i,R.ge.n2=.02590403*t+.7827717*e+-.8086757*i,R.ge.n3=R.At.n3,R.ge.n0*=100}static vI(){R.ge.n0/=100;let t=.9999999*R.ge.n0+.3963377*R.ge.n1+.2158037*R.ge.n2,e=1.000000009*R.ge.n0+-.1055613*R.ge.n1+-.06385417*R.ge.n2,i=1.00000005*R.ge.n0+-.08948418*R.ge.n1+-1.291485*R.ge.n2;t=t**3,e=e**3,i=i**3,R.At.n0=1.2268798*t+-.5578149*e+.281391*i,R.At.n1=-.04057576*t+1.112286*e+-.07171106*i,R.At.n2=-.07637294*t+-.4214933*e+1.586924*i,R.At.n3=R.ge.n3}static FI(){let t=Math.atan2(R.ge.n2,R.ge.n1)*180/Math.PI;R.co.n0=R.ge.n0,R.co.n1=Math.sqrt(R.ge.n1**2+R.ge.n2**2),R.co.n2=t>=0?t:t+360,R.co.n3=R.ge.n3}static RI(){R.ge.n0=R.co.n0,R.ge.n1=R.co.n1*Math.cos(R.co.n2*Math.PI/180),R.ge.n2=R.co.n1*Math.sin(R.co.n2*Math.PI/180),R.ge.n3=R.co.n3}static NI(){R.lD(),R.DI(),R.FI()}static LI(){R.RI(),R.vI(),R.aD()}static Cd(t,e){typeof t=="string"||t instanceof R||m.o("Value for "+e+" must be a color string or a Brush, not "+t)}static Solid=1;static Linear=2;static Radial=3;static Pattern=4;static Lab=1;static HSL=2;static us=null;static b0=!1;static Y=new _e;static ze=new _e;static At=new _e;static ho=new _e;static ge=new _e;static co=new _e}class Lt{Pt="Base";static fs=new Mt;static Tn(t,e){e.name=t,Lt.fs.set(t,e)}get name(){return this.Pt}set name(t){this.Pt=t}constructor(){}get classType(){return G}measure(t,e,i,s,n,o,r){}measureElement(t,e,i,s,n){t.ht(e,i,s,n)}arrange(t,e,i){}arrangeElement(t,e,i,s,n,o){t.Ut(e,i,s,n,o)}remeasureObject(t){t.kf()}Ge(t,e,i){}}class In extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=t.Jo();for(let l=0;l<a;l++){let u=s[l];if(!u.visible&&u!==h)continue;let c=u.margin,d=c.right+c.left,f=c.top+c.bottom;u.ht(e,i,o,r);let p=u.measuredBounds,g=Math.max(p.width+d,0),y=Math.max(p.height+f,0),b=u.position.x,v=u.position.y;if(isFinite(b)||(b=0),isFinite(v)||(v=0),u instanceof it&&u.isGeometryPositioned){let w=u.strokeWidth/2;b-=w,v-=w}n.re(b,v,g,y)}}arrange(t,e,i){let s=e.length,n=t.padding,o=i.x-n.left,r=i.y-n.top;for(let a=0;a<s;a++){let h=e[a],l=h.measuredBounds,u=h.margin,c=h.position.x,d=h.position.y,f=isNaN(c)?-o:c-o,p=isNaN(d)?-r:d-r;if(h instanceof it&&h.isGeometryPositioned){let g=h.strokeWidth/2;f-=g,p-=g}h.visible&&h.Ut(f+u.left,p+u.top,l.width,l.height)}}}Lt.Tn("Position",new In);class Bn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=m.st(),l=t.Jo();for(let c=0;c<a;c++){let d=s[c];if(!d.visible&&d!==l)continue;let f=d.Qs(!1);if(f!==0&&f!==5){h.push(d);continue}d.ht(1/0,i,0,r);let p=d.margin,g=d.measuredBounds,y=Math.max(g.width+p.right+p.left,0),b=Math.max(g.height+p.top+p.bottom,0);n.Kn(n.width+y,Math.max(n.height,b))}let u=h.length;t.desiredSize.height?i=Math.min(t.desiredSize.height,t.maxSize.height):n.height!==0&&(i=Math.min(n.height,t.maxSize.height));for(let c=0;c<u;c++){let d=h[c];if(!d.visible&&d!==l)continue;let f=d.margin,p=f.right+f.left,g=f.top+f.bottom;d.ht(1/0,i,0,r);let y=d.measuredBounds,b=Math.max(y.width+p,0),v=Math.max(y.height+g,0);n.width+=b,n.height=Math.max(n.height,v)}m.Z(h)}arrange(t,e,i){let s=e.length,n=t.padding,o=n.top,r=t.isOpposite,a=r?i.width:n.left;for(let h=0;h<s;h++){let l=o,u=e[h];if(!u.visible)continue;let c=u.measuredBounds,d=u.margin,f=d.top+d.bottom,p=o+n.bottom,g=c.height,y=u.Qs(!1);(isNaN(u.desiredSize.height)&&y===2||y===4)&&(g=Math.max(i.height-f-p,0));let b=g+f+p,v=u.alignment;v.isDefault()&&(v=t.defaultAlignment),v.isSpot()||(v=T.Center),r&&(a-=c.width+d.left+d.right),u.Ut(a+v.offsetX+d.left,l+v.offsetY+d.top+(i.height*v.y-b*v.y),c.width,g),r||(a+=c.width+d.left+d.right)}}}Lt.Tn("Horizontal",new Bn);class Vn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length,h=m.st(),l=t.Jo();for(let c=0;c<a;c++){let d=s[c];if(!d.visible&&d!==l)continue;let f=d.Qs(!1);if(f!==0&&f!==4){h.push(d);continue}d.ht(e,1/0,o,0);let p=d.margin,g=d.measuredBounds,y=Math.max(g.width+p.right+p.left,0),b=Math.max(g.height+p.top+p.bottom,0);n.Kn(Math.max(n.width,y),n.height+b)}let u=h.length;t.desiredSize.width?e=Math.min(t.desiredSize.width,t.maxSize.width):n.width!==0&&(e=Math.min(n.width,t.maxSize.width));for(let c=0;c<u;c++){let d=h[c];if(!d.visible&&d!==l)continue;let f=d.margin,p=f.right+f.left,g=f.top+f.bottom;d.ht(e,1/0,o,0);let y=d.measuredBounds,b=Math.max(y.width+p,0),v=Math.max(y.height+g,0);n.width=Math.max(n.width,b),n.height+=v}m.Z(h)}arrange(t,e,i){let s=e.length,n=t.padding,o=n.left,r=t.isOpposite,a=r?i.height:n.top;for(let h=0;h<s;h++){let l=o,u=e[h];if(!u.visible)continue;let c=u.measuredBounds,d=u.margin,f=d.left+d.right,p=o+n.right,g=c.width,y=u.Qs(!1);(isNaN(u.desiredSize.width)&&y===2||y===5)&&(g=Math.max(i.width-f-p,0));let b=g+f+p,v=u.alignment;v.isDefault()&&(v=t.defaultAlignment),v.isSpot()||(v=T.Center),r&&(a-=c.height+d.bottom+d.top),u.Ut(l+v.offsetX+d.left+(i.width*v.x-b*v.x),a+v.offsetY+d.top,g,c.height),r||(a+=c.height+d.bottom+d.top)}}}Lt.Tn("Vertical",new Vn);class Mi extends Lt{constructor(){super()}static cD=!1;measure(t,e,i,s,n,o,r){let a=s.length;if(a===0)return;let h=t.findMainElement(),l=h.margin,u=0,c=0,d=l.right+l.left,f=l.top+l.bottom;h.ht(e,i,o,r);let p=h.measuredBounds,g=p.width,y=p.height,b=Math.max(g+d,0),v=Math.max(y+f,0),w=t.isClipping;w&&h.Gp()!==0&&!Mi.cD&&(Mi.cD=!0,m.ne("Main Shape for Spot Panel with isClipping = true must have a zero strokeWidth: "+t.toString()));let k=I.z(-l.left,-l.top,b,v),S=I.z(0,0,g,y);this.zC(h,S,!0),g=S.width,y=S.height;let N=!0,D=t.Jo(),L;for(let M=0;M<a;M++){let A=s[M],F=e,O=i;if(A===h||!A.visible&&A!==D)continue;l=A.margin;let E=l.left,B=l.top;switch(u=l.right+l.left,c=l.top+l.bottom,L=A.Qs(!1),L){case 2:F=g,O=y,u=0,c=0,E=0,B=0;break;case 5:F=g,u=0,E=0;break;case 4:O=y,c=0,B=0;break}A.ht(F,O,0,0),p=A.measuredBounds,b=Math.max(p.width+u,0),v=Math.max(p.height+c,0);let X=A.alignment;X.isDefault()&&(X=t.defaultAlignment),X.isSpot()||(X=T.Center);let z=A.alignmentFocus;z.isDefault()&&(z=T.Center);let U=null;A instanceof G&&A.fo!==""&&(U=A.findObject(A.fo),U===A&&(U=null));let tt=S.x-E,st=S.y-B;if(U!==null){A.Ut(0,0,p.width,p.height);let Z=U.actualBounds,et=P.z(Z.x+(z.x*Z.width-z.offsetX),Z.y+(z.y*Z.height-z.offsetY));for(U=U.panel;U!==null&&U!==A;)U.v.gt(et),U=U.panel;tt+=X.x*g+X.offsetX-et.x,st+=X.y*y+X.offsetY-et.y,P.i(et)}else tt+=X.x*g+X.offsetX-(z.x*p.width+z.offsetX),st+=X.y*y+X.offsetY-(z.y*p.height+z.offsetY);N?(N=!1,n.e(tt,st,b,v)):n.re(tt,st,b,v)}switch(N?n.h(k):w?n.intersect(S.x,S.y,S.width,S.height):n.re(k.x,k.y,k.width,k.height),I.i(k),I.i(S),L=h.stretch,L===1&&(L=h.Qs(!1)),L){case 0:return;case 2:if(!isFinite(e)&&!isFinite(i))return;break;case 5:if(!isFinite(e))return;break;case 4:if(!isFinite(i))return;break}p=h.measuredBounds,g=p.width,y=p.height,b=Math.max(g+d,0),v=Math.max(y+f,0),l=h.margin,S=I.z(-l.left,-l.top,b,v),this.zC(h,S,!0),g=S.width,y=S.height;for(let M=0;M<a;M++){let A=s[M];if(A===h||!A.visible&&A!==D)continue;l=A.margin,u=l.right+l.left,c=l.top+l.bottom,p=A.measuredBounds,b=Math.max(p.width+u,0),v=Math.max(p.height+c,0);let F=A.alignment;F.isDefault()&&(F=t.defaultAlignment),F.isSpot()||(F=T.Center);let O=A.alignmentFocus;O.isDefault()&&(O=T.Center),N?(N=!1,n.e(F.x*g+F.offsetX-(O.x*p.width+O.offsetX)-l.left,F.y*y+F.offsetY-(O.y*p.height+O.offsetY)-l.top,b,v)):n.re(F.x*g+F.offsetX-(O.x*p.width+O.offsetX)-l.left,F.y*y+F.offsetY-(O.y*p.height+O.offsetY)-l.top,b,v)}N?n.h(k):w?n.intersect(S.x,S.y,S.width,S.height):n.re(k.x,k.y,k.width,k.height),I.i(S)}arrange(t,e,i){let s=e.length;if(s===0)return;let n=t.findMainElement(),o=n.measuredBounds,r=o.width,a=o.height,h=t.padding,l=h.left,u=h.top,c=l-i.x,d=u-i.y;n.Ut(c,d,r,a);let f=I.z(0,0,r,a);this.zC(n,f,!1);for(let p=0;p<s;p++){let g=e[p];if(g===n)continue;let y=g.measuredBounds,b=y.width,v=y.height,w=g.alignment;w.isDefault()&&(w=t.defaultAlignment),w.isSpot()||(w=T.Center);let k=g.alignmentFocus;k.isDefault()&&(k=T.Center);let S=null;if(g instanceof G&&g.fo!==""&&(S=g.findObject(g.fo),S===g&&(S=null)),S!==null){let N=S.actualBounds,D=P.z(N.x+(k.x*N.width-k.offsetX),N.y+(k.y*N.height-k.offsetY));for(S=S.panel;S!==null&&S!==g;)S.v.gt(D),S=S.panel;c=w.x*f.width+w.offsetX-D.x,d=w.y*f.height+w.offsetY-D.y,P.i(D)}else c=w.x*f.width+w.offsetX-(k.x*b+k.offsetX),d=w.y*f.height+w.offsetY-(k.y*v+k.offsetY);c+=f.x-i.x,d+=f.y-i.y,g.visible&&g.Ut(l+c,u+d,b,v)}I.i(f)}zC(t,e,i){let s=null;if(t instanceof G&&t.fo!==""&&(s=t.findObject(t.fo),s===t&&(s=null)),s!==null)for(i&&t.Ut(0,0,e.width,e.height),e.h(s.actualBounds),s=s.panel;s!==null&&s!==t;)s.v.im(e),s=s.panel}}Lt.Tn("Spot",new Mi);class zn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length;if(a===0)return;let h=t.findMainElement(),l=h.margin,u=e,c=i,d=l.right+l.left,f=l.top+l.bottom;h.ht(e,i,o,r);let p=h.measuredBounds,g=0,y=null;h instanceof it&&(y=h,g=y.strokeWidth*y.scale);let b=Math.max(p.width+d,0),v=Math.max(p.height+f,0),w=t.XC(h),k=w.x*b+w.offsetX,S=w.y*v+w.offsetY,N=t.GC(h),D=N.x*b+N.offsetX,L=N.y*v+N.offsetY;isFinite(e)&&(u=Math.max(Math.abs(k-D)-g,0)),isFinite(i)&&(c=Math.max(Math.abs(S-L)-g,0));let M=0,A=0;o>0&&(M=Math.max(Math.abs(w.x*o+w.offsetX-(N.x*o+N.offsetX))-g,0)),r>0&&(A=Math.max(Math.abs(w.y*r+w.offsetY-(N.y*r+N.offsetY))-g,0));let F=nt.l();F.e(0,0);let O=t.Jo();for(let z=0;z<a;z++){let U=s[z];if(U===h||!U.visible&&U!==O)continue;l=U.margin;let tt=l.right+l.left,st=l.top+l.bottom;U.ht(u,c,M,A),p=U.measuredBounds,b=Math.max(p.width+tt,0),v=Math.max(p.height+st,0),F.e(Math.max(b,F.width),Math.max(v,F.height))}if(a===1){p=h.measuredBounds,n.width=b,n.height=v,nt.i(F);return}w=t.XC(h),N=t.GC(h);let E=0,B=0;N.x!==w.x&&N.y!==w.y&&(E=F.width/Math.abs(N.x-w.x),B=F.height/Math.abs(N.y-w.y)),nt.i(F),g=0,y!==null&&(g=y.strokeWidth*y.scale,y.ZS()===6&&(E=B=Math.max(E,B))),E+=Math.abs(w.offsetX)+Math.abs(N.offsetX)+g,B+=Math.abs(w.offsetY)+Math.abs(N.offsetY)+g;let X=h.stretch;switch(X===1&&(X=h.Qs(!1)),X){case 0:o=0,r=0;break;case 2:isFinite(e)&&(E=e),isFinite(i)&&(B=i);break;case 5:isFinite(e)&&(E=e),r=0;break;case 4:o=0,isFinite(i)&&(B=i);break}h.kf(),h.ht(E,B,o,r),n.width=h.measuredBounds.width+d,n.height=h.measuredBounds.height+f}arrange(t,e,i){let s=e.length;if(s===0)return;let n=t.findMainElement(),o=n.measuredBounds,r=I.l();r.e(0,0,1,1);let a=n.margin,h=a.left,l=a.top,u=t.padding,c=u.left,d=u.top,f=h,p=l,g=o.width,y=o.height;n.Ut(c+f,d+p,g,y);let b=t.XC(n),v=t.GC(n),w=0+b.x*o.width+b.offsetX,k=0+b.y*o.height+b.offsetY,S=0+v.x*o.width+v.offsetX,N=0+v.y*o.height+v.offsetY;r.x=w,r.y=k,r.re(S,N,0,0),r.x+=h+c,r.y+=l+d;for(let D=0;D<s;D++){let L=e[D];if(L===n)continue;let M=L.measuredBounds;a=L.margin;let A=Math.max(M.width+a.right+a.left,0),F=Math.max(M.height+a.top+a.bottom,0),O=L.alignment;O.isDefault()&&(O=t.defaultAlignment),O.isSpot()||(O=T.Center),f=r.width*O.x+O.offsetX-A*O.x+a.left+r.x,p=r.height*O.y+O.offsetY-F*O.y+a.top+r.y,g=r.width,y=r.height,L.visible&&(I.contains(r.x,r.y,r.width,r.height,f,p,M.width,M.height)?L.Ut(f,p,M.width,M.height):L.Ut(f,p,M.width,M.height,new I(r.x,r.y,r.width,r.height)))}I.i(r)}}Lt.Tn("Auto",new zn);class Xn extends Lt{constructor(){super(),this.name="Table"}measure(t,e,i,s,n,o,r){let a=s.length,h=m.st(),l=m.st();for(let ot=0;ot<a;ot++){let H=s[ot],gt=H instanceof G?H:null;if(gt!==null&>.ol()&&H.visible){l.push(gt);let At=gt.D.r,$t=At.length;for(let Ut=0;Ut<$t;Ut++){let Gt=At[Ut];gt.type===G.TableRow?Gt.row=H.row:gt.type===G.TableColumn&&(Gt.column=H.column),h.push(Gt)}}else h.push(H)}a=h.length,a===0&&(t.getRowDefinition(0),t.getColumnDefinition(0));let u=[];for(let ot=0;ot<a;ot++){let H=h[ot];H.visible&&(H.xi(!0),H.lo(!0),u[H.row]||(u[H.row]=[]),u[H.row][H.column]||(u[H.row][H.column]=[]),u[H.row][H.column].push(H))}m.Z(h);let c=m.st(),d=m.st(),f=m.st(),p={count:0},g={count:0},y=e,b=i,v=t.Ii,w=t.Ei,k;a=v.length;for(let ot=0;ot<a;ot++)k=v[ot],k!==void 0&&(k.actual=0,k.ye=0);a=w.length;for(let ot=0;ot<a;ot++)k=w[ot],k!==void 0&&(k.actual=0,k.ye=0);let S=u.length,N=0;for(let ot=0;ot<S;ot++)u[ot]&&(N=Math.max(N,u[ot].length));let D=Math.min(t.topIndex,S-1),L=Math.min(t.leftIndex,N-1),M=0,A;S=u.length;let F=t.Jo();for(let ot=0;ot<S;ot++){if(!u[ot])continue;N=u[ot].length;let H=t.getRowDefinition(ot);H.actual=0,H.ye=0;for(let gt=0;gt<N;gt++){if(!u[ot][gt])continue;let At=t.getColumnDefinition(gt);c[gt]===void 0&&(At.actual=0,At.ye=0,c[gt]=!0);let $t=u[ot][gt],Ut=$t.length;for(let Gt=0;Gt<Ut;Gt++){let Wt=$t[Gt];if(!Wt.visible&&Wt!==F)continue;let ve=Wt.rowSpan>1,ce=Wt.columnSpan>1;(ve||ce)&&!(ot<D)&&!(gt<L)&&d.push(Wt);let fe=Wt.margin,Jt=fe.right+fe.left,Qt=fe.top+fe.bottom;A=Wt.Wp(H,At,!1);let pe=Wt.desiredSize,Ft=!isNaN(pe.width),qt=!isNaN(pe.height);if(A!==0&&!(Ft&&qt)&&!(ot<D)&&!(gt<L)&&(!ce&&p[gt]===void 0&&(A===2||A===5)&&(p[gt]=-1,p.count++),!ve&&g[ot]===void 0&&(A===2||A===4)&&(g[ot]=-1,g.count++),!ve&&!ce&&f.push(Wt)),Wt.ht(1/0,1/0,0,0),ot<D||gt<L)continue;let Ht=Wt.measuredBounds,ke=Math.max(Ht.width+Jt,0),Ae=Math.max(Ht.height+Qt,0);if(Wt.rowSpan===1&&(A===0||A===5)){k=t.getRowDefinition(ot);let Pe=k.computeEffectiveSpacing(),mi=k.q===0;M=Math.max(Ae-k.actual,0),M+(mi?Pe:0)>b&&(M=Math.max(b-Pe,0)),k.ye=k.ye+M,k.actual=k.q+M,b=Math.max(b-(M+(mi?Pe:0)),0)}if(Wt.columnSpan===1&&(A===0||A===4)){k=t.getColumnDefinition(gt);let Pe=k.computeEffectiveSpacing(),mi=k.q===0;M=Math.max(ke-k.actual,0),M+(mi?Pe:0)>y&&(M=Math.max(y-Pe,0)),k.ye=k.ye+M,k.actual=k.q+M,y=Math.max(y-(M+(mi?Pe:0)),0)}(ve||ce)&&Wt.kf()}}}m.Z(c);let O=0,E=0;a=t.columnCount;for(let ot=0;ot<a;ot++){let H=w[ot];H!==void 0&&(O+=isNaN(H.ki)?H.ye:H.ki,H.ye!==0&&(O+=H.computeEffectiveSpacing()))}a=t.rowCount;for(let ot=0;ot<a;ot++){let H=v[ot];H!==void 0&&(E+=isNaN(H.ki)?H.ye:H.ki,H.ye!==0&&(E+=H.computeEffectiveSpacing()))}y=Math.max(e-O,0),b=Math.max(i-E,0);let B=b,X=y;a=f.length;for(let ot=0;ot<a;ot++){let H=f[ot],gt=t.getRowDefinition(H.row),At=t.getColumnDefinition(H.column),$t=H.measuredBounds,Ut=H.margin,Gt=Ut.right+Ut.left,Wt=Ut.top+Ut.bottom;At.ye===0&&p[H.column]!==void 0?p[H.column]=Math.max($t.width+Gt,p[H.column]):p[H.column]=null,gt.ye===0&&g[H.row]!==void 0?g[H.row]=Math.max($t.height+Wt,g[H.row]):g[H.row]=null}let z=0,U=0,tt;for(tt in g)tt!=="count"&&(z+=g[tt]);for(tt in p)tt!=="count"&&(U+=p[tt]);let st=nt.l();for(let ot=0;ot<a;ot++){let H=f[ot];if(!H.visible&&H!==F)continue;let gt=t.getRowDefinition(H.row),At=t.getColumnDefinition(H.column),$t=0;isFinite(At.width)?$t=At.width:(isFinite(y)&&p[H.column]!==null?U===0?$t=At.actual+y:$t=p[H.column]/U*X:p[H.column]!==null?$t=y:$t=At.actual||y,$t=Math.max(0,$t-At.computeEffectiveSpacing()));let Ut=0;switch(isFinite(gt.height)?Ut=gt.height:(isFinite(b)&&g[H.row]!==null?z===0?Ut=gt.actual+b:Ut=g[H.row]/z*B:g[H.row]!==null?Ut=b:Ut=gt.actual||b,Ut=Math.max(0,Ut-gt.computeEffectiveSpacing())),st.e(Math.max(At.minimum,Math.min($t,At.maximum)),Math.max(gt.minimum,Math.min(Ut,gt.maximum))),A=H.Wp(gt,At,!1),A){case 5:st.height=Math.max(st.height,gt.actual+b);break;case 4:st.width=Math.max(st.width,At.actual+y);break}let Gt=H.margin,Wt=Gt.right+Gt.left,ve=Gt.top+Gt.bottom;H.kf();let ce=At.minimum,fe=gt.minimum,Jt=H.measuredBounds;Jt.width===0&&p[H.column]!==null&&(ce=Math.max(ce,p[H.column])),Jt.height===0&&g[H.row]!==null&&(fe=Math.max(ce,g[H.row])),H.ht(st.width,st.height,ce,fe);let Qt=H.measuredBounds,pe=Math.max(Qt.width+Wt,0),Ft=Math.max(Qt.height+ve,0);isFinite(y)&&(pe=Math.min(pe,st.width)),isFinite(b)&&(Ft=Math.min(Ft,st.height));let qt=0;qt=gt.actual,gt.actual=Math.max(gt.actual,Ft),gt.ye=Math.max(gt.ye,Ft),M=gt.actual-qt,b=Math.max(b-M,0),g[H.row]===null&&(B=Math.max(B-M,0)),qt=At.actual,At.actual=Math.max(At.actual,pe),At.ye=Math.max(At.ye,pe),M=At.actual-qt,y=Math.max(y-M,0),p[H.column]===null&&(X=Math.max(X-M,0))}m.Z(f);let Z=nt.l(),et=m.st(),Q=m.st();if(a=d.length,a!==0)for(let ot=0;ot<S;ot++){if(!u[ot])continue;N=u[ot].length;let H=t.getRowDefinition(ot);et[ot]=H.actual;for(let gt=0;gt<N;gt++){if(!u[ot][gt])continue;let At=t.getColumnDefinition(gt);Q[gt]=At.actual}}for(let ot=0;ot<a;ot++){let H=d[ot];if(!H.visible&&H!==F)continue;let gt=t.getRowDefinition(H.row),At=t.getColumnDefinition(H.column);switch(st.e(Math.max(At.minimum,Math.min(e,At.maximum)),Math.max(gt.minimum,Math.min(i,gt.maximum))),A=H.Wp(gt,At,!1),A){case 2:Q[At.index]!==0&&(st.width=Math.min(st.width,Q[At.index])),et[gt.index]!==0&&(st.height=Math.min(st.height,et[gt.index]));break;case 5:Q[At.index]!==0&&(st.width=Math.min(st.width,Q[At.index]));break;case 4:et[gt.index]!==0&&(st.height=Math.min(st.height,et[gt.index]));break}if(A===2||A===4){let Ft=0;for(let qt=0;qt<t.rowCount;qt++){if(qt>=H.row&&qt<H.row+H.rowSpan)continue;let Ht=t.Ii[qt];Ht!==void 0&&(Ft+=et[qt]||0,Ht.ye!==0&&(Ft+=Ht.computeEffectiveSpacing()))}st.height=Math.max(st.height-Ft,0)}if(A===2||A===5){let Ft=0;for(let qt=0;qt<t.columnCount;qt++){if(qt>=H.column&&qt<H.column+H.columnSpan)continue;let Ht=t.Ei[qt];Ht!==void 0&&(Ft+=Q[qt]||0,Ht.ye!==0&&(Ft+=Ht.computeEffectiveSpacing()))}st.width=Math.max(st.width-Ft,0)}isFinite(At.width)&&(st.width=At.width),isFinite(gt.height)&&(st.height=gt.height),Z.e(0,0);let $t=At.minimum,Ut=gt.minimum;for(let Ft=1;Ft<H.rowSpan&&!(H.row+Ft>=t.rowCount);Ft++){if(k=t.getRowDefinition(H.row+Ft),M=0,A===2||A===4){if(k.q===0)continue;M=Math.max(k.minimum,k.q===0?k.maximum:Math.min(k.q,k.maximum))}else M=Math.max(k.minimum,isNaN(k.ki)?k.maximum:Math.min(k.ki,k.maximum));Z.height+=M,Ut+=k.minimum}for(let Ft=1;Ft<H.columnSpan&&!(H.column+Ft>=t.columnCount);Ft++){if(k=t.getColumnDefinition(H.column+Ft),M=0,A===2||A===5){if(k.q===0)continue;M=Math.max(k.minimum,k.q===0?k.maximum:Math.min(k.q,k.maximum))}else M=Math.max(k.minimum,isNaN(k.ki)?k.maximum:Math.min(k.ki,k.maximum));Z.width+=M,$t+=k.minimum}st.width+=Z.width,st.height+=Z.height;let Gt=H.margin,Wt=Gt.right+Gt.left,ve=Gt.top+Gt.bottom;H.ht(st.width,st.height,$t,Ut);let ce=H.measuredBounds,fe=Math.max(ce.width+Wt,0),Jt=Math.max(ce.height+ve,0),Qt=0;for(let Ft=0;Ft<H.rowSpan&&!(H.row+Ft>=t.rowCount);Ft++)k=t.getRowDefinition(H.row+Ft),Qt+=k.total||0;if(Qt<Jt){let Ft=Jt-Qt,qt=Jt-Qt;if(H.spanAllocation!==null){let Ht=H.spanAllocation;for(let ke=0;ke<H.rowSpan&&!(Ft<=0||H.row+ke>=t.rowCount);ke++){k=t.getRowDefinition(H.row+ke);let Ae=k.q||0,Pe=Ht(H,k,qt);k.actual=Math.min(k.maximum,Ae+Pe),k.q!==Ae&&(Ft-=k.q-Ae)}}for(;Ft>0&&k!==void 0;){let Ht=k.q||0;if(isNaN(k.height)&&k.maximum>Ht&&(k.actual=Math.min(k.maximum,Ht+Ft),k.q!==Ht&&(Ft-=k.q-Ht)),k.index===0)break;k=t.getRowDefinition(k.index-1)}}let pe=0;for(let Ft=0;Ft<H.columnSpan&&!(H.column+Ft>=t.columnCount);Ft++)k=t.getColumnDefinition(H.column+Ft),pe+=k.total||0;if(pe<fe){let Ft=fe-pe,qt=fe-pe;if(H.spanAllocation!==null){let Ht=H.spanAllocation;for(let ke=0;ke<H.columnSpan&&!(Ft<=0||H.column+ke>=t.columnCount);ke++){k=t.getColumnDefinition(H.column+ke);let Ae=k.q||0,Pe=Ht(H,k,qt);k.actual=Math.min(k.maximum,Ae+Pe),k.q!==Ae&&(Ft-=k.q-Ae)}}for(;Ft>0&&k!==void 0;){let Ht=k.q||0;if(isNaN(k.width)&&k.maximum>Ht&&(k.actual=Math.min(k.maximum,Ht+Ft),k.q!==Ht&&(Ft-=k.q-Ht)),k.index===0)break;k=t.getColumnDefinition(k.index-1)}}}m.Z(d),nt.i(Z),nt.i(st),et!==void 0&&m.Z(et),Q!==void 0&&m.Z(Q);let rt=0,ft=0,xt=t.desiredSize,Ct=t.maxSize;A=t.Qs(!0),O=0,E=0;let _=0,St=0;a=t.columnCount;for(let ot=0;ot<a;ot++)if(w[ot]!==void 0){if(k=t.getColumnDefinition(ot),isFinite(k.width)){_+=k.width,_+=k.computeEffectiveSpacing();continue}else if(k.Y1()===2){_+=k.q,_+=k.computeEffectiveSpacing();continue}k.q!==0&&(O+=k.q,O+=k.computeEffectiveSpacing())}isFinite(xt.width)?rt=Math.min(xt.width,Ct.width):A!==0&&isFinite(e)?rt=e:rt=O,rt=Math.max(rt,isFinite(e)?Math.min(o,e):o),rt=Math.max(rt-_,0);let bt=O===0?1:Math.max(rt/O,1);for(let ot=0;ot<a;ot++)w[ot]!==void 0&&(k=t.getColumnDefinition(ot),!isFinite(k.width)&&k.Y1()!==2&&(k.actual=k.q*bt),k.position=n.width,k.q!==0&&(n.width+=k.q,n.width+=k.computeEffectiveSpacing()));a=t.rowCount;for(let ot=0;ot<a;ot++)if(v[ot]!==void 0){if(k=t.getRowDefinition(ot),isFinite(k.height)){St+=k.height,St+=k.computeEffectiveSpacing();continue}else if(k.Y1()===2){St+=k.q,St+=k.computeEffectiveSpacing();continue}k.q!==0&&(E+=k.q,E+=k.computeEffectiveSpacing())}isFinite(xt.height)?ft=Math.min(xt.height,Ct.height):A!==0&&isFinite(i)?ft=i:ft=E,ft=Math.max(ft,isFinite(i)?Math.min(r,i):r),ft=Math.max(ft-St,0);let Yt=E===0?1:Math.max(ft/E,1);for(let ot=0;ot<a;ot++)v[ot]!==void 0&&(k=t.getRowDefinition(ot),!isFinite(k.height)&&k.Y1()!==2&&(k.actual=k.q*Yt),k.position=n.height,k.q!==0&&(n.height+=k.q,n.height+=k.computeEffectiveSpacing()));a=l.length;for(let ot=0;ot<a;ot++){let H=l[ot],gt=0,At=0;H.type===G.TableRow?(gt=n.width,k=t.getRowDefinition(H.row),At=k.actual):(k=t.getColumnDefinition(H.column),gt=k.actual,At=n.height),H.measuredBounds.e(0,0,gt,At),H.xi(!1)}m.Z(l),t.La=u}arrange(t,e,i){let s=e.length,n=t.padding,o=n.left,r=n.top,a=t.La;if(a===null)return;let h=0,l=0,u=a.length,c=0;for(let L=0;L<u;L++)a[L]&&(c=Math.max(c,a[L].length));let d=t.Ii,f=t.Ei,p=0,g=0,y=Math.min(t.topIndex,u-1);if(d.length>0){for(;y!==u&&(d[y]===void 0||d[y].q===0);)y++;y=Math.max(Math.min(y,u-1),0),p=-d[y].position}let b=Math.min(t.leftIndex,c-1);if(f.length>0){for(;b!==c&&(f[b]===void 0||f[b].q===0);)b++;b=Math.max(Math.min(b,c-1),0),g=-f[b].position}let v=0,w=0;for(;v!==u&&d[v]===void 0;)v++;for(;w!==u&&f[w]===void 0;)w++;let k=t.part,S=t.getRowDefinition(v),N=t.getColumnDefinition(w);for(let L=0;L<e.length;L++){let M=e[L];if(!(M instanceof G&&M.visible&&M.ol()))continue;M.type===G.TableRow?(S=t.getRowDefinition(M.row),N=t.getColumnDefinition(w)):(S=t.getRowDefinition(v),N=t.getColumnDefinition(M.column)),l=S.position+p+r,S.q!==0&&(l+=S.computeEffectiveSpacingTop(Math.max(v,y))),h=N.position+g+o,N.q!==0&&(h+=N.computeEffectiveSpacingTop(Math.max(w,b)));let A=M.measuredBounds;M.yf(),M.actualBounds.ce();let F=M.actualBounds,O=I.z(F.x,F.y,F.width,F.height);if(F.x=M.type===G.TableRow?o:h,F.y=M.type===G.TableColumn?r:l,F.width=A.width,F.height=A.height,M.actualBounds.k(),M.lo(!1),O.equalsApproxClose(F)){I.i(O);continue}k!==null&&(k.Pa(),M.Kp(k)),I.i(O)}let D=nt.l();for(let L=0;L<u;L++){if(!a[L])continue;c=a[L].length;let M=t.getRowDefinition(L);l=M.position+p+r,M.q!==0&&(l+=M.computeEffectiveSpacingTop(Math.max(v,y)));for(let A=0;A<c;A++){if(!a[L][A])continue;let F=t.getColumnDefinition(A);h=F.position+g+o,F.q!==0&&(h+=F.computeEffectiveSpacingTop(Math.max(w,b)));let O=a[L][A],E=O.length;for(let B=0;B<E;B++){let X=O[B],z=X.measuredBounds;D.e(0,0);for(let Jt=1;Jt<X.rowSpan&&!(L+Jt>=t.rowCount);Jt++){let Qt=t.getRowDefinition(L+Jt);Qt.q!==0&&(D.height+=Qt.total)}for(let Jt=1;Jt<X.columnSpan&&!(A+Jt>=t.columnCount);Jt++){let Qt=t.getColumnDefinition(A+Jt);Qt.q!==0&&(D.width+=Qt.total)}let U=F.q+D.width,tt=M.q+D.height,st=h,Z=l,et=U,Q=tt,rt=h,ft=l,xt=U,Ct=tt;h+U>i.width&&(xt=Math.max(i.width-h,0)),l+tt>i.height&&(Ct=Math.max(i.height-l,0));let _=X.alignment,St=0,bt=0,Yt=0,ot=0;if(_.isDefault()){_=t.defaultAlignment,_.isSpot()||(_=T.Center),St=_.x,bt=_.y,Yt=_.offsetX,ot=_.offsetY;let Jt=F.alignment,Qt=M.alignment;Jt.isSpot()&&(St=Jt.x,Yt=Jt.offsetX),Qt.isSpot()&&(bt=Qt.y,ot=Qt.offsetY)}else St=_.x,bt=_.y,Yt=_.offsetX,ot=_.offsetY;(isNaN(St)||isNaN(bt))&&(St=.5,bt=.5,Yt=0,ot=0);let H=z.width,gt=z.height,At=X.margin,$t=At.left+At.right,Ut=At.top+At.bottom,Gt=X.Wp(M,F,!1);isNaN(X.desiredSize.width)&&(Gt===2||Gt===5)&&(H=Math.max(U-$t,0)),isNaN(X.desiredSize.height)&&(Gt===2||Gt===4)&&(gt=Math.max(tt-Ut,0));let Wt=X.maxSize,ve=X.minSize;H=Math.min(Wt.width,H),gt=Math.min(Wt.height,gt),H=Math.max(ve.width,H),gt=Math.max(ve.height,gt);let ce=H+$t,fe=gt+Ut;st+=et*St-ce*St+Yt+At.left,Z+=Q*bt-fe*bt+ot+At.top,X.visible&&(I.contains(rt,ft,xt,Ct,st,Z,z.width,z.height)?X.Ut(st,Z,H,gt):X.Ut(st,Z,H,gt,new I(rt,ft,xt,Ct)))}}}nt.i(D);for(let L=0;L<s;L++){let M=e[L],A=M instanceof G?M:null;if(A!==null&&A.ol()){let F=M.actualBounds;M.naturalBounds.ce(),M.naturalBounds.e(0,0,F.width,F.height),M.naturalBounds.k()}}}}Lt.Tn("Table",new Xn);class Kn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){}arrange(t,e,i){}}Lt.Tn("TableRow",new Kn);class Yn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){}arrange(t,e,i){}}Lt.Tn("TableColumn",new Yn);class Un extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){s.length!==1&&m.o("Viewbox Panel must contain exactly one GraphObject.");let a=s[0];a.et=1,a.kf(),a.ht(1/0,1/0,o,r);let h=a.measuredBounds,l=a.margin,u=l.right+l.left,c=l.top+l.bottom;if(isFinite(e)||isFinite(i)){let d=a.scale,f=h.width,p=h.height,g=Math.max(e-u,0),y=Math.max(i-c,0),b=1;t.viewboxStretch===6?(f!==0&&p!==0&&(b=Math.min(g/f,y/p)),b===0&&(b=1e-4),a.et*=b):(f!==0&&p!==0&&(b=Math.max(g/f,y/p)),b===0&&(b=1e-4),a.et*=b),d!==a.scale&&(a.xi(!0),a.ht(1/0,1/0,o,r))}h=a.measuredBounds,n.width=isFinite(e)?e:Math.max(h.width+u,0),n.height=isFinite(i)?i:Math.max(h.height+c,0)}arrange(t,e,i){let s=e[0],n=s.measuredBounds,o=s.margin,r=o.right+o.left,a=o.top+o.bottom,h=Math.max(n.width+r,0),l=Math.max(n.height+a,0),u=s.alignment;u.isDefault()&&(u=t.defaultAlignment),u.isSpot()||(u=T.Center),s.Ut(i.width*u.x-h*u.x+u.offsetX,i.height*u.y-l*u.y+u.offsetY,n.width,n.height)}}Lt.Tn("Viewbox",new Un);class jn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){t.Se===null&&(t.Se=new ti),this.OI(t),this.II(t)}arrange(t,e,i){}Ge(t,e,i){let s=t.naturalBounds;e.save(),e.beginPath(),e.rect(0,0,s.width,s.height),e.clip(),e.endPath(),this.EI(t,e,i),e.restore(),e.clearContextCache(!1)}EI(t,e,i){let s=t.getDocumentScale()*i.scale;s<=0&&(s=1);let n=t.gridCellSize,o=n.width,r=n.height,a=t.naturalBounds,h=t.actualBounds,l=a.width,u=a.height,c=Math.ceil(l/o),d=Math.ceil(u/r),f=t.gridOrigin,p=f.x,g=f.y,y=t.Se.k0,b=t.D.r,v=b.length;for(let w=0;w<v;w++){let k=b[w];if(!k.visible)continue;let S=k.interval||1,N=Math.abs(S);if(o*N*s<2)continue;let D=k.segmentIndex;(!isFinite(D)||isNaN(D))&&(D=0),D<0&&(D=N-Math.min(-D,N)),D=Math.round(D%N);let L=k.opacity,M=1;if(L!==1){if(L===0)continue;M=e.globalAlpha,e.globalAlpha=M*L}let A=y[w],F=!1,O=k.strokeDashArray;if(O!==null&&(F=!0,e.enableDash(O,k.strokeDashOffset)),k.stroke!==null&&k.strokeWidth>0&&(k.figure==="LineV"||k.figure==="LineH")){if(e.lineWidth=k.strokeWidth,t.kn(e,k.stroke,!1,!1,a,h),e.beginPath(),k.figure==="LineV"){let E=Math.floor((p-o)/o);for(let B=E;B<=E+c;B++){let X=B*o+p;0<=X&&X<=l&&this.K1(B,S,D,A)&&(e.moveTo(X,0),e.lineTo(X,u))}}else if(k.figure==="LineH"){let E=Math.floor((g-r)/r);for(let B=E;B<=E+d;B++){let X=B*r+g;0<=X&&X<=u&&this.K1(B,S,D,A)&&(e.moveTo(0,X),e.lineTo(l,X))}}e.stroke(),e.endPath()}else if(k.fill!==null){if(t.kn(e,k.fill,!0,!1,a,h),k.figure==="BarV"){let E=k.width;isNaN(E)&&(E=o);let B=Math.floor((p-o)/o);for(let X=B;X<=B+c;X++){let z=X*o+p;0<=z+E&&z<=l&&this.K1(X,S,D,A)&&e.fillRect(z,0,E,u)}}else if(k.figure==="BarH"){let E=k.height;isNaN(E)&&(E=r);let B=Math.floor((g-r)/r);for(let X=B;X<=B+d;X++){let z=X*r+g;0<=z+E&&z<=u&&this.K1(X,S,D,A)&&e.fillRect(0,z,l,E)}}}F&&e.disableDash(),L!==1&&(e.globalAlpha=M)}}K1(t,e,i,s){if(e<0)return t%e===i;if(t%e!==i)return!1;let n=s.length;for(let o=0;o<n;o++){let r=s[o];if(t%r===i)return!1}return!0}II(t){let e=[],i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n],r=[];if(e.push(r),!o.visible)continue;let a=o.interval;if(a<0)continue;let h=o.figure,l=this.YC(h);for(let u=0;u<s;u++){if(u===n)continue;let c=i[u];if(!c.visible)continue;let d=c.figure;if(this.YC(d)!==l)continue;let f=c.interval;f>a&&r.push(f)}}t.Se.k0=e}YC(t){return t==="LineV"||t==="BarV"}OI(t){let e=1,i=1,s=t.D.r,n=s.length;for(let a=0;a<n;a++){let h=s[a],l=Math.abs(h.interval);l<2||(this.YC(h.figure)?i=i*l/C.HL(i,l):e=e*l/C.HL(e,l))}let o=t.gridCellSize,r=t.Se;r.hf.isReal()?r.hf.e(i*o.width,e*o.height):r.hf=new nt(i*o.width,e*o.height)}}Lt.Tn("Grid",new jn);class Gn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=s.length;if(!(t instanceof vt||t instanceof j))return;let h=null,l=null;if(t instanceof j&&(h=t),t instanceof vt&&(l=t,h=l.adornedPart,t.Af===null&&(t.Af=[])),!(h instanceof j))return;let u=h;if(a===0){t.naturalBounds.Kn(0,0),t.measuredBounds.e(0,0,0,0);return}let c=t instanceof vt?null:h.path,d=h.routeBounds,f=t.$o;f.e(0,0,d.width,d.height);let p=u.points,g=h.pointsCount;l!==null?l.Dd(!1):h!==null&&h.Dd(!1);let y=d.width,b=d.height,v=t.Af;if(v.length=0,c!==null){this.measureLinkPath(t,y,b,c);let N=c.measuredBounds;f.unionRect(N),v.push(N)}let w=Nt.l(),k=P.l(),S=P.l();for(let N=0;N<a;N++){let D=s[N];if(D===c)continue;let L=D.measuredBounds;if(D.isPanelMain&&D instanceof it){this.measureLinkPath(t,y,b,D),L=D.measuredBounds,f.unionRect(L),v.push(L);continue}if(g<2){D.ht(1/0,1/0,0,0),L=D.measuredBounds,f.unionRect(L),v.push(L);continue}let M=D.segmentIndex,A=D.segmentFraction,F=D.alignmentFocus;F.isNoSpot()&&(F=T.Center);let O=D.segmentOrientation,E=D.segmentOffset,B=0,X=0,z=0,U=0;if(isNaN(M)){let _=u.ut,St=m.st();_.getPointAndAngleAlongPath(A,St);let bt=P.z(St[0],St[1]);U=St[2],O!==0&&(z=u.computeAngle(D,O,U),D.Xt=z,D.xi(!0),D.lo(!0)),B=bt.x,X=bt.y,P.i(bt),m.Z(St)}else if(M<-g||M>=g){let _=P.l();u.KC(_),U=u.midAngle,O!==0&&(z=u.computeAngle(D,O,U),D.Xt=z,D.xi(!0),D.lo(!0)),B=_.x-d.x,X=_.y-d.y,P.i(_)}else{let _,St,bt=0;if(M>=0?(_=p.elt(M),St=M<g-1?p.elt(M+1):_):(bt=g+M,_=p.elt(bt),St=bt>0?p.elt(bt-1):_),_.equalsApprox(St)){let Yt,ot;M>=0?(Yt=M>0?p.elt(M-1):_,ot=M<g-2?p.elt(M+2):St):(Yt=bt<g-1?p.elt(bt+1):_,ot=bt>1?p.elt(bt-2):St);let H=Yt.distanceSquaredPoint(_),gt=St.distanceSquaredPoint(ot);H>gt+10?U=M>=0?Yt.directionPoint(_):_.directionPoint(Yt):gt>H+10?U=M>=0?St.directionPoint(ot):ot.directionPoint(St):U=M>=0?Yt.directionPoint(ot):ot.directionPoint(Yt)}else U=M>=0?_.directionPoint(St):St.directionPoint(_);O!==0&&(z=u.computeAngle(D,O,U),D.Xt=z,D.xi(!0),D.lo(!0)),B=_.x+(St.x-_.x)*A-d.x,X=_.y+(St.y-_.y)*A-d.y}D.ht(1/0,1/0,0,0),L=D.measuredBounds;let tt=D.naturalBounds,st=0;D instanceof it&&(st=D.strokeWidth);let Z=tt.width+st,et=tt.height+st;w.Ue(),w.Gs(-L.x,-L.y),w.et(D.scale,D.scale),w.ks(O===0?D.angle:U,Z/2,et/2),(O===22||O===26)&&w.ks(90,Z/2,et/2),(O===23||O===27)&&w.ks(-90,Z/2,et/2),O===28&&(U>45&&U<135||U>225&&U<315)&&w.ks(-U,Z/2,et/2);let Q=new I(0,0,Z,et);k.setRectSpot(Q,F),w.gt(k);let rt=-k.x+st/2*D.scale,ft=-k.y+st/2*D.scale;S.h(E);let xt=isNaN(E.x),Ct=isNaN(E.y);if(xt||Ct){let _=Z/2+j.H1,St=et/2+j.H1,bt=U>=45&&U<=135,Yt=U>=225&&U<=315;O===0&&(bt||Yt)?(S.x=Ct?_:E.y,S.y=xt?St:E.x,bt?M>=0||isNaN(M)&&A<.5||xt&&(S.y=-St):Yt&&((M>=0||isNaN(M)&&A<.5)&&xt&&(S.y=-St),Ct&&(S.x=-_))):(xt&&(M>=0||isNaN(M)&&A<.5?S.x=_:S.x=-_),Ct&&(S.y=-St),S.rotate(U))}else S.rotate(U);B+=S.x,X+=S.y,Q.e(B+rt,X+ft,L.width,L.height),v.push(Q),f.unionRect(Q)}if(h!==null){let N=h.labelNodes;for(;N.next();)N.value.ht(1/0,1/0)}t.$o=f,t.position.e(d.x+f.x,d.y+f.y),n.Kn(f.width||0,f.height||0),Nt.i(w),P.i(k),P.i(S)}arrange(t,e,i){let s=e.length;if(!(t instanceof vt||t instanceof j))return;let n=t,o=null;t instanceof vt&&(o=t,n=o.adornedPart);let r=t,a=t instanceof vt?null:n.path,h=t.Af;if(h.length!==0){let d=0;if(a!==null&&d<h.length){let f=h[d];d++,a.Ut(f.x-r.$o.x,f.y-r.$o.y,f.width,f.height)}for(let f=0;f<s;f++){let p=e[f];if(p!==a&&d<h.length){let g=h[d];d++,p.Ut(g.x-r.$o.x,g.y-r.$o.y,g.width,g.height)}}}let l=n.points,u=l.count;if(u>=2&&r instanceof j){let d=r.labelNodes;for(;d.next();){let f=d.value;r.UI(f,u,l)}}o!==null?o.Dd(!1):n.Dd(!1);let c=t.fD(P.l());t.location.e(t.position.x+c.x,t.position.y+c.y),P.i(c)}measureLinkPath(t,e,i,s){if(s.Xo()===!1)return;let n=s.strokeWidth;if(n===0&&t instanceof vt&&t.type===G.Link&&t.adornedObject instanceof it&&(n=t.adornedObject.strokeWidth),n=n*s.et,t instanceof j&&t.ut!==null){let o=t.geometry.bounds;s.ro(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else if(t instanceof vt&&t.adornedPart.ut!==null){let o=t.adornedPart.ut.bounds;s.ro(o.x-n/2,o.y-n/2,o.width+n,o.height+n)}else s.ro(-(n/2),-(n/2),e+n,i+n);s.VI(),s.xi(!1)}}Lt.Tn("Link",new Gn);class qn extends Lt{constructor(){super()}measure(t,e,i,s,n,o,r){let a=t.findMainElement();if(!(a instanceof it))return;t._i=[];let h=a.margin,l=h.right+h.left,u=h.top+h.bottom;a.ht(e,i,o,r);let c=a.measuredBounds,d=c.width,f=c.height,p=Math.max(d+l,0),g=Math.max(f+u,0),y=new I(-h.left,-h.top,p,g);t._i.push(y),n.h(y),this.determineGraduatedMarks(t,a);let b=t.vs;if(b===null)return;let v=s.length;for(let w=0;w<v;w++){let k=s[w],S=b[w];!k.visible||k===a||S.length===0||(k instanceof it?this.measureGraduatedTicks(t,k,S,n):k instanceof lt&&this.measureGraduatedLabels(t,k,S,n),k.xi(!1))}}arrange(t,e,i){if(t._i===null)return;let s=t.findMainElement(),n=t.vs;if(n===null)return;let o=t._i,r=0,a=o[r];r++,s!==null&&s.Ut(a.x-i.x,a.y-i.y,a.width,a.height);let h=e.length;for(let l=0;l<h;l++){let u=e[l],c=n[l];!u.visible||u===s||c.length===0||(a=o[r],r++,u.Ut(a.x-i.x,a.y-i.y,a.width,a.height))}t._i=null}measureGraduatedTicks(t,e,i,s){let n=e.alignmentFocus;n.isNoSpot()&&(n=T.TopCenter);let o=e.angle;e.Xt=0,e.ht(1/0,1/0,0,0),e.Xt=o;let r=e.measuredBounds,a=r.width,h=r.height,l=I.z(0,0,a,h),u=P.l();u.setRectSpot(l,n),I.i(l);let c=-u.x,d=-u.y,f=new I,p=i.length;for(let g=0;g<p;g++){let y=i[g],b=y.pt.x,v=y.pt.y,w=y.angle;for(let k=0;k<4;k++){switch(k){case 0:u.e(c,d);break;case 1:u.e(c+a,d);break;case 2:u.e(c,d+h);break;case 3:u.e(c+a,d+h);break}u.rotate(w+e.angle),u.offset(b,v),g===0&&k===0?f.e(u.x,u.y,0,0):f.unionPoint(u),u.offset(-b,-v),u.rotate(-w-e.angle)}}P.i(u),t._i!==null&&t._i.push(f),s.re(f.x,f.y,f.width,f.height)}measureGraduatedLabels(t,e,i,s){t.vi===null&&(t.vi=new lt);let n=t.vi;this.uD(e,n);let o=e.alignmentFocus;o.isNoSpot()&&(o=T.TopCenter);let r=e.segmentOrientation,a=e.segmentOffset,h=new I,l=0,u=0,c=0,d=0,f=0,p=i.length;for(let g=0;g<p;g++){let y=i[g];l=y.pt.x,u=y.pt.y,c=y.angle,d=e.angle,f=e.angle,r!==0&&(r===21||r===25?f=c+e.angle:f=c,d=j.computeAngle(r,f)),n.Xt=d,n.text=y.text||"",n.ht(1/0,1/0,0,0);let b=n.measuredBounds,v=n.naturalBounds,w=v.width,k=v.height,S=Nt.l();S.Ue(),S.Gs(-b.x,-b.y),S.et(n.scale,n.scale),S.ks(f,w/2,k/2),(r===22||r===26)&&S.ks(90,w/2,k/2),(r===23||r===27)&&S.ks(-90,w/2,k/2),r===28&&(c>45&&c<135||c>225&&c<315)&&S.ks(-c,w/2,k/2);let N=I.z(0,0,w,k),D=P.l();D.setRectSpot(N,o),S.gt(D);let L=-D.x,M=-D.y,A=P.l();A.h(a),isNaN(A.x)&&(A.x=w/2+3),isNaN(A.y)&&(A.y=-(k/2+3)),A.rotate(c),l+=A.x+L,u+=A.y+M;let F=new I(l,u,b.width,b.height),O=new I(b.x,b.y,b.width,b.height),E=new I(v.x,v.y,v.width,v.height);y.labelAngle=d,y.lineCount=n.lineCount,y.lines=n.getMetrics(),y.actualBounds=F,y.measuredBounds=O,y.naturalBounds=E,g===0?h.h(F):h.unionRect(F),P.i(A),P.i(D),I.i(N),Nt.i(S)}t._i!==null&&t._i.push(h),s.re(h.x,h.y,h.width,h.height)}determineGraduatedMarks(t,e){let i=e.geometry,s=e.strokeWidth,n=i.flattenedSegments,o=i.flattenedLengths,r=i.flattenedTotalLength,a=n.length,h=0,l=0,u=m.st();for(let v=0;v<a;v++){let w=n[v],k=[];h=0,l=0;let S=w.length;for(let N=0;N<S;N+=2){let D=w[N],L=w[N+1];if(N===0){h=D,l=L;continue}let M=Math.atan2(L-l,D-h)*180/Math.PI;M<0&&(M+=360),k.push(M),h=D,l=L}u.push(k)}let c=this.BI(t),d=t.D.r,f=d.length,p=0,g=0,y=r;t.vs=[];let b;for(let v=0;v<f;v++){let w=d[v];if(b=[],!w.visible||w===e){t.vs.push(b);continue}let k=Math.abs(w.interval),S=t.graduatedTickUnit;if(S*k*r/t.graduatedRange<2&&w.graduatedSkip===null){t.vs.push(b);continue}let N=o[0][0],D=0,L=0;g=r*w.graduatedStart-1e-4,y=r*w.graduatedEnd+1e-4;let M=S*k,A=t.graduatedTickBase;if(A<t.graduatedMin){let B=(t.graduatedMin-A)/M;B=B%1===0?B:Math.floor(B+1),A+=B*M}else if(A>t.graduatedMin+M){let B=Math.floor((A-t.graduatedMin)/M);A-=B*M}let F=c[v],O=A,E=t.graduatedMax*1e-6;for(let B=1;A<=t.graduatedMax+E;B++){if(this.zI(t,A-t.graduatedTickBase,F)&&(A>t.graduatedMax&&(A=t.graduatedMax),(w.graduatedSkip===null||w instanceof lt&&!w.graduatedSkip(A,w)||w instanceof it&&!w.graduatedSkip(A,w))&&(p=(A-t.graduatedMin)*r/t.graduatedRange,p>r&&(p=r),g<=p&&p<=y))){let X=u[D][L],z=o[D][L];for(;D<o.length;){for(;p>N&&L<o[D].length-1;)L++,X=u[D][L],z=o[D][L],N+=z;if(p<=N)break;D++,L=0,X=u[D][L],z=o[D][L],N+=z}let U=n[D],tt=U[L*2],st=U[L*2+1],Z=U[L*2+2],et=U[L*2+3],Q=(p-(N-z))/z,rt=new P(tt+(Z-tt)*Q+s/2-i.bounds.x,st+(et-st)*Q+s/2-i.bounds.y);if(rt.scale(e.scale,e.scale),X=this.XI(X,Q,U,u[D],L),w instanceof lt){let ft="";w.graduatedFunction!==null?(ft=w.graduatedFunction(A,w),ft=ft!=null?ft.toString():""):ft=(+A.toFixed(2)).toString(),ft!==""&&b.push({pt:rt,angle:X,text:ft})}else b.push({pt:rt,angle:X})}A=O+B*M}t.vs.push(b)}m.Z(u)}XI(t,e,i,s,n){if(e<.5005&&e>.4995)return t;let o=t;if(e<.5?n>0?o=s[n-1]:C.X(i[0],i[i.length-2])&&C.X(i[1],i[i.length-1])&&(o=s[s.length-1]):e>.5&&(n+1<s.length?o=s[n+1]:C.X(i[0],i[i.length-2])&&C.X(i[1],i[i.length-1])&&(o=s[0])),t!==o){let r=Math.abs(t-o);if(r>180&&(t<o?t+=360:o+=360,r=Math.abs(t-o)),e<5e-4||e>.9995)return(t+o)/2%360;if(r<10){let a=1-Math.abs(.5-e);return(t*a+o*(1-a))%360}}return t}BI(t){if(t.ds===null){let e=[],i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n],r=[];if(e.push(r),!o.visible)continue;let a=o.interval;if(!(a<0))for(let h=0;h<s;h++){if(h===n)continue;let l=i[h];if(!l.visible||o.constructor!==l.constructor)continue;let u=l.interval;u>a&&r.push(u)}}t.ds=e}return t.ds}zI(t,e,i){let s=i.length;for(let n=0;n<s;n++){let o=i[n]*t.graduatedTickUnit,r=e%o,a=t.graduatedTickUnit*1e-6;if(r<a&&r>-a)return!1}return!0}Ge(t,e,i){let s=i.mh;i.mh=!0;let n=t.naturalBounds,o=n.width,r=n.height,a=e instanceof ae;e.save(),e.beginPath(),e.rect(-1,-1,o+1,r+1),e.clip(),e.endPath();let h=t.findMainElement();h.Ge(e,i);let l=t.getDocumentScale()*i.scale;l<=0&&(l=1);let u=h.actualBounds,c=t.D.r,d=t.vs,f=c.length;for(let p=0;p<f;p++){let g=c[p],y=d[p],b=y.length;if(!(!g.visible||g===h||y.length===0)){if(g instanceof it){if(t.graduatedTickUnit*g.interval*h.geometry.flattenedTotalLength/t.graduatedRange*l<2&&g.graduatedSkip===null)continue;let v=g.measuredBounds,w=g.strokeWidth*g.scale,k=g.alignmentFocus;k.isNoSpot()&&(k=T.TopCenter);for(let S=0;S<b;S++){let N=y[S].pt,D=y[S].angle;this.GI(g,N,u,D,v,w,k),g.Ge(e,i),a&&(t.svg.appendChild(g.svg),g.svg=null),g.il.Ue()}}else if(g instanceof lt){t.vi===null&&(t.vi=new lt);let v=t.vi;this.uD(g,v),v.HC=!0;for(let w=0;w<b;w++){let k=y[w];if(k.actualBounds&&k.measuredBounds&&k.naturalBounds){v.YI(k);let S=k.actualBounds;v.Ut(S.x,S.y,S.width,S.height),this.KI(v,u,S,k.measuredBounds,k.naturalBounds),v.nl=g.part,v.Zs=g.panel,v.Ge(e,i),v.Zs=null,v.nl=null,a&&(t.svg.appendChild(v.svg),v.svg=null)}}}}}i.mh=s,e.restore(),e.clearContextCache(!0)}GI(t,e,i,s,n,o,r){let a=t.il;a.Ue(),a.Gs(e.x+i.x,e.y+i.y),a.ks(s+t.angle,0,0),a.Gs(-n.width*r.x+r.offsetX+o/2,-n.height*r.y+r.offsetY+o/2),a.et(t.scale,t.scale),t.Md(!1),t.ya.set(t.il),t.Th=t.scale,t.Ma(!1)}KI(t,e,i,s,n){let o=t.il;o.Ue(),o.Gs(i.x+e.x,i.y+e.y),o.Gs(-s.x,-s.y),t.zp(o,n.x,n.y,n.width,n.height),t.Md(!1),t.ya.set(t.il),t.Th=t.scale,t.Ma(!1)}uD(t,e){e.HI(t)}}Lt.Tn("Graduated",new qn);var Us=(x=>(x[x.Uniform=6]="Uniform",x[x.UniformToFill=7]="UniformToFill",x))(Us||{});class G extends J{W;D;Qt;vd;$n;ll;fo;$o;qC;O;Fd;ot;Se;te;Rd;Aa;tn;constructor(t,e){if(super(),t===void 0)this.W=G.Position;else if(typeof t=="string"){let i=Lt.fs.get(t);i!==null?this.W=i:m.o("PanelLayout not loaded: "+t)}else t instanceof Lt?this.W=t:(this.W=G.Position,t&&(e=t));this.n|=4194304|(this.W===G.Grid?1048576:0),this.D=new q,this.Qt=Dt.em,this.vd=T.Default,this.$n=1,this.ll=null,this.fo="",this.$o=new I(NaN,NaN,NaN,NaN),this.qC=null,this.O=null,this.Fd=6,this.Se=null,this.ot=null,this.te=null,this.Rd=NaN,this.Aa=null,this.tn=null,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.W=this.W,t.Qt=this.Qt.C(),t.vd=this.vd.C(),t.$n=this.$n,t.fo=this.fo,t.$o.h(this.$o),this.O!==null&&(t.O=this.O.copy(t)),t.Fd=this.Fd,this.ot!==null&&(t.ot=this.ot.copy()),this.Se!==null&&(t.Se=this.Se.copy()),t.te=this.te,t.Rd=this.Rd,t.Aa=this.Aa}Ho(t){super.Ho(t),t.D=this.D;let e=t.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s];n.Zs=t}t.ll=null}copy(){let t=super.copy(),e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s].copy();t.qI(n)}return t}toString(){return"Panel("+this.type.name+")#"+V.xs(this)}get type(){return this.W}set type(t){let e=this.W;e!==t&&(this.W=t,this.Tf=this.W===G.Grid,this.f(),this.t("type",e,t))}get elements(){return this.D.iterator}get naturalBounds(){return this.Ke}get padding(){return this.Qt}set padding(t){typeof t=="number"?(t<0&&m.J(t,">= 0",G,"padding"),t=new Dt(t)):(t.left<0&&m.J(t.left,">= 0",G,"padding:value.left"),t.right<0&&m.J(t.right,">= 0",G,"padding:value.right"),t.top<0&&m.J(t.top,">= 0",G,"padding:value.top"),t.bottom<0&&m.J(t.bottom,">= 0",G,"padding:value.bottom"));let e=this.Qt;e.equals(t)||(t=t.C(),this.Qt=t,this.f(),this.t("padding",e,t))}get defaultAlignment(){return this.vd}set defaultAlignment(t){let e=this.vd;e.equals(t)||(t=t.C(),this.vd=t,this.f(),this.t("defaultAlignment",e,t))}get defaultStretch(){return this.$n}set defaultStretch(t){let e=this.$n;e!==t&&(this.$n=t,this.f(),this.t("defaultStretch",e,t))}get defaultSeparatorPadding(){return this.O!==null?this.O.P0:Dt.em}set defaultSeparatorPadding(t){typeof t=="number"&&(t=new Dt(t));let e=this.defaultSeparatorPadding;e.equals(t)||(t=t.C(),this.O===null&&(this.O=new ne),this.O.P0=t,this.f(),this.t("defaultSeparatorPadding",e,t))}get defaultRowSeparatorStroke(){return this.O!==null?this.O.S0:null}set defaultRowSeparatorStroke(t){let e=this.defaultRowSeparatorStroke;e!==t&&(t===null||typeof t=="string"||t instanceof R)&&(t instanceof R&&t.k(),this.O===null&&(this.O=new ne),this.O.S0=t,this.N(),this.t("defaultRowSeparatorStroke",e,t))}get defaultRowSeparatorStrokeWidth(){return this.O!==null?this.O.M0:1}set defaultRowSeparatorStrokeWidth(t){let e=this.defaultRowSeparatorStrokeWidth;e!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new ne),this.O.M0=t,this.f(),this.t("defaultRowSeparatorStrokeWidth",e,t))}get defaultRowSeparatorDashArray(){return this.O!==null?this.O.C0:null}set defaultRowSeparatorDashArray(t){let e=this.defaultRowSeparatorDashArray;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",G,"defaultRowSeparatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&m.o("defaultRowSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.O===null&&(this.O=new ne),this.O.C0=t,this.N(),this.t("defaultRowSeparatorDashArray",e,t)}}get defaultColumnSeparatorStroke(){return this.O!==null?this.O.N0:null}set defaultColumnSeparatorStroke(t){let e=this.defaultColumnSeparatorStroke;e!==t&&(t===null||typeof t=="string"||t instanceof R)&&(t instanceof R&&t.k(),this.O===null&&(this.O=new ne),this.O.N0=t,this.N(),this.t("defaultColumnSeparatorStroke",e,t))}get defaultColumnSeparatorStrokeWidth(){return this.O!==null?this.O.L0:1}set defaultColumnSeparatorStrokeWidth(t){let e=this.defaultColumnSeparatorStrokeWidth;e!==t&&isFinite(t)&&t>=0&&(this.O===null&&(this.O=new ne),this.O.L0=t,this.f(),this.t("defaultColumnSeparatorStrokeWidth",e,t))}get defaultColumnSeparatorDashArray(){return this.O!==null?this.O.A0:null}set defaultColumnSeparatorDashArray(t){let e=this.defaultColumnSeparatorDashArray;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",G,"defaultColumnSeparatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&m.o("defaultColumnSeparatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.O===null&&(this.O=new ne),this.O.A0=t,this.N(),this.t("defaultColumnSeparatorDashArray",e,t)}}get La(){return this.O!==null?this.O.La:null}set La(t){this.O===null&&(this.O=new ne),this.O.La=t}get viewboxStretch(){return this.Fd}set viewboxStretch(t){let e=this.Fd;e!==t&&(this.Fd=t,this.f(),this.t("viewboxStretch",e,t))}get gridCellSize(){return this.Se!==null?this.Se.Od:nt.OL}set gridCellSize(t){this.Se===null&&(this.Se=new ti);let e=this.Se.Od;if(!e.equals(t)){(!t.isReal()||t.width===0||t.height===0)&&m.o("Invalid Panel.gridCellSize: "+t),this.Se.Od=t.C();let i=this.diagram;i!==null&&this===i.grid&&i.cd(),this.N(),this.t("gridCellSize",e,t)}}get gridOrigin(){return this.Se!==null?this.Se.Id:P.gn}set gridOrigin(t){this.Se===null&&(this.Se=new ti);let e=this.Se.Id;if(!e.equals(t)){t.isReal()||m.o("Invalid Panel.gridOrigin: "+t),this.Se.Id=t.C();let i=this.diagram;i!==null&&this===i.grid&&i.cd(),this.N(),this.t("gridOrigin",e,t)}}get graduatedMin(){return this.ot!==null?this.ot.T0:0}set graduatedMin(t){let e=this.graduatedMin;if(e!==t&&(this.ot===null&&(this.ot=new Se),this.ot.T0=t,this.f(),this.t("graduatedMin",e,t),this.mf())){let i=this.part;i!==null&&this.Eh(i,"graduatedRange")}}get graduatedMax(){return this.ot!==null?this.ot.D0:100}set graduatedMax(t){let e=this.graduatedMax;if(e!==t&&(this.ot===null&&(this.ot=new Se),this.ot.D0=t,this.f(),this.t("graduatedMax",e,t),this.mf())){let i=this.part;i!==null&&this.Eh(i,"graduatedRange")}}get graduatedRange(){return this.graduatedMax-this.graduatedMin}get graduatedTickUnit(){return this.ot!==null?this.ot.v0:10}set graduatedTickUnit(t){let e=this.graduatedTickUnit;e!==t&&t>0&&(this.ot===null&&(this.ot=new Se),this.ot.v0=t,this.f(),this.t("graduatedTickUnit",e,t))}get graduatedTickBase(){return this.ot!==null?this.ot.F0:0}set graduatedTickBase(t){let e=this.graduatedTickBase;e!==t&&(this.ot===null&&(this.ot=new Se),this.ot.F0=t,this.f(),this.t("graduatedTickBase",e,t))}get vs(){return this.ot!==null?this.ot.vs:null}set vs(t){this.ot!==null?this.ot.vs=t:t!==null&&(this.ot=new Se,this.ot.vs=t)}get _i(){return this.ot!==null?this.ot._i:null}set _i(t){this.ot!==null?this.ot._i=t:t!==null&&(this.ot=new Se,this.ot._i=t)}get ds(){return this.ot!==null?this.ot.ds:null}set ds(t){this.ot!==null?this.ot.ds=t:t!==null&&(this.ot=new Se,this.ot.ds=t)}get vi(){return this.ot!==null?this.ot.vi:null}set vi(t){this.ot!==null?this.ot.vi=t:t!==null&&(this.ot=new Se,this.ot.vi=t)}Kp(t){super.Kp(t);let e=this.D.r,i=e.length;for(let s=0;s<i;s++)e[s].Kp(t)}Sa(t,e){if(this.W===G.Grid){t.commitTransform(),this.W.Ge(this,t,e);return}if(this.W===G.Graduated){t.commitTransform(),this.W.Ge(this,t,e);return}if(this.W===G.Table)if(t.commitTransform(),t instanceof ae){let r=t.currentElement;t.currentElement=t.newGroup2("gojs-ts"),this.jC(t,e),t.endGroup(),t.currentElement=r}else this.jC(t,e);let i=this.isClipping&&this.W===G.Spot;i&&t.save();let s=this.findMainElement(),n=this.D.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];i&&a===s&&(t.clipInsteadOfFill=!0),a.Ge(t,e),i&&a===s&&(t.clipInsteadOfFill=!1)}i&&(t.restore(),t.clearContextCache(!0))}jC(t,e){t.lineCap="butt";let i=this.rowCount>0?this.Ii:null,s=this.columnCount>0?this.Ei:null;i!==null&&this.q1(t,e,!0,i,!0),s!==null&&this.q1(t,e,!1,s,!0),i!==null&&this.dD(t,!0,i),s!==null&&this.dD(t,!1,s),i!==null&&this.q1(t,e,!0,i,!1),s!==null&&this.q1(t,e,!1,s,!1)}dD(t,e,i){let s=i.length,n=this.actualBounds,o=this.naturalBounds,r=!0;for(let a=0;a<s;a++){let h=i[a];if(h===void 0||h.actual===0)continue;if(r){r=!1;continue}if(e){if(h.position>o.height)continue}else if(h.position>o.width)continue;let l=h.separatorStrokeWidth;isNaN(l)&&(l=e?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let u=h.separatorStroke;if(u===null&&(u=e?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),l===0||u===null)continue;this.kn(t,u,!1,!1,o,n);let c=!1,d=h.separatorDashArray;d===null&&(d=e?this.defaultRowSeparatorDashArray:this.defaultColumnSeparatorDashArray),d!==null&&(c=!0,t.enableDash(d,0)),t.beginPath();let f=h.position+l;e?f>o.height&&(l-=f-o.height):f>o.width&&(l-=f-o.width);let p=h.position+l/2;t.lineWidth=l;let g=this.Qt;if(e){p+=g.top;let y=g.left,b=o.width-g.right;t.moveTo(y,p),t.lineTo(b,p)}else{p+=g.left;let y=g.top,b=o.height-g.bottom;t.moveTo(p,y),t.lineTo(p,b)}t.stroke(),t.endPath(),c&&t.disableDash()}}q1(t,e,i,s,n){let o=s.length,r=this.actualBounds,a=this.naturalBounds,h=this.gD(!0),l=this.gD(!1);for(let u=0;u<o;u++){let c=s[u];if(c===void 0||c.background===null||c.coversSeparators===n||c.actual===0)continue;let d=i?r.height:r.width;if(c.position>d)continue;let f=c.computeEffectiveSpacing(),p=c.separatorStrokeWidth;isNaN(p)&&(p=i?this.defaultRowSeparatorStrokeWidth:this.defaultColumnSeparatorStrokeWidth);let g=c.separatorStroke;g===null&&(g=i?this.defaultRowSeparatorStroke:this.defaultColumnSeparatorStroke),(g===null||c.index===(i?h:l))&&(p=0),f-=p;let y=c.position+p,b=f+c.actual;if(y+b>d&&(b=d-y),b<=0)continue;let v=this.Qt;this.kn(t,c.background,!0,!1,a,r),i?t.fillRect(v.left,y+v.top,r.width-(v.left+v.right),b):t.fillRect(y+v.left,v.top,b,r.height-(v.top+v.bottom))}}gD(t){let e=t?this.rowCount:this.columnCount;for(let i=0;i<e;i++){let s=t?this.Ii[i]:this.Ei[i];if(s!==void 0)return s.index}return 0}xf(){let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].xf();this.Zi(!0)}wf(t,e,i){let s=this.svg;if(s===null)return!1;if(this.type===G.Table){let r=s.getElementsByClassName("gojs-ts"),a=r.length!==0?r[0]:null;a!==null&&(a.innerHTML=""),t.currentElement=a,this.jC(t,e),t.currentElement=null}else{if(this.W===G.Grid||this.W===G.Graduated)return s.innerHTML="",s.remove(),!1;if(this.W===G.Spot&&this.isClipping)return s.innerHTML="",s.remove(),this.wa=null,this.xf(),!1}if(!super.wf(t,e,i))return!1;let n=this.D.r,o=n.length;for(let r=0;r<o;r++)n[r].Ge(t,e);return!0}Sd(t){return!0}qp(t,e,i,s){if(!this.isClipping){if(this._s()&&t.partClipRect!==null){let n=t.partClipRect,o=this.D.r,r=0,a=0;for(let h=0;h<o.length;h++){if(!o[h].isVisibleObject())continue;let l=o[h].actualBounds;r=h===0?l.x:Math.min(l.x,r),a=h===0?l.y:Math.min(l.y,a)}s.setAttributeNS(null,"clip-path",`path('M ${n.x-i.x-r},${n.y-i.y-a} l ${n.width} 0 l 0 ${n.height} l -${n.width} 0 z')`);return}super.qp(t,e,i,s)}}pf(t,e,i,s,n){let o=this.Cn(),r=this.v,a=1/(r.m11*r.m22-r.m12*r.m21),h=r.m22*a,l=-r.m12*a,u=-r.m21*a,c=r.m11*a,d=a*(r.m21*r.dy-r.m22*r.dx),f=a*(r.m12*r.dx-r.m11*r.dy);if(this.background!==null){let p=t*h+e*u+d,g=t*l+e*c+f,y=i*h+s*u+d,b=i*l+s*c+f;n.e(0,0);let v=this.naturalBounds,w=C.Al(0,0,v.width,v.height,p,g,y,b,n);return n.v(r),w}else{o||(h=1,l=0,u=0,c=1,d=0,f=0);let p=t*h+e*u+d,g=t*l+e*c+f,y=i*h+s*u+d,b=i*l+s*c+f;n.e(y,b);let v=(y-p)**2+(b-g)**2,w=!1,k=this.D.r,S=k.length,N=P.l(),D=null,L=1/0,M=null,A=this.isClipping&&this.W===G.Spot;A&&(M=P.l(),D=this.findMainElement(),w=D.pf(p,g,y,b,M),w&&(L=(p-M.x)**2+(g-M.y)**2));for(let F=0;F<S;F++){let O=k[F];if(!O.visible||O===D||!O.pf(p,g,y,b,N))continue;w=!0;let E=(p-N.x)**2+(g-N.y)**2;E<v&&(v=E,n.set(N))}return A&&(L>v&&n.set(M),P.i(M)),P.i(N),o&&n.v(r),w}}Wc(){let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].Wc();super.Wc()}f(t){if(this.Xo())return;super.f(t);let e=null;(this.W===G.Auto||this.W===G.Link)&&(e=this.findMainElement());let i=this.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];if((o===e||o.isPanelMain)&&o.f(!0),o.desiredSize.isReal()||!o.visible)continue;let r=o.Qs(!1);!(o instanceof ue)&&!(o instanceof G)&&!(o instanceof lt)&&r===0||o.f(!0)}}kf(){if(this.Xo())return;this.xi(!0),this.lo(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].kf()}yf(){if(this.I1()===!1){this.Md(!0),this.Ma(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].LC()}}LC(){this.Ma(!0);let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].LC()}kd(t,e,i,s){let n=this.$o;n.e(0,0,0,0);let o=this.desiredSize,r=this.minSize;i===void 0&&(i=r.width,s=r.height),i=Math.max(i,r.width),s=Math.max(s,r.height);let a=this.maxSize;isNaN(o.width)||(t=Math.min(o.width,a.width)),isNaN(o.height)||(e=Math.min(o.height,a.height)),t=Math.max(i,t),e=Math.max(s,e);let h=this.Qt;t=Math.max(t-h.left-h.right,0),e=Math.max(e-h.top-h.bottom,0);let l=this.D.r;this.W.measure(this,t,e,l,n,i,s);let u=n.width+h.left+h.right,c=n.height+h.top+h.bottom;isFinite(o.width)&&(u=o.width),isFinite(o.height)&&(c=o.height),u=Math.min(a.width,u),c=Math.min(a.height,c),u=Math.max(r.width,u),c=Math.max(r.height,c),u=Math.max(i,u),c=Math.max(s,c),n.Kn(u,c),this.naturalBounds.Kn(u,c),this.ro(0,0,u,c)}findMainElement(){if(this.ll===null){let t=this.D.r,e=t.length;if(e===0)return null;for(let i=0;i<e;i++){let s=t[i];if(s.isPanelMain===!0)return this.ll=s,s}this.ll=t[0]}return this.ll}Jo(){return this.part!==null?this.part.locationObject:null}get panelLayoutState(){return this.qC}set panelLayoutState(t){this.qC=t}ka(t,e,i,s){let n=this.D.r;if(this.actualBounds.e(t,e,i,s),!this.desiredSize.isReal()){let o=this.Qs(!0),r=this.measuredBounds,a=r.width,h=r.height,l=this.sl,u=l.left+l.right,c=l.top+l.bottom;switch(a===i&&h===s&&(o=0),o){case 0:(a>i||h>s)&&(this.f(),this.ht(a>i?i:a,h>s?s:h,0,0));break;case 2:this.f(!0),this.ht(i+u,s+c,0,0);break;case 5:this.f(!0),this.ht(i+u,h+c,0,0);break;case 4:this.f(!0),this.ht(a+u,s+c,0,0);break}}this.W.arrange(this,n,this.$o)}ba(t){let e=this.naturalBounds,i=this.Jo();if(I.contains(0,0,e.width,e.height,t.x,t.y)){let s=this.D.r,n=s.length,o=P.z(0,0);for(let r=n;r--;){let a=s[r];if(!(!a.visible&&a!==i)&&(o.set(t).Hi(a.v),a.containsPoint(o)))return P.i(o),!0}return P.i(o),this.Nt!==null}return!1}Bp(t){if(this.no===t)return this;let e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s].Bp(t);if(n!==null)return n}return null}walkVisualTreeFrom(t,e){if(e(this,t),t instanceof G){let i=t.D.r,s=i.length;for(let n=0;n<s;n++)this.walkVisualTreeFrom(i[n],e)}}Sn(t){this.mD(this,t)}mD(t,e){e(t);let i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];o instanceof G&&this.mD(o,e)}}jI(t){this.pD(this,t)}pD(t,e){if(e(t),t instanceof G){let i=t.D.r,s=i.length;for(let n=0;n<s;n++)this.pD(i[n],e)}}findInVisualTree(t){return this.yD(this,t)}yD(t,e){if(e(t))return t;if(t instanceof G){let i=t.D.r,s=i.length;for(let n=0;n<s;n++){let o=this.yD(i[n],e);if(o!==null)return o}}return null}findObject(t){if(this.name===t)return this;let e=this.D.r,i=e.length;this.Aa!==null&&(i=this.R0());for(let s=0;s<i;s++){let n=e[s];if(n instanceof G){let o=n.findObject(t);if(o!==null)return o}if(n.name===t)return n}return null}wD(){let t=this.D.r,e=t.length,i=0;for(let s=0;s<e;s++){let n=t[s];n instanceof G?i=Math.max(i,n.wD()):n instanceof it&&(i=Math.max(i,n.WI()))}return i}Cn(){return!(this.type===G.TableRow||this.type===G.TableColumn)}ol(){return this.type===G.TableRow||this.type===G.TableColumn}BA(t,e,i){if(this.pickable===!1||(e===void 0&&(e=null),i===void 0&&(i=null),this.as()))return null;let s=this.naturalBounds,n=1/this.getDocumentScale(),o=this.Cn(),r=o?t:P.z(t.x,t.y).Hi(this.v),a=this.diagram,h=10,l=5;if(a!==null&&(h=a.getInputOption("extraTouchArea"),l=h/2),I.contains(-(l*n),-(l*n),s.width+h*n,s.height+h*n,r.x,r.y)){if(!this.Tf){let c=this.D.r,d=c.length,f=P.l(),p=this.isClipping&&this.W===G.Spot,g=p?this.findMainElement():null;if(p&&g&&(g.Cn()?f.set(t).Hi(g.v):f.set(t),!g.containsPoint(f)))return P.i(f),o||P.i(r),null;let y=this.Jo();for(let b=d;b--;){let v=c[b];if(!v.visible&&v!==y||(v.Cn()?f.set(t).Hi(v.v):f.set(t),p&&v===g))continue;let w=null;if(v instanceof G?w=v.BA(f,e,i):v.pickable===!0&&v.containsPoint(f)&&(w=v),w!==null&&(e!==null&&(w=e(w)),w!==null&&(i===null||i(w))))return P.i(f),o||P.i(r),w}P.i(f)}if(this.background===null)return o||P.i(r),null;let u=I.contains(0,0,s.width,s.height,r.x,r.y)?this:null;return o||P.i(r),u}return o||P.i(r),null}zA(t,e,i,s){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let n=this.naturalBounds,o=this.Cn(),r=o?t:P.z(t.x,t.y).Hi(this.v),a=this.ol(),h=I.contains(0,0,n.width,n.height,r.x,r.y);if(a||h){if(!this.Tf){let l=this.D.r,u=l.length,c=P.l(),d=this.Jo();for(let f=u;f--;){let p=l[f];if(!p.visible&&p!==d)continue;p.Cn()?c.set(t).Hi(p.v):c.set(t);let g=p,y=p instanceof G?p:null;if(y!==null?y.zA(c,e,i,s):g.containsPoint(c)){if(g.pickable===!1)continue;e!==null&&(g=e(g)),g!==null&&(i===null||i(g))&&s.add(g)}}P.i(c)}return o||P.i(r),h&&this.background!==null}return o||P.i(r),!1}jm(t,e,i,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let r=o;if(r===void 0&&(r=Nt.l(),r.Ue()),r.bc(this.v),this.containedInRect(t,r))return this.WC(e,i,n),o===void 0&&Nt.i(r),!0;if(this.intersectsRect(t,r)){if(!this.Tf){let a=this.Jo(),h=this.D.r,l=h.length;for(let u=l;u--;){let c=h[u];if(!c.visible&&c!==a)continue;let d=c.actualBounds,f=this.naturalBounds;if(d.x>f.width||d.y>f.height||d.x+d.width<0||d.y+d.height<0)continue;let p=c,g=c instanceof G?c:null,y=Nt.l();y.set(r),(g!==null?g.jm(t,e,i,s,n,y):p.$T(t,s,y))&&(e!==null&&(p=e(p)),p!==null&&(i===null||i(p))&&n.add(p)),Nt.i(y)}}return o===void 0&&Nt.i(r),s}return o===void 0&&Nt.i(r),!1}WC(t,e,i){let s=this.D.r,n=s.length;for(let o=n;o--;){let r=s[o];if(!r.visible)continue;let a=r.actualBounds,h=this.naturalBounds;if(a.x>h.width||a.y>h.height||a.x+a.width<0||a.y+a.height<0)continue;r instanceof G&&r.WC(t,e,i);let l=r;t!==null&&(l=t(l)),l!==null&&(e===null||e(l))&&i.add(l)}}XA(t,e,i,s,n,o){if(this.pickable===!1)return!1;i===void 0&&(i=null),s===void 0&&(s=null);let r=this.naturalBounds,a=this.Cn(),h=a?t:P.z(t.x,t.y).Hi(this.v),l=a?e:P.z(e.x,e.y).Hi(this.v),u=h.distanceSquaredPoint(l),c=h.x>0&&h.x<r.width&&h.y>0&&h.y<r.height||P.distanceLineSegmentSquared(h.x,h.y,0,0,0,r.height)<=u||P.distanceLineSegmentSquared(h.x,h.y,0,r.height,r.width,r.height)<=u||P.distanceLineSegmentSquared(h.x,h.y,r.width,r.height,r.width,0)<=u||P.distanceLineSegmentSquared(h.x,h.y,r.width,0,0,0)<=u,d=h.distanceSquared(0,0)<=u&&h.distanceSquared(0,r.height)<=u&&h.distanceSquared(r.width,0)<=u&&h.distanceSquared(r.width,r.height)<=u;if(a||(P.i(h),P.i(l)),c){if(!this.Tf){let f=P.l(),p=P.l(),g=this.Jo(),y=this.D.r,b=y.length;for(let v=b;v--;){let w=y[v];if(!w.visible&&w!==g)continue;let k=w.actualBounds,S=this.naturalBounds;if(a&&(k.x>S.width||k.y>S.height||k.x+k.width<0||k.y+k.height<0))continue;if(w.Cn()){let L=w.v;f.set(t).Hi(L),p.set(e).Hi(L)}else f.set(t),p.set(e);let N=w,D=w instanceof G?w:null;(D!==null?D.XA(f,p,i,s,n,o):N.ZT(f,p,n))&&(i!==null&&(N=i(N)),N!==null&&(s===null||s(N))&&o.add(N))}P.i(f),P.i(p)}return n?c:d}return!1}XC(t){let e=null;if(t instanceof it){e=t.spot1,e===T.Default&&(e=null);let i=t.geometry;i!==null&&e===null&&(e=i.spot1)}return e===null&&(e=T.TopLeft),e}GC(t){let e=null;if(t instanceof it){e=t.spot2,e===T.Default&&(e=null);let i=t.geometry;i!==null&&e===null&&(e=i.spot2)}return e===null&&(e=T.BottomRight),e}add(...t){for(let e=0;e<t.length;e++)this.insertAt(this.D.count,t[e]);return this}elt(t){return this.D.elt(t)}insertAt(t,e){e instanceof pt&&m.o("Cannot add a Part to a Panel: "+e+"; use a Panel instead"),(this===e||this.isContainedBy(e))&&(this===e&&m.o("Cannot make a Panel contain itself: "+this.toString()),m.o("Cannot make a Panel indirectly contain itself: "+this.toString()+" already contains "+e.toString()));let i=e.panel;if(i!==null&&i!==this&&m.o("Cannot add a GraphObject that already belongs to another Panel to this Panel: "+e.toString()+", already contained by "+i.toString()+", cannot be shared by this Panel: "+this.toString()),this.W===G.Grid&&!(e instanceof it)&&m.o("Can only add Shapes to a Grid Panel, not: "+e),this.W===G.Graduated&&!(e instanceof it||e instanceof lt)&&m.o("Can only add Shapes or TextBlocks to a Graduated Panel, not: "+e),e.Uh(this),e.nl=null,this.itemArray!==null){let r=e.data;m.$(r)&&(this.tn===null&&(this.tn=new Mt),this.tn.set(r,e))}let s=this.D,n=-1;if(i===this){let r=-1,a=this.D.r,h=a.length;for(let l=0;l<h;l++)if(a[l]===e){r=l;break}if(r!==-1){if(r===t||r+1>=s.count&&t>=s.count)return;s.removeAt(r),n=r}else m.o("element "+e.toString()+" has panel "+i.toString()+" but is not contained by it.")}(t<0||t>s.count)&&(t=s.count),s.insertAt(t,e),(t===0||e.isPanelMain)&&(this.ll=null),this.Xo()||this.f(),e.f(!1),e.portId!==null?this.Ln=!0:e instanceof G&&e.Ln===!0&&(this.Ln=!0),this.ds=null,this.isEnabledObject()||this.j1(e,!1);let o=this.part;if(o!==null){o._p(),o.Df(),this.Ln&&o instanceof $&&(o.Ln=!0),o.Ln&&o instanceof $&&(o.ci=null);let r=this.diagram;if(r!==null&&r.undoManager.isUndoingRedoing)return;n!==-1&&o.raiseChangedEvent(4,"elements",this,e,null,n,null),o.raiseChangedEvent(3,"elements",this,null,e,null,t)}}get Ln(){return(this.n&8388608)!==0}set Ln(t){(this.n&8388608)!==0!==t&&(this.n=this.n^8388608)}SC(){return(this.n&16777216)!==0}JC(t){t?this.n|=16777216:this.n&=-16777217}qI(t){t.Uh(this),t.nl=null;let e=this.D,i=e.count;e.insertAt(i,t);let s=this.part;if(s!==null){s._p(),t.portId!==null&&s instanceof $&&(s.Ln=!0);let n=this.diagram;if(n!==null&&n.undoManager.isUndoingRedoing)return;s.raiseChangedEvent(3,"elements",this,null,t,null,i)}}uI(t){let e=this.D.r,i=e.length,s=-1;for(let n=0;n<i;n++)if(e[n]===t){s=n;break}return s}remove(t){let e=this.D.r,i=e.length,s=-1;for(let n=0;n<i;n++)if(e[n]===t){s=n;break}s!==-1&&this.ri(s,!0)}removeAt(t){t>=0&&this.ri(t,!0)}ri(t,e){let i=this.D,s=i.elt(t);if(s.nl=null,s.Uh(null),this.tn!==null){let o=s.data;m.$(o)&&this.tn.delete(o)}i.removeAt(t),this.xi(!1),this.f(),this.ll===s&&(this.ll=null),this.ds=null;let n=this.part;if(n!==null){n._p(),n.Df(),n.invalidateAdornments(),n instanceof $&&(s instanceof G?s.walkVisualTreeFrom(s,(r,a)=>n.vC(a,e)):n.vC(s,e));let o=this.diagram;if(o!==null&&o.undoManager.isUndoingRedoing)return;n.raiseChangedEvent(4,"elements",this,s,null,t,null)}}get Ii(){return this.O===null&&(this.O=new ne),this.O.Ii}get rowCount(){return this.O===null?0:this.Ii.length}getRowDefinition(t){t<0&&m.J(t,">= 0",G,"getRowDefinition:idx"),t=Math.round(t);let e=this.Ii;if(e[t]===void 0){let i=new Kt;i.Uh(this),i.isRow=!0,i.index=t,e[t]=i,this.raiseChangedEvent(3,"rowdefs",this,null,i,null,t)}return e[t]}removeRowDefinition(t){if(t<0&&m.J(t,">= 0",G,"removeRowDefinition:idx"),this.rowCount===0)return;t=Math.round(t);let e=this.Ii,i=e[t];if(i){e[t]=void 0;let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--;this.raiseChangedEvent(4,"rowdefs",this,i,null,t,null),this.f()}}xT(t,e){let i=this.Ii;if(!(t<0)){if(i[t]=e instanceof Kt?e:void 0,!e){let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--}this.f()}}get Ei(){return this.O===null&&(this.O=new ne),this.O.Ei}get columnCount(){return this.O===null?0:this.Ei.length}getColumnDefinition(t){t<0&&m.J(t,">= 0",G,"getColumnDefinition:idx"),t=Math.round(t);let e=this.Ei;if(e[t]===void 0){let i=new Kt;i.Uh(this),i.isRow=!1,i.index=t,e[t]=i,this.raiseChangedEvent(3,"coldefs",this,null,i,null,t)}return e[t]}removeColumnDefinition(t){if(t<0&&m.J(t,">= 0",G,"removeColumnDefinition:idx"),this.columnCount===0)return;t=Math.round(t);let e=this.Ei,i=e[t];if(i){e[t]=void 0;let s=e.length-1;for(;s>=0&&e[s--]===void 0;)e.length--;this.raiseChangedEvent(4,"coldefs",this,i,null,t,null),this.f()}}bT(t,e){let i=this.Ei;if(!(t<0)){if(i[t]=e instanceof Kt?e:void 0,!e){let s=i.length-1;for(;s>=0&&i[s--]===void 0;)i.length--}this.f()}}addRowColumnDefinition(t){let e=null;return t.isRow?e=this.getRowDefinition(t.index):t.isRow||(e=this.getColumnDefinition(t.index)),e&&e.U1(t),this}addRowDefinition(t,e){let i=this.getRowDefinition(t);return i&&i.U1(new Kt(e)),this}addColumnDefinition(t,e){let i=this.getColumnDefinition(t);return i&&i.U1(new Kt(e)),this}get rowSizing(){return this.O!==null?this.O.O0:3}set rowSizing(t){let e=this.rowSizing;e!==t&&(this.O===null&&(this.O=new ne),this.O.O0=t,this.f(),this.t("rowSizing",e,t))}get columnSizing(){return this.O!==null?this.O.I0:3}set columnSizing(t){let e=this.columnSizing;e!==t&&(this.O===null&&(this.O=new ne),this.O.I0=t,this.f(),this.t("columnSizing",e,t))}get topIndex(){return this.O!==null?this.O.E0:0}set topIndex(t){let e=this.topIndex;e!==t&&((!isFinite(t)||t<0)&&m.o("Panel.topIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new ne),this.O.E0=t,this.f(),this.t("topIndex",e,t))}get leftIndex(){return this.O!==null?this.O.U0:0}set leftIndex(t){let e=this.leftIndex;e!==t&&((!isFinite(t)||t<0)&&m.o("Panel.leftIndex must be greater than zero and a real number, not: "+t),this.O===null&&(this.O=new ne),this.O.U0=t,this.f(),this.t("leftIndex",e,t))}findRowForLocalY(t){if(t<0||this.type!==G.Table||this.rowCount===0)return-1;let e=0,i=this.Ii,s=i.length,n=this.topIndex;for(;n<s;n++){let o=i[n];if(o!==void 0&&(e+=o.total,t<e))return n}return n}findColumnForLocalX(t){if(t<0||this.type!==G.Table||this.columnCount===0)return-1;let e=0,i=this.Ei,s=i.length,n=this.leftIndex;for(;n<s;n++){let o=i[n];if(o!==void 0&&(e+=o.total,t<e))return n}return n}graduatedPointForValue(t,e){if(e===void 0&&(e=new P(NaN,NaN)),this.type!==G.Graduated)return e.e(NaN,NaN),e;t=Math.min(Math.max(t,this.graduatedMin),this.graduatedMax);let i=this.findMainElement();return i.geometry.getPointAlongPath((t-this.graduatedMin)/this.graduatedRange,e),i.v.gt(e)}graduatedValueForPoint(t){if(this.type!==G.Graduated)return NaN;let e=this.findMainElement();return e.v.Ni(t),e.geometry.getFractionForPoint(t)*this.graduatedRange+this.graduatedMin}get data(){return this.te}set data(t){let e=this.te;if(e!==t){let i=this instanceof pt&&!(this instanceof vt);i&&m.s(t,"object",G,"data"),this.It(),this.te=t;let s=this.diagram;if(s!==null)if(i){s.partManager.JI(this,e,t);let n=this.adornments;for(;n.next();){let o=n.value,r=o.adornedObject;if(r!==null){let a=r.findBindingPanel();a!==null&&(o.data=a.data)}}}else{let n=this.panel;n!==null&&n.tn!==null&&(e!==null&&n.tn.delete(e),t!==null&&n.tn.set(t,this))}if(this.t("data",e,t),s!==null&&s.undoManager.isUndoingRedoing)return;t!==null&&this.updateTargetBindings()}}get itemIndex(){return this.Rd}set itemIndex(t){let e=this.Rd;e!==t&&(this.Rd=t,this.t("itemIndex",e,t))}get Ds(){return this.w!==null?this.w.Ds:null}set Ds(t){this.Fe!==t&&(this.w===null&&(this.w=new Ke),this.w.Ds=t)}FC(){return this.Ds!==null}oD(){let t=this.Ds;return t!==null&&t.u}freezeBindings(){return this.It()}It(){let t=this.Ds;if(t===null)this.data!==null&&m.o("Template cannot have .data be non-null: "+this),this.Ds=t=new q;else if(t.u)return this;let e=new q;this.JC(!1),this.walkVisualTreeFrom(this,(n,o)=>{o.xa();let r=o.Fe;if(r!==null){o.AC(!1);let a=r.iterator;for(;a.next();){let h=a.value;h.mode===2&&o.AC(!0);let l=h.sourceName;if(h.isToObject){l==="/"&&n.JC(!0);let u=h.JT(n,o);u!==null&&(e.add(u),u.oo===null&&(u.oo=new q),u.oo.add(h))}t.add(h)}}if(o instanceof G&&o.type===G.Table){if(o.rowCount>0){let a=o.Ii,h=a.length;for(let l=0;l<h;l++){let u=a[l];if(u!==void 0&&u.Fs!==null){let c=u.Fs.iterator;for(;c.next();){let d=c.value;d.Ti=u,d.Ed=2,d.vf=u.index,t.add(d)}}}}if(o.columnCount>0){let a=o.Ei,h=a.length;for(let l=0;l<h;l++){let u=a[l];if(u!==void 0&&u.Fs!==null){let c=u.Fs.iterator;for(;c.next();){let d=c.value;d.Ti=u,d.Ed=1,d.vf=u.index,t.add(d)}}}}}});let i=e.iterator;for(;i.next();){let n=i.value;if(n.oo!==null){n.AC(!0);let o=n.oo.iterator;for(;o.next();){let r=o.value;n.Fe===null&&(n.Fe=new q),n.Fe.add(r)}}n.oo=null}let s=t.iterator;for(;s.next();){let n=s.value,o=n.Ti;if(o!==null){n.Ti=null;let r=n.targetProperty,a=r.indexOf(".");if(a>0&&o instanceof G){let h=r.substring(0,a),l=r.substring(a+1),u=o.findObject(h);u!==null?(o=u,n.targetProperty=l):(m.ne('Warning: unable to find GraphObject named "'+h+'" for Binding: '+n.toString()),o=null)}if(o instanceof Kt){let h=V.xs(o.panel);n.targetId=h===void 0?-1:h,o.panel.no=n.targetId}else if(o instanceof J){let h=V.xs(o);n.targetId=h===void 0?-1:h,o.no=n.targetId}else m.o("Unknown type of binding target: "+o);n.check(o)}}return t.k(),this instanceof pt&&this.Di()&&this.ensureBounds(),this}static zU=!1;copyTemplate(t){t===void 0&&(t=!1);let e=this.copy();return e.jI(i=>{i instanceof G&&(i.Ds=null,i.te=null);let s=i.Fe;s!==null&&(i.Fe=null,s.each(o=>i.bind(o.copy())));let n=i.Ts;n!==null&&(i.Ts=null,n.each(o=>i.trigger(o.value.copy())))}),t&&e.It(),e}updateTargetBindings(t){let e=this.Ds;if(e===null)return;t===void 0&&(t="");let i=this.diagram?.model,s=e.iterator;for(;s.next();){let n=s.value,o=this.$C(n,t);if(o===null)continue;let{data:r,elt:a}=o;n.isToTheme&&this.diagram===null||a!==void 0&&n.updateTarget(a,r,void 0,i)}}$I(t){if(t===""){this.updateTargetBindings(t);return}let e=this.Ds;if(e===null)return;let i=this.diagram?.model,s=e.iterator;for(;s.next();){let n=s.value;if(n.isToData&&n.sourceProperty!=="")continue;let o=this.$C(n,"");if(o===null)continue;let{data:r,elt:a}=o;a!==void 0&&n.updateTarget(a,r,void 0,i)}}Go(){if(this.diagram!==null)if(this.FC()){let t=this.diagram.model,e=this.Ds.iterator;for(;e.next();){let i=e.value;if(!i.isToTheme)continue;let s=this.$C(i);if(s===null)continue;let{data:n,elt:o}=s;o!==void 0&&i.updateTarget(o,n,void 0,t)}}else{let t=this.D.r,e=t.length;for(let i=0;i<e;i++)t[i].Go()}}$C(t,e=""){let i=t.sourceProperty;if(e!==""&&i!==""&&i!==e)return null;let s=t.targetProperty;if(t.converter===null&&s==="")return null;let n=this.data,o=t.sourceName;if(t.isToObject){if(n=this.WT(o),n===null)return null}else if(t.isToModel){let l=this.diagram;if(l===null)return null;n=l.model.modelData}let r=this,a=t.targetId;if(a!==-1){if(r=this.Bp(a),r===null)return null}else t.Ti!==null&&(r=t.Ti);o==="/"?n=r.part:o==="."?n=r:o===".."&&(n=r.panel);let h=t.Ed;if(h!==0){if(!(r instanceof G))return null;h===1?r=r.getColumnDefinition(t.vf):h===2&&(r=r.getRowDefinition(t.vf))}return{data:n,elt:r}}get itemArray(){return this.Aa}set itemArray(t){let e=this.Aa;if(e!==t||t!==null&&this.ZI(t)){let i=this.diagram;if(e!==t&&(i!==null&&e!==null&&i.partManager.C2(this,i),this.Aa=t,i!==null&&t!==null&&i.partManager.M2(this,i)),this.t("itemArray",e,t),i!==null&&i.undoManager.isUndoingRedoing)return;this.xD(e,t)}}findItemPanelForData(t){return t==null||this.tn===null?null:(m.wc(t,G,"findItemPanelForData"),this.tn.get(t))}ZI(t){let e=this.D.r,i=e.length,s=t.length,n=0,o=null;for(;n<i&&(o=e[n],!(o instanceof G)||o.data===null);)n++,o=e[n];if(i-n!==s)return!0;if(o===null)return s>0;let r=0;for(;n<i&&r<s;){if(o=e[n],!(o instanceof G)||o.data!==t[r])return!0;n++,r++}return!1}R0(){if(this.type===G.Spot||this.type===G.Auto)return Math.min(this.D.length,1);if(this.type===G.Link){let t=this.D,e=t.length,i=0;for(;i<e;i++){let s=t.elt(i);if(!(s instanceof it)||!s.isPanelMain)return i}return i}if(this.type===G.Table&&this.D.length>0){let t=this.D.elt(0);if(t.isPanelMain&&t instanceof G&&t.ol())return 1}return 0}rebuildItemElements(){let t=this.R0();for(;this.D.length>t;)this.ri(this.D.length-1,!1);this.xD(null,this.itemArray)}xD(t,e){let i=this.R0(),s=e;if(s===null||s.length===0){for(;this.D.length>i;)this.ri(this.D.length-1,!1);return}if(this.D.length<=i){let n=s.length;for(let o=0;o<n;o++)this.W1(s[o],o,!0)}else{let n=i;for(let r=0;r<s.length;r++,n++){let a=s[r],h=n<this.D.length?this.D.elt(n):null;if(h instanceof G){if(h.data!==a){let l=this.ZC(h.data,r),u=this.ZC(a,r),c=u!==l;if(!c){let d=this.QC(h.data,r,l);c=this.QC(a,r,u)!==d}c?(this.ri(n,!1),this.W1(a,r,!1)):h.data=a}}else this.W1(a,r,!1)}for(;n<this.D.length;)this.ri(n,!1);this.ll=null,this._C(i,0),this.Xo()||this.f(),this.ds=null,this.isEnabledObject()||this.j1(this,!1);let o=this.part;o!==null&&(o._p(),o.Df(),this.Ln&&o instanceof $&&(o.Ln=!0),o.Ln&&o instanceof $&&(o.ci=null))}}W1(t,e,i){if(t==null||e<0)return;let s=this.ZC(t,e),n=this.QC(t,e,s);if(n!==null){n.It();let o=n.copy();if(o.SC()){let a=this.findBindingPanel();a!==null&&a.JC(!0)}m.$(t)&&(this.tn===null&&(this.tn=new Mt),this.tn.set(t,o));let r=e+this.R0();this.insertAt(r,o),i&&(o.te=t,this._C(r,e),o.te=null),o.data=t}}QI(t){if(t<0)return;let e=t+this.R0();this.ri(e,!0),this._C(e,t)}_C(t,e){let i=this.D,s=t,n=e;for(;s<i.length;){let o=i.elt(s);o instanceof G&&o._I(s,n),s++,n++}}_I(t,e){this.type===G.TableRow?this.row=t:this.type===G.TableColumn&&(this.column=t),this.itemIndex=e}get itemTemplate(){let t=this.itemTemplateMap;if(t!==null){let e=t.get("");if(e)return e}return G.bD()}set itemTemplate(t){let e=this.itemTemplate;if(e!==t){(t instanceof pt||t.isPanelMain)&&m.o("Panel.itemTemplate must not be a Part or be Panel.isPanelMain: "+t),this.itemTemplateMap===null&&(this.itemTemplateMap=new Mt),this.itemTemplateMap.set("",t),this.t("itemTemplate",e,t);let i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.rebuildItemElements()}}get itemTemplateMap(){return this.w!==null?this.w.m0:null}set itemTemplateMap(t){let e=this.itemTemplateMap;if(e!==t){let i=t.iterator;for(;i.next();){let n=i.value}this.Yt().m0=t,this.t("itemTemplateMap",e,t);let s=this.diagram;if(s!==null&&s.undoManager.isUndoingRedoing)return;this.rebuildItemElements()}}get itemCategoryProperty(){return this.w!==null?this.w.p0:"category"}set itemCategoryProperty(t){let e=this.itemCategoryProperty;e!==t&&(typeof t!="string"&&!m.it(t)&&m.si(t,"string or function",G,"itemCategoryProperty"),this.Yt().p0=t,this.t("itemCategoryProperty",e,t))}ZC(t,e){if(t===null)return"";let i=this.itemCategoryProperty,s="";if(m.it(i))s=i(t);else if(typeof i=="string"&&m.$(t)){if(i==="")return"";let n=this.diagram,o=n!==null?n.model:null;o?s=o.Lt(t,i):s=dt.Lt(t,i)}else return"";if(s===void 0)return"";if(typeof s=="string")return s;m.o("Panel.getCategoryForItemData found a non-string category for "+t+": "+s)}static kD=!1;static tN;static bD(){return G.tN||(G.tN=new G().add(new lt().bind("text","",m.toString).theme("stroke","text"))),G.tN}QC(t,e,i){let s=null,n=this.itemTemplateMap;return n!==null&&(s=n.get(i),s===null&&(s=n.get(""))),s===null&&(G.kD||(G.kD=!0,m.ne('No item template Panel found for category "'+i+'" on '+this),m.ne(" Using default item template.")),s=G.bD()),s}get Tf(){return(this.n&1048576)!==0}set Tf(t){let e=(this.n&1048576)!==0;e!==t&&(m.s(t,"boolean",G,"isAtomic"),this.n=this.n^1048576,this.t("isAtomic",e,t))}get isClipping(){return(this.n&2097152)!==0}set isClipping(t){let e=(this.n&2097152)!==0;e!==t&&(this.xf(),this.n=this.n^2097152,this instanceof ht&&(this.he=null),this.f(),this.t("isClipping",e,t))}get isOpposite(){return(this.n&33554432)!==0}set isOpposite(t){let e=(this.n&33554432)!==0;e!==t&&(this.n=this.n^33554432,this.f(),this.t("isOpposite",e,t))}get isEnabled(){return(this.n&4194304)!==0}set isEnabled(t){let e=(this.n&4194304)!==0;if(e!==t){let i=this.panel===null||this.panel.isEnabledObject();this.n=this.n^4194304,this.t("isEnabled",e,t);let s=this.diagram;if(s!==null&&s.undoManager.isUndoingRedoing)return;i&&this.j1(this,t)}}j1(t,e){let i=t.enabledChanged;if(i!==null&&i(t,e),t instanceof G){let s=t.D.r,n=s.length;for(let o=0;o<n;o++){let r=s[o];e&&r instanceof G&&!r.isEnabled||this.j1(r,e)}}}get alignmentFocusName(){return this.fo}set alignmentFocusName(t){let e=this.fo;e!==t&&(this.fo=t,this.f(),this.t("alignmentFocusName",e,t))}static definePanelLayout(t,e){Lt.Tn(t,e)}static isLayoutDefined(t){return Lt.fs.has(t)}static Position=Lt.fs.get("Position");static Horizontal=Lt.fs.get("Horizontal");static Vertical=Lt.fs.get("Vertical");static Spot=Lt.fs.get("Spot");static Auto=Lt.fs.get("Auto");static Table=Lt.fs.get("Table");static Viewbox=Lt.fs.get("Viewbox");static TableRow=Lt.fs.get("TableRow");static TableColumn=Lt.fs.get("TableColumn");static Link=Lt.fs.get("Link");static Grid=Lt.fs.get("Grid");static Graduated=Lt.fs.get("Graduated")}G.definePanelLayout=G.definePanelLayout;class Se{T0;D0;v0;F0;vs;_i;ds;vi;constructor(){this.T0=0,this.D0=100,this.v0=10,this.F0=0,this.vs=null,this._i=null,this.ds=null,this.vi=null}copy(){let t=new Se;return t.T0=this.T0,t.D0=this.D0,t.v0=this.v0,t.F0=this.F0,t.vs=this.vs,t._i=this._i,t.ds=this.ds,t.vi=this.vi,t}}class ti{Od;Id;hf;k0;constructor(){this.Od=nt.OL,this.Id=P.gn,this.hf=nt.jw,this.k0=[]}copy(){let t=new ti;return t.Od=this.Od.copy(),t.Id=this.Id.copy(),t.hf=this.hf.copy(),t.k0=this.k0,t}}class ne{Ii;Ei;O0;I0;E0;U0;P0;M0;S0;C0;L0;N0;A0;La;constructor(){this.Ii=[],this.Ei=[],this.O0=3,this.I0=3,this.E0=0,this.U0=0,this.P0=Dt.em,this.M0=1,this.S0=null,this.C0=null,this.L0=1,this.N0=null,this.A0=null,this.La=null}copy(t){let e=new ne,i=this.Ii,s=i.length,n=e.Ii;for(let h=0;h<s;h++){let l=i[h];if(l===void 0)continue;let u=l.copy();u.Uh(t),n[h]=u}let o=this.Ei,r=o.length,a=e.Ei;for(let h=0;h<r;h++){let l=o[h];if(l===void 0)continue;let u=l.copy();u.Uh(t),a[h]=u}return e.O0=this.O0,e.I0=this.I0,e.E0=this.E0,e.U0=this.U0,e.P0=this.P0.C(),e.M0=this.M0,e.S0=this.S0,e.C0=this.C0,e.L0=this.L0,e.N0=this.N0,e.A0=this.A0,e.La=this.La,e}}var zi=(x=>(x[x.Default=1]="Default",x[x.None=2]="None",x[x.ProportionalExtra=3]="ProportionalExtra",x))(zi||{});class Kt{Zs;V0;Tt;Xh;Gh;de;ct;Ud;ao;al;Vd;Bd;Yh;Nt;zd;Fs;q;ye;ki;constructor(t){V.Je(this),this.Zs=null,this.V0=!0,this.Tt=0,this.ki=NaN,this.Xh=0,this.Gh=1/0,this.de=T.Default,this.q=0,this.ye=0,this.ct=0,this.Fs=null,this.Ud=1,this.ao=1,this.al=null,this.Vd=null,this.Bd=NaN,this.Yh=null,this.Nt=null,this.zd=!1,t&&(Object.assign(this,t),t.column!==void 0?(this.isRow=!1,this.index=t.column):t.row!==void 0&&(this.isRow=!0,this.index=t.row))}copy(){let t=new Kt;return t.V0=this.V0,t.Tt=this.Tt,t.ki=this.ki,t.Xh=this.Xh,t.Gh=this.Gh,t.de=this.de,t.q=this.q,t.ye=this.ye,t.ct=this.ct,t.ao=this.ao,t.Ud=this.Ud,this.al===null?t.al=null:t.al=this.al.C(),t.Vd=this.Vd,t.Bd=this.Bd,t.Yh=null,this.Yh!==null&&(t.separatorDashArray=this.Yh.slice()),t.Nt=this.Nt,t.zd=this.zd,t.Fs=this.Fs,t}U1(t){t.isRow?t.height!==void 0&&(this.height=t.height):t.width!==void 0&&(this.width=t.width),t.minimum!==void 0&&(this.minimum=t.minimum),t.maximum!==void 0&&(this.maximum=t.maximum),t.alignment!==void 0&&(this.alignment=t.alignment),t.stretch!==void 0&&(this.stretch=t.stretch),t.sizing!==void 0&&(this.sizing=t.sizing),t.separatorPadding!==void 0&&(this.separatorPadding=t.separatorPadding),t.separatorStroke!==void 0&&(this.separatorStroke=t.separatorStroke),t.separatorStrokeWidth!==void 0&&(this.separatorStrokeWidth=t.separatorStrokeWidth),t.separatorDashArray!==void 0&&(this.Yh=t.separatorDashArray),t.background!==void 0&&(this.background=t.background),t.coversSeparators!==void 0&&(this.coversSeparators=t.coversSeparators),t.Fs!==void 0&&(this.Fs=t.Fs)}fe(t){t in zi?this.sizing=t:m.ur(this,t)}toString(){return"RowColumnDefinition "+(this.isRow?"(Row ":"(Column ")+this.index+") #"+V.xs(this)}static Default=1;static None=2;static ProportionalExtra=3;Uh(t){this.Zs=t}computeEffectiveSpacingTop(t){let e=0,i=this.Zs;if(this.index!==t){let n=this.separatorStroke;n===null&&i!==null&&(n=this.isRow?i.defaultRowSeparatorStroke:i.defaultColumnSeparatorStroke),n!==null&&(e=this.separatorStrokeWidth,isNaN(e)&&(i!==null?e=this.isRow?i.defaultRowSeparatorStrokeWidth:i.defaultColumnSeparatorStrokeWidth:e=0))}let s=this.al;if(s===null)if(i!==null)s=i.defaultSeparatorPadding;else return e;return e+(this.isRow?s.top:s.left)}computeEffectiveSpacing(){let t=0,e=this.Zs,i=0,s=this.isRow;if(e!==null&&e.type===G.Table){let o=s?e.Ii.length:e.Ei.length;for(let r=0;r<o;r++){let a=s?e.Ii[r]:e.Ei[r];if(a!==void 0&&a.q!==0){i=a.index;break}}}if(this.index!==i){let o=this.separatorStroke;o===null&&e!==null&&(o=s?e.defaultRowSeparatorStroke:e.defaultColumnSeparatorStroke),o!==null&&(t=this.separatorStrokeWidth,isNaN(t)&&(e!==null?t=s?e.defaultRowSeparatorStrokeWidth:e.defaultColumnSeparatorStrokeWidth:t=0))}let n=this.al;if(n===null)if(e!==null)n=e.defaultSeparatorPadding;else return t;return t+(this.isRow?n.top+n.bottom:n.left+n.right)}t(t,e,i,s,n){let o=this.Zs;if(o!==null&&(o.raiseChangedEvent(2,t,this,e,i,s,n),this.Fs!==null)){let r=o.diagram;if(r!==null&&!r.wi){let a=o.findBindingPanel();if(a!==null){let h=a.data;if(h!==null){let l=this.Fs.iterator;for(;l.next();)l.value.updateSource(this,h,t,a)}}}}}get panel(){return this.Zs}get isRow(){return this.V0}set isRow(t){this.V0=t}get index(){return this.Tt}set index(t){this.Tt=t}get height(){return this.ki}set height(t){let e=this.ki;e!==t&&(t<0&&m.J(t,">= 0",Kt,"height"),this.ki=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("height",e,t))}get width(){return this.ki}set width(t){let e=this.ki;e!==t&&(t<0&&m.J(t,">= 0",Kt,"width"),this.ki=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("width",e,t))}get minimum(){return this.Xh}set minimum(t){let e=this.Xh;e!==t&&((t<0||!isFinite(t))&&m.J(t,">= 0",Kt,"minimum"),this.Xh=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("minimum",e,t))}get maximum(){return this.Gh}set maximum(t){let e=this.Gh;e!==t&&(t<0&&m.J(t,">= 0",Kt,"maximum"),this.Gh=t,this.actual=this.q,this.panel!==null&&this.panel.f(),this.t("maximum",e,t))}get alignment(){return this.de}set alignment(t){let e=this.de;e.equals(t)||(this.de=t.C(),this.panel!==null&&this.panel.f(),this.t("alignment",e,t))}get stretch(){return this.ao}set stretch(t){let e=this.ao;e!==t&&(this.ao=t,this.panel!==null&&this.panel.f(),this.t("stretch",e,t))}get separatorPadding(){return this.al}set separatorPadding(t){typeof t=="number"&&(t=new Dt(t));let e=this.al;(t===null||e===null||!e.equals(t))&&(t!==null&&(t=t.C()),this.al=t,this.panel!==null&&this.panel.f(),this.t("separatorPadding",e,t))}get separatorStroke(){return this.Vd}set separatorStroke(t){let e=this.Vd;e!==t&&(t!==null&&R.Cd(t,"RowColumnDefinition.separatorStroke"),t instanceof R&&t.k(),this.Vd=t,this.panel!==null&&this.panel.f(),this.t("separatorStroke",e,t))}get separatorStrokeWidth(){return this.Bd}set separatorStrokeWidth(t){let e=this.Bd;e!==t&&(this.Bd=t,this.panel!==null&&this.panel.f(),this.t("separatorStrokeWidth",e,t))}get separatorDashArray(){return this.Yh}set separatorDashArray(t){let e=this.Yh;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",Kt,"separatorDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(typeof o!="number"||!(o>=0)||!isFinite(o))&&m.o("separatorDashArray value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.Yh=t,this.panel!==null&&this.panel.N(),this.t("separatorDashArray",e,t)}}get background(){return this.Nt}set background(t){let e=this.Nt;e!==t&&(t!==null&&R.Cd(t,"RowColumnDefinition.background"),t instanceof R&&t.k(),this.Nt=t,this.panel!==null&&this.panel.N(),this.t("background",e,t))}get coversSeparators(){return this.zd}set coversSeparators(t){let e=this.zd;e!==t&&(m.s(t,"boolean",Kt,"coversSeparators"),this.zd=t,this.panel!==null&&this.panel.N(),this.t("coversSeparators",e,t))}get sizing(){return this.Ud}set sizing(t){let e=this.Ud;e!==t&&(this.Ud=t,this.panel!==null&&this.panel.f(),this.t("sizing",e,t))}Y1(){if(this.sizing===1){let t=this.Zs;return t===null?2:this.isRow?t.rowSizing:t.columnSizing}return this.sizing}get actual(){return this.q}set actual(t){isNaN(this.ki)?this.q=Math.max(Math.min(this.Gh,t),this.Xh):this.q=Math.max(Math.min(this.Gh,this.ki),this.Xh)}get measured(){return this.ye}set measured(t){this.ye=t}get total(){return this.q+this.computeEffectiveSpacing()}get position(){return this.ct}set position(t){this.ct=t}bind(t,e,i,s){return this.Sf(t,e,i,s),this}bindTwoWay(t,e,i,s){let n=this.Sf(t,e,i,s);return s===void 0&&n.makeTwoWay(),this}theme(t,e,i,s,n){return this.Ca(t,e,i,s,n),this}themeData(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofData(),this}themeObject(t,e,i,s,n,o){return this.Ca(t,e,i,s,n).ofObject(o),this}themeModel(t,e,i,s,n){return this.Ca(t,e,i,s,n).ofModel(),this}Sf(t,e,i,s){let n;return typeof t=="string"?n=new ie(t,e,i,s):n=t,this.g0(n),n}Ca(t,e,i,s,n){let o;return typeof t=="string"?o=new ii(t,e,i,s,n):o=t,this.g0(o),o}g0(t){t.Ti=this;let e=this.panel;if(e!==null){let i=e.findBindingPanel();i!==null&&i.oD()&&m.o("Cannot add a Binding to a RowColumnDefinition that is already frozen: "+t+" on "+e)}this.Fs===null&&(this.Fs=new q),this.Fs.add(t)}}class it extends J{ut;en;Xd;Kh;Qe;Zo;jo;Kt;Gd;Yd;K;constructor(t,e){super(),this.ut=null,this.en=null,this.Xd="None",this.Kh="black",this.Qe="black",this.Zo=1,this.jo=null,this.Kt=null,this.Gd=NaN,this.Yd=NaN,this.K=null,typeof t=="string"?this.figure=t:t&&Object.assign(this,t),e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.ut=this.ut,t.en=this.en,t.Xd=this.Xd,t.Kh=this.Kh,t.Qe=this.Qe,t.Zo=this.Zo,this.jo!==null&&(t.jo=this.jo.slice()),this.Kt!==null&&(this.Kt.me?t.Kt=this.Kt:t.Kt=this.Kt.copy()),t.Gd=this.Gd,t.Yd=this.Yd,this.K!==null&&(t.K=this.K.copy())}Hh(){return this.Kt===null?this.Kt=new Xi:this.Kt.me&&(this.Kt=this.Kt.copy()),this.Kt}xa(){super.xa(),this.Kt!==null&&(this.Kt.me=!0)}fe(t){t in Ri?this.geometryStretch=t:super.fe(t)}toString(){return"Shape("+(this.figure!=="None"?this.figure:this.toArrow!=="None"?this.toArrow:this.fromArrow)+")#"+V.xs(this)}tE(t,e){let i=this.pathPattern;if(i===null)return;i.ht(1/0,1/0);let s=i.measuredBounds;i.Ut(0,0,s.width,s.height);let n=this.geometry;if(n===null)return;t.save(),t.beginPath();let o=m.st();if(n.type===1)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.endY),this.Kd(t,e,o,i);else if(n.type===4){let r=n.figures.iterator;for(;r.next();){let a=r.value;o.length=0,o.push(a.startX),o.push(a.startY);let h=a.startX,l=a.startY,u=h,c=l,d=a.segments.r,f=d.length;for(let p=0;p<f;p++){let g=d[p];switch(g.type){case 1:this.Kd(t,e,o,i),o.length=0,o.push(g.endX),o.push(g.endY),h=g.endX,l=g.endY,u=h,c=l;break;case 2:o.push(g.endX),o.push(g.endY),h=g.endX,l=g.endY;break;case 3:C.qn(h,l,g.point1X,g.point1Y,g.point2X,g.point2Y,g.endX,g.endY,.5,o),h=g.endX,l=g.endY;break;case 4:C.sm(h,l,g.point1X,g.point1Y,g.endX,g.endY,.5,o),h=g.endX,l=g.endY;break;case 5:{let y=g.vo(a),b=y.length;if(b===0){o.push(g.centerX),o.push(g.centerY),h=g.centerX,l=g.centerY;break}for(let v=0;v<b;v++){let w=y[v];C.qn(h,l,w[2],w[3],w[4],w[5],w[6],w[7],.5,o),h=w[6],l=w[7]}break}case 6:{let y=g.$a(a,h,l),b=y.length;if(b===0){o.push(g.endX),o.push(g.endY),h=g.endX,l=g.endY;break}for(let v=0;v<b;v++){let w=y[v];C.qn(h,l,w[2],w[3],w[4],w[5],w[6],w[7],.5,o),h=w[6],l=w[7]}break}default:m.o("Segment not of valid type: "+g.type)}g.isClosed&&(o.push(u),o.push(c),this.Kd(t,e,o,i))}this.Kd(t,e,o,i)}}else if(n.type===2)o.push(n.startX),o.push(n.startY),o.push(n.endX),o.push(n.startY),o.push(n.endX),o.push(n.endY),o.push(n.startX),o.push(n.endY),o.push(n.startX),o.push(n.startY),this.Kd(t,e,o,i);else if(n.type===3){let r=new zt;r.startX=n.endX,r.startY=(n.startY+n.endY)/2;let a=new mt(5);a.startAngle=0,a.sweepAngle=360,a.centerX=(n.startX+n.endX)/2,a.centerY=(n.startY+n.endY)/2,a.radiusX=Math.abs(n.startX-n.endX)/2,a.radiusY=Math.abs(n.startY-n.endY)/2,r.add(a);let h=a.vo(r),l=h.length;if(l===0)o.push(a.centerX),o.push(a.centerY);else{let u=r.startX,c=r.startY;for(let d=0;d<l;d++){let f=h[d];C.qn(u,c,f[2],f[3],f[4],f[5],f[6],f[7],.5,o),u=f[6],c=f[7]}}this.Kd(t,e,o,i)}m.Z(o),t.restore(),t.clearContextCache(!1)}eE(t){let e=t.measuredBounds.width;return t instanceof it&&(e-=t.strokeWidth),e<1&&(e=1),e}Kd(t,e,i,s){let n=i.length;if(n<4)return;let o=s.measuredBounds,r=Math.max(1,o.width),a=o.height,h=i[0],l=i[1],u=0,c=0,d=0,f=0,p=0,g=0,y=0,b=0,v=m.st();for(let A=2;A<n;A+=2)u=i[A],c=i[A+1],d=u-h,f=c-l,d===0&&(d=.001),p=f/d,g=Math.atan2(f,d),y=Math.sqrt(d*d+f*f),v.push([d,g,p,y]),b+=y,h=u,l=c;h=i[0],l=i[1];let w=this.eE(s),k=w,S=r/2,N=S!==0,D=0,L=v[D];d=L[0],g=L[1],p=L[2],y=L[3];let M=0;for(;b>=.1;){if(M===0&&(N?(k=w,k-=S,b-=S,N=!1):k=w,k===0&&(k=1)),k>b){k=b,m.Z(v);return}k>y?(M=k-y,k=y):M=0;let A=Math.sqrt(k*k/(1+p*p));if(d<0&&(A=-A),h+=A,l+=p*A,t.translate(h,l),t.rotate(g),t.translate(-(r/2),-(a/2)),M===0&&s.Sa(t,e),t.translate(r/2,a/2),t.rotate(-g),t.translate(-h,-l),b-=k,y-=k,M!==0){if(D++,D===v.length){m.Z(v);return}L=v[D],d=L[0],g=L[1],p=L[2],y=L[3],k=M}}m.Z(v)}Sa(t,e){let i=t instanceof ae,s=this.Qe,n=this.Kh;if(s===null&&n===null)return;let o=this.ut;if(o===null)return;t.commitTransform();let r=this.actualBounds,a=this.naturalBounds;n!==null&&this.kn(t,n,!0,!1,a,r);let h=this.part,l=this.Zo;s!==null&&l===0&&h!==null&&(this.isPanelMain||h.findMainElement()===this)&&(l=h.iE()),l===0&&(s=null),s!==null&&l!==0&&(this.kn(t,s,!1,!1,a,r),t.lineWidth=l,t.lineJoin=this.strokeJoin,t.lineCap=this.strokeCap,t.miterLimit=this.strokeMiterLimit);let u=!1;h&&e.getRenderingHint("drawShadows")&&(u=h.isShadowed),t.rl===!1&&(u=!1);let c=!0;s!==null&&(n===null||n==="transparent")&&(c=!1);let d=!1,f=this.strokeDashArray;if(f!==null&&(d=!0,t.enableDash(f,this.strokeDashOffset)),o.type===1)t.beginPath(),t.moveTo(o.startX,o.startY),t.lineTo(o.endX,o.endY),s!==null&&t.strokeContext(),t.endPath();else if(o.type===2){let p=o.startX,g=o.startY,y=o.endX,b=o.endY,v=Math.min(p,y),w=Math.min(g,b),k=Math.abs(y-p),S=Math.abs(b-g);t.beginPath(),t.rect(v,w,k,S),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&u&&t.shadowsOff(),t.strokeContext(),c&&u&&t.shadowsOn()),t.endPath()}else if(o.type===3){let p=o.startX,g=o.startY,y=o.endX,b=o.endY,v=Math.abs(y-p)/2,w=Math.abs(b-g)/2,k=Math.min(p,y)+v,S=Math.min(g,b)+w;t.beginPath(),t.moveTo(k,S-w),t.bezierCurveTo(k+C.Hn*v,S-w,k+v,S-C.Hn*w,k+v,S),t.bezierCurveTo(k+v,S+C.Hn*w,k+C.Hn*v,S+w,k,S+w),t.bezierCurveTo(k-C.Hn*v,S+w,k-v,S+C.Hn*w,k-v,S),t.bezierCurveTo(k-v,S-C.Hn*w,k-C.Hn*v,S-w,k,S-w),t.closePath(),n!==null&&t.fillContext(n,!1,null),s!==null&&(c&&u&&t.shadowsOff(),t.strokeContext(),c&&u&&t.shadowsOn()),t.endPath()}else if(o.type===4){let p=o.figures,g=p.length;for(let y=0;y<g;y++){let b=p.r[y];i?(t.beginPath(),this.PD(t,b)):b.ji===null&&(b.ji=new Path2D,this.PD(b.ji,b));let v=b.isFilled;u?b.isShadowed?(v===!0&&n!=="transparent"&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&(v&&c&&t.shadowsOff(),t.stroke(b.ji),v&&c&&t.shadowsOn())):(t.shadowsOff(),v&&n!=="transparent"&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&t.stroke(b.ji),t.shadowsOn()):(v&&n!==null&&t.fillContext(n,b.isEvenOdd,b.ji),s!==null&&t.stroke(b.ji)),t.endPath(y)}}d&&t.disableDash(),this.tE(t,e)}PD(t,e){t.moveTo(e.startX,e.startY);let i=e.segments.r,s=i.length,n=null;for(let o=0;o<s;o++){let r=i[o];switch(r.type){case 1:t.moveTo(r.endX,r.endY);break;case 2:t.lineTo(r.endX,r.endY);break;case 3:t.bezierCurveTo(r.point1X,r.point1Y,r.point2X,r.point2Y,r.endX,r.endY);break;case 4:t.quadraticCurveTo(r.point1X,r.point1Y,r.endX,r.endY);break;case 5:if(r.radiusX===r.radiusY){let a=n!==null?n.endX:e.startX,h=n!==null?n.endY:e.startY,l=Math.PI/180;t.arc(r.point1X,r.point1Y,r.radiusX,r.startAngle*l,(r.startAngle+r.sweepAngle)*l,r.sweepAngle<0,a,h)}else{let a=r.vo(e),h=a.length;if(h===0){t.lineTo(r.centerX,r.centerY);break}for(let l=0;l<h;l++){let u=a[l];l===0&&t.lineTo(u[0],u[1]),t.bezierCurveTo(u[2],u[3],u[4],u[5],u[6],u[7])}}break;case 6:{let a=0,h=0,l;if(n!==null&&n.type===5){l=n.vo(e);let c=l.length;if(c===0){t.lineTo(r.endX,r.endY);break}let d=l[c-1]||null;d!==null&&(a=d[6],h=d[7])}else a=n!==null?n.endX:e.startX,h=n!==null?n.endY:e.startY;l=r.$a(e,a,h);let u=l.length;if(u===0){t.lineTo(r.endX,r.endY);break}for(let c=0;c<u;c++){let d=l[c];t.bezierCurveTo(d[2],d[3],d[4],d[5],d[6],d[7])}break}}r.isClosed&&t.closePath(),n=r}}wf(t,e,i){if(!super.wf(t,e,i)||this.Qe===null&&this.Kh===null||this.ut===null||this.pathPattern!==null)return!1;let s=this.svg.getElementsByTagName("path");return this.geometry.figures.length!==s.length?!1:(t.currentPath=this.svg,this.Sa(t,e),t.currentPath=null,!0)}Sd(t){return this.geometry!==null&&this.geometry.figures.length>1||this.pathPattern!==null?!0:super.Sd(t)}NC(t,e){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",e);else{let i=t.getElementsByTagName("path");for(let s=0;s<i.length;s++)i[s].setAttributeNS(null,"filter",e)}}getDocumentPoint(t,e){if(e===void 0&&(e=new P),t instanceof T){let i=t;i.isNoSpot()&&m.o("getDocumentPoint Spot must be a real, specific Spot, not: "+i.toString());let s=this.naturalBounds,n=this.strokeWidth;return e.e(i.x*(s.width+n)-n/2+s.x+i.offsetX,i.y*(s.height+n)-n/2+s.y+i.offsetY),this.Js.gt(e),e}else return e.set(t),this.Js.gt(e),e}getDocumentBounds(t){t===void 0&&(t=new I);let e=this.naturalBounds,i=this.Js,s=I.z(e.x,e.y,e.width,e.height),n=this.strokeWidth;s.inflate(n/2,n/2);let o=P.z(s.x,s.y).v(i);return t.e(o.x,o.y,0,0),o.e(s.right,s.y).v(i),t.re(o.x,o.y,0,0),o.e(s.right,s.bottom).v(i),t.re(o.x,o.y,0,0),o.e(s.x,s.bottom).v(i),t.re(o.x,o.y,0,0),I.i(s),P.i(o),t}ba(t,e){let i=this.geometry;if(i===null||this.fill===null&&this.stroke===null)return!1;let s=i.bounds,n=this.strokeWidth/2;i.type===1&&!e&&(n+=2);let o=I.l();if(o.h(s),o.inflate(n+2,n+2),!o.containsPoint(t))return I.i(o),!1;let r=n+1e-4;if(i.type===1){if(this.stroke===null)return!1;let a=(i.startX-i.endX)*(t.x-i.endX)+(i.startY-i.endY)*(t.y-i.endY),h=(i.endX-i.startX)*(t.x-i.startX)+(i.endY-i.startY)*(t.y-i.startY);return a<0||h<0?!1:(I.i(o),C.Ve(i.startX,i.startY,i.endX,i.endY,n,t.x,t.y))}else if(i.type===2){let a=i.startX,h=i.startY,l=i.endX,u=i.endY;if(o.x=Math.min(a,l),o.y=Math.min(h,u),o.width=Math.abs(l-a),o.height=Math.abs(u-h),this.fill===null){if(o.inflate(-r,-r),o.containsPoint(t))return I.i(o),!1;o.inflate(r,r)}this.stroke!==null&&o.inflate(n,n);let c=o.containsPoint(t);return I.i(o),c}else if(i.type===3){let a=i.startX,h=i.startY,l=i.endX,u=i.endY,c=Math.min(a,l),d=Math.min(h,u),f=Math.abs(l-a),p=Math.abs(u-h),g=f/2,y=p/2;if(c=t.x-(c+g),d=t.y-(d+y),this.fill===null){if(g-=r,y-=r,g<=0||y<=0||c*c/(g*g)+d*d/(y*y)<=1)return I.i(o),!1;g+=r,y+=r}return this.stroke!==null&&(g+=r,y+=r),I.i(o),g<=0||y<=0?!1:c*c/(g*g)+d*d/(y*y)<=1}else{if(i.type===4)return I.i(o),this.fill===null?i.ZL(t.x,t.y,n):i.OP(t,n,this.strokeWidth>1,e);m.o("Unknown Geometry type: "+i.type)}}kd(t,e,i,s){let n=this.desiredSize,o=this.Zo;t=Math.max(t,0),e=Math.max(e,0);let r;if(this.en!==null)r=this.geometry.bounds;else{let p=this.figure,g=it.eN[p];if(g===void 0){let y=C.jn[p];typeof y=="string"&&(y=C.jn[y]),m.it(y)?(g=y(null,100,100),it.eN[p]=g):m.o("Unsupported Figure: "+p)}r=g.bounds}let a=r.width,h=r.height,l=r.width,u=r.height;switch(this.Qs(!0)){case 0:i=0,s=0;break;case 2:l=Math.max(t-o,0),u=Math.max(e-o,0);break;case 5:l=Math.max(t-o,0),s=0;break;case 4:i=0,u=Math.max(e-o,0);break}isFinite(n.width)&&(l=n.width),isFinite(n.height)&&(u=n.height);let c=this.maxSize,d=this.minSize;i=Math.max(i-o,d.width),s=Math.max(s-o,d.height),l=Math.min(c.width,l),u=Math.min(c.height,u),l=isFinite(l)?Math.max(i,l):Math.max(a,i),u=isFinite(u)?Math.max(s,u):Math.max(h,s);let f=this.ZS();switch(f){case 0:break;case 2:a=l,h=u;break;case 6:{let p=Math.min(l/a,u/h);isFinite(p)||(p=1),a=a*p,h=h*p;break}default:m.o(f+" is not a valid geometryStretch.")}if(this.en!==null){a===0&&(a=.001),h===0&&(h=.001);let p=this.en.nR(a,h);this.ut=p}else(this.ut===null||!C.X(this.ut.Pc,t-o)||!C.X(this.ut.Sc,e-o))&&(this.ut=it.sE(this,a,h));r=this.ut.bounds,t===1/0||e===1/0?this.ro(r.x-o/2,r.y-o/2,t===0&&a===0?0:r.width+o,e===0&&h===0?0:r.height+o):this.ro(-(o/2),-(o/2),l+o,u+o),n.isReal()?(l=n.width,u=n.height,l=Math.min(c.width,l),u=Math.min(c.height,u),l=Math.max(d.width,l),u=Math.max(d.height,u),this.Ke.e(0,0,l,u)):this.Ke.h(r)}ZS(){let t=this.geometryStretch;return this.en!==null?t===1?2:t:t===1?it.eN[this.figure].defaultStretch:t}ka(t,e,i,s){this.commonArrange(t,e,i,s)}getNearestIntersectionPoint(t,e,i){return this.pf(t.x,t.y,e.x,e.y,i)}pf(t,e,i,s,n){let o=this.v,r=1/(o.m11*o.m22-o.m12*o.m21),a=o.m22*r,h=-o.m12*r,l=-o.m21*r,u=o.m11*r,c=r*(o.m21*o.dy-o.m22*o.dx),d=r*(o.m12*o.dx-o.m11*o.dy),f=t*a+e*l+c,p=t*h+e*u+d,g=i*a+s*l+c,y=i*h+s*u+d,b=this.Zo/2,v=this.ut;v===null&&(this.ht(1/0,1/0),v=this.ut);let w=v.bounds,k=!1;if(v.type===1)if(this.strokeWidth<=1.5)k=C.Do(v.startX,v.startY,v.endX,v.endY,f,p,g,y,n);else{let S=0,N=0;if(v.startX===v.endX)S=b,N=0;else{let F=(v.endY-v.startY)/(v.endX-v.startX);N=b/Math.sqrt(1+F*F),S=N*F}let D=m.st(),L=new P;C.Do(v.startX+S,v.startY+N,v.endX+S,v.endY+N,f,p,g,y,L)&&D.push(L),L=new P,C.Do(v.startX-S,v.startY-N,v.endX-S,v.endY-N,f,p,g,y,L)&&D.push(L),L=new P,C.Do(v.startX+S,v.startY+N,v.startX-S,v.startY-N,f,p,g,y,L)&&D.push(L),L=new P,C.Do(v.endX+S,v.endY+N,v.endX-S,v.endY-N,f,p,g,y,L)&&D.push(L);let M=D.length;if(M===0)return m.Z(D),!1;k=!0;let A=1/0;for(let F=0;F<M;F++){let O=D[F],E=(O.x-f)**2+(O.y-p)**2;E<A&&(A=E,n.x=O.x,n.y=O.y)}m.Z(D)}else if(v.type===2)k=C.Al(w.x-b,w.y-b,w.x+w.width+b,w.y+w.height+b,f,p,g,y,n);else if(v.type===3){let S=I.z(w.x,w.y,w.width,w.height).inflate(b,b);k=this.nE(S,f,p,g,y,n),I.i(S)}else if(v.type===4){let S=0,N=0,D=0,L=0,M=P.l(),A=g-f,F=y-p,O=A*A+F*F,E=f,B=p;if(O>0&&w.contains(E,B)&&(M.x=E,M.y=B,this.containsPoint(M)))for(A!==0&&Math.abs(A)<.5?(F*=.5/A,A=.5):F!==0&&Math.abs(F)<.5&&(A*=.5/F,F=.5),E-=A,B-=F;w.contains(E,B);)E-=A,B-=F;let X=.6;n.x=g,n.y=y;for(let st=0;st<v.figures.count;st++){let Z=v.figures.r[st],et=Z.isFilled?E:f,Q=Z.isFilled?B:p,rt=Z.segments;S=Z.startX,N=Z.startY;let ft=S,xt=N;for(let Ct=0;Ct<rt.count;Ct++){let _=rt.r[Ct],St=_.type;D=_.endX,L=_.endY;let bt=!1;switch(St){case 1:ft=D,xt=L;break;case 2:bt=this.J1(S,N,D,L,et,Q,g,y,M);break;case 3:{bt=C.nm(S,N,_.point1X,_.point1Y,_.point2X,_.point2Y,D,L,et,Q,g,y,X,M);break}case 4:{bt=C.nm(S,N,S+2/3*(_.point1X-S),N+2/3*(_.point1Y-N),D+2/3*(_.point1X-D),L+2/3*(_.point1Y-L),D,L,et,Q,g,y,X,M);break}case 5:case 6:{let Yt=_.type===5?_.vo(Z):_.$a(Z,S,N),ot=Yt.length;if(ot===0){bt=this.J1(S,N,_.type===5?_.centerX:_.endX,_.type===5?_.centerY:_.endY,et,Q,g,y,M);break}let H=null;for(let gt=0;gt<ot;gt++){if(H=Yt[gt],gt===0&&this.J1(S,N,H[0],H[1],et,Q,g,y,M)){let At=this.$1(et,Q,M,O,n);At<O&&(O=At,k=!0)}if(C.nm(H[0],H[1],H[2],H[3],H[4],H[5],H[6],H[7],et,Q,g,y,X,M)){let At=this.$1(et,Q,M,O,n);At<O&&(O=At,k=!0)}}D=H[6],L=H[7];break}default:m.o("Unknown Segment type: "+St)}if(S=D,N=L,bt){let Yt=this.$1(et,Q,M,O,n);Yt<O&&(O=Yt,k=!0)}if(_.isClosed&&(D=ft,L=xt,this.J1(S,N,D,L,et,Q,g,y,M))){let Yt=this.$1(et,Q,M,O,n);Yt<O&&(O=Yt,k=!0)}}}let z=i-t,U=s-e,tt=Math.sqrt(z*z+U*U);tt!==0&&(z/=tt,U/=tt),n.x-=z*b,n.y-=U*b,P.i(M)}else m.o("Unknown Geometry type: "+v.type);return k?(this.v.gt(n),!0):!1}$1(t,e,i,s,n){let o=i.x-t,r=i.y-e,a=o*o+r*r;return a<s?(n.x=i.x,n.y=i.y,a):s}J1(t,e,i,s,n,o,r,a,h){if(C.X(t,i)&&C.X(e,s)||C.X(n,r)&&C.X(o,a))return!1;let l=!1,u=(n-r)*(e-s)-(o-a)*(t-i);if(u===0)return!1;if(h.x=((n*a-o*r)*(t-i)-(n-r)*(t*s-e*i))/u,h.y=((n*a-o*r)*(e-s)-(o-a)*(t*s-e*i))/u,(t>i?t-i:i-t)<(e>s?e-s:s-e)){let c=e<s?e:s,d=e<s?s:e;(h.y>c||C.X(h.y,c))&&(h.y<d||C.X(h.y,d))&&(l=!0)}else{let c=t<i?t:i,d=t<i?i:t;(h.x>c||C.X(h.x,c))&&(h.x<d||C.X(h.x,d))&&(l=!0)}return l}oE(t,e,i){return this.pickable===!1?!1:(i.bc(this.v),e?this.rE(t,i):this.containedInRect(t,i))}containedInRect(t,e){if(e===void 0)return t.containsRect(this.actualBounds);let i=this.ut;i===null&&(this.ht(1/0,1/0),i=this.ut);let s=i.bounds,n=this.strokeWidth/2,o=!1,r=P.l();return r.e(s.x-n,s.y-n),t.containsPoint(e.gt(r))&&(r.e(s.x-n,s.bottom+n),t.containsPoint(e.gt(r))&&(r.e(s.right+n,s.bottom+n),t.containsPoint(e.gt(r))&&(r.e(s.right+n,s.y-n),t.containsPoint(e.gt(r))&&(o=!0)))),P.i(r),o}intersectsRect(t,e){if(this.containedInRect(t,e)||e===void 0&&(e=this.v,t.containsRect(this.actualBounds)))return!0;let i=Nt.l();i.set(e),i.Zw();let s=t.left,n=t.right,o=t.top,r=t.bottom,a=P.l();if(a.e(s,o),i.gt(a),this.ba(a,!0)||(a.e(n,o),i.gt(a),this.ba(a,!0))||(a.e(s,r),i.gt(a),this.ba(a,!0))||(a.e(n,r),i.gt(a),this.ba(a,!0)))return P.i(a),!0;let h=P.l(),l=P.l();i.set(e),i.zL(this.v),i.Zw(),h.x=n,h.y=o,h.v(i),a.x=s,a.y=o,a.v(i);let u=!1;return this.qh(a,h,l)?u=!0:(a.x=n,a.y=r,a.v(i),this.qh(a,h,l)?u=!0:(h.x=s,h.y=r,h.v(i),this.qh(a,h,l)?u=!0:(a.x=s,a.y=o,a.v(i),this.qh(a,h,l)&&(u=!0)))),P.i(a),Nt.i(i),P.i(h),P.i(l),u}qh(t,e,i){if(!this.getNearestIntersectionPoint(t,e,i))return!1;let s=t.x,n=t.y,o=e.x,r=e.y,a=i.x,h=i.y;if(s===o){let l=0,u=0;return n<r?(l=n,u=r):(l=r,u=n),h>=l&&h<=u}else{let l=0,u=0;return s<o?(l=s,u=o):(l=o,u=s),a>=l&&a<=u}}rE(t,e){if(this.containedInRect(t,e)||e===void 0&&(e=this.v,t.containsRect(this.actualBounds)))return!0;let i=t.left,s=t.right,n=t.top,o=t.bottom,r=P.l(),a=P.l(),h=P.l(),l=Nt.l();l.set(e),l.zL(this.v),l.Zw(),a.x=s,a.y=n,a.v(l),r.x=i,r.y=n,r.v(l);let u=!1;return this.qh(r,a,h)?u=!0:(r.x=s,r.y=o,r.v(l),this.qh(r,a,h)?u=!0:(a.x=i,a.y=o,a.v(l),this.qh(r,a,h)?u=!0:(r.x=i,r.y=n,r.v(l),this.qh(r,a,h)&&(u=!0)))),Nt.i(l),P.i(r),P.i(a),P.i(h),u}ZT(t,e,i){if(i&&this.fill!==null&&this.ba(t,!0))return!0;let s=t.distanceSquaredPoint(e),n=s;this.strokeWidth>1.5&&(s=this.strokeWidth/2+Math.sqrt(s),s*=s);let o=this.ut;if(o===null&&(this.ht(1/0,1/0),o=this.ut,o===null))return!1;if(!i){let c=o.bounds,d=c.x,f=c.y,p=c.x+c.width,g=c.y+c.height;if(P.distanceSquared(t.x,t.y,d,f)<=s&&P.distanceSquared(t.x,t.y,p,f)<=s&&P.distanceSquared(t.x,t.y,d,g)<=s&&P.distanceSquared(t.x,t.y,p,g)<=s)return!0}function r(c,d){let f=c.length;for(let p=0;p<f;p+=2)if(d.distanceSquared(c[p],c[p+1])>s)return!0;return!1}let a=o.startX,h=o.startY,l=o.endX,u=o.endY;if(o.type===1){let c=P.distanceLineSegmentSquared(t.x,t.y,a,h,l,u),d=(l-a)*(t.x-a)+(u-h)*(t.y-h),f=(a-l)*(t.x-l)+(h-u)*(t.y-u),p=d>=0&&f>=0?s:n;return c<=p}else if(o.type===2){let c=!1;return i&&(c=P.distanceLineSegmentSquared(t.x,t.y,a,h,a,u)<=s||P.distanceLineSegmentSquared(t.x,t.y,a,h,l,h)<=s||P.distanceLineSegmentSquared(t.x,t.y,l,h,l,u)<=s||P.distanceLineSegmentSquared(t.x,t.y,a,u,l,u)<=s),c}else if(o.type===3){let c=(a+l)/2,d=(h+u)/2,f=t.x-c,p=t.y-d,g=Math.abs(l-a)/2,y=Math.abs(u-h)/2;if(g===0||y===0)return P.distanceLineSegmentSquared(t.x,t.y,a,h,l,u)<=s;if(i){let b=C.JF(g,y,f,p);return b*b<=s}else return!(P.distanceSquared(f,p,-g,0)>=s||P.distanceSquared(f,p,0,-y)>=s||P.distanceSquared(f,p,0,y)>=s||P.distanceSquared(f,p,g,0)>=s)}else if(o.type===4){let c=o.bounds,d=c.x,f=c.y,p=c.x+c.width,g=c.y+c.height;if(t.x>p&&t.x<d&&t.y>g&&t.y<f&&P.distanceLineSegmentSquared(t.x,t.y,d,f,d,g)>s&&P.distanceLineSegmentSquared(t.x,t.y,d,f,p,f)>s&&P.distanceLineSegmentSquared(t.x,t.y,p,g,d,g)>s&&P.distanceLineSegmentSquared(t.x,t.y,p,g,p,f)>s)return!1;let y=Math.sqrt(s);if(i){if(this.fill===null?o.ZL(t.x,t.y,y):o.OP(t,y,!0,!1))return!0}else{let b=o.figures;for(let v=0;v<b.count;v++){let w=b.r[v],k=w.startX,S=w.startY;if(t.distanceSquared(k,S)>s)return!1;let N=w.segments.r,D=N.length;for(let L=0;L<D;L++){let M=N[L];switch(M.type){case 1:case 2:if(k=M.endX,S=M.endY,t.distanceSquared(k,S)>s)return!1;break;case 3:{let A=m.st();C.qn(k,S,M.point1X,M.point1Y,M.point2X,M.point2Y,M.endX,M.endY,.8,A);let F=r(A,t);if(m.Z(A),F||(k=M.endX,S=M.endY,t.distanceSquared(k,S)>s))return!1;break}case 4:{let A=m.st();C.sm(k,S,M.point1X,M.point1Y,M.endX,M.endY,.8,A);let F=r(A,t);if(m.Z(A),F||(k=M.endX,S=M.endY,t.distanceSquared(k,S)>s))return!1;break}case 5:case 6:{let A=M.type===5?M.vo(w):M.$a(w,k,S),F=A.length;if(F===0){if(k=M.type===5?M.centerX:M.endX,S=M.type===5?M.centerY:M.endY,t.distanceSquared(k,S)>s)return!1;break}let O=null,E=m.st();for(let B=0;B<F;B++)if(O=A[B],E.length=0,C.qn(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],.8,E),r(E,t))return m.Z(E),!1;m.Z(E),O!==null&&(k=O[6],S=O[7]);break}default:m.o("Unknown Segment type: "+M.type)}}}return!0}}return!1}nE(t,e,i,s,n,o){if(t.width===0)return C.Do(t.x,t.y,t.x,t.y+t.height,e,i,s,n,o);if(t.height===0)return C.Do(t.x,t.y,t.x+t.width,t.y,e,i,s,n,o);{let r=t.width/2,a=t.height/2,h=t.x+r,l=t.y+a,u=9999;if(e!==s&&(u=(i-n)/(e-s)),Math.abs(u)<9999){let c=i-l-u*(e-h);if(r*r*(u*u)+a*a-c*c<0)return o.x=NaN,o.y=NaN,!1;let d=Math.sqrt(r*r*(u*u)+a*a-c*c),f=(-(r*r*u*c)+r*a*d)/(a*a+r*r*(u*u))+h,p=(-(r*r*u*c)-r*a*d)/(a*a+r*r*(u*u))+h,g=u*(f-h)+c+l,y=u*(p-h)+c+l,b=Math.abs((e-f)**2)+Math.abs((i-g)**2),v=Math.abs((e-p)**2)+Math.abs((i-y)**2);b<v?(o.x=f,o.y=g):(o.x=p,o.y=y)}else{let c=a*a,d=r*r,f=e-h,p=c-c/d*(f*f);if(p<0)return o.x=NaN,o.y=NaN,!1;let g=Math.sqrt(p),y=l+g,b=l-g,v=Math.abs(y-i),w=Math.abs(b-i);v<w?(o.x=e,o.y=y):(o.x=e,o.y=b)}return!0}}WI(){return this.Zo/2*this.strokeMiterLimit*this.getDocumentScale()}get geometry(){return this.ut!==null?this.ut:this.en}set geometry(t){let e=this.ut,i=this.en;if(e===t)return;t!==null?(this.ut=t.k(),this.en=this.ut):(this.ut=null,this.en=null);let s=this.part;if(s!==null&&s.Df(),this.f(),this.t("geometry",e||i,t),this.mf()){let n=this.part;n!==null&&this.Eh(n,"geometryString")}}get geometryString(){return this.geometry===null?"":this.geometry.toString()}set geometryString(t){let e=wt.parse(t),i=e.normalize();this.geometry=e;let s=P.z(-i.x,-i.y);this.position=s,P.i(s)}get isGeometryPositioned(){return(this.n&1048576)!==0}set isGeometryPositioned(t){let e=(this.n&1048576)!==0;e!==t&&(this.n=this.n^1048576,this.f(),this.t("isGeometryPositioned",e,t))}ai(){this.ut=null}get fill(){return this.Kh}set fill(t){let e=this.Kh;e!==t&&(t!==null&&R.Cd(t,"Shape.fill"),t instanceof R&&t.k(),this.Kh=t,this.N(),this.t("fill",e,t))}get stroke(){return this.Qe}set stroke(t){let e=this.Qe;e!==t&&(t!==null&&R.Cd(t,"Shape.stroke"),t instanceof R&&t.k(),this.Qe=t,this.N(),this.t("stroke",e,t))}get strokeWidth(){return this.Zo}set strokeWidth(t){let e=this.Zo;if(e!==t)if(t>=0){this.Zo=t,this.f();let i=this.part;i!==null&&i.Df(),this.t("strokeWidth",e,t)}else m.J(t,"value >= 0",it,"strokeWidth:value")}Gp(){return this.Zo}get strokeCap(){return this.Kt!==null?this.Kt.B0:"butt"}set strokeCap(t){let e=this.strokeCap;e!==t&&(typeof t=="string"&&(t==="butt"||t==="round"||t==="square")?(this.Hh().B0=t,this.N(),this.t("strokeCap",e,t)):m.J(t,'"butt", "round", or "square"',it,"strokeCap"))}get strokeJoin(){return this.Kt!==null?this.Kt.z0:"miter"}set strokeJoin(t){let e=this.strokeJoin;e!==t&&(typeof t=="string"&&(t==="miter"||t==="bevel"||t==="round")?(this.Hh().z0=t,this.N(),this.t("strokeJoin",e,t)):m.J(t,'"miter", "bevel", or "round"',it,"strokeJoin"))}get strokeMiterLimit(){return this.Kt!==null?this.Kt.X0:10}set strokeMiterLimit(t){let e=this.strokeMiterLimit;if(e!==t&&t>=1){this.Hh().X0=t,this.N();let i=this.part;i!==null&&i.Df(),this.t("strokeMiterLimit",e,t)}}get strokeDashArray(){return this.jo}set strokeDashArray(t){let e=this.jo;if(e!==t){if(t!==null&&!Array.isArray(t)&&m.si(t,"Array",it,"strokeDashArray:value"),t!==null){let i=t.length,s=0;for(let n=0;n<i;n++){let o=t[n];(!(o>=0)||!isFinite(o))&&m.o("strokeDashArray:value "+o+" at index "+n+" must be a positive number or zero."),s+=o}if(s===0){if(e===null)return;t=null}}this.jo=t,this.N(),this.t("strokeDashArray",e,t)}}get strokeDashOffset(){return this.Kt!==null?this.Kt.Na:0}set strokeDashOffset(t){let e=this.strokeDashOffset;e!==t&&t>=0&&(this.Hh().Na=t,this.N(),this.t("strokeDashOffset",e,t))}get figure(){return this.Xd}set figure(t){let e=this.Xd;if(e!==t){let i=C.jn[t];if(m.it(i)?i=t:(i=C.jn[t.toLowerCase()],(!i||typeof i=="function")&&m.o("Unknown Shape.figure: "+t)),e!==i){let s=this.part;s!==null&&s.Df(),this.Xd=i,this.en=null,this.ai(),this.f(),this.t("figure",e,i)}}}get toArrow(){return this.Ot!==null?this.Ot.G0:"None"}set toArrow(t){let e=this.toArrow;if(t===!0?t="Standard":t===!1&&(t=""),e!==t){let i=it.SD(t);i===null?m.o("Unknown Shape.toArrow: "+t):e!==i&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.G0=i,this.en=null,this.ai(),this.f(),this.MD(i),this.t("toArrow",e,i))}}get fromArrow(){return this.Ot!==null?this.Ot.Y0:"None"}set fromArrow(t){let e=this.fromArrow;if(t===!0?t="Standard":t===!1&&(t=""),e!==t){let i=it.SD(t);i===null?m.o("Unknown Shape.fromArrow: "+t):e!==i&&(this.Ot===null&&(this.Ot=new Oe),this.Ot.Y0=i,this.en=null,this.ai(),this.f(),this.MD(i),this.t("fromArrow",e,i))}}MD(t){let e=this.diagram;e!==null&&e.undoManager.isUndoingRedoing||(this.yI(),this.toArrow!=="None"?(this.segmentIndex=-1,this.alignmentFocus=T.Right):this.fromArrow!=="None"&&(this.segmentIndex=0,this.alignmentFocus=T.Left))}get spot1(){return this.Kt!==null?this.Kt.Wn:T.Default}set spot1(t){let e=this.spot1;e.equals(t)||(t=t.C(),this.Hh().Wn=t,this.f(),this.t("spot1",e,t))}get spot2(){return this.Kt!==null?this.Kt.Jn:T.Default}set spot2(t){let e=this.spot2;e.equals(t)||(t=t.C(),this.Hh().Jn=t,this.f(),this.t("spot2",e,t))}get parameter1(){return this.Gd}set parameter1(t){let e=this.Gd;e!==t&&(this.Gd=t,this.ai(),this.f(),this.t("parameter1",e,t))}get parameter2(){return this.Yd}set parameter2(t){let e=this.Yd;e!==t&&(this.Yd=t,this.ai(),this.f(),this.t("parameter2",e,t))}get naturalBounds(){return this.Ke}VI(){let t=this.desiredSize;if(!t.isReal()&&this.ut!==null){let e=this.ut.bounds;this.Ke.h(e)}else this.Ke.e(0,0,t.width,t.height)}get pathPattern(){return this.Kt!==null?this.Kt.K0:null}set pathPattern(t){let e=this.pathPattern;e!==t&&(this.Hh().K0=t,this.N(),this.t("pathPattern",e,t))}get geometryStretch(){return this.Kt!==null?this.Kt.H0:1}set geometryStretch(t){let e=this.geometryStretch;e!==t&&(this.Hh().H0=t,this.f(),this.t("geometryStretch",e,t))}get interval(){return this.K!==null?this.K.Ff:1}set interval(t){let e=this.interval;if(t=Math.round(t),e!==t&&t!==0&&isFinite(t)){this.K===null&&(this.K=new be),this.K.Ff=t;let i=this.panel;if(i!==null){i.ds=null,i.f();let s=this.diagram;s!==null&&i===s.grid&&s.cd()}this.t("interval",e,t)}}get graduatedStart(){return this.K!==null?this.K.Rf:0}set graduatedStart(t){let e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Rf=t,this.f(),this.t("graduatedStart",e,t))}get graduatedEnd(){return this.K!==null?this.K.Of:1}set graduatedEnd(t){let e=this.graduatedEnd;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Of=t,this.f(),this.t("graduatedEnd",e,t))}get graduatedSkip(){return this.K!==null?this.K.If:null}set graduatedSkip(t){let e=this.graduatedSkip;e!==t&&(t!==null&&m.S(t,it,"graduatedSkip"),this.K===null&&(this.K=new be),this.K.If=t,this.f(),this.t("graduatedSkip",e,t))}polygonContainsRect(t){let e=this;if(!e.part||!e.part.actualBounds.containsRect(t))return!1;let i=e.geometry;if(!i)return!1;let s=t.x,n=t.y,o=t.width,r=t.height,a=P.l();if(a.x=s,a.y=n,e.getLocalPoint(a,a),!i.containsPoint(a)||o>0&&r>0&&(a.x=s+o,a.y=n+r,e.getLocalPoint(a,a),!i.containsPoint(a))||o>0&&(a.x=s+o,a.y=n,e.getLocalPoint(a,a),!i.containsPoint(a))||r>0&&(a.x=s,a.y=n+r,e.getLocalPoint(a,a),!i.containsPoint(a))||i.type===1)return!1;if(i.type===4){let h=i.figures.iterator;for(;h.next();){let l=h.value;if(!l.isFilled)continue;a.x=l.startX,a.y=l.startY,e.getDocumentPoint(a,a);let u=a.x,c=a.y,d=u,f=c,p=u,g=c,y=l.segments.iterator;for(;y.next();){let b=y.value;if(a.x=b.endX,a.y=b.endY,e.getDocumentPoint(a,a),p=a.x,g=a.y,b.type===1)u=p,c=g;else if(b.type!==5&&(I.intersectsLineSegment(s,n,o,r,d,f,p,g)||b.isClosed&&I.intersectsLineSegment(s,n,o,r,p,g,u,c)))return!1;d=p,f=g}}}return P.i(a),!0}static sE(t,e,i){let s=null;if(t.toArrow!=="None")s=it.Dn[t.toArrow];else if(t.fromArrow!=="None")s=it.Dn[t.fromArrow];else{let n=C.jn[t.figure];typeof n=="string"&&(n=C.jn[n]),n===void 0&&m.o("Unknown Shape.figure: "+t.figure),s=n(t,e,i),s.Pc=e,s.Sc=i}if(s===null){let n=C.jn.Rectangle;m.it(n)&&(s=n(t,e,i))}return s}static getFigureGenerators(){let t=new Mt;for(let e in C.jn){if(e===e.toLowerCase())continue;let i=C.jn[e];t.set(e,i)}return t.k(),t}static defineFigureGenerator(t,e){m.s(t,"string",it,"defineFigureGenerator:name"),typeof e=="string"||m.S(e,it,"defineFigureGenerator:func");let i=t.toLowerCase(),s=C.jn;s[t]=e,s[i]=t}static isFigureDefined(t){return t in C.jn}static getArrowheadGeometries(){let t=new Mt;for(let e in C.rm)if(it.Dn[e]===void 0){let i=wt.parse(C.rm[e],!1);it.Dn[e]=i;let s=e.toLowerCase();s!==e&&(it.Dn[s]=e)}for(let e in it.Dn){if(e===e.toLowerCase())continue;let i=it.Dn[e];i instanceof wt&&t.set(e,i)}return t.k(),t}static defineArrowheadGeometry(t,e){m.s(t,"string",it,"defineArrowheadGeometry:name");let i=null;typeof e=="string"?(m.s(e,"string",it,"defineArrowheadGeometry:pathstr"),i=wt.parse(e,!1)):i=e;let s=t.toLowerCase();(s==="none"||t===s)&&m.o("Shape.defineArrowheadGeometry name must not be empty or None or all-lower-case: "+t);let n=it.Dn;n[t]=i,n[s]=t}static isArrowheadDefined(t){return it.Dn.has(t)}static Dn=new yt;static eN=new yt;static SD(t){let e=it.Dn[t];if(e===void 0){let i=t.toLowerCase();if(i==="none")return"None";if(e=it.Dn[i],e===void 0){let s=null;for(let n in C.rm)if(n.toLowerCase()===i){s=n;break}if(s!==null){let n=wt.parse(C.rm[s],!1);return it.Dn[s]=n,i!==s&&(it.Dn[i]=s),s}}}return typeof e=="string"?e:e instanceof wt?t:null}}class Xi{me;B0;z0;X0;Na;K0;H0;Wn;Jn;constructor(){this.me=!1,this.B0="butt",this.z0="miter",this.X0=10,this.Na=0,this.K0=null,this.H0=1,this.Wn=T.Default,this.Jn=T.Default}copy(){let t=new Xi;return t.B0=this.B0,t.z0=this.z0,t.X0=this.X0,t.Na=this.Na,t.K0=this.K0,t.H0=this.H0,t.Wn=this.Wn.C(),t.Jn=this.Jn.C(),t}}var Ki=(x=>(x[x.None=0]="None",x[x.Fit=1]="Fit",x[x.DesiredSize=2]="DesiredSize",x[x.BreakAll=3]="BreakAll",x))(Ki||{}),js=(x=>(x[x.Clip=0]="Clip",x[x.Ellipsis=1]="Ellipsis",x))(js||{}),Yi=(x=>(x[x.Trim=0]="Trim",x[x.None=1]="None",x))(Yi||{});class lt extends J{ue;Qe;vn;Pi;pe;Yp;Hd;K;tt;Yl;uo;Fn;Ui;we;Rn;constructor(t,e){return super(),lt.b0===!1&&(lt.b0=!0,lt.us=Y.isUsingDOM()?new De(null)._t:null),this.n|=2097152,this.ue="",this.Qe="black",this.vn="13px sans-serif",this.Pi=0,this.pe=0,this.Yp=0,this.Hd=null,this.K=null,this.tt=null,this.Yl=0,this.uo=null,this.Fn=0,this.Ui=null,this.we=null,this.Rn=null,typeof t=="string"?this.text=t:t&&Object.assign(this,t),e&&Object.assign(this,e),this}cloneProtected(t){super.cloneProtected(t),t.ue=this.ue,t.Qe=this.Qe,t.vn=this.vn,t.Pi=this.Pi,t.pe=this.pe,t.Yp=this.Yp,t.Hd=this.Hd,this.K!==null&&(t.K=this.K.copy()),this.tt!==null&&(this.tt.me?t.tt=this.tt:t.tt=this.tt.copy()),t.Yl=this.Yl,t.uo=this.uo,t.Fn=this.Fn,t.Ui=this.Ui,t.we=this.we,t.Rn=this.Rn}Rs(){return this.tt===null?this.tt=new Ui:this.tt.me&&(this.tt=this.tt.copy()),this.tt}xa(){super.xa(),this.tt!==null&&(this.tt.me=!0)}HI(t){this.n=t.n|2048|4096,this.Zt=t.opacity,this.Nt=t.background,this.cs=t.desiredSize.C(),this.minSize=t.minSize.C(),this.maxSize=t.maxSize.C(),t.Me!==null?this.Me=t.Me.copy():this.Me=null,this.et=t.scale,this.Xt=t.angle,this.stretch=t.stretch,this.sl=t.margin.C(),this.de=t.alignment.C(),this.xd=t.alignmentFocus.C(),this.segmentFraction=t.segmentFraction,this.segmentOffset=t.segmentOffset.C(),this.segmentOrientation=t.segmentOrientation,t.he!==null&&(this.he=t.he.copy()),this.shadowVisible=t.shadowVisible,this.ue=t.ue,this.Qe=t.Qe,this.vn=t.vn,this.K!==null&&(this.K=t.K.copy()),t.tt!==null&&(t.tt.me?this.tt=t.tt:this.tt=t.tt.copy()),this.Yl=t.Yl}YI(t){if(this.ue=t.text||"",this.Xt=t.labelAngle||0,this.Pi=t.lineCount||0,this.lE(t.lines),t.naturalBounds&&(this.Ke=t.naturalBounds),t.actualBounds){let e=t.actualBounds;this.Ut(e.x,e.y,e.width,e.height)}}fe(t){t in Ki?this.wrap=t:super.fe(t)}toString(){return this.ue.length>22?'TextBlock("'+this.ue.substring(0,20)+'"...)':'TextBlock("'+this.ue+'")'}static getEllipsis(){return lt.q0}static setEllipsis(t){lt.q0=t,lt.Z1=new yt,lt.iN=0}static getBaseline(){return lt.Q1}static setBaseline(t){lt.Q1=t}static Q1=null;static getUnderline(){return lt._1}static setUnderline(t){lt._1=t}static _1=null;static None=0;static WrapFit=1;static WrapDesiredSize=2;static WrapBreakAll=3;static OverflowClip=0;static OverflowEllipsis=1;static FormatTrim=0;static FormatNone=1;f(){super.f(),this.Zi(!0)}get font(){return this.vn}set font(t){let e=this.vn;e!==t&&(this.vn=t,this.uo=null,this.f(),this.t("font",e,t))}static isValidFont(t){return K.CSS?K.CSS.supports("font",t):!0}get text(){return this.ue}set text(t){let e=this.ue;t!=null?t=t.toString():t="",e!==t&&(this.ue=t,this.f(),this.t("text",e,t))}get textAlign(){return this.tt!==null?this.tt.j0:"start"}set textAlign(t){let e=this.textAlign;e!==t&&(t==="start"||t==="end"||t==="left"||t==="right"||t==="center")&&(this.Rs().j0=t,this.N(),this.t("textAlign",e,t))}get flip(){return this.tt!==null?this.tt.go:0}set flip(t){let e=this.flip;e!==t&&(this.Rs().go=t,this.N(),this.t("flip",e,t))}get verticalAlignment(){return this.tt!==null?this.tt.hl:T.Top}set verticalAlignment(t){let e=this.verticalAlignment;e.equals(t)||(t=t.C(),this.Rs().hl=t,this.Pf(),this.t("verticalAlignment",e,t))}get naturalBounds(){if(!this.Ke.isReal()){let t=nt.l();this.sN(this.ue,999999,t);let e=t.width;nt.i(t);let i=this.CD(e),s=this.desiredSize;isNaN(s.width)||(e=s.width),isNaN(s.height)||(i=s.height),this.Ke.Kn(e,i)}return this.Ke}get isMultiline(){return(this.n&2097152)!==0}set isMultiline(t){let e=(this.n&2097152)!==0;e!==t&&(this.n=this.n^2097152,this.f(),this.t("isMultiline",e,t))}get isUnderline(){return(this.n&4194304)!==0}set isUnderline(t){let e=(this.n&4194304)!==0;e!==t&&(this.n=this.n^4194304,this.Zi(!0),this.N(),this.t("isUnderline",e,t))}get isStrikethrough(){return(this.n&8388608)!==0}set isStrikethrough(t){let e=(this.n&8388608)!==0;e!==t&&(this.n=this.n^8388608,this.Zi(!0),this.N(),this.t("isStrikethrough",e,t))}get wrap(){return this.tt!==null?this.tt.W0:2}set wrap(t){let e=this.wrap;e!==t&&(this.Rs().W0=t,this.f(),this.t("wrap",e,t))}get overflow(){return this.tt!==null?this.tt.J0:0}set overflow(t){let e=this.overflow;e!==t&&(this.Rs().J0=t,this.f(),this.t("overflow",e,t))}get isOverflowed(){return(this.n&16777216)!==0}nN(t){t?this.n|=16777216:this.n&=-16777217}get stroke(){return this.Qe}set stroke(t){let e=this.Qe;e!==t&&(t!==null&&R.Cd(t,"TextBlock.stroke"),t instanceof R&&t.k(),this.Qe=t,typeof t!="string"&&this.xf(),this.N(),this.t("stroke",e,t))}get lineCount(){return this.Pi}get lineHeight(){return this.$0()}get editable(){return(this.n&1048576)!==0}set editable(t){let e=(this.n&1048576)!==0;e!==t&&(this.n=this.n^1048576,this.t("editable",e,t))}get HC(){return(this.n&33554432)!==0}set HC(t){this.n=this.n^33554432}get textEditor(){return this.tt!==null?this.tt.Z0:null}set textEditor(t){let e=this.textEditor;e!==t&&(this.Rs().Z0=t,this.t("textEditor",e,t))}get errorFunction(){return this.tt!==null?this.tt.gs:null}set errorFunction(t){let e=this.errorFunction;e!==t&&(t!==null&&m.S(t,lt,"errorFunction"),this.Rs().gs=t,this.t("errorFunction",e,t))}get interval(){return this.K!==null?this.K.Ff:1}set interval(t){let e=this.interval;if(t=Math.round(t),e!==t&&t!==0&&isFinite(t)){this.K===null&&(this.K=new be),this.K.Ff=t,this.f();let i=this.panel;i!==null&&(i.ds=null),this.t("interval",e,t)}}get graduatedStart(){return this.K!==null?this.K.Rf:0}set graduatedStart(t){let e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Rf=t,this.f(),this.t("graduatedStart",e,t))}get graduatedEnd(){return this.K!==null?this.K.Of:1}set graduatedEnd(t){let e=this.graduatedEnd;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new be),this.K.Of=t,this.f(),this.t("graduatedEnd",e,t))}get graduatedFunction(){return this.K!==null?this.K.Q0:null}set graduatedFunction(t){let e=this.graduatedFunction;e!==t&&(t!==null&&m.S(t,lt,"graduatedFunction"),this.K===null&&(this.K=new be),this.K.Q0=t,this.f(),this.t("graduatedFunction",e,t))}get graduatedSkip(){return this.K!==null?this.K.If:null}set graduatedSkip(t){let e=this.graduatedSkip;e!==t&&(t!==null&&m.S(t,lt,"graduatedSkip"),this.K===null&&(this.K=new be),this.K.If=t,this.f(),this.t("graduatedSkip",e,t))}Sa(t,e){if(this.Qe===null||this.ue.length===0||this.vn===null)return;let i=this.naturalBounds,s=this.actualBounds,n=i.width,o=i.height,r=this.$0(),a=t.textAlign=this.textAlign,h=e.rd;a==="start"?a=h?"right":"left":a==="end"&&(a=h?"left":"right");let l=this.isUnderline,u=this.isStrikethrough;this.kn(t,this.Qe,!0,!1,i,s),(l||u)&&this.kn(t,this.Qe,!1,!1,i,s);let c=0,d=0,f=n,p=!1;e.Wt===t&&!(e.Wt instanceof ae)&&!this.HC&&e.getRenderingHint("textGreeking")===!0&&r*this.Th*e.scale<3&&(p=!0);let g=this.spacingAbove,y=this.spacingBelow;switch(this.flip){case 0:break;case 2:t.translate(n,0),t.scale(-1,1);break;case 1:t.translate(0,o),t.scale(1,-1);break;case 3:t.translate(n,o),t.scale(-1,-1);break}t.commitTransform();let b=this.Pi,v=(g+r+y)*b;if(o>v){let w=this.verticalAlignment;d=w.y*o-w.y*v+w.offsetY}if(lt.tk&&(t.letterSpacing=this.letterSpacing,t.wordSpacing=this.wordSpacing),b===1&&this.Rn!==null){let w=this.pe;w>f&&(w=f),d+=g,this.ND(this.Rn,t,c,d,f,r,w,p,a,l,u)}else if(this.Ui!==null&&this.we!==null)for(let w=0;w<b;w++){let k=this.Ui[w];k>f&&(k=f),d+=g,this.ND(this.we[w],t,c,d,f,r,k,p,a,l,u),d+=r+y}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-n,0);break;case 1:t.scale(1,-1),t.translate(0,-o);break;case 3:t.scale(-1,-1),t.translate(-n,-o);break}}ND(t,e,i,s,n,o,r,a,h,l,u){let c=0;if(a){h==="left"?c=0:h==="right"?c=n-r:h==="center"&&(c=(n-r)/2);let p=e.globalAlpha;e.globalAlpha=p/2,e.fillRect(i+c,s+o/4,r,o/2),e.globalAlpha=p;return}h==="left"?c=0:h==="right"?c=n:h==="center"&&(c=n/2);let d=lt.Q1!==null?lt.Q1(this,o):o*.75;e.fillText(t,i+c,s+d);let f=o/20|0;if(f===0&&(f=1),h==="right"?c-=r:h==="center"&&(c-=r/2),l){let p=lt._1!==null?lt._1(this,o):o*.8;this.LD(i+c,s+p,i+c+r,s+p,f,e),e instanceof ae&&e.lastCreatedElement.classList.add("gojs-td")}if(u){let p=s+o-o/2.2|0;f%2!==0&&(p+=.5),this.LD(i+c,p,i+c+r,p,f,e),e instanceof ae&&e.lastCreatedElement.classList.add("gojs-td")}}LD(t,e,i,s,n,o){o.beginPath(),o.lineWidth=n,o.moveTo(t,e),o.lineTo(i,s),o.stroke(),o.endPath()}wf(t,e,i){if(!super.wf(t,e,i))return!1;if(this.kn(t,this.Qe,!0,!1,this.naturalBounds,this.actualBounds),i){if(this.svg.getElementsByTagName("text").length===0)return!0;let s=this.svg.getElementsByClassName("gojs-td");for(let n=0;n<s.length;n++)t.setFillOrStrokeInPlace(s[n],!1)}else this.aE(this.svg,this.we?this.we[0]:this.text,t);return!0}aE(t,e,i){t.innerHTML=e,i.setFillOrStrokeInPlace(t,!0)}Sd(t){return this.lineCount>1||this.isUnderline||this.isStrikethrough?!0:super.Sd(t)}NC(t,e){if(t.nodeName!=="g")t.setAttributeNS(null,"filter",e);else{let i=t.getElementsByTagName("text");for(let s=0;s<i.length;s++)i[s].setAttributeNS(null,"filter",e)}}hE(){this.Fn=0,this.pe=0,this.uo=null,this.Ui=null,this.we=null,this.Rn=null}kd(t,e,i,s){let n=this.Pi;this.Yl=t,this.nN(!1);let o=this.vn;lt.us!==null&&(lt.AD!==o&&(lt.us.font=o,lt.AD=o),lt.tk&&(lt.us.letterSpacing=this.letterSpacing,lt.us.wordSpacing=this.wordSpacing)),this.hE();let r=0,a=0;isNaN(this.desiredSize.width)?(r=this.cE(),r=Math.min(r,t/this.scale)):r=this.desiredSize.width,this.panel!==null&&(r=Math.min(r,this.panel.maxSize.width)),a=this.CD(r),isNaN(this.desiredSize.height)?a=Math.min(a,e/this.scale):a=this.desiredSize.height,this.fE(t,a),(this.wrap===1||isNaN(this.desiredSize.width))&&(r=isNaN(t)?this.pe:Math.min(t,this.pe)),r=Math.max(i,r),a=Math.max(s,a),this.Ke.Kn(r,a),this.ro(0,0,r,a),this.svg!==null&&n!==this.Pi&&this.Zi(!0)}ka(t,e,i,s){this.commonArrange(t,e,i,s)}On(t,e){this.Rn===null?(this.Rn=t,this.pe=e):((this.we===null||this.Ui===null)&&(this.we=[],this.Ui=[],this.we.push(this.Rn),this.Ui.push(this.pe)),this.we.push(t),this.Ui.push(e),this.we.length>this.maxLines&&(this.n|=16777216))}sN(t,e,i){let s=this.formatting===0;s&&(t=t.trim());let n=0,o=0,r=0,a=this.vn,h=this.spacingAbove+this.spacingBelow,l=Math.max(0,this.$0()+h),u=this.overflow===1?this.TD(a):0;if(this.Pi>=this.maxLines){i!==void 0&&i.e(0,l);return}let c=t;if(this.wrap===0){if(this.Fn=1,o=this.getStringWidth(t),u===0||o<=e){this.pe=Math.max(this.pe,o),this.On(t,this.pe),i!==void 0&&i.e(o,l);return}let f=this.qd(c);c=c.substring(f.length);let p=this.qd(c);for(o=this.getStringWidth(f+p),r=0;p.length>0&&o<=e;){f+=p,c=c.substring(p.length),p=this.qd(c),r=o;let g=f+p;s&&(g=g.trim()),o=this.getStringWidth(g)}for(s&&(p=p.trim()),f+=p,e=Math.max(1,e-u);this.getStringWidth(f)>e&&f.length>1;)f=f.substring(0,f.length-1);this.nN(!0),f+=lt.q0,r=this.getStringWidth(f),this.pe=r,this.On(f,r),i!==void 0&&i.e(r,l);return}let d=0;for(c.length===0&&(d=1,this.On(c,0));c.length>0;){let f=this.qd(c);for(c=c.substring(f.length);this.getStringWidth(f)>e;){let y=1;for(o=this.getStringWidth(f.substring(0,y)),r=0;o<=e;)y++,r=o,o=this.getStringWidth(f.substring(0,y));let b=0;y===1?(b=o,n=Math.max(n,o)):(b=r,n=Math.max(n,r)),y--,y<1&&(y=1);let v=f.substring(0,y);if(this.On(v,b),d++,f=f.substring(y),this.Pi+d>this.maxLines)break}let p=this.qd(c);for(o=this.getStringWidth(f+p),r=0;p.length>0&&o<=e;){f+=p,c=c.substring(p.length),p=this.qd(c),r=o;let y=f+p;s&&(y=y.trim()),o=this.getStringWidth(y)}if(s&&(f=f.trim()),f==="")continue;f[f.length-1]==="\xAD"&&(f=f.substring(0,f.length-1)+"\u2010");let g=0;if(p.length===0?(g=o,n=Math.max(n,o)):(r=this.getStringWidth(f),g=r,n=Math.max(n,r)),this.On(f,g),d++,this.Pi+d>this.maxLines)break}this.Fn=Math.min(this.maxLines-this.Pi,d),this.pe=Math.max(this.pe,n),i!==void 0&&i.e(this.pe,l*this.Fn)}fE(t,e){if(this.pe===0||this.Ui===null||this.we===null||this.overflow!==1)return;let i=this.vn,s=this.overflow===1?this.TD(i):0,n=this.spacingAbove+this.spacingBelow,o=Math.max(0,this.$0()+n),r=Math.min(this.maxLines-1,Math.max(Math.floor(e/o+.01)-1,0));if(r+1>=this.we.length)return;this.nN(!0);let a=this.we[r],h=Math.max(1,t-s);for(;this.getStringWidth(a)>h&&a.length>1;)a=a.substring(0,a.length-1);a+=lt.q0;let l=this.getStringWidth(a);this.we[r]=a,this.we=this.we.slice(0,r+1),this.Ui[r]=l,this.Ui=this.Ui.slice(0,r+1),this.Fn=this.we.length,this.pe=Math.max(this.pe,l),this.Pi=this.Fn,this.Pi===1&&(this.Rn=this.we[0])}qd(t){if(this.wrap===3)return t.substring(0,1);let e=t.length,i=0,s=lt.uE;for(;i<e&&!s.test(t.charAt(i));)i++;for(this.formatting===1&&(e=Math.min(e,i+1));i<e&&s.test(t.charAt(i));)i++;return i>=t.length?t:t.substring(0,i)}getStringWidth(t){return lt.us===null?t.length*8:lt.us.measureText(t).width}$0(){if(this.uo!==null)return this.uo;let t=this.vn,e=0;if(lt.us===null)return e=16,this.uo=e,e;if(lt.oN[t]!==void 0&<.DD<5e3)e=lt.oN[t];else{lt.us.letterSpacing="0px";let i=lt.us.measureText("M");lt.us.letterSpacing=this.letterSpacing,e=i.width*1.3,lt.oN[t]=e,lt.DD++}return this.uo=e,e}TD(t){if(lt.us===null)return 6;let e=0;return lt.Z1[t]!==void 0&<.iN<5e3?e=lt.Z1[t]:(e=lt.us.measureText(lt.q0).width,lt.Z1[t]=e,lt.iN++),e}ek(t,e){return t.indexOf(`
|
|
8
8
|
`,e)}CD(t){let e=this.ue.replace(/\r\n/g,`
|
|
9
9
|
`).replace(/\r/g,`
|
|
10
10
|
`),i=this.spacingAbove+this.spacingBelow,s=Math.max(0,this.$0()+i);if(e.length===0)return this.pe=0,this.Pi=1,s;if(!this.isMultiline){let h=this.ek(e,0);h>=0&&(e=e.substring(0,h))}let n=0;this.Pi=0;let o=0,r=-1,a=!1;for(;!a;){if(r=this.ek(e,o),r===-1&&(r=e.length,a=!0),o<=r){let h=e.substring(o,r);if(this.wrap!==0){this.Fn=0;let l=nt.l();this.sN(h,t,l),n+=l.height,nt.i(l),this.Pi+=this.Fn}else this.sN(h,t),n+=s,this.Pi++;this.Pi===this.maxLines&&(a=!0)}o=r+1}return this.Yp=n,n}cE(){let t=this.ue.replace(/\r\n/g,`
|
|
@@ -12,7 +12,7 @@ string: ${t}`);break}}let A=k.fm;if(Ne.WL(k),e){let F=A.figures.iterator;for(;F.
|
|
|
12
12
|
`);if(t.length===0)return 8;if(this.isMultiline){let e=0,i=0,s=!1;for(;!s;){let n=this.ek(t,i);n===-1&&(n=t.length,s=!0);let o=t.substring(i,n);this.formatting===0&&(o=o.trim()),e=Math.max(e,this.getStringWidth(o)),i=n+1}return e}else{let e=this.ek(t,0);return e>=0&&(t=t.substring(0,e)),this.getStringWidth(t)}}get textValidation(){return this.tt!==null?this.tt.Gl:null}set textValidation(t){let e=this.textValidation;e!==t&&(t!==null&&m.S(t,lt,"textValidation"),this.Rs().Gl=t,this.t("textValidation",e,t))}get textEdited(){return this.tt!==null?this.tt._0:null}set textEdited(t){let e=this.textEdited;e!==t&&(t!==null&&m.S(t,lt,"textEdited"),this.Rs()._0=t,this.t("textEdited",e,t))}get spacingAbove(){return this.tt!==null?this.tt.ty:0}set spacingAbove(t){let e=this.spacingAbove;e!==t&&(this.Rs().ty=t,this.f(),this.t("spacingAbove",e,t))}get spacingBelow(){return this.tt!==null?this.tt.ey:0}set spacingBelow(t){let e=this.spacingBelow;e!==t&&(this.Rs().ey=t,this.f(),this.t("spacingBelow",e,t))}get letterSpacing(){return this.tt!==null?this.tt.iy:"0px"}set letterSpacing(t){let e=this.letterSpacing;e!==t&&(lt.tk=!0,this.Rs().iy=t,this.f(),this.t("letterSpacing",e,t))}get wordSpacing(){return this.tt!==null?this.tt.ny:"0px"}set wordSpacing(t){let e=this.wordSpacing;e!==t&&(lt.tk=!0,this.Rs().ny=t,this.f(),this.t("wordSpacing",e,t))}get formatting(){return this.tt!==null?this.tt.ly:0}set formatting(t){let e=this.formatting;e!==t&&(this.Rs().ly=t,this.f(),this.t("formatting",e,t))}get maxLines(){return this.tt!==null?this.tt.hy:1/0}set maxLines(t){let e=this.maxLines;e!==t&&(t=Math.floor(t),t<=0&&m.J(t,"> 0",lt,"maxLines"),this.Rs().hy=t,this.f(),this.t("maxLines",e,t))}getMetrics(){return[this.pe,this.Yl,this.uo,this.Fn,this.Ui,this.we,this.Rn||""]}lE(t){t!==void 0&&(this.pe=t[0],this.Yl=t[1],this.uo=t[2],this.Fn=t[3],this.Ui=t[4],this.we=t[5],this.Rn=t[6])}get metrics(){return{arrSize:this.Ui!==null?this.Ui:[this.pe],arrText:this.we!==null?this.we:[this.Rn],maxLineWidth:this.pe,fontHeight:this.uo}}get choices(){return this.Hd}set choices(t){let e=this.Hd;e!==t&&(this.Hd=t,this.t("choices",e,t))}static uE=new RegExp("[ \u200B\xAD]");static oN=new yt;static DD=0;static Z1=new yt;static iN=0;static q0="...";static AD="";static us=null;static b0=!1;static tk=!1}class Ui{me;gs;go;ly;hy;J0;ty;ey;j0;_0;Z0;Gl;hl;W0;iy;ny;constructor(){this.me=!1,this.gs=null,this.go=0,this.ly=0,this.hy=1/0,this.J0=0,this.ty=0,this.ey=0,this.j0="start",this._0=null,this.Z0=null,this.Gl=null,this.hl=T.Top,this.W0=2,this.iy="0px",this.ny="0px"}copy(){let t=new Ui;return t.gs=this.gs,t.go=this.go,t.ly=this.ly,t.hy=this.hy,t.J0=this.J0,t.ty=this.ty,t.ey=this.ey,t.j0=this.j0,t._0=this._0,t.Z0=this.Z0,t.Gl=this.Gl,t.hl=this.hl,t.W0=this.W0,t.iy=this.iy,t.ny=this.ny,t}}class be{Ff;Rf;Of;Q0;If;constructor(){this.Ff=1,this.Rf=0,this.Of=1,this.Q0=null,this.If=null}copy(){let t=new be;return t.Ff=this.Ff,t.Rf=this.Rf,t.Of=this.Of,t.Q0=this.Q0,t.If=this.If,t}}var ji=(x=>(x[x.None=0]="None",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x[x.UniformToFill=7]="UniformToFill",x))(ji||{});class Bt extends J{cl;sn;fl;Ef;gs;ul;Uf;go;Vf;Bf;R1;constructor(t,e){super(),this.n|=2097152,this.cl=null,this.sn="",this.fl=I.YF,this.Ef=2,this.gs=null,this.ul=null,this.Uf=T.Center,this.go=0,this.Vf=null,this.Bf=null,this.R1=null,typeof t=="string"?this.source=t:t&&Object.assign(this,t),e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.sn=this.sn,t.element=this.cl,t.fl=this.fl.C(),t.Ef=this.Ef,t.go=this.go,t.gs=this.gs,t.ul=this.ul,t.Uf=this.Uf.C(),t.Bf=this.Bf}fe(t){t in ji?this.imageStretch=t:super.fe(t)}toString(){return"Picture("+this.source+")#"+V.xs(this)}get zf(){return(this.n&1048576)!==0}set zf(t){this.zf!==t&&(this.n=this.n^1048576)}get cy(){return(this.n&2097152)!==0}set cy(t){this.cy!==t&&(this.n=this.n^2097152)}get Mn(){return(this.n&4194304)!==0}set Mn(t){this.Mn!==t&&(this.n=this.n^4194304)}static clearCache(t){t===void 0&&(t=""),m.s(t,"string",Bt,"clearCache:url"),t!==""?Bt.fy[t]&&(delete Bt.fy[t],Bt.ik--):(Bt.fy=new yt,Bt.ik=0)}static ST(t,e){e.vD||(e.sk=i=>{Bt.dE(e,i),t.desiredSize.isReal()||(t.xi(!1),t.f())},e.nk=i=>Bt.gE(e,i),e.addEventListener("load",e.sk),e.addEventListener("error",e.nk),e.vD=!0)}static vO(t){t.sk&&t.removeEventListener("load",t.sk),t.nk&&t.removeEventListener("error",t.nk),delete t.sk,delete t.nk,t.vD=!1}get element(){return this.cl}set element(t){let e=this.cl;if(this.Zi(!0),e!==t){let i=Y.isUsingDOM(),s=!1;i&&(this.zf=t instanceof HTMLCanvasElement,s=t instanceof HTMLImageElement,t!==null&&!(s||t instanceof HTMLVideoElement||this.zf)&&m.o("Picture.element must be an instance of Image, Canvas, or Video, not: "+t));let n=this.diagram;n!==null&&n.F2(this),this.cl=t,t!==null&&s&&t.hs===void 0&&(t.hs=new V),n!==null&&s&&n.v2(this),this.t("element",e,t),this.N()}}TO(){let t=this.cl;if(t===null)return;let e=this.desiredSize.isReal();(this.zf||t.complete===!0)&&(t.Np&&(t.uy instanceof Event&&this.gs!==null?this.gs(this,t.uy):t.Mn===!0&&!t.uy&&this.ul!==null&&t.rN&&this.ul(this,t.rN)),t.Mn=!0),t.Mn&&e&&this.diagram!==null&&this.diagram.od.add(this)}mE(){if(this.cl===null){this.Vf=!1;return}let t=new De(null)._t;try{t.drawImage(this.cl,0,0)}catch{this.cy=!1}try{t.getImageData(0,0,1,1).data[3]&&(this.Vf=!1),this.Vf=!1}catch{this.Vf=!0}}get source(){return this.sn}set source(t){let e=this.sn;if(e!==t){this.Zi(!0),m.s(t,"string",Bt,"source"),this.sn=t;let i=Bt.fy,s=null;if(i[t]!==void 0)s=i[t];else if(t!==""){Bt.ik>30&&(Bt.clearCache(),i=Bt.fy),s=m.Ci("img"),s.Np=!0,Bt.ST(this,s);let n=this.Bf;n!==null&&(s.crossOrigin=n(this)),s.src=t,i[t]=s,Bt.ik++}this.element=s,s!==null&&s.__goCache===void 0&&(s.__goCache=new Hn),this.f(),this.N(),this.t("source",e,t)}}static dE(t,e){t.Mn=!0,t.uy=!1;let i,s=t.hs.copy();if(s==null)return;let n=s.iterator;for(;n.next();){let o=n.value;o.N();let r=t.getAttribute("src")||"",a=o.la.get(r);if(a===null)continue;let h=a.length;for(let l=0;l<h;l++)i=a[l],i.desiredSize.isReal()||o.od.add(i),i.Zi(!0),o.requestUpdate(),t.Np&&(t.rN===void 0&&(t.rN=e),i.ul!==null&&i.ul(i,e))}t.hs.clear()}static gE(t,e){t.uy=e;let i,s=t.hs.copy();if(s==null)return;let n=s.iterator;for(;n.next();){let o=n.value,r=t.getAttribute("src")||"",a=o.la.get(r);if(a===null)continue;let h=a.length,l=m.st();for(let u=0;u<h;u++)l.push(a[u]);if(t.Np)for(let u=0;u<h;u++)i=l[u],i.gs!==null&&i.gs(i,e);m.Z(l)}t.hs.clear()}reloadSource(){if(this.source==="")return;Bt.clearCache(this.source);let t=this.source;this.source="",this.source=t}redraw(){this.N(),this.Zi(!0)}get sourceCrossOrigin(){return this.Bf}set sourceCrossOrigin(t){if(this.Bf!==t){t!==null&&m.S(t,Bt,"sourceCrossOrigin"),this.Bf=t;let e=this.element;if(e!==null){let i=e.getAttribute("src");e.crossOrigin!==void 0&&(t===null&&typeof i=="string"?e.crossOrigin=null:t!==null&&(e.crossOrigin=t(this)),i&&(e.src=i))}}}get sourceRect(){return this.fl}set sourceRect(t){let e=this.fl;e.equals(t)||(t=t.C(),this.fl=t,this.f(),this.t("sourceRect",e,t))}get imageStretch(){return this.Ef}set imageStretch(t){let e=this.Ef;e!==t&&(this.Ef=t,this.N(),this.t("imageStretch",e,t))}get flip(){return this.go}set flip(t){let e=this.go;e!==t&&(this.go=t,this.N(),this.t("flip",e,t))}get imageAlignment(){return this.Uf}set imageAlignment(t){let e=this.Uf;e.equals(t)||(t=t.C(),this.Uf=t,this.N(),this.t("imageAlignment",e,t))}get errorFunction(){return this.gs}set errorFunction(t){let e=this.gs;e!==t&&(t!==null&&m.S(t,Bt,"errorFunction"),this.gs=t,this.t("errorFunction",e,t))}get successFunction(){return this.ul}set successFunction(t){let e=this.ul;e!==t&&(t!==null&&m.S(t,Bt,"successFunction"),this.ul=t,this.t("successFunction",e,t))}Sa(t,e){let i=this.cl;if(i===null)return;let s=i.getAttribute("src"),n=Y.isUsingDOM();if(n&&i instanceof HTMLImageElement&&(s===null||s==="")||i.uy instanceof Event&&t instanceof ci)return;let o=t instanceof ae,r=this.naturalBounds,a=0,h=0,l=this.zf,u=l?+i.width:i.naturalWidth,c=l?+i.height:i.naturalHeight;if(u===void 0&&i.videoWidth&&(u=i.videoWidth),c===void 0&&i.videoHeight&&(c=i.videoHeight),n){if(u===0||c===0)return}else u=this.width,c=this.height;let d=u,f=c;this.sourceRect.isReal()&&(a=this.fl.x,h=this.fl.y,u=this.fl.width,c=this.fl.height);let p=u,g=c,y=this.Ef,b=this.Uf;switch(y){case 0:if(this.sourceRect.isReal())break;p>=r.width&&(a=a+b.offsetX+(p*b.x-r.width*b.x)),g>=r.height&&(h=h+b.offsetY+(g*b.y-r.height*b.y)),u=Math.min(r.width,p),c=Math.min(r.height,g);break;case 2:p=r.width,g=r.height;break;case 6:case 7:let E=0;y===6?(E=Math.min(r.height/g,r.width/p),p*=E,g*=E):y===7&&(E=Math.max(r.height/g,r.width/p),p*=E,g*=E,p>=r.width&&(a=(a+b.offsetX+(p*b.x-r.width*b.x)/p)*u),g>=r.height&&(h=(h+b.offsetY+(g*b.y-r.height*b.y)/g)*c),u*=1/(p/r.width),c*=1/(g/r.height),p=r.width,g=r.height);break}let v=u*c,w=this.getDocumentScale()*e.scale,k=p*w,S=g*w,N=k*S,D=v/N,L=i.__goCache,M=null,A=Bt.pE;if(!o){if(i.Mn&&L!==void 0&&d<8e3&&f<8e3&&N>4&&D>A*A){L.Bt===null&&(L.FD(4,d,f,i),L.FD(16,d,f,i));let E=L.Bt,B=E.length;for(let X=0;X<B&&E[X].jd*E[X].jd<D;X++)M=E[X]}if(!e.nd&&(this.Vf===null&&this.mE(),this.Vf))return}let F=p<r.width?b.offsetX+(r.width*b.x-p*b.x):0,O=g<r.height?b.offsetY+(r.height*b.y-g*b.y):0;switch(this.flip){case 0:break;case 2:t.translate(Math.min(r.width,p),0),t.scale(-1,1);break;case 1:t.translate(0,Math.min(r.height,g)),t.scale(1,-1);break;case 3:t.translate(Math.min(r.width,p),Math.min(r.height,g)),t.scale(-1,-1);break}if(t.commitTransform(),e.getRenderingHint("pictureRatioOptimization")&&!e.mh&&L!==void 0&&M!==null&&M.jd!==1){t.save();let E=M.jd;try{t.drawImage(M.sn,a/E,h/E,Math.min(M.sn.width,u/E),Math.min(M.sn.height,c/E),F,O,Math.min(r.width,p),Math.min(r.height,g)),t instanceof ae&&(this.R1=[a/E,h/E,Math.min(M.sn.width,u/E),Math.min(M.sn.height,c/E),F,O,Math.min(r.width,p),Math.min(r.height,g)])}catch{this.cy=!1}t.restore()}else try{t.drawImage(i,a,h,u,c,F,O,Math.min(r.width,p),Math.min(r.height,g)),t instanceof ae&&(this.R1=[a,h,u,c,F,O,Math.min(r.width,p),Math.min(r.height,g)])}catch{this.cy=!1}switch(this.flip){case 0:break;case 2:t.scale(-1,1),t.translate(-Math.min(r.width,p),0);break;case 1:t.scale(1,-1),t.translate(0,-Math.min(r.height,g));break;case 3:t.scale(-1,-1),t.translate(-Math.min(r.width,p),-Math.min(r.height,g));break}}get naturalBounds(){return this.Ke}kd(t,e,i,s){let n=this.desiredSize,o=this.Qs(!0),r=this.cl,a=this.zf,h=0,l=0;(a||!this.Mn&&r&&r.complete)&&(this.Mn=!0),r===null?(isFinite(n.width)||(t=i),isFinite(n.height)||(e=s)):(h=a?+r.width:r.naturalWidth,l=a?+r.height:r.naturalHeight),!isFinite(n.width)&&o!==2&&o!==5?r!==null&&this.Mn!==!1&&(this.sourceRect.isReal()?t=this.sourceRect.width:t=h):(isFinite(t)||(this.sourceRect.isReal()?t=this.sourceRect.width:r!==null&&(t=h)),i=0),!isFinite(n.height)&&o!==2&&o!==4?r!==null&&this.Mn!==!1&&(this.sourceRect.isReal()?e=this.sourceRect.height:e=l):(isFinite(e)||(this.sourceRect.isReal()?e=this.sourceRect.height:r!==null&&(e=l)),s=0),isFinite(n.width)&&(t=n.width),isFinite(n.height)&&(e=n.height);let u=this.maxSize,c=this.minSize;i=Math.max(i||0,c.width),s=Math.max(s||0,c.height),t=Math.min(u.width,t),e=Math.min(u.height,e),t=Math.max(i,t),e=Math.max(s,e),r!==null&&!r.complete&&(isFinite(t)||(t=0),isFinite(e)||(e=0)),this.Ke.Kn(t,e),this.ro(0,0,t,e)}ka(t,e,i,s){this.commonArrange(t,e,i,s)}static fy=new yt;static ik=0;static pE=4}class Hn{Bt;constructor(){this.Bt=null}FD(t,e,i,s){this.Bt===null&&(this.Bt=[]);let n=new De(null),o=n._t,r=1/t;if(n.width=e/t,n.height=i/t,n.width===0||n.height===0)return;let a=new Wn(n.bt,t),h=s,l=1;if(this.Bt.length>0){let u=this.Bt[this.Bt.length-1];h=u.sn,l=u.jd}o.setTransform(r*l,0,0,r*l,0,0),o.commitTransform(),o.drawImage(h,0,0),this.Bt.push(a)}}class Wn{sn;jd;constructor(t,e){this.sn=t,this.jd=e}}class Ne{Ne;fm;constructor(){this.fm=new wt,this.Ne=null}Ue(t){t!==null?(this.fm=t,t.figures.clear()):this.fm=new wt,this.Ne=null}Au(t,e,i,s,n,o){if(s!==void 0&&s===!0){let r=new mt(1);r.endX=t,r.endY=e,this.Ne.segments.add(r)}else this.Ne=new zt,this.Ne.startX=t,this.Ne.startY=e,this.Ne.isFilled=i,this.Ne.isEvenOdd=o||!1,this.fm.figures.add(this.Ne);n!==void 0&&(this.Ne.isShadowed=n)}tR(){let t=this.Ne.segments.length;t>0&&this.Ne.segments.elt(t-1).close()}eR(){this.Ne.segments.length>0&&(this.Ne.isFilled=!0)}iR(t){this.Ne.isShadowed=t}XU(t){this.Ne.isEvenOdd=t}ZF(t,e,i){i===void 0&&(i=!1);let s=new mt(1);s.endX=t,s.endY=e,i&&s.close(),this.Ne.segments.add(s)}Ks(t,e,i){i===void 0&&(i=!1);let s=new mt(2);s.endX=t,s.endY=e,i&&s.close(),this.Ne.segments.add(s)}wr(t,e,i,s,n,o,r){r===void 0&&(r=!1);let a=new mt(3);a.point1X=t,a.point1Y=e,a.point2X=i,a.point2Y=s,a.endX=n,a.endY=o,r&&a.close(),this.Ne.segments.add(a)}Tu(t,e,i,s,n){n===void 0&&(n=!1);let o=new mt(4);o.point1X=t,o.point1Y=e,o.endX=i,o.endY=s,n&&o.close(),this.Ne.segments.add(o)}QF(t,e,i,s,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);let a=new mt(5);a.startAngle=t,a.sweepAngle=e,a.centerX=i,a.centerY=s,a.radiusX=n,o!==0?a.radiusY=o:a.radiusY=n,r&&a.close(),this.Ne.segments.add(a)}_F(t,e,i,s,n,o,r,a){a===void 0&&(a=!1);let h=new mt(6,o,r,t,e,i,s,n);a&&h.close(),this.Ne.segments.add(h)}static lN=null;static jL(t){let e=Ne.lN;if(e!==null)return Ne.lN=null,e.Ue(t),e;{let i=new Ne;return i.Ue(t),i}}static WL(t){Ne.lN=t}}{let x=function(n,o){let r=n.toLowerCase(),a=C.jn;a[n]=o,a[r]=n};x("Rectangle",(n,o,r)=>{let a="r"+o+","+r,h=C.pr[a];return h!==void 0||(h=new wt(2),h.endX=o,h.endY=r,C.yr<C.lm&&(C.pr[a]=h,C.yr++)),h}),x("Square",(n,o,r)=>{let a="s"+o+","+r,h=C.pr[a];return h!==void 0||(h=new wt(2),h.endX=o,h.endY=r,h.defaultStretch=6,C.yr<C.lm&&(C.pr[a]=h,C.yr++)),h});let t=(n,o,r,a,h)=>{(isNaN(a)||a<0)&&(a=5),isNaN(h)&&(h=15);let l="rr"+o+","+r+","+a+","+h,u=C.pr[l];if(u!==void 0)return u;let c=a;(h&1)===1?(c=Math.min(c,(h&2)===2?o/3:o),c=Math.min(c,(h&8)===8?r/3:r)):c=0;let d=new zt(c,0,!0);u=new wt().add(d);let f=T.TopLeft.copy(),p=T.BottomRight.copy();if((h&2)===2){let g=a;g=Math.min(g,(h&1)===1?o/3:o),g=Math.min(g,(h&4)===4?r/3:r);let y=g*C.Hn;d.add(new mt(2,o-g,0)).add(new mt(3,o,g,o-y,0,o,y)),f.offsetY=y,p.offsetX=-y}else d.add(new mt(2,o,0));if((h&4)===4){let g=a;g=Math.min(g,(h&8)===8?o/3:o),g=Math.min(g,(h&2)===2?r/3:r);let y=g*C.Hn;d.add(new mt(2,o,r-g)).add(new mt(3,o-g,r,o,r-y,o-y,r)),p.offsetX=-y,p.offsetY=-y}else d.add(new mt(2,o,r));if((h&8)===8){let g=a;g=Math.min(g,(h&4)===4?o/3:o),g=Math.min(g,(h&1)===1?r/3:r);let y=g*C.Hn;d.add(new mt(2,g,r)).add(new mt(3,0,r-g,y,r,0,r-y)),f.offsetX=y,p.offsetY=-y}else d.add(new mt(2,0,r));if((h&1)===1){let g=c*C.Hn;d.add(new mt(2,0,c)).add(new mt(3,c,0,0,g,g,0).close()),f.offsetX=g,f.offsetY=g}else d.add(new mt(2,0,0).close());return u.spot1=f,u.spot2=p,C.yr<C.lm&&(C.pr[l]=u,C.yr++),u};x("RoundedRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN,h=n?n.parameter2:NaN;return t(n,o,r,a,h)}),x("Border","RoundedRectangle"),x("RoundedTopRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,3)}),x("RoundedBottomRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,12)}),x("RoundedLeftRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,9)}),x("RoundedRightRectangle",(n,o,r)=>{let a=n?n.parameter1:NaN;return t(n,o,r,a,6)}),x("Ellipse",(n,o,r)=>{let a="e"+o+","+r,h=C.pr[a];return h!==void 0||(h=new wt(3),h.endX=o,h.endY=r,h.spot1=T.LP,h.spot2=T.AP,C.yr<C.lm&&(C.pr[a]=h,C.yr++)),h}),x("Circle",(n,o,r)=>{let a="c"+o+","+r,h=C.pr[a];return h!==void 0||(h=new wt(3),h.endX=o,h.endY=r,h.spot1=T.LP,h.spot2=T.AP,h.defaultStretch=6,C.yr<C.lm&&(C.pr[a]=h,C.yr++)),h}),x("TriangleRight",(n,o,r)=>new wt().add(new zt(0,0).add(new mt(2,o,.5*r)).add(new mt(2,0,r).close())).setSpots(0,.25,.5,.75)),x("TriangleDown",(n,o,r)=>new wt().add(new zt(0,0).add(new mt(2,o,0)).add(new mt(2,.5*o,r).close())).setSpots(.25,0,.75,.5)),x("TriangleLeft",(n,o,r)=>new wt().add(new zt(o,r).add(new mt(2,0,.5*r)).add(new mt(2,o,0).close())).setSpots(.5,.25,1,.75)),x("TriangleUp",(n,o,r)=>new wt().add(new zt(o,r).add(new mt(2,0,r)).add(new mt(2,.5*o,0).close())).setSpots(.25,.5,.75,1)),x("Triangle","TriangleUp"),x("Diamond",(n,o,r)=>new wt().add(new zt(.5*o,0).add(new mt(2,0,.5*r)).add(new mt(2,.5*o,r)).add(new mt(2,o,.5*r).close())).setSpots(.25,.25,.75,.75)),x("LineH",(n,o,r)=>{let a=new wt(1);return a.startX=0,a.startY=r/2,a.endX=o,a.endY=r/2,a}),x("LineV",(n,o,r)=>{let a=new wt(1);return a.startX=o/2,a.startY=0,a.endX=o/2,a.endY=r,a}),x("None","Rectangle"),x("BarH","Rectangle"),x("BarV","Rectangle"),x("MinusLine","LineH"),x("PlusLine",(n,o,r)=>new wt().add(new zt(0,r/2,!1).add(new mt(2,o,r/2)).add(new mt(1,o/2,0)).add(new mt(2,o/2,r)))),x("XLine",(n,o,r)=>new wt().add(new zt(0,r,!1).add(new mt(2,o,0)).add(new mt(1,0,0)).add(new mt(2,o,r)))),x("LineRight",(n,o,r)=>new wt().add(new zt(.25*o,0,!1).add(new mt(2,.75*o,.5*r)).add(new mt(2,.25*o,r)))),x("LineDown",(n,o,r)=>new wt().add(new zt(0,.25*r,!1).add(new mt(2,.5*o,.75*r)).add(new mt(2,o,.25*r)))),x("LineLeft",(n,o,r)=>new wt().add(new zt(.75*o,0,!1).add(new mt(2,.25*o,.5*r)).add(new mt(2,.75*o,r)))),x("LineUp",(n,o,r)=>new wt().add(new zt(0,.75*r,!1).add(new mt(2,.5*o,.25*r)).add(new mt(2,o,.75*r)))),x("Capsule",(n,o,r)=>{let a=new wt;if(o<r){let h=o/2,l=new zt(0,h,!0);a.add(l),l.add(new mt(5,180,180,h,h,h,h)),l.add(new mt(2,o,r-h)),l.add(new mt(5,0,180,h,r-h,h,h)),l.add(new mt(2,0,h));let u=isFinite(n.parameter1)?n.parameter1:o*.156;return a.setSpots(0,0,1,1,0,u,0,-u),a}else if(o>r){let h=r/2,l=new zt(h,0,!0);a.add(l),l.add(new mt(2,o-h,0)),l.add(new mt(5,270,180,o-h,h,h,h)),l.add(new mt(2,h,r)),l.add(new mt(5,90,180,h,h,h,h));let u=isFinite(n.parameter1)?n.parameter1:r*.156;return a.setSpots(0,0,1,1,u,0,-u,0),a}else return a.type=3,a.endX=o,a.endY=r,a.spot1=T.LP,a.spot2=T.AP,a});let e=(n,o)=>new zt(n,o,!1,!1),i=(n,o,r)=>n.add(new mt(2,o,r)),s=(n,o,r)=>n.add(new mt(1,o,r));x("Borders",(n,o,r)=>{let a=n?n.parameter1:NaN;isNaN(a)?a=10:a=a&15;let h=new wt,l;return a===10?(l=e(o,0),i(l,o,r),s(l,0,r),i(l,0,0)):a===5?(l=e(0,0),i(l,o,0),s(l,o,r),i(l,0,r)):a===1?(l=e(0,0),i(l,o,0),s(l,o,r)):a===2?(l=e(o,0),i(l,o,r)):a===4?(l=e(o,r),i(l,0,r)):a===8?(l=e(0,r),i(l,0,0),s(l,o,r)):a===3?(l=e(0,0),i(l,o,0),i(l,o,r)):a===6?(l=e(o,0),i(l,o,r),i(l,0,r)):a===12?(l=e(o,r),i(l,0,r),i(l,0,0)):a===9?(l=e(0,r),i(l,0,0),i(l,o,0)):a===7?(l=e(0,0),i(l,o,0),i(l,o,r),i(l,0,r)):a===14?(l=e(o,0),i(l,o,r),i(l,0,r),i(l,0,0)):a===13?(l=e(o,r),i(l,0,r),i(l,0,0),i(l,o,0)):a===11?(l=e(0,r),i(l,0,0),i(l,o,0),i(l,o,r)):a===15?(l=e(0,0),i(l,o,0),i(l,o,r),i(l,0,r),l.add(new mt(2,0,0).close())):(l=e(0,0),s(l,o,r)),h.add(l),h})}C.rm={"":"",Standard:"F1 m 0,0 l 8,4 -8,4 2,-4 z",Backward:"F1 m 8,0 l -2,4 2,4 -8,-4 z",Triangle:"F1 m 0,0 l 8,4.62 -8,4.62 z",BackwardTriangle:"F1 m 8,4 l 0,4 -8,-4 8,-4 0,4 z",Boomerang:"F1 m 0,0 l 8,4 -8,4 4,-4 -4,-4 z",BackwardBoomerang:"F1 m 8,0 l -8,4 8,4 -4,-4 4,-4 z",SidewaysV:"m 0,0 l 8,4 -8,4 0,-1 6,-3 -6,-3 0,-1 z",BackwardV:"m 8,0 l -8,4 8,4 0,-1 -6,-3 6,-3 0,-1 z",OpenTriangle:"m 0,0 l 8,4 -8,4",BackwardOpenTriangle:"m 8,0 l -8,4 8,4",OpenTriangleLine:"m 0,0 l 8,4 -8,4 m 8.5,0 l 0,-8",BackwardOpenTriangleLine:"m 8,0 l -8,4 8,4 m -8.5,0 l 0,-8",OpenTriangleTop:"m 0,0 l 8,4 m 0,4",BackwardOpenTriangleTop:"m 8,0 l -8,4 m 0,4",OpenTriangleBottom:"m 0,8 l 8,-4",BackwardOpenTriangleBottom:"m 0,4 l 8,4",HalfTriangleTop:"F1 m 0,0 l 0,4 8,0 z m 0,8",BackwardHalfTriangleTop:"F1 m 8,0 l 0,4 -8,0 z m 0,8",HalfTriangleBottom:"F1 m 0,4 l 0,4 8,-4 z",BackwardHalfTriangleBottom:"F1 m 8,4 l 0,4 -8,-4 z",ForwardSemiCircle:"m 4,0 b 270 180 0 4 4",BackwardSemiCircle:"m 4,8 b 90 180 0 -4 4",Feather:"m 0,0 l 3,4 -3,4",BackwardFeather:"m 3,0 l -3,4 3,4",DoubleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardDoubleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4",TripleFeathers:"m 0,0 l 3,4 -3,4 m 3,-8 l 3,4 -3,4 m 3,-8 l 3,4 -3,4",BackwardTripleFeathers:"m 3,0 l -3,4 3,4 m 3,-8 l -3,4 3,4 m 3,-8 l -3,4 3,4",ForwardSlash:"m 0,8 l 5,-8",BackSlash:"m 0,0 l 5,8",DoubleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8",DoubleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8",TripleForwardSlash:"m 0,8 l 4,-8 m -2,8 l 4,-8 m -2,8 l 4,-8",TripleBackSlash:"m 0,0 l 4,8 m -2,-8 l 4,8 m -2,-8 l 4,8",Fork:"m 0,4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4",LineFork:"m 0,0 l 0,8 m 0,-4 l 8,0 m -8,0 l 8,-4 m -8,4 l 8,4",BackwardLineFork:"m 8,4 l -8,0 m 8,0 l -8,-4 m 8,4 l -8,4 m 8,-8 l 0,8",CircleFork:"F1 m 6,4 b 0 360 -3 0 3 z m 0,0 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 6,0 b 0 360 -3 0 3",CircleLineFork:"F1 m 6,4 b 0 360 -3 0 3 z m 1,-4 l 0,8 m 0,-4 l 6,0 m -6,0 l 6,-4 m -6,4 l 6,4",BackwardCircleLineFork:"F1 m 0,4 l 6,0 m -6,-4 l 6,4 m -6,4 l 6,-4 m 0,-4 l 0,8 m 7,-4 b 0 360 -3 0 3",Circle:"F1 m 8,4 b 0 360 -4 0 4 z",Block:"F1 m 0,0 l 0,8 8,0 0,-8 z",StretchedDiamond:"F1 m 0,3 l 5,-3 5,3 -5,3 -5,-3 z",Diamond:"F1 m 0,4 l 4,-4 4,4 -4,4 -4,-4 z",Chevron:"F1 m 0,0 l 5,0 3,4 -3,4 -5,0 3,-4 -3,-4 z",StretchedChevron:"F1 m 0,0 l 8,0 3,4 -3,4 -8,0 3,-4 -3,-4 z",NormalArrow:"F1 m 0,2 l 4,0 0,-2 4,4 -4,4 0,-2 -4,0 z",X:"m 0,0 l 8,8 m 0,-8 l -8,8",TailedNormalArrow:"F1 m 0,0 l 2,0 1,2 3,0 0,-2 2,4 -2,4 0,-2 -3,0 -1,2 -2,0 1,-4 -1,-4 z",DoubleTriangle:"F1 m 0,0 l 4,4 -4,4 0,-8 z m 4,0 l 4,4 -4,4 0,-8 z",BigEndArrow:"F1 m 0,0 l 5,2 0,-2 3,4 -3,4 0,-2 -5,2 0,-8 z",ConcaveTailArrow:"F1 m 0,2 h 4 v -2 l 4,4 -4,4 v -2 h -4 l 2,-2 -2,-2 z",RoundedTriangle:"F1 m 0,1 a 1,1 0 0 1 1,-1 l 7,3 a 0.5,1 0 0 1 0,2 l -7,3 a 1,1 0 0 1 -1,-1 l 0,-6 z",SimpleArrow:"F1 m 1,2 l -1,-2 2,0 1,2 -1,2 -2,0 1,-2 5,0 0,-2 2,2 -2,2 0,-2 z",AccelerationArrow:"F1 m 0,0 l 0,8 0.2,0 0,-8 -0.2,0 z m 2,0 l 0,8 1,0 0,-8 -1,0 z m 3,0 l 2,0 2,4 -2,4 -2,0 0,-8 z",BoxArrow:"F1 m 0,0 l 4,0 0,2 2,0 0,-2 2,4 -2,4 0,-2 -2,0 0,2 -4,0 0,-8 z",TriangleLine:"F1 m 8,4 l -8,-4 0,8 8,-4 z m 0.5,4 l 0,-8",CircleEndedArrow:"F1 m 10,4 l -2,-3 0,2 -2,0 0,2 2,0 0,2 2,-3 z m -4,0 b 0 360 -3 0 3 z",DynamicWidthArrow:"F1 m 0,3 l 2,0 2,-1 2,-2 2,4 -2,4 -2,-2 -2,-1 -2,0 0,-2 z",EquilibriumArrow:"m 0,3 l 8,0 -3,-3 m 3,5 l -8,0 3,3",FastForward:"F1 m 0,0 l 3.5,4 0,-4 3.5,4 0,-4 1,0 0,8 -1,0 0,-4 -3.5,4 0,-4 -3.5,4 0,-8 z",Kite:"F1 m 0,4 l 2,-4 6,4 -6,4 -2,-4 z",HalfArrowTop:"F1 m 0,0 l 4,4 4,0 -8,-4 z m 0,8",HalfArrowBottom:"F1 m 0,8 l 4,-4 4,0 -8,4 z",OpposingDirectionDoubleArrow:"F1 m 0,4 l 2,-4 0,2 4,0 0,-2 2,4 -2,4 0,-2 -4,0 0,2 -2,-4 z",PartialDoubleTriangle:"F1 m 0,0 4,3 0,-3 4,4 -4,4 0,-3 -4,3 0,-8 z",LineCircle:"F1 m 0,0 l 0,8 m 7 -4 b 0 360 -3 0 3 z",DoubleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",TripleLineCircle:"F1 m 0,0 l 0,8 m 2,-8 l 0,8 m 2,-8 l 0,8 m 7 -4 b 0 360 -3 0 3 z",CircleLine:"F1 m 6 4 b 0 360 -3 0 3 z m 1,-4 l 0,8",DiamondCircle:"F1 m 8,4 l -4,4 -4,-4 4,-4 4,4 m 8,0 b 0 360 -4 0 4 z",PlusCircle:"F1 m 8,4 b 0 360 -4 0 4 l -8 0 z m -4 -4 l 0 8",OpenRightTriangleTop:"m 8,0 l 0,4 -8,0 m 0,4",OpenRightTriangleBottom:"m 8,8 l 0,-4 -8,0",Line:"m 0,0 l 0,8",DoubleLine:"m 0,0 l 0,8 m 2,0 l 0,-8",TripleLine:"m 0,0 l 0,8 m 2,0 l 0,-8 m 2,0 l 0,8",PentagonArrow:"F1 m 8,4 l -4,-4 -4,0 0,8 4,0 4,-4 z"};var Gs=(x=>(x[x.None=0]="None",x[x.Added=1]="Added",x[x.Removed=2]="Removed",x[x.Shown=4]="Shown",x[x.Hidden=8]="Hidden",x[x.NodeSized=16]="NodeSized",x[x.GroupLayout=32]="GroupLayout",x[x.NodeReplaced=64]="NodeReplaced",x[x.Standard=127]="Standard",x[x.All=16777215]="All",x))(Gs||{});class pt extends G{b;Qo;H;dl;gl;_o;ue;pl;Ta;nn;tr;Wd;IM;RD;gy;my;constructor(t,e){let i;t===void 0||t instanceof Lt||typeof t=="string"?i=t:t&&(e=t),super(i),this.b=2408959,this.Qo="",this.H=null,this.dl="",this.gl=null,this._o=null,this.ue="",this.pl=null,this.Ta=null,this.nn=new P(NaN,NaN).k(),this.tr=null,this.Wd=NaN,this.IM=-1,this.RD=new I,this.gy=null,this.my=NaN,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.b=this.b&-4097|16384|32768,t.Qo=this.Qo,this.H!==null&&(this.H.me?t.H=this.H:t.H=this.H.copy()),t.dl=this.dl,t._o=null,t.ue=this.ue,t.nn.h(this.nn),t.Wd=this.Wd}Ho(t){super.Ho(t),t.Pa(),t.gl=null,t.tr=null,t.gy=null}toString(){let t=m.Yn(this.constructor)+"#"+V.xs(this);return this.data!==null&&(t+="("+m.toString(this.data)+")"),t}static LayoutNone=0;static LayoutAdded=1;static LayoutRemoved=2;static LayoutShown=4;static LayoutHidden=8;static LayoutNodeSized=16;static LayoutGroupLayout=32;static LayoutNodeReplaced=64;static LayoutStandard=127;static LayoutAll=16777215;_e(){return this.H===null?this.H=new Gi:this.H.me&&(this.H=this.H.copy()),this.H}xa(){super.xa(),this.H!==null&&(this.H.me=!0)}gf(t,e,i,s,n,o,r){let a=this.diagram;a!==null&&(t===3&&e==="elements"?n instanceof G?n.Sn(h=>{a.partManager.M2(h,a)}):n instanceof Bt&&a.v2(n):t===4&&e==="elements"&&(n instanceof G?n.Sn(h=>a.partManager.C2(h,a)):n instanceof Bt&&a.F2(n)),a.raiseChangedEvent(t,e,i,s,n,o,r))}updateTargetBindings(t){if(super.updateTargetBindings(t),this.data===null)return;let e=this.D.r,i=e.length;for(let n=0;n<i;n++){let o=e[n];o instanceof G&&o.Sn(r=>{r.data!==null&&r.$I(t)})}let s=this.adornments;for(;s.next();)s.value.updateTargetBindings(t)}Go(){if(super.Go(),this.FC()){let e=this.D.r,i=e.length;for(let s=0;s<i;s++){let n=e[s];n instanceof G&&n.Sn(o=>o.Go())}}let t=this.adornments;for(;t.next();)t.value.Go()}updateRelationshipsFromData(){this.data!==null&&this.diagram?.partManager.updateRelationshipsFromData(this)}get key(){let t=this.diagram;if(t!==null)return t.model.getKeyForNodeData(this.data)}get adornments(){return this._o===null?Pt.instance:this._o.iteratorValues}findAdornment(t){let e=this._o;return e===null?null:e.get(t)}addAdornment(t,e){if(e===null)return;let i=null,s=this._o;if(s!==null&&(i=s.get(t)),i!==e){if(i!==null){let o=i.diagram;o!==null&&o.remove(i)}s===null&&(s=new Mt,this._o=s),e.Qo!==t&&(e.category=t),s.set(t,e);let n=this.diagram;if(n!==null){n.add(e);let o=e.adornedObject;if(o!==null){let r=o.findBindingPanel();r!==null&&(e.data=r.data)}}}}removeAdornment(t){let e=this._o;if(e===null)return;let i=e.get(t);if(i!==null){let s=i.diagram;s!==null&&(s.remove(i),i.data=null)}e.delete(t),e.count===0&&(this._o=null)}clearAdornments(){let t=this._o;if(t===null)return;let e=m.st(),i=t.iterator;for(;i.next();){let n=i.key;e.push(n)}let s=e.length;for(let n=0;n<s;n++)this.removeAdornment(e[n]);m.Z(e)}updateAdornments(){let t=this.diagram;if(t===null)return;this.yE(t),this.wE(t);let e=this.adornments;for(;e.next();){let i=e.value;i.f(),i.hasPlaceholder()&&i.placeholder.f()}for(e=this.adornments;e.next();)e.value.updateTargetBindings()}invalidateAdornments(){let t=this.diagram;t!==null&&(t.Qr(),this.OD()!==!0&&this.ID(!0))}EM(){this.OD()!==!1&&(this.updateAdornments(),this.ID(!1))}yE(t){let e="Selection";if(this.isSelected&&this.selectionAdorned){let i=this.selectionObject;if(i!==null&&this.actualBounds.isReal()&&this.isVisible()&&i.isVisibleObject()&&i.actualBounds.isReal()){let s=this.findAdornment(e);if(s===null){let n=this.selectionAdornmentTemplate;n===null&&(this.Lr()?n=t.linkSelectionAdornmentTemplate:this instanceof ht?n=t.groupSelectionAdornmentTemplate:n=t.nodeSelectionAdornmentTemplate),s=n.copy(),s!==null&&(this.Lr()&&this.selectionObject===this.path&&(s.type=G.Link),s.adornedObject=i)}if(s!==null){s.type===G.Link&&s.f(),this.addAdornment(e,s);return}}}this.removeAdornment(e)}wE(t){let e=this;t.toolManager.mouseDownTools.each(i=>{i.isEnabled&&i.updateAdornments(e)}),t.toolManager.updateAdornments(e)}RM(t){this.pl=t,t===null&&this.gI()}get layer(){return this.pl}get diagram(){let t=this.pl;return t==null?null:t.diagram}get layerName(){return this.dl}set layerName(t){let e=this.dl;if(e===t)return;let i=this.diagram;if(i!==null&&(i.findLayer(t)===null||i.partManager.addsToTemporaryLayer))return;this.dl=t,i!==null&&i.invalidateDocumentBounds(),this.t("layerName",e,t);let s=this.layer;if(s===null||s.name===t||(i=s.diagram,i===null))return;let n=i.findLayer(t);if(n===null||n===s)return;let o=s.ri(-1,this,!0);o>=0&&i.raiseChangedEvent(4,"parts",s,this,null,o,!0),o=n.hh(99999999,this,!0),s.visible!==n.visible&&this.Xe(n.visible),o>=0&&i.raiseChangedEvent(3,"parts",n,null,this,!0,o);let r=this.layerChanged;if(r===null)return;let a=i.G;i.G=!0,r(this,s,n),i.G=a}get layerChanged(){return this.H!==null?this.H.yy:null}set layerChanged(t){let e=this.layerChanged;e!==t&&(t!==null&&m.S(t,pt,"layerChanged"),this._e().yy=t,this.t("layerChanged",e,t))}get zOrder(){return this.Wd}set zOrder(t){let e=this.Wd;if(e===t)return;this.Wd=t;let i=this.layer;i!==null&&i.sb(-1,this),this.t("zOrder",e,t);let s=this.diagram;s!==null&&s.N()}xE(){let t=this.layer;t!==null&&t.sb(-1,this)}ok(){if(this.fa()!==!1)return;this.aN(!0),this.yf();let t=this.diagram;t!==null&&(t.Pp(this),t.requestUpdate())}ED(){if(this.b|=2097152,this.fa()===!1)return;let t=this.position,e=this.location;(!e.isReal()||!t.isReal())&&this.UD(t,e);let i=this.ve,s=I.l().h(i);i.ce(),i.x=t.x,i.y=t.y,i.k(),this.Pd(s,i),I.i(s),this.aN(!1),this.yf()}ro(t,e,i,s){let n=this.hi;n.e(t,e,i,s),this.Me===null&&(this.Me=new Nt);let o=this.Me;o.Ue(),this.zp(o,t,e,i,s),this.Me=o,o.TP()||o.im(n)}zp(t,e,i,s,n){if(this.et!==1&&t.et(this.et),this.Xt===0)return;let o=T.Center;this.locationSpot.isSpot()&&(o=this.locationSpot);let r=P.l();if(this.locationObject!==this){let a=this.locationObject,h=a.naturalBounds;r.setSpot(h.x,h.y,h.width,h.height,o),a.Me!==null&&a.Me.gt(r),r.offset(-a.measuredBounds.x,-a.measuredBounds.y);let l=a.panel;for(;l!==null&&l!==this;)l.Me!==null&&l.Me.gt(r),r.offset(-l.measuredBounds.x,-l.measuredBounds.y),l=l.panel}else r.setSpot(e,i,s,n,o);t.ks(this.Xt,r.x,r.y),P.i(r)}get locationObject(){if(this.tr===null)if(this instanceof vt&&this.type!==G.Link&&this.hasPlaceholder())this.tr=this.placeholder;else{let t=this.locationObjectName;if(t!==""){let e=this.findObject(t);e!==null?this.tr=e:this.tr=this}else this.tr=this}return this.tr?.visible?this.tr:this}get minLocation(){return this.H!==null?this.H.wy:P.DL}set minLocation(t){let e=this.minLocation;e.equals(t)||(t=t.C(),this._e().wy=t,this.t("minLocation",e,t))}get maxLocation(){return this.H!==null?this.H.xy:P.vL}set maxLocation(t){let e=this.maxLocation;e.equals(t)||(t=t.C(),this._e().xy=t,this.t("maxLocation",e,t))}get locationObjectName(){return this.H!==null?this.H.ky:""}set locationObjectName(t){let e=this.locationObjectName;e!==t&&(this._e().ky=t,this.tr=null,this.f(),this.t("locationObjectName",e,t))}get locationSpot(){return this.H!==null?this.H.Py:T.TopLeft}set locationSpot(t){let e=this.locationSpot;e.equals(t)||(t=t.C(),this._e().Py=t,this.f(),this.t("locationSpot",e,t))}move(t,e){e===!0?this.location=t:this.position=t}moveTo(t,e,i){let s=P.z(t,e);this.move(s,i),P.i(s)}isVisible(){if(!this.visible)return!1;let t=this.layer;if(t!==null){if(!t.visible)return!1;let i=t.diagram;if(i!==null&&i.animationManager.Hx(this))return!0}let e=this.containingGroup;return!(e!==null&&(!e.isSubGraphExpanded||!e.isVisible()))}Xe(t){let e=this.diagram;t?(this.invalidateLayout(4),this.invalidateAdornments(),e!==null&&e.Pp(this)):(this.invalidateLayout(8),this.clearAdornments()),this.Pa(),e!==null&&(e.invalidateDocumentBounds(),this instanceof $&&this.canAvoid()&&e.ud(this),e.N())}findObject(t){if(this.name===t)return this;let e=this.gy;if(e===null&&(this.gy=e=new Mt),e.get(t)!==null)return e.get(t);let i=super.findObject(t);return i!==null?(e.set(t,i),i):(e.set(t,null),null)}_p(){this.gy=null}getRelativePoint(t,e,i){i===void 0&&(i=new P);let s=e.isNoSpot()?T.Center:e,n=t.naturalBounds;if(i.e(n.width*s.x+s.offsetX,n.height*s.y+s.offsetY),t===null||t===this)return i;t.v.gt(i);let o=t.panel;for(;o!==null&&o!==this;)o.v.gt(i),o=o.panel;return this.Me!==null&&this.Me.gt(i),i.offset(-this.hi.x,-this.hi.y),i}getDocumentBounds(t){return t===void 0&&(t=new I),t.h(this.actualBounds)}ensureBounds(){this.ht(1/0,1/0),this.Ut()}fD(t){let e=this.locationSpot,i=this.locationObject,s=i.naturalBounds;s.isReal()||(s=I.tm);let n=i instanceof it?i.strokeWidth:0;if(t.setSpot(0,0,s.width+n,s.height+n,e),i!==this){t.offset(-n/2,-n/2),i.v.gt(t);let o=i.panel;for(;o!==null&&o!==this;)o.v.gt(t),o=o.panel}return this.Me!==null&&this.Me.gt(t),t.offset(-this.hi.x,-this.hi.y),t}ah(t,e){let i=e===void 0?this.RD:e,s=this.bE(),n=s*2;if(!this.isShadowed)return i.e(t.x-1-s,t.y-1-s,t.width+2+n,t.height+2+n),i;let o=t.x,r=t.y,a=t.width,h=t.height,l=this.shadowBlur,u=this.shadowOffset;return a+=l,h+=l,o-=l/2,r-=l/2,u.x>0?a+=u.x:(o+=u.x,a-=u.x),u.y>0?h+=u.y:(r+=u.y,h-=u.y),i.e(o-1,r-1,a+2,h+2),i}iE(){return this.type===G.Link&&this instanceof vt&&this.category==="Selection"&&this.adornedObject instanceof it&&this.adornedPart.findMainElement()===this.adornedObject?this.adornedObject.strokeWidth:0}bE(){return isNaN(this.my)&&(this.my=this.wD()),this.my}Df(){this.my=NaN}Ut(){if(this.as()===!1){this.ED();return}this.lo(!1);let t=this.ve,e=I.l();e.h(t);let i=this.Bl();this.ka(0,0,this.hi.width,this.hi.height);let s=this.position;this.UD(s,this.location),t.ce(),t.x=s.x,t.y=s.y,t.k(),this.Pd(e,t),e.equals(t)?this.rs(i):this.Di()&&(!C.c(e.width,t.width)||!C.c(e.height,t.height))&&this.IM>=0&&this.invalidateLayout(16),I.i(e),this.aN(!1)}Pd(t,e){let i=this.diagram;if(i===null)return;let s=!1;if(i.gh===!1&&t.isReal()){let n=I.l();n.h(i.documentBounds),n.subtractMargin(i.padding),t.x>n.x&&t.y>n.y&&t.right<n.right&&t.bottom<n.bottom&&e.x>n.x&&e.y>n.y&&e.right<n.right&&e.bottom<n.bottom&&(s=!0),I.i(n)}(this.kE()===!0||!t.equals(e))&&this.dT(s,i),i.N(),!(!t.isReal()&&!e.isReal()||t.equalsApproxClose(e))&&(this instanceof $&&!i.undoManager.isUndoingRedoing&&this.invalidateConnectedLinks(),this.Pa())}get location(){return this.nn}set location(t){let e=t.x,i=t.y,s=this.nn;(s.x!==e&&(!isNaN(s.x)||!isNaN(e))||s.y!==i&&(!isNaN(s.y)||!isNaN(i)))&&(t=t.copy(),this.PE(t,s)&&this.t("location",s,t.copy()))}PE(t,e){if(this.Lr())return!1;if(this.nn=t,this.b|=2097152,this.as()===!1){this.ok();let i=this.ct;if(i.isReal()){let s=this.diagram;if(s===null||s.animationManager.isTicking||!s.undoManager.isUndoingRedoing){let n=i.copy();i.e(i.x+(t.x-e.x),i.y+(t.y-e.y)),this.VD(s,i,n.x,n.y),this.t("position",n,i.copy())}}}return!0}TC(t,e,i){if(this.Lr()||!t.isReal())return!1;let s=this.diagram;if(s!==null&&this.VD(s,t,e,i),this.ct=t,this.b&=-2097153,this.nn.isReal()&&(s===null||s.animationManager.isTicking||!s.undoManager.isUndoingRedoing)){let n=this.nn;this.nn=new P(n.x+(t.x-e),n.y+(t.y-i)).k(),this.t("location",n,this.nn.copy())}return this.fa()===!1&&this.as()===!1&&(this.ok(),this.ED()),!0}VD(t,e,i,s){if(t===null||this instanceof vt)return;let n=t.animationManager;n.Pe&&n.vA(this,new P(i,s),e,!1)}Uc(t,e,i){let s=this.nn,n=this.ct;if(i){if(s.x===t&&s.y===e)return;this.fa()||this.as()?n.e(NaN,NaN):n.e(n.x+t-s.x,n.y+e-s.y),s.e(t,e)}else{if(n.x===t&&n.y===e)return;s.e(s.x+t-n.x,s.y+e-n.y),n.e(t,e)}this.ok()}DC(){this.b&=-2097153,this.ok()}UD(t,e){let i=this.fD(P.l()),s=this.diagram,n=e.isReal(),o=t.isReal();n&&o?(this.b&2097152)!==0?this.BD(t,e,s,i):this.zD(t,e,s,i):n?this.BD(t,e,s,i):o&&this.zD(t,e,s,i),this.b|=2097152,P.i(i),this.yf()}BD(t,e,i,s){let n=t.x,o=t.y;if(t.e(e.x-s.x,e.y-s.y),i!==null){let r=i.animationManager,a=r.defaultAnimation.isAnimating;!a&&r.Pe&&!(this instanceof vt)&&r.vA(this,new P(n,o),t,!1),!a&&!(t.x===n&&t.y===o)&&this.t("position",new P(n,o),t.copy())}}zD(t,e,i,s){let n=e.copy();e.e(t.x+s.x,t.y+s.y),!e.equals(n)&&i!==null&&this.t("location",n,e.copy())}dT(t,e){this.MC(!1),this instanceof $&&e.ud(this),!this.layer.isTemporary&&!t&&e.invalidateDocumentBounds();let i=this.ve,s=e.viewportBounds;s.isReal()?this.Bl()?(i.UL(s,10)||this.rs(!1),this.updateAdornments()):this.isVisible()&&i.intersectsRect(s)?(this.rs(!0),this.updateAdornments()):this.invalidateAdornments():e.ef=!0}_r(){return!0}Di(){return!0}Lr(){return!1}_s(){return!0}hasPlaceholder(){return!1}get category(){return this.Qo}set category(t){let e=this.Qo;if(e===t)return;this.svg!==null&&(this.svg.remove(),this.Zi(!0));let i=this.diagram,s=this.data,n=null;if(i!==null&&s!==null&&!(this instanceof vt)){let o=i.model.undoManager;o.isEnabled&&!o.isUndoingRedoing&&(n=this.clone(),n.D.addAll(this.D))}if(this.Qo=t,this.t("category",e,t),i!==null&&s!==null&&!(this instanceof vt)){let o=i.model;if(o.undoManager.isUndoingRedoing)return;if(this.Lr()){i.partManager.setLinkCategoryForData(s,t);let r=i.partManager.findLinkTemplateForCategory(t);if(r!==null){r.It();let a=r.copy();a!==null&&this.hN(a,e,t)}}else{o!==null&&o.setCategoryForNodeData(s,t);let r=i.partManager.findTemplateForNodeData(s,t);if(r!==null){r.It();let a=r.copy();if(a!==null&&!(a instanceof j)){let h=this.location.copy();this.hN(a,e,t),this.location.isReal()||(this.location=h)}}}if(n!==null){let r=this.clone();r.D.addAll(this.D),this.t("self",n,r)}}else if(this instanceof vt){let o=this.adornedPart;if(o!==null){let r=o._o;r!==null&&r.delete(e),o.addAdornment(this.category,this)}}}get self(){return this}set self(t){this.hN(t,this.category,t.category)}static XD=!1;hN(t,e,i){t.constructor!==this.constructor&&(pt.XD||(pt.XD=!0,m.ne('Should not change the class of the Part when changing category from "'+e+'" to "'+i+'"'),m.ne(" Old class: "+m.Yn(this.constructor)+", new class: "+m.Yn(t.constructor)+", part: "+this.toString()))),this.clearAdornments();let s=this.data,n=this.layerName,o=this.isSelected,r=this.isHighlighted,a=!0,h=!0,l=!1;this instanceof $&&(a=this.isTreeLeaf,h=this.isTreeExpanded,l=this.wasTreeExpanded),this.rI(),t.Ho(this),t.jT(this),t.cloneProtected(this),this.Qo=i,this.svg!==null&&(this.svg.remove(),this.Wc(),this.Zi(!0)),this.f(),this.N();let u=this.diagram,c=!0;u!==null&&(c=u.skipsUndoManager,u.skipsUndoManager=!0),this.te=s,this.b=o?this.b|4096:this.b&-4097,this.b=r?this.b|524288:this.b&-524289,this instanceof $&&(this.E=a?this.E|4:this.E&-5,this.E=h?this.E|1:this.E&-2,this.E=l?this.E|2:this.E&-3),s!==null&&this.updateTargetBindings();let d=this.layerName;d!==n&&(this.dl=n,this.layerName=d),u!==null&&(u.skipsUndoManager=c),this.Di()&&this.invalidateLayout(64)}canCopy(){if(!this.copyable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowCopy)return!1;let e=t.diagram;return e===null?!0:!!e.allowCopy}canDelete(){if(!this.deletable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowDelete)return!1;let e=t.diagram;return e===null?!0:!!e.allowDelete}canEdit(){if(!this.textEditable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowTextEdit)return!1;let e=t.diagram;return e===null?!0:!!e.allowTextEdit}canGroup(){if(!this.groupable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowGroup)return!1;let e=t.diagram;return e===null?!0:!!e.allowGroup}canMove(){if(!this.movable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowMove)return!1;let e=t.diagram;return e===null?!0:!!e.allowMove}canReshape(){if(!this.reshapable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowReshape)return!1;let e=t.diagram;return e===null?!0:!!e.allowReshape}canResize(){if(!this.resizable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowResize)return!1;let e=t.diagram;return e===null?!0:!!e.allowResize}canRotate(){if(!this.rotatable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowRotate)return!1;let e=t.diagram;return e===null?!0:!!e.allowRotate}canSelect(){if(!this.selectable)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowSelect)return!1;let e=t.diagram;return e===null?!0:!!e.allowSelect}get copyable(){return(this.b&1)!==0}set copyable(t){let e=(this.b&1)!==0;e!==t&&(this.b=this.b^1,this.t("copyable",e,t))}get deletable(){return(this.b&2)!==0}set deletable(t){let e=(this.b&2)!==0;e!==t&&(this.b=this.b^2,this.t("deletable",e,t))}get textEditable(){return(this.b&4)!==0}set textEditable(t){let e=(this.b&4)!==0;e!==t&&(this.b=this.b^4,this.t("textEditable",e,t),this.invalidateAdornments())}get groupable(){return(this.b&8)!==0}set groupable(t){let e=(this.b&8)!==0;e!==t&&(this.b=this.b^8,this.t("groupable",e,t))}get movable(){return(this.b&16)!==0}set movable(t){let e=(this.b&16)!==0;e!==t&&(this.b=this.b^16,this.t("movable",e,t))}get selectionAdorned(){return(this.b&32)!==0}set selectionAdorned(t){let e=(this.b&32)!==0;e!==t&&(this.b=this.b^32,this.t("selectionAdorned",e,t),this.invalidateAdornments())}get isInDocumentBounds(){return(this.b&64)!==0}set isInDocumentBounds(t){let e=(this.b&64)!==0;if(e!==t){this.b=this.b^64;let i=this.diagram;i!==null&&i.invalidateDocumentBounds(),this.t("isInDocumentBounds",e,t)}}get isLayoutPositioned(){return(this.b&128)!==0}set isLayoutPositioned(t){let e=(this.b&128)!==0;e!==t&&(this.b=this.b^128,this.t("isLayoutPositioned",e,t),this.invalidateLayout(t?4:8))}get selectable(){return(this.b&256)!==0}set selectable(t){let e=(this.b&256)!==0;e!==t&&(this.b=this.b^256,this.t("selectable",e,t),this.invalidateAdornments())}get reshapable(){return(this.b&512)!==0}set reshapable(t){let e=(this.b&512)!==0;e!==t&&(this.b=this.b^512,this.t("reshapable",e,t),this.invalidateAdornments())}get resizable(){return(this.b&1024)!==0}set resizable(t){let e=(this.b&1024)!==0;e!==t&&(this.b=this.b^1024,this.t("resizable",e,t),this.invalidateAdornments())}get rotatable(){return(this.b&2048)!==0}set rotatable(t){let e=(this.b&2048)!==0;e!==t&&(this.b=this.b^2048,this.t("rotatable",e,t),this.invalidateAdornments())}get isSelected(){return(this.b&4096)!==0}set isSelected(t){let e=(this.b&4096)!==0;if(e!==t){let i=this.diagram;if(t){if(!this.canSelect())return;if(i!==null){let o=i.maxSelectionCount;if(i.selection.count>=o)return}}this.b=this.b^4096;let s=!1;if(i!==null){s=i.skipsUndoManager,i.skipsUndoManager=!0;let o=i.selection;o.ce(),t?o.add(this):o.delete(this),o.k()}this.t("isSelected",e,t),this.invalidateAdornments();let n=this.selectionChanged;n!==null&&n(this),i!==null&&(i.requestUpdate(),i.skipsUndoManager=s)}}get isHighlighted(){return(this.b&524288)!==0}set isHighlighted(t){let e=(this.b&524288)!==0;if(e!==t){this.b=this.b^524288;let i=this.diagram;if(i!==null){let n=i.highlighteds;n.ce(),t?n.add(this):n.delete(this),n.k()}this.t("isHighlighted",e,t),this.N();let s=this.highlightedChanged;s!==null&&s(this)}}get isShadowed(){return(this.b&8192)!==0}set isShadowed(t){let e=(this.b&8192)!==0;e!==t&&(this.b=this.b^8192,this.Zi(!0),this.t("isShadowed",e,t),this.N())}OD(){return(this.b&16384)!==0}ID(t){t?this.b|=16384:this.b&=-16385}fa(){return(this.b&32768)!==0}aN(t){t?this.b|=32768:this.b&=-32769}kE(){return(this.b&65536)!==0}MC(t){t?this.b|=65536:this.b&=-65537}Bl(){return(this.b&131072)!==0}rs(t){t?this.b|=131072:this.b&=-131073}GD(){return(this.b&1048576)!==0}rk(t){t?this.b|=1048576:this.b&=-1048577}get isAnimated(){return(this.b&262144)!==0}set isAnimated(t){let e=(this.b&262144)!==0;e!==t&&(this.b=this.b^262144,this.t("isAnimated",e,t))}get highlightedChanged(){return this.H!==null?this.H.Sy:null}set highlightedChanged(t){let e=this.highlightedChanged;e!==t&&(t!==null&&m.S(t,pt,"highlightedChanged"),this._e().Sy=t,this.t("highlightedChanged",e,t))}get selectionObjectName(){return this.H!==null?this.H.My:""}set selectionObjectName(t){let e=this.selectionObjectName;e!==t&&(this._e().My=t,this.gl=null,this.t("selectionObjectName",e,t))}get selectionAdornmentTemplate(){return this.H!==null?this.H.Cy:null}set selectionAdornmentTemplate(t){let e=this.selectionAdornmentTemplate;e!==t&&(t!==null&&t.It(),this._e().Cy=t,this.t("selectionAdornmentTemplate",e,t))}get selectionObject(){if(this.gl===null){let t=this.selectionObjectName;if(t!==null&&t!==""){let e=this.findObject(t);e!==null?this.gl=e:this.gl=this}else if(this instanceof j){let e=this.path;e!==null?this.gl=e:this.gl=this}else this.gl=this}return this.gl}get selectionChanged(){return this.H!==null?this.H.Ny:null}set selectionChanged(t){let e=this.selectionChanged;e!==t&&(t!==null&&m.S(t,pt,"selectionChanged"),this._e().Ny=t,this.t("selectionChanged",e,t))}get resizeAdornmentTemplate(){return this.H!==null?this.H.Ly:null}set resizeAdornmentTemplate(t){let e=this.resizeAdornmentTemplate;e!==t&&(this._e().Ly=t!==null?t.It():null,this.t("resizeAdornmentTemplate",e,t))}get resizeObjectName(){return this.H!==null?this.H.Ay:""}set resizeObjectName(t){let e=this.resizeObjectName;e!==t&&(this._e().Ay=t,this.t("resizeObjectName",e,t))}get resizeObject(){let t=this.resizeObjectName;if(t!==""){let e=this.findObject(t);if(e!==null)return e}return this}get resizeCellSize(){return this.H!==null?this.H.Ty:nt.jw}set resizeCellSize(t){let e=this.resizeCellSize;e.equals(t)||(t=t.C(),this._e().Ty=t,this.t("resizeCellSize",e,t))}get rotateAdornmentTemplate(){return this.H!==null?this.H.Dy:null}set rotateAdornmentTemplate(t){let e=this.rotateAdornmentTemplate;e!==t&&(this._e().Dy=t!==null?t.It():null,this.t("rotateAdornmentTemplate",e,t))}get rotateObjectName(){return this.H!==null?this.H.vy:""}set rotateObjectName(t){let e=this.rotateObjectName;e!==t&&(this._e().vy=t,this.t("rotateObjectName",e,t))}get rotateObject(){let t=this.rotateObjectName;if(t!==""){let e=this.findObject(t);if(e!==null)return e}return this}get rotationSpot(){return this.H!==null?this.H.Fy:T.Default}set rotationSpot(t){let e=this.rotationSpot;e.equals(t)||(t=t.C(),this._e().Fy=t,this.t("rotationSpot",e,t))}get text(){return this.ue}set text(t){let e=this.ue;e!==t&&(this.ue=t,this.t("text",e,t))}get containingGroup(){return this.Ta}set containingGroup(t){if(this.Di()){let e=this.Ta;if(e!==t){t!==null&&(this===t||t.isMemberOf(this))&&(this===t&&m.o("Cannot make a Group a member of itself: "+this.toString()),m.o("Cannot make a Group indirectly contain itself: "+this.toString()+" already contains "+t.toString())),this.invalidateLayout(2);let i=this.diagram;if(e!==null?e.cN(this):this instanceof ht&&i!==null&&i.$r.delete(this),this.Ta=t,t!==null?t.fN(this):this instanceof ht&&i!==null&&i.$r.add(this),this.invalidateLayout(1),i!==null&&i.G){let n=this.data,o=i.model;if(n!==null&&o.Ah()){let r=t!==null?t.data:null;o.setGroupForData(n,o.getKeyForNodeData(r))}}let s=this.containingGroupChanged;if(s!==null){let n=!0;i!==null&&(n=i.G,i.G=!0),s(this,e,t),i!==null&&(i.G=n)}if(this instanceof ht){let n=new V;pt.ga(n,this,!0,0,!0);let o=n.iterator;for(;o.next();){let r=o.value;if(r instanceof $){let a=r.linksConnected;for(;a.next();)a.value.Jd()}}}if(this instanceof $){let n=this.linksConnected;for(;n.next();)n.value.Jd();let o=this.labeledLink;o!==null&&o.Jd()}this.t("containingGroup",e,t),t!==null&&t.xE()}}else m.o("cannot set the Part.containingGroup of a Link or Adornment")}Pa(){let t=this.containingGroup;t!==null&&(t.hasPlaceholder()&&t.placeholder.f(),t.f(),t.invalidateConnectedLinks())}N(){let t=this.diagram;t!==null&&!this.as()&&!this.fa()&&this.isVisible()&&this.ve.isReal()&&t.N(this.ah(this.ve))}f(){if(this.Xo())return;super.f();let t=this.diagram;t!==null&&(t.Pp(this),this instanceof $&&this.labeledLink!==null&&this.labeledLink.Pf(),t.requestUpdate(!0))}Pf(t){if(this.as())return;let e=this.diagram;e!==null&&(e.Pp(this),this instanceof $&&this.invalidateConnectedLinks(),e.requestUpdate()),this.lo(!0)}$m(t){if(!t){let e=this.Ta;e!==null&&e.fN(this)}}Zm(t){if(!t){let e=this.Ta;e!==null&&e.cN(this)}}af(){let t=this.data;if(t!==null){let e=this.diagram;if(e!==null){let i=e.model;i!==null&&i.removeNodeData(t)}}}get containingGroupChanged(){return this.H!==null?this.H.Ry:null}set containingGroupChanged(t){let e=this.containingGroupChanged;e!==t&&(t!==null&&m.S(t,pt,"containingGroupChanged"),this._e().Ry=t,this.t("containingGroupChanged",e,t))}findSubGraphLevel(){return this.uN(this)}uN(t){let e=t.containingGroup;if(e!==null)return 1+this.uN(e);if(t instanceof $){let i=t.labeledLink;if(i!==null)return this.uN(i)}return 0}findTopLevelPart(){return this.dN(this)}dN(t){let e=t.containingGroup;if(e!==null)return this.dN(e);if(t instanceof $){let i=t.labeledLink;if(i!==null)return this.dN(i)}return t}get isTopLevel(){return!(this.containingGroup!==null||this instanceof $&&this.labeledLink!==null)}isMemberOf(t){return t instanceof ht?this.gN(this,t):!1}gN(t,e){if(t===e||e===null)return!1;let i=t.containingGroup;if(i!==null&&(i===e||this.gN(i,e)))return!0;if(t instanceof $){let s=t.labeledLink;if(s!==null)return this.gN(s,e)}return!1}findCommonContainingGroup(t){if(t===null)return null;if(this===t)return this.containingGroup;let e=this;for(;e!==null;){if(e instanceof ht&&e.rk(!0),e instanceof $){let s=e.labeledLink;s!==null&&(e=s)}e=e.containingGroup}let i=null;for(e=t;e!==null;){if(e.GD()){i=e;break}if(e instanceof $){let s=e.labeledLink;s!==null&&(e=s)}e=e.containingGroup}for(e=this;e!==null;){if(e instanceof ht&&e.rk(!1),e instanceof $){let s=e.labeledLink;s!==null&&(e=s)}e=e.containingGroup}return i}get layoutConditions(){return this.H!==null?this.H.Oy:127}set layoutConditions(t){let e=this.layoutConditions;e!==t&&(this._e().Oy=t,this.t("layoutConditions",e,t))}canLayout(){if(!this.isLayoutPositioned||!this.isVisible())return!1;let t=this.layer;return!(t!==null&&t.isTemporary||this instanceof $&&this.isLinkLabel)}SE(t){if(!this.isLayoutPositioned||(t&this.layoutConditions)===0)return!1;let e=this.layer;if(e!==null&&e.isTemporary||this instanceof $&&this.isLinkLabel)return!1;let i=this.diagram;return!(i!==null&&i.undoManager.isUndoingRedoing)}invalidateLayout(t){if(t===void 0&&(t=16777215),!this.SE(t))return;let e=this.Ta;if(e!==null){let i=e.layout;i!==null?i.p():e.invalidateLayout(t)}else{let i=this.diagram;if(i!==null){let s=i.layout;s!==null&&s.p()}}}gT(){if(!this.isVisible())return!1;let t=this.layer;return!(t!==null&&t.isTemporary)}static ga(t,e,i,s,n,o){if(o===void 0&&(o=null),!t.has(e)&&!(o!==null&&!o(e))&&!(e instanceof vt)){if(t.add(e),e instanceof $){if(i&&e instanceof ht){let r=e.memberParts;for(;r.next();){let a=r.value;pt.ga(t,a,i,s,n,o)}}if(n!==!1){let r=e.linksConnected;for(;r.next();){let a=r.value;if(t.has(a))continue;let h=a.fromNode,l=a.toNode,u=h===null||t.has(h),c=l===null||t.has(l);(n?u&&c:u||c)&&pt.ga(t,a,i,s,n,o)}}if(s>1){let r=e.findTreeChildrenNodes();for(;r.next();){let a=r.value;pt.ga(t,a,i,s-1,n,o)}}}else if(e instanceof j){let r=e.labelNodes;for(;r.next();){let a=r.value;pt.ga(t,a,i,s,n,o)}}}}get dragComputation(){return this.H!==null?this.H.Iy:null}set dragComputation(t){let e=this.dragComputation;e!==t&&(t!==null&&m.S(t,pt,"dragComputation"),this._e().Iy=t,this.t("dragComputation",e,t))}get shadowOffset(){return this.H!==null?this.H.Ey:P.FL}set shadowOffset(t){let e=this.shadowOffset;e.equals(t)||(t=t.C(),this._e().Ey=t,this.N(),this.t("shadowOffset",e,t))}get shadowColor(){return this.H!==null?this.H.Uy:"gray"}set shadowColor(t){let e=this.shadowColor;e!==t&&(this._e().Uy=t,this.N(),this.t("shadowColor",e,t))}get shadowBlur(){return this.H!==null?this.H.An:4}set shadowBlur(t){let e=this.shadowBlur;e!==t&&(this._e().An=t,this.N(),this.t("shadowBlur",e,t))}}class Gi{me;yy;Ry;Cy;My;Ny;Sy;Ly;Ay;Ty;Dy;vy;Fy;ky;Py;wy;xy;Iy;Oy;Ey;Uy;An;constructor(){this.me=!1,this.yy=null,this.Ry=null,this.Cy=null,this.My="",this.Ny=null,this.Sy=null,this.Ly=null,this.Ay="",this.Ty=nt.jw,this.Dy=null,this.vy="",this.Fy=T.Default,this.ky="",this.Py=T.TopLeft,this.wy=P.DL,this.xy=P.vL,this.Iy=null,this.Oy=127,this.Ey=P.FL,this.Uy="gray",this.An=4}copy(){let t=new Gi;return t.yy=this.yy,t.Ry=this.Ry,t.Cy=this.Cy,t.My=this.My,t.Ny=this.Ny,t.Sy=this.Sy,t.Ly=this.Ly,t.Ay=this.Ay,t.Ty=this.Ty.C(),t.Dy=this.Dy,t.vy=this.vy,t.Fy=this.Fy.C(),t.ky=this.ky,t.Py=this.Py.C(),t.wy=this.wy.C(),t.xy=this.xy.C(),t.Iy=this.Iy,t.Oy=this.Oy,t.Ey=this.Ey.C(),t.Uy=this.Uy,t.An=this.An,t}}class vt extends pt{Ms;Dt;HS;qS;Af;constructor(t,e){let i;t===void 0||t instanceof Lt||typeof t=="string"?i=t:t&&(e=t),super(i),this.b&=-257,this.dl="Adornment",this.Ms=null,this.HS=0,this.qS=!1,this.Dt=null,this.Af=null,e&&Object.assign(this,e)}toString(){let t=this.adornedPart;return"Adornment("+this.category+")"+(t!==null?t.toString():"")}updateRelationshipsFromData(){}Dd(t){let e=this.adornedObject;if(!(e instanceof it))return;let i=e.part;if(!(i instanceof j))return;let s=i.path,n=s.geometry;i.Dd(t),n=s.geometry;let o=this.D.r,r=o.length;for(let a=0;a<r;a++){let h=o[a];h.isPanelMain&&h instanceof it&&(h.ut=n)}}hasPlaceholder(){return this.Dt!==null&&this.Dt.isVisibleObject()}get placeholder(){return this.Dt}get adornedObject(){return this.Ms}set adornedObject(t){let e=this.adornedPart,i=null;t!==null&&(i=t.part),e!==null&&(t===null||e!==i)&&e.removeAdornment(this.category),this.Ms=t,i!==null&&i.addAdornment(this.category,this)}get adornedPart(){let t=this.Ms;return t!==null?t.part:null}_r(){let t=this.Ms;if(t===null)return!0;let e=t.part;return e===null||!e.as()}Di(){return!1}get containingGroup(){return null}gf(t,e,i,s,n,o,r){if(t===3&&e==="elements"){if(n instanceof ue)this.Dt===null&&(this.Dt=n);else if(n instanceof G){let a=n.findInVisualTree(h=>h instanceof ue);a instanceof ue&&this.Dt===null&&(this.Dt=a)}}else t===4&&e==="elements"&&this.Dt!==null&&(s===this.Dt?this.Dt=null:s instanceof G&&this.Dt.isContainedBy(s)&&(this.Dt=null));super.gf(t,e,i,s,n,o,r)}updateAdornments(){}af(){}}var qs=(x=>(x[x.None=0]="None",x[x.Evenly=1]="Evenly",x[x.Packed=2]="Packed",x))(qs||{});class $ extends pt{E;vt;Xf;yl;Da;ci;ee;constructor(t,e){let i;t===void 0||t instanceof Lt||typeof t=="string"?i=t:t&&(e=t),super(i),this.E=13,this.vt=null,this.ee=new q,this.Xf=null,this.yl=null,this.ci=null,this.Da=!1,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),t.E=this.E,this.vt!==null&&(this.vt.me?t.vt=this.vt:t.vt=this.vt.copy())}Ho(t){super.Ho(t),t.invalidateConnectedLinks(),t.yl=this.yl,t.ci=null}static SpreadingNone=0;static SpreadingEvenly=1;static SpreadingPacked=2;wl(){return this.vt===null?this.vt=new qi:this.vt.me&&(this.vt=this.vt.copy()),this.vt}xa(){super.xa(),this.vt!==null&&(this.vt.me=!0)}YD(t){t!==null&&(this.yl===null&&(this.yl=new V),this.yl.add(t))}KD(t){t!==null&&this.yl!==null&&this.yl.delete(t)}HD(t,e,i){if(t===null||this.yl===null)return null;let s=this.yl.iterator;for(;s.next();){let n=s.value;if(n.Vy===this&&n.lk===t&&n.mN===e&&n.pN===i||n.Vy===t&&n.lk===this&&n.mN===i&&n.pN===e)return n}return null}invalidateLinkBundle(t,e,i){e==null&&(e=""),i==null&&(i="");let s=this.HD(t,e,i);s!==null&&s.$d()}gf(t,e,i,s,n,o,r){t===3&&e==="elements"?this.ci=null:t===4&&e==="elements"&&(this.ci=null),super.gf(t,e,i,s,n,o,r)}invalidateConnectedLinks(t,e){let i=this.linksConnected;for(;i.next();){let s=i.value;t&&t.has(s)||e&&s.fromPort!==e&&s.toPort!==e||(this.Ze(s.fromPort),this.Ze(s.toPort),s.$t())}}Ze(t){if(t===null)return;let e=t.wd;e!==null&&e.$d();let i=t.part,s=i.containingGroup;s!==null&&!i.isVisible()&&s.Ze(s.port)}_r(){return!0}get portSpreading(){return this.vt!==null?this.vt.By:1}set portSpreading(t){let e=this.portSpreading;if(e!==t){this.wl().By=t,this.t("portSpreading",e,t);let i=this.diagram;if(i!==null&&i.undoManager.isUndoingRedoing)return;this.invalidateConnectedLinks()}}get avoidable(){return(this.E&8)!==0}set avoidable(t){let e=(this.E&8)!==0;if(e!==t){this.E=this.E^8;let i=this.diagram;i!==null&&i.ud(this),this.t("avoidable",e,t)}}get avoidableMargin(){return this.vt!==null?this.vt.zy:Dt.BL}set avoidableMargin(t){typeof t=="number"&&(t=new Dt(t));let e=this.avoidableMargin;if(!e.equals(t)){t=t.C(),this.wl().zy=t;let i=this.diagram;i!==null&&i.ud(this),this.t("avoidableMargin",e,t)}}canAvoid(){return this.avoidable&&!this.isLinkLabel}getAvoidableRect(t){return t.set(this.actualBounds),t.addMargin(this.avoidableMargin),t}findVisibleNode(){let t=this;for(;t!==null&&!t.isVisible();)t=t.containingGroup;return t}isVisible(){if(!super.isVisible())return!1;let t=!0,e=1,i=this.diagram;if(i!==null){if(i.animationManager.Hx(this))return!0;t=i.isTreePathToChildren,e=i.treeCollapsePolicy}if(e===1){let n=this.findTreeParentNode();if(n!==null&&!n.isTreeExpanded)return!1}else if(e===2){let n=t?this.findLinksInto():this.findLinksOutOf(),o=!1,r=!1;for(;n.next();){let a=n.value;if(a.isTreeLink){o=!0;let h=t?a.fromNode:a.toNode;if(h&&h.isTreeExpanded){r=!0;break}}}if(o&&!r)return!1}else if(e===3){let n=t?this.findLinksInto():this.findLinksOutOf(),o=!1,r=!1;for(;n.next();){let a=n.value;if(a.isTreeLink){o=!0;let h=t?a.fromNode:a.toNode;if(h&&!h.isTreeExpanded){r=!0;break}}}if(o&&r)return!1}let s=this.labeledLink;return s!==null?s.isVisible():!0}Xe(t){super.Xe(t);let e=this.linksConnected;for(;e.next();){let i=e.value;if(t&&this.containingGroup!==null){let s=i.getOtherNode(this);s!==null&&!s.isMemberOf(this.containingGroup)&&i.$t()}i.Xe(t)}}get linksConnected(){return this.ee.iterator}findExternalTreeLinksConnected(){let t=new V,e=new V;return this.qD(this,t,e),e.iterator}qD(t,e,i){if(t===null||e.has(t))return;e.add(t);let s=!0,n=this.diagram;n!==null&&(s=n.isTreePathToChildren),t.linksConnected.each(o=>{o.isTreeLink?(s?o.fromNode===t:o.toNode===t)&&this.qD(s?o.toNode:o.fromNode,e,i):i.add(o)})}findLinksConnected(t){if(t===void 0&&(t=null),t===null)return this.ee.iterator;let e=new ct(this.ee),i=this;return e.predicate=s=>s.fromNode===i&&s.fromPortId===t||s.toNode===i&&s.toPortId===t,e}findLinksOutOf(t){t===void 0&&(t=null);let e=new ct(this.ee),i=this;return e.predicate=s=>s.fromNode!==i?!1:t===null?!0:s.fromPortId===t,e}findLinksInto(t){t===void 0&&(t=null);let e=new ct(this.ee),i=this;return e.predicate=s=>s.toNode!==i?!1:t===null?!0:s.toPortId===t,e}findNodesConnected(t){t===void 0&&(t=null);let e=null,i=null,s=this.ee.iterator;for(;s.next();){let n=s.value;if(n.fromNode===this){if(t===null||n.fromPortId===t){let o=n.toNode;e!==null?e.add(o):i!==null&&i!==o?(e=new V,e.add(i),e.add(o)):i=o}}else if(n.toNode===this&&(t===null||n.toPortId===t)){let o=n.fromNode;e!==null?e.add(o):i!==null&&i!==o?(e=new V,e.add(i),e.add(o)):i=o}}return e!==null?e.iterator:i!==null?new ut(i):Pt.instance}findNodesOutOf(t){t===void 0&&(t=null);let e=null,i=null,s=this.ee.iterator;for(;s.next();){let n=s.value;if(n.fromNode===this&&(t===null||n.fromPortId===t)){let o=n.toNode;e!==null?e.add(o):i!==null&&i!==o?(e=new V,e.add(i),e.add(o)):i=o}}return e!==null?e.iterator:i!==null?new ut(i):Pt.instance}findNodesInto(t){t===void 0&&(t=null);let e=null,i=null,s=this.ee.iterator;for(;s.next();){let n=s.value;if(n.toNode===this&&(t===null||n.toPortId===t)){let o=n.fromNode;e!==null?e.add(o):i!==null&&i!==o?(e=new V,e.add(i),e.add(o)):i=o}}return e!==null?e.iterator:i!==null?new ut(i):Pt.instance}findLinksBetween(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null);let s=new ct(this.ee),n=this;return s.predicate=o=>o.fromNode===n&&o.toNode===t&&(e===null||o.fromPortId===e)&&(i===null||o.toPortId===i)||o.fromNode===t&&o.toNode===n&&(i===null||o.fromPortId===i)&&(e===null||o.toPortId===e),s}findLinksTo(t,e,i){e===void 0&&(e=null),i===void 0&&(i=null);let s=new ct(this.ee),n=this;return s.predicate=o=>!(o.fromNode!==n||o.toNode!==t||e!==null&&o.fromPortId!==e||i!==null&&o.toPortId!==i),s}findSuccessorParts(t){return t===void 0&&(t=new V),this.jD(this,t),t.remove(this),t}jD(t,e){t!==null&&(e.has(t)||(e.add(t),t.findLinksOutOf().each(i=>{if(e.has(i))return;e.add(i);let s=i.toNode;s!==null&&this.jD(s,e)})))}findPredecessorParts(t){return t===void 0&&(t=new V),this.WD(this,t),t.remove(this),t}WD(t,e){t!==null&&(e.has(t)||(e.add(t),t.findLinksInto().each(i=>{if(e.has(i))return;e.add(i);let s=i.fromNode;s!==null&&this.WD(s,e)})))}get linkConnected(){return this.vt!==null?this.vt.Xy:null}set linkConnected(t){let e=this.linkConnected;e!==t&&(t!==null&&m.S(t,$,"linkConnected"),this.wl().Xy=t,this.t("linkConnected",e,t))}get linkDisconnected(){return this.vt!==null?this.vt.Gy:null}set linkDisconnected(t){let e=this.linkDisconnected;e!==t&&(t!==null&&m.S(t,$,"linkDisconnected"),this.wl().Gy=t,this.t("linkDisconnected",e,t))}get linkValidation(){return this.vt!==null?this.vt.Vl:null}set linkValidation(t){let e=this.linkValidation;e!==t&&(t!==null&&m.S(t,$,"linkValidation"),this.wl().Vl=t,this.t("linkValidation",e,t))}ak(t,e){this.Ze(e);let i=this.ee.has(t);if(i||this.ee.add(t),!i||t.fromNode===t.toNode){let s=this.linkConnected;if(s!==null){let n=!0,o=this.diagram;o!==null&&(n=o.G,o.G=!0),s(this,t,e),o!==null&&(o.G=n)}}if(!i){if(!t.isTreeLink)return;let s=t.fromNode,n=t.toNode;if(s!==null&&n!==null&&s!==n){let o=!0,r=this.diagram;r!==null&&(o=r.isTreePathToChildren);let a=o?n:s,h=o?s:n;if(a.Da||(a.Da=h),h.isTreeLeaf){if(r!==null&&r.undoManager.isUndoingRedoing)return;o?s===h&&(h.isTreeLeaf=!1):n===h&&(h.isTreeLeaf=!1)}}}}hk(t,e){this.Ze(e);let i=this.ee.delete(t),s=null;if(i||t.toNode===t.fromNode){let n=this.linkDisconnected;if(s=this.diagram,n!==null){let o=!0;s!==null&&(o=s.G,s.G=!0),n(this,t,e),s!==null&&(s.G=o)}}if(i){if(!t.isTreeLink)return;let n=!0;s!==null&&(n=s.isTreePathToChildren);let o=n?t.toNode:t.fromNode,r=n?t.fromNode:t.toNode;if(o!==null&&(o.Da=!1),r!==null&&!r.isTreeLeaf)if(r.ee.count===0){if(r.Da=null,s!==null&&s.undoManager.isUndoingRedoing)return;r.isTreeLeaf=!0}else r.Lp()}}Lp(){if(this.Da=!1,this.ee.count===0)return;let t=!0,e=this.diagram;if(e!==null&&e.undoManager.isUndoingRedoing)return;e!==null&&(t=e.isTreePathToChildren);let i=this.ee.iterator;for(;i.next();){let s=i.value;if(s.isTreeLink){if(t){if(s.fromNode===this){this.isTreeLeaf=!1;return}}else if(s.toNode===this){this.isTreeLeaf=!1;return}}}this.isTreeLeaf=!0}updateRelationshipsFromData(){let t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}$m(t){if(super.$m(t),!t){this.Lp();let e=this.Xf;e!==null&&e.JD(this)}}Zm(t){if(super.Zm(t),!t){let e=this.Xf;e!==null&&e.$D(this)}}af(){if(this.ee.count>0){let t=this.diagram;if(t!==null){let e=t.commandHandler!==null?t.commandHandler.deletesConnectedLinks:!0,i=this.ee.copy().iterator;for(;i.next();){let s=i.value;e?t.remove(s):(s.fromNode===this&&(s.fromNode=null),s.toNode===this&&(s.toNode=null))}}}this.labeledLink=null,super.af()}get isLinkLabel(){return this.Xf!==null}get labeledLink(){return this.Xf}set labeledLink(t){let e=this.Xf;if(e!==t){let i=this.diagram,s=this.data;if(e!==null){if(e.$D(this),i!==null&&s!==null&&!i.undoManager.isUndoingRedoing){let n=e.data,o=i.model;if(n!==null&&o.jh()){let r=o.getKeyForNodeData(s);r!==void 0&&o.removeLabelKeyForLinkData(n,r)}}this.containingGroup=null}if(this.Xf=t,t!==null){if(t.JD(this),i!==null&&s!==null&&!i.undoManager.isUndoingRedoing){let n=t.data,o=i.model;if(n!==null&&o.jh()){let r=o.getKeyForNodeData(s);r!==void 0&&o.addLabelKeyForLinkData(n,r)}}this.containingGroup=t.containingGroup}this.Pf(),this.t("labeledLink",e,t)}}findVisiblePort(t){let e=t;for(;e!==null&&(!e.actualBounds.isReal()||!e.isVisibleObject());)e=e.panel;return e===null?this.port:e}findPort(t){if(this.ci===null){if(t===""&&this.Ln===!1)return this;this.ZD()}let e=this.ci.get(t);return e!==null||t!==""&&(e=this.ci.get(""),e!==null)?e:this}get port(){return this.findPort("")}get ports(){return this.ci===null&&this.ZD(),this.ci.iteratorValues}ZD(){this.ci===null?this.ci=new Mt:this.ci.clear(),this.walkVisualTreeFrom(this,(t,e)=>t.nD(e)),this.ci.count===0&&this.ci.set("",this)}nD(t){let e=t.portId;e!==null&&this.ci!==null&&this.ci.set(e,t)}vC(t,e){let i=t.portId;if(i!==null){this.ci!==null&&this.ci.delete(i);let s=this.diagram;if(s!==null&&e){let n=null,o=this.findLinksConnected(i);for(;o.next();){let r=o.value;n===null&&(n=m.st()),n.push(r)}if(n!==null){for(let r=0;r<n.length;r++){let a=n[r];s.remove(a)}m.Z(n)}}}}isInTreeOf(t){if(t===null||t===this)return!1;let e=!0,i=this.diagram;i!==null&&(e=i.isTreePathToChildren);let s=this,n=t,o;if(e)for(;s!==n;){o=null;let r=s.ee.iterator;for(;r.next();){let a=r.value;if(a.isTreeLink&&(o=a.fromNode,o!==s&&o!==this))break}if(o===this||o===null||o===s)return!1;s=o}else for(;s!==n;){o=null;let r=s.ee.iterator;for(;r.next();){let a=r.value;if(a.isTreeLink&&(o=a.toNode,o!==s&&o!==this))break}if(o===this||o===null||o===s)return!1;s=o}return!0}findTreeRoot(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=this,s;if(t)for(;;){s=null;let n=i.ee.iterator;for(;n.next();){let o=n.value;if(o.isTreeLink&&(s=o.fromNode,s!==i&&s!==this))break}if(s===this)return this;if(s===null||s===i)return i;i=s}else for(;;){s=null;let n=i.ee.iterator;for(;n.next();){let o=n.value;if(o.isTreeLink&&(s=o.toNode,s!==i&&s!==this))break}if(s===this)return this;if(s===null||s===i)return i;i=s}}findCommonTreeParent(t){if(t===null)return null;if(this===t)return this;let e=this;for(;e!==null;)e.rk(!0),e=e.findTreeParentNode();let i=null;for(e=t;e!==null;){if(e.GD()){i=e;break}e=e.findTreeParentNode()}for(e=this;e!==null;)e.rk(!1),e=e.findTreeParentNode();return i}findTreeParentLink(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=this.ee.iterator;if(t)for(;i.next();){let s=i.value;if(s.isTreeLink&&s.fromNode!==this)return s}else for(;i.next();){let s=i.value;if(s.isTreeLink&&s.toNode!==this)return s}return null}findTreeParentNode(){let t=this.Da;if(t===null)return null;if(t instanceof $)return t;let e=this.diagram,i=e!==null?e.isTreePathToChildren:!0,s=this.ee.iterator;for(;s.next();){let n=s.value;if(!n.isTreeLink)continue;let o=i?n.fromNode:n.toNode;if(o!==this)return this.Da=o,o}return this.Da=null,null}findTreeParentChain(t){function e(i,s){s.add(i);let n=i.findTreeParentLink();if(n!==null){s.add(n);let o=i.findTreeParentNode();if(o===null)return;e(o,s)}}return t===void 0&&(t=new V),e(this,t),t}findTreeLevel(){return this.ME(this)}ME(t){let e=0,i=t.findTreeParentNode();for(;i!==null&&i!==t;)i=i.findTreeParentNode(),e++;return e}findTreeChildrenLinks(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=new ct(this.ee),s=this;return t?i.predicate=n=>!(!n.isTreeLink||n.fromNode!==s):i.predicate=n=>!(!n.isTreeLink||n.toNode!==s),i}findTreeChildrenNodes(){let t=!0,e=this.diagram;e!==null&&(t=e.isTreePathToChildren);let i=null,s=null,n=this.ee.iterator;if(t)for(;n.next();){let o=n.value;if(o.isTreeLink&&o.fromNode===this){let r=o.toNode;i!==null?i.add(r):s!==null&&s!==r?(i=new q,i.add(s),i.add(r)):s=r}}else for(;n.next();){let o=n.value;if(o.isTreeLink&&o.toNode===this){let r=o.fromNode;i!==null?i.add(r):s!==null&&s!==r?(i=new q,i.add(s),i.add(r)):s=r}}return i!==null?i.iterator:s!==null?new ut(s):Pt.instance}findTreeParts(t,e){return t===void 0&&(t=1/0),m.s(t,"number",$,"findTreeParts:level"),e===void 0&&(e=new V),pt.ga(e,this,!1,t,!0),e}collapseTree(t){t===void 0&&(t=1),t<1&&(t=1);let e=this.diagram;if(e===null||e.isCollapsingExpanding)return;e.isCollapsingExpanding=!0;let i=new V;i.add(this),this.QD(i,e.isTreePathToChildren,t,e,this,e.treeCollapsePolicy===1),e.isCollapsingExpanding=!1}QD(t,e,i,s,n,o){if(i>1){let r=e?this.findLinksOutOf():this.findLinksInto();for(;r.next();){let a=r.value;if(!a.isTreeLink)continue;let h=a.getOtherNode(this);h!==null&&h!==this&&!t.has(h)&&(t.add(h),h.QD(t,e,i-1,s,n,o))}}else this._D(t,e,s,n,o)}_D(t,e,i,s,n){let o=s===this?!0:this.isTreeExpanded,r=e?this.findLinksOutOf():this.findLinksInto();for(;r.next();){let a=r.value;if(!a.isTreeLink)continue;let h=a.getOtherNode(this);if(h!==null&&h!==this){let l=t.has(h);if(l||t.add(h),o){let u=e?h.findNodesInto():h.findNodesOutOf(),c=this;u.all(d=>d===c||!d.isTreeExpanded)&&i.Kc(h,s),h.Pa(),h.Xe(!1)}h.isTreeExpanded&&(h.wasTreeExpanded=h.isTreeExpanded,l||h._D(t,e,i,s,n))}}this.isTreeExpanded=!1}expandTree(t){t===void 0&&(t=2),t<2&&(t=2);let e=this.diagram;if(e===null||e.isCollapsingExpanding)return;e.isCollapsingExpanding=!0;let i=new V;i.add(this),this.tv(i,e.isTreePathToChildren,t,e,this,e.treeCollapsePolicy===1),e.isCollapsingExpanding=!1}tv(t,e,i,s,n,o){let r=n===this?!1:this.isTreeExpanded,a=e?this.findLinksOutOf():this.findLinksInto();for(;a.next();){let h=a.value;if(!h.isTreeLink)continue;r||h.Fi||h.$t();let l=h.getOtherNode(this);if(l!==null&&l!==this&&!t.has(l)){if(t.add(l),!r){l.Xe(!0),l.Pa();let u=e?l.findNodesInto():l.findNodesOutOf(),c=this;u.all(d=>d===c||!d.isTreeExpanded)&&s.Yc(l,n)}(i>2||l.wasTreeExpanded)&&(l.wasTreeExpanded=!1,l.tv(t,e,i-1,s,n,o))}}this.isTreeExpanded=!0}get isTreeExpanded(){return(this.E&1)!==0}set isTreeExpanded(t){let e=(this.E&1)!==0;if(e!==t){this.E=this.E^1;let i=this.diagram;this.t("isTreeExpanded",e,t);let s=this.treeExpandedChanged;if(s!==null){let n=!0;i!==null&&(n=i.G,i.G=!0),s(this),i!==null&&(i.G=n)}if(i!==null&&i.undoManager.isUndoingRedoing){this.Xe(t);return}t?this.expandTree():this.collapseTree()}}get wasTreeExpanded(){return(this.E&2)!==0}set wasTreeExpanded(t){let e=(this.E&2)!==0;e!==t&&(this.E=this.E^2,this.t("wasTreeExpanded",e,t))}get treeExpandedChanged(){return this.vt!==null?this.vt.Yy:null}set treeExpandedChanged(t){let e=this.treeExpandedChanged;e!==t&&(t!==null&&m.S(t,$,"treeExpandedChanged"),this.wl().Yy=t,this.t("treeExpandedChanged",e,t))}get isTreeLeaf(){return(this.E&4)!==0}set isTreeLeaf(t){let e=(this.E&4)!==0;e!==t&&(this.E=this.E^4,this.t("isTreeLeaf",e,t))}get isTreeRoot(){return this.findTreeParentLink()===null}}class qi{me;Xy;Gy;Vl;Yy;zy;By;Ky;Hy;da;qy;constructor(){this.me=!1,this.Xy=null,this.Gy=null,this.Vl=null,this.Yy=null,this.zy=Dt.BL,this.By=1,this.Ky=null,this.Hy=null,this.da=null,this.qy=null}copy(){let t=new qi;return t.Xy=this.Xy,t.Gy=this.Gy,t.Vl=this.Vl,t.Yy=this.Yy,t.zy=this.zy.C(),t.By=this.By,t.Ky=this.Ky,t.Hy=this.Hy,t.da=this.da,t.qy=this.qy,t}}var Hi=(x=>(x[x.None=0]="None",x[x.End=17]="End",x[x.Scale=18]="Scale",x[x.Stretch=19]="Stretch",x))(Hi||{}),Wi=(x=>(x[x.Normal=1]="Normal",x[x.Orthogonal=2]="Orthogonal",x[x.AvoidsNodes=6]="AvoidsNodes",x[x.AvoidsNodesStraight=7]="AvoidsNodesStraight",x))(Wi||{}),$i=(x=>(x[x.None=0]="None",x[x.Bezier=9]="Bezier",x[x.JumpGap=10]="JumpGap",x[x.JumpOver=11]="JumpOver",x))($i||{});class j extends pt{St;mo;po;Zd;yo;wo;Qd;Gf;_d;tg;eg;Wh;ig;on;Ce;xl;Dr;bl;er;yN;wN;ck;xN;bN;Jh;fk;ut;ir;static $h=null;static Zh=null;Af;kN;PN;constructor(t){super(G.Link),this.St=8,this.mo=null,this.po="",this.Zd=null,this.yo=null,this.wo="",this.Qd=null,this.Gf=0,this._d=0,this.tg=0,this.eg=NaN,this.Wh=1,this.ig=.5,this.on=null,this.Ce=new q().k(),this.xl=null,this.Dr=null,this.bl=new I,this.ut=new wt,this.er=null,this.ir=null,this.yN=P.mn,this.wN=P.mn,this.kN=0,this.PN=0,this.ck=new P,this.xN=null,this.bN=null,this.Jh=null,this.fk=NaN,this.ft=null,this.Af=[],t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.St=this.St&-113,t.po=this.po,t.Zd=this.Zd,t.wo=this.wo,t.Qd=this.Qd,t.Gf=this.Gf,t._d=this._d,t.tg=this.tg,t.eg=this.eg,t.Wh=this.Wh,t.ig=this.ig,this.ft!==null&&(t.ft=this.ft.copy())}Ho(t){super.Ho(t),this.po=t.po,this.wo=t.wo,t.xl=null,t.$t(),t.ir=this.ir;let e=t.fromPort;e!==null&&t.fromNode.Ze(e);let i=t.toPort;i!==null&&t.toNode.Ze(i)}fe(t){t in Wi||t in $i||t in Hi?j.SN(t)?this.routing=t:t===9||t===10||t===11?this.curve=t:t===17||t===18||t===19?this.adjusting=t:t===1||t===0||m.o("Unknown Link enum value for a Link property: "+t):super.fe(t)}static Normal=1;static Orthogonal=2;static AvoidsNodes=6;static AvoidsNodesStraight=7;static None=0;static Bezier=9;static JumpGap=10;static JumpOver=11;static End=17;static Scale=18;static Stretch=19;static OrientAlong=21;static OrientPlus90=22;static OrientMinus90=23;static OrientOpposite=24;static OrientUpright=25;static OrientPlus90Upright=26;static OrientMinus90Upright=27;static OrientUpright45=28;static ev=8;static iv=16;static va=8;static H1=3;static sv=3;static nv=1.333;static MN=1;static CN=0;static ov=10;static Yf=9999;static rv=30;static lv=30;static NN=10;static av=10;static hv=14;static cv=30;static fv=14;static _A=8;static tT=8;static uv=11;static setRoutingParameter(t,e){switch(t){case 1:j.ev=e;break;case 2:j.iv=e;break;case 3:j.va=e;break;case 4:j.H1=e;break;case 5:j.sv=e;break;case 6:j.nv=e;break;case 7:j.MN=e;break;case 8:j.CN=e;break;case 9:j.ov=e;break;case 10:j.Yf=e;break;case 11:j.rv=e;break;case 12:j.lv=e;break;case 13:j.NN=e;break;case 14:j.av=e;break;case 15:j.hv=e;break;case 16:j.cv=e;break;case 17:j.fv=e;break;case 18:j._A=e;break;case 19:j.tT=e;break;case 20:j.uv=e;break}t>29&&t<71&&(j.IT=t+parseInt(e.toString().slice(0,-1)))}static IT;$i(){return this.ft===null&&(this.ft=new Ni),this.ft}UI(t,e,i){let s=t.segmentIndex,n=t.segmentFraction,o=t.alignmentFocus,r=t.segmentOrientation,a=t.segmentOffset,h=0,l=0,u=0,c=0;if(isNaN(s)){let L=this.ut,M=m.st();L.getPointAndAngleAlongPath(n,M);let A=P.z(M[0],M[1]);if(c=M[2],A.add(this.getPoint(0)),L.type===1)A.offset(-L.startX,-L.startY);else{let F=L.figures.first();A.offset(-F.startX,-F.startY)}r!==0&&(u=this.computeAngle(t,r,c),t.angle=u),h=A.x,l=A.y,P.i(A),m.Z(M)}else if(s<-e||s>=e){let L=P.l();this.KC(L),c=this.midAngle,r!==0&&(u=this.computeAngle(t,r,c),t.angle=u),h=L.x,l=L.y,P.i(L)}else{let L,M,A=0;if(s>=0?(L=i.r[s],M=s<e-1?i.r[s+1]:L):(A=e+s,L=i.r[A],M=A>0?i.r[A-1]:L),L.equalsApprox(M)){let F,O;s>=0?(F=s>0?i.r[s-1]:L,O=s<e-2?i.r[s+2]:M):(F=A<e-1?i.r[A+1]:L,O=A>1?i.r[A-2]:M);let E=F.distanceSquaredPoint(L),B=M.distanceSquaredPoint(O);E>B+10?c=s>=0?F.directionPoint(L):L.directionPoint(F):B>E+10?c=s>=0?M.directionPoint(O):O.directionPoint(M):c=s>=0?F.directionPoint(O):O.directionPoint(F)}else c=s>=0?L.directionPoint(M):M.directionPoint(L);r!==0&&(u=this.computeAngle(t,r,c),t.angle=u),h=L.x+(M.x-L.x)*n,l=L.y+(M.y-L.y)*n}if(o.isNone()){t.moveTo(h,l,!0);return}else o.isNoSpot()&&(o=T.Center);let d=Nt.l();d.Ue(),d.et(t.scale,t.scale),d.ks(t.angle,0,0);let f=t.naturalBounds,p=I.z(0,0,f.width,f.height),g=P.l();g.setRectSpot(p,o),d.gt(g);let y=-g.x,b=-g.y,v=f.width,w=f.height,k=P.bs(a),S=isNaN(a.x),N=isNaN(a.y);if(S||N){let L=v/2+j.H1,M=w/2+j.sv,A=c>=45&&c<=135,F=c>=225&&c<=315;r===0&&(A||F)?(k.x=N?L:a.y,k.y=S?M:a.x,A?s>=0||isNaN(s)&&n<.5||S&&(k.y=-M):F&&((s>=0||isNaN(s)&&n<.5)&&S&&(k.y=-M),N&&(k.x=-L))):(S&&(s>=0||isNaN(s)&&n<.5?k.x=L:k.x=-L),N&&(k.y=-M),k.rotate(c))}else k.rotate(c);h+=k.x,l+=k.y,d.im(p),y+=p.x,b+=p.y;let D=P.z(h+y,l+b);t.move(D),P.i(D),P.i(k),P.i(g),I.i(p),Nt.i(d)}_r(){let t=this.fromNode;if(t!==null){let i=t.findVisibleNode();if(i!==null&&(t=i),t.as()||t.fa())return!1}let e=this.toNode;if(e!==null){let i=e.findVisibleNode();if(i!==null&&(e=i),e.as()||e.fa())return!1}return!0}TC(t,e,i){return!1}DC(){}Di(){return!1}computeAngle(t,e,i){return j.computeAngle(e,i)}static computeAngle(t,e){let i=0;switch(t){default:case 0:i=0;break;case 21:i=e;break;case 22:i=e+90;break;case 23:i=e-90;break;case 24:i=e+180;break;case 25:i=C.Ee(e),i>90&&i<270&&(i-=180);break;case 26:i=C.Ee(e+90),i>90&&i<270&&(i-=180);break;case 27:i=C.Ee(e-90),i>90&&i<270&&(i-=180);break;case 28:if(i=C.Ee(e),i>45&&i<135||i>225&&i<315)return 0;i>90&&i<270&&(i-=180);break}return C.Ee(i)}get fromNode(){return this.mo}set fromNode(t){let e=this.mo;if(e!==t){let i=this.fromPort;e!==null&&(this.yo!==e&&e.hk(this,i),this.jy(),this.invalidateLayout(2)),this.mo=t,t!==null&&this.Xe(t.isVisible()),this.er=null,this.$t();let s=this.diagram;s!==null&&s.G&&s.partManager.setFromNodeForLink(this,t,e);let n=this.fromPort,o=this.fromPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.G,s.G=!0),o(this,i,n),s!==null&&(s.G=r)}t!==null&&(this.yo!==t&&t.ak(this,n),this.Wy(),this.invalidateLayout(1)),this.t("fromNode",e,t),this.Jd()}}get fromPortId(){return this.po}set fromPortId(t){let e=this.po;if(e!==t){let i=this.fromPort;i!==null&&this.fromNode?.Ze(i),this.jy(),this.po=t;let s=this.fromPort;s!==null&&this.fromNode?.Ze(s);let n=this.diagram;if(n!==null){let o=this.data,r=n.model;o!==null&&r.jh()&&r.setFromPortIdForLinkData(o,t)}if(i!==s){this.er=null,this.$t();let o=this.fromPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.G,n.G=!0),o(this,i,s),n!==null&&(n.G=r)}}this.Wy(),this.t("fromPortId",e,t)}}get fromPort(){let t=this.mo;if(t===null)return null;let e=this.po;return t.findPort(e)}get fromPortChanged(){return this.Zd}set fromPortChanged(t){let e=this.Zd;e!==t&&(t!==null&&m.S(t,j,"fromPortChanged"),this.Zd=t,this.t("fromPortChanged",e,t))}get toNode(){return this.yo}set toNode(t){let e=this.yo;if(e!==t){let i=this.toPort;e!==null&&(this.mo!==e&&e.hk(this,i),this.jy(),this.invalidateLayout(2)),this.yo=t,t!==null&&this.Xe(t.isVisible()),this.er=null,this.$t();let s=this.diagram;s!==null&&s.G&&s.partManager.setToNodeForLink(this,t,e);let n=this.toPort,o=this.toPortChanged;if(o!==null){let r=!0;s!==null&&(r=s.G,s.G=!0),o(this,i,n),s!==null&&(s.G=r)}t!==null&&(this.mo!==t&&t.ak(this,n),this.Wy(),this.invalidateLayout(1)),this.t("toNode",e,t),this.Jd()}}get toPortId(){return this.wo}set toPortId(t){let e=this.wo;if(e!==t){let i=this.toPort;i!==null&&this.toNode?.Ze(i),this.jy(),this.wo=t;let s=this.toPort;s!==null&&this.toNode?.Ze(s);let n=this.diagram;if(n!==null){let o=this.data,r=n.model;o!==null&&r.jh()&&r.setToPortIdForLinkData(o,t)}if(i!==s){this.er=null,this.$t();let o=this.toPortChanged;if(o!==null){let r=!0;n!==null&&(r=n.G,n.G=!0),o(this,i,s),n!==null&&(n.G=r)}}this.Wy(),this.t("toPortId",e,t)}}get toPort(){let t=this.yo;if(t===null)return null;let e=this.wo;return t.findPort(e)}get toPortChanged(){return this.Qd}set toPortChanged(t){let e=this.Qd;e!==t&&(t!==null&&m.S(t,j,"toPortChanged"),this.Qd=t,this.t("toPortChanged",e,t))}get fromSpot(){return this.ft!==null?this.ft.Dh:T.Default}set fromSpot(t){let e=this.fromSpot;if(!e.equals(t)){if(t=t.C(),this.$i().Dh=t,this.t("fromSpot",e,t),e.isSide()||t.isSide()){let i=this.fromNode;i!==null&&i.Ze(this.fromPort)}this.$t()}}get fromEndSegmentLength(){return this.ft!==null?this.ft.Fh:NaN}set fromEndSegmentLength(t){let e=this.fromEndSegmentLength;if(e!==t){if(t<0&&m.J(t,">= 0",j,"fromEndSegmentLength"),this.$i().Fh=t,this.t("fromEndSegmentLength",e,t),this.computeSpot(!0,this.fromPort).isSide()){let i=this.fromNode;i!==null&&i.Ze(this.fromPort)}this.$t()}}get fromShortLength(){return this.ft!==null?this.ft.Oh:NaN}set fromShortLength(t){let e=this.fromShortLength;e!==t&&(this.$i().Oh=t,this.ai(),this.t("fromShortLength",e,t))}get toSpot(){return this.ft!==null?this.ft.vh:T.Default}set toSpot(t){let e=this.toSpot;if(!e.equals(t)){if(t=t.C(),this.$i().vh=t,this.t("toSpot",e,t),e.isSide()||t.isSide()){let i=this.toNode;i!==null&&i.Ze(this.toPort)}this.$t()}}get toEndSegmentLength(){return this.ft!==null?this.ft.Rh:NaN}set toEndSegmentLength(t){let e=this.toEndSegmentLength;if(e!==t){if(t<0&&m.J(t,">= 0",j,"toEndSegmentLength"),this.$i().Rh=t,this.t("toEndSegmentLength",e,t),this.computeSpot(!1,this.toPort).isSide()){let i=this.toNode;i!==null&&i.Ze(this.toPort)}this.$t()}}get toShortLength(){return this.ft!==null?this.ft.Ih:NaN}set toShortLength(t){let e=this.toShortLength;e!==t&&(this.$i().Ih=t,this.ai(),this.t("toShortLength",e,t))}Jd(){let t=this.fromNode,e=this.toNode,i=null;if(t!==null?e!==null?i=t.findCommonContainingGroup(e):i=t.containingGroup:e!==null?i=e.containingGroup:i=null,this.CE(i),this.isLabeledLink){let s=this.labelNodes;for(;s.next();){let n=s.value;n.containingGroup=i}}}CE(t){let e=this.Ta;if(e!==t){e!==null&&e.cN(this),this.Ta=t,t!==null&&t.fN(this);let i=this.containingGroupChanged;if(i!==null){let s=!0,n=this.diagram;n!==null&&(s=n.G,n.G=!0),i(this,e,t),n!==null&&(n.G=s)}this.Fi&&(this.xN===e||this.bN===e)&&this.$t()}}Pa(){let t=this.containingGroup;t!==null&&this.fromNode!==t&&this.toNode!==t&&t.computesBoundsIncludingLinks&&super.Pa()}getOtherNode(t){let e=this.fromNode;return t===e?this.toNode:e}getOtherPort(t){let e=this.fromPort;return t===e?this.toPort:e}get isLabeledLink(){return this.on===null?!1:this.on.count>0}get labelNodes(){return this.on===null?Pt.instance:this.on.iterator}JD(t){this.on===null&&(this.on=new V),this.on.add(t),this.f()}$D(t){this.on!==null&&(this.on.delete(t),this.f())}$m(t){if(super.$m(t),this.Qh()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){let e=this.mo,i=null;e!==null&&(i=this.fromPort,e.ak(this,i));let s=this.yo,n=null;s!==null&&(n=this.toPort,(s!==e||n!==i)&&s.ak(this,n)),this.Wy()}}Zm(t){if(super.Zm(t),this.Qh()&&this.invalidateOtherJumpOvers(this.actualBounds),!t){let e=this.mo,i=null;e!==null&&(i=this.fromPort,e.hk(this,i));let s=this.yo,n=null;s!==null&&(n=this.toPort,(s!==e||n!==i)&&s.hk(this,n)),this.jy()}}af(){if(this.Fi=!0,this.on!==null){let t=this.diagram;if(t!==null){let e=this.on.copy().iterator;for(;e.next();){let i=e.value;t.remove(i)}}}if(this.data!==null){let t=this.diagram;t!==null&&t.partManager.LN(this)}}updateRelationshipsFromData(){if(this.data===null)return;let t=this.diagram;t!==null&&t.partManager.updateRelationshipsFromData(this)}move(t,e){let i=e?this.location:this.position,s=i.x;isNaN(s)&&(s=0);let n=i.y;isNaN(n)&&(n=0);let o=t.x-s,r=t.y-n;if(e===!0)super.move(t,!1);else{let h=P.z(i.x+o,i.y+r);super.move(h,!1),P.i(h)}this.kr(o,r);let a=this.labelNodes;for(;a.next();){let h=a.value,l=h.position;h.moveTo(l.x+o,l.y+r)}}get relinkableFrom(){return(this.St&1)!==0}set relinkableFrom(t){let e=(this.St&1)!==0;e!==t&&(this.St=this.St^1,this.t("relinkableFrom",e,t),this.invalidateAdornments())}get relinkableTo(){return(this.St&2)!==0}set relinkableTo(t){let e=(this.St&2)!==0;e!==t&&(this.St=this.St^2,this.t("relinkableTo",e,t),this.invalidateAdornments())}canRelinkFrom(){if(!this.relinkableFrom)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;let e=t.diagram;return!(e!==null&&!e.allowRelink)}canRelinkTo(){if(!this.relinkableTo)return!1;let t=this.layer;if(t===null)return!0;if(!t.allowRelink)return!1;let e=t.diagram;return!(e!==null&&!e.allowRelink)}get resegmentable(){return(this.St&4)!==0}set resegmentable(t){let e=(this.St&4)!==0;e!==t&&(this.St=this.St^4,this.t("resegmentable",e,t),this.invalidateAdornments())}get isTreeLink(){return(this.St&8)!==0}set isTreeLink(t){let e=(this.St&8)!==0;e!==t&&(this.St=this.St^8,this.t("isTreeLink",e,t),this.fromNode!==null&&this.fromNode.Lp(),this.toNode!==null&&this.toNode.Lp())}get path(){let t=this.findMainElement();return t instanceof it?t:null}get routeBounds(){return this.updateRoute(),this.bl}AN(t){let e=1/0,i=1/0,s=this.pointsCount;if(s===0)return t.e(NaN,NaN,0,0),t;if(s===1){let n=this.getPoint(0);e=Math.min(n.x,e),i=Math.min(n.y,i),t.e(n.x,n.y,0,0)}else if(s===2){let n=this.getPoint(0),o=this.getPoint(1);e=Math.min(n.x,o.x),i=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o)}else if(this.computeCurve()===9&&s>=3&&!this.isOrthogonal){let n=this.getPoint(0);if(e=n.x,i=n.y,t.e(e,i,0,0),s===3){let o=this.getPoint(1);e=Math.min(o.x,e),i=Math.min(o.y,i);let r=this.getPoint(2);e=Math.min(r.x,e),i=Math.min(r.y,i),C.Cu(n.x,n.y,o.x,o.y,o.x,o.y,r.x,r.y,.5,t)}else for(let o=3;o<s;o+=3){let r=this.getPoint(o-2);o+3>=s&&(o=s-1);let a=this.getPoint(o-1),h=this.getPoint(o);C.Cu(n.x,n.y,r.x,r.y,a.x,a.y,h.x,h.y,.5,t),e=Math.min(h.x,e),i=Math.min(h.y,i),n=h}}else{let n=this.getPoint(0),o=this.getPoint(1);e=Math.min(n.x,o.x),i=Math.min(n.y,o.y),t.e(n.x,n.y,0,0),t.unionPoint(o);for(let r=2;r<s;r++){let a=this.getPoint(r);e=Math.min(a.x,e),i=Math.min(a.y,i),t.unionPoint(a)}}return this.ck.e(e-t.x,i-t.y),t}get midPoint(){return this.KC(new P)}KC(t){return this.updateRoute(),this.computeMidPoint(t)}computeMidPoint(t){let e=this.pointsCount;if(e===0)return t.h(P.mn),t;if(e===1)return t.h(this.getPoint(0)),t;if(e===2){let l=this.getPoint(0),u=this.getPoint(1);return t.e((l.x+u.x)/2,(l.y+u.y)/2),t}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9)){this.ut.getPointAlongPath(.5,t),t.add(this.getPoint(0));let l=this.ut.figures.first();return t.offset(-l.startX,-l.startY),t}if(this.computeCurve()===9){if(e===3){let c=this.getPoint(0),d=this.getPoint(1),f=this.getPoint(2);return C.YL(c.x,c.y,d.x,d.y,d.x,d.y,f.x,f.y,t),t}let l=(e-1)/3|0,u=(l/2|0)*3;if(l%2===1){let c=this.getPoint(u),d=this.getPoint(u+1),f=this.getPoint(u+2),p=this.getPoint(u+3);return C.YL(c.x,c.y,d.x,d.y,f.x,f.y,p.x,p.y,t),t}else return t.h(this.getPoint(u)),t}let i=this.flattenedLengths,s=this.flattenedTotalLength,n=0,o=0,r=0;for(;n<s/2&&o<e&&(r=i[o],!(n+r>s/2));)n+=r,o++;let a=this.getPoint(o),h=this.getPoint(o+1);if(Math.abs(a.x-h.x)<1)a.y>h.y?t.e(a.x,a.y-(s/2-n)):t.e(a.x,a.y+(s/2-n));else if(Math.abs(a.y-h.y)<1)a.x>h.x?t.e(a.x-(s/2-n),a.y):t.e(a.x+(s/2-n),a.y);else{let l=(s/2-n)/r,u=l*(h.x-a.x),c=l*(h.y-a.y);t.e(a.x+u,a.y+c)}return t}get midAngle(){return this.updateRoute(),this.computeMidAngle()}computeMidAngle(){let t=this.pointsCount;if(t<2)return NaN;if(t===2){let h=this.getPoint(0),l=this.getPoint(1);return h.directionPoint(l)}if(this.isOrthogonal&&(this.computeCorner()>=15||this.computeCurve()===9))return this.ut.getAngleAlongPath(.5);if(this.computeCurve()===9&&t>=4){let h=(t-1)/3|0,l=(h/2|0)*3;if(h%2===1){l=Math.floor(l);let u=this.getPoint(l),c=this.getPoint(l+1),d=this.getPoint(l+2),f=this.getPoint(l+3);return C.qF(u.x,u.y,c.x,c.y,d.x,d.y,f.x,f.y)}else if(l>0&&l+1<t){let u=this.getPoint(l-1),c=this.getPoint(l+1);return u.directionPoint(c)}}let e=this.flattenedLengths,i=this.flattenedTotalLength,s=0,n=0,o=0;for(;s<i/2&&n<t&&(o=e[n],!(s+o>i/2));)s+=o,n++;let r=this.getPoint(n),a=this.getPoint(n+1);if(Math.abs(r.x-a.x)<.5&&Math.abs(r.y-a.y)<j.MN){if(n>0&&n<t-2){let h=this.getPoint(n-1),l=this.getPoint(n+2);return h.x<l.x?0:h.x>l.x?180:h.y<l.y?90:270}}else if(Math.abs(r.y-a.y)<.5&&Math.abs(r.x-a.x)<j.MN&&n>0&&n<t-2){let h=this.getPoint(n-1),l=this.getPoint(n+2);return h.y<l.y?90:h.y>l.y?270:h.x<l.x?0:180}return r.directionPoint(a)}get flattenedLengths(){return this.Jh!==null?this.Jh:(this.Fi||this.uk(),this.NE())}get flattenedTotalLength(){let t=this.fk;if(isNaN(t)){let e=this.flattenedLengths,i=e.length;t=0;for(let s=0;s<i;s++)t+=e[s];this.fk=t}return t}NE(){this.Jh===null?this.Jh=[]:this.Jh.length=0;let t=this.Jh,e=this.pointsCount;for(let i=0;i<e-1;i++){let s=0,n=this.getPoint(i),o=this.getPoint(i+1);C.X(n.x,o.x)?(s=o.y-n.y,s<0&&(s=-s),t.push(s)):C.X(n.y,o.y)?(s=o.x-n.x,s<0&&(s=-s),t.push(s)):(s=Math.sqrt(n.distanceSquaredPoint(o)),t.push(s))}return t}get points(){return this.Ce}set points(t){let e=this.Ce;if(e===t)return;let i=null;if(Array.isArray(t))i=this.convertPointsArrayToList(t);else if(t instanceof q){i=t.copy();let n=i.iterator;for(;n.next();)n.value.k()}else m.o("Link.points value is not an instance of List or Array: "+t);if(i===null)return;i.k(),this.Ce=i,this.ai(),this.uk();let s=this.diagram;s!==null&&(!s.Za&&!s.undoManager.isUndoingRedoing&&s.eb.add(this),s.animationManager.Pe&&s.animationManager.NM(this,i)),this.t("points",e,i)}convertPointsArrayToList(t){let e=null,i=t.length%2===0;if(i){for(let s=0;s<t.length;s++)if(typeof t[s]!="number"||isNaN(t[s])){i=!1;break}}if(i){e=new q;for(let s=0;s<t.length/2;s++)e.add(new P(t[s*2],t[s*2+1]).k())}else{let s=!0;for(let n=0;n<t.length;n++){let o=t[n];if(!m.$(o)||typeof o.x!="number"||isNaN(o.x)||typeof o.y!="number"||isNaN(o.y)){s=!1;break}}if(s){e=new q;for(let n=0;n<t.length;n++){let o=t[n];e.add(new P(o.x,o.y).k())}}}return e}get pointsCount(){return this.Ce.count}getPoint(t){return this.Ce.r[t]}setPoint(t,e){this.Ce.setElt(t,e)}setPointAt(t,e,i){this.Ce.setElt(t,new P(e,i))}insertPoint(t,e){this.Ce.insertAt(t,e)}insertPointAt(t,e,i){this.Ce.insertAt(t,new P(e,i))}addPoint(t){this.Ce.add(t)}addPointAt(t,e){this.Ce.add(new P(t,e))}removePoint(t){this.Ce.removeAt(t)}clearPoints(){this.Ce.clear()}kr(t,e){if(t===0&&e===0)return;if(this.pointsCount===0){this.defaultFromPoint.isReal()&&this.defaultFromPoint.offset(t,e),this.defaultToPoint.isReal()&&this.defaultToPoint.offset(t,e);return}let i=this.Fi,s=new q,n=this.Ce.iterator;for(;n.next();){let a=n.value;s.add(new P(a.x+t,a.y+e).k())}s.k();let o=this.Ce;this.Ce=s;let r=this.diagram;isNaN(t)||isNaN(e)||r!==null&&r.animationManager.Pe?this.f():(this.nn.e(this.nn.x+t,this.nn.y+e),this.ct.e(this.ct.x+t,this.ct.y+e),this.Pf()),i?this.uk():(this.defaultFromPoint.isReal()&&(this.defaultFromPoint=this.getPoint(0)),this.defaultToPoint.isReal()&&(this.defaultToPoint=this.getPoint(this.pointsCount-1))),r!==null&&r.animationManager.Pe&&r.animationManager.NM(this,s),this.t("points",o,s)}startRoute(){this.xl===null&&(this.xl=this.Ce,this.Ce=this.Ce.copy())}commitRoute(){if(this.xl===null)return;let t=this.xl,e=this.Ce;this.xl=null;let i=this.diagram;i!==null&&i.animationManager.Pe&&i.animationManager.NM(this,e),this.ai(),this.uk(),this.t("points",t,e)}rollbackRoute(){this.xl!==null&&(this.Ce=this.xl,this.xl=null,this.AN(this.bl))}vR(){this.Dr!==null&&(this.points=this.Dr,this.Dr=null)}uk(){if(this.Ce.count===0){this.Fi=!1;return}this.Fi=!0,this.AN(this.bl),this.Jh=null,this.fk=NaN,this.defaultFromPoint=this.getPoint(0),this.defaultToPoint=this.getPoint(this.pointsCount-1),this.dk(!1)}invalidateRoute(){this.$t()}$t(){if(this.suspendsRouting)return;let t=this.path;if(t===null)return;let e=this.diagram;if(e){if(e.eb.has(this)||e.undoManager.isUndoingRedoing)return;let i=e.animationManager;if(i.isTicking&&!i.isAnimating)return;this.Dr!==null&&!i.isTicking&&(this.Dr=null)}this.Fi=!1,this.f(),t.f()}get Fi(){return(this.St&16)!==0}set Fi(t){(this.St&16)!==0!==t&&(this.St=this.St^16)}get suspendsRouting(){return(this.St&32)!==0}set suspendsRouting(t){(this.St&32)!==0!==t&&(this.St=this.St^32)}get Jy(){return(this.St&64)!==0}set Jy(t){(this.St&64)!==0!==t&&(this.St=this.St^64)}get TN(){return(this.St&512)!==0}set TN(t){(this.St&512)!==0!==t&&(this.St=this.St^512)}get defaultFromPoint(){return this.yN}set defaultFromPoint(t){this.yN=t&&t.isReal()?t.copy():P.mn}get defaultToPoint(){return this.wN}set defaultToPoint(t){this.wN=t&&t.isReal()?t.copy():P.mn}updateRoute(){if(this.Fi||this.Jy)return;let t=!0;try{this.Jy=!0,this.startRoute(),t=this.computePoints()}catch{this.Jy=!1,this.rollbackRoute()}finally{this.Jy=!1,t?this.commitRoute():this.rollbackRoute()}}computePoints(){let t=this.diagram;if(t===null)return!1;let e=this.fromNode,i=null;if(e===null?(j.$h||(j.$h=new $,j.$h.desiredSize=nt.xc,j.$h.ensureBounds()),this.defaultFromPoint.isReal()&&(j.$h.location=this.defaultFromPoint,j.$h.ensureBounds(),e=j.$h,i=j.$h)):i=this.fromPort,i!==null&&!e.isVisible()){let p=e.findVisibleNode();p!==null&&p!==e?(e=p,i=p.port):e=p}if(this.xN=e,e===null||!e.location.isReal()||i===null||(i=e.findVisiblePort(i),i===null))return!1;let s=this.toNode,n=null;if(s===null?(j.Zh||(j.Zh=new $,j.Zh.desiredSize=nt.xc,j.Zh.ensureBounds()),this.defaultToPoint.isReal()&&(j.Zh.location=this.defaultToPoint,j.Zh.ensureBounds(),s=j.Zh,n=j.Zh)):n=this.toPort,n!==null&&!s.isVisible()){let p=s.findVisibleNode();p!==null&&p!==s?(s=p,n=p.port):s=p}if(this.bN=s,s===null||!s.location.isReal()||n===null||(n=s.findVisiblePort(n),n===null))return!1;let o=this.pointsCount,r=this.computeSpot(!0,i),a=this.computeSpot(!1,n),h=this.kl(r),l=this.kl(a),u=i===n&&i!==null,c=this.isOrthogonal,d=this.curve===9;u&&!c?(d=!0,this.er=!0):this.er=!1;let f=this.computeAdjusting()===0||u;if(!c&&!u&&h&&l){let p=!1;if(!f&&o>=3){let g=this.getLinkPoint(e,i,r,!0,!1,s,n),y=this.getLinkPoint(s,n,a,!1,!1,e,i);p=this.adjustPoints(0,g,o-1,y),p&&(g=this.getLinkPoint(e,i,r,!0,!1,s,n),y=this.getLinkPoint(s,n,a,!1,!1,e,i),this.adjustPoints(0,g,o-1,y))}p||(this.clearPoints(),d?this.LE(e,i,r,s,n,a):this.AE(e,i,r,s,n,a))}else{let p=u?this.computeCurviness():0;f&&(c&&this.isAvoiding||u)&&this.clearPoints();let g=this.getLinkPoint(e,i,r,!0,c,s,n),y=this.getLinkPoint(s,n,a,!1,c,e,i),b=0,v=0,w=0;if(c||!h||u){w=this.getLinkDirection(e,i,g,r,!0,c,s,n);let M=this.gk(e,i,r,!0,w);if(u&&(h||r.equals(a)||!c&&r.x+a.x===1&&r.y+a.y===1)&&(w-=c?90:j.rv,p<0&&(w-=180)),w=C.Ee(w),u&&(M+=Math.abs(p)*(c?1:2)),w===0?b=M:w===90?v=M:w===180?b=-M:w===270?v=-M:(b=M*Math.cos(w*Math.PI/180),v=M*Math.sin(w*Math.PI/180)),r.isNoSpot()&&u){let A=i.getDocumentPoint(T.Center,P.l()),F=P.z(A.x+b*j.Yf,A.y+v*j.Yf);this.getLinkPointFromPoint(e,i,A,F,!0,g),P.i(A),P.i(F)}}let k=0,S=0,N=0;if(c||!l||u){N=this.getLinkDirection(s,n,y,a,!1,c,e,i);let M=this.gk(s,n,a,!1,N);if(u&&(l||r.equals(a)||!c&&r.x+a.x===1&&r.y+a.y===1)&&(N+=c?0:j.lv,p<0&&(N+=180)),N=C.Ee(N),u&&(M+=Math.abs(p)*(c?1:2)),N===0?k=M:N===90?S=M:N===180?k=-M:N===270?S=-M:(k=M*Math.cos(N*Math.PI/180),S=M*Math.sin(N*Math.PI/180)),a.isNoSpot()&&u){let A=n.getDocumentPoint(T.Center,P.l()),F=P.z(A.x+k*j.Yf,A.y+S*j.Yf);this.getLinkPointFromPoint(s,n,A,F,!1,y),P.i(A),P.i(F)}}let D=g;(c||!h||u)&&(D=new P(g.x+b,g.y+v));let L=y;(c||!l||u)&&(L=new P(y.x+k,y.y+S)),!f&&!c&&h&&o>3&&this.adjustPoints(0,g,o-2,L)?this.setPoint(o-1,y):!f&&!c&&l&&o>3&&this.adjustPoints(1,D,o-1,y)?this.setPoint(0,g):!f&&(c?o>=6:o>4)&&this.adjustPoints(1,D,o-2,L)?(this.setPoint(0,g),this.setPoint(o-1,y)):(this.clearPoints(),this.addPoint(g),(c||!h||u)&&this.addPoint(D),c&&this.addOrthoPoints(D,w,L,N,e,s),(c||!l||u)&&this.addPoint(L),this.addPoint(y))}return t.addInvalidRoute(this),!0}DN(t,e){return Math.abs(e.x-t.x)>Math.abs(e.y-t.y)?(e.x>=t.x?e.x=t.x+9e9:e.x=t.x-9e9,e.y=t.y):(e.y>=t.y?e.y=t.y+9e9:e.y=t.y-9e9,e.x=t.x),e}getLinkPointFromPoint(t,e,i,s,n,o){if(o===void 0&&(o=new P),t===null||e===null)return o.h(i),o;if(!t.isVisible()){let d=t.findVisibleNode();d!==null&&d!==t&&(t=d,e=t.port)}let r=0,a=0,h=0,l=0,u=null,c=e.panel;if(c!==null&&!c.Cn()&&(c=c.panel),c===null)r=s.x,a=s.y,h=i.x,l=i.y;else{u=c.Js;let d=1/(u.m11*u.m22-u.m12*u.m21),f=u.m22*d,p=-u.m12*d,g=-u.m21*d,y=u.m11*d,b=d*(u.m21*u.dy-u.m22*u.dx),v=d*(u.m12*u.dx-u.m11*u.dy);r=s.x*f+s.y*g+b,a=s.x*p+s.y*y+v,h=i.x*f+i.y*g+b,l=i.x*p+i.y*y+v}return e.pf(r,a,h,l,o),u!==null&&o.v(u),o}TE(t,e){let i=t.wd;return i!==null?i.dv(e):null}mk(t){if(t===null)return null;let e=t.wd;return e===null&&(e=new Ji(t.part,t),t.wd=e),e.dv(this)}getLinkPoint(t,e,i,s,n,o,r,a){if(a===void 0&&(a=new P),i.isSpot()&&!this.kl(i))return e.getDocumentPoint(i,a),a;if(i.isSide()){let u=this.mk(e);if(u!==null){let c=u._h;if(a.h(c),n&&this.routing===7){let d=this.mk(r);if(d!==null&&u.Kf<d.Kf){let f=P.l(),p=P.l(),g=I.l();e.getDocumentPoint(T.TopLeft,f),e.getDocumentPoint(T.BottomRight,p);let y=f.x,b=f.y,v=p.x,w=p.y;g.x=Math.min(y,v),g.y=Math.min(b,w),g.width=Math.abs(y-v),g.height=Math.abs(b-w);let k=this.computeSpot(!s,r),S=this.getLinkPoint(o,r,k,!s,n,t,e,p);(i.includesSide(T.LeftSide)||i.includesSide(T.RightSide))&&S.y>=g.y&&S.y<=g.y+g.height?a.y=S.y:(i.includesSide(T.TopSide)||i.includesSide(T.BottomSide))&&S.x>=g.x&&S.x<=g.x+g.width&&(a.x=S.x),I.i(g),P.i(f),P.i(p)}}return a}}let h=e.getDocumentPoint(this.sg(i,s),P.l()),l=P.l();if(this.pointsCount>(n?6:2))l.h(s?this.getPoint(1):this.getPoint(this.pointsCount-2)),n&&this.DN(h,l);else if(t?.isMemberOf(o)||o?.isMemberOf(t)){let u=e.getDocumentBounds(I.l()),c=r.getDocumentBounds(I.l());u.isReal()&&c.isReal()?c.containsRect(u)?(l.h(h),this.vN(c,h.x,h.y,0,this.computeSpot(r===this.toPort,r),l)):u.containsRect(c)?(r.getDocumentPoint(T.Center,l),this.vN(u,l.x,l.y,0,this.computeSpot(e===this.toPort,e),l)):this.FN(r,h,s,n,l):this.FN(r,h,s,n,l),I.i(u),I.i(c)}else this.FN(r,h,s,n,l);return this.getLinkPointFromPoint(t,e,h,l,s,a),P.i(l),P.i(h),a}FN(t,e,i,s,n){let o=this.computeSpot(!i,t);t.getDocumentPoint(this.sg(o,!i),n),s&&this.DN(e,n)}getLinkDirection(t,e,i,s,n,o,r,a){let h=this.DE(t,e,i,s,n,o,r,a);if(t&&r){let u=I.l(),c=I.l();if(s.isNone()&&t.isMemberOf(r)&&e&&a){if(e.getDocumentBounds(u),a.getDocumentBounds(c),u.isReal()&&c.isReal()&&c.containsRect(u)){let d=this.computeSpot(a===this.toPort,a);d.equals(T.Left)||d.equals(T.LeftSide)?h=180:d.equals(T.Right)||d.equals(T.RightSide)?h=0:d.equals(T.Top)||d.equals(T.TopSide)?h=270:d.equals(T.Bottom)||d.equals(T.BottomSide)?h=90:h=C.Ee(h+180)}}else r?.isMemberOf(t)&&e&&a&&(e.getDocumentBounds(u),a.getDocumentBounds(c),u.isReal()&&c.isReal()&&u.containsRect(c)&&(h=C.Ee(h+180)));I.i(u),I.i(c)}if(this.kl(s)||e===null)return h;let l=e.getDocumentAngle();return l===0?h:(45<=l&&l<135?h+=90:135<=l&&l<225?h+=180:225<=l&&l<315&&(h+=270),C.Ee(h))}DE(t,e,i,s,n,o,r,a){if(s.isSpot())return C.Jw(null,s.x,s.y);if(s.isSide()){let c=this.mk(e);if(c!==null)switch(c.fi){case 1:return 270;case 8:return 90;case 2:return 180;default:return 0}else return s.includesSide(T.TopSide)?270:s.includesSide(T.BottomSide)?90:s.includesSide(T.LeftSide)?180:0}if(e===null||a===null)return 0;let h=e.getDocumentPoint(T.Center,P.l()),l=P.l();this.pointsCount>(o?6:2)?o?(l.h(n?this.getPoint(1):this.getPoint(this.pointsCount-2)),this.DN(h,l)):l.h(i):a.getDocumentPoint(T.Center,l);let u=0;return Math.abs(l.x-h.x)>Math.abs(l.y-h.y)?l.x>=h.x?u=0:u=180:l.y>=h.y?u=90:u=270,P.i(l),P.i(h),u}computeEndSegmentLength(t,e,i,s){return this.gk(t,e,i,s,NaN)}gk(t,e,i,s,n){if(e!==null&&i.isSide()){let r=this.mk(e);if(r!==null)return r.pk}let o=NaN;if(s?o=this.fromEndSegmentLength:o=this.toEndSegmentLength,e!==null&&isNaN(o))if(n===void 0&&(n=NaN),j.CN>0&&this.computeCurve()===9&&!isNaN(n)&&i.isSpot()){let r=this.getOtherPort(e);if(r){let a=P.l(),h=P.l(),l=e.getDocumentPoint(i,a),u=r.getDocumentPoint(i.opposite(),h),c=n>=315||n<=45||n>=135&&n<=225,d=Math.abs(c?l.x-u.x:l.y-u.y)/j.CN;return d=Math.max(d,j.NN),P.i(a),P.i(h),d}}else s?o=e.fromEndSegmentLength:o=e.toEndSegmentLength;return isNaN(o)&&(o=j.NN),o}computeSpot(t,e){return e===void 0&&(e=null),t?this.vE(e||this.fromPort):this.FE(e||this.toPort)}vE(t){if(t===null)return T.Center;let e=this.fromSpot;return e.isDefault()&&(e=t.fromSpot),e===T.Default?T.None:e}FE(t){if(t===null)return T.Center;let e=this.toSpot;return e.isDefault()&&(e=t.toSpot),e===T.Default?T.None:e}kl(t){return t===T.None||t.x===.5&&t.y===.5}sg(t,e){return t.x===.5&&t.y===.5?t:T.Center}computeOtherPoint(t,e){if(this.computeAdjusting()!==0&&this.pointsCount>4)return this.getPoint(Math.floor(this.pointsCount/2));{let i=this.TE(e,this);if(i!==null)return i._h;if(t instanceof ht){let s=this.fromNode,n=this.fromPort;n===e&&(s=this.toNode,n=this.toPort);let o=I.l(),r=I.l();if(n&&s?.isMemberOf(t)){let a=this.computeSpot(n===e,e);if(e.getDocumentBounds(o),n.getDocumentBounds(r),o.isReal()&&r.isReal()&&o.containsRect(r)){let h=n.getDocumentPoint(T.Center);return this.vN(o,h.x,h.y,0,a,h),I.i(o),I.i(r),h}}I.i(o),I.i(r)}return e.getDocumentPoint(T.Center)}}computeShortLength(t){if(t){let e=this.fromShortLength;if(isNaN(e)){let i=this.fromPort;i!==null&&(e=i.fromShortLength)}return isNaN(e)?0:e}else{let e=this.toShortLength;if(isNaN(e)){let i=this.toPort;i!==null&&(e=i.toShortLength)}return isNaN(e)?0:e}}jm(t,e,i,s,n,o){if(this.pickable===!1)return!1;e===void 0&&(e=null),i===void 0&&(i=null);let r;if(o===void 0?(r=Nt.l(),r.Ue()):r=o,r.bc(this.v),this.containedInRect(t,r))return this.WC(e,i,n),o===void 0&&Nt.i(r),!0;if(this.intersectsRect(t,r)){let a=!1;if(!this.Tf){let h=this.D.r,l=h.length;for(let u=l;u--;){let c=h[u];if(!c.visible&&c!==this.locationObject)continue;let d=c.actualBounds,f=this.naturalBounds;if(d.x>f.width||d.y>f.height||d.x+d.width<0||d.y+d.height<0)continue;let p=c,g=Nt.l();if(g.set(r),p instanceof G?a=p.jm(t,e,i,s,n,g):this.path===p?p instanceof it&&(a=p.oE(t,s,g)):a=p.$T(t,s,g),a){let y=p;e!==null&&(y=e(p)),y&&(i===null||i(y))&&n.add(y)}Nt.i(g)}}return o===void 0&&Nt.i(r),a||this.background!==null}return o===void 0&&Nt.i(r),!1}get isOrthogonal(){return(this.Wh&2)===2}static SN(t){return(t&2)===2}get isAvoiding(){return(this.Wh&4)===4}computeCurve(){if(this.er===null){let t=this.fromPort,e=t!==null&&t===this.toPort,i=this.isOrthogonal;this.er=e&&!i}return this.er?9:this.curve}computeCorner(){if(this.curve===9)return 0;let t=this.corner;return(isNaN(t)||t<0)&&(t=j.av),t}findMidLabel(){let t=this.path,e=this.D.r,i=e.length;for(let n=0;n<i;n++){let o=e[n];if(!(o===t||o.isPanelMain)&&(o.segmentIndex===-1/0||isNaN(o.segmentIndex)))return o}let s=this.labelNodes;for(;s.next();){let n=s.value;if(n.segmentIndex===-1/0||isNaN(n.segmentIndex))return n}return null}computeSpacing(){if(!this.isVisible())return 0;let t=j.hv;t=Math.max(t,this.computeThickness());let e=this.fromPort,i=this.toPort;if(e!==null&&i!==null){let s=this.findMidLabel();if(s!==null){let n=s.naturalBounds,o=s.margin,r=isNaN(n.width)?j.cv:n.width*s.scale+o.left+o.right,a=isNaN(n.height)?j.fv:n.height*s.scale+o.top+o.bottom,h=s.segmentOrientation;if(h===21||h===25||h===24)t=Math.max(t,a);else if(h===23||h===27||h===22||h===26)t=Math.max(t,r);else{let l=e.getDocumentPoint(T.Center).directionPoint(i.getDocumentPoint(T.Center))/180*Math.PI;t=Math.max(t,Math.abs(Math.sin(l)*r)+Math.abs(Math.cos(l)*a)+1)}this.curve===9&&(t*=j.nv)}}return t}arrangeBundledLinks(t,e){if(e)for(let i=0;i<t.length;i++){let s=t[i];s.computeAdjusting()===0&&s.$t()}}computeCurviness(){let t=this.curviness;if(isNaN(t)){t=j.iv;let e=this.ir;if(e!==null){let i=m.st(),s=0,n=e.rn;for(let r=0;r<n.length;r++){let a=n[r].computeSpacing();i.push(a),s+=a}let o=-s/2;for(let r=0;r<n.length;r++){if(n[r]===this){t=o+i[r]/2;break}o+=i[r]}e.Vy===this.fromNode&&(t=-t),m.Z(i)}}return t}computeThickness(){if(!this.isVisible())return 0;let t=this.path;return t!==null?Math.max(t.strokeWidth,1):1}hasCurviness(){return!isNaN(this.curviness)||this.ir!==null}AE(t,e,i,s,n,o){let r=this.getLinkPoint(t,e,i,!0,!1,s,n),a=this.getLinkPoint(s,n,o,!1,!1,t,e);if(this.gv(t,e,i,r,s,n,o,a),this.addPoint(r),this.addPoint(a),this.hasCurviness()){let h=a.x-r.x,l=a.y-r.y,u=this.computeCurviness(),c=u,d=r.x+h/2,f=r.y+l/2,p=d,g=f;if(C.c(l,0))h>0?g-=c:g+=c;else{let y=-h/l,b=Math.sqrt(c*c/(y*y+1));u<0&&(b=-b),p=(l<0?-1:1)*b+d,g=y*(p-d)+f}this.insertPointAt(1,p,g)}}gv(t,e,i,s,n,o,r,a){let h=o.getDocumentBounds(I.l()),l=e.getDocumentBounds(I.l());if(l.intersectsRect(h)){let u=P.l();if(h.containsRect(l)){if(o.containsPoint(o.getLocalPoint(s,u))){let c=P.l();e.getDocumentPoint(this.sg(i,!0),c),a.h(c),this.RN(h,c.x,c.y,j.Yf,a),this.getLinkPointFromPoint(n,o,h.containsPoint(c)?c:s,a,!1,a),this.getLinkPointFromPoint(t,e,c,a,!0,s),P.i(c)}}else if(l.containsRect(h)){if(e.containsPoint(e.getLocalPoint(a,u))){let c=P.l();o.getDocumentPoint(this.sg(r,!1),c),s.h(c),this.RN(l,c.x,c.y,j.Yf,s),this.getLinkPointFromPoint(t,e,l.containsPoint(c)?c:a,s,!0,s),this.getLinkPointFromPoint(n,o,c,s,!1,a),P.i(c)}}else{let c=P.l();e.getDocumentPoint(this.sg(i,!0),c);let d=P.l();o.getDocumentPoint(this.sg(r,!1),d);let f=o.containsPoint(o.getLocalPoint(c,u)),p=e.containsPoint(e.getLocalPoint(d,u));if(f||p)s.h(c),a.h(d);else if(o.containsPoint(o.getLocalPoint(s,u))||e.containsPoint(e.getLocalPoint(a,u))){let g=s.x,y=s.y;s.x=a.x,s.y=a.y,a.x=g,a.y=y}P.i(c),P.i(d)}P.i(u)}I.i(h),I.i(l)}vN(t,e,i,s,n,o){let r=-1;return n.equals(T.Left)||n.equals(T.LeftSide)?r=180:n.equals(T.Right)||n.equals(T.RightSide)?r=0:n.equals(T.Top)||n.equals(T.TopSide)?r=270:(n.equals(T.Bottom)||n.equals(T.BottomSide))&&(r=90),r===-1?this.RN(t,e,i,0,o):this.mv(t,e,i,0,r,o)}RN(t,e,i,s,n){let o=C.Jw(t,e,i);return this.mv(t,e,i,s,o,n)}mv(t,e,i,s,n,o){return n===0?o.x=t.right+s:n===90?o.y=t.bottom+s:n===180?o.x=t.x-s:n===270?o.y=t.y-s:n===45?(o.x=t.right+s,o.y=t.bottom+s):n===135?(o.x=t.x-s,o.y=t.bottom+s):n===225?(o.x=t.x-s,o.y=t.y-s):n===315&&(o.x=t.right+s,o.y=t.y-s),o}LE(t,e,i,s,n,o){let r=this.getLinkPoint(t,e,i,!0,!1,s,n),a=this.getLinkPoint(s,n,o,!1,!1,t,e);this.gv(t,e,i,r,s,n,o,a),this.addPoint(r),this.addPoint(a);let h=a.x-r.x,l=a.y-r.y,u=this.computeCurviness(),c=0,d=0,f=r.x+h/3,p=r.y+l/3,g=f,y=p;C.c(l,0)?h>0?y-=u:y+=u:(c=-h/l,d=Math.sqrt(u*u/(c*c+1)),u<0&&(d=-d),g=(l<0?-1:1)*d+f,y=c*(g-f)+p),f=r.x+2*h/3,p=r.y+2*l/3;let b=f,v=p;C.c(l,0)?h>0?v-=u:v+=u:(b=(l<0?-1:1)*d+f,v=c*(b-f)+p),this.insertPointAt(1,g,y),this.insertPointAt(2,b,v),this.setPoint(0,this.getLinkPoint(t,e,i,!0,!1,s,n)),this.setPoint(3,this.getLinkPoint(s,n,o,!1,!1,t,e))}adjustPoints(t,e,i,s){let n=this.computeAdjusting();if(this.isOrthogonal){if(n===18)return!1;n===19&&(n=17)}switch(n){case 18:return this.RE(t,e,i,s);case 19:return this.OE(t,e,i,s);case 17:return this.IE(t,e,i,s);default:return!1}}RE(t,e,i,s){let n=this.getPoint(t),o=this.getPoint(i);if(n.equalsApprox(e)&&o.equalsApprox(s))return!0;let r=n.x,a=n.y,h=o.x,l=o.y,u=h-r,c=l-a,d=Math.sqrt(u*u+c*c);if(C.X(d,0))return!0;let f=0;C.X(u,0)?c<0?f=-Math.PI/2:f=Math.PI/2:(f=Math.atan(c/Math.abs(u)),u<0&&(f=Math.PI-f));let p=e.x,g=e.y,y=s.x,b=s.y,v=y-p,w=b-g,k=Math.sqrt(v*v+w*w),S=0;C.X(v,0)?w<0?S=-Math.PI/2:S=Math.PI/2:(S=Math.atan(w/Math.abs(v)),v<0&&(S=Math.PI-S));let N=k/d,D=S-f;this.setPoint(t,e);for(let L=t+1;L<i;L++){let M=this.getPoint(L);u=M.x-r,c=M.y-a;let A=Math.sqrt(u*u+c*c);if(C.X(A,0))continue;let F=0;C.X(u,0)?c<0?F=-Math.PI/2:F=Math.PI/2:(F=Math.atan(c/Math.abs(u)),u<0&&(F=Math.PI-F));let O=F+D,E=A*N,B=p+E*Math.cos(O),X=g+E*Math.sin(O);this.setPointAt(L,B,X)}return this.setPoint(i,s),!0}OE(t,e,i,s){let n=this.getPoint(t),o=this.getPoint(i);if(n.equalsApprox(e)&&o.equalsApprox(s))return!0;let r=n.x,a=n.y,h=o.x,l=o.y,u=(h-r)**2+(l-a)**2,c=e.x,d=e.y,f=s.x,p=s.y,g=0,y=1;f-c!==0?(g=(p-d)/(f-c),y=Math.sqrt(1+1/(g*g))):g=9e9,this.setPoint(t,e);for(let b=t+1;b<i;b++){let v=this.getPoint(b),w=v.x,k=v.y,S=.5;u!==0&&(S=((r-w)*(r-h)+(a-k)*(a-l))/u);let N=r+S*(h-r),D=a+S*(l-a),L=Math.sqrt((w-N)**2+(k-D)**2);k<g*(w-N)+D&&(L=-L),g>0&&(L=-L);let M=c+S*(f-c),A=d+S*(p-d);if(g!==0){let F=M+L/y,O=A-(F-M)/g;this.setPointAt(b,F,O)}else this.setPointAt(b,M,A+L)}return this.setPoint(i,s),!0}IE(t,e,i,s){if(this.isOrthogonal){let n=this.getPoint(t),o=this.getPoint(t+1),r=this.getPoint(t+2),a=o.x,h=o.y,l=a,u=h;C.c(n.y,o.y)?C.c(o.x,r.x)?h=e.y:C.c(o.y,r.y)&&(a=e.x):C.c(n.x,o.x)&&(C.c(o.y,r.y)?a=e.x:C.c(o.x,r.x)&&(h=e.y)),this.setPointAt(t+1,a,h),n=this.getPoint(i),o=this.getPoint(i-1),r=this.getPoint(i-2);let c=o.x,d=o.y,f=c,p=d;if(C.c(n.y,o.y)?C.c(o.x,r.x)?d=s.y:C.c(o.y,r.y)&&(c=s.x):C.c(n.x,o.x)&&(C.c(o.y,r.y)?c=s.x:C.c(o.x,r.x)&&(d=s.y)),this.setPointAt(i-1,c,d),this.yT())return this.setPointAt(t+1,l,u),this.setPointAt(i-1,f,p),!1}return this.setPoint(t,e),this.setPoint(i,s),!0}addOrthoPoints(t,e,i,s,n,o){e=C.Ee(e),s=C.Ee(s);let r=s;e>=315||e<45?e=0:45<=e&&e<135?e=90:135<=e&&e<225?e=180:e=270,s>=315||s<45?s=0:45<=s&&s<135?s=90:135<=s&&s<225?s=180:s=270;let a=t,h=i,l=I.bs(n.actualBounds),u=I.bs(o.actualBounds);l.inflate(j.va,j.va),u.inflate(j.va,j.va),l.unionPoint(t),u.unionPoint(i);let c=P.l(),d=P.l(),f=u.containsPoint(a)||l.containsPoint(h);e===0?h.x>a.x||s===270&&h.y<a.y&&u.right>a.x||s===90&&h.y>a.y&&u.right>a.x?(c.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),s===180?(c.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1),d.x=c.x,d.y=h.y):s===270&&h.y<a.y||s===90&&h.y>a.y?(a.x<u.left?c.x=this.computeMidOrthoPosition(a.x,a.y,u.left,h.y,!1):a.x<u.right&&(s===270&&a.y<u.top||s===90&&a.y>u.bottom)?c.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):c.x=u.right,d.x=c.x,d.y=h.y):s===0&&a.x<u.left&&a.y>u.top&&a.y<u.bottom&&(c.x=a.x,a.y<h.y?c.y=Math.min(h.y,u.top):c.y=Math.max(h.y,u.bottom),d.y=c.y)):(c.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),(s===180||s===90&&h.y<l.top||s===270&&h.y>l.bottom)&&(s===180&&f?c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):h.y<a.y&&(s===180||s===90)?c.y=this.computeMidOrthoPosition(a.x,l.top,h.x,(f?Math.min:Math.max)(h.y,u.bottom),!0):h.y>a.y&&(s===180||s===270)&&(c.y=this.computeMidOrthoPosition(a.x,l.bottom,h.x,(f?Math.max:Math.min)(h.y,u.top),!0)),d.x=h.x,d.y=c.y),c.y>l.top&&c.y<l.bottom&&(h.x>=l.left&&h.x<=a.x||a.x<=u.right&&a.x>=h.x?(s===90||s===270)&&(c.e(Math.max((a.x+h.x)/2,a.x),a.y),d.e(c.x,h.y)):(s===270||(s===0||s===180)&&h.y<a.y?c.y=Math.min(h.y,s===0?l.top:Math.min(l.top,u.top)):c.y=Math.max(h.y,s===0?l.bottom:Math.max(l.bottom,u.bottom)),d.x=h.x,d.y=c.y))):e===180?h.x<a.x||s===270&&h.y<a.y&&u.left<a.x||s===90&&h.y>a.y&&u.left<a.x?(c.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),s===0?(c.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1),d.x=c.x,d.y=h.y):s===270&&h.y<a.y||s===90&&h.y>a.y?(a.x>u.right?c.x=this.computeMidOrthoPosition(a.x,a.y,u.right,h.y,!1):a.x>u.left&&(s===270&&a.y<u.top||s===90&&a.y>u.bottom)?c.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):c.x=u.left,d.x=c.x,d.y=h.y):s===180&&a.x>u.right&&a.y>u.top&&a.y<u.bottom&&(c.x=a.x,a.y<h.y?c.y=Math.min(h.y,u.top):c.y=Math.max(h.y,u.bottom),d.y=c.y)):(c.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),(s===0||s===90&&h.y<l.top||s===270&&h.y>l.bottom)&&(s===0&&f?c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):h.y<a.y&&(s===0||s===90)?c.y=this.computeMidOrthoPosition(a.x,l.top,h.x,(f?Math.min:Math.max)(h.y,u.bottom),!0):h.y>a.y&&(s===0||s===270)&&(c.y=this.computeMidOrthoPosition(a.x,l.bottom,h.x,(f?Math.max:Math.min)(h.y,u.top),!0)),d.x=h.x,d.y=c.y),c.y>l.top&&c.y<l.bottom&&(h.x<=l.right&&h.x>=a.x||a.x>=u.left&&a.x<=h.x?(s===90||s===270)&&(c.e(Math.min((a.x+h.x)/2,a.x),a.y),d.e(c.x,h.y)):(s===270||(s===0||s===180)&&h.y<a.y?c.y=Math.min(h.y,s===180?l.top:Math.min(l.top,u.top)):c.y=Math.max(h.y,s===180?l.bottom:Math.max(l.bottom,u.bottom)),d.x=h.x,d.y=c.y))):e===90?h.y>a.y||s===180&&h.x<a.x&&u.bottom>a.y||s===0&&h.x>a.x&&u.bottom>a.y?(c.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),s===270?(c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0),d.x=h.x,d.y=c.y):s===180&&h.x<a.x||s===0&&h.x>a.x?(a.y<u.top?c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,u.top,!0):a.y<u.bottom&&(s===180&&a.x<u.left||s===0&&a.x>u.right)?c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):c.y=u.bottom,d.x=h.x,d.y=c.y):s===90&&a.y<u.top&&a.x>u.left&&a.x<u.right&&(a.x<h.x?c.x=Math.min(h.x,u.left):c.x=Math.max(h.x,u.right),c.y=a.y,d.x=c.x)):(c.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),(s===270||s===0&&h.x<l.left||s===180&&h.x>l.right)&&(s===270&&f?c.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):h.x<a.x&&(s===270||s===0)?c.x=this.computeMidOrthoPosition(l.left,a.y,(f?Math.min:Math.max)(h.x,u.right),h.y,!1):h.x>a.x&&(s===270||s===180)&&(c.x=this.computeMidOrthoPosition(l.right,a.y,(f?Math.max:Math.min)(h.x,u.left),h.y,!1)),d.x=c.x,d.y=h.y),c.x>l.left&&c.x<l.right&&(h.y>=l.top&&h.y<=a.y||a.y<=u.bottom&&a.y>=h.y?(s===0||s===180)&&(c.e(a.x,Math.max((a.y+h.y)/2,a.y)),d.e(h.x,c.y)):(s===180||(s===90||s===270)&&h.x<a.x?c.x=Math.min(h.x,s===90?l.left:Math.min(l.left,u.left)):c.x=Math.max(h.x,s===90?l.right:Math.max(l.right,u.right)),d.x=c.x,d.y=h.y))):h.y<a.y||s===180&&h.x<a.x&&u.top<a.y||s===0&&h.x>a.x&&u.top<a.y?(c.e(a.x,h.y),d.e((a.x+h.x)/2,h.y),s===90?(c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0),d.x=h.x,d.y=c.y):s===180&&h.x<a.x||s===0&&h.x>=a.x?(a.y>u.bottom?c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,u.bottom,!0):a.y>u.top&&(s===180&&a.x<u.left||s===0&&a.x>u.right)?c.y=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!0):c.y=u.top,d.x=h.x,d.y=c.y):s===270&&a.y>u.bottom&&a.x>u.left&&a.x<u.right&&(a.x<h.x?c.x=Math.min(h.x,u.left):c.x=Math.max(h.x,u.right),c.y=a.y,d.x=c.x)):(c.e(h.x,a.y),d.e(h.x,(a.y+h.y)/2),(s===90||s===0&&h.x<l.left||s===180&&h.x>l.right)&&(s===90&&f?c.x=this.computeMidOrthoPosition(a.x,a.y,h.x,h.y,!1):h.x<a.x&&(s===90||s===0)?c.x=this.computeMidOrthoPosition(l.left,a.y,(f?Math.min:Math.max)(h.x,u.right),h.y,!1):h.x>a.x&&(s===90||s===180)&&(c.x=this.computeMidOrthoPosition(l.right,a.y,(f?Math.max:Math.min)(h.x,u.left),h.y,!1)),d.x=c.x,d.y=h.y),c.x>l.left&&c.x<l.right&&(h.y<=l.bottom&&h.y>=a.y||a.y>=u.top&&a.y<=h.y?(s===0||s===180)&&(c.e(a.x,Math.min((a.y+h.y)/2,a.y)),d.e(h.x,c.y)):(s===180||(s===90||s===270)&&h.x<a.x?c.x=Math.min(h.x,s===270?l.left:Math.min(l.left,u.left)):c.x=Math.max(h.x,s===270?l.right:Math.max(l.right,u.right)),d.x=c.x,d.y=h.y))),this.TN=s!==r,this.kN=e,this.PN=s,this.addPoint(c.copy()),this.addPoint(d.copy()),P.i(c),P.i(d),I.i(l),I.i(u)}computeMidOrthoPosition(t,e,i,s,n){let o=0;return this.hasCurviness()&&!this.computeSpot(!0,this.fromPort).isSide()&&!this.computeSpot(!1,this.toPort).isSide()&&(o=this.computeCurviness()),n?(e+s)/2+o:(t+i)/2+o}yT(){if(this.diagram===null||!this.isAvoiding||this.diagram.animationManager.isTicking)return!1;let t=this.points.r,e=t.length;if(e<4)return!1;let i=this.diagram.getPositions(!1,this.containingGroup,null);for(let s=1;s<e-2;s++){let n=t[s],o=t[s+1];if(!i.isUnoccupied(Math.min(n.x,o.x),Math.min(n.y,o.y),Math.abs(n.x-o.x),Math.abs(n.y-o.y)))return!0}return!1}findClosestSegment(t){let e=t.x,i=t.y,s=this.getPoint(0),n=this.getPoint(1),o=P.distanceLineSegmentSquared(e,i,s.x,s.y,n.x,n.y),r=0;for(let a=1;a<this.pointsCount-1;a++){s=this.getPoint(a+1);let h=P.distanceLineSegmentSquared(e,i,n.x,n.y,s.x,s.y);n=s,h<o&&(r=a,o=h)}return r}invalidateGeometry(){this.ai()}ai(){this.Fa&&(this.Fa=!1,this.f())}get Fa(){return(this.St&128)!==0}set Fa(t){(this.St&128)!==0!==t&&(this.St=this.St^128)}get geometry(){if(!this.Fa){if(this.updateRoute(),this.pointsCount<2)return this.Fa=!0,this.ut;this.ut=this.makeGeometry(),this.Fa=!0}return this.ut}Dd(t){if(!t){if(this.Fi===!1)return;let n=this.findMainElement();if(this.Fa&&(n===null||n.geometry!==null))return}this.pointsCount>=2&&(this.ut=this.makeGeometry()),this.Fa=!0;let e=this.path;if(e===null)return;e.ut=this.ut;let i=this.D.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];o!==e&&o.isPanelMain&&o instanceof it&&(o.ut=this.ut)}}EE(t){return this.Qh()&&t.aa.has(this)&&(this.bl.width!==0||this.bl.height!==0)&&(t.animationManager.isAnimating||t.currentTool!==t.toolManager)}makeGeometry(){let t=this.ut,e=this.pointsCount,i=!1,s=this.diagram;s!==null&&this.EE(s)&&(i=!0);let n=0,o=0,r=P.bs(this.getPoint(0)),a=P.bs(r),h=this.Ce.r,l=this.computeCurve();if(l===9&&e>=3&&!C.X(this.smoothness,0))if(e===3){let u=this.getPoint(1);n=Math.min(r.x,u.x),o=Math.min(r.y,u.y),u=this.getPoint(2),n=Math.min(n,u.x),o=Math.min(o,u.y)}else if(this.isOrthogonal){for(let u=0;u<e;u++){let c=h[u];a.x=Math.min(c.x,a.x),a.y=Math.min(c.y,a.y)}n=a.x,o=a.y}else{for(let u=3;u<e;u+=3){u+3>=e&&(u=e-1);let c=this.getPoint(u);a.x=Math.min(c.x,a.x),a.y=Math.min(c.y,a.y)}n=a.x,o=a.y}else{for(let u=0;u<e;u++){let c=h[u];a.x=Math.min(c.x,a.x),a.y=Math.min(c.y,a.y)}n=a.x,o=a.y}if(n-=this.ck.x,o-=this.ck.y,r.x-=n,r.y-=o,this.computeShortLength(!0)!==0&&(r=this.tc(r,!0,a)),e===2&&!this.Qh()){let u=P.bs(this.getPoint(1));return u.x-=n,u.y-=o,this.computeShortLength(!1)!==0&&(u=this.tc(u,!1,a)),t.type=1,t.startX=r.x,t.startY=r.y,t.endX=u.x,t.endY=u.y,P.i(u),P.i(r),P.i(a),t}else{t.type=4;let u=Ne.jL(t);if(u.Au(r.x,r.y,!1,!1),l===9&&e>=3&&!C.X(this.smoothness,0))if(e===3){let c=this.getPoint(1),d=c.x-n,f=c.y-o,p=P.bs(this.getPoint(2));p.x-=n,p.y-=o,this.computeShortLength(!1)!==0&&this.tc(p,!1,a),u.wr(d,f,d,f,p.x,p.y),P.i(p)}else if(this.isOrthogonal){let c=P.z(n,o),d=P.bs(this.getPoint(1)),f=P.z(n,o),p=P.z(n,o),g=this.getPoint(0),y,b=this.smoothness/3;for(let S=1;S<this.pointsCount-1;S++){y=this.getPoint(S);let N=g,D=y,L=this.getPoint(this.ON(y,S,!1));C.X(N.x,D.x)&&C.X(D.x,L.x)||C.X(N.y,D.y)&&C.X(D.y,L.y)||(this.UE(N,D,L,b,f,p),(S===1||S===2&&C.X(g.x,this.getPoint(0).x)&&C.X(g.y,this.getPoint(0).y))&&(d.x=(g.x+y.x)*.5,d.y=(g.y+y.y)*.5),u.wr(d.x-n,d.y-o,f.x-n,f.y-o,y.x-n,y.y-o),c.h(f),d.h(p),g=y)}let v=g.x,w=g.y,k=P.bs(this.getPoint(this.pointsCount-1));this.computeShortLength(!1)!==0&&this.tc(k,!1,P.gn),v=.5*(v+k.x),w=.5*(w+k.y),u.wr(p.x-n,p.y-o,v-n,w-o,k.x-n,k.y-o),P.i(k),P.i(c),P.i(d),P.i(f),P.i(p)}else for(let c=3;c<e;c+=3){let d=this.getPoint(c-2);c+3>=e&&(c=e-1);let f=this.getPoint(c-1),p=P.bs(this.getPoint(c));c===e-1&&this.computeShortLength(!1)!==0&&this.tc(p,!1,P.gn),u.wr(d.x-n,d.y-o,f.x-n,f.y-o,p.x-n,p.y-o),P.i(p)}else if(this.isOrthogonal||e===2){let c=P.bs(this.getPoint(0)),d=P.l(),f=P.bs(c),p=this.computeCorner(),g=1,y=0;for(;g<e;){if(g=this.ON(c,g,g>1),d.h(this.getPoint(g)),g>=e-1){if(!c.equals(d))this.computeShortLength(!1)!==0&&this.tc(d,!1,P.gn),this.On(u,-n,-o,c,d,i);else if(y===0)for(g=1;g<e;)f.h(c),d.h(this.getPoint(g++)),this.On(u,-n,-o,c,d,i),c.h(d);break}y=this.ON(d,g+1,g<e-3);let b=this.getPoint(y);this.VE(u,-n,-o,c,d,b,c,f,p,i),f.h(d),g=y}P.i(c),P.i(d),P.i(f)}else{let c=this.computeCorner();if(e>2&&c>=.5){let d=P.bs(h[e-1]);this.computeShortLength(!1)!==0&&this.tc(d,!1,P.gn),r.x+=n,r.y+=o;for(let f=1;f<e;f++){let p=f===1?r:h[f-1],g=f===e-1?d:h[f],y=Math.sqrt(p.distanceSquaredPoint(g)),b=c/y;if(b<.5){if(f>1){let v=p.x+(g.x-p.x)*b,w=p.y+(g.y-p.y)*b;u.Tu(p.x-n,p.y-o,v-n,w-o)}u.Ks(g.x+(p.x-g.x)*b-n,g.y+(p.y-g.y)*b-o)}else f>1&&u.Tu(p.x-n,p.y-o,(p.x+g.x)/2-n,(p.y+g.y)/2-o);f===e-1&&u.Ks(d.x-n,d.y-o)}P.i(d)}else if(e>=2){let d=P.bs(h[e-1]);this.computeShortLength(!1)!==0&&this.tc(d,!1,P.gn);for(let f=1;f<e-1;f++)u.Ks(h[f].x-n,h[f].y-o);u.Ks(d.x-n,d.y-o),P.i(d)}}return Ne.WL(u),P.i(r),P.i(a),t}}yk(t,e,i,s){let n=i-t;if(isNaN(n)||n===1/0||n===-1/0)return NaN;n<0&&(n=-n);let o=s-e;return isNaN(o)||o===1/0||o===-1/0?NaN:(o<0&&(o=-o),C.X(n,0)?o:C.X(o,0)?n:Math.sqrt(n*n+o*o))}UE(t,e,i,s,n,o){isNaN(s)&&(s=this.smoothness/3);let r=t.x,a=t.y,h=e.x,l=e.y,u=i.x,c=i.y,d=s*this.yk(r,a,h,l),f=s*this.yk(h,l,u,c);if(C.X(a,l)&&C.X(h,u)&&(h>r?c>l?(n.x=h-d,n.y=l-d,o.x=h+f,o.y=l+f):(n.x=h-d,n.y=l+d,o.x=h+f,o.y=l-f):c>l?(n.x=h+d,n.y=l-d,o.x=h-f,o.y=l+f):(n.x=h+d,n.y=l+d,o.x=h-f,o.y=l-f)),C.X(r,h)&&C.X(l,c)&&(l>a?u>h?(n.x=h-d,n.y=l-d,o.x=h+f,o.y=l+f):(n.x=h+d,n.y=l-d,o.x=h-f,o.y=l+f):u>h?(n.x=h-d,n.y=l+d,o.x=h+f,o.y=l-f):(n.x=h+d,n.y=l+d,o.x=h-f,o.y=l-f)),C.X(r,h)&&C.X(h,u)||C.X(a,l)&&C.X(l,c)){let p=.5*(r+u),g=.5*(a+c);n.x=p,n.y=g,o.x=p,o.y=g}}tc(t,e,i){let s=this.pointsCount;if(s<2)return t;if(e){let n=this.getPoint(1),o=n.x-i.x,r=n.y-i.y,a=this.yk(t.x,t.y,o,r);if(a===0)return t;let h=s===2?a*.5:a,l=this.computeShortLength(!0);l>h&&(l=h);let u=l*(o-t.x)/a,c=l*(r-t.y)/a;t.x+=u,t.y+=c}else{let n=this.getPoint(s-2),o=n.x-i.x,r=n.y-i.y,a=this.yk(t.x,t.y,o,r);if(a===0)return t;let h=s===2?a*.5:a,l=this.computeShortLength(!1);l>h&&(l=h);let u=l*(t.x-o)/a,c=l*(t.y-r)/a;t.x-=u,t.y-=c}return t}ON(t,e,i){let s=this.pointsCount,n=t;for(;C.X(t.x,n.x)&&C.X(t.y,n.y);){if(e>=s)return s-1;n=this.getPoint(e++)}if(!C.X(t.x,n.x)&&!C.X(t.y,n.y))return e-1;let o=n;for(;C.X(t.x,n.x)&&C.X(n.x,o.x)&&(!i||(t.y>=n.y?n.y>=o.y:n.y<=o.y))||C.X(t.y,n.y)&&C.X(n.y,o.y)&&(!i||(t.x>=n.x?n.x>=o.x:n.x<=o.x));){if(e>=s)return s-1;o=this.getPoint(e++)}return e-2}VE(t,e,i,s,n,o,r,a,h,l){if(C.c(s.y,n.y)&&C.c(n.x,o.x)){let u=Math.min(h,Math.abs(n.x-a.x)/2),c=Math.min(u,Math.abs(o.y-n.y)/2);if(u=c,C.c(u,0)){this.On(t,e,i,s,n,l),r.h(n);return}let d=n.x,f=n.y,p=d,g=f;n.x>s.x?(d=n.x-u,o.y>n.y?g=n.y+c:g=n.y-c):(d=n.x+u,o.y>n.y?g=n.y+c:g=n.y-c);let y=P.z(d,f);this.On(t,e,i,s,y,l),P.i(y),t.Tu(n.x+e,n.y+i,p+e,g+i),r.e(p,g)}else if(C.c(s.x,n.x)&&C.c(n.y,o.y)){let u=Math.min(h,Math.abs(n.y-a.y)/2),c=Math.min(u,Math.abs(o.x-n.x)/2);if(u=c,C.c(c,0)){this.On(t,e,i,s,n,l),r.h(n);return}let d=n.x,f=n.y,p=d,g=f;n.y>s.y?(f=n.y-u,o.x>n.x?p=n.x+c:p=n.x-c):(f=n.y+u,o.x>n.x?p=n.x+c:p=n.x-c);let y=P.z(d,f);this.On(t,e,i,s,y,l),P.i(y),t.Tu(n.x+e,n.y+i,p+e,g+i),r.e(p,g)}else this.On(t,e,i,s,n,l),r.h(n)}On(t,e,i,s,n,o){if(o||!this.Qh())t.Ks(n.x+e,n.y+i);else{let r=j.ov,a=r/2,h=[],l=0;this.isVisible()&&(l=this.BE(s,n,h));let u=s.x,c=s.y;if(l>0){if(C.c(s.y,n.y))if(s.x<n.x){let d=0;for(;d<l;){let f=Math.max(s.x,Math.min(h[d++]-a,n.x-r));t.Ks(f+e,n.y+i),u=f+e,c=n.y+i;let p=Math.min(f+r,n.x);for(;d<l;){let v=h[d];if(v<p+r)d++,p=Math.min(v+a,n.x);else break}let g=n.y-r+i,y=p+e,b=n.y+i;this.curve===10?t.Au(y,b,!1,!1):t.wr(u,g,y,g,y,b),u=y,c=b}}else{let d=l-1;for(;d>=0;){let f=Math.min(s.x,Math.max(h[d--]+a,n.x+r));t.Ks(f+e,n.y+i),u=f+e,c=n.y+i;let p=Math.max(f-r,n.x);for(;d>=0;){let v=h[d];if(v>p-r)d--,p=Math.max(v-a,n.x);else break}let g=n.y-r+i,y=p+e,b=n.y+i;this.curve===10?t.Au(y,b,!1,!1):t.wr(u,g,y,g,y,b),u=y,c=b}}else if(C.c(s.x,n.x))if(s.y<n.y){let d=0;for(;d<l;){let f=Math.max(s.y,Math.min(h[d++]-a,n.y-r));t.Ks(n.x+e,f+i),u=n.x+e,c=f+i;let p=Math.min(f+r,n.y);for(;d<l;){let v=h[d];if(v<p+r)d++,p=Math.min(v+a,n.y);else break}let g=n.x-r+e,y=n.x+e,b=p+i;this.curve===10?t.Au(y,b,!1,!1):t.wr(g,c,g,b,y,b),u=y,c=b}}else{let d=l-1;for(;d>=0;){let f=Math.min(s.y,Math.max(h[d--]+a,n.y+r));t.Ks(n.x+e,f+i),u=n.x+e,c=f+i;let p=Math.max(f-r,n.y);for(;d>=0;){let v=h[d];if(v>p-r)d--,p=Math.max(v-a,n.y);else break}let g=n.x-r+e,y=n.x+e,b=p+i;this.curve===10?t.Au(y,b,!1,!1):t.wr(g,c,g,b,y,b),u=y,c=b}}}t.Ks(n.x+e,n.y+i)}}BE(t,e,i){let s=this.diagram;if(s===null||t.equals(e))return 0;let n=s.layers;for(;n.next();){let o=n.value;if(o!==null&&o.visible){let r=o.OM(),a=r.length;for(let h=0;h<a;h++){let l=r[h];if(!(l instanceof j))continue;if(l===this)return i.length>0&&i.sort((d,f)=>d-f),i.length;if(!l.isVisible()||!l.Qh())continue;let u=l.routeBounds;if(!u.isReal()||!this.routeBounds.intersectsRect(u)||this.usesSamePort(l))continue;let c=l.path;c!==null&&c.isVisibleObject()&&this.zE(t,e,i,l)}}}return i.length>0&&i.sort((o,r)=>o-r),i.length}zE(t,e,i,s){let n=C.c(t.y,e.y),o=s.pointsCount,r=s.getPoint(0),a=P.l();for(let h=1;h<o;h++){let l=s.getPoint(h);if(h<o-1){let u=s.getPoint(h+1);if(r.y===l.y&&l.y===u.y){if(l.x>r.x&&u.x>=l.x||l.x<r.x&&u.x<=l.x)continue}else if(r.x===l.x&&l.x===u.x&&(l.y>r.y&&u.y>=l.y||l.y<r.y&&u.y<=l.y))continue}this.XE(t,e,r,l,a)&&(n?i.push(a.x):i.push(a.y)),r=l}P.i(a)}XE(t,e,i,s,n){let o=t.x,r=t.y,a=e.x,h=e.y,l=i.x,u=i.y,c=s.x,d=s.y;if(C.c(o,a)){if(!C.c(r,h)&&C.c(u,d)&&Math.min(r,h)<u&&Math.max(r,h)>u&&Math.min(l,c)<o&&Math.max(l,c)>o&&!C.c(l,c))return n.x=o,n.y=u,!0}else if(C.c(r,h)&&C.c(l,c)&&Math.min(o,a)<l&&Math.max(o,a)>l&&Math.min(u,d)<r&&Math.max(u,d)>r&&!C.c(u,d))return n.x=l,n.y=r,!0;return n.x=0,n.y=0,!1}get firstPickIndex(){return this.pointsCount<=2?0:this.isOrthogonal||!this.kl(this.computeSpot(!0))?1:0}get lastPickIndex(){let t=this.pointsCount;return t===0?0:t<=2?t-1:this.isOrthogonal||!this.kl(this.computeSpot(!1))?t-2:t-1}Qh(){let t=this.curve;return t===11||t===10}dk(t){if(t||this.Qh()){let e=this.diagram;e!==null&&!e.animationManager.isTicking&&!e.aa.has(this)&&(this.bl.width!==0||this.bl.height!==0)&&e.aa.set(this,this.bl.copy())}}invalidateOtherJumpOvers(t){let e=this.layer;if(e===null||!e.visible||e.isTemporary)return;let i=e.diagram;if(i===null||i.animationManager.isTicking)return;let s=!1,n=i.layers;for(;n.next();){let o=n.value;if(o.visible){if(o===e){s=!0;let r=!1,a=o.OM(),h=a.length;for(let l=0;l<h;l++){let u=a[l];u instanceof j&&(u===this?r=!0:r&&this.pv(u,t))}}else if(s){let r=o.OM(),a=r.length;for(let h=0;h<a;h++){let l=r[h];l instanceof j&&this.pv(l,t)}}}}}pv(t,e){if(t===null||!t.Fa||!t.Fi||!t.Qh())return;let i=t.routeBounds;i.isReal()&&(!this.routeBounds.intersectsRect(i)&&!e.intersectsRect(i)||this.usesSamePort(t)||t.ai())}usesSamePort(t){let e=this.pointsCount,i=t.pointsCount;if(e>0&&i>0){let s=this.getPoint(0),n=t.getPoint(0);if(s.equalsApprox(n))return!0;let o=this.getPoint(e-1),r=t.getPoint(i-1);if(o.equalsApprox(r)||s.equalsApprox(r)||o.equalsApprox(n))return!0}else if(this.fromNode===t.fromNode||this.toNode===t.toNode||this.fromNode===t.toNode||this.toNode===t.fromNode)return!0;return!1}isVisible(){if(!super.isVisible())return!1;let t=this.containingGroup,e=!0,i=this.diagram;i!==null&&(e=i.isTreePathToChildren);let s=this.fromNode;if(s!==null){if(this.isTreeLink&&e&&!s.isTreeExpanded)return!1;if(s===t)return!0;let o=s;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}let r=s.findVisibleNode();if(r===null||r===t)return!1}let n=this.toNode;if(n!==null){if(this.isTreeLink&&!e&&!n.isTreeExpanded)return!1;if(n===t)return!0;let o=n;for(;o!==null;){if(o.labeledLink===this)return!0;o=o.containingGroup}let r=n.findVisibleNode();if(r===null||r===t)return!1}return!0}Xe(t){if(super.Xe(t),t&&this.dk(!1),this.ir!==null&&this.ir.$d(),this.on!==null){let e=this.on.iterator;for(;e.next();)e.value.Xe(t)}}get adjusting(){return this.Gf}set adjusting(t){let e=this.Gf;e!==t&&(this.Gf=t,this.t("adjusting",e,t))}computeAdjusting(){return this.isAvoiding&&this.diagram!==null&&this.diagram.animationManager.defaultAnimation.isAnimating?17:this.Gf}get corner(){return this._d}set corner(t){let e=this._d;e!==t&&(this._d=t,this.ai(),this.t("corner",e,t))}get curve(){return this.tg}set curve(t){let e=this.tg;e!==t&&(this.tg=t,(e===9||t===9)&&this.AN(this.bl),this.$t(),this.ai(),this.dk(e===10||e===11||t===10||t===11),this.t("curve",e,t))}get curviness(){return this.eg}set curviness(t){let e=this.eg;e!==t&&(this.eg=t,this.$t(),this.ai(),this.t("curviness",e,t))}get routing(){return this.Wh}set routing(t){let e=this.Wh;e!==t&&(this.Wh=t,this.isAvoiding&&this.diagram!==null&&(this.diagram.sp=!0),this.er=null,this.$t(),this.dk(j.SN(e)||j.SN(t)),this.t("routing",e,t))}get smoothness(){return this.ig}set smoothness(t){let e=this.ig;e!==t&&(this.ig=t,this.ai(),this.t("smoothness",e,t))}Wy(){let t=this.mo;if(t===null)return;let e=this.yo;if(e===null||!isNaN(this.curviness))return;let i=this.po,s=this.wo,n=null,o=null,r=t.ee.r,a=r.length;for(let h=0;h<a;h++){let l=r[h];!(l.mo===t&&l.po===i&&l.yo===e&&l.wo===s)&&!(l.mo===e&&l.po===s&&l.yo===t&&l.wo===i)||(o===null?o=l:(n===null&&(n=[],n.push(o)),n.push(l)))}if(n!==null){let h=t.HD(e,i,s);h===null&&(h=new $n(t,i,e,s),t.YD(h),e.YD(h)),h.rn=n;for(let l=0;l<n.length;l++){let u=n[l];u.ir=h}h.$d()}}jy(){let t=this.ir;if(t!==null){if(!isNaN(this.curviness))return;this.ir=null;let e=t.rn.indexOf(this);e>=0&&(t.rn.splice(e,1),t.$d())}}Lr(){return!0}get key(){let t=this.diagram;if(!(t===null||!t.model.jh()))return t.model.getKeyForLinkData(this.data)}}class $n{Yo;js;Vy;mN;lk;pN;rn;constructor(t,e,i,s){V.Je(this),this.Yo=!1,this.js=!1,this.Vy=t,this.mN=e,this.lk=i,this.pN=s,this.rn=[]}$d(){if(!this.Yo){let t=this.rn;if(t.length>0){let e=t[0].diagram;e!==null&&(e.i2.add(this),this.js=e.undoManager.isUndoingRedoing)}}this.Yo=!0}b2(){if(this.Yo){this.Yo=!1;let t=this.rn;if(t.length>0){let e=t[0],i=e.diagram,s=i===null||i.Za&&!this.js;this.js=!1,e.arrangeBundledLinks(t,s),t.length===1&&(e.ir=null,t.length=0)}t.length===0&&(this.Vy.KD(this),this.lk.KD(this))}}}class Ot{ui;di;ec;ic;xe;be;Bt;Ra;Oa;Lh;O2;Yo;$y;cf;I2;E2;constructor(t){V.Je(this),this.Lh=null,this.O2=null,this.Yo=!0,this.$y=!1,this.ui=1,this.di=1,this.ec=-1,this.ic=-1,this.xe=t.width,this.be=t.height,this.Bt=[],this.Ra=0,this.Oa=0,this.cf=j.uv,this.I2=this.cf*2,this.E2=this.cf*2}static ln=0;static sc=1;static ng=999999;static IN=Ot.ng+1;static EN=Ot.ng+2;l1(t){if(t.width<=0||t.height<=0)return;let e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;this.ui=Math.floor((e-this.xe)/this.xe)*this.xe,this.di=Math.floor((i-this.be)/this.be)*this.be,this.ec=Math.ceil((s+2*this.xe)/this.xe)*this.xe,this.ic=Math.ceil((n+2*this.be)/this.be)*this.be;let o=1+(Math.ceil((this.ec-this.ui)/this.xe)|0),r=1+(Math.ceil((this.ic-this.di)/this.be)|0);if(this.Bt.length===0||this.Ra<o-1||this.Oa<r-1){let a=[];for(let h=0;h<=o;h++)a[h]=new Uint32Array(r);this.Bt=a,this.Ra=o-1,this.Oa=r-1}this.GE(Ot.IN)}get bounds(){return new I(this.ui,this.di,this.ec-this.ui,this.ic-this.di)}get cellWidth(){return this.xe}set cellWidth(t){t>0&&t!==this.xe&&(this.xe=t,this.l1(this.bounds))}get cellHeight(){return this.be}set cellHeight(t){t>0&&t!==this.be&&(this.be=t,this.l1(this.bounds))}og(t,e){return this.ui<=t&&t<=this.ec&&this.di<=e&&e<=this.ic}xo(t,e){if(!this.og(t,e))return Ot.IN;t-=this.ui,t/=this.xe,e-=this.di,e/=this.be;let i=t|0,s=e|0;return this.Bt[i][s]}FO(t,e,i,s){if(!this.og(t,e))return;let n=(t-this.ui)/this.xe|0,o=(e-this.di)/this.be|0,r=(t+i-this.ui)/this.xe|0,a=(e+s-this.di)/this.be|0,h=Math.min(r,this.Ra),l=Math.min(a,this.Oa);for(let u=n;u<=h;u++){let c=this.Bt[u];if(c.fill)c.fill(Ot.ln,o,l+1);else for(let d=o;d<=l;d++)c[d]=Ot.ln}}GE(t){for(let e=0;e<=this.Ra;e++){let i=this.Bt[e];if(i.fill)i.fill(t);else for(let s=0;s<=this.Oa;s++)i[s]=t}}TT(){for(let t=0;t<=this.Ra;t++){let e=this.Bt[t];for(let i=0;i<=this.Oa;i++)e[i]>=Ot.sc&&(e[i]=Ot.IN)}}YE(t,e){return this.xo(t,e)===Ot.ln}isUnoccupied(t,e,i,s){if(t>this.ec||t+i<this.ui||e>this.ic||e+s<this.di)return!0;let n=(t-this.ui)/this.xe|0,o=(e-this.di)/this.be|0,r=Math.max(0,i)/this.xe+1|0,a=Math.max(0,s)/this.be+1|0;if(n<0&&(r+=n,n=0),o<0&&(a+=o,o=0),r<0||a<0)return!0;let h=Math.min(n+r-1,this.Ra)|0,l=Math.min(o+a-1,this.Oa)|0;for(let u=n;u<=h;u++){let c=this.Bt[u];for(let d=o;d<=l;d++)if(c[d]===Ot.ln)return!1}return!0}maxAvoidsLinksSpaceH(t,e,i,s){if(t>this.ec||e<this.ui||i>this.ic||i<this.di)return 0;let n=(t-this.ui)/this.xe|0,o=(e-this.ui)/this.xe|0,r=(i-this.di)/this.be|0,a=s/this.be+1|0,h;for(h=0;h<a/2;h++){let l=!1;for(let u=n;u<=o;u++)if(this.Bt[u][r+h]===Ot.ln||this.Bt[u][r-h]===Ot.ln){l=!0;break}if(l)return Math.max(0,(2*h-1)*this.be)}return s}maxAvoidsLinksSpaceV(t,e,i,s){if(t>this.ic||e<this.di||i>this.ec||i<this.ui)return 0;let n=(t-this.di)/this.be|0,o=(e-this.di)/this.be|0,r=(i-this.ui)/this.xe|0,a=s/this.xe+1|0,h;for(h=0;h<a/2;h++){let l=!1;for(let u=n;u<=o;u++)if(this.Bt[r+h][u]===Ot.ln||this.Bt[r-h][u]===Ot.ln){l=!0;break}if(l)return Math.max(0,(2*h-1)*this.xe)}return s}KE(t,e,i,s,n,o,r,a){t=t|0,e=e|0;let h=this.Bt[t][e];if(h>=Ot.sc&&h<Ot.ng)for(s?e+=i:t+=i,h+=1;n<=t&&t<=o&&r<=e&&e<=a;){let l=this.Bt[t][e];if(h>=l)break;this.Bt[t][e]=h,h+=1,s?e+=i:t+=i}return s?e:t}bo(t,e,i,s,n,o,r,a){if(t<n||t>o||e<r||e>a)return;let h=this.KE(t,e,i,s,n,o,r,a);if(s)if(i>0)for(let l=e+i;l<h;l+=i)this.bo(t,l,1,!s,n,o,r,a),this.bo(t,l,-1,!s,n,o,r,a);else for(let l=e+i;l>h;l+=i)this.bo(t,l,1,!s,n,o,r,a),this.bo(t,l,-1,!s,n,o,r,a);else if(i>0)for(let l=t+i;l<h;l+=i)this.bo(l,e,1,!s,n,o,r,a),this.bo(l,e,-1,!s,n,o,r,a);else for(let l=t+i;l>h;l+=i)this.bo(l,e,1,!s,n,o,r,a),this.bo(l,e,-1,!s,n,o,r,a)}wk(t,e,i,s,n,o,r,a,h,l){let u=t|0,c=e|0,d=Ot.ln,f=Ot.sc;for(this.Bt[u][c]=f;d===Ot.ln&&u>r&&u<a&&c>h&&c<l;)f+=1,this.Bt[u][c]=f,o?c+=n:u+=n,d=this.Bt[u][c];return o?c:u}xk(t,e,i,s,n,o,r,a,h,l){let u=i|0,c=s|0,d=Ot.ln,f=Ot.ng;for(this.Bt[u][c]=f;d===Ot.ln&&u>r&&u<a&&c>h&&c<l;)this.Bt[u][c]=f,o?c+=n:u+=n,d=this.Bt[u][c]}yv(t,e,i,s,n,o){this.$y=!1;let r=t.x,a=t.y;if(!this.og(r,a))return;r-=this.ui,r/=this.xe,a-=this.di,a/=this.be;let h=i.x,l=i.y;if(!this.og(h,l))return;if(h-=this.ui,h/=this.xe,l-=this.di,l/=this.be,Math.abs(r-h)<=1&&Math.abs(a-l)<=1){this.$y=!0;return}let u=n.x,c=n.y,d=n.x+n.width,f=n.y+n.height;u-=this.ui,u/=this.xe,c-=this.di,c/=this.be,d-=this.ui,d/=this.xe,f-=this.di,f/=this.be;let p=Math.max(0,Math.min(this.Ra,u|0)),g=Math.min(this.Ra,Math.max(0,d|0)),y=Math.max(0,Math.min(this.Oa,c|0)),b=Math.min(this.Oa,Math.max(0,f|0)),v=0,w=90,k=270,S=this.Bt,N=r|0,D=a|0,L=h|0,M=l|0,A=e===v||e===w?1:-1,F=e===w||e===k;S[N][D]===Ot.ln?(this.wk(N,D,L,M,A,F,p,g,y,b),this.wk(N,D,L,M,1,!F,p,g,y,b),this.wk(N,D,L,M,-1,!F,p,g,y,b)):this.wk(N,D,L,M,A,F,N,D,N,D),S[L][M]===Ot.ln?(this.xk(N,D,L,M,s===v||s===w?1:-1,s===w||s===k,p,g,y,b),this.xk(N,D,L,M,1,!(s===w||s===k),p,g,y,b),this.xk(N,D,L,M,-1,!(s===w||s===k),p,g,y,b)):this.xk(N,D,L,M,A,F,L,M,L,M);let O=m.st();if(o&&this.wv(L,M,s,N,D,O)){(O[0]!==L||O[1]!==M)&&(O.unshift(M),O.unshift(L)),(O[O.length-2]!==N||O[O.length-1]!==D)&&(O.push(N),O.push(D));let E=Ot.sc,B=O[O.length-2],X=O[O.length-1];S[B][X]=E++;for(let z=O.length-4;z>=0;z-=2){B=O[z+2],X=O[z+3];let U=O[z],tt=O[z+1];for(;U>B?B++:U<B?B--:tt>X?X++:tt<X&&X--,S[B][X]=E++,!(B===U&&X===tt););}}else this.bo(N,D,1,!1,p,g,y,b),this.bo(N,D,-1,!1,p,g,y,b),this.bo(N,D,1,!0,p,g,y,b),this.bo(N,D,-1,!0,p,g,y,b);m.Z(O)}wv(t,e,i,s,n,o){let r=this.Bt,a=t,h=e;for(;;){if(a===s&&h===n)return!0;let l=a,u=h;if(i===0)if(l<s)l++;else break;else if(i===90)if(u<n)u++;else break;else if(i===180)if(l>s)l--;else break;else if(u>n)u--;else break;let c=r[l][u];if(c===0||c===Ot.EN)break;a=l,h=u}for(;;){let l=i,u=a,c=h;i===0?c<n?(l=90,c++):c>n&&(l=270,c--):i===90?u<s?(l=0,u++):u>s&&(l=180,u--):i===180?c<n?(l=90,c++):c>n&&(l=270,c--):u<s?(l=0,u++):u>s&&(l=180,u--);let d=r[u][c];if(l!==i&&d!==0&&d!==Ot.EN){if(o.push(a),o.push(h),this.wv(a,h,l,s,n,o))return!0;o.pop(),o.pop()}if(r[a][h]=Ot.EN,i===0){if(a===t)return!1;a--}else if(i===90){if(h===e)return!1;h--}else if(i===180){if(a===t)return!1;a++}else{if(h===e)return!1;h++}}}}class Ji{Ri;Os;Vi;rg;constructor(t,e){V.Je(this),this.Ri=t,this.Os=e,this.Vi=[],this.rg=!1}toString(){let t=this.Vi,e=this.Ri.toString()+" "+t.length.toString()+":";for(let i=0;i<t.length;i++){let s=t[i];s!==null&&(e+=`
|
|
13
13
|
`+s.toString())}return e}HE(t,e,i,s){let n=e.offsetY;switch(n){case 8:return 90;case 2:return 180;case 1:return 270;case 4:return 0}let o=i;switch(n){case 9:return o>180?270:90;case 6:return o>90&&o<=270?180:0}let r=Math.atan2(t.height,t.width)*180/Math.PI;switch(n){case 3:return o>r&&o<=180+r?180:270;case 5:return o>180-r&&o<=360-r?270:0;case 12:return o>r&&o<=180+r?90:0;case 10:return o>180-r&&o<=360-r?180:90;case 7:return o>90&&o<=180+r?180:o>180+r&&o<=360-r?270:0;case 13:return o>180&&o<=360-r?270:o>r&&o<=180?90:0;case 14:return o>r&&o<=180-r?90:o>180-r&&o<=270?180:0;case 11:return o>180-r&&o<=180+r?180:o>180+r?270:90}return s&&n!==15&&(o-=15,o<0&&(o+=360)),o>r&&o<180-r?90:o>=180-r&&o<=180+r?180:o>180+r&&o<360-r?270:0}$d(){this.Vi.length=0}dv(t){let e=this.Vi;e.length===0&&(this.qE(),e=this.Vi);for(let i=0;i<e.length;i++){let s=e[i];if(s!==null&&s.ts===t)return s}return null}qE(){if(!this.rg){let t=this.rg;this.rg=!0;let e,i=null,s=this.Ri,n=s instanceof ht?s:null;if(n!==null&&!n.isSubGraphExpanded){if(!n.actualBounds.isReal())return this.rg=t,this.Vi;i=n,e=i.findExternalLinksConnected()}else s.isTreeExpanded?e=s.findLinksConnected(this.Os.portId):e=s.findExternalTreeLinksConnected();this.Vi.length=0;let o=0,r=this.Os.getDocumentPoint(T.TopLeft,P.l()),a=this.Os.getDocumentPoint(T.BottomRight,P.l()),h=I.z(r.x,r.y,0,0);h.unionPoint(a),P.i(r),P.i(a);let l=P.z(h.x+h.width/2,h.y+h.height/2),u=this.Os.getDocumentAngle(),c=e.iterator;for(;c.next();){let g=c.value;if(!g.isVisible())continue;let y=g.fromPort,b=g.toPort;if(y===b)continue;if(i!==null&&this.Os===i.port){if(y?.part===i&&y!==this.Os||b?.part===i&&b!==this.Os)continue}else if(y!==this.Os&&b!==this.Os)continue;let v=y===this.Os||i!==null&&g.fromNode!==null&&g.fromNode.isMemberOf(i),w=g.computeSpot(v,this.Os);if(!w.isSide())continue;let k;if(v?k=b:k=y,k===null)continue;let S=k.part;if(S===null)continue;let N=S.findVisibleNode();N!==null&&N!==S&&(S=N,k=S.port);let D=g.computeOtherPoint(S,k),L=l.directionPoint(D);u!==0&&(L=C.Ee(L-u));let M=this.HE(h,w,L,g.isOrthogonal),A=0;M===0?(A=4,L>180&&(L-=360)):M===90?(A=8,L>270&&(L-=360)):M===180?A=2:(A=1,L<90&&(L+=360));let F=this.Vi[o];F===void 0?(F=new Jn(g,L,A),this.Vi[o]=F):(F.ts=g,F.Xt=L,F.fi=A),F.bk.h(D),o++}P.i(l),this.jE();let d=this.Vi.length,f=-1,p=0;for(o=0;o<d;o++){let g=this.Vi[o];g!==void 0&&(g.fi!==f&&(f=g.fi,p=0),g.lg=p,p++)}for(f=-1,p=0,o=d-1;o>=0;o--){let g=this.Vi[o];g!==void 0&&(g.fi!==f&&(f=g.fi,p=g.lg+1),g.Kf=p)}this.WE(this.Vi),this.JE(this.Vi),this.rg=t,I.i(h)}return this.Vi}$E(t,e){return t===e?0:t===null?-1:e===null?1:t.fi<e.fi?-1:t.fi>e.fi?1:t.Xt<e.Xt?-1:t.Xt>e.Xt?1:0}jE(){this.Vi.sort(Ji.prototype.$E)}WE(t){let e=this.Os,i=this.Ri.portSpreading,s=P.l(),n=P.l(),o=P.l(),r=P.l();e.getDocumentPoint(T.TopLeft,s),e.getDocumentPoint(T.TopRight,n),e.getDocumentPoint(T.BottomRight,o),e.getDocumentPoint(T.BottomLeft,r);let a=0,h=0,l=0,u=0;if(i===2)for(let v=0;v<t.length;v++){let w=t[v];if(w===null)continue;let k=w.ts.computeThickness();switch(w.fi){case 8:l+=k;break;case 2:u+=k;break;case 1:a+=k;break;default:case 4:h+=k;break}}let c=0,d=0,f=1,p=n,g=o,y=0,b=0;for(let v=0;v<t.length;v++){let w=t[v];if(w===null)continue;if(c!==w.fi){switch(c=w.fi,c){case 8:p=o,g=r;break;case 2:p=r,g=s;break;case 1:p=s,g=n;break;default:case 4:p=n,g=o;break}switch(y=g.x-p.x,b=g.y-p.y,c){case 8:l>Math.abs(y)?(f=Math.abs(y)/l,l=Math.abs(y)):f=1;break;case 2:u>Math.abs(b)?(f=Math.abs(b)/u,u=Math.abs(b)):f=1;break;case 1:a>Math.abs(y)?(f=Math.abs(y)/a,a=Math.abs(y)):f=1;break;default:case 4:h>Math.abs(b)?(f=Math.abs(b)/h,h=Math.abs(b)):f=1;break}d=0}let k=w._h;if(i===2){let S=w.ts.computeThickness();switch(S*=f,k.h(p),c){case 8:k.x=p.x+y/2+l/2-d-S/2;break;case 2:k.y=p.y+b/2+u/2-d-S/2;break;case 1:k.x=p.x+y/2-a/2+d+S/2;break;default:case 4:k.y=p.y+b/2-h/2+d+S/2;break}d+=S}else{let S=.5;i===1&&(S=(w.lg+1)/(w.Kf+1)),k.x=p.x+y*S,k.y=p.y+b*S}}P.i(s),P.i(n),P.i(o),P.i(r)}JE(t){for(let e=0;e<t.length;e++){let i=t[e];i!==null&&(i.pk=this.ZE(i,e))}}ZE(t,e){let i=t.ts,s=i.fromPort===this.Os,n=0;switch(t.fi){case 1:n=270;break;case 2:n=180;break;case 4:n=0;break;case 8:n=90;break}let o=i.gk(this.Ri,this.Os,T.None,s,n),r=t.lg;if(r<0)return o;let a=t.Kf;if(a<=1||!i.isOrthogonal)return o;let h=t.bk,l=t._h,u=t.fi===2||t.fi===8;u&&(r=a-1-r);let c=j.ev,d=t.fi===2||t.fi===4,f=r<=0?l:this.Vi[u?e+1:e-1]._h,p=r>=a-1?l:this.Vi[u?e-1:e+1]._h;return(d?h.y>=f.y&&h.y<=p.y:h.x>=f.x&&h.x<=p.x)?o:(d?h.y<l.y:h.x<l.x)?o+r*c:o+(a-1-r)*c}}class Jn{ts;Xt;fi;bk;lg;Kf;_h;pk;constructor(t,e,i){this.ts=t,this.Xt=e,this.fi=i,this.bk=new P,this.lg=0,this.Kf=0,this._h=new P,this.pk=0}toString(){return this.ts.toString()+" "+this.Xt.toString()+" "+this.fi.toString()+":"+this.lg.toString()+"/"+this.Kf.toString()+" "+this._h.toString()+" "+this.pk.toString()+" "+this.bk.toString()}}class Ni{Dh;vh;Fh;Rh;Oh;Ih;r0;s0;l0;o0;constructor(){this.Dh=T.Default,this.vh=T.Default,this.Fh=NaN,this.Rh=NaN,this.Oh=NaN,this.Ih=NaN,this.r0=null,this.s0=null,this.l0=1/0,this.o0=1/0}copy(){let t=new Ni;return t.Dh=this.Dh.C(),t.vh=this.vh.C(),t.Fh=this.Fh,t.Rh=this.Rh,t.Oh=this.Oh,t.Ih=this.Ih,t.r0=this.r0,t.s0=this.s0,t.l0=this.l0,t.o0=this.o0,t}}class Oe{$p;Zp;Qp;Jp;G0;Y0;constructor(){this.$p=-1/0,this.Zp=0,this.Qp=P.gn,this.Jp=0,this.G0="None",this.Y0="None"}copy(){let t=new Oe;return t.$p=this.$p,t.Zp=this.Zp,t.Qp=this.Qp.C(),t.Jp=this.Jp,t.G0=this.G0,t.Y0=this.Y0,t}}class ht extends ${ag;Dt;Ch;Ap;he;li;constructor(t,e){let i;t===void 0||t instanceof Lt||typeof t=="string"?i=t:t&&(e=t),super(i),this.E=this.E|4608,this.ag=new V,this.Dt=null,this.li=new ee,this.li.group=this,this.Ch=new V,this.Ap=null,this.he=null,e&&Object.assign(this,e)}cloneProtected(t){super.cloneProtected(t),this.E=this.E&-32769;let e=t.findInVisualTree(i=>i instanceof ue);e instanceof ue?t.Dt=e:t.Dt=null,this.li!==null?(t.li=this.li.copy(),t.li.group=t):(t.li!==null&&(t.li.group=null),t.li=null),this.he!==null&&(t.he=this.he.copy())}Ho(t){super.Ho(t);let e=t.findSubGraphParts(),i=t.memberParts;for(;i.next();){let s=i.value;if(s.f(),s.invalidateLayout(8),s.clearAdornments(),s instanceof $)s.invalidateConnectedLinks(e);else if(s instanceof j){let n=s.labelNodes;for(;n.next();)n.value.invalidateConnectedLinks(e)}}}gf(t,e,i,s,n,o,r){if(t===3&&e==="elements"){if(n instanceof ue)this.Dt===null?this.Dt=n:this.Dt!==n&&m.o("Cannot insert a second Placeholder into the visual tree of a Group.");else if(n instanceof G){let a=n.findInVisualTree(h=>h instanceof ue);a instanceof ue&&(this.Dt===null?this.Dt=a:this.Dt!==a&&m.o("Cannot insert a second Placeholder into the visual tree of a Group."))}}else t===4&&e==="elements"&&this.Dt!==null&&(s===this.Dt?this.Dt=null:s instanceof G&&this.Dt.isContainedBy(s)&&(this.Dt=null));super.gf(t,e,i,s,n,o,r)}Pd(t,e){if(super.Pd(t,e),this.isClipping&&this.type!==G.Spot&&this.isSubGraphExpanded){let i=this.resizeObject;i instanceof G&&(i=i.findMainElement()),this.he===null&&(this.he=new I),i.getDocumentBounds(this.he),i instanceof it&&this.he.inflate(-i.strokeWidth,-i.strokeWidth)}}ka(t,e,i,s){this.hasPlaceholder()&&(this.tr=this.placeholder),super.ka(t,e,i,s)}ensureBounds(){this.isSubGraphExpanded&&this.memberParts.each(t=>{t.ensureBounds()}),super.ensureBounds()}_r(){if(!super._r())return!1;let t=this.memberParts;for(;t.next();){let e=t.value;if(e instanceof $){if(!e.isVisible())continue;if(e.as())return!1}else if(e instanceof j){if(!e.isVisible())continue;if(e.as()&&e.fromNode!==this&&e.toNode!==this)return!1}}return!0}hasPlaceholder(){return this.Dt!==null&&this.Dt.isVisibleObject()&&this.isSubGraphExpanded}get placeholder(){return this.Dt}get computesBoundsAfterDrag(){return(this.E&2048)!==0}set computesBoundsAfterDrag(t){let e=(this.E&2048)!==0;e!==t&&(this.E=this.E^2048,this.t("computesBoundsAfterDrag",e,t))}get computesBoundsIncludingLinks(){return(this.E&4096)!==0}set computesBoundsIncludingLinks(t){let e=(this.E&4096)!==0;e!==t&&(this.E=this.E^4096,this.t("computesBoundsIncludingLinks",e,t))}get computesBoundsIncludingLocation(){return(this.E&8192)!==0}set computesBoundsIncludingLocation(t){let e=(this.E&8192)!==0;e!==t&&(this.E=this.E^8192,this.t("computesBoundsIncludingLocation",e,t))}get handlesDragDropForMembers(){return(this.E&16384)!==0}set handlesDragDropForMembers(t){let e=(this.E&16384)!==0;e!==t&&(this.E=this.E^16384,this.t("handlesDragDropForMembers",e,t))}get avoidableMembers(){return(this.E&131072)!==0}set avoidableMembers(t){let e=(this.E&131072)!==0;e!==t&&(this.E=this.E^131072,this.t("avoidableMembers",e,t))}get memberParts(){return this.ag.iterator}fN(t){if(this.ag.add(t)){t instanceof ht&&this.Ch.add(t);let i=this.memberAdded;if(i!==null){let s=!0,n=this.diagram;n!==null&&(s=n.G,n.G=!0),i(this,t),n!==null&&(n.G=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Xe(!1)}if(t instanceof j&&!this.computesBoundsIncludingLinks)return;let e=this.Dt;e===null&&(e=this),e.f()}cN(t){if(this.ag.delete(t)){t instanceof ht&&this.Ch.delete(t);let i=this.memberRemoved;if(i!==null){let s=!0,n=this.diagram;n!==null&&(s=n.G,n.G=!0),i(this,t),n!==null&&(n.G=s)}(!this.isVisible()||!this.isSubGraphExpanded)&&t.Xe(!0)}if(t instanceof j&&!this.computesBoundsIncludingLinks)return;let e=this.Dt;e===null&&(e=this),e.f()}af(){if(this.ag.count>0){let t=this.diagram;if(t!==null){let e=this.ag.copy().iterator;for(;e.next();){let i=e.value;t.remove(i)}}}super.af()}get layout(){return this.li}set layout(t){let e=this.li;if(e!==t){t!==null&&t.diagram!==null&&t.diagram.layout===t&&m.o("A layout cannot be both the Diagram.layout and a Group.layout: "+t),e!==null&&(e.diagram=null,e.group=null),this.li=t;let i=this.diagram;t!==null&&(t.diagram=i,t.group=this),i!==null&&(i.Jr=!0),this.t("layout",e,t),i!==null&&i.requestUpdate()}}get memberAdded(){return this.vt!==null?this.vt.Ky:null}set memberAdded(t){let e=this.memberAdded;e!==t&&(t!==null&&m.S(t,ht,"memberAdded"),this.wl().Ky=t,this.t("memberAdded",e,t))}get memberRemoved(){return this.vt!==null?this.vt.Hy:null}set memberRemoved(t){let e=this.memberRemoved;e!==t&&(t!==null&&m.S(t,ht,"memberRemoved"),this.wl().Hy=t,this.t("memberRemoved",e,t))}get memberValidation(){return this.vt!==null?this.vt.da:null}set memberValidation(t){let e=this.memberValidation;e!==t&&(t!==null&&m.S(t,ht,"memberValidation"),this.wl().da=t,this.t("memberValidation",e,t))}canAddMembers(t){let e=this.diagram;if(e===null)return!1;let i=e.commandHandler,s=i.yC(t).iterator;for(;s.next();){let n=s.value;if(!i.isValidMember(this,n))return!1}return!0}addMembers(t,e){let i=this.diagram;if(i===null)return!1;let s=i.commandHandler,n=s.yC(t),o=!0,r=n.iterator;for(;r.next();){let a=r.value;!e||s.isValidMember(this,a)?a.containingGroup=this:o=!1}return o}get ungroupable(){return(this.E&256)!==0}set ungroupable(t){let e=(this.E&256)!==0;e!==t&&(this.E=this.E^256,this.t("ungroupable",e,t))}canUngroup(){if(!this.ungroupable)return!1;let t=this.layer;if(t===null||!t.allowUngroup)return!1;let e=t.diagram;return!(e!==null&&!e.allowUngroup)}invalidateConnectedLinks(t){let e=this.QE();if(super.invalidateConnectedLinks(t),e)return;this.cT(!0);let i=this.findExternalLinksConnected();for(;i.next();){let s=i.value;if(t!==void 0&&t.has(s))continue;let n=s.fromNode;if(n!==null&&n!==this&&n.isMemberOf(this)&&!n.isVisible())n.Ze(s.fromPort),n.Ze(s.toPort),s.$t();else{let o=s.toNode;o!==null&&o!==this&&o.isMemberOf(this)&&!o.isVisible()&&(o.Ze(s.fromPort),o.Ze(s.toPort),s.$t())}}}findExternalLinksConnected(){let t=this.diagram!==null&&this.diagram.c2;if(t&&this.Ap!==null)return this.Ap.iterator;let e=this.findSubGraphParts();e.add(this);let i=new V,s=e.iterator;for(;s.next();){let n=s.value;if(!(n instanceof $))continue;let o=n.linksConnected;for(;o.next();){let r=o.value;e.has(r)||i.add(r)}}return t&&(this.Ap=i),i.iterator}findExternalNodesConnected(){let t=this.findSubGraphParts();t.add(this);let e=new V,i=t.iterator;for(;i.next();){let s=i.value;if(!(s instanceof $))continue;let n=s.linksConnected;for(;n.next();){let o=n.value,r=o.fromNode;r!==null&&(!t.has(r)||r===this)&&e.add(r);let a=o.toNode;a!==null&&(!t.has(a)||a===this)&&e.add(a)}}return e.iterator}GU(){function t(i,s){i!==null&&(s.add(i),t(i.containingGroup,s))}let e=new V;return t(this,e),e}findSubGraphParts(){let t=new V;return pt.ga(t,this,!0,0,!0),t.delete(this),t}Xe(t){super.Xe(t);let e=this.memberParts;for(;e.next();)e.value.Xe(t)}collapseSubGraph(){let t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;let e=this.findSubGraphParts();this.xv(e,t,this),t.isCollapsingExpanding=!1}xv(t,e,i){let s=this.memberParts;for(;s.next();){let n=s.value;if(n.Xe(!1),n instanceof ht&&n.isSubGraphExpanded&&(n.wasSubGraphExpanded=n.isSubGraphExpanded,n.xv(t,e,i)),n instanceof $)n.invalidateConnectedLinks(t),e.Kc(n,i);else if(n instanceof j){let o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!1}expandSubGraph(){let t=this.diagram;if(t===null||t.isCollapsingExpanding)return;t.isCollapsingExpanding=!0;let e=this.findSubGraphParts();this.bv(e,t,this),t.isCollapsingExpanding=!1}bv(t,e,i){let s=this.memberParts;for(;s.next();){let n=s.value;if(n.Xe(!0),n instanceof ht&&n.wasSubGraphExpanded&&(n.wasSubGraphExpanded=!1,n.bv(t,e,i)),n instanceof $)n.invalidateConnectedLinks(t);else if(n instanceof j){let o=n.labelNodes;for(;o.next();)o.value.invalidateConnectedLinks(t)}}this.isSubGraphExpanded=!0}get isSubGraphExpanded(){return(this.E&512)!==0}set isSubGraphExpanded(t){let e=(this.E&512)!==0;if(e!==t){this.E=this.E^512;let i=this.diagram;this.t("isSubGraphExpanded",e,t);let s=this.subGraphExpandedChanged;if(s!==null){let n=!0;i!==null&&(n=i.G,i.G=!0),s(this),i!==null&&(i.G=n)}if(i!==null&&i.undoManager.isUndoingRedoing){this.Dt!==null&&this.Dt.f(),this.memberParts.each(n=>n.updateAdornments());return}t?this.expandSubGraph():this.collapseSubGraph()}}get wasSubGraphExpanded(){return(this.E&1024)!==0}set wasSubGraphExpanded(t){let e=(this.E&1024)!==0;e!==t&&(this.E=this.E^1024,this.t("wasSubGraphExpanded",e,t))}get subGraphExpandedChanged(){return this.vt!==null?this.vt.qy:null}set subGraphExpandedChanged(t){let e=this.subGraphExpandedChanged;e!==t&&(t!==null&&m.S(t,ht,"subGraphExpandedChanged"),this.wl().qy=t,this.t("subGraphExpandedChanged",e,t))}move(t,e){e===void 0&&(e=!1);let i=e?this.location:this.position,s=i.x,n=i.y,o=t.x,r=t.y;if((s===o||isNaN(s)&&isNaN(o))&&(n===r||isNaN(n)&&isNaN(r)))return;let a=o-(isNaN(s)?0:s),h=r-(isNaN(n)?0:n),l=P.l();super.move(t,e);let u=new V,c=this.findSubGraphParts().iterator;for(;c.next();){let d=c.value;d instanceof j&&(d.suspendsRouting&&u.add(d),!(!d.Fi&&(d.fromNode===this||d.toNode===this))&&(d.suspendsRouting=!0))}for(c.reset();c.next();){let d=c.value;if(d.Lr()||d instanceof $&&d.isLinkLabel)continue;let f=d.position,p=d.location;f.isReal()?(l.x=f.x+a,l.y=f.y+h,d.position=l):p.isReal()&&(l.x=p.x+a,l.y=p.y+h,d.location=l)}for(c.reset();c.next();){let d=c.value;if(!(d instanceof j)||(d.suspendsRouting=u.has(d),!d.Fi&&(d.fromNode===this||d.toNode===this)))continue;let f=d.position;l.x=f.x+a,l.y=f.y+h,l.isReal()?d.move(l):d.$t()}P.i(l)}QE(){return(this.E&65536)!==0}cT(t){(this.E&65536)!==0!==t&&(this.E=this.E^65536)}get Nh(){return(this.E&32768)!==0}set Nh(t){(this.E&32768)!==0!==t&&(this.E=this.E^32768)}}class ue extends J{Qt;hg;constructor(t){super(),this.Qt=Dt.em,this.hg=new I(NaN,NaN,NaN,NaN),t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.Qt=this.Qt.C(),t.hg=this.hg.copy()}ba(t){if(this.background===null)return!1;let e=this.naturalBounds;return I.contains(0,0,e.width,e.height,t.x,t.y)}kd(t,e,i,s){let n=this.part;if((n===null||!(n instanceof ht)&&!(n instanceof vt))&&m.o("Placeholder is not inside a Group or Adornment."),n instanceof ht){let o=this.computeBorder(this.hg),r=this.minSize,a=isFinite(r.width)?Math.max(r.width,o.width):o.width,h=isFinite(r.height)?Math.max(r.height,o.height):o.height,l=this.Ke;l.Kn(a||0,h||0),this.ro(0,0,l.width,l.height);let u=n.memberParts,c=!1;for(;u.next();)if(u.value.isVisible()){c=!0;break}let d=n.diagram;if(c&&d!==null&&!d.animationManager.MM(n)&&!isNaN(o.x)&&!isNaN(o.y)){let f=P.l();f.setRectSpot(o,n.locationSpot),n.location=f,P.i(f)}}else{let o=n,r=this.Ke,a=this.Qt,h=a.left+a.right,l=a.top+a.bottom,u=o.adornedObject,c=u.getDocumentAngle();o.angle=c;let d=0;u instanceof it&&(d=u.strokeWidth);let f=u.getDocumentScale(),p=u.naturalBounds,g=(p.width+d)*f,y=(p.height+d)*f;if(o.type!==G.Link){let b=o.category==="Selection"?T.TopLeft:o.locationSpot,v=u.getDocumentPoint(b,P.l());o.location=v,P.i(v)}if(!isNaN(g)&&!isNaN(y))r.Kn(g+h||0,y+l||0),this.ro(-a.left,-a.top,r.width,r.height);else{let b=u.getDocumentPoint(T.TopLeft,P.l()),v=I.z(b.x,b.y,0,0);v.unionPoint(u.getDocumentPoint(T.BottomRight,b)),v.unionPoint(u.getDocumentPoint(T.TopRight,b)),v.unionPoint(u.getDocumentPoint(T.BottomLeft,b)),r.Kn(v.width+h||0,v.height+l||0),this.ro(-a.left,-a.top,r.width,r.height),P.i(b),I.i(v)}}}ka(t,e,i,s){this.actualBounds.e(t,e,i,s)}computeBorder(t){let e=this.part,i=e.diagram;if(i===null||i.animationManager.isAnimating)return t;if(e instanceof ht&&!e.layer.isTemporary&&e.computesBoundsAfterDrag&&this.hg.isReal()){let r=i.toolManager.findTool("Dragging");if(r===i.currentTool&&r.pR(e,this.hg,t))return t}let s=I.l(),n=this.computeMemberBounds(s),o=this.Qt;return e instanceof ht&&!e.isSubGraphExpanded?t.e(n.x-o.left,n.y-o.top,0,0):t.e(n.x-o.left,n.y-o.top,Math.max(n.width+o.left+o.right,0),Math.max(n.height+o.top+o.bottom,0)),I.i(s),e instanceof ht&&e.computesBoundsIncludingLocation&&e.location.isReal()&&t.unionPoint(e.location),t}computeMemberBounds(t){if(!(this.part instanceof ht))return t.e(0,0,0,0),t;let e=this.part,i=1/0,s=1/0,n=-1/0,o=-1/0,r=e.memberParts;for(;r.next();){let a=r.value;if(!a.isVisible()||a instanceof j&&(!e.computesBoundsIncludingLinks||a.Xo()||a.fromNode===e||a.toNode===e))continue;let h=a.actualBounds;h.left<i&&(i=h.left),h.top<s&&(s=h.top),h.right>n&&(n=h.right),h.bottom>o&&(o=h.bottom)}if(!isFinite(i)||!isFinite(s)){let a=e.location;t.e(a.x,a.y,0,0)}else t.e(i,s,n-i,o-s);return t}get padding(){return this.Qt}set padding(t){typeof t=="number"&&(t=new Dt(t));let e=this.Qt;e.equals(t)||(t=t.C(),this.Qt=t,this.t("padding",e,t),this.f())}}class ee{a;Lh;cg;Ar;fg;ug;Uo;Pl;dg;gg;ko;constructor(t){V.Je(this),this.a=null,this.Lh=null,this.cg=!0,this.Ar=!0,this.fg=!1,this.ug=new P(0,0),this.Uo=!0,this.Pl=null,this.dg=null,this.gg=!1,this.ko=null,t&&Object.assign(this,t)}cloneProtected(t){t.cg=this.cg,t.Ar=this.Ar,t.fg=this.fg,t.ug.h(this.ug),t.Uo=this.Uo,t.Pl=this.Pl,t.dg=this.dg,t.gg=!0}copy(){let t=new this.constructor;return this.cloneProtected(t),t}fe(t){m.ur(this,t)}toString(){let t=m.Yn(this.constructor);return t+="(",this.group!==null&&(t+=" in "+this.group),this.diagram!==null&&(t+=" for "+this.diagram),t+=")",t}get diagram(){return this.a}set diagram(t){this.a=t}get group(){return this.Lh}set group(t){this.Lh!==t&&(this.Lh=t,t!==null&&(this.a=t.diagram))}get isOngoing(){return this.cg}set isOngoing(t){this.cg!==t&&(m.s(t,"boolean",ee,"isOngoing"),this.cg=t)}get isInitial(){return this.Ar}set isInitial(t){m.s(t,"boolean",ee,"isInitial"),this.Ar=t,t||(this.gg=!0)}get isViewportSized(){return this.fg}set isViewportSized(t){this.fg!==t&&(m.s(t,"boolean",ee,"isViewportSized"),this.fg=t,t&&this.p())}get isRouting(){return this.Uo}set isRouting(t){this.Uo!==t&&(m.s(t,"boolean",ee,"isRouting"),this.Uo=t)}get isRealtime(){return this.Pl}set isRealtime(t){this.Pl!==t&&(t!==null&&m.s(t,"boolean",ee,"isRealtime"),this.Pl=t)}get isValidLayout(){return this.gg}set isValidLayout(t){if(this.gg!==t&&(m.s(t,"boolean",ee,"isValidLayout"),this.gg=t,!t)){let e=this.diagram;e!==null&&(e.Jr=!0)}}invalidateLayout(){if(!this.isValidLayout)return;let t=this.diagram;if(t===null||t.undoManager.isUndoingRedoing)return;let e=t.animationManager;e.isTicking||(e.defaultAnimation.isAnimating&&e.stopAnimation(),(this.isOngoing&&t.Za||this.isInitial&&!t.Za)&&(this.isValidLayout=!1,t.requestUpdate()))}p(){this.invalidateLayout()}get network(){return this.ko}set network(t){this.ko!==t&&(this.ko=t,t!==null&&(t.layout=this))}createNetwork(){return new Re(this)}makeNetwork(t){let e=this.createNetwork();return t instanceof Y?(e.addParts(t.nodes,!0),e.addParts(t.links,!0)):t instanceof ht?e.addParts(t.memberParts):e.addParts(t.iterator),e}updateParts(){this.isValidLayout=!0;let t=this.diagram;if(t===null&&this.network!==null){let e=this.network.vertexes.iterator;for(;e.next();){let i=e.value.node;if(i!==null&&(t=i.diagram,t!==null))break}}try{t!==null&&t.startTransaction("Layout"),this.commitLayout()}finally{t!==null&&t.commitTransaction("Layout")}}commitLayout(){if(this.network===null)return;let t=this.network.vertexes.iterator;for(;t.next();)t.value.commit();if(this.isRouting){let e=this.network.edges.iterator;for(;e.next();)e.value.commit()}}doLayout(t){let e=new V;if(t instanceof Y?(this.Ia(e,t.nodes,!0,this.Nh,!0,!1,!0),this.Ia(e,t.parts,!0,this.Nh,!0,!1,!0)):t instanceof ht?this.Ia(e,t.memberParts,!1,this.Nh,!0,!1,!0):e.addAll(t.iterator),e.count>0){let i=this.diagram;i!==null&&i.startTransaction("Layout"),this.doMinimalNoNetworkLayout(e),i!==null&&i.commitTransaction("Layout")}this.isValidLayout=!0}doMinimalNoNetworkLayout(t){let e=t.count,i=Math.ceil(Math.sqrt(e));this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);let s=this.arrangementOrigin.x,n=this.arrangementOrigin.y,o=s,r=n,a=0,h=0,l=t.iterator;for(;l.next();){let u=l.value;u.ensureBounds();let c=u.measuredBounds,d=c.width,f=c.height;u.moveTo(o,r),u instanceof ht&&(u.Nh=!1),o+=Math.max(d,50)+20,h=Math.max(h,Math.max(f,50)),a>=i-1?(a=0,o=s,r+=h+20,h=0):a++}}Nh(t){return!!(!t.location.isReal()&&!t.position.isReal()||t instanceof ht&&t.Nh)}Ia(t,e,i,s,n,o,r){let a=e.iterator;for(;a.next();){let h=a.value;if(!(i&&!h.isTopLevel)&&!(s!==null&&!s(h))&&h.canLayout())if(n&&h instanceof $){if(h.isLinkLabel)continue;h instanceof ht&&h.layout===null?this.Ia(t,h.memberParts,!1,s,n,o,r):(h.ensureBounds(),t.add(h))}else o&&h instanceof j?t.add(h):r&&h.Di()&&!(h instanceof $)&&(h.ensureBounds(),t.add(h))}}getLayoutBounds(t,e){let i=this.boundsComputation;return i!==null?(e||(e=new I),i(t,this,e)):!e&&t.margin.equalTo(0,0,0,0)?t.actualBounds:(e||(e=new I),e.set(t.actualBounds),e.addMargin(t.margin),e)}get boundsComputation(){return this.dg}set boundsComputation(t){this.dg!==t&&(t!==null&&m.S(t,ee,"boundsComputation"),this.dg=t,this.p())}collectParts(t){let e=new V;return t instanceof Y?(this.Ia(e,t.nodes,!0,null,!0,!0,!0),this.Ia(e,t.links,!0,null,!0,!0,!0),this.Ia(e,t.parts,!0,null,!0,!0,!0)):t instanceof ht?this.Ia(e,t.memberParts,!1,null,!0,!0,!0):this.Ia(e,t.iterator,!1,null,!0,!0,!0),e}get arrangementOrigin(){return this.ug}set arrangementOrigin(t){this.ug.equals(t)||(this.ug.h(t),this.p())}initialOrigin(t){let e=this.group;if(e!==null)if(e.hasPlaceholder()){let i=e.placeholder,s=i.getDocumentPoint(T.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);let n=i.padding;return s.x+=n.left,s.y+=n.top,s}else{let i=e.position.copy();return(isNaN(i.x)||isNaN(i.y))&&i.set(t),i}return t}}class Re{li;Po;In;Zy;Qy;constructor(t){V.Je(this),this.li=t,this.Po=new V,this.In=new V,this.Zy=new Mt,this.Qy=new Mt}clear(){if(this.Po){let t=this.Po.iterator;for(;t.next();)t.value.clear()}if(this.In){let t=this.In.iterator;for(;t.next();)t.value.clear()}this.Po=new V,this.In=new V,this.Zy=new Mt,this.Qy=new Mt}toString(t){t===void 0&&(t=0);let e="LayoutNetwork"+(this.layout!==null?"("+this.layout.toString()+")":"");if(t<=0)return e;if(e+=" vertexes: "+this.Po.count+" edges: "+this.In.count,t>1){let i=this.Po.iterator;for(;i.next();){let n=i.value;e+=`
|
|
14
14
|
`+n.toString(t-1)}let s=this.In.iterator;for(;s.next();){let n=s.value;e+=`
|
|
15
|
-
`+n.toString(t-1)}}return e}get layout(){return this.li}set layout(t){t!==null&&(this.li=t)}get vertexes(){return this.Po}get edges(){return this.In}createVertex(){return new Ee(this)}createEdge(){return new ei(this)}addParts(t,e,i){if(t===null)return;e===void 0&&(e=!1),m.s(e,"boolean",Re,"addParts:toplevelonly"),i===void 0&&(i=null),i===null&&(i=n=>{if(n instanceof $)return!n.isLinkLabel;if(n instanceof j){let o=n.fromNode;if(o===null||o.isLinkLabel)return!1;let r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});let s=t.iterator;for(;s.next();){let n=s.value;if(n instanceof $&&!(e&&!n.isTopLevel)&&n.canLayout()&&i(n))if(n instanceof ht&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;let o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){let n=s.value;if(!(n instanceof j)||e&&!n.isTopLevel||!n.canLayout()||!i(n)||this.findEdge(n)!==null)continue;let o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;let a=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(a,h,n)}}findGroupVertex(t){let e=t.findVisibleNode();if(e===null)return null;let i=this.findVertex(e);if(i!==null)return i;let s=e.containingGroup;for(;s!==null;){if(i=this.findVertex(s),i!==null)return i;s=s.containingGroup}return null}addVertex(t){this.Po.add(t);let e=t.node;e!==null&&this.Zy.set(e,t),t.network=this}addNode(t){let e=this.findVertex(t);return e===null&&(e=this.createVertex(),e.node=t,this.addVertex(e)),e}deleteVertex(t){if(this.kv(t)){let e=t.sr;for(let i=e.count-1;i>=0;i--){let s=e.elt(i);this.deleteEdge(s)}e=t.nr;for(let i=e.count-1;i>=0;i--){let s=e.elt(i);this.deleteEdge(s)}}}kv(t){let e=this.Po.delete(t);if(e){let i=t.node;i!==null&&this.Zy.delete(i)}return e}deleteNode(t){let e=this.findVertex(t);e!==null&&this.deleteVertex(e)}findVertex(t){return this.Zy.get(t)}addEdge(t){this.UN(t);let e=t.toVertex;e!==null&&e.addSourceEdge(t);let i=t.fromVertex;i!==null&&i.addDestinationEdge(t)}UN(t){this.In.add(t);let e=t.link;e!==null&&this.findEdge(e)===null&&this.Qy.set(e,t),t.network=this}addLink(t){let e=t.fromNode,i=t.toNode,s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,e!==null&&(s.fromVertex=this.addNode(e)),i!==null&&(s.toVertex=this.addNode(i)),this.addEdge(s)):(e!==null?s.fromVertex=this.addNode(e):s.fromVertex=null,i!==null?s.toVertex=this.addNode(i):s.toVertex=null),s}deleteEdge(t){let e=t.toVertex;e!==null&&e.deleteSourceEdge(t);let i=t.fromVertex;i!==null&&i.deleteDestinationEdge(t),this.VN(t)}VN(t){let e=this.In.delete(t);if(e){let i=t.link;i!==null&&this.Qy.delete(i)}return e}deleteLink(t){let e=this.findEdge(t);e!==null&&this.deleteEdge(e)}findEdge(t){return this.Qy.get(t)}linkVertexes(t,e,i){if(t===null||e===null)return null;if(t.network===this&&e.network===this){let s=this.createEdge();return s.link=i,s.fromVertex=t,s.toVertex=e,this.addEdge(s),s}return null}reverseEdge(t){let e=t.fromVertex,i=t.toVertex;e===null||i===null||(e.deleteDestinationEdge(t),i.deleteSourceEdge(t),t.reverseEdge(),e.addSourceEdge(t),i.addDestinationEdge(t))}deleteSelfEdges(){let t=m.st(),e=this.In.iterator;for(;e.next();){let s=e.value;s.fromVertex===s.toVertex&&t.push(s)}let i=t.length;for(let s=0;s<i;s++)this.deleteEdge(t[s]);m.Z(t)}deleteArtificialVertexes(){let t=m.st(),e=this.Po.iterator;for(;e.next();){let o=e.value;o.node===null&&o.data===null&&t.push(o)}let i=t.length;for(let o=0;o<i;o++)this.deleteVertex(t[o]);let s=m.st(),n=this.In.iterator;for(;n.next();){let o=n.value;o.link===null&&o.data===null&&s.push(o)}i=s.length;for(let o=0;o<i;o++)this.deleteEdge(s[o]);m.Z(t),m.Z(s)}deleteUselessEdges(){let t=m.st(),e=this.In.iterator;for(;e.next();){let s=e.value;(s.fromVertex===null||s.toVertex===null)&&t.push(s)}let i=t.length;for(let s=0;s<i;s++)this.deleteEdge(t[s]);m.Z(t)}isSingleton(t){return!(t.sr.count>0||t.nr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());let e=new q,i=!0;for(;i;){i=!1;let s=this.Po.iterator;for(;s.next();){let n=s.value;if(this.isSingleton(n))continue;let o=this.layout.createNetwork();e.add(o),this._E(o,n),i=!0;break}}return e.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),e}_E(t,e){if(e===null)return;let i=new q;for(i.add(e);i.count>0;){let s=i.first();if(i.removeAt(0),!s||s.network===t)continue;this.kv(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){let o=n.value;o.network!==t&&(this.VN(o),t.UN(o),o.fromVertex&&i.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){let o=n.value;o.network!==t&&(this.VN(o),t.UN(o),o.toVertex&&i.add(o.toVertex))}}}findAllParts(){let t=new V,e=this.Po.iterator;for(;e.next();){let s=e.value;s.node&&t.add(s.node)}let i=this.In.iterator;for(;i.next();){let s=i.value;s.link&&t.add(s.link)}return t}}class Ee{ko;te;Ri;Bi;es;sr;nr;constructor(t){V.Je(this),this.ko=t,this.Bi=new I(0,0,10,10),this.es=new P(5,5),this.te=null,this.Ri=null,this.sr=new q,this.nr=new q}clear(){this.te=null,this.Ri=null,this.sr=new q,this.nr=new q}toString(t){t===void 0&&(t=0);let e="LayoutVertex#"+V.xs(this);if(t>0&&(e+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let i="",s=!0,n=this.sr.iterator;for(;n.next();){let r=n.value;s?s=!1:i+=",",i+=r.toString(0)}let o="";for(s=!0,n=this.nr.iterator;n.next();){let r=n.value;s?s=!1:o+=",",o+=r.toString(0)}e+=" sources: "+i+" destinations: "+o}return e}get So(){return this.sr.AL}get or(){return this.nr.AL}get data(){return this.te}set data(t){if(this.te=t,t!==null&&t.bounds){let e=t.bounds,i=e.x,s=e.y,n=e.width,o=e.height;this.es.e(n/2,o/2),this.Bi.e(i,s,n,o)}}get node(){return this.Ri}set node(t){if(this.Ri!==t){if(this.Ri=t,t===null)return;t.ensureBounds();let e=this.network.layout,i=I.l(),s=e.getLayoutBounds(t,i),n=s.x,o=s.y,r=s.width,a=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Bi.e(n,o,r,a),I.i(i),!(t instanceof ht)){let h=t.locationObject.getDocumentPoint(T.Center);if(h.isReal()){this.es.e(h.x-n,h.y-o);return}}this.es.e(r/2,a/2)}}get bounds(){return this.Bi}set bounds(t){this.Bi.equals(t)||this.Bi.h(t)}get focus(){return this.es}set focus(t){this.es.equals(t)||this.es.h(t)}get centerX(){return this.Bi.x+this.es.x}set centerX(t){let e=this.Bi;e.x+this.es.x!==t&&(e.x=t-this.es.x)}get centerY(){return this.Bi.y+this.es.y}set centerY(t){let e=this.Bi;e.y+this.es.y!==t&&(e.y=t-this.es.y)}get focusX(){return this.es.x}set focusX(t){let e=this.es;e.x!==t&&(e.x=t)}get focusY(){return this.es.y}set focusY(t){let e=this.es;e.y!==t&&(e.y=t)}get x(){return this.Bi.x}set x(t){let e=this.Bi;e.x!==t&&(e.x=t)}get y(){return this.Bi.y}set y(t){let e=this.Bi;e.y!==t&&(e.y=t)}get width(){return this.Bi.width}set width(t){let e=this.Bi;e.width!==t&&(e.width=t)}get height(){return this.Bi.height}set height(t){let e=this.Bi;e.height!==t&&(e.height=t)}commit(){let t=this.te;if(t!==null){let i=this.bounds,s=t.bounds;m.$(s)?(s.x=i.x,s.y=i.y,s.width=i.width,s.height=i.height):t.bounds=i.copy();return}let e=this.node;if(e!==null){let i=this.bounds;if(!(e instanceof ht)){let s=I.l();e.ensureBounds();let n=this.network.layout.getLayoutBounds(e,s),o=e.locationObject.getDocumentPoint(T.Center);if(n.isReal()&&o.isReal()){e.moveTo(i.x+this.focusX-(o.x-n.x)+e.margin.left,i.y+this.focusY-(o.y-n.y+e.margin.top)),I.i(s);return}I.i(s)}e.moveTo(i.x+e.margin.left,i.y+e.margin.top)}}addSourceEdge(t){t!==null&&(this.sr.has(t)||this.sr.add(t))}deleteSourceEdge(t){t!==null&&this.sr.delete(t)}addDestinationEdge(t){t!==null&&(this.nr.has(t)||this.nr.add(t))}deleteDestinationEdge(t){t!==null&&this.nr.delete(t)}get network(){return this.ko}set network(t){this.ko=t}get sourceVertexes(){let t=new V,e=this.sourceEdges;for(;e.next();){let i=e.value;i.fromVertex&&t.add(i.fromVertex)}return t.iterator}get destinationVertexes(){let t=new V,e=this.destinationEdges;for(;e.next();){let i=e.value;i.toVertex&&t.add(i.toVertex)}return t.iterator}get vertexes(){let t=new V,e=this.sourceEdges;for(;e.next();){let i=e.value;i.fromVertex&&t.add(i.fromVertex)}for(e=this.destinationEdges;e.next();){let i=e.value;i.toVertex&&t.add(i.toVertex)}return t.iterator}get sourceEdges(){return this.sr.iterator}get destinationEdges(){return this.nr.iterator}get edges(){let t=new q,e=this.sourceEdges;for(;e.next();){let i=e.value;t.add(i)}for(e=this.destinationEdges;e.next();){let i=e.value;t.add(i)}return t.iterator}get edgesCount(){return this.sr.count+this.nr.count}static standardComparer(t,e){let i=t.Ri,s=e.Ri;if(i)if(s){let n=i.text,o=s.text;return n<o?-1:n>o?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,e){if(t!==null)if(e!==null){let i=t.Ri,s=e.Ri;if(i!==null)if(s!==null){let n=i.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),a=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),h=0;for(;h<r.length;h++)if(a[h]!==""&&a[h]!==void 0){let l=parseFloat(r[h]),u=parseFloat(a[h]);if(isNaN(l))if(isNaN(u)){if(r[h].localeCompare(a[h])!==0)return r[h].localeCompare(a[h]);continue}else return 1;else{if(isNaN(u))return-1;if(l-u!==0)return l-u;continue}}else{if(r[h]==="")continue;return 1}return a[h]!==""&&a[h]!==void 0?-1:0}else return 1;else return s!==null?-1:0}else return 1;else return e!==null?-1:0}}class ei{ko;te;ts;is;ss;constructor(t){V.Je(this),this.ko=t,this.te=null,this.ts=null,this.is=null,this.ss=null}clear(){this.te=null,this.ts=null,this.is=null,this.ss=null}toString(t){t===void 0&&(t=0);let e="LayoutEdge#"+V.xs(this);return t>0&&(e+=this.ts!==null?"("+this.ts.toString()+")":"",t>1&&(e+=" "+(this.is?this.is.toString():"null")+" --> "+(this.ss?this.ss.toString():"null"))),e}reverseEdge(){let t=this.is;this.is=this.ss,this.ss=t}commit(){}getOtherVertex(t){return this.ss===t?this.is:this.is===t?this.ss:null}get network(){return this.ko}set network(t){this.ko=t}get data(){return this.te}set data(t){this.te!==t&&(this.te=t)}get link(){return this.ts}set link(t){this.ts!==t&&(this.ts=t)}get fromVertex(){return this.is}set fromVertex(t){this.is!==t&&(this.is=t)}get toVertex(){return this.ss}set toVertex(t){this.ss!==t&&(this.ss=t)}}var Zi=(x=>(x[x.Position=0]="Position",x[x.Location=1]="Location",x))(Zi||{}),Qi=(x=>(x[x.LeftToRight=10]="LeftToRight",x[x.RightToLeft=11]="RightToLeft",x))(Qi||{}),_i=(x=>(x[x.Forwards=20]="Forwards",x[x.Reverse=21]="Reverse",x[x.Ascending=22]="Ascending",x[x.Descending=23]="Descending",x))(_i||{});class Ye extends ee{mg;pg;Ro;En;de;He;Si;Mi;constructor(t){super(),this.isViewportSized=!0,this.mg=NaN,this.pg=NaN,this.Ro=new nt(NaN,NaN).k(),this.En=new nt(10,10).k(),this.de=1,this.He=10,this.Si=22,this.Mi=Ye.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.mg=this.mg,t.pg=this.pg,t.Ro.h(this.Ro),t.En.h(this.En),t.de=this.de,t.He=this.He,t.Si=this.Si,t.Mi=this.Mi}fe(t){t in _i?this.sorting=t:t in Qi?this.arrangement=t:t in Zi?this.alignment=t:super.fe(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);let e=this.collectParts(t),i=this.diagram,s=e.copy().iterator;for(;s.next();){let f=s.value;if(f.Lr()&&(f.fromNode!==null||f.toNode!==null)){e.delete(f);continue}if(f.ensureBounds(),f instanceof ht){let p=f.memberParts;for(;p.next();){let g=p.value;e.delete(g)}}}let n=e.toArray();if(n.length===0)return;switch(this.sorting){case 20:break;case 21:n.reverse();break;case 22:n.sort(this.comparer);break;case 23:n.sort(this.comparer),n.reverse();break}let o=this.wrappingColumn;isNaN(o)&&(o=0);let r=this.wrappingWidth;if(isNaN(r)&&i!==null){let f=i.viewportBounds,p=i.padding;r=Math.max(f.width-p.left-p.right,0)}else r=Math.max(this.wrappingWidth,0);o<=0&&r<=0&&(o=1);let a=this.spacing.width;isFinite(a)||(a=0);let h=this.spacing.height;isFinite(h)||(h=0),i!==null&&i.startTransaction("Layout");let l=[];switch(this.alignment){case 0:this.t3(n,r,o,a,h,l);break;case 1:this.e3(n,r,o,a,h,l);break}let u=0,c=0,d=0;for(let f=0;f<l.length;f++){let p=l[f];u=Math.min(u,p.x),c=Math.min(c,p.y),d=Math.max(d,p.x+p.width)}this.arrangement===11?this.commitLayers(l,new P(u+a/2-(d+u),c-h/2)):this.commitLayers(l,new P(u-a/2,c-h/2)),i!==null&&i.commitTransaction("Layout"),this.isValidLayout=!0}t3(t,e,i,s,n,o){let r=I.l(),a=Math.max(this.cellSize.width,1);if(!isFinite(a)){a=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r);a=Math.max(a,v.width)}}a+=s,a=Math.max(a,1);let h=Math.max(this.cellSize.height,1);if(!isFinite(h)){h=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r);h=Math.max(h,v.height)}}h+=n,h=Math.max(h,1);let l=this.arrangement,u=this.arrangementOrigin.x,c=this.arrangementOrigin.y,d=u,f=c,p=0,g=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r),w=Math.ceil((v.width+s)/a),k=Math.ceil((v.height+n)/h),S=w*a,N=k*h,D=0;l===11?D=Math.abs(d-v.width):D=d+v.width,(i>0&&p>i-1||e>0&&p>0&&D-u>e)&&(o.push(new I(0,f,e+s,g)),p=0,d=u,f+=g,g=0),g=Math.max(g,N);let L=0;l===11?L=-v.width:L=0,(b.moveTo(d+L+b.margin.left,f+b.margin.top),l)===11?d-=S:d+=S,p++}o.push(new I(0,f,e+s,g)),I.i(r)}e3(t,e,i,s,n,o){let r=I.l(),a=Math.max(this.cellSize.width,1),h=0,l=0,u=0,c=P.l();for(let L=0;L<t.length;L++){let M=t[L],A=this.getLayoutBounds(M,r),F=M.getRelativePoint(M.locationObject,M.locationSpot,c);h=Math.max(h,F.x),l=Math.max(l,A.width-F.x),u=Math.max(u,F.y)}let d=this.arrangement;d===11?h+=s:l+=s,isFinite(a)?a=Math.max(a+s,1):a=Math.max(h+l,1);let f=this.arrangementOrigin.x,p=this.arrangementOrigin.y,g=f,y=p,b=0;e>=h&&(e-=h);let v=0,w=0,k=Math.max(this.cellSize.height,1);u=0;let S=0,N=!0,D=P.l();for(let L=0;L<t.length;L++){let M=t[L],A=this.getLayoutBounds(M,r),F=M.getRelativePoint(M.locationObject,M.locationSpot,c);if(b>0)if(d===11){let E=(g-f-(A.width-F.x))/a;C.X(Math.round(E),E)?E=Math.round(E):E=Math.floor(E),g=E*a+f}else{let E=(g-f+F.x)/a;C.X(Math.round(E),E)?E=Math.round(E):E=Math.ceil(E),g=E*a+f}else d===11?v=g+F.x+A.width:v=g-F.x;let O=0;if(d===11?O=-(g+F.x)+v:O=g+A.width-F.x-v,i>0&&b>i-1||e>0&&b>0&&O>e){o.push(new I(0,N?y-u:y,e+s,S+u+n));for(let E=0;E<b&&L!==b;E++){let B=t[L-b+E],X=B.getRelativePoint(B.locationObject,B.locationSpot,D);B.moveTo(B.position.x,B.position.y+u-X.y)}S+=n,N?y+=S:y+=S+u,u=0,S=0,b=0,g=f,N=!1}(g===f&&(d===11?w=Math.max(w,A.width-F.x):w=Math.min(w,-F.x)),u=Math.max(u,F.y),S=Math.max(S,A.height-F.y),isFinite(k)&&(S=Math.max(S,Math.max(A.height,k)-F.y)),N?M.moveTo(g-F.x,y-F.y):M.moveTo(g-F.x,y),d)===11?g-=F.x+s:g+=A.width-F.x+s,b++}if(o.push(new I(0,y,e+s,(N?S:S+u)+n)),t.length!==b)for(let L=0;L<b;L++){let M=t[t.length-b+L],A=M.getRelativePoint(M.locationObject,M.locationSpot,c);M.moveTo(M.position.x,M.position.y+u-A.y)}if(P.i(c),P.i(D),d===11)for(let L=0;L<o.length;L++){let M=o[L];M.width+=w,M.x-=w}else for(let L=0;L<o.length;L++){let M=o[L];M.x>w&&(M.width+=M.x-w,M.x=w)}I.i(r)}commitLayers(t,e){}get wrappingWidth(){return this.mg}set wrappingWidth(t){this.mg!==t&&(m.s(t,"number",Ye,"wrappingWidth"),(t>0||isNaN(t))&&(this.mg=t,this.isViewportSized=isNaN(t),this.p()))}get wrappingColumn(){return this.pg}set wrappingColumn(t){this.pg!==t&&(m.s(t,"number",Ye,"wrappingColumn"),(t>0||isNaN(t))&&(this.pg=t,this.p()))}get cellSize(){return this.Ro}set cellSize(t){this.Ro.equals(t)||(this.Ro.h(t),this.p())}get spacing(){return this.En}set spacing(t){this.En.equals(t)||(this.En.h(t),this.p())}get alignment(){return this.de}set alignment(t){this.de!==t&&(t===1||t===0)&&(this.de=t,this.p())}get arrangement(){return this.He}set arrangement(t){this.He!==t&&(t===10||t===11)&&(this.He=t,this.p())}get sorting(){return this.Si}set sorting(t){this.Si!==t&&(t===20||t===21||t===22||t===23)&&(this.Si=t,this.p())}get comparer(){return this.Mi}set comparer(t){this.Mi!==t&&(m.S(t,Ye,"comparer"),this.Mi=t,this.p())}static standardComparer(t,e){let i=t.text,s=e.text;return i<s?-1:i>s?1:0}static smartComparer(t,e){if(t!==null)if(e!==null){let i=t.text.toLocaleLowerCase(),s=e.text.toLocaleLowerCase(),n=i.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),r=0;for(;r<n.length;r++)if(o[r]!==""&&o[r]!==void 0){let a=parseFloat(n[r]),h=parseFloat(o[r]);if(isNaN(a))if(isNaN(h)){if(n[r].localeCompare(o[r])!==0)return n[r].localeCompare(o[r]);continue}else return 1;else{if(isNaN(h))return-1;if(a-h!==0)return a-h;continue}}else{if(n[r]==="")continue;return 1}return o[r]!==""&&o[r]!==void 0?-1:0}else return 1;else return e!==null?-1:0}static Position=0;static Location=1;static LeftToRight=10;static RightToLeft=11;static Forward=20;static Reverse=21;static Ascending=22;static Descending=23}class me{yg;rn;Ct;Mo;wg;xg;a;BN;constructor(){this.yg=new V,this.rn=new V,this.Ct=new V,this.Mo=new Mt,this.wg=new Mt,this.xg=new Mt,this.a=null,this.BN=!1}clear(){this.yg.clear(),this.rn.clear(),this.Ct.clear(),this.Mo.clear(),this.wg.clear(),this.xg.clear()}Io(t){this.a=t}hh(t){if(t instanceof $){if(this.yg.add(t),t instanceof ht){let i=t.containingGroup;i===null?this.diagram.$r.add(t):i.Ch.add(t);let s=t.layout;s!==null&&(s.diagram=this.diagram)}}else t instanceof j?(this.rn.add(t),t.isAvoiding&&(this.diagram.sp=!0)):t instanceof vt||this.Ct.add(t);let e=t.data;e!==null&&(t instanceof vt||(t instanceof j?this.Pv(e,t):this.Mo.set(e,t)))}ri(t){if(t.clearAdornments(),t instanceof $){if(this.yg.delete(t),t instanceof ht){let i=t.containingGroup;i===null?this.diagram.$r.delete(t):i.Ch.delete(t);let s=t.layout;s!==null&&(s.diagram=null)}}else t instanceof j?this.rn.delete(t):t instanceof vt||this.Ct.delete(t);let e=t.data;e!==null&&(t instanceof vt||(t instanceof j?this.Sv(e,t):this.Mo.delete(e)))}Pv(t,e){this.wg.set(t,e)}Sv(t,e){this.wg.delete(t)}rebuildParts(){let t=this.diagram;if(t===null)return;let e=t.nodeTemplateMap.iterator;for(;e.next();){let d=e.value,f=e.key;(!d.Di()||d instanceof ht)&&m.o(`Invalid node template in Diagram.nodeTemplateMap: template for "${f}" must be a Node or a simple Part, not a Group or Link: ${d}`)}let i=t.groupTemplateMap.iterator;for(;i.next();){let d=i.value,f=i.key;d instanceof ht||m.o(`Invalid group template in Diagram.groupTemplateMap: template for "${f}" must be a Group, not a normal Node or Link: ${d}`)}let s=t.linkTemplateMap.iterator;for(;s.next();){let d=s.value,f=s.key;d instanceof j||m.o(`Invalid link template in Diagram.linkTemplateMap: template for "${f}" must be a Link, not a normal Node or simple Part: ${d}`)}let n=m.st(),o=t.selection.iterator;for(;o.next();){let d=o.value.data;d&&n.push(d)}let r=m.st(),a=t.highlighteds.iterator;for(;a.next();){let d=a.value.data;d&&r.push(d)}let h=m.st(),l=this.nodes.iterator;for(;l.next();){let d=l.value;d.data!==null&&(h.push(d.data),h.push(d.location))}let u=this.links.iterator;for(;u.next();){let d=u.value;d.data!==null&&(h.push(d.data),h.push(d.location))}let c=this.parts.iterator;for(;c.next();){let d=c.value;d.data!==null&&(h.push(d.data),h.push(d.location))}this.Mv(),this.T2();for(let d=0;d<n.length;d++){let f=this.findPartForData(n[d]);f!==null&&(f.isSelected=!0)}for(let d=0;d<r.length;d++){let f=this.findPartForData(r[d]);f!==null&&(f.isHighlighted=!0)}for(let d=0;d<h.length;d+=2){let f=this.findPartForData(h[d]);f!==null&&(f.location=h[d+1])}m.Z(n),m.Z(r),m.Z(h)}T2(){let t=this.diagram.model;this._y(t.nodeDataArray)}_y(t,e){let i=this.diagram.model;t.forEach(s=>{i.containsNodeData(s)&&this.Cv(s,!1)}),t.forEach(s=>{i.containsNodeData(s)&&this.kk(s)}),e!==!1&&this.diagram.o1(!1)}Cv(t,e){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;e===void 0&&(e=!0);let i=this.i3(t);return i!==null&&e&&this.kk(t),i}i3(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;let e=this.s3(t),i=this.findTemplateForNodeData(t,e);if(i!==null){i.It();let s=i.copy();if(s!==null){let n=this.diagram.wi;return this.diagram.wi=!0,s.Qo=e,s.te=t,this.addsToTemporaryLayer&&(s.dl="Tool"),this.diagram.add(s),s.te=null,s.data=t,this.diagram.wi=n,s}}return null}insertLink(t,e,i,s){return null}kk(t){}s3(t){return this.diagram.model.getCategoryForNodeData(t)}static Nv=!1;static Lv=!1;findTemplateForNodeData(t,e){let i=this.diagram,s=i.model,n=s.Ah()&&s.isGroupForData(t),o=null;return n?(o=i.groupTemplateMap.get(e),o===null&&(o=i.groupTemplateMap.get(""),o===null&&(me.Lv||(me.Lv=!0,m.ne('No Group template found for category "'+e+'"'),m.ne(" Using default group template")),o=i.e2))):(o=i.nodeTemplateMap.get(e),o===null&&(o=i.nodeTemplateMap.get(""),o===null&&(me.Nv||(me.Nv=!0,m.ne('No Node template found for category "'+e+'"'),m.ne(" Using default node template")),o=i.QM))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,e){}setFromNodeForLink(t,e,i){}setToNodeForLink(t,e,i){}static Av=!1;findLinkTemplateForCategory(t){let e=this.diagram,i=e.linkTemplateMap.get(t);return i===null&&(i=e.linkTemplateMap.get(""),i===null&&(me.Av||(me.Av=!0,m.ne('No Link template found for category "'+t+'"'),m.ne(" Using default link template")),i=e._M)),i}JI(t,e,i){t instanceof j?(e!==null&&this.Sv(e,t),i!==null&&this.Pv(i,t)):t instanceof pt&&(e!==null&&this.Mo.delete(e),i!==null&&this.Mo.set(i,t))}Mv(){let t=this.diagram.model;this.zN(t.nodeDataArray)}zN(t){t.forEach(e=>{this.Pk(e)})}Pk(t){let e=this.findPartForData(t);e!==null&&(this.diagram.N2(e,!1),this.XN(e))}XN(t){}LN(t){}findPartForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.Mo.get(e):null}findNodeForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);if(e===null)return null;let i=this.Mo.get(e);return i instanceof $?i:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let e=this.Mo.get(t);return e!==null||(e=this.wg.get(t)),e}findNodeForData(t){if(t===null)return null;let e=this.Mo.get(t);return e instanceof $?e:null}findLinkForData(t,e){return t===null?null:this.wg.get(t)}findNodesByExample(...t){let e=new V,i=this.yg.iterator;for(;i.next();){let s=i.value,n=s.data;if(n!==null)for(let o=0;o<arguments.length;o++){let r=arguments[o];if(m.$(r)&&this.GN(n,r)){e.add(s);break}}}return e.iterator}findLinksByExample(...t){let e=new V,i=this.rn.iterator;for(;i.next();){let s=i.value,n=s.data;if(n!==null)for(let o=0;o<arguments.length;o++){let r=arguments[o];if(m.$(r)&&this.GN(n,r)){e.add(s);break}}}return e.iterator}GN(t,e){for(let i in e){let s=t[i],n=e[i];if(Array.isArray(n)){if(!Array.isArray(s))return!1;let o=s,r=n;if(o.length<r.length)return!1;for(let a=0;a<o.length;a++){let h=o[a],l=r[a];if(l!==void 0&&!this.Tv(h,l))return!1}}else if(!this.Tv(s,n))return!1}return!0}Tv(t,e){if(m.it(e)){if(!e(t))return!1}else if(e instanceof RegExp){if(!t||!e.test(t.toString()))return!1}else if(m.$(t)&&m.$(e)){if(!this.GN(t,e))return!1}else if(t!==e)return!1;return!0}doModelDataChanged(t){if(t.model===this.diagram.model&&this.diagram.G){this.diagram.G=!1;try{let e=t.change;t.modelChange===""&&t.object!==null&&e===2&&this.tw(t.object,t.propertyName)}finally{this.diagram.G=!0}}}doModelChanged(t){let e=this.diagram;if(!e||t.model!==e.model)return;let i=t.change;if(e.AO(t),!!e.G){e.G=!1;try{let s=t.modelChange;if(s!=="")if(i===2){if(s==="nodeCategory"){let n=t.object;if(n!==null){let o=this.findPartForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}}else if(s==="nodeDataArray"){let n=t.oldValue;this.zN(n);let o=t.newValue;this._y(o)}e.isModified=!0}else if(i===3){let n=t.newValue;s==="nodeDataArray"&&m.$(n)&&this.Cv(n),e.isModified=!0}else if(i===4){let n=t.oldValue;s==="nodeDataArray"&&m.$(n)&&this.Pk(n),e.isModified=!0}else i===1&&(s==="SourceChanged"?t.object!==null?this.tw(t.object,t.propertyName):(this.updateAllRelationshipsFromData(),this.updateAllTargetBindings()):s==="ModelDisplaced"&&this.rebuildParts());else if(i===2){let n=t.propertyName,o=t.object,r=e.model;o===r?(n==="nodeKeyProperty"||n==="nodeCategoryProperty")&&(e.undoManager.isUndoingRedoing||this.rebuildParts()):o!==null&&this.tw(o,n),e.isModified=!0}else(i===3||i===4)&&(this.o3(t,e.model),e.isModified=!0)}finally{e.G=!0}}}updateAllTargetBindings(t){t===void 0&&(t="");let e=this.parts.iterator;for(;e.next();)e.value.updateTargetBindings(t);for(e=this.nodes.iterator;e.next();)e.value.updateTargetBindings(t);for(e=this.links.iterator;e.next();)e.value.updateTargetBindings(t)}updateAllThemeBindings(){let t=this.parts.iterator;for(;t.next();)t.value.Go();for(t=this.nodes.iterator;t.next();)t.value.Go();for(t=this.links.iterator;t.next();)t.value.Go()}updateAllRelationshipsFromData(){let t=this.diagram.model,e=new V,i=t.nodeDataArray;for(let o=0;o<i.length;o++){let r=i[o];e.add(r)}let s=[];this.nodes.each(o=>{o.data!==null&&!e.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!e.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.Dv(o,!1));for(let o=0;o<i.length;o++){let r=i[o];this.findPartForData(r)===null&&t.vv(r,!1)}this.Fv();let n=this.parts.iterator;for(;n.next();)n.value.updateRelationshipsFromData();for(n=this.nodes.iterator;n.next();)n.value.updateRelationshipsFromData();for(n=this.links.iterator;n.next();)n.value.updateRelationshipsFromData()}Fv(){}updateRelationshipsFromData(t){}tw(t,e){if(typeof e=="string"){let i=this.findPartForData(t);if(i!==null)i.updateTargetBindings(e);else{let s=this.r3(t);if(s!==null&&s.length>0){for(let o=0;o<s.length;o++)s[o].updateTargetBindings(e);let n=s[0].part;if(n!==null){let o=n.adornments;for(;o.next();)o.value.updateTargetBindings(e)}m.Z(s)}}t===this.diagram.model.modelData&&this.updateAllTargetBindings(e)}}r3(t){let e=null,i=this.xg.iterator;for(;i.next();){let s=i.value;for(let n=0;n<s.length;n++){let o=s[n].findItemPanelForData(t);o!==null&&(e===null&&(e=m.st()),e.push(o))}if(e!==null)break}return e}YN(t){return this.xg.get(t)}o3(t,e){let i=t.object;if(!Array.isArray(i))return;let s=t.change===3,n=s?t.newParam:t.oldParam,o=s?t.newValue:t.oldValue,r=this.YN(i);if(Array.isArray(r))for(let a=0;a<r.length;a++){let h=r[a];s?h.W1(o,n,!0):h.QI(n)}}M2(t,e){e!==null&&t.Sn(s=>e.uT(s));let i=t.Aa;if(Array.isArray(i)){let s=this.YN(i);if(s===null)this.xg.set(i,[t]);else{for(let n=0;n<s.length;n++)if(s[n]===t)return;s.push(t)}}}C2(t,e){t.Sn(s=>e.DO(s));let i=t.Aa;if(Array.isArray(i)){let s=this.YN(i);if(s!==null){for(let n=0;n<s.length;n++)if(s[n]===t){s.splice(n,1),s.length===0&&this.xg.delete(i);return}}}}copyParts(t,e,i){i===void 0&&(i=!1);let s=new Mt;if(Array.isArray(t))for(let o=0;o<t.length;o++)this.Sk(t[o],e,s,i);else{let o=t.iterator;for(;o.next();)this.Sk(o.value,e,s,i)}if(e!==null){let o=e.model,r=e.Cp().dragsLink,a=new V,h=new Mt,l=s.iterator;for(;l.next();){let u=l.value;if(u instanceof j)!r&&(u.fromNode===null||u.toNode===null)&&a.add(u);else if(u instanceof $&&u.data!==null){if(o.Mx()){let c=u,d=l.key,f=d.findTreeParentNode();if(f!==null){let p=s.get(f);if(p!==null){o.setParentKeyForNodeData(c.data,o.getKeyForNodeData(p.data));let g=e.findLinkForData(c.data),y=d.findTreeParentLink();y!==null&&g!==null&&h.set(y,g)}}}else if(o.Rv()){let c=u,d=l.key,f=o.isRelatedKeysPathTo?d.findNodesOutOf():d.findNodesInto();for(;f.next();){let p=f.value,g=s.get(p);if(g!==null){o.addRelatedKeyForNodeData(c.data,g.key);let y=e.partManager.findLinkForData(c.data,g.key),b=this.findLinkForData(d.data,p.key);b!==null&&y!==null&&h.set(b,y)}else o.removeRelatedKeyForNodeData(c.data,p.key)}}}}if(a.count>0&&e.removeParts(a,!1),h.count>0){let u=h.iterator;for(;u.next();){let c=u.key,d=u.value;s.set(c,d)}}}if(e!==null&&this.diagram!==null){let o=e.model,r=o.afterCopyFunction;if(r!==null){let a=new Mt;s.each(l=>{l.key.data!==null&&a.set(l.key.data,l.value.data)});let h=this.diagram.model;r(a,o,h)}}let n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Sk(t,e,i,s){if(t===null||s&&!t.canCopy())return null;if(i.has(t))return i.get(t);let n=this.KN(t,e);if(!(n instanceof pt))return null;if(n.isSelected=!1,n.isHighlighted=!1,i.set(t,n),t instanceof $){let o=t.linksConnected;for(;o.next();){let r=o.value;if(r.fromNode===t){let a=i.get(r);a!==null&&(a.fromNode=n)}if(r.toNode===t){let a=i.get(r);a!==null&&(a.toNode=n)}}if(t instanceof ht&&n instanceof ht){let r=t.memberParts;for(;r.next();){let a=r.value,h=this.Sk(a,e,i,s);h instanceof j||h!==null&&(h.containingGroup=n)}}}else if(t instanceof j&&n instanceof j){let o=t.fromNode;if(o!==null){let h=i.get(o);h!==null&&(n.fromNode=h)}let r=t.toNode;if(r!==null){let h=i.get(r);h!==null&&(n.toNode=h)}let a=t.labelNodes;for(;a.next();){let h=a.value,l=this.Sk(h,e,i,s);l!==null&&l instanceof $&&(l.labeledLink=n)}}return n}KN(t,e){let i=null,s=t.data;if(s!==null&&e!==null){let n=e.model;if(!(t instanceof j)){let o=n.copyNodeData(s);n.addNodeData(o),i=e.findPartForData(o)}}else if(t.It(),i=t.copy(),i!==null){let n=this.diagram;if(e!==null)e.add(i);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){let o=n.model,r=null;i instanceof j||(r=o.copyNodeData(s)),i.data=r}}return i}get nodes(){return this.yg}get links(){return this.rn}get parts(){return this.Ct}get diagram(){return this.a}get addsToTemporaryLayer(){return this.BN}set addsToTemporaryLayer(t){this.BN=t}}class Zn extends me{T2(){let t=this.diagram.model;this._y(t.nodeDataArray),this.Ov(t.linkDataArray)}_y(t){super._y(t,!1);let e=this.links.iterator;for(;e.next();)e.value.Jd();this.diagram.o1(!1)}Ov(t){t.forEach(e=>{this.Iv(e)}),this.diagram.o1(!1)}Iv(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.findLinkForData(t))return null;let e=this.getLinkCategoryForData(t),i=this.findLinkTemplateForCategory(e);if(i!==null){i.It();let s=i.copy();if(s!==null){let n=this.diagram.wi;this.diagram.wi=!0,s.Qo=e,s.te=t;let o=this.diagram.model,r=o.Mk(t,!0);r!==""&&(s.fromPortId=r);let a=o.zi(t,!0);if(a!==void 0){let c=this.findNodeForKey(a);c instanceof $&&(s.fromNode=c)}let h=o.Mk(t,!1);h!==""&&(s.toPortId=h);let l=o.zi(t,!1);if(l!==void 0){let c=this.findNodeForKey(l);c instanceof $&&(s.toNode=c)}let u=o.getLabelKeysForLinkData(t);return Array.isArray(u)&&u.forEach(c=>{let d=this.findNodeForKey(c);d!==null&&(d.labeledLink=s)}),this.addsToTemporaryLayer&&(s.dl="Tool"),this.diagram.add(s),s.te=null,s.data=t,this.diagram.wi=n,s}}return null}Mv(){let t=this.diagram.model;this.Ev(t.linkDataArray),this.zN(t.nodeDataArray)}Ev(t){t.forEach(e=>{this.Pk(e)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,e){return this.diagram.model.setCategoryForLinkData(t,e)}setFromNodeForLink(t,e,i){let s=this.diagram.model,n=e!==null?e.data:null;s.setFromKeyForLinkData(t.data,s.getKeyForNodeData(n))}setToNodeForLink(t,e,i){let s=this.diagram.model,n=e!==null?e.data:null;s.setToKeyForLinkData(t.data,s.getKeyForNodeData(n))}LN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){let e=super.findPartForKey(t);if(e===null){let i=this.diagram.model.findLinkDataForKey(t);if(i!==null)return this.findLinkForData(i)}return e}findLinkForKey(t){if(t==null)return null;let e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.findLinkForData(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;let e=this.diagram;if(t.model!==e.model)return;let i=t.change;if(e.G){e.G=!1;try{let s=t.modelChange;if(s!==""){if(i===2){if(s==="linkFromKey"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue,a=this.findNodeForKey(r);o.fromNode=a}}else if(s==="linkToKey"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue,a=this.findNodeForKey(r);o.toNode=a}}else if(s==="linkFromPortId"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){let n=t.object,o=this.findPartForData(n);if(o!==null){let r=t.newValue;if(r!==void 0){let a=this.findNodeForKey(r);a instanceof ht?o.containingGroup=a:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.oldValue,a=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(a.indexOf(h)>=0)return;let l=this.findNodeForKey(h);l!==null&&(l.labeledLink=null)}),Array.isArray(a)&&a.forEach(h=>{let l=this.findNodeForKey(h);l!==null&&(l.labeledLink=o)})}}else if(s==="linkCategory"){let n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){let n=t.oldValue;this.Ev(n);let o=t.newValue;this.Ov(o)}e.isModified=!0}else if(i===3){let n=t.newValue;if(s==="linkDataArray"&&m.$(n))this.Iv(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){let o=t.object,r=this.findLinkForData(o),a=this.findNodeForKey(n);r!==null&&a!==null&&(a.labeledLink=r)}e.isModified=!0}else if(i===4){let n=t.oldValue;if(s==="linkDataArray"&&m.$(n))this.Pk(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){let o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}e.isModified=!0}}else if(i===2){let n=t.propertyName,o=t.object,r=e.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(e.undoManager.isUndoingRedoing||this.rebuildParts()),e.isModified=!0}}finally{e.G=!0}}}Fv(){let t=this.diagram.model,e=new Set,i=t.linkDataArray;i.forEach(n=>{e.add(n)});let s=[];this.links.each(n=>{n.data!==null&&!e.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.Uv(n,!1)}),i.forEach(n=>{this.findLinkForData(n)===null&&t.Vv(n,!1)})}updateRelationshipsFromData(t){let e=t.data;if(e===null)return;let i=t.diagram;if(i===null)return;let s=i.model;if(t instanceof j){let n=s.zi(e,!0),o=i.findNodeForKey(n);t.fromNode=o,n=s.zi(e,!1),o=i.findNodeForKey(n),t.toNode=o;let r=s.getLabelKeysForLinkData(e);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){let c=r[0],d=t.labelNodes.first();if(d!==null&&s.getKeyForNodeData(d.data)===c)return}let a=new V().addAll(r),h=new V;t.labelNodes.each(c=>{if(c.data!==null){let d=s.getKeyForNodeData(c.data);d!==void 0&&h.add(d)}});let l=h.copy();l.removeAll(a);let u=a.copy();if(u.removeAll(h),l.count>0||u.count>0){let c=t;l.each(d=>{let f=i.findNodeForKey(d);f!==null&&f.labeledLink===c&&(f.labeledLink=null)}),u.each(d=>{let f=i.findNodeForKey(d);f!==null&&f.labeledLink!==c&&(f.labeledLink=c)})}}}else if(!(t instanceof vt)){let n=s.getGroupKeyForNodeData(e),o=i.findPartForKey(n);(o===null||o instanceof ht)&&(t.containingGroup=o)}}kk(t){let e=this.diagram.model,i=e.getKeyForNodeData(t);if(i!==void 0){let s=e.ew(i),n=this.findPartForData(t);if(s!==null&&n!==null){let r=s.iterator;for(;r.next();){let a=r.value;if(e.containsNodeData(a)){if(n instanceof ht&&e.getGroupKeyForNodeData(a)===i){let h=this.findPartForData(a);h!==null&&(h.containingGroup=n)}}else{let h=this.findLinkForData(a);if(h!==null&&n instanceof $){e.zi(a,!0)===i&&(h.fromNode=n),e.zi(a,!1)===i&&(h.toNode=n);let l=e.getLabelKeysForLinkData(a);Array.isArray(l)&&l.some(u=>u===i?(n.labeledLink=h,!0):!1)}}}e.an(i)}let o=e.getGroupKeyForNodeData(t);if(o!==void 0){let r=this.findNodeForKey(o);n!==null&&r instanceof ht&&(n.containingGroup=r)}}}XN(t){let e=this.diagram.model;if(t instanceof $){let i=e.getKeyForNodeData(t.data);if(i!==void 0){let s=t.linksConnected;for(;s.next();){let n=s.value;e.hn(i,n.data)}if(t.isLinkLabel){let n=t.labeledLink;n!==null&&e.hn(i,n.data)}if(t instanceof ht){let n=t.memberParts;for(;n.next();){let o=n.value.data;e.containsNodeData(o)&&e.hn(i,o)}}}}}KN(t,e){let i=super.KN(t,e);if(t instanceof j){let s=t.data;if(s!==null&&e!==null){let n=e.model,o=n.copyLinkData(s);n.addLinkData(o),i=e.findLinkForData(o)}else if(i!==null){let n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){let o=n.model.copyLinkData(s);i.data=o}}}return i}insertLink(t,e,i,s){let n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking"),a="";t!==null&&(e===null&&(e=t),a=e.portId,a===null&&(a=""));let h="";i!==null&&(s===null&&(s=i),h=s.portId,h===null&&(h=""));let l=r.archetypeLinkData;if(l instanceof j){l.It();let u=l.copy();if(u!==null){u.fromNode=t,u.fromPortId=a,u.toNode=i,u.toPortId=h,n.add(u);let c=r.archetypeLabelNodeData;if(c instanceof $){c.It();let d=c.copy();d!==null&&(d.labeledLink=u,n.add(d))}return u}}else if(l!==null){let u=o.copyLinkData(l);if(m.$(u)){t!==null&&o.bg(u,o.getKeyForNodeData(t.data),!0),o.kg(u,a,!0),i!==null&&o.bg(u,o.getKeyForNodeData(i.data),!1),o.kg(u,h,!1),o.addLinkData(u);let c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof $)){let d=o.copyNodeData(c);o.addNodeData(d);let f=o.getKeyForNodeData(d);f!==void 0&&o.addLabelKeyForLinkData(u,f)}return n.findLinkForData(u)}}return null}}class Qn extends me{Ea=null;Ck(t,e){if(t===null||e===null||e.findTreeParentLink()!==null)return;let i=this.diagram.toolManager.findTool("Linking"),s=t,n=e;if(this.diagram.isTreePathToChildren){if(i!==null&&i.Vu(s,n,null,!0))return}else if(s=e,n=t,i!==null&&i.Vu(s,n,null,!0))return;let o=this.getLinkCategoryForData(e.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.It();let a=r.copy();if(a!==null){let h=this.diagram.wi;this.diagram.wi=!0,a.Qo=o,a.te=e.data,a.fromNode=s,a.toNode=n,this.diagram.add(a),a.te=null,a.data=e.data,this.diagram.wi=h}}}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,e){this.diagram.model.setParentLinkCategoryForNodeData(t,e)}setFromNodeForLink(t,e,i){let s=this.diagram.model;i===void 0&&(i=null);let n=e!==null?e.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{let o=this.Ea;this.Ea=t,i!==null&&s.setParentKeyForNodeData(i.data,void 0);let r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ea=o}}setToNodeForLink(t,e,i){let s=this.diagram.model;i===void 0&&(i=null);let n=e!==null?e.data:null;if(this.diagram.isTreePathToChildren){let o=this.Ea;this.Ea=t,i!==null&&s.setParentKeyForNodeData(i.data,void 0);let r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ea=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}LN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.findLinkForData(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;let e=this.diagram;if(t.model!==e.model)return;let i=t.change;if(e.G){e.G=!1;try{let s=t.modelChange;if(s!==""){if(i===2){if(s==="nodeParentKey"){let n=t.object,o=n?this.findNodeForData(n):null,r=t.newValue,a=this.findNodeForKey(r);if(n&&this.Ea!==null)a!==null&&(this.Ea.data=n,this.Ea.category=this.getLinkCategoryForData(n));else if(o!==null){let h=o.findTreeParentLink();h!==null?a===null?e.remove(h):e.isTreePathToChildren?h.fromNode=a:h.toNode=a:this.Ck(a,o)}}else if(s==="parentLinkCategory"){let n=t.object,o=n?this.findNodeForData(n):null,r=t.newValue;if(o!==null&&typeof r=="string"){let a=o.findTreeParentLink();a!==null&&(a.category=r)}}e.isModified=!0}}else i===2&&(t.object===e.model&&t.propertyName==="nodeParentKeyProperty"&&(e.undoManager.isUndoingRedoing||this.rebuildParts()),e.isModified=!0)}finally{e.G=!0}}}updateRelationshipsFromData(t){let e=t.data;if(e===null)return;let i=t.diagram;if(i===null)return;let s=i.model;if(t instanceof $){let n=s.getParentKeyForNodeData(e),o=i.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){let a=t.findTreeParentLink();o!==null?a!==null?i.isTreePathToChildren?a.fromNode=o:a.toNode=o:this.Ck(o,t):a!==null&&i.N2(a,!1)}}}tw(t,e){if(super.tw(t,e),typeof e=="string"&&this.findPartForData(t)!==null){let i=this.findLinkForData(t);i!==null&&i.updateTargetBindings(e)}}kk(t){let e=this.diagram.model,i=e.getKeyForNodeData(t);if(i!==void 0){let s=e.ew(i),n=this.findPartForData(t);if(s!==null&&n!==null){let r=s.iterator;for(;r.next();){let a=r.value;if(e.containsNodeData(a)&&n instanceof $&&e.getParentKeyForNodeData(a)===i){let h=this.findNodeForData(a);this.Ck(n,h)}}e.an(i)}let o=e.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof $){let r=this.findNodeForKey(o);this.Ck(r,n)}}}XN(t){let e=this.diagram.model;if(t instanceof $){let i=e.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;let r=s.layer;if(r!==null){let a=r.ri(-1,s,!1);a>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,a,null);let h=s.layerChanged;h!==null&&h(s,r,null)}}let n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){let r=o.value,a=n?r.toNode:r.fromNode;if(a!==null){let h=a.data;e.containsNodeData(h)&&e.hn(i,h)}}}}insertLink(t,e,i,s){let n=this.diagram.model,o=t,r=i;if(this.diagram.isTreePathToChildren||(o=i,r=t),o!==null&&r!==null){let a=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(a)),r.findTreeParentLink()}return null}}var Ci=(x=>(x[x.OneWay=1]="OneWay",x[x.TwoWay=2]="TwoWay",x))(Ci||{});class ie{n;HN;nc;Hf;Ua;qf;jf;Wf;Nk;Ti;Ed;vf;constructor(t,e,i,s){V.Je(this),t===void 0?t="":m.s(t,"string",ie,"constructor:targetprop"),e===void 0?e=t:m.s(e,"string",ie,"constructor:sourceprop"),i===void 0?i=null:i!==null&&m.S(i,ie,"constructor:conv"),this.HN=-1,this.Ti=null,this.nc=t,this.Ed=0,this.vf=0,this.Hf=null,this.Ua=e,this.qf=i,s===void 0?(this.jf=1,this.Wf=null):(this.jf=2,this.Wf=s),this.Nk=new V,this.n=2}copy(){let t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.nc=this.nc,t.Ed=this.Ed,t.vf=this.vf,t.Hf=this.Hf,t.Ua=this.Ua,t.qf=this.qf,t.jf=this.jf,t.Wf=this.Wf,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,e){return m.S(t,ie,"parseEnum:ctor"),i=>{let s=parseInt(i);return isNaN(s)&&(s=m.Ja(t,i),s===null)?e:s}}fe(t){t in Ci?this.mode=t:m.ur(this,t)}static toString(t){return m.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+Ci[this.mode]+")"}k(){return this.n=this.n|1,this}get targetId(){return this.HN}set targetId(t){this.u&&m.L(this),this.HN=t}get targetProperty(){return this.nc}set targetProperty(t){this.u&&m.L(this),m.s(t,"string",ie,"targetProperty"),this.nc=t}get sourceProperty(){return this.Ua}set sourceProperty(t){this.u&&m.L(this),m.s(t,"string",ie,"sourceProperty"),this.Ua=t}get u(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get qN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}bd(){return!1}get sourceName(){return this.Hf}set sourceName(t){this.u&&m.L(this),t!==null&&m.s(t,"string",ie,"sourceName"),this.Hf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.qf}set converter(t){this.u&&m.L(this),t!==null&&m.S(t,ie,"converter"),this.qf=t}get backConverter(){return this.Wf}set backConverter(t){this.u&&m.L(this),t!==null&&m.S(t,ie,"backConverter"),this.Wf=t}get mode(){return this.jf}set mode(t){this.u&&m.L(this),this.isToTheme&&t===2&&m.o("Theme Bindings cannot be TwoWay."),this.jf=t}makeTwoWay(t){return this.isToTheme&&m.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(m.S(t,ie,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.u&&m.L(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.u&&m.L(this),this.n=this.n&-3&-5|8,this.Hf=null,this}JT(t,e){let i=this.sourceName,s=null;return i===null||i===""?s=t:i==="/"?s=e.part:i==="."?s=e:i===".."?s=e.panel:s=t.findObject(i),s}check(t){let e=this.nc,i=this.Ua,s=this.qf;(this.bd()&&s===null&&this.Va===null&&e===""||s===null&&e==="")&&m.ne("Binding error: target property is the empty string: "+this.toString()),this.bd()&&this.qN&&i===""&&s===null&&this.Va===null&&m.ne("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof e=="string"&&(!m.it(["setAttribute"])&&e.length>0&&e[0]!=="_"&&!m.Gw(t,e)?m.ne("Binding error: undefined target property: "+e+" on "+t.toString()):e==="name"&&t instanceof J&&m.ne("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,e,i,s){let n=this.Ua;if(i!==void 0&&n!==""&&n!==i||this.isToTheme&&t.diagram===null)return;let o=this.nc,r=this.qf,a=e;if(n!==""&&!this.qN&&(a=dt.Lt(e,n)),a!==void 0)if(r===null){if(o!==""){if(this.bd()){let h=t.diagram?.themeManager;if(a=this.Bv(h,a,t,o),a===void 0)return}s?s.nt(t,o,a):(e instanceof J||e instanceof Kt)&&dt.nt(t,o,a)}}else try{if(o!==""){let h=r(a,t);if(this.bd()){let l=t.diagram?.themeManager;if(h=this.Bv(l,h,t,o),h===void 0)return}s?s.nt(t,o,h):(e instanceof J||e instanceof Kt)&&dt.nt(t,o,h)}else r(a,t)}catch{}}updateSource(t,e,i,s){if(this.jf!==2)return;let n=this.nc;if(i!==void 0&&n!==i)return;let o=this.Ua,r=this.Wf,a=s!==null?s.diagram:null,h=a!==null?a.model:null,l=t;if(n!==""&&(l=dt.Lt(t,n)),l!==void 0&&!this.Nk.has(t))try{if(this.Nk.add(t),r===null){if(o!=="")h!==null?h.setDataProperty(e,o,l):(e instanceof J||e instanceof Kt)&&(e[o]=l);else if(h!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){let u=s.itemIndex,c=s.panel.itemArray;h.removeArrayItem(c,u),h.insertArrayItem(c,u,l)}}else try{if(o!==""){let u=r(l,e,h);h!==null?h.setDataProperty(e,o,u):(e instanceof J||e instanceof Kt)&&(e[o]=u)}else{let u=r(l,e,h);if(u!==void 0&&h!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){let c=s.itemIndex,d=s.panel.itemArray;h.removeArrayItem(d,c),h.insertArrayItem(d,c,u)}}}catch{}}finally{this.Nk.delete(t)}}}class ii extends ie{iw;Va;oc;constructor(t,e,i,s,n){super(t,e,s),i==null&&(i=""),n===void 0&&(n=null),this.iw=i,this.Va=n,this.oc=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.iw=this.iw,t.Va=this.Va,t.oc=this.oc}bd(){return!0}get themeSource(){return this.iw}set themeSource(t){this.u&&m.L(this),t!==null&&m.s(t,"string",ii,"themeSource"),this.iw=t,this.oc=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Va}set themeConverter(t){this.u&&m.L(this),t!==null&&m.S(t,ii,"themeConverter"),this.Va=t}ofData(){return this.u&&m.L(this),this.n=this.n|2,this.Hf=null,this}Bv(t,e,i,s){if(!t||(this.qN&&(e=this.Ua),!e&&e!==0))return;let n=this.themeSource;this.oc!==null?n=this.oc:typeof n=="string"&&n.includes(".")&&(this.oc=n.split("."),n=this.oc);let o=t.findValue(e,n,s);if(o===void 0&&m.ne(`Theme warning: ${e} could not be found when setting target property ${s}.`),t.readsCssVariables&&typeof o=="string"&&o.startsWith("var(")){let r=o.match(this.l3);r&&(o=getComputedStyle(K.document.documentElement).getPropertyValue(r[1]))}return m.it(this.Va)&&(o=this.Va(o,i)),o}l3=/var\((.*)\)/}class dt{Pt;Pg;Bo;jN;Xi;ke;Ba;Jf;$f;Sg;Mg;Cg;Ng;nw;rc;rr;ow;Vo;Lk;constructor(t,e){if(V.Je(this),this.Pt="",this.Pg="",this.Bo=!1,this.jN={},this.Xi=[],this.ke=new Mt,this.Ba="key",this.Jf=null,this.$f=null,this.Sg=!1,this.Mg=!1,this.Cg=!1,this.Ng=null,this.nw=100,this.rc="category",this.rr=new Mt,this.ow=[],this.Vo=!1,this.Lk=null,this.undoManager=new vi,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:e=t),e){Object.assign(this,e);let i=e.Changed;i&&(delete this.Changed,this.addChangedListener(i))}}cloneProtected(t){t.Pt=this.Pt,t.Pg=this.Pg,t.Bo=this.Bo,t.Ba=this.Ba,t.Jf=this.Jf,t.$f=this.$f,t.Sg=this.Sg,t.Mg=this.Mg,t.Cg=this.Cg,t.Ng=this.Ng,t.nw=this.nw,t.rc=this.rc}copy(){let t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Xi=[],this.ke.clear(),this.rr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let e=(this.name!==""?this.name:"")+" Model";if(t>0){e+=`
|
|
15
|
+
`+n.toString(t-1)}}return e}get layout(){return this.li}set layout(t){t!==null&&(this.li=t)}get vertexes(){return this.Po}get edges(){return this.In}createVertex(){return new Ee(this)}createEdge(){return new ei(this)}addParts(t,e,i){if(t===null)return;e===void 0&&(e=!1),m.s(e,"boolean",Re,"addParts:toplevelonly"),i===void 0&&(i=null),i===null&&(i=n=>{if(n instanceof $)return!n.isLinkLabel;if(n instanceof j){let o=n.fromNode;if(o===null||o.isLinkLabel)return!1;let r=n.toNode;return!(r===null||r.isLinkLabel)}return!1});let s=t.iterator;for(;s.next();){let n=s.value;if(n instanceof $&&!(e&&!n.isTopLevel)&&n.canLayout()&&i(n))if(n instanceof ht&&n.layout===null)this.addParts(n.memberParts,!1);else{if(this.findVertex(n)!==null)continue;let o=this.createVertex();o.node=n,this.addVertex(o)}}for(s.reset();s.next();){let n=s.value;if(!(n instanceof j)||e&&!n.isTopLevel||!n.canLayout()||!i(n)||this.findEdge(n)!==null)continue;let o=n.fromNode,r=n.toNode;if(o===null||r===null||o===r)continue;let a=this.findGroupVertex(o),h=this.findGroupVertex(r);this.linkVertexes(a,h,n)}}findGroupVertex(t){let e=t.findVisibleNode();if(e===null)return null;let i=this.findVertex(e);if(i!==null)return i;let s=e.containingGroup;for(;s!==null;){if(i=this.findVertex(s),i!==null)return i;s=s.containingGroup}return null}addVertex(t){this.Po.add(t);let e=t.node;e!==null&&this.Zy.set(e,t),t.network=this}addNode(t){let e=this.findVertex(t);return e===null&&(e=this.createVertex(),e.node=t,this.addVertex(e)),e}deleteVertex(t){if(this.kv(t)){let e=t.sr;for(let i=e.count-1;i>=0;i--){let s=e.elt(i);this.deleteEdge(s)}e=t.nr;for(let i=e.count-1;i>=0;i--){let s=e.elt(i);this.deleteEdge(s)}}}kv(t){let e=this.Po.delete(t);if(e){let i=t.node;i!==null&&this.Zy.delete(i)}return e}deleteNode(t){let e=this.findVertex(t);e!==null&&this.deleteVertex(e)}findVertex(t){return this.Zy.get(t)}addEdge(t){this.UN(t);let e=t.toVertex;e!==null&&e.addSourceEdge(t);let i=t.fromVertex;i!==null&&i.addDestinationEdge(t)}UN(t){this.In.add(t);let e=t.link;e!==null&&this.findEdge(e)===null&&this.Qy.set(e,t),t.network=this}addLink(t){let e=t.fromNode,i=t.toNode,s=this.findEdge(t);return s===null?(s=this.createEdge(),s.link=t,e!==null&&(s.fromVertex=this.addNode(e)),i!==null&&(s.toVertex=this.addNode(i)),this.addEdge(s)):(e!==null?s.fromVertex=this.addNode(e):s.fromVertex=null,i!==null?s.toVertex=this.addNode(i):s.toVertex=null),s}deleteEdge(t){let e=t.toVertex;e!==null&&e.deleteSourceEdge(t);let i=t.fromVertex;i!==null&&i.deleteDestinationEdge(t),this.VN(t)}VN(t){let e=this.In.delete(t);if(e){let i=t.link;i!==null&&this.Qy.delete(i)}return e}deleteLink(t){let e=this.findEdge(t);e!==null&&this.deleteEdge(e)}findEdge(t){return this.Qy.get(t)}linkVertexes(t,e,i){if(t===null||e===null)return null;if(t.network===this&&e.network===this){let s=this.createEdge();return s.link=i,s.fromVertex=t,s.toVertex=e,this.addEdge(s),s}return null}reverseEdge(t){let e=t.fromVertex,i=t.toVertex;e===null||i===null||(e.deleteDestinationEdge(t),i.deleteSourceEdge(t),t.reverseEdge(),e.addSourceEdge(t),i.addDestinationEdge(t))}deleteSelfEdges(){let t=m.st(),e=this.In.iterator;for(;e.next();){let s=e.value;s.fromVertex===s.toVertex&&t.push(s)}let i=t.length;for(let s=0;s<i;s++)this.deleteEdge(t[s]);m.Z(t)}deleteArtificialVertexes(){let t=m.st(),e=this.Po.iterator;for(;e.next();){let o=e.value;o.node===null&&o.data===null&&t.push(o)}let i=t.length;for(let o=0;o<i;o++)this.deleteVertex(t[o]);let s=m.st(),n=this.In.iterator;for(;n.next();){let o=n.value;o.link===null&&o.data===null&&s.push(o)}i=s.length;for(let o=0;o<i;o++)this.deleteEdge(s[o]);m.Z(t),m.Z(s)}deleteUselessEdges(){let t=m.st(),e=this.In.iterator;for(;e.next();){let s=e.value;(s.fromVertex===null||s.toVertex===null)&&t.push(s)}let i=t.length;for(let s=0;s<i;s++)this.deleteEdge(t[s]);m.Z(t)}isSingleton(t){return!(t.sr.count>0||t.nr.count>0)}splitIntoSubNetworks(t){t===void 0&&(t=!0),t&&(this.deleteArtificialVertexes(),this.deleteUselessEdges(),this.deleteSelfEdges());let e=new q,i=!0;for(;i;){i=!1;let s=this.Po.iterator;for(;s.next();){let n=s.value;if(this.isSingleton(n))continue;let o=this.layout.createNetwork();e.add(o),this._E(o,n),i=!0;break}}return e.sort((s,n)=>s===null||n===null||s===n?0:n.vertexes.count-s.vertexes.count),e}_E(t,e){if(e===null)return;let i=new q;for(i.add(e);i.count>0;){let s=i.first();if(i.removeAt(0),!s||s.network===t)continue;this.kv(s),t.addVertex(s);let n=s.sourceEdges;for(;n.next();){let o=n.value;o.network!==t&&(this.VN(o),t.UN(o),o.fromVertex&&i.add(o.fromVertex))}for(n=s.destinationEdges;n.next();){let o=n.value;o.network!==t&&(this.VN(o),t.UN(o),o.toVertex&&i.add(o.toVertex))}}}findAllParts(){let t=new V,e=this.Po.iterator;for(;e.next();){let s=e.value;s.node&&t.add(s.node)}let i=this.In.iterator;for(;i.next();){let s=i.value;s.link&&t.add(s.link)}return t}}class Ee{ko;te;Ri;Bi;es;sr;nr;constructor(t){V.Je(this),this.ko=t,this.Bi=new I(0,0,10,10),this.es=new P(5,5),this.te=null,this.Ri=null,this.sr=new q,this.nr=new q}clear(){this.te=null,this.Ri=null,this.sr=new q,this.nr=new q}toString(t){t===void 0&&(t=0);let e="LayoutVertex#"+V.xs(this);if(t>0&&(e+=this.node!==null?"("+this.node.toString()+")":"",t>1)){let i="",s=!0,n=this.sr.iterator;for(;n.next();){let r=n.value;s?s=!1:i+=",",i+=r.toString(0)}let o="";for(s=!0,n=this.nr.iterator;n.next();){let r=n.value;s?s=!1:o+=",",o+=r.toString(0)}e+=" sources: "+i+" destinations: "+o}return e}get So(){return this.sr.AL}get or(){return this.nr.AL}get data(){return this.te}set data(t){if(this.te=t,t!==null&&t.bounds){let e=t.bounds,i=e.x,s=e.y,n=e.width,o=e.height;this.es.e(n/2,o/2),this.Bi.e(i,s,n,o)}}get node(){return this.Ri}set node(t){if(this.Ri!==t){if(this.Ri=t,t===null)return;t.ensureBounds();let e=this.network.layout,i=I.l(),s=e.getLayoutBounds(t,i),n=s.x,o=s.y,r=s.width,a=s.height;if(isNaN(n)&&(n=0),isNaN(o)&&(o=0),this.Bi.e(n,o,r,a),I.i(i),!(t instanceof ht)){let h=t.locationObject.getDocumentPoint(T.Center);if(h.isReal()){this.es.e(h.x-n,h.y-o);return}}this.es.e(r/2,a/2)}}get bounds(){return this.Bi}set bounds(t){this.Bi.equals(t)||this.Bi.h(t)}get focus(){return this.es}set focus(t){this.es.equals(t)||this.es.h(t)}get centerX(){return this.Bi.x+this.es.x}set centerX(t){let e=this.Bi;e.x+this.es.x!==t&&(e.x=t-this.es.x)}get centerY(){return this.Bi.y+this.es.y}set centerY(t){let e=this.Bi;e.y+this.es.y!==t&&(e.y=t-this.es.y)}get focusX(){return this.es.x}set focusX(t){let e=this.es;e.x!==t&&(e.x=t)}get focusY(){return this.es.y}set focusY(t){let e=this.es;e.y!==t&&(e.y=t)}get x(){return this.Bi.x}set x(t){let e=this.Bi;e.x!==t&&(e.x=t)}get y(){return this.Bi.y}set y(t){let e=this.Bi;e.y!==t&&(e.y=t)}get width(){return this.Bi.width}set width(t){let e=this.Bi;e.width!==t&&(e.width=t)}get height(){return this.Bi.height}set height(t){let e=this.Bi;e.height!==t&&(e.height=t)}commit(){let t=this.te;if(t!==null){let i=this.bounds,s=t.bounds;m.$(s)?(s.x=i.x,s.y=i.y,s.width=i.width,s.height=i.height):t.bounds=i.copy();return}let e=this.node;if(e!==null){let i=this.bounds;if(!(e instanceof ht)){let s=I.l();e.ensureBounds();let n=this.network.layout.getLayoutBounds(e,s),o=e.locationObject.getDocumentPoint(T.Center);if(n.isReal()&&o.isReal()){e.moveTo(i.x+this.focusX-(o.x-n.x)+e.margin.left,i.y+this.focusY-(o.y-n.y+e.margin.top)),I.i(s);return}I.i(s)}e.moveTo(i.x+e.margin.left,i.y+e.margin.top)}}addSourceEdge(t){t!==null&&(this.sr.has(t)||this.sr.add(t))}deleteSourceEdge(t){t!==null&&this.sr.delete(t)}addDestinationEdge(t){t!==null&&(this.nr.has(t)||this.nr.add(t))}deleteDestinationEdge(t){t!==null&&this.nr.delete(t)}get network(){return this.ko}set network(t){this.ko=t}get sourceVertexes(){let t=new V,e=this.sourceEdges;for(;e.next();){let i=e.value;i.fromVertex&&t.add(i.fromVertex)}return t.iterator}get destinationVertexes(){let t=new V,e=this.destinationEdges;for(;e.next();){let i=e.value;i.toVertex&&t.add(i.toVertex)}return t.iterator}get vertexes(){let t=new V,e=this.sourceEdges;for(;e.next();){let i=e.value;i.fromVertex&&t.add(i.fromVertex)}for(e=this.destinationEdges;e.next();){let i=e.value;i.toVertex&&t.add(i.toVertex)}return t.iterator}get sourceEdges(){return this.sr.iterator}get destinationEdges(){return this.nr.iterator}get edges(){let t=new q,e=this.sourceEdges;for(;e.next();){let i=e.value;t.add(i)}for(e=this.destinationEdges;e.next();){let i=e.value;t.add(i)}return t.iterator}get edgesCount(){return this.sr.count+this.nr.count}static standardComparer(t,e){let i=t.Ri,s=e.Ri;if(i)if(s){let n=i.text,o=s.text;return n<o?-1:n>o?1:0}else return 1;else return s!==null?-1:0}static smartComparer(t,e){if(t!==null)if(e!==null){let i=t.Ri,s=e.Ri;if(i!==null)if(s!==null){let n=i.text.toLocaleLowerCase(),o=s.text.toLocaleLowerCase(),r=n.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),a=o.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),h=0;for(;h<r.length;h++)if(a[h]!==""&&a[h]!==void 0){let l=parseFloat(r[h]),u=parseFloat(a[h]);if(isNaN(l))if(isNaN(u)){if(r[h].localeCompare(a[h])!==0)return r[h].localeCompare(a[h]);continue}else return 1;else{if(isNaN(u))return-1;if(l-u!==0)return l-u;continue}}else{if(r[h]==="")continue;return 1}return a[h]!==""&&a[h]!==void 0?-1:0}else return 1;else return s!==null?-1:0}else return 1;else return e!==null?-1:0}}class ei{ko;te;ts;is;ss;constructor(t){V.Je(this),this.ko=t,this.te=null,this.ts=null,this.is=null,this.ss=null}clear(){this.te=null,this.ts=null,this.is=null,this.ss=null}toString(t){t===void 0&&(t=0);let e="LayoutEdge#"+V.xs(this);return t>0&&(e+=this.ts!==null?"("+this.ts.toString()+")":"",t>1&&(e+=" "+(this.is?this.is.toString():"null")+" --> "+(this.ss?this.ss.toString():"null"))),e}reverseEdge(){let t=this.is;this.is=this.ss,this.ss=t}commit(){}getOtherVertex(t){return this.ss===t?this.is:this.is===t?this.ss:null}get network(){return this.ko}set network(t){this.ko=t}get data(){return this.te}set data(t){this.te!==t&&(this.te=t)}get link(){return this.ts}set link(t){this.ts!==t&&(this.ts=t)}get fromVertex(){return this.is}set fromVertex(t){this.is!==t&&(this.is=t)}get toVertex(){return this.ss}set toVertex(t){this.ss!==t&&(this.ss=t)}}var Zi=(x=>(x[x.Position=0]="Position",x[x.Location=1]="Location",x))(Zi||{}),Qi=(x=>(x[x.LeftToRight=10]="LeftToRight",x[x.RightToLeft=11]="RightToLeft",x))(Qi||{}),_i=(x=>(x[x.Forwards=20]="Forwards",x[x.Reverse=21]="Reverse",x[x.Ascending=22]="Ascending",x[x.Descending=23]="Descending",x))(_i||{});class Ye extends ee{mg;pg;Ro;En;de;He;Si;Mi;constructor(t){super(),this.isViewportSized=!0,this.mg=NaN,this.pg=NaN,this.Ro=new nt(NaN,NaN).k(),this.En=new nt(10,10).k(),this.de=1,this.He=10,this.Si=22,this.Mi=Ye.standardComparer,t&&Object.assign(this,t)}cloneProtected(t){super.cloneProtected(t),t.mg=this.mg,t.pg=this.pg,t.Ro.h(this.Ro),t.En.h(this.En),t.de=this.de,t.He=this.He,t.Si=this.Si,t.Mi=this.Mi}fe(t){t in _i?this.sorting=t:t in Qi?this.arrangement=t:t in Zi?this.alignment=t:super.fe(t)}doLayout(t){this.arrangementOrigin=this.initialOrigin(this.arrangementOrigin);let e=this.collectParts(t),i=this.diagram,s=e.copy().iterator;for(;s.next();){let f=s.value;if(f.Lr()&&(f.fromNode!==null||f.toNode!==null)){e.delete(f);continue}if(f.ensureBounds(),f instanceof ht){let p=f.memberParts;for(;p.next();){let g=p.value;e.delete(g)}}}let n=e.toArray();if(n.length===0)return;switch(this.sorting){case 20:break;case 21:n.reverse();break;case 22:n.sort(this.comparer);break;case 23:n.sort(this.comparer),n.reverse();break}let o=this.wrappingColumn;isNaN(o)&&(o=0);let r=this.wrappingWidth;if(isNaN(r)&&i!==null){let f=i.viewportBounds,p=i.padding;r=Math.max(f.width-p.left-p.right,0)}else r=Math.max(this.wrappingWidth,0);o<=0&&r<=0&&(o=1);let a=this.spacing.width;isFinite(a)||(a=0);let h=this.spacing.height;isFinite(h)||(h=0),i!==null&&i.startTransaction("Layout");let l=[];switch(this.alignment){case 0:this.t3(n,r,o,a,h,l);break;case 1:this.e3(n,r,o,a,h,l);break}let u=0,c=0,d=0;for(let f=0;f<l.length;f++){let p=l[f];u=Math.min(u,p.x),c=Math.min(c,p.y),d=Math.max(d,p.x+p.width)}this.arrangement===11?this.commitLayers(l,new P(u+a/2-(d+u),c-h/2)):this.commitLayers(l,new P(u-a/2,c-h/2)),i!==null&&i.commitTransaction("Layout"),this.isValidLayout=!0}t3(t,e,i,s,n,o){let r=I.l(),a=Math.max(this.cellSize.width,1);if(!isFinite(a)){a=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r);a=Math.max(a,v.width)}}a+=s,a=Math.max(a,1);let h=Math.max(this.cellSize.height,1);if(!isFinite(h)){h=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r);h=Math.max(h,v.height)}}h+=n,h=Math.max(h,1);let l=this.arrangement,u=this.arrangementOrigin.x,c=this.arrangementOrigin.y,d=u,f=c,p=0,g=0;for(let y=0;y<t.length;y++){let b=t[y],v=this.getLayoutBounds(b,r),w=Math.ceil((v.width+s)/a),k=Math.ceil((v.height+n)/h),S=w*a,N=k*h,D=0;switch(l){case 11:D=Math.abs(d-v.width);break;default:D=d+v.width;break}(i>0&&p>i-1||e>0&&p>0&&D-u>e)&&(o.push(new I(0,f,e+s,g)),p=0,d=u,f+=g,g=0),g=Math.max(g,N);let L=0;switch(l){case 11:L=-v.width;break;default:L=0;break}switch(b.moveTo(d+L+b.margin.left,f+b.margin.top),l){case 11:d-=S;break;default:d+=S;break}p++}o.push(new I(0,f,e+s,g)),I.i(r)}e3(t,e,i,s,n,o){let r=I.l(),a=Math.max(this.cellSize.width,1),h=0,l=0,u=0,c=P.l();for(let L=0;L<t.length;L++){let M=t[L],A=this.getLayoutBounds(M,r),F=M.getRelativePoint(M.locationObject,M.locationSpot,c);h=Math.max(h,F.x),l=Math.max(l,A.width-F.x),u=Math.max(u,F.y)}let d=this.arrangement;switch(d){case 11:h+=s;break;default:l+=s;break}isFinite(a)?a=Math.max(a+s,1):a=Math.max(h+l,1);let f=this.arrangementOrigin.x,p=this.arrangementOrigin.y,g=f,y=p,b=0;e>=h&&(e-=h);let v=0,w=0,k=Math.max(this.cellSize.height,1);u=0;let S=0,N=!0,D=P.l();for(let L=0;L<t.length;L++){let M=t[L],A=this.getLayoutBounds(M,r),F=M.getRelativePoint(M.locationObject,M.locationSpot,c);if(b>0)switch(d){case 11:{let E=(g-f-(A.width-F.x))/a;C.X(Math.round(E),E)?E=Math.round(E):E=Math.floor(E),g=E*a+f;break}default:{let E=(g-f+F.x)/a;C.X(Math.round(E),E)?E=Math.round(E):E=Math.ceil(E),g=E*a+f;break}}else switch(d){case 11:v=g+F.x+A.width;break;default:v=g-F.x;break}let O=0;switch(d){case 11:O=-(g+F.x)+v;break;default:O=g+A.width-F.x-v;break}if(i>0&&b>i-1||e>0&&b>0&&O>e){o.push(new I(0,N?y-u:y,e+s,S+u+n));for(let E=0;E<b&&L!==b;E++){let B=t[L-b+E],X=B.getRelativePoint(B.locationObject,B.locationSpot,D);B.moveTo(B.position.x,B.position.y+u-X.y)}S+=n,N?y+=S:y+=S+u,u=0,S=0,b=0,g=f,N=!1}switch(g===f&&(d===11?w=Math.max(w,A.width-F.x):w=Math.min(w,-F.x)),u=Math.max(u,F.y),S=Math.max(S,A.height-F.y),isFinite(k)&&(S=Math.max(S,Math.max(A.height,k)-F.y)),N?M.moveTo(g-F.x,y-F.y):M.moveTo(g-F.x,y),d){case 11:g-=F.x+s;break;default:g+=A.width-F.x+s;break}b++}if(o.push(new I(0,y,e+s,(N?S:S+u)+n)),t.length!==b)for(let L=0;L<b;L++){let M=t[t.length-b+L],A=M.getRelativePoint(M.locationObject,M.locationSpot,c);M.moveTo(M.position.x,M.position.y+u-A.y)}if(P.i(c),P.i(D),d===11)for(let L=0;L<o.length;L++){let M=o[L];M.width+=w,M.x-=w}else for(let L=0;L<o.length;L++){let M=o[L];M.x>w&&(M.width+=M.x-w,M.x=w)}I.i(r)}commitLayers(t,e){}get wrappingWidth(){return this.mg}set wrappingWidth(t){this.mg!==t&&(m.s(t,"number",Ye,"wrappingWidth"),(t>0||isNaN(t))&&(this.mg=t,this.isViewportSized=isNaN(t),this.p()))}get wrappingColumn(){return this.pg}set wrappingColumn(t){this.pg!==t&&(m.s(t,"number",Ye,"wrappingColumn"),(t>0||isNaN(t))&&(this.pg=t,this.p()))}get cellSize(){return this.Ro}set cellSize(t){this.Ro.equals(t)||(this.Ro.h(t),this.p())}get spacing(){return this.En}set spacing(t){this.En.equals(t)||(this.En.h(t),this.p())}get alignment(){return this.de}set alignment(t){this.de!==t&&(t===1||t===0)&&(this.de=t,this.p())}get arrangement(){return this.He}set arrangement(t){this.He!==t&&(t===10||t===11)&&(this.He=t,this.p())}get sorting(){return this.Si}set sorting(t){this.Si!==t&&(t===20||t===21||t===22||t===23)&&(this.Si=t,this.p())}get comparer(){return this.Mi}set comparer(t){this.Mi!==t&&(m.S(t,Ye,"comparer"),this.Mi=t,this.p())}static standardComparer(t,e){let i=t.text,s=e.text;return i<s?-1:i>s?1:0}static smartComparer(t,e){if(t!==null)if(e!==null){let i=t.text.toLocaleLowerCase(),s=e.text.toLocaleLowerCase(),n=i.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),o=s.split(/([+-]?[.]?\d+(?:\.\d*)?(?:e[+-]?\d+)?)/),r=0;for(;r<n.length;r++)if(o[r]!==""&&o[r]!==void 0){let a=parseFloat(n[r]),h=parseFloat(o[r]);if(isNaN(a))if(isNaN(h)){if(n[r].localeCompare(o[r])!==0)return n[r].localeCompare(o[r]);continue}else return 1;else{if(isNaN(h))return-1;if(a-h!==0)return a-h;continue}}else{if(n[r]==="")continue;return 1}return o[r]!==""&&o[r]!==void 0?-1:0}else return 1;else return e!==null?-1:0}static Position=0;static Location=1;static LeftToRight=10;static RightToLeft=11;static Forward=20;static Reverse=21;static Ascending=22;static Descending=23}class me{yg;rn;Ct;Mo;wg;xg;a;BN;constructor(){this.yg=new V,this.rn=new V,this.Ct=new V,this.Mo=new Mt,this.wg=new Mt,this.xg=new Mt,this.a=null,this.BN=!1}clear(){this.yg.clear(),this.rn.clear(),this.Ct.clear(),this.Mo.clear(),this.wg.clear(),this.xg.clear()}Io(t){this.a=t}hh(t){if(t instanceof $){if(this.yg.add(t),t instanceof ht){let i=t.containingGroup;i===null?this.diagram.$r.add(t):i.Ch.add(t);let s=t.layout;s!==null&&(s.diagram=this.diagram)}}else t instanceof j?(this.rn.add(t),t.isAvoiding&&(this.diagram.sp=!0)):t instanceof vt||this.Ct.add(t);let e=t.data;e!==null&&(t instanceof vt||(t instanceof j?this.Pv(e,t):this.Mo.set(e,t)))}ri(t){if(t.clearAdornments(),t instanceof $){if(this.yg.delete(t),t instanceof ht){let i=t.containingGroup;i===null?this.diagram.$r.delete(t):i.Ch.delete(t);let s=t.layout;s!==null&&(s.diagram=null)}}else t instanceof j?this.rn.delete(t):t instanceof vt||this.Ct.delete(t);let e=t.data;e!==null&&(t instanceof vt||(t instanceof j?this.Sv(e,t):this.Mo.delete(e)))}Pv(t,e){this.wg.set(t,e)}Sv(t,e){this.wg.delete(t)}rebuildParts(){let t=this.diagram;if(t===null)return;let e=t.nodeTemplateMap.iterator;for(;e.next();){let d=e.value,f=e.key;(!d.Di()||d instanceof ht)&&m.o(`Invalid node template in Diagram.nodeTemplateMap: template for "${f}" must be a Node or a simple Part, not a Group or Link: ${d}`)}let i=t.groupTemplateMap.iterator;for(;i.next();){let d=i.value,f=i.key;d instanceof ht||m.o(`Invalid group template in Diagram.groupTemplateMap: template for "${f}" must be a Group, not a normal Node or Link: ${d}`)}let s=t.linkTemplateMap.iterator;for(;s.next();){let d=s.value,f=s.key;d instanceof j||m.o(`Invalid link template in Diagram.linkTemplateMap: template for "${f}" must be a Link, not a normal Node or simple Part: ${d}`)}let n=m.st(),o=t.selection.iterator;for(;o.next();){let d=o.value.data;d&&n.push(d)}let r=m.st(),a=t.highlighteds.iterator;for(;a.next();){let d=a.value.data;d&&r.push(d)}let h=m.st(),l=this.nodes.iterator;for(;l.next();){let d=l.value;d.data!==null&&(h.push(d.data),h.push(d.location))}let u=this.links.iterator;for(;u.next();){let d=u.value;d.data!==null&&(h.push(d.data),h.push(d.location))}let c=this.parts.iterator;for(;c.next();){let d=c.value;d.data!==null&&(h.push(d.data),h.push(d.location))}this.Mv(),this.T2();for(let d=0;d<n.length;d++){let f=this.findPartForData(n[d]);f!==null&&(f.isSelected=!0)}for(let d=0;d<r.length;d++){let f=this.findPartForData(r[d]);f!==null&&(f.isHighlighted=!0)}for(let d=0;d<h.length;d+=2){let f=this.findPartForData(h[d]);f!==null&&(f.location=h[d+1])}m.Z(n),m.Z(r),m.Z(h)}T2(){let t=this.diagram.model;this._y(t.nodeDataArray)}_y(t,e){let i=this.diagram.model;t.forEach(s=>{i.containsNodeData(s)&&this.Cv(s,!1)}),t.forEach(s=>{i.containsNodeData(s)&&this.kk(s)}),e!==!1&&this.diagram.o1(!1)}Cv(t,e){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;e===void 0&&(e=!0);let i=this.i3(t);return i!==null&&e&&this.kk(t),i}i3(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.Mo.has(t))return null;let e=this.s3(t),i=this.findTemplateForNodeData(t,e);if(i!==null){i.It();let s=i.copy();if(s!==null){let n=this.diagram.wi;return this.diagram.wi=!0,s.Qo=e,s.te=t,this.addsToTemporaryLayer&&(s.dl="Tool"),this.diagram.add(s),s.te=null,s.data=t,this.diagram.wi=n,s}}return null}insertLink(t,e,i,s){return null}kk(t){}s3(t){return this.diagram.model.getCategoryForNodeData(t)}static Nv=!1;static Lv=!1;findTemplateForNodeData(t,e){let i=this.diagram,s=i.model,n=s.Ah()&&s.isGroupForData(t),o=null;return n?(o=i.groupTemplateMap.get(e),o===null&&(o=i.groupTemplateMap.get(""),o===null&&(me.Lv||(me.Lv=!0,m.ne('No Group template found for category "'+e+'"'),m.ne(" Using default group template")),o=i.e2))):(o=i.nodeTemplateMap.get(e),o===null&&(o=i.nodeTemplateMap.get(""),o===null&&(me.Nv||(me.Nv=!0,m.ne('No Node template found for category "'+e+'"'),m.ne(" Using default node template")),o=i.QM))),o}getLinkCategoryForData(t){return""}setLinkCategoryForData(t,e){}setFromNodeForLink(t,e,i){}setToNodeForLink(t,e,i){}static Av=!1;findLinkTemplateForCategory(t){let e=this.diagram,i=e.linkTemplateMap.get(t);return i===null&&(i=e.linkTemplateMap.get(""),i===null&&(me.Av||(me.Av=!0,m.ne('No Link template found for category "'+t+'"'),m.ne(" Using default link template")),i=e._M)),i}JI(t,e,i){t instanceof j?(e!==null&&this.Sv(e,t),i!==null&&this.Pv(i,t)):t instanceof pt&&(e!==null&&this.Mo.delete(e),i!==null&&this.Mo.set(i,t))}Mv(){let t=this.diagram.model;this.zN(t.nodeDataArray)}zN(t){t.forEach(e=>{this.Pk(e)})}Pk(t){let e=this.findPartForData(t);e!==null&&(this.diagram.N2(e,!1),this.XN(e))}XN(t){}LN(t){}findPartForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.Mo.get(e):null}findNodeForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);if(e===null)return null;let i=this.Mo.get(e);return i instanceof $?i:null}findLinkForKey(t){return null}findPartForData(t){if(t===null)return null;let e=this.Mo.get(t);return e!==null||(e=this.wg.get(t)),e}findNodeForData(t){if(t===null)return null;let e=this.Mo.get(t);return e instanceof $?e:null}findLinkForData(t,e){return t===null?null:this.wg.get(t)}findNodesByExample(...t){let e=new V,i=this.yg.iterator;for(;i.next();){let s=i.value,n=s.data;if(n!==null)for(let o=0;o<arguments.length;o++){let r=arguments[o];if(m.$(r)&&this.GN(n,r)){e.add(s);break}}}return e.iterator}findLinksByExample(...t){let e=new V,i=this.rn.iterator;for(;i.next();){let s=i.value,n=s.data;if(n!==null)for(let o=0;o<arguments.length;o++){let r=arguments[o];if(m.$(r)&&this.GN(n,r)){e.add(s);break}}}return e.iterator}GN(t,e){for(let i in e){let s=t[i],n=e[i];if(Array.isArray(n)){if(!Array.isArray(s))return!1;let o=s,r=n;if(o.length<r.length)return!1;for(let a=0;a<o.length;a++){let h=o[a],l=r[a];if(l!==void 0&&!this.Tv(h,l))return!1}}else if(!this.Tv(s,n))return!1}return!0}Tv(t,e){if(m.it(e)){if(!e(t))return!1}else if(e instanceof RegExp){if(!t||!e.test(t.toString()))return!1}else if(m.$(t)&&m.$(e)){if(!this.GN(t,e))return!1}else if(t!==e)return!1;return!0}doModelDataChanged(t){if(t.model===this.diagram.model&&this.diagram.G){this.diagram.G=!1;try{let e=t.change;t.modelChange===""&&t.object!==null&&e===2&&this.tw(t.object,t.propertyName)}finally{this.diagram.G=!0}}}doModelChanged(t){let e=this.diagram;if(!e||t.model!==e.model)return;let i=t.change;if(e.AO(t),!!e.G){e.G=!1;try{let s=t.modelChange;if(s!=="")if(i===2){if(s==="nodeCategory"){let n=t.object;if(n!==null){let o=this.findPartForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}}else if(s==="nodeDataArray"){let n=t.oldValue;this.zN(n);let o=t.newValue;this._y(o)}e.isModified=!0}else if(i===3){let n=t.newValue;s==="nodeDataArray"&&m.$(n)&&this.Cv(n),e.isModified=!0}else if(i===4){let n=t.oldValue;s==="nodeDataArray"&&m.$(n)&&this.Pk(n),e.isModified=!0}else i===1&&(s==="SourceChanged"?t.object!==null?this.tw(t.object,t.propertyName):(this.updateAllRelationshipsFromData(),this.updateAllTargetBindings()):s==="ModelDisplaced"&&this.rebuildParts());else if(i===2){let n=t.propertyName,o=t.object,r=e.model;o===r?(n==="nodeKeyProperty"||n==="nodeCategoryProperty")&&(e.undoManager.isUndoingRedoing||this.rebuildParts()):o!==null&&this.tw(o,n),e.isModified=!0}else(i===3||i===4)&&(this.o3(t,e.model),e.isModified=!0)}finally{e.G=!0}}}updateAllTargetBindings(t){t===void 0&&(t="");let e=this.parts.iterator;for(;e.next();)e.value.updateTargetBindings(t);for(e=this.nodes.iterator;e.next();)e.value.updateTargetBindings(t);for(e=this.links.iterator;e.next();)e.value.updateTargetBindings(t)}updateAllThemeBindings(){let t=this.parts.iterator;for(;t.next();)t.value.Go();for(t=this.nodes.iterator;t.next();)t.value.Go();for(t=this.links.iterator;t.next();)t.value.Go()}updateAllRelationshipsFromData(){let t=this.diagram.model,e=new V,i=t.nodeDataArray;for(let o=0;o<i.length;o++){let r=i[o];e.add(r)}let s=[];this.nodes.each(o=>{o.data!==null&&!e.has(o.data)&&s.push(o.data)}),this.parts.each(o=>{o.data!==null&&!e.has(o.data)&&s.push(o.data)}),s.forEach(o=>t.Dv(o,!1));for(let o=0;o<i.length;o++){let r=i[o];this.findPartForData(r)===null&&t.vv(r,!1)}this.Fv();let n=this.parts.iterator;for(;n.next();)n.value.updateRelationshipsFromData();for(n=this.nodes.iterator;n.next();)n.value.updateRelationshipsFromData();for(n=this.links.iterator;n.next();)n.value.updateRelationshipsFromData()}Fv(){}updateRelationshipsFromData(t){}tw(t,e){if(typeof e=="string"){let i=this.findPartForData(t);if(i!==null)i.updateTargetBindings(e);else{let s=this.r3(t);if(s!==null&&s.length>0){for(let o=0;o<s.length;o++)s[o].updateTargetBindings(e);let n=s[0].part;if(n!==null){let o=n.adornments;for(;o.next();)o.value.updateTargetBindings(e)}m.Z(s)}}t===this.diagram.model.modelData&&this.updateAllTargetBindings(e)}}r3(t){let e=null,i=this.xg.iterator;for(;i.next();){let s=i.value;for(let n=0;n<s.length;n++){let o=s[n].findItemPanelForData(t);o!==null&&(e===null&&(e=m.st()),e.push(o))}if(e!==null)break}return e}YN(t){return this.xg.get(t)}o3(t,e){let i=t.object;if(!Array.isArray(i))return;let s=t.change===3,n=s?t.newParam:t.oldParam,o=s?t.newValue:t.oldValue,r=this.YN(i);if(Array.isArray(r))for(let a=0;a<r.length;a++){let h=r[a];s?h.W1(o,n,!0):h.QI(n)}}M2(t,e){e!==null&&t.Sn(s=>e.uT(s));let i=t.Aa;if(Array.isArray(i)){let s=this.YN(i);if(s===null)this.xg.set(i,[t]);else{for(let n=0;n<s.length;n++)if(s[n]===t)return;s.push(t)}}}C2(t,e){t.Sn(s=>e.DO(s));let i=t.Aa;if(Array.isArray(i)){let s=this.YN(i);if(s!==null){for(let n=0;n<s.length;n++)if(s[n]===t){s.splice(n,1),s.length===0&&this.xg.delete(i);return}}}}copyParts(t,e,i){i===void 0&&(i=!1);let s=new Mt;if(Array.isArray(t))for(let o=0;o<t.length;o++)this.Sk(t[o],e,s,i);else{let o=t.iterator;for(;o.next();)this.Sk(o.value,e,s,i)}if(e!==null){let o=e.model,r=e.Cp().dragsLink,a=new V,h=new Mt,l=s.iterator;for(;l.next();){let u=l.value;if(u instanceof j)!r&&(u.fromNode===null||u.toNode===null)&&a.add(u);else if(u instanceof $&&u.data!==null){if(o.Mx()){let c=u,d=l.key,f=d.findTreeParentNode();if(f!==null){let p=s.get(f);if(p!==null){o.setParentKeyForNodeData(c.data,o.getKeyForNodeData(p.data));let g=e.findLinkForData(c.data),y=d.findTreeParentLink();y!==null&&g!==null&&h.set(y,g)}}}else if(o.Rv()){let c=u,d=l.key,f=o.isRelatedKeysPathTo?d.findNodesOutOf():d.findNodesInto();for(;f.next();){let p=f.value,g=s.get(p);if(g!==null){o.addRelatedKeyForNodeData(c.data,g.key);let y=e.partManager.findLinkForData(c.data,g.key),b=this.findLinkForData(d.data,p.key);b!==null&&y!==null&&h.set(b,y)}else o.removeRelatedKeyForNodeData(c.data,p.key)}}}}if(a.count>0&&e.removeParts(a,!1),h.count>0){let u=h.iterator;for(;u.next();){let c=u.key,d=u.value;s.set(c,d)}}}if(e!==null&&this.diagram!==null){let o=e.model,r=o.afterCopyFunction;if(r!==null){let a=new Mt;s.each(l=>{l.key.data!==null&&a.set(l.key.data,l.value.data)});let h=this.diagram.model;r(a,o,h)}}let n=s.iterator;for(;n.next();)n.value.updateTargetBindings();return s}Sk(t,e,i,s){if(t===null||s&&!t.canCopy())return null;if(i.has(t))return i.get(t);let n=this.KN(t,e);if(!(n instanceof pt))return null;if(n.isSelected=!1,n.isHighlighted=!1,i.set(t,n),t instanceof $){let o=t.linksConnected;for(;o.next();){let r=o.value;if(r.fromNode===t){let a=i.get(r);a!==null&&(a.fromNode=n)}if(r.toNode===t){let a=i.get(r);a!==null&&(a.toNode=n)}}if(t instanceof ht&&n instanceof ht){let r=t.memberParts;for(;r.next();){let a=r.value,h=this.Sk(a,e,i,s);h instanceof j||h!==null&&(h.containingGroup=n)}}}else if(t instanceof j&&n instanceof j){let o=t.fromNode;if(o!==null){let h=i.get(o);h!==null&&(n.fromNode=h)}let r=t.toNode;if(r!==null){let h=i.get(r);h!==null&&(n.toNode=h)}let a=t.labelNodes;for(;a.next();){let h=a.value,l=this.Sk(h,e,i,s);l!==null&&l instanceof $&&(l.labeledLink=n)}}return n}KN(t,e){let i=null,s=t.data;if(s!==null&&e!==null){let n=e.model;if(!(t instanceof j)){let o=n.copyNodeData(s);n.addNodeData(o),i=e.findPartForData(o)}}else if(t.It(),i=t.copy(),i!==null){let n=this.diagram;if(e!==null)e.add(i);else if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){let o=n.model,r=null;i instanceof j||(r=o.copyNodeData(s)),i.data=r}}return i}get nodes(){return this.yg}get links(){return this.rn}get parts(){return this.Ct}get diagram(){return this.a}get addsToTemporaryLayer(){return this.BN}set addsToTemporaryLayer(t){this.BN=t}}class Zn extends me{T2(){let t=this.diagram.model;this._y(t.nodeDataArray),this.Ov(t.linkDataArray)}_y(t){super._y(t,!1);let e=this.links.iterator;for(;e.next();)e.value.Jd();this.diagram.o1(!1)}Ov(t){t.forEach(e=>{this.Iv(e)}),this.diagram.o1(!1)}Iv(t){if(t==null||this.diagram.undoManager.isUndoingRedoing||this.findLinkForData(t))return null;let e=this.getLinkCategoryForData(t),i=this.findLinkTemplateForCategory(e);if(i!==null){i.It();let s=i.copy();if(s!==null){let n=this.diagram.wi;this.diagram.wi=!0,s.Qo=e,s.te=t;let o=this.diagram.model,r=o.Mk(t,!0);r!==""&&(s.fromPortId=r);let a=o.zi(t,!0);if(a!==void 0){let c=this.findNodeForKey(a);c instanceof $&&(s.fromNode=c)}let h=o.Mk(t,!1);h!==""&&(s.toPortId=h);let l=o.zi(t,!1);if(l!==void 0){let c=this.findNodeForKey(l);c instanceof $&&(s.toNode=c)}let u=o.getLabelKeysForLinkData(t);return Array.isArray(u)&&u.forEach(c=>{let d=this.findNodeForKey(c);d!==null&&(d.labeledLink=s)}),this.addsToTemporaryLayer&&(s.dl="Tool"),this.diagram.add(s),s.te=null,s.data=t,this.diagram.wi=n,s}}return null}Mv(){let t=this.diagram.model;this.Ev(t.linkDataArray),this.zN(t.nodeDataArray)}Ev(t){t.forEach(e=>{this.Pk(e)})}getLinkCategoryForData(t){return this.diagram.model.getCategoryForLinkData(t)}setLinkCategoryForData(t,e){return this.diagram.model.setCategoryForLinkData(t,e)}setFromNodeForLink(t,e,i){let s=this.diagram.model,n=e!==null?e.data:null;s.setFromKeyForLinkData(t.data,s.getKeyForNodeData(n))}setToNodeForLink(t,e,i){let s=this.diagram.model,n=e!==null?e.data:null;s.setToKeyForLinkData(t.data,s.getKeyForNodeData(n))}LN(t){this.diagram.model.removeLinkData(t.data)}findPartForKey(t){let e=super.findPartForKey(t);if(e===null){let i=this.diagram.model.findLinkDataForKey(t);if(i!==null)return this.findLinkForData(i)}return e}findLinkForKey(t){if(t==null)return null;let e=this.diagram.model.findLinkDataForKey(t);return e!==null?this.findLinkForData(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;let e=this.diagram;if(t.model!==e.model)return;let i=t.change;if(e.G){e.G=!1;try{let s=t.modelChange;if(s!==""){if(i===2){if(s==="linkFromKey"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue,a=this.findNodeForKey(r);o.fromNode=a}}else if(s==="linkToKey"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue,a=this.findNodeForKey(r);o.toNode=a}}else if(s==="linkFromPortId"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue;typeof r=="string"&&(o.fromPortId=r)}}else if(s==="linkToPortId"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.newValue;typeof r=="string"&&(o.toPortId=r)}}else if(s==="nodeGroupKey"){let n=t.object,o=this.findPartForData(n);if(o!==null){let r=t.newValue;if(r!==void 0){let a=this.findNodeForKey(r);a instanceof ht?o.containingGroup=a:o.containingGroup=null}else o.containingGroup=null}}else if(s==="linkLabelKeys"){let n=t.object,o=this.findLinkForData(n);if(o!==null){let r=t.oldValue,a=t.newValue;Array.isArray(r)&&r.forEach(h=>{if(a.indexOf(h)>=0)return;let l=this.findNodeForKey(h);l!==null&&(l.labeledLink=null)}),Array.isArray(a)&&a.forEach(h=>{let l=this.findNodeForKey(h);l!==null&&(l.labeledLink=o)})}}else if(s==="linkCategory"){let n=t.object,o=this.findLinkForData(n),r=t.newValue;o!==null&&typeof r=="string"&&(o.category=r)}else if(s==="linkDataArray"){let n=t.oldValue;this.Ev(n);let o=t.newValue;this.Ov(o)}e.isModified=!0}else if(i===3){let n=t.newValue;if(s==="linkDataArray"&&m.$(n))this.Iv(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){let o=t.object,r=this.findLinkForData(o),a=this.findNodeForKey(n);r!==null&&a!==null&&(a.labeledLink=r)}e.isModified=!0}else if(i===4){let n=t.oldValue;if(s==="linkDataArray"&&m.$(n))this.Pk(n);else if(s==="linkLabelKeys"&&t.model.isKeyType(n)){let o=this.findNodeForKey(n);o!==null&&(o.labeledLink=null)}e.isModified=!0}}else if(i===2){let n=t.propertyName,o=t.object,r=e.model;o===r&&(n==="linkFromKeyProperty"||n==="linkToKeyProperty"||n==="linkFromPortIdProperty"||n==="linkToPortIdProperty"||n==="linkLabelKeysProperty"||n==="nodeIsGroupProperty"||n==="nodeGroupKeyProperty"||n==="linkCategoryProperty")&&(e.undoManager.isUndoingRedoing||this.rebuildParts()),e.isModified=!0}}finally{e.G=!0}}}Fv(){let t=this.diagram.model,e=new Set,i=t.linkDataArray;i.forEach(n=>{e.add(n)});let s=[];this.links.each(n=>{n.data!==null&&!e.has(n.data)&&s.push(n.data)}),s.forEach(n=>{t.Uv(n,!1)}),i.forEach(n=>{this.findLinkForData(n)===null&&t.Vv(n,!1)})}updateRelationshipsFromData(t){let e=t.data;if(e===null)return;let i=t.diagram;if(i===null)return;let s=i.model;if(t instanceof j){let n=s.zi(e,!0),o=i.findNodeForKey(n);t.fromNode=o,n=s.zi(e,!1),o=i.findNodeForKey(n),t.toNode=o;let r=s.getLabelKeysForLinkData(e);if(r.length>0||t.labelNodes.count>0){if(r.length===1&&t.labelNodes.count===1){let c=r[0],d=t.labelNodes.first();if(d!==null&&s.getKeyForNodeData(d.data)===c)return}let a=new V().addAll(r),h=new V;t.labelNodes.each(c=>{if(c.data!==null){let d=s.getKeyForNodeData(c.data);d!==void 0&&h.add(d)}});let l=h.copy();l.removeAll(a);let u=a.copy();if(u.removeAll(h),l.count>0||u.count>0){let c=t;l.each(d=>{let f=i.findNodeForKey(d);f!==null&&f.labeledLink===c&&(f.labeledLink=null)}),u.each(d=>{let f=i.findNodeForKey(d);f!==null&&f.labeledLink!==c&&(f.labeledLink=c)})}}}else if(!(t instanceof vt)){let n=s.getGroupKeyForNodeData(e),o=i.findPartForKey(n);(o===null||o instanceof ht)&&(t.containingGroup=o)}}kk(t){let e=this.diagram.model,i=e.getKeyForNodeData(t);if(i!==void 0){let s=e.ew(i),n=this.findPartForData(t);if(s!==null&&n!==null){let r=s.iterator;for(;r.next();){let a=r.value;if(e.containsNodeData(a)){if(n instanceof ht&&e.getGroupKeyForNodeData(a)===i){let h=this.findPartForData(a);h!==null&&(h.containingGroup=n)}}else{let h=this.findLinkForData(a);if(h!==null&&n instanceof $){e.zi(a,!0)===i&&(h.fromNode=n),e.zi(a,!1)===i&&(h.toNode=n);let l=e.getLabelKeysForLinkData(a);Array.isArray(l)&&l.some(u=>u===i?(n.labeledLink=h,!0):!1)}}}e.an(i)}let o=e.getGroupKeyForNodeData(t);if(o!==void 0){let r=this.findNodeForKey(o);n!==null&&r instanceof ht&&(n.containingGroup=r)}}}XN(t){let e=this.diagram.model;if(t instanceof $){let i=e.getKeyForNodeData(t.data);if(i!==void 0){let s=t.linksConnected;for(;s.next();){let n=s.value;e.hn(i,n.data)}if(t.isLinkLabel){let n=t.labeledLink;n!==null&&e.hn(i,n.data)}if(t instanceof ht){let n=t.memberParts;for(;n.next();){let o=n.value.data;e.containsNodeData(o)&&e.hn(i,o)}}}}}KN(t,e){let i=super.KN(t,e);if(t instanceof j){let s=t.data;if(s!==null&&e!==null){let n=e.model,o=n.copyLinkData(s);n.addLinkData(o),i=e.findLinkForData(o)}else if(i!==null){let n=this.diagram;if(s!==null&&n!==null&&n.commandHandler!==null&&n.commandHandler.copiesClipboardData){let o=n.model.copyLinkData(s);i.data=o}}}return i}insertLink(t,e,i,s){let n=this.diagram,o=n.model,r=n.toolManager.findTool("Linking"),a="";t!==null&&(e===null&&(e=t),a=e.portId,a===null&&(a=""));let h="";i!==null&&(s===null&&(s=i),h=s.portId,h===null&&(h=""));let l=r.archetypeLinkData;if(l instanceof j){l.It();let u=l.copy();if(u!==null){u.fromNode=t,u.fromPortId=a,u.toNode=i,u.toPortId=h,n.add(u);let c=r.archetypeLabelNodeData;if(c instanceof $){c.It();let d=c.copy();d!==null&&(d.labeledLink=u,n.add(d))}return u}}else if(l!==null){let u=o.copyLinkData(l);if(m.$(u)){t!==null&&o.bg(u,o.getKeyForNodeData(t.data),!0),o.kg(u,a,!0),i!==null&&o.bg(u,o.getKeyForNodeData(i.data),!1),o.kg(u,h,!1),o.addLinkData(u);let c=r.archetypeLabelNodeData;if(c!==null&&!(c instanceof $)){let d=o.copyNodeData(c);o.addNodeData(d);let f=o.getKeyForNodeData(d);f!==void 0&&o.addLabelKeyForLinkData(u,f)}return n.findLinkForData(u)}}return null}}class Qn extends me{Ea=null;Ck(t,e){if(t===null||e===null||e.findTreeParentLink()!==null)return;let i=this.diagram.toolManager.findTool("Linking"),s=t,n=e;if(this.diagram.isTreePathToChildren){if(i!==null&&i.Vu(s,n,null,!0))return}else if(s=e,n=t,i!==null&&i.Vu(s,n,null,!0))return;let o=this.getLinkCategoryForData(e.data),r=this.findLinkTemplateForCategory(o);if(r!==null){r.It();let a=r.copy();if(a!==null){let h=this.diagram.wi;this.diagram.wi=!0,a.Qo=o,a.te=e.data,a.fromNode=s,a.toNode=n,this.diagram.add(a),a.te=null,a.data=e.data,this.diagram.wi=h}}}getLinkCategoryForData(t){return this.diagram.model.getParentLinkCategoryForNodeData(t)}setLinkCategoryForData(t,e){this.diagram.model.setParentLinkCategoryForNodeData(t,e)}setFromNodeForLink(t,e,i){let s=this.diagram.model;i===void 0&&(i=null);let n=e!==null?e.data:null;if(this.diagram.isTreePathToChildren)s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n));else{let o=this.Ea;this.Ea=t,i!==null&&s.setParentKeyForNodeData(i.data,void 0);let r=t.toNode!==null?t.toNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ea=o}}setToNodeForLink(t,e,i){let s=this.diagram.model;i===void 0&&(i=null);let n=e!==null?e.data:null;if(this.diagram.isTreePathToChildren){let o=this.Ea;this.Ea=t,i!==null&&s.setParentKeyForNodeData(i.data,void 0);let r=t.fromNode!==null?t.fromNode.data:null;s.setParentKeyForNodeData(n,s.getKeyForNodeData(r)),this.Ea=o}else s.setParentKeyForNodeData(t.data,s.getKeyForNodeData(n))}LN(t){this.diagram.model.setParentKeyForNodeData(t.data,void 0)}findLinkForKey(t){if(t==null)return null;let e=this.diagram.model.findNodeDataForKey(t);return e!==null?this.findLinkForData(e):null}doModelChanged(t){if(super.doModelChanged(t),!this.diagram)return;let e=this.diagram;if(t.model!==e.model)return;let i=t.change;if(e.G){e.G=!1;try{let s=t.modelChange;if(s!==""){if(i===2){if(s==="nodeParentKey"){let n=t.object,o=n?this.findNodeForData(n):null,r=t.newValue,a=this.findNodeForKey(r);if(n&&this.Ea!==null)a!==null&&(this.Ea.data=n,this.Ea.category=this.getLinkCategoryForData(n));else if(o!==null){let h=o.findTreeParentLink();h!==null?a===null?e.remove(h):e.isTreePathToChildren?h.fromNode=a:h.toNode=a:this.Ck(a,o)}}else if(s==="parentLinkCategory"){let n=t.object,o=n?this.findNodeForData(n):null,r=t.newValue;if(o!==null&&typeof r=="string"){let a=o.findTreeParentLink();a!==null&&(a.category=r)}}e.isModified=!0}}else i===2&&(t.object===e.model&&t.propertyName==="nodeParentKeyProperty"&&(e.undoManager.isUndoingRedoing||this.rebuildParts()),e.isModified=!0)}finally{e.G=!0}}}updateRelationshipsFromData(t){let e=t.data;if(e===null)return;let i=t.diagram;if(i===null)return;let s=i.model;if(t instanceof $){let n=s.getParentKeyForNodeData(e),o=i.findNodeForKey(n),r=t.findTreeParentNode();if(o!==r){let a=t.findTreeParentLink();o!==null?a!==null?i.isTreePathToChildren?a.fromNode=o:a.toNode=o:this.Ck(o,t):a!==null&&i.N2(a,!1)}}}tw(t,e){if(super.tw(t,e),typeof e=="string"&&this.findPartForData(t)!==null){let i=this.findLinkForData(t);i!==null&&i.updateTargetBindings(e)}}kk(t){let e=this.diagram.model,i=e.getKeyForNodeData(t);if(i!==void 0){let s=e.ew(i),n=this.findPartForData(t);if(s!==null&&n!==null){let r=s.iterator;for(;r.next();){let a=r.value;if(e.containsNodeData(a)&&n instanceof $&&e.getParentKeyForNodeData(a)===i){let h=this.findNodeForData(a);this.Ck(n,h)}}e.an(i)}let o=e.getParentKeyForNodeData(t);if(o!==void 0&&n instanceof $){let r=this.findNodeForKey(o);this.Ck(r,n)}}}XN(t){let e=this.diagram.model;if(t instanceof $){let i=e.getKeyForNodeData(t.data),s=this.findLinkForData(t.data);if(s!==null){s.isSelected=!1,s.isHighlighted=!1;let r=s.layer;if(r!==null){let a=r.ri(-1,s,!1);a>=0&&this.diagram.raiseChangedEvent(4,"parts",r,s,null,a,null);let h=s.layerChanged;h!==null&&h(s,r,null)}}let n=this.diagram.isTreePathToChildren,o=t.linksConnected;for(;o.next();){let r=o.value,a=n?r.toNode:r.fromNode;if(a!==null){let h=a.data;e.containsNodeData(h)&&e.hn(i,h)}}}}insertLink(t,e,i,s){let n=this.diagram.model,o=t,r=i;if(this.diagram.isTreePathToChildren||(o=i,r=t),o!==null&&r!==null){let a=o.data,h=r.data;return n.setParentKeyForNodeData(h,n.getKeyForNodeData(a)),r.findTreeParentLink()}return null}}var Ci=(x=>(x[x.OneWay=1]="OneWay",x[x.TwoWay=2]="TwoWay",x))(Ci||{});class ie{n;HN;nc;Hf;Ua;qf;jf;Wf;Nk;Ti;Ed;vf;constructor(t,e,i,s){V.Je(this),t===void 0?t="":m.s(t,"string",ie,"constructor:targetprop"),e===void 0?e=t:m.s(e,"string",ie,"constructor:sourceprop"),i===void 0?i=null:i!==null&&m.S(i,ie,"constructor:conv"),this.HN=-1,this.Ti=null,this.nc=t,this.Ed=0,this.vf=0,this.Hf=null,this.Ua=e,this.qf=i,s===void 0?(this.jf=1,this.Wf=null):(this.jf=2,this.Wf=s),this.Nk=new V,this.n=2}copy(){let t=new this.constructor;return this.cloneProtected(t),t}cloneProtected(t){t.nc=this.nc,t.Ed=this.Ed,t.vf=this.vf,t.Hf=this.Hf,t.Ua=this.Ua,t.qf=this.qf,t.jf=this.jf,t.Wf=this.Wf,t.n=this.n&-2}static OneWay=1;static TwoWay=2;static parseEnum(t,e){return m.S(t,ie,"parseEnum:ctor"),i=>{let s=parseInt(i);return isNaN(s)&&(s=m.Ja(t,i),s===null)?e:s}}fe(t){t in Ci?this.mode=t:m.ur(this,t)}static toString(t){return m.toString(t)}toString(){return"Binding("+this.targetProperty+":"+this.sourceProperty+(this.targetId!==-1?" "+this.targetId:"")+" "+Ci[this.mode]+")"}k(){return this.n=this.n|1,this}get targetId(){return this.HN}set targetId(t){this.u&&m.L(this),this.HN=t}get targetProperty(){return this.nc}set targetProperty(t){this.u&&m.L(this),m.s(t,"string",ie,"targetProperty"),this.nc=t}get sourceProperty(){return this.Ua}set sourceProperty(t){this.u&&m.L(this),m.s(t,"string",ie,"sourceProperty"),this.Ua=t}get u(){return(this.n&1)!==0}get isToData(){return(this.n&2)!==0}get isToObject(){return(this.n&4)!==0}get isToModel(){return(this.n&8)!==0}get isToTheme(){return(this.n&16)!==0}get qN(){return this.isToTheme&&!(this.isToData||this.isToObject||this.isToModel)}bd(){return!1}get sourceName(){return this.Hf}set sourceName(t){this.u&&m.L(this),t!==null&&m.s(t,"string",ie,"sourceName"),this.Hf=t,t!==null?this.n=this.n&-3|4:this.n=this.n|2}get converter(){return this.qf}set converter(t){this.u&&m.L(this),t!==null&&m.S(t,ie,"converter"),this.qf=t}get backConverter(){return this.Wf}set backConverter(t){this.u&&m.L(this),t!==null&&m.S(t,ie,"backConverter"),this.Wf=t}get mode(){return this.jf}set mode(t){this.u&&m.L(this),this.isToTheme&&t===2&&m.o("Theme Bindings cannot be TwoWay."),this.jf=t}makeTwoWay(t){return this.isToTheme&&m.o("Theme Bindings cannot be TwoWay."),this.mode=2,t&&(m.S(t,ie,"makeTwoWay"),this.backConverter=t),this}ofObject(t){return this.u&&m.L(this),t===void 0&&(t=""),this.sourceName=t,this}ofModel(){return this.u&&m.L(this),this.n=this.n&-3&-5|8,this.Hf=null,this}JT(t,e){let i=this.sourceName,s=null;return i===null||i===""?s=t:i==="/"?s=e.part:i==="."?s=e:i===".."?s=e.panel:s=t.findObject(i),s}check(t){let e=this.nc,i=this.Ua,s=this.qf;(this.bd()&&s===null&&this.Va===null&&e===""||s===null&&e==="")&&m.ne("Binding error: target property is the empty string: "+this.toString()),this.bd()&&this.qN&&i===""&&s===null&&this.Va===null&&m.ne("Binding error: theme bindings require a source property when not using a converter: "+this.toString()),t&&typeof e=="string"&&(!m.it(["setAttribute"])&&e.length>0&&e[0]!=="_"&&!m.Gw(t,e)?m.ne("Binding error: undefined target property: "+e+" on "+t.toString()):e==="name"&&t instanceof J&&m.ne("Binding error: cannot modify GraphObject.name on "+t.toString()))}updateTarget(t,e,i,s){let n=this.Ua;if(i!==void 0&&n!==""&&n!==i||this.isToTheme&&t.diagram===null)return;let o=this.nc,r=this.qf,a=e;if(n!==""&&!this.qN&&(a=dt.Lt(e,n)),a!==void 0)if(r===null){if(o!==""){if(this.bd()){let h=t.diagram?.themeManager;if(a=this.Bv(h,a,t,o),a===void 0)return}s?s.nt(t,o,a):(e instanceof J||e instanceof Kt)&&dt.nt(t,o,a)}}else try{if(o!==""){let h=r(a,t);if(this.bd()){let l=t.diagram?.themeManager;if(h=this.Bv(l,h,t,o),h===void 0)return}s?s.nt(t,o,h):(e instanceof J||e instanceof Kt)&&dt.nt(t,o,h)}else r(a,t)}catch{}}updateSource(t,e,i,s){if(this.jf!==2)return;let n=this.nc;if(i!==void 0&&n!==i)return;let o=this.Ua,r=this.Wf,a=s!==null?s.diagram:null,h=a!==null?a.model:null,l=t;if(n!==""&&(l=dt.Lt(t,n)),l!==void 0&&!this.Nk.has(t))try{if(this.Nk.add(t),r===null){if(o!=="")h!==null?h.setDataProperty(e,o,l):(e instanceof J||e instanceof Kt)&&(e[o]=l);else if(h!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){let u=s.itemIndex,c=s.panel.itemArray;h.removeArrayItem(c,u),h.insertArrayItem(c,u,l)}}else try{if(o!==""){let u=r(l,e,h);h!==null?h.setDataProperty(e,o,u):(e instanceof J||e instanceof Kt)&&(e[o]=u)}else{let u=r(l,e,h);if(u!==void 0&&h!==null&&s!==null&&s.itemIndex>=0&&s.panel!==null&&Array.isArray(s.panel.itemArray)){let c=s.itemIndex,d=s.panel.itemArray;h.removeArrayItem(d,c),h.insertArrayItem(d,c,u)}}}catch{}}finally{this.Nk.delete(t)}}}class ii extends ie{iw;Va;oc;constructor(t,e,i,s,n){super(t,e,s),i==null&&(i=""),n===void 0&&(n=null),this.iw=i,this.Va=n,this.oc=null,this.n=16}cloneProtected(t){super.cloneProtected(t),t.iw=this.iw,t.Va=this.Va,t.oc=this.oc}bd(){return!0}get themeSource(){return this.iw}set themeSource(t){this.u&&m.L(this),t!==null&&m.s(t,"string",ii,"themeSource"),this.iw=t,this.oc=null,t!==null?this.n=this.n|16:this.n=this.n&-17}get themeConverter(){return this.Va}set themeConverter(t){this.u&&m.L(this),t!==null&&m.S(t,ii,"themeConverter"),this.Va=t}ofData(){return this.u&&m.L(this),this.n=this.n|2,this.Hf=null,this}Bv(t,e,i,s){if(!t||(this.qN&&(e=this.Ua),!e&&e!==0))return;let n=this.themeSource;this.oc!==null?n=this.oc:typeof n=="string"&&n.includes(".")&&(this.oc=n.split("."),n=this.oc);let o=t.findValue(e,n,s);if(o===void 0&&m.ne(`Theme warning: ${e} could not be found when setting target property ${s}.`),t.readsCssVariables&&typeof o=="string"&&o.startsWith("var(")){let r=o.match(this.l3);r&&(o=getComputedStyle(K.document.documentElement).getPropertyValue(r[1]))}return m.it(this.Va)&&(o=this.Va(o,i)),o}l3=/var\((.*)\)/}class dt{Pt;Pg;Bo;jN;Xi;ke;Ba;Jf;$f;Sg;Mg;Cg;Ng;nw;rc;rr;ow;Vo;Lk;constructor(t,e){if(V.Je(this),this.Pt="",this.Pg="",this.Bo=!1,this.jN={},this.Xi=[],this.ke=new Mt,this.Ba="key",this.Jf=null,this.$f=null,this.Sg=!1,this.Mg=!1,this.Cg=!1,this.Ng=null,this.nw=100,this.rc="category",this.rr=new Mt,this.ow=[],this.Vo=!1,this.Lk=null,this.undoManager=new vi,t!==void 0&&(Array.isArray(t)?this.nodeDataArray=t:e=t),e){Object.assign(this,e);let i=e.Changed;i&&(delete this.Changed,this.addChangedListener(i))}}cloneProtected(t){t.Pt=this.Pt,t.Pg=this.Pg,t.Bo=this.Bo,t.Ba=this.Ba,t.Jf=this.Jf,t.$f=this.$f,t.Sg=this.Sg,t.Mg=this.Mg,t.Cg=this.Cg,t.Ng=this.Ng,t.nw=this.nw,t.rc=this.rc}copy(){let t=new this.constructor;return this.cloneProtected(t),t}clear(){this.Xi=[],this.ke.clear(),this.rr.clear(),this.undoManager.clear()}toString(t){if(t===void 0&&(t=0),t>1)return this.toJson();{let e=(this.name!==""?this.name:"")+" Model";if(t>0){e+=`
|
|
16
16
|
node data:`;let i=this.nodeDataArray,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+this.getKeyForNodeData(o)+":"+m.toString(o)}}return e}}toIncrementalData(t){t.change!==1&&m.o("Model.toIncrementalData argument is not a Transaction ChangedEvent:"+t.toString());let e=t.object;if(!t.isTransactionFinished||!(e instanceof oi))return null;let i=this.zv(e);return this.WN(e,t.propertyName==="FinishedUndo",i)}WN(t,e,i){let s=this,n=!1,o=new V,r=new V,a=new V;t.changes.each(d=>{if(d.model===s){if(d.modelChange==="nodeDataArray")d.change===3?o.add(d.newValue):d.change===4&&a.add(d.oldValue);else if(s.containsNodeData(d.object))d.object!==null&&r.add(d.object);else if(d.change===2&&(s.modelData===d.object||d.propertyName==="modelData"))n=!0;else if(d.object!==null)if(i.has(d.object)){let f=i.get(d.object);f&&f.each(p=>{s.containsNodeData(p)&&r.add(p)})}else{if(d.object instanceof dt||s.jh()&&s.containsLinkData(d.object))return;s.Xv(d.object).each(f=>{r.add(f)})}}});let h=new V;o.each(d=>{let f=s.getKeyForNodeData(d);f!==void 0&&h.add(f),e||r.add(d)});let l=new V;a.each(d=>{let f=s.getKeyForNodeData(d);f!==void 0&&l.add(f),e&&r.add(d)});let u=s.cloneDeep(r.toArray()),c=null;return n&&(c===null&&(c={}),c.modelData=this.cloneDeep(this.modelData)),h.count>0&&(c===null&&(c={}),e?c.removedNodeKeys=h.toArray():c.insertedNodeKeys=h.toArray()),u.length>0&&(c===null&&(c={}),c.modifiedNodeData=u),l.count>0&&(c===null&&(c={}),e?c.insertedNodeKeys=l.toArray():c.removedNodeKeys=l.toArray()),c}cloneDeep(t){return this.Lg(t,!0)}Lg(t,e,i,s){if(!m.$(t))return t;i||(i=new Mt);let n=i.get(t);if(n)return n;let o;if(Array.isArray(t)){o=[],i.set(t,o);for(let r=0;r<t.length;r++){let a=t[r];o.push(this.Lg(a,!1,i,s))}}else if(t instanceof P||t instanceof nt||t instanceof I||t instanceof Dt||t instanceof T)o=t.copy(),i.set(t,o);else{if(t instanceof R||t instanceof wt)return t;if(t instanceof q)o=new q().addAll(this.Lg(t.toArray(),!1,i,s)),i.set(t,o);else if(t instanceof V)o=new V().addAll(this.Lg(t.toArray(),!1,i,s)),i.set(t,o);else if(t instanceof Mt)o=new Mt().addAll(this.Lg(t.toArray(),!1,i,s)),i.set(t,o);else if(t instanceof Date)o=new Date(t),i.set(t,o);else if(t instanceof RegExp)o=new RegExp(t),i.set(t,o),o.lastIndex=t.lastIndex;else if(dt.JN(null,"",t))o=t;else if(m.it(t.copy))o=t.copy(),i.set(t,o);else{o={},i.set(t,o);for(let r in t){if(r==="__gohashid")continue;let a=t[r];o[r]=this.Lg(a,!1,i,s)}}}return o}quote(t){return JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,e=>{let i="0000"+e.charCodeAt(0).toString(16);return"\\u"+i.substring(i.length-4)})}Ag(){let t="";return this.name!==""&&(t+=`,
|
|
17
17
|
"name": `+this.quote(this.name)),this.dataFormat!==""&&(t+=`,
|
|
18
18
|
"dataFormat": `+this.quote(this.dataFormat)),this.isReadOnly&&(t+=`,
|