@hachej/boring-ui-cli 0.1.66 → 0.1.68
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/README.md +1 -1
- package/dist/server/pluginDiscovery.js +1 -1
- package/package.json +7 -6
- package/public/assets/Assistant-Bold-gm-uSS1B.woff2 +0 -0
- package/public/assets/Assistant-Medium-DrcxCXg3.woff2 +0 -0
- package/public/assets/Assistant-Regular-DVxZuzxb.woff2 +0 -0
- package/public/assets/Assistant-SemiBold-SCI4bEL9.woff2 +0 -0
- package/public/assets/DebugDrawer-BPhPmF7n.js +1 -0
- package/public/assets/DiagramPane-Cb8gdMwJ.js +109 -0
- package/public/assets/DiagramPane-DtRVLazd.css +1 -0
- package/public/assets/{angular-html-B39RWSv-.js → angular-html-DAZkIvH1.js} +1 -1
- package/public/assets/{angular-html-DgNOLx12.js → angular-html-OPr40Bdu.js} +1 -1
- package/public/assets/{angular-ts-CSfeHFey.js → angular-ts-BZGLXMD_.js} +1 -1
- package/public/assets/{angular-ts-CMYap2MI.js → angular-ts-ByBtq9hT.js} +1 -1
- package/public/assets/{apl-Cit2AbZp.js → apl-DjtZag15.js} +1 -1
- package/public/assets/{apl-DnbZkura.js → apl-NsZXS6sH.js} +1 -1
- package/public/assets/ar-SA-G6X2FPQ2-Cb41YiB7.js +10 -0
- package/public/assets/{arc-DpYq0g5z.js → arc-CBOKWbS-.js} +1 -1
- package/public/assets/architecture-YZFGNWBL-BHB2sWUH.js +1 -0
- package/public/assets/{architectureDiagram-Q4EWVU46-BrRMwXdF.js → architectureDiagram-Q4EWVU46-C2LlQ_Jj.js} +1 -1
- package/public/assets/{astro-DEHcyQDT.js → astro-BlEuKi4L.js} +1 -1
- package/public/assets/{astro-DbAXz9vD.js → astro-DpsWYwqp.js} +1 -1
- package/public/assets/az-AZ-76LH7QW2-CnfWZeUk.js +1 -0
- package/public/assets/bg-BG-XCXSNQG7-Cl45RwQy.js +5 -0
- package/public/assets/{blade-Koy9dtV6.js → blade-Co7NgYWY.js} +1 -1
- package/public/assets/{blade-CaquFwJY.js → blade-D6_8TV4v.js} +1 -1
- package/public/assets/{blockDiagram-DXYQGD6D-D7Z-ocih.js → blockDiagram-DXYQGD6D-e3vVT5ca.js} +1 -1
- package/public/assets/bn-BD-2XOGV67Q-ClQx2pnI.js +5 -0
- package/public/assets/bundle-mjs-waAbs7aL.js +1 -0
- package/public/assets/{c-DSb_9Qym.js → c-CXHx_QxQ.js} +1 -1
- package/public/assets/{c-CGfw0hEY.js → c-DZcGRK6x.js} +1 -1
- package/public/assets/{c4Diagram-AHTNJAMY-CvqR_pBI.js → c4Diagram-AHTNJAMY-CQMGUGZr.js} +1 -1
- package/public/assets/ca-ES-6MX7JW3Y-B70Lf-H_.js +8 -0
- package/public/assets/channel-DHwtVBRO.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-CU8ErJTl.js → chunk-4BX2VUAB-TekC62G8.js} +1 -1
- package/public/assets/{chunk-4TB4RGXK-OsoVpy7y.js → chunk-4TB4RGXK-NVc-EkQr.js} +2 -2
- package/public/assets/{chunk-55IACEB6-DU0EXLY8.js → chunk-55IACEB6-BM2FPRve.js} +1 -1
- package/public/assets/{chunk-5FUZZQ4R-BYqci71H.js → chunk-5FUZZQ4R-DFs5M0VY.js} +1 -1
- package/public/assets/{chunk-5PVQY5BW-Cke21h48.js → chunk-5PVQY5BW-PKb2UfEn.js} +1 -1
- package/public/assets/chunk-6U3AYISY-C6-Mtja1.js +12 -0
- package/public/assets/{chunk-BSJP7CBP-B0F0WywQ.js → chunk-BSJP7CBP-kQ7Calqs.js} +1 -1
- package/public/assets/{chunk-EDXVE4YY-Cm46dxOD.js → chunk-EDXVE4YY-W62DzS3u.js} +1 -1
- package/public/assets/chunk-EIO257PC-Bt5tXGkD.js +22 -0
- package/public/assets/chunk-ENJZ2VHE-B19bR_UY.js +10 -0
- package/public/assets/{chunk-FMBD7UC4-Caj-UZG6.js → chunk-FMBD7UC4-Mds7U6Tl.js} +1 -1
- package/public/assets/{chunk-ICPOFSXX-C6w-kDPZ.js → chunk-ICPOFSXX-CbeWjtve.js} +3 -3
- package/public/assets/chunk-K2UTITRG-CrL9EuZD.js +35 -0
- package/public/assets/{chunk-K5T4RW27-B8krvPgy.js → chunk-K5T4RW27-BJPpT0_8.js} +4 -4
- package/public/assets/{chunk-OYMX7WX6-wITau7qV.js → chunk-OYMX7WX6-DDrTbLPP.js} +1 -1
- package/public/assets/chunk-QZHKN3VN-Cql2fGuf.js +1 -0
- package/public/assets/chunk-SRAX5OIU-QXaHHJU-.js +1 -0
- package/public/assets/{chunk-U2HBQHQK-CnBTRkXz.js → chunk-U2HBQHQK-CdUtCuol.js} +1 -1
- package/public/assets/{chunk-X2U36JSP-Cw7Lksyy.js → chunk-X2U36JSP-CJWDEMsp.js} +1 -1
- package/public/assets/{chunk-YZCP3GAM-C5htJxP7.js → chunk-YZCP3GAM-C1MzZAkl.js} +1 -1
- package/public/assets/chunk-Z3N5DIM6-D9TMVU7m.js +1 -0
- package/public/assets/chunk-ZUYEQ4TG-BzFOpW--.js +7 -0
- package/public/assets/{chunk-ZZ45TVLE-OsGVWY8u.js → chunk-ZZ45TVLE-CCEhJUTd.js} +1 -1
- package/public/assets/classDiagram-6PBFFD2Q-DrDFaWlC.js +1 -0
- package/public/assets/classDiagram-v2-HSJHXN6E-DrDFaWlC.js +1 -0
- package/public/assets/clone-euLbFmGl.js +1 -0
- package/public/assets/{cobol-DHZ6vC5A.js → cobol-1yO40WvH.js} +1 -1
- package/public/assets/{cobol-BSZK6gvX.js → cobol-DLIHcK6X.js} +1 -1
- package/public/assets/{coffee-DC1Xlh7j.js → coffee-BH85s6z9.js} +1 -1
- package/public/assets/{coffee-JFuPUsC8.js → coffee-BtNhp1Qm.js} +1 -1
- package/public/assets/{cose-bilkent-S5V4N54A-lccYlEHv.js → cose-bilkent-S5V4N54A-DsSOGNwJ.js} +1 -1
- package/public/assets/{cpp-CmBZcPpY.js → cpp-4v70owf9.js} +1 -1
- package/public/assets/{cpp-D-PYxrPR.js → cpp-X2kfd8wP.js} +1 -1
- package/public/assets/createLucideIcon-BpL36Utr.js +41 -0
- package/public/assets/{crystal-ROeOZjS0.js → crystal-CiNiOkvj.js} +1 -1
- package/public/assets/{crystal-cklMTMZU.js → crystal-CvCDm65O.js} +1 -1
- package/public/assets/cs-CZ-2BRQDIVT-CK-m8a6b.js +11 -0
- package/public/assets/{css-Db5oXez4.js → css-0y4-KSD0.js} +1 -1
- package/public/assets/{css-DKkzKoRq.js → css-7OAM-P7i.js} +1 -1
- package/public/assets/da-DK-5WZEPLOC-B_630tmB.js +5 -0
- package/public/assets/{dagre-BZmt1Xiv.js → dagre-DGF0uJBS.js} +1 -1
- package/public/assets/dagre-KV5264BT-DUiFDgw2.js +4 -0
- package/public/assets/de-DE-XR44H4JA-DtdQNPIr.js +8 -0
- package/public/assets/{diagram-5BDNPKRD-DMs3ML4T.js → diagram-5BDNPKRD-zVwejgnb.js} +1 -1
- package/public/assets/{diagram-G4DWMVQ6-PPwat941.js → diagram-G4DWMVQ6-TIbsYTBJ.js} +1 -1
- package/public/assets/{diagram-MMDJMWI5-CztzFB07.js → diagram-MMDJMWI5-CFsXMMwG.js} +1 -1
- package/public/assets/{diagram-TYMM5635-Dw88vukx.js → diagram-TYMM5635-Dy645EM6.js} +1 -1
- package/public/assets/directory-open-01563666-D4xXyWb_.js +1 -0
- package/public/assets/directory-open-4ed118d0-1i309Asm.js +1 -0
- package/public/assets/dist-DAGGreTm.js +19 -0
- package/public/assets/{dist-DfGpsssh.js → dist-shQtHlo7.js} +1 -1
- package/public/assets/{edge-C2RFEFnj.js → edge-CzDFjITs.js} +1 -1
- package/public/assets/{edge-Cdcn16j1.js → edge-KEfM9eR8.js} +1 -1
- package/public/assets/el-GR-BZB4AONW-BhrdBtxp.js +10 -0
- package/public/assets/{elixir-D29-Y5pS.js → elixir-BuYyFZe9.js} +1 -1
- package/public/assets/{elixir-D9V4jKRq.js → elixir-BwKQnSXz.js} +1 -1
- package/public/assets/{elm-B6qzVAdm.js → elm-CsxBHsx4.js} +1 -1
- package/public/assets/{elm-DIiv-awt.js → elm-DfB-0k7U.js} +1 -1
- package/public/assets/en-B4ZKOASM-BNPKUPIM.js +1 -0
- package/public/assets/{erDiagram-SMLLAGMA-BA9TTZ2t.js → erDiagram-SMLLAGMA-CGqOyENd.js} +2 -2
- package/public/assets/{erb-C8WU1R1c.js → erb-Cjc8n6sT.js} +1 -1
- package/public/assets/{erb-D0TpFgki.js → erb-DUBviY-i.js} +1 -1
- package/public/assets/es-ES-U4NZUMDT-BVdRn_Jk.js +9 -0
- package/public/assets/eu-ES-A7QVB2H4-tW-JN7p8.js +11 -0
- package/public/assets/fa-IR-HGAKTJCU-BZyMSjbe.js +8 -0
- package/public/assets/fi-FI-Z5N7JZ37-DzRBXsPy.js +6 -0
- package/public/assets/file-open-002ab408-BHUWm0Sh.js +1 -0
- package/public/assets/file-open-7c801643-DZtJT5zp.js +1 -0
- package/public/assets/file-save-3189631c-CO9S4HFW.js +1 -0
- package/public/assets/file-save-745eba88-Bwdfz6OZ.js +1 -0
- package/public/assets/{flatten-DkO_XGHs.js → flatten-D5sKD-5t.js} +1 -1
- package/public/assets/{flowDiagram-DWJPFMVM-Dklx4ZlV.js → flowDiagram-DWJPFMVM-L6BVbVJK.js} +3 -3
- package/public/assets/fr-FR-RHASNOE6-DEodF8O6.js +9 -0
- package/public/assets/{ganttDiagram-T4ZO3ILL-BTT_YZM8.js → ganttDiagram-T4ZO3ILL-BUrmnGiC.js} +1 -1
- package/public/assets/{git-rebase-CbR6h3gY.js → git-rebase-BDmFkYHa.js} +1 -1
- package/public/assets/{git-rebase-DtuRY1s6.js → git-rebase-CJowa7Cz.js} +1 -1
- package/public/assets/gitGraph-7Q5UKJZL-nQMAGxnD.js +1 -0
- package/public/assets/{gitGraphDiagram-UUTBAWPF-DFctPk_F.js → gitGraphDiagram-UUTBAWPF-D6R_lj2o.js} +1 -1
- package/public/assets/gl-ES-HMX3MZ6V-Du5pFjOW.js +10 -0
- package/public/assets/{glimmer-js-D8jwLwre.js → glimmer-js-D5eZdT4q.js} +1 -1
- package/public/assets/{glimmer-js-DnaO57FY.js → glimmer-js-Dnlbedm-.js} +1 -1
- package/public/assets/{glimmer-ts-C0Gc9wBz.js → glimmer-ts-CRxOnUuY.js} +1 -1
- package/public/assets/{glimmer-ts-DncEGZcb.js → glimmer-ts-CUXyr5gc.js} +1 -1
- package/public/assets/{glsl-DIyw_n10.js → glsl-ChqQY85_.js} +1 -1
- package/public/assets/{glsl-XmQLoWTd.js → glsl-ZkHBcETX.js} +1 -1
- package/public/assets/{graphlib-CnM3KfVp.js → graphlib-DGfh1co3.js} +1 -1
- package/public/assets/{graphql-DbJ6s07V.js → graphql-B8s0y7SE.js} +1 -1
- package/public/assets/{graphql-z5w2oPad.js → graphql-BswNaMW0.js} +1 -1
- package/public/assets/{hack-8EVjuCGk.js → hack-DhlnIVni.js} +1 -1
- package/public/assets/{hack-B6ElcKtQ.js → hack-MHjHM3Fw.js} +1 -1
- package/public/assets/{haml-BCXmfrFq.js → haml-D3KaFfqI.js} +1 -1
- package/public/assets/{haml-CxRDY_qR.js → haml-DIZUWW64.js} +1 -1
- package/public/assets/{handlebars-CWYYzQm1.js → handlebars-Df9vShQa.js} +1 -1
- package/public/assets/{handlebars-Cr6DgEdL.js → handlebars-YIbU_d5l.js} +1 -1
- package/public/assets/he-IL-6SHJWFNN-D9GHex1S.js +10 -0
- package/public/assets/hi-IN-IWLTKZ5I-DnqTYaZL.js +4 -0
- package/public/assets/highlighted-body-OFNGDK62-Ckfy53pN.js +1 -0
- package/public/assets/{html-CdgAVyWe.js → html-CMyw-11O.js} +1 -1
- package/public/assets/{html-UpaxNpl1.js → html-Cr00W52X.js} +1 -1
- package/public/assets/{html-derivative-BEqslGqH.js → html-derivative-BrnYzwu4.js} +1 -1
- package/public/assets/{html-derivative-DNLsj7E8.js → html-derivative-BzhEXa6T.js} +1 -1
- package/public/assets/{http-Bd8J5sk4.js → http-CAyFjLsd.js} +1 -1
- package/public/assets/{http-CWawU2Ur.js → http-tJF3gUny.js} +1 -1
- package/public/assets/hu-HU-A5ZG7DT2-BYOpW44D.js +7 -0
- package/public/assets/{hurl-Cv853ROj.js → hurl-7KVe7Zel.js} +1 -1
- package/public/assets/{hurl-bakY91g_.js → hurl-DnzPO2nb.js} +1 -1
- package/public/assets/id-ID-SAP4L64H-DfY6GEBJ.js +10 -0
- package/public/assets/image-GAAHSSAO-C7O7NdjH.js +1 -0
- package/public/assets/image-blob-reduce.esm-DLFdRAwc.js +2 -0
- package/public/assets/index-Bp2DjxBi.js +861 -0
- package/public/assets/info-OMHHGYJF-CxYJBTrR.js +1 -0
- package/public/assets/{infoDiagram-42DDH7IO-C0WP-KYo.js → infoDiagram-42DDH7IO-L3GN3t-A.js} +1 -1
- package/public/assets/{ishikawaDiagram-UXIWVN3A-D31uCle4.js → ishikawaDiagram-UXIWVN3A-CriSwJEC.js} +1 -1
- package/public/assets/it-IT-JPQ66NNP-C8bnB-BP.js +11 -0
- package/public/assets/ja-JP-DBVTYXUO-CXnZ_q5a.js +8 -0
- package/public/assets/{java-BKjUn1fn.js → java-Cbnz9Hh0.js} +1 -1
- package/public/assets/{java-BHp6IuKC.js → java-DxVPSl2E.js} +1 -1
- package/public/assets/{javascript-DpaUJ1AF.js → javascript-BIFKftnz.js} +1 -1
- package/public/assets/{javascript-sBCNfWeD.js → javascript-CiVtKqTf.js} +1 -1
- package/public/assets/{jinja-DDfApWa2.js → jinja-C4aMjrbR.js} +1 -1
- package/public/assets/{jinja-JI4gpsbJ.js → jinja-d3rD1-45.js} +1 -1
- package/public/assets/{jison-C3plQy7R.js → jison-BTFFpafa.js} +1 -1
- package/public/assets/{jison-C7zlJPuM.js → jison-DoJKlVbX.js} +1 -1
- package/public/assets/{journeyDiagram-VCZTEJTY-nF1JXq8r.js → journeyDiagram-VCZTEJTY-CYX--9Wp.js} +1 -1
- package/public/assets/{json-BHCiOpyK.js → json--SvNElTv.js} +1 -1
- package/public/assets/{json-LwtTidO3.js → json-DmI0juDY.js} +1 -1
- package/public/assets/{jsx-CCtMG784.js → jsx-8OLW1s-j.js} +1 -1
- package/public/assets/{jsx-DlZ9KC_R.js → jsx-BgZC5iNs.js} +1 -1
- package/public/assets/jsx-runtime-CC-kRuLe.js +1 -0
- package/public/assets/{julia-gNWUdbFQ.js → julia-H5UiyP9J.js} +1 -1
- package/public/assets/{julia-C6mNI1sF.js → julia-bZVlMoSO.js} +1 -1
- package/public/assets/{just-C0fz_bIp.js → just-BykQi8z9.js} +1 -1
- package/public/assets/{just-CKTmH4mX.js → just-CSmGa9bc.js} +1 -1
- package/public/assets/kaa-6HZHGXH3-DDaHm4rV.js +1 -0
- package/public/assets/kab-KAB-ZGHBKWFO-DBB61TA4.js +8 -0
- package/public/assets/{kanban-definition-6JOO6SKY-B6jAFFuA.js → kanban-definition-6JOO6SKY-r_FtVoAw.js} +3 -3
- package/public/assets/kk-KZ-P5N5QNE5-nJujjHZU.js +1 -0
- package/public/assets/km-KH-HSX4SM5Z-BTbPrn7C.js +11 -0
- package/public/assets/ko-KR-MTYHY66A-DY7N8FkC.js +9 -0
- package/public/assets/ku-TR-6OUDTVRD-CWiwUq7W.js +9 -0
- package/public/assets/{latex-D6VROaBk.js → latex-CxL6GDET.js} +1 -1
- package/public/assets/{latex-GrWM0ZPB.js → latex-nPurGBuO.js} +1 -1
- package/public/assets/{line-DztFIo_D.js → line-CR3tMWzH.js} +1 -1
- package/public/assets/{linear-sDEobIB4.js → linear-pQr9MHWw.js} +1 -1
- package/public/assets/{liquid-C9QfLt2Y.js → liquid-DO7yqCeF.js} +1 -1
- package/public/assets/{liquid-DphnKNv5.js → liquid-qq9k020p.js} +1 -1
- package/public/assets/lt-LT-XHIRWOB4-D5iGl8SA.js +3 -0
- package/public/assets/{lua-SDOyLusT.js → lua-B0hdEAwT.js} +1 -1
- package/public/assets/{lua-CK2jTcMk.js → lua-B5VEjJNI.js} +1 -1
- package/public/assets/lv-LV-5QDEKY6T-Dk5tYd5b.js +7 -0
- package/public/assets/{marko-C1J3-BdZ.js → marko-BY44o4xN.js} +1 -1
- package/public/assets/{marko-mDP56VBg.js → marko-DD2_5Cqw.js} +1 -1
- package/public/assets/{mdc-DWepuBWK.js → mdc-BJCizhU8.js} +1 -1
- package/public/assets/{mdc-eZyDVX9o.js → mdc-Do6ECbGI.js} +1 -1
- package/public/assets/mermaid-GHXKKRXX-DZG06fPR.js +1 -0
- package/public/assets/{mermaid-parser.core-BtQMqYpo.js → mermaid-parser.core-Ds0FSkVW.js} +2 -2
- package/public/assets/{mindmap-definition-QFDTVHPH-BmFnhufO.js → mindmap-definition-QFDTVHPH-CXn15TFt.js} +2 -2
- package/public/assets/mr-IN-CRQNXWMA-C3V-9EA3.js +13 -0
- package/public/assets/my-MM-5M5IBNSE-BkC0s2uK.js +1 -0
- package/public/assets/nb-NO-T6EIAALU-DVr77Juq.js +10 -0
- package/public/assets/{nginx-CIX8aOsc.js → nginx-BKWrkH-b.js} +1 -1
- package/public/assets/{nginx-DKPpSMe8.js → nginx-Cmwhrfiy.js} +1 -1
- package/public/assets/{nim-bGHfAHFs.js → nim-C3yhVY09.js} +1 -1
- package/public/assets/{nim-DGqqutcw.js → nim-ClbUVaF5.js} +1 -1
- package/public/assets/nl-NL-IS3SIHDZ-B9zaDsWm.js +8 -0
- package/public/assets/nn-NO-6E72VCQL-TxuzXJMr.js +8 -0
- package/public/assets/oc-FR-POXYY2M6-Du5tRkPK.js +8 -0
- package/public/assets/pa-IN-N4M65BXN-Ducc8ihq.js +4 -0
- package/public/assets/packet-4T2RLAQJ-f-eHIL1I.js +1 -0
- package/public/assets/percentages-BXMCSKIN-BzbvNGT_.js +1 -0
- package/public/assets/{perl-Dw5eGTLH.js → perl-BPpBSCFz.js} +1 -1
- package/public/assets/{perl-CbclNq8W.js → perl-CsDfcdDD.js} +1 -1
- package/public/assets/{php-BgmylLF3.js → php-Bc3nQoe0.js} +1 -1
- package/public/assets/{php-4ZoS2cMf.js → php-JXgMf01f.js} +1 -1
- package/public/assets/pica-BJC-kph8.js +2 -0
- package/public/assets/pie-ZZUOXDRM-Br4NtZeB.js +1 -0
- package/public/assets/{pieDiagram-DEJITSTG-D-fc4ghs.js → pieDiagram-DEJITSTG-CkClooEG.js} +1 -1
- package/public/assets/pl-PL-T2D74RX3-2GqH9xC0.js +9 -0
- package/public/assets/pt-BR-5N22H2LF-CZaLZGo4.js +9 -0
- package/public/assets/pt-PT-UZXXM6DQ-CZ_1UJI0.js +9 -0
- package/public/assets/{pug-B23FEZpW.js → pug-BKOO7giR.js} +1 -1
- package/public/assets/{pug-DL8MZ5S3.js → pug-BgOLlA7u.js} +1 -1
- package/public/assets/{qml-HiTfbmBE.js → qml-BBheGDU7.js} +1 -1
- package/public/assets/{qml-CM0VX5jL.js → qml-CJaH9k26.js} +1 -1
- package/public/assets/{quadrantDiagram-34T5L4WZ-Djd66VH6.js → quadrantDiagram-34T5L4WZ-D6Mc-mAE.js} +1 -1
- package/public/assets/{r-CkAqcQLQ.js → r-BQPfBfAV.js} +1 -1
- package/public/assets/{r-mbEajl6P.js → r-DDWYI-FX.js} +1 -1
- package/public/assets/radar-PYXPWWZC-DJpNuaAh.js +1 -0
- package/public/assets/{razor-BE3CgPws.js → razor-B6j0NgUG.js} +1 -1
- package/public/assets/{razor-CWtZ9UxH.js → razor-BqBUprH1.js} +1 -1
- package/public/assets/{reduce-Btctuiak.js → reduce-CSUAx4db.js} +1 -1
- package/public/assets/{regexp-BNS6Ofwz.js → regexp-Cwog52Fw.js} +1 -1
- package/public/assets/{regexp-DDv7zd5t.js → regexp-DToI4_jr.js} +1 -1
- package/public/assets/{requirementDiagram-MS252O5E-DEKwMJND.js → requirementDiagram-MS252O5E-4jeIYjL_.js} +2 -2
- package/public/assets/ro-RO-JPDTUUEW-BP6wu9nV.js +11 -0
- package/public/assets/{rolldown-runtime-C_JxhDyB.js → rolldown-runtime-BG2f4sTM.js} +1 -1
- package/public/assets/roundRect-D01gJrlt.js +1 -0
- package/public/assets/{rst-6BDdLnbn.js → rst-DKvq_BO-.js} +1 -1
- package/public/assets/{rst-CX4d7kqZ.js → rst-ukMr3rhh.js} +1 -1
- package/public/assets/ru-RU-B4JR7IUQ-Bi4CkeXg.js +9 -0
- package/public/assets/{ruby-BCot4oth.js → ruby-BSMWJsQO.js} +1 -1
- package/public/assets/{ruby-DC_Aqhyh.js → ruby-CfEZ5cWW.js} +1 -1
- package/public/assets/{sankeyDiagram-XADWPNL6-RNQ-uDSb.js → sankeyDiagram-XADWPNL6-DefHsk1L.js} +1 -1
- package/public/assets/{sas-BIVSnxlK.js → sas-D4r1HPKz.js} +1 -1
- package/public/assets/{sas-DEFEsGt7.js → sas-DZEbfvsK.js} +1 -1
- package/public/assets/{scss-CKfHcJzL.js → scss-4Uhttjqe.js} +1 -1
- package/public/assets/{scss-yQJsu9w4.js → scss-Du5DK-cx.js} +1 -1
- package/public/assets/{sequenceDiagram-FGHM5R23-C7OkYzUE.js → sequenceDiagram-FGHM5R23-BSK4jxQB.js} +2 -2
- package/public/assets/{shellscript-hSx0g1Ti.js → shellscript-B5RZ6Tk7.js} +1 -1
- package/public/assets/{shellscript-DRzhXImS.js → shellscript-C0Pd2SHP.js} +1 -1
- package/public/assets/{shellsession-BHTlD1yF.js → shellsession-Cu2ZtCV0.js} +1 -1
- package/public/assets/{shellsession-Io8M6QGP.js → shellsession-DSMfBdxp.js} +1 -1
- package/public/assets/si-LK-N5RQ5JYF-M5DVaWhp.js +1 -0
- package/public/assets/sk-SK-C5VTKIMK-D9ZLQfWn.js +6 -0
- package/public/assets/sl-SI-NN7IZMDC-Bxlmsjpq.js +6 -0
- package/public/assets/{soy-CIDHs7na.js → soy-DKGU1CbK.js} +1 -1
- package/public/assets/{soy-DHwKFEgu.js → soy-Hm0xWfOL.js} +1 -1
- package/public/assets/{sql-DMVX6MX3.js → sql-Bk8ZwAyn.js} +1 -1
- package/public/assets/{sql-qvgMKpnj.js → sql-DLggO0Nj.js} +1 -1
- package/public/assets/{src-TNZsktvB.js → src-DEzQF-Xc.js} +1 -1
- package/public/assets/{stata-DyQu-ySg.js → stata-BL8yDqic.js} +1 -1
- package/public/assets/{stata-BNwBZFqT.js → stata-C9dv2tS6.js} +1 -1
- package/public/assets/stateDiagram-FHFEXIEX-CF__r1FS.js +1 -0
- package/public/assets/stateDiagram-v2-QKLJ7IA2-CTaYljGy.js +1 -0
- package/public/assets/subset-shared.chunk-1xFsF_5Y.js +1 -0
- package/public/assets/subset-worker.chunk-DUh4TQ15.js +1 -0
- package/public/assets/{surrealql-DkwvWC9A.js → surrealql-4QrhEPcp.js} +1 -1
- package/public/assets/{surrealql-CJ7wcxeG.js → surrealql-D_oI8Fdv.js} +1 -1
- package/public/assets/sv-SE-XGPEYMSR-BjmoYeta.js +10 -0
- package/public/assets/{svelte-DoDXxVEu.js → svelte-CCJy2Qqx.js} +1 -1
- package/public/assets/{svelte-lCCp4xuq.js → svelte-DXpJC-4k.js} +1 -1
- package/public/assets/ta-IN-2NMHFXQM-09poAzNq.js +9 -0
- package/public/assets/{templ-DaphOiR9.js → templ-BVl0Bk4o.js} +1 -1
- package/public/assets/{templ-Z4ngS9DD.js → templ-D_3Tz_dc.js} +1 -1
- package/public/assets/{tex-BSONQkvo.js → tex-95EoF-Kp.js} +1 -1
- package/public/assets/{tex-KFYNCf4G.js → tex-C30sC1kD.js} +1 -1
- package/public/assets/th-TH-HPSO5L25-nZve-9bk.js +2 -0
- package/public/assets/{timeline-definition-GMOUNBTQ-2dfNeneI.js → timeline-definition-GMOUNBTQ-PQmHOvTQ.js} +1 -1
- package/public/assets/tr-TR-DEFEU3FU-CCapu8i5.js +7 -0
- package/public/assets/treeView-SZITEDCU-B3Z7Q2r-.js +1 -0
- package/public/assets/treemap-W4RFUUIX-CkYHLHQz.js +1 -0
- package/public/assets/{ts-tags-_t2nGkgg.js → ts-tags-3hbvPxqg.js} +1 -1
- package/public/assets/{ts-tags-CGd_sYNe.js → ts-tags-D66eKyQo.js} +1 -1
- package/public/assets/{tsx-s_MIJXvc.js → tsx-DdW_dHCB.js} +1 -1
- package/public/assets/{tsx-xu3XYmnx.js → tsx-DwlZc6_Q.js} +1 -1
- package/public/assets/{twig-BHQiwQ5C.js → twig-DUPDR3-4.js} +1 -1
- package/public/assets/{twig-CJ0Icv_c.js → twig-DzW_sJWN.js} +1 -1
- package/public/assets/{typescript-CCGrjcQk.js → typescript-Ciy0DLcG.js} +1 -1
- package/public/assets/{typescript-DN8a22JG.js → typescript-DCuML655.js} +1 -1
- package/public/assets/uk-UA-QMV73CPH-DDPMXs9n.js +6 -0
- package/public/assets/{vennDiagram-DHZGUBPP-5TPxF76y.js → vennDiagram-DHZGUBPP-BKKZxb8t.js} +1 -1
- package/public/assets/vi-VN-M7AON7JQ-Db_NuxeD.js +5 -0
- package/public/assets/{vue-LK1PrwQB.js → vue-BCfRvEeh.js} +1 -1
- package/public/assets/{vue-CPy56RG2.js → vue-CuoTZdx9.js} +1 -1
- package/public/assets/{vue-html-DHOxjS-u.js → vue-html-CDUqoBuq.js} +1 -1
- package/public/assets/{vue-html-DtXwCILZ.js → vue-html-Hk8W1G1O.js} +1 -1
- package/public/assets/{vue-vine-CFpVyOJ3.js → vue-vine-BQ4D8Gb4.js} +1 -1
- package/public/assets/{vue-vine-C3waRCf0.js → vue-vine-CBUEkRxV.js} +1 -1
- package/public/assets/wardley-RL74JXVD-DwJKtGnx.js +1 -0
- package/public/assets/{wardleyDiagram-NUSXRM2D-DcXT0o1B.js → wardleyDiagram-NUSXRM2D-BwMOKkpM.js} +1 -1
- package/public/assets/{xml-DNfslw6j.js → xml-CaY59JGw.js} +1 -1
- package/public/assets/{xml-smjIOBHl.js → xml-CwUWkS0w.js} +1 -1
- package/public/assets/{xsl-B6AUFcEQ.js → xsl-B2s0V2KB.js} +1 -1
- package/public/assets/{xsl-BN0HyQy2.js → xsl-ZJXPl2Yd.js} +1 -1
- package/public/assets/{xychartDiagram-5P7HB3ND-DTAQWuSG.js → xychartDiagram-5P7HB3ND-DVsnXqW_.js} +1 -1
- package/public/assets/{yaml-Dz23M7IW.js → yaml-Bm2zdT8j.js} +1 -1
- package/public/assets/{yaml-Ifzv9Z4U.js → yaml-DiaFUrac.js} +1 -1
- package/public/assets/zh-CN-LNUGB5OW-OgXhNNDt.js +10 -0
- package/public/assets/zh-HK-E62DVLB3-DnB5sd3Z.js +1 -0
- package/public/assets/zh-TW-RAJ6MFWO-CGNGxCX-.js +9 -0
- package/public/index.html +17 -15
- package/public/assets/DebugDrawer-DA-24RgO.js +0 -1
- package/public/assets/architecture-YZFGNWBL-lFW39zLt.js +0 -1
- package/public/assets/bundle-mjs-Q1vXGOKi.js +0 -1
- package/public/assets/channel-D_4OJX-I.js +0 -1
- package/public/assets/chunk-QZHKN3VN-CkjFCxg4.js +0 -1
- package/public/assets/classDiagram-6PBFFD2Q-DDHwE6EX.js +0 -1
- package/public/assets/classDiagram-v2-HSJHXN6E-DDHwE6EX.js +0 -1
- package/public/assets/clone-D25SuTm_.js +0 -1
- package/public/assets/createLucideIcon-B3CaPkua.js +0 -41
- package/public/assets/dagre-KV5264BT-Bqajq4-L.js +0 -4
- package/public/assets/gitGraph-7Q5UKJZL-puDJfp6Y.js +0 -1
- package/public/assets/highlighted-body-OFNGDK62-DM1CMHZp.js +0 -1
- package/public/assets/index-BDGnMcme.js +0 -870
- package/public/assets/info-OMHHGYJF-C4irAYLz.js +0 -1
- package/public/assets/mermaid-GHXKKRXX-DY_qvJvU.js +0 -1
- package/public/assets/packet-4T2RLAQJ-AJn7Lb8K.js +0 -1
- package/public/assets/pie-ZZUOXDRM-2Nexbs1C.js +0 -1
- package/public/assets/radar-PYXPWWZC-DN-EZ75V.js +0 -1
- package/public/assets/stateDiagram-FHFEXIEX-C4JrT4f3.js +0 -1
- package/public/assets/stateDiagram-v2-QKLJ7IA2-CcdPpnw2.js +0 -1
- package/public/assets/treeView-SZITEDCU-Dxq0LJ7f.js +0 -1
- package/public/assets/treemap-W4RFUUIX-DrJ-Azpw.js +0 -1
- package/public/assets/wardley-RL74JXVD-CQQOGmSa.js +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ar-SA-G6X2FPQ2-Cb41YiB7.js","assets/chunk-SRAX5OIU-QXaHHJU-.js","assets/rolldown-runtime-BG2f4sTM.js","assets/az-AZ-76LH7QW2-CnfWZeUk.js","assets/bg-BG-XCXSNQG7-Cl45RwQy.js","assets/bn-BD-2XOGV67Q-ClQx2pnI.js","assets/ca-ES-6MX7JW3Y-B70Lf-H_.js","assets/cs-CZ-2BRQDIVT-CK-m8a6b.js","assets/da-DK-5WZEPLOC-B_630tmB.js","assets/de-DE-XR44H4JA-DtdQNPIr.js","assets/el-GR-BZB4AONW-BhrdBtxp.js","assets/en-B4ZKOASM-BNPKUPIM.js","assets/chunk-6U3AYISY-C6-Mtja1.js","assets/es-ES-U4NZUMDT-BVdRn_Jk.js","assets/eu-ES-A7QVB2H4-tW-JN7p8.js","assets/fa-IR-HGAKTJCU-BZyMSjbe.js","assets/fi-FI-Z5N7JZ37-DzRBXsPy.js","assets/fr-FR-RHASNOE6-DEodF8O6.js","assets/gl-ES-HMX3MZ6V-Du5pFjOW.js","assets/he-IL-6SHJWFNN-D9GHex1S.js","assets/hi-IN-IWLTKZ5I-DnqTYaZL.js","assets/hu-HU-A5ZG7DT2-BYOpW44D.js","assets/id-ID-SAP4L64H-DfY6GEBJ.js","assets/it-IT-JPQ66NNP-C8bnB-BP.js","assets/ja-JP-DBVTYXUO-CXnZ_q5a.js","assets/kaa-6HZHGXH3-DDaHm4rV.js","assets/kab-KAB-ZGHBKWFO-DBB61TA4.js","assets/kk-KZ-P5N5QNE5-nJujjHZU.js","assets/km-KH-HSX4SM5Z-BTbPrn7C.js","assets/ko-KR-MTYHY66A-DY7N8FkC.js","assets/ku-TR-6OUDTVRD-CWiwUq7W.js","assets/lt-LT-XHIRWOB4-D5iGl8SA.js","assets/lv-LV-5QDEKY6T-Dk5tYd5b.js","assets/mr-IN-CRQNXWMA-C3V-9EA3.js","assets/my-MM-5M5IBNSE-BkC0s2uK.js","assets/nb-NO-T6EIAALU-DVr77Juq.js","assets/nl-NL-IS3SIHDZ-B9zaDsWm.js","assets/nn-NO-6E72VCQL-TxuzXJMr.js","assets/oc-FR-POXYY2M6-Du5tRkPK.js","assets/pa-IN-N4M65BXN-Ducc8ihq.js","assets/percentages-BXMCSKIN-BzbvNGT_.js","assets/chunk-Z3N5DIM6-D9TMVU7m.js","assets/pl-PL-T2D74RX3-2GqH9xC0.js","assets/pt-BR-5N22H2LF-CZaLZGo4.js","assets/pt-PT-UZXXM6DQ-CZ_1UJI0.js","assets/ro-RO-JPDTUUEW-BP6wu9nV.js","assets/ru-RU-B4JR7IUQ-Bi4CkeXg.js","assets/si-LK-N5RQ5JYF-M5DVaWhp.js","assets/sk-SK-C5VTKIMK-D9ZLQfWn.js","assets/sl-SI-NN7IZMDC-Bxlmsjpq.js","assets/sv-SE-XGPEYMSR-BjmoYeta.js","assets/ta-IN-2NMHFXQM-09poAzNq.js","assets/th-TH-HPSO5L25-nZve-9bk.js","assets/tr-TR-DEFEU3FU-CCapu8i5.js","assets/uk-UA-QMV73CPH-DDPMXs9n.js","assets/vi-VN-M7AON7JQ-Db_NuxeD.js","assets/zh-CN-LNUGB5OW-OgXhNNDt.js","assets/zh-HK-E62DVLB3-DnB5sd3Z.js","assets/zh-TW-RAJ6MFWO-CGNGxCX-.js","assets/image-GAAHSSAO-C7O7NdjH.js","assets/chunk-K2UTITRG-CrL9EuZD.js","assets/jsx-runtime-CC-kRuLe.js","assets/preload-helper-CZgWQFsJ.js","assets/chunk-ZUYEQ4TG-BzFOpW--.js","assets/dist-DAGGreTm.js","assets/index-Bp2DjxBi.js","assets/bundle-mjs-waAbs7aL.js","assets/createLucideIcon-BpL36Utr.js","assets/src-DEzQF-Xc.js","assets/chunk-ICPOFSXX-CbeWjtve.js","assets/chunk-5PVQY5BW-PKb2UfEn.js","assets/dist-shQtHlo7.js","assets/identity-Co3Kha3t.js","assets/chunk-BSJP7CBP-kQ7Calqs.js","assets/chunk-ZZ45TVLE-CCEhJUTd.js","assets/chunk-X2U36JSP-CJWDEMsp.js","assets/chunk-U2HBQHQK-CdUtCuol.js","assets/chunk-5FUZZQ4R-DFs5M0VY.js","assets/rough.esm-CSKSodPl.js","assets/chunk-ENJZ2VHE-B19bR_UY.js","assets/line-CR3tMWzH.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/index-C44hLTZz.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as e,t}from"./rolldown-runtime-BG2f4sTM.js";import{n,t as r}from"./jsx-runtime-CC-kRuLe.js";import{r as i}from"./bundle-mjs-waAbs7aL.js";import{At as a,Gt as o,Ht as s,Jt as c,Kt as l,Ot as u,Rt as d,Ut as f,Vt as p,Wt as m,Yt as h,qt as g,zt as _}from"./createLucideIcon-BpL36Utr.js";import{t as v}from"./preload-helper-CZgWQFsJ.js";import{T as y,a as b,i as x,n as S,o as ee,r as te,t as ne,w as re}from"./index-Bp2DjxBi.js";import{t as C}from"./chunk-ZUYEQ4TG-BzFOpW--.js";import{i as w,n as ie,r as ae}from"./chunk-SRAX5OIU-QXaHHJU-.js";import{$ as oe,$a as se,$c as ce,$i as T,$l as le,$n as ue,$o as de,$r as fe,$s as pe,$t as me,A as he,Ac as ge,Ai as _e,Al as ve,An as ye,Ao as be,Ar as xe,As as Se,At as Ce,Au as we,B as Te,Bc as Ee,Bi as De,Bl as Oe,Bn as ke,Bo as Ae,Br as je,Bs as Me,Bt as Ne,Bu as Pe,C as Fe,Ca as Ie,Cc as Le,Ci as Re,Cl as ze,Cn as Be,Co as Ve,Cr as He,Cs as Ue,Ct as We,D as Ge,Da as Ke,Dc as qe,Di as Je,Dl as E,Dn as Ye,Do as D,Dr as Xe,Ds as Ze,Dt as Qe,Du as $e,E as et,Ea as tt,Ec as nt,Ei as rt,El as it,En as at,Eo as ot,Er as st,Es as ct,Et as lt,Eu as ut,F as dt,Fa as ft,Fc as pt,Fi as mt,Fl as O,Fn as ht,Fo as gt,Fr as _t,Fs as vt,Ft as yt,Fu as bt,G as k,Ga as xt,Gc as St,Gi as Ct,Gl as wt,Gn as Tt,Go as Et,Gr as Dt,Gs as Ot,Gt as kt,Gu as At,H as jt,Ha as Mt,Hc as Nt,Hi as Pt,Hl as Ft,Hn as It,Ho as Lt,Hr as Rt,Hs as zt,Ht as A,Hu as Bt,I as Vt,Ia as Ht,Ic as Ut,Ii as Wt,Il as Gt,In as Kt,Io as qt,Ir as Jt,Is as Yt,It as Xt,Iu as Zt,J as Qt,Ja as $t,Jc as en,Ji as tn,Jl as nn,Jn as rn,Jo as an,Jr as on,Js as j,Jt as sn,K as cn,Ka as ln,Kc as un,Ki as dn,Kl as fn,Kn as pn,Ko as mn,Kr as hn,Ks as gn,Kt as _n,Ku as vn,L as yn,La as bn,Lc as xn,Li as Sn,Ll as Cn,Ln as wn,Lo as Tn,Lr as En,Ls as Dn,Lt as On,Lu as kn,M as An,Ma as jn,Mc as Mn,Mi as Nn,Ml as Pn,Mn as Fn,Mo as M,Mr as In,Ms as Ln,Mt as Rn,Mu as N,N as zn,Na as Bn,Nc as Vn,Ni as Hn,Nl as Un,Nn as P,No as Wn,Nr as Gn,Ns as Kn,Nt as qn,Nu as Jn,O as Yn,Oa as Xn,Oc as Zn,Oi as Qn,Ol as $n,On as er,Oo as tr,Or as nr,Ot as rr,Ou as ir,P as ar,Pa as or,Pc as sr,Pi as cr,Pl as lr,Pn as ur,Po as dr,Pr as fr,Ps as pr,Pt as mr,Pu as hr,Q as gr,Qa as _r,Qc as vr,Qi as yr,Ql as br,Qn as xr,Qo as Sr,Qr as Cr,Qs as wr,Qt as Tr,R as Er,Ra as Dr,Rc as Or,Ri as kr,Rl as Ar,Rn as jr,Ro as Mr,Rr as F,Rs as Nr,Rt as Pr,Ru as Fr,S as Ir,Sa as Lr,Sc as Rr,Si as zr,Sl as Br,Sn as Vr,So as Hr,Sr as Ur,Ss as Wr,St as Gr,Su as Kr,T as qr,Ta as Jr,Tc as Yr,Ti as Xr,Tl as Zr,Tn as Qr,To as $r,Tr as ei,Ts as ti,Tt as ni,Tu as ri,U as ii,Ua as ai,Uc as oi,Ui as si,Ul as ci,Un as li,Uo as ui,Ur as di,Us as fi,Ut as pi,Uu as I,V as mi,Va as hi,Vc as gi,Vi as _i,Vl as vi,Vn as yi,Vo as bi,Vr as xi,Vs as Si,Vt as Ci,Vu as wi,W as Ti,Wa as Ei,Wc as Di,Wi as Oi,Wl as ki,Wn as Ai,Wo as ji,Wr as Mi,Ws as L,Wt as Ni,Wu as Pi,X as Fi,Xa as Ii,Xc as Li,Xi as Ri,Xl as zi,Xn as Bi,Xo as Vi,Xr as Hi,Xs as Ui,Xt as Wi,Y as Gi,Ya as Ki,Yc as qi,Yi as Ji,Yn as Yi,Yo as Xi,Yr as Zi,Ys as Qi,Yt as $i,Z as ea,Za as R,Zc as ta,Zi as na,Zl as ra,Zn as ia,Zo as aa,Zr as oa,Zs as sa,Zt as ca,_ as la,_a as ua,_c as da,_i as fa,_l as pa,_n as ma,_o as ha,_r as ga,_s as _a,_t as va,_u as ya,a as ba,aa as xa,ac as Sa,ai as Ca,al as wa,an as Ta,ao as Ea,ar as Da,as as Oa,at as ka,au as Aa,b as ja,ba as Ma,bc as Na,bi as Pa,bl as Fa,bn as Ia,bo as La,br as Ra,bs as za,bt as Ba,bu as Va,c as Ha,ca as Ua,cc as Wa,ci as Ga,cl as Ka,cn as qa,co as Ja,cr as Ya,cs as Xa,ct as Za,cu as Qa,d as $a,da as eo,dc as to,di as no,dl as ro,dn as z,do as io,dr as ao,ds as oo,dt as so,du as co,ea as lo,ec as uo,ei as fo,el as po,en as mo,eo as ho,er as go,es as _o,et as vo,eu as yo,f as bo,fa as xo,fc as So,fi as Co,fl as wo,fn as To,fo as Eo,fr as Do,fs as Oo,ft as ko,fu as Ao,g as jo,ga as Mo,gc as No,gi as Po,gl as Fo,gn as Io,go as B,gr as Lo,gs as Ro,gt as zo,gu as Bo,h as Vo,ha as Ho,hc as Uo,hi as Wo,hl as Go,hn as Ko,ho as qo,hr as Jo,hs as Yo,ht as V,hu as Xo,i as Zo,ia as Qo,ic as $o,ii as es,il as ts,in as ns,io as rs,ir as is,is as as,it as os,iu as ss,j as cs,ja as ls,jc as us,ji as ds,jl as fs,jn as ps,jo as ms,jr as hs,js as gs,jt as _s,ju as vs,k as ys,ka as bs,kc as xs,ki as Ss,kl as Cs,kn as ws,ko as Ts,kr as Es,ks as Ds,kt as Os,ku as ks,l as As,la as js,lc as Ms,li as Ns,ll as Ps,ln as Fs,lo as Is,lr as Ls,ls as Rs,lt as zs,lu as Bs,m as Vs,ma as Hs,mc as Us,mi as Ws,ml as Gs,mn as Ks,mo as qs,mr as Js,ms as Ys,mt as Xs,mu as Zs,na as Qs,nc as $s,ni as ec,nl as tc,nn as nc,no as rc,nr as ic,ns as ac,nt as oc,nu as H,o as sc,oa as cc,oc as lc,oi as uc,ol as dc,on as fc,oo as pc,or as mc,os as hc,ot as gc,ou as _c,p as vc,pa as yc,pc as bc,pi as xc,pl as Sc,pn as Cc,po as wc,pr as Tc,ps as Ec,pt as Dc,pu as Oc,q as kc,qa as Ac,qc as jc,qi as Mc,ql as Nc,qn as Pc,qo as Fc,qr as Ic,qs as Lc,qt as Rc,qu as zc,r as Bc,ra as Vc,rc as Hc,ri as Uc,rl as Wc,rn as Gc,ro as Kc,rr as qc,rs as Jc,rt as Yc,ru as Xc,s as Zc,sa as Qc,sc as $c,si as el,sl as tl,sn as nl,so as rl,sr as il,ss as al,st as ol,su as sl,t as cl,tc as ll,ti as ul,tl as dl,tn as fl,to as pl,tr as ml,ts as hl,tt as gl,tu as _l,u as vl,ua as U,uc as yl,ui as bl,ul as xl,un as Sl,uo as Cl,ur as wl,us as Tl,ut as El,uu as Dl,v as Ol,va as kl,vc as Al,vi as jl,vl as Ml,vn as Nl,vo as Pl,vr as Fl,vs as Il,vt as Ll,vu as Rl,wa as zl,wc as Bl,wi as Vl,wl as Hl,wn as Ul,wo as Wl,wr as Gl,ws as Kl,wt as ql,wu as Jl,x as Yl,xa as Xl,xc as Zl,xi as Ql,xl as $l,xn as eu,xo as tu,xr as nu,xs as ru,xt as iu,xu as au,y as ou,ya as su,yc as W,yi as cu,yl as lu,yn as uu,yo as du,yr as fu,ys as pu,yu as mu,z as hu,za as gu,zc as _u,zi as vu,zl as yu,zn as bu,zo as xu,zr as Su,zs as Cu,zt as wu,zu as Tu}from"./chunk-K2UTITRG-CrL9EuZD.js";import{n as Eu}from"./chunk-6U3AYISY-C6-Mtja1.js";import{t as Du}from"./chunk-Z3N5DIM6-D9TMVU7m.js";var G=e(n(),1),K=e(r()),Ou=0;function ku(e,t){let n=`atom${++Ou}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=Au,r.write=ju),t&&(r.write=t),r}function Au(e){return e(this)}function ju(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}var Mu=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,Nu=e=>`init`in e,Pu=e=>!!e.write,Fu=new WeakMap,Iu=e=>zu(e)&&!Fu.get(e)?.[1],Lu=(e,t)=>{let n=Fu.get(e);n&&(n[1]=!0,n[0].forEach(e=>e(t)))},Ru=e=>{if(Fu.has(e))return;let t=[new Set,!1];Fu.set(e,t);let n=()=>{t[1]=!0};e.then(n,n),e.onCancel=e=>{t[0].add(e)}},zu=e=>typeof e?.then==`function`,Bu=e=>`v`in e||`e`in e,Vu=e=>{if(`e`in e)throw e.e;return e.v},Hu=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},Uu=(e,t,n,r,i)=>{var a;n.d.set(r,i.n),Iu(n.v)&&Hu(t,n.v,i),(a=i.m)==null||a.t.add(t),e&&qu(e,r,t)},Wu=()=>({D:new Map,H:new Set,M:new Set,L:new Set}),Gu=(e,t,n)=>{e[t].add(n)},Ku=(e,t,n)=>{e.D.has(t)||(e.D.set(t,new Set),Gu(e,`M`,()=>{var t;(t=n.m)==null||t.l.forEach(t=>Gu(e,`M`,t))}))},qu=(e,t,n)=>{let r=e.D.get(t);r&&r.add(n)},Ju=(e,t)=>e.D.get(t),Yu=e=>{let t,n=!1,r=e=>{try{e()}catch(e){n||=(t=e,!0)}};for(;e.H.size||e.M.size||e.L.size;)e.D.clear(),e.H.forEach(r),e.H.clear(),e.M.forEach(r),e.M.clear(),e.L.forEach(r),e.L.clear();if(n)throw t},Xu=(...[e,t,n,r])=>{let i=(t,n,r)=>{let i=`v`in n,a=n.v,o=Iu(n.v)?n.v:null;if(zu(r)){Ru(r);for(let i of n.d.keys())Hu(t,r,e(i));n.v=r}else n.v=r;delete n.e,delete n.x,(!i||!Object.is(a,n.v))&&(++n.n,o&&Lu(o,r))},a=(n,r)=>{var o;let s=e(r);if(Bu(s)&&(s.m&&!s.x||Array.from(s.d).every(([e,t])=>a(n,e).n===t)))return s;s.d.clear();let c=!0,l=t=>{if(Mu(r,t)){let n=e(t);if(!Bu(n))if(Nu(t))i(t,n,t.init);else throw Error(`no atom init`);return Vu(n)}let o=a(n,t);try{return Vu(o)}finally{if(c)Uu(n,r,s,t,o);else{let e=Wu();Uu(e,r,s,t,o),d(e,r,s),Yu(e)}}},f,p,m={get signal(){return f||=new AbortController,f.signal},get setSelf(){return!p&&Pu(r)&&(p=(...e)=>{if(!c)return u(r,...e)}),p}};try{let e=t(r,l,m);if(i(r,s,e),zu(e)){(o=e.onCancel)==null||o.call(e,()=>f?.abort());let t=()=>{if(s.m){let e=Wu();d(e,r,s),Yu(e)}};e.then(t,t)}return s}catch(e){return delete s.v,s.e=e,delete s.x,++s.n,s}finally{c=!1}},o=e=>Vu(a(void 0,e)),s=(t,n,r)=>{var i;let a=new Map;for(let t of r.m?.t||[]){let n=e(t);n.m&&a.set(t,n)}for(let t of r.p)a.set(t,e(t));return(i=Ju(t,n))==null||i.forEach(t=>{a.set(t,e(t))}),a},c=(e,t,n)=>{let r=[],i=new Set,o=new Set,c=[[t,n]];for(;c.length>0;){let[t,n]=c[c.length-1];if(o.has(t)){c.pop();continue}if(i.has(t)){r.push([t,n,n.n]),o.add(t),n.x=!0,c.pop();continue}i.add(t);for(let[r,a]of s(e,t,n))t!==r&&!i.has(r)&&c.push([r,a])}Gu(e,`H`,()=>{let n=new Set([t]);for(let t=r.length-1;t>=0;--t){let[i,o,s]=r[t],c=!1;for(let e of o.d.keys())if(e!==i&&n.has(e)){c=!0;break}c&&(a(e,i),d(e,i,o),s!==o.n&&(Ku(e,i,o),n.add(i))),delete o.x}})},l=(t,r,...o)=>{let s=!0,u=e=>Vu(a(t,e)),f=(n,...a)=>{let o=e(n);try{if(Mu(r,n)){if(!Nu(n))throw Error(`atom not writable`);let e=o.n,r=a[0];i(n,o,r),d(t,n,o),e!==o.n&&(Ku(t,n,o),c(t,n,o));return}else return l(t,n,...a)}finally{s||Yu(t)}};try{return n(r,u,f,...o)}finally{s=!1}},u=(e,...t)=>{let n=Wu();try{return l(n,e,...t)}finally{Yu(n)}},d=(t,n,r)=>{if(r.m&&!Iu(r.v)){for(let i of r.d.keys())r.m.d.has(i)||(f(t,i,e(i)).t.add(n),r.m.d.add(i));for(let i of r.m.d||[])r.d.has(i)||(r.m.d.delete(i),p(t,i,e(i))?.t.delete(n))}},f=(t,n,i)=>{if(!i.m){a(t,n);for(let r of i.d.keys())f(t,r,e(r)).t.add(n);if(i.m={l:new Set,d:new Set(i.d.keys()),t:new Set},Pu(n)){let e=i.m,a,o=(e,t)=>{let r=!0;a=(...t)=>{try{return l(e,n,...t)}finally{r||Yu(e)}};try{return t()}finally{r=!1}};Gu(t,`L`,()=>{let i=o(t,()=>r(n,(...e)=>a(...e)));i&&(e.u=e=>o(e,i))})}}return i.m},p=(t,n,r)=>{if(r.m&&!r.m.l.size&&!Array.from(r.m.t).some(t=>e(t).m?.d.has(n))){let i=r.m.u;i&&Gu(t,`L`,()=>i(t)),delete r.m;for(let i of r.d.keys())p(t,i,e(i))?.t.delete(n);return}return r.m};return{get:o,set:u,sub:(t,n)=>{let r=Wu(),i=e(t),a=f(r,t,i).l;return a.add(n),Yu(r),()=>{a.delete(n);let e=Wu();p(e,t,i),Yu(e)}},unstable_derive:i=>Xu(...i(e,t,n,r))}},Zu=()=>{let e=new WeakMap;return Xu(t=>{let n=e.get(t);return n||(n={d:new Map,p:new Set,n:0},e.set(t,n)),n},(e,...t)=>e.read(...t),(e,...t)=>e.write(...t),(e,...t)=>e.onMount?.call(e,...t))},Qu,$u=()=>(Qu||=Zu(),Qu),ed=(0,G.createContext)(void 0),td=e=>{let t=(0,G.useContext)(ed);return e?.store||t||$u()},nd=e=>typeof e?.then==`function`,rd=e=>{e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t})},id=G.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(rd(e),e)}),ad=new WeakMap,od=e=>{let t=ad.get(e);return t||(t=new Promise((n,r)=>{let i=e,a=e=>t=>{i===e&&n(t)},o=e=>t=>{i===e&&r(t)},s=e=>{`onCancel`in e&&typeof e.onCancel==`function`&&e.onCancel(e=>{nd(e)?(ad.set(e,t),i=e,e.then(a(e),o(e)),s(e)):n(e)})};e.then(a(e),o(e)),s(e)}),ad.set(e,t)),t};function sd(e,t){let n=td(t),[[r,i,a],o]=(0,G.useReducer)(t=>{let r=n.get(e);return Object.is(t[0],r)&&t[1]===n&&t[2]===e?t:[r,n,e]},void 0,()=>[n.get(e),n,e]),s=r;(i!==n||a!==e)&&(o(),s=n.get(e));let c=t?.delay;return(0,G.useEffect)(()=>{let t=n.sub(e,()=>{if(typeof c==`number`){let t=n.get(e);nd(t)&&rd(od(t)),setTimeout(o,c);return}o()});return o(),t},[n,e,c]),(0,G.useDebugValue)(s),nd(s)?id(od(s)):s}function cd(e,t){let n=td(t);return(0,G.useCallback)((...t)=>n.set(e,...t),[n,e])}function ld(e,t){return[sd(e,t),cd(e,t)]}var ud=new WeakMap;function dd(e,t){let n=td(t),r=fd(n);for(let[i,a]of e)(!r.has(i)||t?.dangerouslyForceHydrate)&&(r.add(i),n.set(i,a))}var fd=e=>{let t=ud.get(e);return t||(t=new WeakSet,ud.set(e,t)),t};function pd(){return pd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pd.apply(this,arguments)}function md(){let e=(0,G.createContext)(null);function t({store:t,initialValues:n=[],children:r}){let i=(0,G.useRef)(t);return i.current||=Zu(),dd(n,{store:i.current}),(0,K.jsx)(e.Provider,{value:i.current,children:r})}let n=t=>{let n=(0,G.useContext)(e);if(!n)throw Error(`Missing Provider from createIsolation`);return td(pd({store:n},t))};return{Provider:t,useStore:n,useAtom:(e,t)=>{let r=n();return ld(e,pd({store:r},t))},useAtomValue:(e,t)=>{let r=n();return sd(e,pd({store:r},t))},useSetAtom:(e,t)=>{let r=n();return cd(e,pd({store:r},t))}}}var{read:hd,write:gd}=ku(null);(0,G.createContext)({scope:void 0,baseStore:void 0});var _d=e(i(),1);function vd(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function yd(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function bd(...e){return t=>{let n=!1,r=e.map(e=>{let r=yd(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():yd(e[t],null)}}}}function xd(...e){return G.useCallback(bd(...e),e)}function Sd(e,t=[]){let n=[];function r(t,r){let i=G.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=G.useMemo(()=>o,Object.values(o));return(0,K.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=G.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>G.createContext(e));return function(n){let r=n?.[e]||t;return G.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Cd(i,...t)]}function Cd(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return G.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var wd=G.forwardRef((e,t)=>{let{children:n,...r}=e,i=G.Children.toArray(n),a=i.find(Dd);if(a){let e=a.props.children,n=i.map(t=>t===a?G.Children.count(e)>1?G.Children.only(null):G.isValidElement(e)?e.props.children:null:t);return(0,K.jsx)(Td,{...r,ref:t,children:G.isValidElement(e)?G.cloneElement(e,void 0,n):null})}return(0,K.jsx)(Td,{...r,ref:t,children:n})});wd.displayName=`Slot`;var Td=G.forwardRef((e,t)=>{let{children:n,...r}=e;if(G.isValidElement(n)){let e=kd(n),i=Od(r,n.props);return n.type!==G.Fragment&&(i.ref=t?bd(t,e):e),G.cloneElement(n,i)}return G.Children.count(n)>1?G.Children.only(null):null});Td.displayName=`SlotClone`;var Ed=({children:e})=>(0,K.jsx)(K.Fragment,{children:e});function Dd(e){return G.isValidElement(e)&&e.type===Ed}function Od(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function kd(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Ad=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=G.forwardRef((e,n)=>{let{asChild:r,...i}=e,a=r?wd:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,K.jsx)(a,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function jd(e,t){e&&_d.flushSync(()=>e.dispatchEvent(t))}function Md(e){let t=G.useRef(e);return G.useEffect(()=>{t.current=e}),G.useMemo(()=>(...e)=>t.current?.(...e),[])}function Nd(e,t=globalThis?.document){let n=Md(e);G.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Pd=`DismissableLayer`,Fd=`dismissableLayer.update`,Id=`dismissableLayer.pointerDownOutside`,Ld=`dismissableLayer.focusOutside`,Rd,zd=G.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bd=G.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=G.useContext(zd),[u,d]=G.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=G.useState({}),m=xd(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=Ud(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=Wd(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Nd(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),G.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Rd=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Gd(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Rd)}},[u,f,n,l]),G.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Gd())},[u,l]),G.useEffect(()=>{let e=()=>p({});return document.addEventListener(Fd,e),()=>document.removeEventListener(Fd,e)},[]),(0,K.jsx)(Ad.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:vd(e.onFocusCapture,S.onFocusCapture),onBlurCapture:vd(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:vd(e.onPointerDownCapture,x.onPointerDownCapture)})});Bd.displayName=Pd;var Vd=`DismissableLayerBranch`,Hd=G.forwardRef((e,t)=>{let n=G.useContext(zd),r=G.useRef(null),i=xd(t,r);return G.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,K.jsx)(Ad.div,{...e,ref:i})});Hd.displayName=Vd;function Ud(e,t=globalThis?.document){let n=Md(e),r=G.useRef(!1),i=G.useRef(()=>{});return G.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Kd(Id,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Wd(e,t=globalThis?.document){let n=Md(e),r=G.useRef(!1);return G.useEffect(()=>{let e=e=>{e.target&&!r.current&&Kd(Ld,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Gd(){let e=new CustomEvent(Fd);document.dispatchEvent(e)}function Kd(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?jd(i,a):i.dispatchEvent(a)}var qd=0;function Jd(){G.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Yd()),document.body.insertAdjacentElement(`beforeend`,e[1]??Yd()),qd++,()=>{qd===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),qd--}},[])}function Yd(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Xd=`focusScope.autoFocusOnMount`,Zd=`focusScope.autoFocusOnUnmount`,Qd={bubbles:!1,cancelable:!0},$d=`FocusScope`,ef=G.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=G.useState(null),l=Md(i),u=Md(a),d=G.useRef(null),f=xd(t,e=>c(e)),p=G.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;G.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:cf(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||cf(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&cf(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),G.useEffect(()=>{if(s){lf.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Xd,Qd);s.addEventListener(Xd,l),s.dispatchEvent(t),t.defaultPrevented||(tf(ff(rf(s)),{select:!0}),document.activeElement===e&&cf(s))}return()=>{s.removeEventListener(Xd,l),setTimeout(()=>{let t=new CustomEvent(Zd,Qd);s.addEventListener(Zd,u),s.dispatchEvent(t),t.defaultPrevented||cf(e??document.body,{select:!0}),s.removeEventListener(Zd,u),lf.remove(p)},0)}}},[s,l,u,p]);let m=G.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=nf(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&cf(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&cf(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,K.jsx)(Ad.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});ef.displayName=$d;function tf(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(cf(r,{select:t}),document.activeElement!==n)return}function nf(e){let t=rf(e);return[af(t,e),af(t.reverse(),e)]}function rf(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function af(e,t){for(let n of e)if(!of(n,{upTo:t}))return n}function of(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function sf(e){return e instanceof HTMLInputElement&&`select`in e}function cf(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&sf(e)&&t&&e.select()}}var lf=uf();function uf(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=df(e,t),e.unshift(t)},remove(t){e=df(e,t),e[0]?.resume()}}}function df(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ff(e){return e.filter(e=>e.tagName!==`A`)}var pf=globalThis?.document?G.useLayoutEffect:()=>{},mf=G.useId||(()=>void 0),hf=0;function gf(e){let[t,n]=G.useState(mf());return pf(()=>{e||n(e=>e??String(hf++))},[e]),e||(t?`radix-${t}`:``)}var _f=`Arrow`,vf=G.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,K.jsx)(Ad.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,K.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});vf.displayName=_f;var yf=vf;function bf(e){let[t,n]=G.useState(void 0);return pf(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var xf=`Popper`,[Sf,Cf]=Sd(xf),[wf,Tf]=Sf(xf),Ef=e=>{let{__scopePopper:t,children:n}=e,[r,i]=G.useState(null);return(0,K.jsx)(wf,{scope:t,anchor:r,onAnchorChange:i,children:n})};Ef.displayName=xf;var Df=`PopperAnchor`,Of=G.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Tf(Df,n),o=G.useRef(null),s=xd(t,o);return G.useEffect(()=>{a.onAnchorChange(r?.current||o.current)}),r?null:(0,K.jsx)(Ad.div,{...i,ref:s})});Of.displayName=Df;var kf=`PopperContent`,[Af,jf]=Sf(kf),Mf=G.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:u=0,arrowPadding:d=0,avoidCollisions:_=!0,collisionBoundary:v=[],collisionPadding:y=0,sticky:b=`partial`,hideWhenDetached:x=!1,updatePositionStrategy:S=`optimized`,onPlaced:ee,...te}=e,ne=Tf(kf,n),[re,C]=G.useState(null),w=xd(t,e=>C(e)),[ie,ae]=G.useState(null),oe=bf(ie),se=oe?.width??0,ce=oe?.height??0,T=r+(a===`center`?``:`-`+a),le=typeof y==`number`?y:{top:0,right:0,bottom:0,left:0,...y},ue=Array.isArray(v)?v:[v],de=ue.length>0,fe={padding:le,boundary:ue.filter(If),altBoundary:de},{refs:pe,floatingStyles:me,placement:he,isPositioned:ge,middlewareData:_e}=c({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>h(...e,{animationFrame:S===`always`}),elements:{reference:ne.anchor},middleware:[o({mainAxis:i+ce,alignmentAxis:u}),_&&l({mainAxis:!0,crossAxis:!1,limiter:b===`partial`?m():void 0,...fe}),_&&s({...fe}),g({...fe,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),ie&&p({element:ie,padding:d}),Lf({arrowWidth:se,arrowHeight:ce}),x&&f({strategy:`referenceHidden`,...fe})]}),[ve,ye]=Rf(he),be=Md(ee);pf(()=>{ge&&be?.()},[ge,be]);let xe=_e.arrow?.x,Se=_e.arrow?.y,Ce=_e.arrow?.centerOffset!==0,[we,Te]=G.useState();return pf(()=>{re&&Te(window.getComputedStyle(re).zIndex)},[re]),(0,K.jsx)(`div`,{ref:pe.setFloating,"data-radix-popper-content-wrapper":``,style:{...me,transform:ge?me.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:we,"--radix-popper-transform-origin":[_e.transformOrigin?.x,_e.transformOrigin?.y].join(` `),..._e.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,K.jsx)(Af,{scope:n,placedSide:ve,onArrowChange:ae,arrowX:xe,arrowY:Se,shouldHideArrow:Ce,children:(0,K.jsx)(Ad.div,{"data-side":ve,"data-align":ye,...te,ref:w,style:{...te.style,animation:ge?void 0:`none`}})})})});Mf.displayName=kf;var Nf=`PopperArrow`,Pf={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Ff=G.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=jf(Nf,n),a=Pf[i.placedSide];return(0,K.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,K.jsx)(yf,{...r,ref:t,style:{...r.style,display:`block`}})})});Ff.displayName=Nf;function If(e){return e!==null}var Lf=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Rf(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Rf(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var zf=Ef,Bf=Of,Vf=Mf,Hf=Ff,Uf=`Portal`,Wf=G.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=G.useState(!1);pf(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?_d.createPortal((0,K.jsx)(Ad.div,{...r,ref:t}),o):null});Wf.displayName=Uf;function Gf(e,t){return G.useReducer((e,n)=>t[e][n]??e,e)}var Kf=e=>{let{present:t,children:n}=e,r=qf(t),i=typeof n==`function`?n({present:r.isPresent}):G.Children.only(n),a=xd(r.ref,Yf(i));return typeof n==`function`||r.isPresent?G.cloneElement(i,{ref:a}):null};Kf.displayName=`Presence`;function qf(e){let[t,n]=G.useState(),r=G.useRef({}),i=G.useRef(e),a=G.useRef(`none`),[o,s]=Gf(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return G.useEffect(()=>{let e=Jf(r.current);a.current=o===`mounted`?e:`none`},[o]),pf(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Jf(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),pf(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Jf(r.current).includes(a.animationName);if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=Jf(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:G.useCallback(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function Jf(e){return e?.animationName||`none`}function Yf(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Xf({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=Zf({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=Md(n);return[o,G.useCallback(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function Zf({defaultProp:e,onChange:t}){let n=G.useState(e),[r]=n,i=G.useRef(r),a=Md(t);return G.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var Qf=`Popover`,[$f,ep]=Sd(Qf,[Cf]),tp=Cf(),[np,rp]=$f(Qf),ip=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=tp(t),c=G.useRef(null),[l,u]=G.useState(!1),[d=!1,f]=Xf({prop:r,defaultProp:i,onChange:a});return(0,K.jsx)(zf,{...s,children:(0,K.jsx)(np,{scope:t,contentId:gf(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:G.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:G.useCallback(()=>u(!0),[]),onCustomAnchorRemove:G.useCallback(()=>u(!1),[]),modal:o,children:n})})};ip.displayName=Qf;var ap=`PopoverAnchor`,op=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=rp(ap,n),a=tp(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return G.useEffect(()=>(o(),()=>s()),[o,s]),(0,K.jsx)(Bf,{...a,...r,ref:t})});op.displayName=ap;var sp=`PopoverTrigger`,cp=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=rp(sp,n),a=tp(n),o=xd(t,i.triggerRef),s=(0,K.jsx)(Ad.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Sp(i.open),...r,ref:o,onClick:vd(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,K.jsx)(Bf,{asChild:!0,...a,children:s})});cp.displayName=sp;var lp=`PopoverPortal`,[up,dp]=$f(lp,{forceMount:void 0}),fp=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=rp(lp,t);return(0,K.jsx)(up,{scope:t,forceMount:n,children:(0,K.jsx)(Kf,{present:n||a.open,children:(0,K.jsx)(Wf,{asChild:!0,container:i,children:r})})})};fp.displayName=lp;var pp=`PopoverContent`,mp=G.forwardRef((e,t)=>{let n=dp(pp,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=rp(pp,e.__scopePopover);return(0,K.jsx)(Kf,{present:r||a.open,children:a.modal?(0,K.jsx)(hp,{...i,ref:t}):(0,K.jsx)(gp,{...i,ref:t})})});mp.displayName=pp;var hp=G.forwardRef((e,t)=>{let n=rp(pp,e.__scopePopover),r=G.useRef(null),i=xd(t,r),a=G.useRef(!1);return G.useEffect(()=>{let e=r.current;if(e)return d(e)},[]),(0,K.jsx)(_,{as:wd,allowPinchZoom:!0,children:(0,K.jsx)(_p,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:vd(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:vd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:vd(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),gp=G.forwardRef((e,t)=>{let n=rp(pp,e.__scopePopover),r=G.useRef(!1),i=G.useRef(!1);return(0,K.jsx)(_p,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),_p=G.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=rp(pp,n),p=tp(n);return Jd(),(0,K.jsx)(ef,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,K.jsx)(Bd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,K.jsx)(Vf,{"data-state":Sp(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),vp=`PopoverClose`,yp=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=rp(vp,n);return(0,K.jsx)(Ad.button,{type:`button`,...r,ref:t,onClick:vd(e.onClick,()=>i.onOpenChange(!1))})});yp.displayName=vp;var bp=`PopoverArrow`,xp=G.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=tp(n);return(0,K.jsx)(Hf,{...i,...r,ref:t})});xp.displayName=bp;function Sp(e){return e?`open`:`closed`}var Cp=ip,wp=cp,Tp=fp,Ep=mp,Dp=xp,Op=t(((e,t)=>{(function(){var n=this,r={};e===void 0?n.fuzzy=r:t.exports=r,r.simpleFilter=function(e,t){return t.filter(function(t){return r.test(e,t)})},r.test=function(e,t){return r.match(e,t)!==null},r.match=function(e,t,n){n||={};var r=0,i=[],a=t.length,o=0,s=0,c=n.pre||``,l=n.post||``,u=n.caseSensitive&&t||t.toLowerCase(),d;e=n.caseSensitive&&e||e.toLowerCase();for(var f=0;f<a;f++)d=t[f],u[f]===e[r]?(d=c+d+l,r+=1,s+=1+s):s=0,o+=s,i[i.length]=d;return r===e.length?(o=u===e?1/0:o,{rendered:i.join(``),score:o}):null},r.filter=function(e,t,n){return!t||t.length===0?[]:typeof e==`string`?(n||={},t.reduce(function(t,i,a,o){var s=i;n.extract&&(s=n.extract(i));var c=r.match(e,s,n);return c!=null&&(t[t.length]={string:c.rendered,score:c.score,index:a,original:i}),t},[]).sort(function(e,t){return t.score-e.score||e.index-t.index})):t}})()})),kp=e(At(),1),Ap=e(Op(),1),jp=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Mp=e=>e?jp(e):jp,Np=e(x(),1),{useDebugValue:Pp}=G.default,{useSyncExternalStoreWithSelector:Fp}=Np.default,Ip=e=>e;function Lp(e,t=Ip,n){let r=Fp(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Pp(r),r}var Rp=e=>{let t=typeof e==`function`?Mp(e):e,n=(e,n)=>Lp(t,e,n);return Object.assign(n,t),n},zp=e=>e?Rp(e):Rp,Bp,Vp=typeof window<`u`&&((Bp=window.document)!=null&&Bp.createElement||window.navigator?.product===`ReactNative`)?G.useLayoutEffect:G.useEffect;function Hp(){let e=zp(e=>({current:[],version:0,set:e}));return{In:({children:t})=>{let n=e(e=>e.set),r=e(e=>e.version);return Vp(()=>{n(e=>({version:e.version+1}))},[]),Vp(()=>(n(({current:e})=>({current:[...e,t]})),()=>n(({current:e})=>({current:e.filter(e=>e!==t)}))),[t,r]),null},Out:()=>{let t=e(e=>e.current);return G.createElement(G.Fragment,null,t)}}}function Up(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Wp(e,t=[]){let n=[];function r(t,r){let i=(0,G.createContext)(r),a=n.length;n=[...n,r];function o(t){let{scope:n,children:r,...o}=t,s=n?.[e][a]||i,c=(0,G.useMemo)(()=>o,Object.values(o));return(0,G.createElement)(s.Provider,{value:c},r)}function s(n,o){let s=(0,G.useContext)(o?.[e][a]||i);if(s)return s;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return o.displayName=t+`Provider`,[o,s]}let i=()=>{let t=n.map(e=>(0,G.createContext)(e));return function(n){let r=n?.[e]||t;return(0,G.useMemo)(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Gp(i,...t)]}function Gp(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return(0,G.useMemo)(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Kp(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}function qp(...e){return t=>e.forEach(e=>Kp(e,t))}function Jp(...e){return(0,G.useCallback)(qp(...e),e)}var Yp=(0,G.forwardRef)((e,t)=>{let{children:n,...r}=e,i=G.Children.toArray(n),a=i.find(Qp);if(a){let e=a.props.children,n=i.map(t=>t===a?G.Children.count(e)>1?G.Children.only(null):(0,G.isValidElement)(e)?e.props.children:null:t);return(0,G.createElement)(Xp,b({},r,{ref:t}),(0,G.isValidElement)(e)?(0,G.cloneElement)(e,void 0,n):null)}return(0,G.createElement)(Xp,b({},r,{ref:t}),n)});Yp.displayName=`Slot`;var Xp=(0,G.forwardRef)((e,t)=>{let{children:n,...r}=e;return(0,G.isValidElement)(n)?(0,G.cloneElement)(n,{...$p(r,n.props),ref:qp(t,n.ref)}):G.Children.count(n)>1?G.Children.only(null):null});Xp.displayName=`SlotClone`;var Zp=({children:e})=>(0,G.createElement)(G.Fragment,null,e);function Qp(e){return(0,G.isValidElement)(e)&&e.type===Zp}function $p(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function em(e){let t=e+`CollectionProvider`,[n,r]=Wp(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=G.useRef(null),a=G.useRef(new Map).current;return G.createElement(i,{scope:t,itemMap:a,collectionRef:r},n)},s=e+`CollectionSlot`,c=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Jp(t,a(s,n).collectionRef);return G.createElement(Yp,{ref:i},r)}),l=e+`CollectionItemSlot`,u=`data-radix-collection-item`,d=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),s=Jp(t,o),c=a(l,n);return G.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),G.createElement(Yp,{[u]:``,ref:s},r)});function f(t){let n=a(e+`CollectionConsumer`,t);return G.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:c,ItemSlot:d},f,r]}var tm=globalThis!=null&&globalThis.document?G.useLayoutEffect:()=>{},nm=G.useId||(()=>void 0),rm=0;function im(e){let[t,n]=G.useState(nm());return tm(()=>{e||n(e=>e??String(rm++))},[e]),e||(t?`radix-${t}`:``)}var am=[`a`,`button`,`div`,`h2`,`h3`,`img`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=(0,G.forwardRef)((e,n)=>{let{asChild:r,...i}=e,a=r?Yp:t;return(0,G.useEffect)(()=>{window[Symbol.for(`radix-ui`)]=!0},[]),(0,G.createElement)(a,b({},i,{ref:n}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function om(e){let t=(0,G.useRef)(e);return(0,G.useEffect)(()=>{t.current=e}),(0,G.useMemo)(()=>(...e)=>t.current?.call(t,...e),[])}function sm({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=cm({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=om(n);return[o,(0,G.useCallback)(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function cm({defaultProp:e,onChange:t}){let n=(0,G.useState)(e),[r]=n,i=(0,G.useRef)(r),a=om(t);return(0,G.useEffect)(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var lm=(0,G.createContext)(void 0);function um(e){let t=(0,G.useContext)(lm);return e||t||`ltr`}var dm=`rovingFocusGroup.onEntryFocus`,fm={bubbles:!1,cancelable:!0},pm=`RovingFocusGroup`,[mm,hm,gm]=em(pm),[_m,vm]=Wp(pm,[gm]),[ym,bm]=_m(pm),xm=(0,G.forwardRef)((e,t)=>(0,G.createElement)(mm.Provider,{scope:e.__scopeRovingFocusGroup},(0,G.createElement)(mm.Slot,{scope:e.__scopeRovingFocusGroup},(0,G.createElement)(Sm,b({},e,{ref:t}))))),Sm=(0,G.forwardRef)((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,...u}=e,d=(0,G.useRef)(null),f=Jp(t,d),p=um(a),[m=null,h]=sm({prop:o,defaultProp:s,onChange:c}),[g,_]=(0,G.useState)(!1),v=om(l),y=hm(n),x=(0,G.useRef)(!1),[S,ee]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let e=d.current;if(e)return e.addEventListener(dm,v),()=>e.removeEventListener(dm,v)},[v]),(0,G.createElement)(ym,{scope:n,orientation:r,dir:p,loop:i,currentTabStopId:m,onItemFocus:(0,G.useCallback)(e=>h(e),[h]),onItemShiftTab:(0,G.useCallback)(()=>_(!0),[]),onFocusableItemAdd:(0,G.useCallback)(()=>ee(e=>e+1),[]),onFocusableItemRemove:(0,G.useCallback)(()=>ee(e=>e-1),[])},(0,G.createElement)(am.div,b({tabIndex:g||S===0?-1:0,"data-orientation":r},u,{ref:f,style:{outline:`none`,...e.style},onMouseDown:Up(e.onMouseDown,()=>{x.current=!0}),onFocus:Up(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!g){let t=new CustomEvent(dm,fm);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=y().filter(e=>e.focusable);Om([e.find(e=>e.active),e.find(e=>e.id===m),...e].filter(Boolean).map(e=>e.ref.current))}}x.current=!1}),onBlur:Up(e.onBlur,()=>_(!1))})))}),Cm=`RovingFocusGroupItem`,wm=(0,G.forwardRef)((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,...o}=e,s=im(),c=a||s,l=bm(Cm,n),u=l.currentTabStopId===c,d=hm(n),{onFocusableItemAdd:f,onFocusableItemRemove:p}=l;return(0,G.useEffect)(()=>{if(r)return f(),()=>p()},[r,f,p]),(0,G.createElement)(mm.ItemSlot,{scope:n,id:c,focusable:r,active:i},(0,G.createElement)(am.span,b({tabIndex:u?0:-1,"data-orientation":l.orientation},o,{ref:t,onMouseDown:Up(e.onMouseDown,e=>{r?l.onItemFocus(c):e.preventDefault()}),onFocus:Up(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:Up(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){l.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Dm(e,l.orientation,l.dir);if(t!==void 0){e.preventDefault();let n=d().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=l.loop?km(n,r+1):n.slice(r+1)}setTimeout(()=>Om(n))}})})))}),Tm={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Em(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Dm(e,t,n){let r=Em(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Tm[r]}function Om(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function km(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Am=xm,jm=wm;function Mm(e,t){return(0,G.useReducer)((e,n)=>t[e][n]??e,e)}var Nm=e=>{let{present:t,children:n}=e,r=Pm(t),i=typeof n==`function`?n({present:r.isPresent}):G.Children.only(n),a=Jp(r.ref,i.ref);return typeof n==`function`||r.isPresent?(0,G.cloneElement)(i,{ref:a}):null};Nm.displayName=`Presence`;function Pm(e){let[t,n]=(0,G.useState)(),r=(0,G.useRef)({}),i=(0,G.useRef)(e),a=(0,G.useRef)(`none`),[o,s]=Mm(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return(0,G.useEffect)(()=>{let e=Fm(r.current);a.current=o===`mounted`?e:`none`},[o]),tm(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Fm(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),tm(()=>{if(t){let e=e=>{let n=Fm(r.current).includes(e.animationName);e.target===t&&n&&(0,_d.flushSync)(()=>s(`ANIMATION_END`))},n=e=>{e.target===t&&(a.current=Fm(r.current))};return t.addEventListener(`animationstart`,n),t.addEventListener(`animationcancel`,e),t.addEventListener(`animationend`,e),()=>{t.removeEventListener(`animationstart`,n),t.removeEventListener(`animationcancel`,e),t.removeEventListener(`animationend`,e)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:(0,G.useCallback)(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function Fm(e){return e?.animationName||`none`}var Im=`Tabs`,[Lm,Rm]=Wp(Im,[vm]),zm=vm(),[Bm,Vm]=Lm(Im),Hm=(0,G.forwardRef)((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=um(s),[d,f]=sm({prop:r,onChange:i,defaultProp:a});return(0,G.createElement)(Bm,{scope:n,baseId:im(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c},(0,G.createElement)(am.div,b({dir:u,"data-orientation":o},l,{ref:t})))}),Um=`TabsList`,Wm=(0,G.forwardRef)((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Vm(Um,n);return(0,G.createElement)(Am,b({asChild:!0},zm(n),{orientation:a.orientation,dir:a.dir,loop:r}),(0,G.createElement)(am.div,b({role:`tablist`,"aria-orientation":a.orientation},i,{ref:t})))}),Gm=`TabsTrigger`,Km=(0,G.forwardRef)((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Vm(Gm,n),s=zm(n),c=Ym(o.baseId,r),l=Xm(o.baseId,r),u=r===o.value;return(0,G.createElement)(jm,b({asChild:!0},s,{focusable:!i,active:u}),(0,G.createElement)(am.button,b({type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c},a,{ref:t,onMouseDown:Up(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:Up(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:Up(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})))}),qm=`TabsContent`,Jm=(0,G.forwardRef)((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Vm(qm,n),c=Ym(s.baseId,r),l=Xm(s.baseId,r),u=r===s.value,d=(0,G.useRef)(u);return(0,G.useEffect)(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,G.createElement)(Nm,{present:i||u},({present:n})=>(0,G.createElement)(am.div,b({"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0},o,{ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0}}),n&&a))});function Ym(e,t){return`${e}-trigger-${t}`}function Xm(e,t){return`${e}-content-${t}`}var Zm=Hm,Qm=Wm,$m=Km,eh=Jm,th=e(t(((e,t)=>{var n=NaN,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=typeof global==`object`&&global&&global.Object===Object&&global,l=typeof self==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,h=!0;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=y(t)||0,g(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?f(y(n.maxWait)||0,t):a,h=`trailing`in n?!!n.trailing:h);function _(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function v(e){return l=e,s=setTimeout(S,t),u?_(e):o}function b(e){var n=e-c,r=e-l,i=t-n;return d?p(i,a-r):i}function x(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function S(){var e=m();if(x(e))return ee(e);s=setTimeout(S,b(e))}function ee(e){return s=void 0,h&&r?_(e):(r=i=void 0,o)}function te(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function ne(){return s===void 0?o:ee(m())}function re(){var e=m(),n=x(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return v(c);if(d)return s=setTimeout(S,t),_(c)}return s===void 0&&(s=setTimeout(S,t)),o}return re.cancel=te,re.flush=ne,re}function g(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function _(e){return!!e&&typeof e==`object`}function v(e){return typeof e==`symbol`||_(e)&&d.call(e)==`[object Symbol]`}function y(e){if(typeof e==`number`)return e;if(v(e))return n;if(g(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=g(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?n:+e}t.exports=h}))(),1);function nh(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}nh({},`LaserPointer`,()=>_h);function rh([e,t,n],[r,i,a]){return[e+r,t+i,n+a]}function ih([e,t,n],[r,i,a]){return[e-r,t-i,n-a]}function ah([e,t,n],r){return[e*r,t*r,n*r]}function oh([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function sh([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function ch(e,t,n){return rh(e,ah(ih(t,e),n))}function lh(e,t,n){return Math.atan2(n[1]-e[1],n[0]-e[0])-Math.atan2(t[1]-e[1],t[0]-e[0])}function uh(e){return Math.atan2(Math.sin(e),Math.cos(e))}function dh([e,t]){return Math.sqrt(e**2+t**2)}function fh([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function ph(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=fh(e[n-1],e[n]);return t+=fh(e[e.length-2],e[e.length-1]),t}var mh=(e,t,n)=>Math.max(t,Math.min(n,e));function hh(e,t,n){let r=fh(t,n);if(r===0)return fh(e,t);let i=mh(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1);return fh([t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]],e)}function gh(e,t){if(t===0||e.length<=2)return e;let n=e[0],r=e[e.length-1],[i,a]=e.reduce(([e,t],i,a)=>{let o=hh(i,n,r);return o>e?[o,a]:[e,t]},[0,-1]);if(i>=t){let i=e[a];return[...gh([n,...e.slice(1,a),i],t).slice(0,-1),i,...gh([i,...e.slice(a,-1),r],t).slice(1)]}else return[n,r]}var _h=class e{static{this.defaults={size:2,streamline:.45,simplify:.1,simplifyPhase:`output`,keepHead:!1,sizeMapping:()=>1}}static{this.constants={cornerDetectionMaxAngle:75,cornerDetectionVariance:e=>e>35?.5:1,maxTailLength:50}}constructor(t){this.originalPoints=[],this.stablePoints=[],this.tailPoints=[],this.isFresh=!0,this.options=Object.assign({},e.defaults,t)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(t){let n=this.originalPoints[this.originalPoints.length-1];if(!(n&&n[0]===t[0]&&n[1]===t[1])){if(this.originalPoints.push(t),this.isFresh){this.isFresh=!1,this.stablePoints.push(t);return}this.options.streamline>0&&(t=ch(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),ph(this.tailPoints)>e.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==`tail`)throw Error(`Not implemented yet`);this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(e,t,n,r,i){return(e??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:n,totalLength:r})}getStrokeOutline(t){if(this.isFresh)return[];let n=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase===`input`&&(n=gh(n,this.options.simplify));let r=n.length;if(r===0)return[];if(r===1){let e=n[0],i=this.getSize(t,e[2],0,r,0);if(i<.5)return[];let a=[];for(let t=0;t<=Math.PI*2;t+=Math.PI/16)a.push(rh(e,ah(sh([1,0,0],t),i)));return a.push(rh(e,ah([1,0,0],this.getSize(t,e[2],0,r,0)))),a}if(r===2){let e=n[0],i=n[1],a=this.getSize(t,e[2],0,r,0),o=this.getSize(t,i[2],0,r,0);if(a<.5||o<.5)return[];let s=[],c=lh(e,[e[0],e[1]-100,e[2]],i);for(let t=c;t<=Math.PI+c;t+=Math.PI/16)s.push(rh(e,ah(sh([1,0,0],t),a)));for(let e=Math.PI+c;e<=Math.PI*2+c;e+=Math.PI/16)s.push(rh(i,ah(sh([1,0,0],e),o)));return s.push(s[0]),s}let i=[],a=[],o=0,s=0,c=0,l=0;for(let u=1;u<r-1;u++){let d=n[u-1],f=n[u],p=n[u+1],m=f[2],h=fh(d,f);l+=h,o=s+(h-s)*.2;let g=this.getSize(t,m,u,r,l);if(g===0){c=u+1;continue}let _=oh(ih(d,f)),v=oh(ih(p,f)),y=sh(_,Math.PI/2),b=sh(_,-Math.PI/2),x=sh(v,Math.PI/2),S=sh(v,-Math.PI/2),ee=rh(f,ah(y,g)),te=rh(f,ah(b,g)),ne=rh(f,ah(x,g)),re=rh(f,ah(S,g)),C=rh(y,S),w=rh(b,x),ie=rh(f,ah(dh(C)===0?_:oh(C),g)),ae=rh(f,ah(dh(w)===0?v:oh(w),g)),oe=uh(lh(f,d,p)),se=e.constants.cornerDetectionMaxAngle/180*Math.PI*e.constants.cornerDetectionVariance(o);if(Math.abs(oe)<se){let e=Math.abs(uh(Math.PI-oe));if(e===0)continue;if(oe<0){a.push(te,ae);for(let t=0;t<=e;t+=e/4)i.push(rh(f,sh(ah(y,g),t)));for(let t=e;t>=0;t-=e/4)a.push(rh(f,sh(ah(y,g),t)));a.push(ae,ne)}else{i.push(ee,ie);for(let t=0;t<=e;t+=e/4)a.push(rh(f,sh(ah(y,-g),-t)));for(let t=e;t>=0;t-=e/4)i.push(rh(f,sh(ah(y,-g),-t)));i.push(ie,re)}}else i.push(ie),a.push(ae);s=o}if(c>=r-2)if(this.options.keepHead){let e=n[r-1],t=[];for(let n=0;n<=Math.PI*2;n+=Math.PI/16)t.push(rh(e,ah(sh([1,0,0],n),this.options.size)));return t.push(rh(e,ah([1,0,0],this.options.size))),t}else return[];let u=n[c],d=n[c+1],f=n[r-2],p=n[r-1],m=oh(ih(d,u)),h=oh(ih(f,p)),g=sh(m,-Math.PI/2),_=sh(h,Math.PI/2),v=this.getSize(t,u[2],0,r,0),y=[],b=this.options.keepHead?this.options.size:this.getSize(t,f[2],r-2,r,l),x=[];if(v>1){for(let e=0;e<=Math.PI;e+=Math.PI/16)y.unshift(rh(u,sh(ah(g,v),-e)));y.unshift(rh(u,ah(g,-v)))}else y.push(u);for(let e=0;e<=Math.PI*3;e+=Math.PI/16)x.push(rh(p,sh(ah(_,-b),-e)));let S=[...y,...i,...x.reverse(),...a.reverse()];return y.length>0&&S.push(y[0]),this.options.simplify>0&&this.options.simplifyPhase===`output`?gh(S,this.options.simplify):S}},vh=md(),{useAtom:yh,useSetAtom:bh,useAtomValue:xh,useStore:Sh}=vh,Ch=vh.Provider,wh=Zu(),Th=ie({"./locales/ar-SA.json":()=>v(()=>import(`./ar-SA-G6X2FPQ2-Cb41YiB7.js`),__vite__mapDeps([0,1,2])),"./locales/az-AZ.json":()=>v(()=>import(`./az-AZ-76LH7QW2-CnfWZeUk.js`),__vite__mapDeps([3,1,2])),"./locales/bg-BG.json":()=>v(()=>import(`./bg-BG-XCXSNQG7-Cl45RwQy.js`),__vite__mapDeps([4,1,2])),"./locales/bn-BD.json":()=>v(()=>import(`./bn-BD-2XOGV67Q-ClQx2pnI.js`),__vite__mapDeps([5,1,2])),"./locales/ca-ES.json":()=>v(()=>import(`./ca-ES-6MX7JW3Y-B70Lf-H_.js`),__vite__mapDeps([6,1,2])),"./locales/cs-CZ.json":()=>v(()=>import(`./cs-CZ-2BRQDIVT-CK-m8a6b.js`),__vite__mapDeps([7,1,2])),"./locales/da-DK.json":()=>v(()=>import(`./da-DK-5WZEPLOC-B_630tmB.js`),__vite__mapDeps([8,1,2])),"./locales/de-DE.json":()=>v(()=>import(`./de-DE-XR44H4JA-DtdQNPIr.js`),__vite__mapDeps([9,1,2])),"./locales/el-GR.json":()=>v(()=>import(`./el-GR-BZB4AONW-BhrdBtxp.js`),__vite__mapDeps([10,1,2])),"./locales/en.json":()=>v(()=>import(`./en-B4ZKOASM-BNPKUPIM.js`),__vite__mapDeps([11,1,2,12])),"./locales/es-ES.json":()=>v(()=>import(`./es-ES-U4NZUMDT-BVdRn_Jk.js`),__vite__mapDeps([13,1,2])),"./locales/eu-ES.json":()=>v(()=>import(`./eu-ES-A7QVB2H4-tW-JN7p8.js`),__vite__mapDeps([14,1,2])),"./locales/fa-IR.json":()=>v(()=>import(`./fa-IR-HGAKTJCU-BZyMSjbe.js`),__vite__mapDeps([15,1,2])),"./locales/fi-FI.json":()=>v(()=>import(`./fi-FI-Z5N7JZ37-DzRBXsPy.js`),__vite__mapDeps([16,1,2])),"./locales/fr-FR.json":()=>v(()=>import(`./fr-FR-RHASNOE6-DEodF8O6.js`),__vite__mapDeps([17,1,2])),"./locales/gl-ES.json":()=>v(()=>import(`./gl-ES-HMX3MZ6V-Du5pFjOW.js`),__vite__mapDeps([18,1,2])),"./locales/he-IL.json":()=>v(()=>import(`./he-IL-6SHJWFNN-D9GHex1S.js`),__vite__mapDeps([19,1,2])),"./locales/hi-IN.json":()=>v(()=>import(`./hi-IN-IWLTKZ5I-DnqTYaZL.js`),__vite__mapDeps([20,1,2])),"./locales/hu-HU.json":()=>v(()=>import(`./hu-HU-A5ZG7DT2-BYOpW44D.js`),__vite__mapDeps([21,1,2])),"./locales/id-ID.json":()=>v(()=>import(`./id-ID-SAP4L64H-DfY6GEBJ.js`),__vite__mapDeps([22,1,2])),"./locales/it-IT.json":()=>v(()=>import(`./it-IT-JPQ66NNP-C8bnB-BP.js`),__vite__mapDeps([23,1,2])),"./locales/ja-JP.json":()=>v(()=>import(`./ja-JP-DBVTYXUO-CXnZ_q5a.js`),__vite__mapDeps([24,1,2])),"./locales/kaa.json":()=>v(()=>import(`./kaa-6HZHGXH3-DDaHm4rV.js`),__vite__mapDeps([25,1,2])),"./locales/kab-KAB.json":()=>v(()=>import(`./kab-KAB-ZGHBKWFO-DBB61TA4.js`),__vite__mapDeps([26,1,2])),"./locales/kk-KZ.json":()=>v(()=>import(`./kk-KZ-P5N5QNE5-nJujjHZU.js`),__vite__mapDeps([27,1,2])),"./locales/km-KH.json":()=>v(()=>import(`./km-KH-HSX4SM5Z-BTbPrn7C.js`),__vite__mapDeps([28,1,2])),"./locales/ko-KR.json":()=>v(()=>import(`./ko-KR-MTYHY66A-DY7N8FkC.js`),__vite__mapDeps([29,1,2])),"./locales/ku-TR.json":()=>v(()=>import(`./ku-TR-6OUDTVRD-CWiwUq7W.js`),__vite__mapDeps([30,1,2])),"./locales/lt-LT.json":()=>v(()=>import(`./lt-LT-XHIRWOB4-D5iGl8SA.js`),__vite__mapDeps([31,1,2])),"./locales/lv-LV.json":()=>v(()=>import(`./lv-LV-5QDEKY6T-Dk5tYd5b.js`),__vite__mapDeps([32,1,2])),"./locales/mr-IN.json":()=>v(()=>import(`./mr-IN-CRQNXWMA-C3V-9EA3.js`),__vite__mapDeps([33,1,2])),"./locales/my-MM.json":()=>v(()=>import(`./my-MM-5M5IBNSE-BkC0s2uK.js`),__vite__mapDeps([34,1,2])),"./locales/nb-NO.json":()=>v(()=>import(`./nb-NO-T6EIAALU-DVr77Juq.js`),__vite__mapDeps([35,1,2])),"./locales/nl-NL.json":()=>v(()=>import(`./nl-NL-IS3SIHDZ-B9zaDsWm.js`),__vite__mapDeps([36,1,2])),"./locales/nn-NO.json":()=>v(()=>import(`./nn-NO-6E72VCQL-TxuzXJMr.js`),__vite__mapDeps([37,1,2])),"./locales/oc-FR.json":()=>v(()=>import(`./oc-FR-POXYY2M6-Du5tRkPK.js`),__vite__mapDeps([38,1,2])),"./locales/pa-IN.json":()=>v(()=>import(`./pa-IN-N4M65BXN-Ducc8ihq.js`),__vite__mapDeps([39,1,2])),"./locales/percentages.json":()=>v(()=>import(`./percentages-BXMCSKIN-BzbvNGT_.js`),__vite__mapDeps([40,1,2,41])),"./locales/pl-PL.json":()=>v(()=>import(`./pl-PL-T2D74RX3-2GqH9xC0.js`),__vite__mapDeps([42,1,2])),"./locales/pt-BR.json":()=>v(()=>import(`./pt-BR-5N22H2LF-CZaLZGo4.js`),__vite__mapDeps([43,1,2])),"./locales/pt-PT.json":()=>v(()=>import(`./pt-PT-UZXXM6DQ-CZ_1UJI0.js`),__vite__mapDeps([44,1,2])),"./locales/ro-RO.json":()=>v(()=>import(`./ro-RO-JPDTUUEW-BP6wu9nV.js`),__vite__mapDeps([45,1,2])),"./locales/ru-RU.json":()=>v(()=>import(`./ru-RU-B4JR7IUQ-Bi4CkeXg.js`),__vite__mapDeps([46,1,2])),"./locales/si-LK.json":()=>v(()=>import(`./si-LK-N5RQ5JYF-M5DVaWhp.js`),__vite__mapDeps([47,1,2])),"./locales/sk-SK.json":()=>v(()=>import(`./sk-SK-C5VTKIMK-D9ZLQfWn.js`),__vite__mapDeps([48,1,2])),"./locales/sl-SI.json":()=>v(()=>import(`./sl-SI-NN7IZMDC-Bxlmsjpq.js`),__vite__mapDeps([49,1,2])),"./locales/sv-SE.json":()=>v(()=>import(`./sv-SE-XGPEYMSR-BjmoYeta.js`),__vite__mapDeps([50,1,2])),"./locales/ta-IN.json":()=>v(()=>import(`./ta-IN-2NMHFXQM-09poAzNq.js`),__vite__mapDeps([51,1,2])),"./locales/th-TH.json":()=>v(()=>import(`./th-TH-HPSO5L25-nZve-9bk.js`),__vite__mapDeps([52,1,2])),"./locales/tr-TR.json":()=>v(()=>import(`./tr-TR-DEFEU3FU-CCapu8i5.js`),__vite__mapDeps([53,1,2])),"./locales/uk-UA.json":()=>v(()=>import(`./uk-UA-QMV73CPH-DDPMXs9n.js`),__vite__mapDeps([54,1,2])),"./locales/vi-VN.json":()=>v(()=>import(`./vi-VN-M7AON7JQ-Db_NuxeD.js`),__vite__mapDeps([55,1,2])),"./locales/zh-CN.json":()=>v(()=>import(`./zh-CN-LNUGB5OW-OgXhNNDt.js`),__vite__mapDeps([56,1,2])),"./locales/zh-HK.json":()=>v(()=>import(`./zh-HK-E62DVLB3-DnB5sd3Z.js`),__vite__mapDeps([57,1,2])),"./locales/zh-TW.json":()=>v(()=>import(`./zh-TW-RAJ6MFWO-CGNGxCX-.js`),__vite__mapDeps([58,1,2]))}),Eh=85,Dh={code:`en`,label:`English`},Oh=[Dh,...[{code:`ar-SA`,label:`العربية`,rtl:!0},{code:`bg-BG`,label:`Български`},{code:`ca-ES`,label:`Català`},{code:`cs-CZ`,label:`Česky`},{code:`de-DE`,label:`Deutsch`},{code:`el-GR`,label:`Ελληνικά`},{code:`es-ES`,label:`Español`},{code:`eu-ES`,label:`Euskara`},{code:`fa-IR`,label:`فارسی`,rtl:!0},{code:`fi-FI`,label:`Suomi`},{code:`fr-FR`,label:`Français`},{code:`gl-ES`,label:`Galego`},{code:`he-IL`,label:`עברית`,rtl:!0},{code:`hi-IN`,label:`हिन्दी`},{code:`hu-HU`,label:`Magyar`},{code:`id-ID`,label:`Bahasa Indonesia`},{code:`it-IT`,label:`Italiano`},{code:`ja-JP`,label:`日本語`},{code:`kab-KAB`,label:`Taqbaylit`},{code:`kk-KZ`,label:`Қазақ тілі`},{code:`ko-KR`,label:`한국어`},{code:`ku-TR`,label:`Kurdî`},{code:`lt-LT`,label:`Lietuvių`},{code:`lv-LV`,label:`Latviešu`},{code:`my-MM`,label:`Burmese`},{code:`nb-NO`,label:`Norsk bokmål`},{code:`nl-NL`,label:`Nederlands`},{code:`nn-NO`,label:`Norsk nynorsk`},{code:`oc-FR`,label:`Occitan`},{code:`pa-IN`,label:`ਪੰਜਾਬੀ`},{code:`pl-PL`,label:`Polski`},{code:`pt-BR`,label:`Português Brasileiro`},{code:`pt-PT`,label:`Português`},{code:`ro-RO`,label:`Română`},{code:`ru-RU`,label:`Русский`},{code:`sk-SK`,label:`Slovenčina`},{code:`sv-SE`,label:`Svenska`},{code:`sl-SI`,label:`Slovenščina`},{code:`tr-TR`,label:`Türkçe`},{code:`uk-UA`,label:`Українська`},{code:`zh-CN`,label:`简体中文`},{code:`zh-TW`,label:`繁體中文`},{code:`vi-VN`,label:`Tiếng Việt`},{code:`mr-IN`,label:`मराठी`}].filter(e=>Du[e.code]>=Eh).sort((e,t)=>e.label>t.label?1:-1)],kh=`__test__`;C.DEV&&Oh.unshift({code:kh,label:`test language`},{code:`${kh}.rtl`,label:`test language (rtl)`,rtl:!0});var Ah=Dh,jh={},Mh=async e=>{if(Ah=e,document.documentElement.dir=Ah.rtl?`rtl`:`ltr`,document.documentElement.lang=Ah.code,e.code.startsWith(kh))jh={};else try{jh=await Th(`./locales/${Ah.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),jh=Eu}wh.set(Fh,e.code)},Nh=()=>Ah,Ph=(e,t)=>{for(let n=0;n<t.length;++n){let r=t[n];if(e[r]===void 0)return;e=e[r]}if(typeof e==`string`)return e},q=(e,t,n)=>{if(Ah.code.startsWith(kh))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split(`.`),i=Ph(jh,r)||Ph(Eu,r)||n;if(i===void 0){let t=`Can't find translation for ${e}`;if(C.PROD)return console.warn(t),``;throw Error(t)}if(t)for(let e in t)i=i.replace(`{{${e}}}`,String(t[e]));return i},Fh=ku(Dh.code),Ih=()=>({t:q,langCode:xh(Fh)}),Lh=({size:e=`1em`,circleWidth:t=8,synchronized:n=!1,className:r=``})=>{let i=-(G.useRef(Date.now()).current%1600);return(0,K.jsx)(`div`,{className:`Spinner ${r}`,children:(0,K.jsx)(`svg`,{viewBox:`0 0 100 100`,style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:(0,K.jsx)(`circle`,{cx:`50`,cy:`50`,r:50-t/2,strokeWidth:t,fill:`none`,strokeMiterlimit:`10`})})})},Rh=({delay:e,theme:t})=>{let[n,r]=(0,G.useState)(!!e);return(0,G.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,K.jsxs)(`div`,{className:I(`LoadingMessage`,{"LoadingMessage--dark":t===j.DARK}),children:[(0,K.jsx)(`div`,{children:(0,K.jsx)(Lh,{})}),(0,K.jsx)(`div`,{className:`LoadingMessage-text`,children:q(`labels.loadingScene`)})]})},zh=e=>{let[t,n]=(0,G.useState)(!0);return(0,G.useEffect)(()=>{let t=async()=>{await Mh(r),n(!1)},r=Oh.find(t=>t.code===e.langCode)||Dh;t()},[e.langCode]),t?(0,K.jsx)(Rh,{theme:e.theme}):e.children},J=G.forwardRef(({size:e=`medium`,visible:t=!0,className:n=``,...r},i)=>{let{id:a}=yE(),o=G.useRef(null);G.useImperativeHandle(i,()=>o.current);let s=`ToolIcon_size_${e}`,[c,l]=(0,G.useState)(!1),u=(0,G.useRef)(!0),d=async e=>{let t=`onClick`in r&&r.onClick?.(e);if(Qe(t))try{l(!0),await t}catch(e){if(e instanceof ii)console.warn(e);else throw e}finally{u.current&&l(!1)}};(0,G.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let f=(0,G.useRef)(null);if(r.type===`button`||r.type===`icon`||r.type===`submit`){let e=r.type===`icon`?`button`:r.type;return(0,K.jsxs)(`button`,{className:I(`ToolIcon_type_button`,s,n,t&&!r.hidden?`ToolIcon_type_button--show`:`ToolIcon_type_button--hide`,{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type===`icon`}),style:r.style,"data-testid":r[`data-testid`],hidden:r.hidden,title:r.title,"aria-label":r[`aria-label`],type:e,onClick:d,ref:o,disabled:c||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&(0,K.jsxs)(`div`,{className:`ToolIcon__icon`,"aria-hidden":`true`,"aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&(0,K.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel}),r.isLoading&&(0,K.jsx)(Lh,{})]}),r.showAriaLabel&&(0,K.jsxs)(`div`,{className:`ToolIcon__label`,children:[r[`aria-label`],` `,c&&(0,K.jsx)(Lh,{})]}),r.children]})}return(0,K.jsxs)(`label`,{className:I(`ToolIcon`,n),title:r.title,onPointerDown:e=>{f.current=e.pointerType||null,r.onPointerDown?.({pointerType:e.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{f.current=null})},children:[(0,K.jsx)(`input`,{className:`ToolIcon_type_radio ${s}`,type:`radio`,name:r.name,"aria-label":r[`aria-label`],"aria-keyshortcuts":r[`aria-keyshortcuts`],"data-testid":r[`data-testid`],id:`${a}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:f.current})},checked:r.checked,ref:o}),(0,K.jsxs)(`div`,{className:`ToolIcon__icon`,children:[r.icon,r.keyBindingLabel&&(0,K.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel})]})]})});J.displayName=`ToolButton`;var Bh=(e,t,n)=>{let r=new Set(R(e.filter(e=>D(e)),t).map(e=>e.id)),i={},a=n.scene.getNonDeletedElementsMap(),o=new Set;for(let t of r){let n=Pl(e,t);for(let e of n)if(!o.has(e.id)){if(Ls(e)){let t=ce(e,a);t&&(i[t.id]=!0)}else i[e.id]=!0;o.add(e.id)}}let s=!0,c=e.map(e=>{if(t.selectedElementIds[e.id]){let t=Ls(e)?ce(e,a):null;return e.frameId&&r.has(e.frameId)?(s=!1,i[e.id]=!0,e):t?.frameId&&r.has(t?.frameId)?e:(e.boundElements&&e.boundElements.forEach(t=>{let r=n.scene.getNonDeletedElementsMap().get(t.id);r&&T(r)&&(U(r,{startBinding:e.id===r.startBinding?.elementId?null:r.startBinding,endBinding:e.id===r.endBinding?.elementId?null:r.endBinding}),U(r,{points:r.points}))}),H(e,{isDeleted:!0}))}return e.frameId&&r.has(e.frameId)?(s=!1,Ls(e)||(i[e.id]=!0),H(e,{frameId:null})):Ls(e)&&t.selectedElementIds[e.containerId]?H(e,{isDeleted:!0}):e}),l=t.editingGroupId;if(s&&t.editingGroupId){let e=Ki(c,t.editingGroupId).filter(e=>!e.isDeleted);if(e.length>1)e[0]&&(i[e[0].id]=!0);else{l=null,e[0]&&(i[e[0].id]=!0);let n=e[0];if(n){let e=n.groupIds.findIndex(e=>e===t.editingGroupId),r=n.groupIds[e+1];if(r){let e=Ki(c,r).filter(e=>!e.isDeleted);e.length>1&&(l=r,e.forEach(e=>{i[e.id]=!0}))}}}}return{elements:c,appState:{...t,...xt({selectedElementIds:i,editingGroupId:l},c,t,null)}}},Vh=(e,t)=>{if(e.editingGroupId){let n=Ki(V(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},Hh=P({name:`deleteSelectedElements`,label:`labels.delete`,icon:cu,trackEvent:{category:`element`,action:`delete`},perform:(e,t,n,r)=>{if(t.editingLinearElement){let{elementId:n,selectedPointsIndices:i,startBindingElement:a,endBindingElement:o}=t.editingLinearElement,s=r.scene.getNonDeletedElementsMap(),c=N.getElement(n,s);if(!c||i==null)return!1;if(c.points.length<2){let n=e.map(e=>e.id===c.id?H(e,{isDeleted:!0}):e);return{elements:n,appState:{...Vh(t,n),editingLinearElement:null},captureUpdate:M.IMMEDIATELY}}let l={startBindingElement:i?.includes(0)?null:a,endBindingElement:i?.includes(c.points.length-1)?null:o};return N.deletePoints(c,i),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...l,selectedPointsIndices:i?.[0]>0?[i[0]-1]:[0]}},captureUpdate:M.IMMEDIATELY}}let{elements:i,appState:a}=Bh(e,t,r);return eu(i,i.filter(e=>e.isDeleted)),a=Vh(a,i),{elements:i,appState:{...a,activeTool:Ha(t,{type:`selection`}),multiElement:null,activeEmbeddable:null},captureUpdate:mo(V(e),t)?M.IMMEDIATELY:M.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===F.BACKSPACE||e.key===F.DELETE)&&!e[F.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsx)(J,{type:`button`,icon:cu,title:q(`labels.delete`),"aria-label":q(`labels.delete`),onClick:()=>n(null),visible:mo(V(e),t)})}),Uh=(e,t)=>e.frameId===t||e.id===t,Wh=(e,t,n)=>{let r=[],i=[],a=null,o=-1,s=E(n||R(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++o<e.length;){let t=e[o];s.get(t.id)?(i.length&&(r=r.concat(i),i=[]),r.push(o),a=o+1):t.isDeleted&&a===o?(a=o+1,i.push(o)):i=[]}return r},Gh=e=>{let t=0;return e.reduce((n,r,i)=>(i>0&&e[i-1]!==r-1&&(t=++t),(n[t]||(n[t]=[])).push(r),n),[])},Kh=(e,t,n)=>{if(`containerId`in e&&e.containerId){let r=fa.getScene(e).getElement(e.containerId);if(r)return n===`left`?Math.min(t.indexOf(r),t.indexOf(e)):Math.max(t.indexOf(r),t.indexOf(e))}else{let r=e.boundElements?.find(e=>e.type!==`arrow`)?.id;if(r){let i=fa.getScene(e).getElement(r);if(i)return n===`left`?Math.min(t.indexOf(i),t.indexOf(e)):Math.max(t.indexOf(i),t.indexOf(e))}}},qh=(e,t)=>{let n=-1,r=-1;return e.forEach((e,i)=>{Uh(e,t)&&(n===-1&&(n=i),r=i)}),n===-1?[]:e.slice(n,r+1)},Jh=(e,t,n,r,i)=>{let a=t[n],o=t=>t.isDeleted?!1:i?t.frameId===i:e.editingGroupId?t.groupIds.includes(e.editingGroupId):!0,s=r===`left`?Nt(t,e=>o(e),Math.max(0,n-1)):Sr(t,e=>o(e),n+1),c=t[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join(``)===c?.groupIds.join(``))return Kh(c,t,r)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!i&&(c.frameId||D(c))){let e=qh(t,c.frameId||c.id);return r===`left`?t.indexOf(e[0]):t.indexOf(e[e.length-1])}if(!c.groupIds.length)return Kh(c,t,r)??s;let l=Ki(t,e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1]);return l.length?r===`left`?t.indexOf(l[0]):t.indexOf(l[l.length-1]):s},Yh=(e,t)=>t.reduce((t,n)=>{let r=e[n];return t.set(r.id,r),t},new Map),Xh=(e,t,n)=>{let r=Wh(e,t),i=Yh(e,r),a=Gh(r);n===`right`&&(a=a.reverse());let o=new Set(r.filter(t=>D(e[t])).map(t=>e[t].id));return a.forEach((r,i)=>{let a=r[0],s=r[r.length-1],c=n===`left`?a:s,l=r.some(t=>{let n=e[t];return n.frameId&&o.has(n.frameId)})?null:e[c]?.frameId,u=Jh(t,e,c,n,l);if(u===-1||c===u)return;let d=n===`left`?e.slice(0,u):e.slice(0,a),f=e.slice(a,s+1),p=n===`left`?e.slice(u,a):e.slice(s+1,u+1),m=n===`left`?e.slice(s+1):e.slice(u+1);e=n===`left`?[...d,...f,...p,...m]:[...d,...p,...f,...m]}),bs(e,i),e},Zh=(e,t,n,r,i)=>{let a=Wh(e,t,i),o=Yh(e,a),s=[],c,l;if(n===`left`){if(r)c=Sr(e,e=>Uh(e,r));else if(t.editingGroupId){let n=Ki(e,t.editingGroupId);if(!n.length)return e;c=e.indexOf(n[0])}else c=0;l=a[a.length-1]}else{if(r)l=Nt(e,e=>Uh(e,r));else if(t.editingGroupId){let n=Ki(e,t.editingGroupId);if(!n.length)return e;l=e.indexOf(n[n.length-1])}else l=e.length-1;c=a[0]}c===-1&&(c=0);for(let t=c;t<l+1;t++)a.includes(t)||s.push(e[t]);let u=Array.from(o.values()),d=e.slice(0,c),f=e.slice(l+1),p=n===`left`?[...d,...u,...s,...f]:[...d,...s,...u,...f];return bs(p,o),p};function Qh(e,t,n,r){let i=E(R(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),a={regularElements:[],frameChildren:new Map},o=new Set;for(let t of e)i.has(t.id)&&D(t)&&o.add(t.id);for(let t of e)if(i.has(t.id))if(D(t)||t.frameId&&o.has(t.frameId))a.regularElements.push(t);else if(!t.frameId)a.regularElements.push(t);else{let e=a.frameChildren.get(t.frameId)||[];e.push(t),a.frameChildren.set(t.frameId,e)}let s=e,c=Array.from(a.frameChildren.entries());for(let[i,a]of c)s=r(e,t,n,i,a);return r(s,t,n,null,a.regularElements)}var $h=(e,t)=>Xh(e,t,`left`),eg=(e,t)=>Xh(e,t,`right`),tg=(e,t)=>Qh(e,t,`left`,Zh),ng=(e,t)=>Qh(e,t,`right`,Zh),rg=P({name:`sendBackward`,label:`labels.sendBackward`,keywords:[`move down`,`zindex`,`layer`],icon:Ts,trackEvent:{category:`element`},perform:(e,t)=>({elements:$h(e,t),appState:t,captureUpdate:M.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[F.CTRL_OR_CMD]&&!e.shiftKey&&e.code===k.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${q(`labels.sendBackward`)} \u2014 ${B(`CtrlOrCmd+[`)}`,children:Ts})}),ig=P({name:`bringForward`,label:`labels.bringForward`,keywords:[`move up`,`zindex`,`layer`],icon:lu,trackEvent:{category:`element`},perform:(e,t)=>({elements:eg(e,t),appState:t,captureUpdate:M.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[F.CTRL_OR_CMD]&&!e.shiftKey&&e.code===k.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${q(`labels.bringForward`)} \u2014 ${B(`CtrlOrCmd+]`)}`,children:lu})}),ag=P({name:`sendToBack`,label:`labels.sendToBack`,keywords:[`move down`,`zindex`,`layer`],icon:yl,trackEvent:{category:`element`},perform:(e,t)=>({elements:tg(e,t),appState:t,captureUpdate:M.IMMEDIATELY}),keyTest:e=>wt?e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.BRACKET_LEFT:e[F.CTRL_OR_CMD]&&e.shiftKey&&e.code===k.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${q(`labels.sendToBack`)} \u2014 ${B(wt?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)}`,children:yl})}),og=P({name:`bringToFront`,label:`labels.bringToFront`,keywords:[`move up`,`zindex`,`layer`],icon:ha,trackEvent:{category:`element`},perform:(e,t)=>({elements:ng(e,t),appState:t,captureUpdate:M.IMMEDIATELY}),keyTest:e=>wt?e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.BRACKET_RIGHT:e[F.CTRL_OR_CMD]&&e.shiftKey&&e.code===k.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:t=>e(null),title:`${q(`labels.bringToFront`)} \u2014 ${B(wt?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)}`,children:ha})}),sg=P({name:`selectAll`,label:`labels.selectAll`,icon:Te,trackEvent:{category:`canvas`},viewMode:!1,perform:(e,t,n,r)=>{if(t.editingLinearElement)return!1;let i=e.filter(e=>!e.isDeleted&&!(L(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...xt({editingGroupId:null,selectedElementIds:i},V(e),t,r),selectedLinearElement:Object.keys(i).length===1&&Ac(e[0])?new N(e[0]):null},captureUpdate:M.IMMEDIATELY}},keyTest:e=>e[F.CTRL_OR_CMD]&&e.key===F.A}),cg=e=>{let t=e.slice(),n=new Set,r=e=>{let t=e[0]?.groupIds?.join(``),n=[e[0]],i=[];for(let r of e.slice(1))r.groupIds?.join(``)===t?n.push(r):i.push(r);return i.length?[...n,...r(i)]:n},i=new Map;return t.forEach((e,a)=>{if(!i.has(e.id))if(e.groupIds?.length){let o=e.groupIds[e.groupIds.length-1],s=t.slice(a).filter(e=>{let t=e?.groupIds?.some(e=>e===o);return t&&i.set(e.id,!0),t});for(let e of r(s))n.add(e)}else n.add(e)}),n.size===e.length?[...n]:(console.error(`normalizeGroupElementOrder: lost some elements... bailing!`),e)},lg=e=>{let t=Tl(e),n=e.slice(),r=new Set;return n.forEach((e,i)=>{e&&(e.boundElements?.length?(r.add(e),n[i]=null,e.boundElements.forEach(e=>{let i=t.get(e.id);i&&e.type===`text`&&(r.add(i[0]),n[i[1]]=null)})):e.type===`text`&&e.containerId&&t.get(e.containerId)?.[0].boundElements?.find(t=>t.id===e.id)||(r.add(e),n[i]=null))}),r.size===e.length?[...r]:(console.error(`normalizeBoundElementsOrder: lost some elements... bailing!`),e)},ug=e=>lg(cg(e)),dg=P({name:`duplicateSelection`,label:`labels.duplicateSelection`,icon:Tt,trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(t.editingLinearElement)try{return{elements:e,appState:N.duplicateSelectedPoints(t,r.scene.getNonDeletedElementsMap()),captureUpdate:M.IMMEDIATELY}}catch{return!1}let i=fg(e,t);if(r.props.onDuplicate&&i.elements){let t=r.props.onDuplicate(i.elements,e);t&&(i.elements=t)}return{...i,captureUpdate:M.IMMEDIATELY}},keyTest:e=>e[F.CTRL_OR_CMD]&&e.key===F.D,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsx)(J,{type:`button`,icon:Tt,title:`${q(`labels.duplicateSelection`)} \u2014 ${B(`CtrlOrCmd+D`)}`,"aria-label":q(`labels.duplicateSelection`),onClick:()=>n(null),visible:mo(V(e),t)})}),fg=(e,t)=>{let n=new Map,r=[],i=[],a=new Map,o=new Map,s=E(e),c=e=>{let s=ba(e).reduce((e,s)=>{if(u.has(s.id))return e;u.set(s.id,!0);let c=kn(t.editingGroupId,n,s,{x:s.x+20/2,y:s.y+20/2});return u.set(c.id,!0),o.set(c.id,c),a.set(s.id,c.id),i.push(s),r.push(c),e.push(c),e},[]);return Array.isArray(e)?s:s[0]||null};e=ug(e);let l=E(R(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),u=new Map,d=e.slice(),f=(e,t)=>{jo(e!==-1,`targetIndex === -1 `),!(!Array.isArray(t)&&!t)&&d.splice(e+1,0,...ba(t))},p=new Set(e.filter(e=>l.has(e.id)&&D(e)).map(e=>e.id));for(let n of e){if(u.has(n.id)||!l.has(n.id))continue;let r=Bi(t,n);if(r){let t=Ki(e,r).flatMap(t=>D(t)?[...Pl(e,t.id),t]:[t]);f(Nt(d,e=>e.groupIds?.includes(r)),c(t));continue}if(!(n.frameId&&p.has(n.frameId))){if(D(n)){let t=n.id,r=Pl(e,t);f(Nt(d,e=>e.frameId===t||e.id===t),c([...r,n]));continue}if(Ja(n)){let e=Mn(n,s),t=Nt(d,e=>e.id===n.id||`containerId`in e&&e.containerId===n.id);e?f(t,c([n,e])):f(t,c(n));continue}if(Ls(n)){let e=ce(n,s),t=Nt(d,t=>t.id===n.id||t.id===e?.id);e?f(t,c([e,n])):f(t,c(n));continue}f(Nt(d,e=>e.id===n.id),c(n))}}Wl(d,i,a),vc(d,i,a),Cn(d,i,a);let m=Fc(r);return{elements:d,appState:{...t,...xt({editingGroupId:t.editingGroupId,selectedElementIds:m.reduce((e,t)=>(Ls(t)||(e[t.id]=!0),e),{})},V(d),t,null)}}},pg=new Set([`command_palette`,`export`]),Y=(e,t,n,r)=>{try{if(typeof window>`u`||C.VITE_WORKER_ID||C.VITE_APP_ENABLE_TRACKING!==`true`||!pg.has(e)||C.DEV)return;C.PROD||console.info(`trackEvent`,{category:e,action:t,label:n,value:r}),window.sa_event&&window.sa_event(t,{category:e,label:n,value:r})}catch(e){console.error(`error during analytics`,e)}},mg=(0,G.forwardRef)((e,t)=>{let{title:n,className:r,testId:i,active:a,standalone:o,icon:s,onClick:c}=e;return(0,K.jsx)(`button`,{type:`button`,ref:t,title:n,"data-testid":i,className:I(r,{standalone:o,active:a}),onClick:c,children:s},n)}),hg=e=>(0,K.jsx)(`div`,{className:`buttonList`,children:e.options.map(t=>e.type===`button`?(0,K.jsx)(mg,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:n=>e.onClick(t.value,n)},t.text):(0,K.jsxs)(`label`,{className:I({active:e.value===t.value}),title:t.text,children:[(0,K.jsx)(`input`,{type:`radio`,name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))}),gg=({onChange:e,type:t,activeColor:n,topPicks:r})=>{let i;return t===`elementStroke`&&(i=si),t===`elementBackground`&&(i=bt),t===`canvasBackground`&&(i=je),r&&(i=r),i?(0,K.jsx)(`div`,{className:`color-picker__top-picks`,children:i.map(t=>(0,K.jsx)(`button`,{className:I(`color-picker__button`,{active:t===n,"is-transparent":t===`transparent`||!t}),style:{"--swatch-color":t},type:`button`,title:t,onClick:()=>e(t),"data-testid":`color-top-pick-${t}`,children:(0,K.jsx)(`div`,{className:`color-picker__button-outline`})},t))}):(console.error(`Invalid type for TopPicks`),null)},_g=()=>(0,K.jsx)(`div`,{style:{width:1,height:`1rem`,backgroundColor:`var(--default-border-color)`,margin:`0 auto`}}),vg=({palette:e,color:t})=>{for(let[n,r]of Object.entries(e))if(Array.isArray(r)){let e=r.indexOf(t);if(e>-1)return{colorName:n,shade:e}}else if(r===t)return{colorName:n,shade:null};return null},yg=[[`q`,`w`,`e`,`r`,`t`],[`a`,`s`,`d`,`f`,`g`],[`z`,`x`,`c`,`v`,`b`]].flat(),bg=({color:e,palette:t})=>!Object.values(t).flat().includes(e),xg=(e,t,n)=>{let r={elementBackground:`backgroundColor`,elementStroke:`strokeColor`},i=e.filter(e=>{if(e.isDeleted)return!1;let i=e[r[t]];return bg({color:i,palette:n})}),a=new Map;return i.forEach(e=>{let n=e[r[t]];a.has(n)?a.set(n,a.get(n)+1):a.set(n,1)}),[...a.entries()].sort((e,t)=>t[1]-e[1]).map(e=>e[0]).slice(0,5)},Sg=ku(null),Cg=(e,t,n)=>(e*299+t*587+n*114)/1e3>=160?`black`:`white`,wg=(e,t)=>{if(t){let t=new Option().style;if(t.color=e,t.color){let e=t.color.replace(/^(rgb|rgba)\(/,``).replace(/\)$/,``).replace(/\s/g,``).split(`,`);return Cg(parseInt(e[0]),parseInt(e[1]),parseInt(e[2]))}}return e===`transparent`?`black`:Cg(parseInt(e.substring(1,3),16),parseInt(e.substring(3,5),16),parseInt(e.substring(5,7),16))},Tg=({color:e,keyLabel:t,isCustomColor:n=!1,isShade:r=!1})=>(0,K.jsxs)(`div`,{className:`color-picker__button__hotkey-label`,style:{color:wg(e,n)},children:[r&&`⇧`,t]}),Eg=({hex:e,onChange:t,palette:n})=>{let r=vg({color:e||`transparent`,palette:n}),[i,a]=yh(Sg),o=(0,G.useRef)(null);if((0,G.useEffect)(()=>{o.current&&i===`shades`&&o.current.focus()},[r,i]),r){let{colorName:e,shade:s}=r,c=n[e];if(Array.isArray(c))return(0,K.jsx)(`div`,{className:`color-picker-content--default shades`,children:c.map((n,r)=>(0,K.jsxs)(`button`,{ref:r===s&&i===`shades`?o:void 0,tabIndex:-1,type:`button`,className:I(`color-picker__button color-picker__button--large`,{active:r===s}),"aria-label":`Shade`,title:`${e} - ${r+1}`,style:n?{"--swatch-color":n}:void 0,onClick:()=>{t(n),a(`shades`)},children:[(0,K.jsx)(`div`,{className:`color-picker__button-outline`}),(0,K.jsx)(Tg,{color:n,keyLabel:r+1,isShade:!0})]},r))})}return(0,K.jsxs)(`div`,{className:`color-picker-content--default`,style:{position:`relative`},tabIndex:-1,children:[(0,K.jsx)(`button`,{type:`button`,tabIndex:-1,className:`color-picker__button color-picker__button--large color-picker__button--no-focus-visible`}),(0,K.jsx)(`div`,{tabIndex:-1,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,display:`flex`,alignItems:`center`,justifyContent:`center`,textAlign:`center`,fontSize:`0.75rem`},children:q(`colorPicker.noShades`)})]})},Dg=({palette:e,color:t,onChange:n,label:r,activeShade:i})=>{let a=vg({color:t||`transparent`,palette:e}),[o,s]=yh(Sg),c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{c.current&&o===`baseColors`&&c.current.focus()},[a?.colorName,o]),(0,K.jsx)(`div`,{className:`color-picker-content--default`,children:Object.entries(e).map(([e,t],r)=>{let o=(Array.isArray(t)?t[i]:t)||`transparent`,l=yg[r],u=q(`colors.${e.replace(/\d+/,``)}`,null,``);return(0,K.jsxs)(`button`,{ref:a?.colorName===e?c:void 0,tabIndex:-1,type:`button`,className:I(`color-picker__button color-picker__button--large`,{active:a?.colorName===e,"is-transparent":o===`transparent`||!o}),onClick:()=>{n(o),s(`baseColors`)},title:`${u}${o.startsWith(`#`)?` ${o}`:``} \u2014 ${l}`,"aria-label":`${u} \u2014 ${l}`,style:o?{"--swatch-color":o}:void 0,"data-testid":`color-${e}`,children:[(0,K.jsx)(`div`,{className:`color-picker__button-outline`}),(0,K.jsx)(Tg,{color:o,keyLabel:l})]},e)})})},Og=({colors:e,color:t,onChange:n,label:r})=>{let[i,a]=yh(Sg),o=(0,G.useRef)(null);return(0,G.useEffect)(()=>{o.current&&o.current.focus()},[t,i]),(0,K.jsx)(`div`,{className:`color-picker-content--default`,children:e.map((e,i)=>(0,K.jsxs)(`button`,{ref:t===e?o:void 0,tabIndex:-1,type:`button`,className:I(`color-picker__button color-picker__button--large`,{active:t===e,"is-transparent":e===`transparent`||!e}),onClick:()=>{n(e),a(`custom`)},title:e,"aria-label":r,style:{"--swatch-color":e},children:[(0,K.jsx)(`div`,{className:`color-picker__button-outline`}),(0,K.jsx)(Tg,{color:e,keyLabel:i+1,isCustomColor:!0})]},i))})},kg=(e,t,n)=>{let r=Math.ceil(n/5);switch(t??=-1,e){case`ArrowLeft`:{let e=t-1;return e<0?n-1:e}case`ArrowRight`:return(t+1)%n;case`ArrowDown`:{let e=t+5;return e>=n?t%5:e}case`ArrowUp`:{let e=t-5,i=e<0?5*r+e:e;return i>=n?void 0:i}}},Ag=({e,colorObj:t,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:o})=>{if(t?.shade!=null&&[`Digit1`,`Digit2`,`Digit3`,`Digit4`,`Digit5`].includes(e.code)&&e.shiftKey){let i=Number(e.code.slice(-1))-1;return n(r[t.colorName][i]),a(`shades`),!0}if([`1`,`2`,`3`,`4`,`5`].includes(e.key)&&i[Number(e.key)-1])return n(i[Number(e.key)-1]),a(`custom`),!0;if(yg.includes(e.key)){let t=yg.indexOf(e.key),i=r[Object.keys(r)[t]];return n(Array.isArray(i)?i[o]:i),a(`baseColors`),!0}return!1},jg=({event:e,activeColorPickerSection:t,palette:n,color:r,onChange:i,customColors:a,setActiveColorPickerSection:o,updateData:s,activeShade:c,onEyeDropperToggle:l,onEscape:u})=>{if(e[F.CTRL_OR_CMD])return!1;if(e.key===F.ESCAPE)return u(e),!0;if(e.key===F.ALT)return l(!0),!0;if(e.key===F.I)return l(),!0;let d=vg({color:r,palette:n});if(e.key===F.TAB){let s={custom:!!a.length,baseColors:!0,shades:d?.shade!=null,hex:!0},c=Object.entries(s).reduce((e,[t,n])=>(n&&e.push(t),e),[]),l=c.indexOf(t),u=e.shiftKey?-1:1,f=c[l+u>c.length-1?0:l+u<0?c.length-1:l+u];return f&&o(f),f===`custom`?i(a[0]):f===`baseColors`&&(Object.entries(n).find(([e,t])=>Array.isArray(t)?t.includes(r):t===r?e:null)||i(Ma.black)),e.preventDefault(),e.stopPropagation(),!0}if(Ag({e,colorObj:d,onChange:i,palette:n,customColors:a,setActiveColorPickerSection:o,activeShade:c}))return!0;if(t===`shades`&&d){let{shade:t}=d,r=kg(e.key,t,5);if(r!==void 0)return i(n[d.colorName][r]),!0}if(t===`baseColors`&&d){let{colorName:t}=d,r=Object.keys(n),a=r.indexOf(t),o=kg(e.key,a,r.length);if(o!==void 0){let e=n[r[o]];return i(Array.isArray(e)?e[c]:e),!0}}if(t===`custom`){let t=a.indexOf(r),n=kg(e.key,t,a.length);if(n!==void 0){let e=a[n];return i(e),!0}}return!1},Mg=({children:e})=>(0,K.jsx)(`div`,{className:`color-picker__heading`,children:e}),Ng=({color:e,onChange:t,label:n,type:r,elements:i,palette:a,updateData:o,children:s,onEyeDropperToggle:c,onEscape:l})=>{let[u]=G.useState(()=>r===`canvasBackground`?[]:xg(i,r,a)),[d,f]=yh(Sg),p=vg({color:e,palette:a});(0,G.useEffect)(()=>{if(!d){let t=bg({color:e,palette:a}),n=t&&!u.includes(e);f(n?`hex`:t?`custom`:p?.shade==null?`baseColors`:`shades`)}},[d,e,a,f,p,u]);let[m,h]=(0,G.useState)(p?.shade??(r===`elementBackground`?1:4));(0,G.useEffect)(()=>{p?.shade!=null&&h(p.shade);let e=e=>{e.key===F.ALT&&c(!1)};return document.addEventListener(`keyup`,e,{capture:!0}),()=>{document.removeEventListener(`keyup`,e,{capture:!0})}},[p,c]);let g=G.useRef(null);return(0,K.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":q(`labels.colorPicker`),children:(0,K.jsxs)(`div`,{ref:g,onKeyDown:n=>{jg({event:n,activeColorPickerSection:d,palette:a,color:e,onChange:t,onEyeDropperToggle:c,customColors:u,setActiveColorPickerSection:f,updateData:o,activeShade:m,onEscape:l})&&(n.preventDefault(),n.stopPropagation())},className:`color-picker-content properties-content`,tabIndex:-1,children:[!!u.length&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Mg,{children:q(`colorPicker.mostUsedCustomColors`)}),(0,K.jsx)(Og,{colors:u,color:e,label:q(`colorPicker.mostUsedCustomColors`),onChange:t})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Mg,{children:q(`colorPicker.colors`)}),(0,K.jsx)(Dg,{color:e,label:n,palette:a,onChange:t,activeShade:m})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Mg,{children:q(`colorPicker.shades`)}),(0,K.jsx)(Eg,{hex:e,onChange:t,palette:a})]}),s]})})},Pg=G.createContext(null),Fg=()=>G.useContext(Pg),Ig=e=>{let[t,n]=(0,G.useState)(null),r=vE(),{theme:i}=Fg(),{container:a}=yE();return(0,G.useLayoutEffect)(()=>{t&&(t.className=``,t.classList.add(`excalidraw`,...e?.className?.split(/\s+/)||[]),t.classList.toggle(`excalidraw--mobile`,r.editor.isMobile),t.classList.toggle(`theme--dark`,i===j.DARK))},[t,i,r.editor.isMobile,e?.className]),(0,G.useLayoutEffect)(()=>{let t=e?.parentSelector?a?.querySelector(e.parentSelector):document.body;if(!t)return;let r=document.createElement(`div`);return t.appendChild(r),n(r),()=>{t.removeChild(r)}},[a,e?.parentSelector]),t};function Lg(e,t,n){(0,G.useEffect)(()=>{function r(r){let i=r;if(!e.current)return;let a=n?.(i,e.current);if(a!==!0){if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest(`[data-radix-portal]`)||i.target===document.documentElement&&document.body.style.pointerEvents===`none`||i.target.closest(`[data-prevent-outside-click]`)||t(i)}}return document.addEventListener(`pointerdown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`pointerdown`,r),document.removeEventListener(`touchstart`,r)}},[e,t,n])}var Rg=e=>{let t=(0,G.useRef)(e);return Object.assign(t.current,e),t.current},zg=ku(null),Bg=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{let i=Ig({className:`excalidraw-eye-dropper-backdrop`,parentSelector:`.excalidraw-eye-dropper-container`}),a=Fg(),o=bE(),s=gE(),c=Rg({app:s,onCancel:e,onChange:t,onSelect:n,selectedElements:R(o,a)}),{container:l}=yE();(0,G.useEffect)(()=>{let e=u.current;if(!e||!s.canvas||!i)return;let t=!1,n=s.canvas.getContext(`2d`),o=({clientX:e,clientY:t})=>{let r=n.getImageData((e-a.offsetLeft)*window.devicePixelRatio,(t-a.offsetTop)*window.devicePixelRatio,1,1).data;return Hl(r[0],r[1],r[2])},d=({clientX:n,clientY:i,altKey:a})=>{e.style.top=`${i+20}px`,e.style.left=`${n+20}px`;let s=o({clientX:n,clientY:i});t&&c.onChange(r,s,c.selectedElements,{altKey:a}),e.style.background=s},f=()=>{c.onCancel()},p=(e,t)=>{c.onSelect(e,t)},m=e=>{t=!0,e.stopImmediatePropagation()},h=e=>{t=!1,l?.focus(),e.stopImmediatePropagation(),e.preventDefault(),p(o(e),e)},g=e=>{e.key===F.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),f())};return i.tabIndex=-1,i.focus(),d({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),i.addEventListener(`keydown`,g),i.addEventListener(`pointerdown`,m),i.addEventListener(`pointerup`,h),window.addEventListener(`pointermove`,d,{passive:!0}),window.addEventListener(`blur`,f),()=>{t=!1,i.removeEventListener(`keydown`,g),i.removeEventListener(`pointerdown`,m),i.removeEventListener(`pointerup`,h),window.removeEventListener(`pointermove`,d),window.removeEventListener(`blur`,f)}},[c,s.canvas,i,r,l,a.offsetLeft,a.offsetTop]);let u=(0,G.useRef)(null);return Lg(u,()=>{e()},e=>!!e.target.closest(`.excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop`)),i?(0,_d.createPortal)((0,K.jsx)(`div`,{ref:u,className:`excalidraw-eye-dropper-preview`}),i):null},Vg=({color:e,onChange:t,label:n,colorPickerType:r})=>{let i=vE(),[a,o]=(0,G.useState)(e),[s,c]=yh(Sg);(0,G.useEffect)(()=>{o(e)},[e]);let l=(0,G.useCallback)(e=>{let n=e.toLowerCase(),r=Gg(n);r&&t(r),o(n)},[t]),u=(0,G.useRef)(null),d=(0,G.useRef)(null);(0,G.useEffect)(()=>{u.current&&u.current.focus()},[s]);let[f,p]=yh(zg);return(0,G.useEffect)(()=>()=>{p(null)},[p]),(0,K.jsxs)(`div`,{className:`color-picker__input-label`,children:[(0,K.jsx)(`div`,{className:`color-picker__input-hash`,children:`#`}),(0,K.jsx)(`input`,{ref:s===`hex`?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:`color-picker-input`,"aria-label":n,onChange:e=>{l(e.target.value)},value:(a||``).replace(/^#/,``),onBlur:()=>{o(e)},tabIndex:-1,onFocus:()=>c(`hex`),onKeyDown:e=>{e.key!==F.TAB&&(e.key===F.ESCAPE&&d.current?.focus(),e.stopPropagation())}}),!i.editor.isMobile&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{style:{width:`1px`,height:`1.25rem`,backgroundColor:`var(--default-border-color)`}}),(0,K.jsx)(`div`,{ref:d,className:I(`excalidraw-eye-dropper-trigger`,{selected:f}),onClick:()=>p(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:r}),title:`${q(`labels.eyeDropper`)} \u2014 ${F.I.toLocaleUpperCase()} or ${B(`Alt`)} `,children:Dt})]})]})},Hg=G.forwardRef(({children:e,padding:t,className:n,style:r},i)=>(0,K.jsx)(`div`,{className:I(`Island`,n),style:{"--padding":t,...r},ref:i,children:e})),Ug=G.forwardRef(({className:e,container:t,children:n,style:r,onClose:i,onKeyDown:a,onFocusOutside:o,onPointerLeave:s,onPointerDownOutside:c},l)=>{let u=vE();return(0,K.jsx)(Tp,{container:t,children:(0,K.jsxs)(Ep,{ref:l,className:I(`focus-visible-none`,e),"data-prevent-outside-click":!0,side:u.editor.isMobile&&!u.viewport.isLandscape?`bottom`:`right`,align:u.editor.isMobile&&!u.viewport.isLandscape?`center`:`start`,alignOffset:-16,sideOffset:20,style:{zIndex:`var(--zIndex-popup)`},onPointerLeave:s,onKeyDown:a,onFocusOutside:o,onPointerDownOutside:c,onCloseAutoFocus:e=>{e.stopPropagation(),e.preventDefault(),t&&!pr(document.activeElement)&&t.focus(),i()},children:[(0,K.jsx)(Hg,{padding:3,style:r,children:n}),(0,K.jsx)(Dp,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})}),Wg=e=>{let t=new Option().style;return t.color=e,!!t.color},Gg=e=>na(e)?e:Wg(`#${e}`)?`#${e}`:Wg(e)?e:null,Kg=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Ma,updateData:o})=>{let{container:s}=yE(),[,c]=yh(Sg),[l,u]=yh(zg),d=(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Mg,{children:q(`colorPicker.hexCode`)}),(0,K.jsx)(Vg,{color:t,label:r,onChange:e=>{n(e)},colorPickerType:e})]}),f=(0,G.useRef)(null),p=()=>{f.current?.querySelector(`.color-picker-content`)?.focus()};return(0,K.jsx)(Ug,{container:s,style:{maxWidth:`13rem`},onFocusOutside:e=>{p(),e.preventDefault()},onPointerDownOutside:e=>{l&&e.preventDefault()},onClose:()=>{o({openPopup:null}),c(null)},children:a?(0,K.jsx)(Ng,{palette:a,color:t,onChange:e=>{n(e)},onEyeDropperToggle:t=>{u(r=>t?(r||={keepOpenOnAlt:!0,onSelect:n,colorPickerType:e},r.keepOpenOnAlt=!0,r):t===!1||r?null:{keepOpenOnAlt:!1,onSelect:n,colorPickerType:e})},onEscape:e=>{l?u(null):o({openPopup:null})},label:r,type:e,elements:i,updateData:o,children:d}):d})},qg=({label:e,color:t,type:n})=>(0,K.jsx)(wp,{type:`button`,className:I(`color-picker__button active-color properties-trigger`,{"is-transparent":t===`transparent`||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:q(n===`elementStroke`?`labels.showStroke`:`labels.showBackground`),children:(0,K.jsx)(`div`,{className:`color-picker__button-outline`})}),Jg=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Ma,topPicks:o,updateData:s,appState:c})=>(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`color-picker-container`,children:[(0,K.jsx)(gg,{activeColor:t,onChange:n,type:e,topPicks:o}),(0,K.jsx)(_g,{}),(0,K.jsxs)(Cp,{open:c.openPopup===e,onOpenChange:t=>{s({openPopup:t?e:null})},children:[(0,K.jsx)(qg,{color:t,label:r,type:e}),c.openPopup===e&&(0,K.jsx)(Kg,{type:e,color:t,onChange:n,label:r,elements:i,palette:a,updateData:s})]})]})}),Yg=({icon:e})=>(0,K.jsx)(`span`,{style:{width:`1em`,margin:`0 0.5ex 0 0.5ex`,display:`inline-block`,lineHeight:0,verticalAlign:`middle`},children:e}),Xg=({label:e,open:t,openTrigger:n,children:r,className:i})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{style:{cursor:`pointer`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},className:i,onClick:n,children:[e,(0,K.jsx)(Yg,{icon:t?gt:$l})]}),t&&(0,K.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:r})]}),Zg=ku(!1);function Qg({options:e,value:t,label:n,onChange:r,onClose:i,numberOfOptionsToAlwaysShow:a=e.length}){let o=vE(),s=n=>{let o=e.find(e=>e.keyBinding===n.key.toLowerCase());if(!(n.metaKey||n.altKey||n.ctrlKey)&&o)r(o.value),n.preventDefault();else if(n.key===F.TAB){let i=e.findIndex(e=>e.value===t);r(e[n.shiftKey?(e.length+i-1)%e.length:(i+1)%e.length].value)}else if(hu(n.key)){let i=Nh().rtl,o=e.findIndex(e=>e.value===t);if(o!==-1){let t=e.length,s=o;switch(n.key){case i?F.ARROW_LEFT:F.ARROW_RIGHT:s=(o+1)%t;break;case i?F.ARROW_RIGHT:F.ARROW_LEFT:s=(t+o-1)%t;break;case F.ARROW_DOWN:s=(o+(a??1))%t;break;case F.ARROW_UP:s=(t+o-(a??1))%t;break}r(e[s].value)}n.preventDefault()}else(n.key===F.ESCAPE||n.key===F.ENTER)&&(n.preventDefault(),i());n.nativeEvent.stopImmediatePropagation(),n.stopPropagation()},[c,l]=yh(Zg),u=G.useMemo(()=>e.slice(0,a),[e,a]),d=G.useMemo(()=>e.slice(a),[e,a]);(0,G.useEffect)(()=>{u.some(e=>e.value===t)||l(!0)},[t,u,l]);let f=e=>(0,K.jsx)(`div`,{className:`picker-content`,children:e.map((e,n)=>(0,K.jsxs)(`button`,{type:`button`,className:I(`picker-option`,{active:t===e.value}),onClick:t=>{r(e.value)},title:`${e.text} ${e.keyBinding&&`\u2014 ${e.keyBinding.toUpperCase()}`}`,"aria-label":e.text||`none`,"aria-keyshortcuts":e.keyBinding||void 0,ref:n=>{t===e.value&&setTimeout(()=>{n?.focus()},0)},children:[e.icon,e.keyBinding&&(0,K.jsx)(`span`,{className:`picker-keybinding`,children:e.keyBinding})]},e.text))});return(0,K.jsx)(Ep,{side:o.editor.isMobile&&!o.viewport.isLandscape?`top`:`bottom`,align:`start`,sideOffset:12,style:{zIndex:`var(--zIndex-popup)`},onKeyDown:s,children:(0,K.jsxs)(`div`,{className:`picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n,children:[f(u),d.length>0&&(0,K.jsx)(Xg,{label:q(`labels.more_options`),open:c,openTrigger:()=>{l(e=>!e)},className:`picker-collapsible`,children:f(d)})]})})}function $g({value:e,label:t,options:n,onChange:r,group:i=``,numberOfOptionsToAlwaysShow:a}){let[o,s]=G.useState(!1),c=G.useRef(null);return(0,K.jsx)(`div`,{children:(0,K.jsxs)(Cp,{open:o,onOpenChange:e=>s(e),children:[(0,K.jsx)(wp,{name:i,type:`button`,"aria-label":t,onClick:()=>s(!o),ref:c,className:o?`active`:``,children:n.find(t=>t.value===e)?.icon}),o&&(0,K.jsx)(Qg,{options:n,value:e,label:t,onChange:r,onClose:()=>{s(!1)},numberOfOptionsToAlwaysShow:a})]})})}var e_=G.forwardRef(({className:e,placeholder:t,onChange:n},r)=>(0,K.jsxs)(`div`,{className:I(`QuickSearch__wrapper`,e),children:[$a,(0,K.jsx)(`input`,{ref:r,className:`QuickSearch__input`,type:`text`,placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),t_=({className:e,placeholder:t,children:n})=>{let r=!G.Children.count(n);return(0,K.jsx)(`div`,{className:I(`ScrollableList__wrapper`,e),role:`menu`,children:r?(0,K.jsx)(`div`,{className:`empty`,children:t}):n})},n_=({children:e,className:t=``,style:n,title:r})=>(0,K.jsxs)(`div`,{className:`dropdown-menu-group ${t}`,style:n,children:[r&&(0,K.jsx)(`p`,{className:`dropdown-menu-group-title`,children:r}),e]}),r_=n_;n_.displayName=`DropdownMenuGroup`;var i_=G.createContext({}),a_=(e=``,t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
3
|
+
${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),o_=(e,t)=>{let n=(0,G.useContext)(i_);return Wo(e,e=>{let r=new CustomEvent(`menu.itemSelect`,{bubbles:!0,cancelable:!0});t?.(r),r.defaultPrevented||n.onSelect?.(r)})},s_=({textStyle:e,icon:t,shortcut:n,children:r})=>{let i=vE();return(0,K.jsxs)(K.Fragment,{children:[t&&(0,K.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,K.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:r}),n&&!i.editor.isMobile&&(0,K.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},c_=({icon:e,value:t,order:n,children:r,shortcut:i,className:a,hovered:o,selected:s,textStyle:c,onSelect:l,onClick:u,...d})=>{let f=o_(u,l),p=(0,G.useRef)(null);return(0,G.useEffect)(()=>{o&&(n===0?p.current?.scrollIntoView({block:`end`}):p.current?.scrollIntoView({block:`nearest`}))},[o,n]),(0,K.jsx)(`button`,{...d,ref:p,value:t,onClick:f,className:a_(a,s,o),title:d.title??d[`aria-label`],children:(0,K.jsx)(s_,{textStyle:c,icon:e,shortcut:i,children:r})})};c_.displayName=`DropdownMenuItem`;var l_={GREEN:`green`,RED:`red`,BLUE:`blue`},u_=({type:e=l_.BLUE,children:t})=>{let{theme:n}=xE(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===j.LIGHT?`1.5px solid white`:`none`};switch(e){case l_.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case l_.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case l_.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,K.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};u_.displayName=`DropdownMenuItemBadge`,c_.Badge=u_;var d_=c_,f_=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[F.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===F.F)return t.current?.focus(),!0;if(e.key===F.ESCAPE)return i(),!0;if(e.key===F.ENTER)return n?.value&&a(n.value),!0;if(e.key===F.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===F.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},p_=G.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o})=>{let{container:s}=yE(),{fonts:c}=gE(),{showDeprecatedFonts:l}=_E(),[u,d]=(0,G.useState)(``),f=(0,G.useRef)(null),p=(0,G.useMemo)(()=>Array.from(ao.registered.entries()).filter(([e,{metadata:t}])=>!t.serverSide&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:t.icon??Wa,text:n[0]?.fontFace?.family??`Unknown`};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:l_.RED,placeholder:q(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),m=(0,G.useMemo)(()=>new Set(c.getSceneFamilies()),[e]),h=(0,G.useMemo)(()=>p.filter(e=>m.has(e.value)),[p,m]),g=(0,G.useMemo)(()=>p.filter(e=>!m.has(e.value)&&(l||!e.deprecated)),[p,m,l]),_=(0,G.useMemo)(()=>Bo([...h,...g].filter(e=>e.text?.toLowerCase().includes(u))),[h,g,u]),v=(0,G.useMemo)(()=>{let n;return t?n=_.find(e=>e.value===t):e&&(n=_.find(t=>t.value===e)),!n&&u&&(_[0]?.value?r(_[0].value):i()),n},[t,e,u,_,r,i]),y=(0,G.useCallback)(e=>{f_({event:e,inputRef:f,hoveredFont:v,filteredFonts:_,onSelect:n,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[v,_,n,r,o]);(0,G.useEffect)(()=>(a(),()=>{o()}),[]);let b=(0,G.useMemo)(()=>_.filter(e=>m.has(e.value)),[_,m]),x=(0,G.useMemo)(()=>_.filter(e=>!m.has(e.value)),[_,m]),S=(t,i)=>(0,K.jsxs)(d_,{icon:t.icon,value:t.value,order:i,textStyle:{fontFamily:Mr({fontFamily:t.value})},hovered:t.value===v?.value,selected:t.value===e,tabIndex:t.value===e?0:-1,onClick:e=>{n(Number(e.currentTarget.value))},onMouseMove:()=>{v?.value!==t.value&&r(t.value)},children:[t.text,t.badge&&(0,K.jsx)(u_,{type:t.badge.type,children:t.badge.placeholder})]},t.value),ee=[];return b.length&&ee.push((0,K.jsx)(r_,{title:q(`fontList.sceneFonts`),children:b.map(S)},`group_1`)),x.length&&ee.push((0,K.jsx)(r_,{title:q(`fontList.availableFonts`),children:x.map((e,t)=>S(e,t+b.length))},`group_2`)),(0,K.jsxs)(Ug,{className:`properties-content`,container:s,style:{width:`15rem`},onClose:o,onPointerLeave:i,onKeyDown:y,children:[(0,K.jsx)(e_,{ref:f,placeholder:q(`quickSearch.placeholder`),onChange:Zc(d,20)}),(0,K.jsx)(t_,{className:`dropdown-menu fonts manual-hover`,placeholder:q(`fontList.empty`),children:ee.length?ee:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),m_=({selectedFontFamily:e})=>{let t=(0,G.useMemo)(()=>!!(e&&!__(e)),[e]);return(0,K.jsx)(wp,{asChild:!0,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(mg,{standalone:!0,icon:Vo,title:q(`labels.showFonts`),className:`properties-trigger`,testId:`font-family-show-fonts`,active:t,onClick:()=>{}})})})},h_=[{value:fl.Excalifont,icon:Tc,text:q(`labels.handDrawn`),testId:`font-family-hand-drawn`},{value:fl.Nunito,icon:Wa,text:q(`labels.normal`),testId:`font-family-normal`},{value:fl[`Comic Shanns`],icon:Xr,text:q(`labels.code`),testId:`font-family-code`}],g_=new Set(h_.map(e=>e.value)),__=e=>e?g_.has(e):!1,v_=G.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,onSelect:r,onHover:i,onLeave:a,onPopupChange:o})=>{let s=(0,G.useMemo)(()=>h_,[]),c=(0,G.useCallback)(e=>{e&&r(e)},[r]);return(0,K.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`FontPicker__container`,children:[(0,K.jsx)(hg,{type:`button`,options:s,value:t,onClick:c}),(0,K.jsx)(_g,{}),(0,K.jsxs)(Cp,{open:e,onOpenChange:o,children:[(0,K.jsx)(m_,{selectedFontFamily:t}),e&&(0,K.jsx)(p_,{selectedFontFamily:t,hoveredFontFamily:n,onSelect:c,onHover:i,onLeave:a,onOpen:()=>o(!0),onClose:()=>o(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),y_=({updateData:e,appState:t,elements:n,testId:r})=>{let i=G.useRef(null),a=G.useRef(null),o=S_(n,t,e=>e.opacity,!0,t.currentItemOpacity);return(0,G.useEffect)(()=>{if(i.current&&a.current){let e=i.current,t=a.current,n=e.offsetWidth,r=o/100*(n-15)+15/2;t.style.left=`${r}px`,e.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${o}%, var(--button-bg) ${o}%, var(--button-bg) 100%)`}},[o]),(0,K.jsxs)(`label`,{className:`control-label`,children:[q(`labels.opacity`),(0,K.jsxs)(`div`,{className:`range-wrapper`,children:[(0,K.jsx)(`input`,{ref:i,type:`range`,min:`0`,max:`100`,step:`10`,onChange:t=>{e(+t.target.value)},value:o,className:`range-input`,"data-testid":r}),(0,K.jsx)(`div`,{className:`value-bubble`,ref:a,children:o===0?null:o}),(0,K.jsx)(`div`,{className:`zero-label`,children:`0`})]})]})},b_=.1,x_=(e,t,n,r=!1)=>{let i=E(R(e,t,{includeBoundTextElement:r}));return e.map(e=>i.get(e.id)||e.id===t.editingTextElement?.id?n(e):e)},S_=function(e,t,n,r,i){let a=t.editingTextElement,o=V(e),s=null;return a&&(s=n(a)),s||=mo(o,t)?Qa(r===!0?o:o.filter(e=>r(e)),t,n)??(typeof i==`function`?i(!0):i):typeof i==`function`?i(!1):i,s},C_=(e,t)=>Ls(t)||!t.autoResize?t:U(t,{x:e.textAlign===`left`?e.x:e.x+(e.width-t.width)/(e.textAlign===`center`?2:1),y:e.y+(e.height-t.height)/2},!1),w_=(e,t,n,r,i)=>{let a=new Set,o=x_(e,t,e=>{if(L(e)){let t=r(e);a.add(t);let i=H(e,{fontSize:t});return Qo(i,n.scene.getContainerElement(e),n.scene.getNonDeletedElementsMap()),i=C_(e,i),i}return e},!0),s=E(o);return R(e,t,{includeBoundTextElement:!0}).forEach(e=>{L(e)&&Io(e,s)}),{elements:o,appState:{...t,currentItemFontSize:a.size===1?[...a][0]:i??t.currentItemFontSize},captureUpdate:M.IMMEDIATELY}};P({name:`changeStrokeColor`,label:`labels.stroke`,trackEvent:!1,perform:(e,t,n)=>({...n.currentItemStrokeColor&&{elements:x_(e,t,e=>mc(e.type)?H(e,{strokeColor:n.currentItemStrokeColor}):e,!0)},appState:{...t,...n},captureUpdate:n.currentItemStrokeColor?M.IMMEDIATELY:M.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{"aria-hidden":`true`,children:q(`labels.stroke`)}),(0,K.jsx)(Jg,{topPicks:si,palette:Me,type:`elementStroke`,label:q(`labels.stroke`),color:S_(e,t,e=>e.strokeColor,!0,t.currentItemStrokeColor),onChange:e=>n({currentItemStrokeColor:e}),elements:e,appState:t,updateData:n})]})}),P({name:`changeBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n)=>({...n.currentItemBackgroundColor&&{elements:x_(e,t,e=>H(e,{backgroundColor:n.currentItemBackgroundColor}))},appState:{...t,...n},captureUpdate:n.currentItemBackgroundColor?M.IMMEDIATELY:M.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{"aria-hidden":`true`,children:q(`labels.background`)}),(0,K.jsx)(Jg,{topPicks:bt,palette:Tn,type:`elementBackground`,label:q(`labels.background`),color:S_(e,t,e=>e.backgroundColor,!0,t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}),P({name:`changeFillStyle`,label:`labels.fill`,trackEvent:!1,perform:(e,t,n,r)=>(Y(`element`,`changeFillStyle`,`${n} (${r.device.editor.isMobile?`mobile`:`desktop`})`),{elements:x_(e,t,e=>H(e,{fillStyle:n})),appState:{...t,currentItemFillStyle:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=R(e,t),i=r.length>0&&r.every(e=>e.fillStyle===`zigzag`);return(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.fill`)}),(0,K.jsx)(hg,{type:`button`,options:[{value:`hachure`,text:`${q(i?`labels.zigzag`:`labels.hachure`)} (${B(`Alt-Click`)})`,icon:i?vo:Uc,active:i?!0:void 0,testId:`fill-hachure`},{value:`cross-hatch`,text:q(`labels.crossHatch`),icon:_l,testId:`fill-cross-hatch`},{value:`solid`,text:q(`labels.solid`),icon:sc,testId:`fill-solid`}],value:S_(e,t,e=>e.fillStyle,e=>e.hasOwnProperty(`fillStyle`),e=>e?null:t.currentItemFillStyle),onClick:(e,t)=>{n(t.altKey&&e===`hachure`&&r.every(e=>e.fillStyle===`hachure`)?`zigzag`:e)}})]})}}),P({name:`changeStrokeWidth`,label:`labels.strokeWidth`,trackEvent:!1,perform:(e,t,n)=>({elements:x_(e,t,e=>H(e,{strokeWidth:n})),appState:{...t,currentItemStrokeWidth:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.strokeWidth`)}),(0,K.jsx)(hg,{group:`stroke-width`,options:[{value:Ia.thin,text:q(`labels.thin`),icon:Gn,testId:`strokeWidth-thin`},{value:Ia.bold,text:q(`labels.bold`),icon:wl,testId:`strokeWidth-bold`},{value:Ia.extraBold,text:q(`labels.extraBold`),icon:ni,testId:`strokeWidth-extraBold`}],value:S_(e,t,e=>e.strokeWidth,e=>e.hasOwnProperty(`strokeWidth`),e=>e?null:t.currentItemStrokeWidth),onChange:e=>n(e)})]})}),P({name:`changeSloppiness`,label:`labels.sloppiness`,trackEvent:!1,perform:(e,t,n)=>({elements:x_(e,t,e=>H(e,{seed:vu(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.sloppiness`)}),(0,K.jsx)(hg,{group:`sloppiness`,options:[{value:0,text:q(`labels.architect`),icon:Ol},{value:1,text:q(`labels.artist`),icon:at},{value:2,text:q(`labels.cartoonist`),icon:Ni}],value:S_(e,t,e=>e.roughness,e=>e.hasOwnProperty(`roughness`),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})]})}),P({name:`changeStrokeStyle`,label:`labels.strokeStyle`,trackEvent:!1,perform:(e,t,n)=>({elements:x_(e,t,e=>H(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.strokeStyle`)}),(0,K.jsx)(hg,{group:`strokeStyle`,options:[{value:`solid`,text:q(`labels.strokeStyle_solid`),icon:Gn},{value:`dashed`,text:q(`labels.strokeStyle_dashed`),icon:bn},{value:`dotted`,text:q(`labels.strokeStyle_dotted`),icon:Gl}],value:S_(e,t,e=>e.strokeStyle,e=>e.hasOwnProperty(`strokeStyle`),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})]})}),P({name:`changeOpacity`,label:`labels.opacity`,trackEvent:!1,perform:(e,t,n)=>({elements:x_(e,t,e=>H(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsx)(y_,{updateData:n,elements:e,appState:t,testId:`opacity`})}),P({name:`changeFontSize`,label:`labels.fontSize`,trackEvent:!1,perform:(e,t,n,r)=>w_(e,t,r,()=>n,n),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.fontSize`)}),(0,K.jsx)(hg,{group:`font-size`,options:[{value:16,text:q(`labels.small`),icon:Br,testId:`fontSize-small`},{value:20,text:q(`labels.medium`),icon:Rr,testId:`fontSize-medium`},{value:28,text:q(`labels.large`),icon:wa,testId:`fontSize-large`},{value:36,text:q(`labels.veryLarge`),icon:us,testId:`fontSize-veryLarge`}],value:S_(e,t,e=>{if(L(e))return e.fontSize;let t=Mn(e,r.scene.getNonDeletedElementsMap());return t?t.fontSize:null},e=>L(e)||Mn(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:t.currentItemFontSize||20),onChange:e=>n(e)})]})});var T_=P({name:`decreaseFontSize`,label:`labels.decreaseFontSize`,icon:Ze,trackEvent:!1,perform:(e,t,n,r)=>w_(e,t,r,e=>Math.round(1/(1+b_)*e.fontSize)),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&(e.key===F.CHEVRON_LEFT||e.key===F.COMMA)}),E_=P({name:`increaseFontSize`,label:`labels.increaseFontSize`,icon:Ze,trackEvent:!1,perform:(e,t,n,r)=>w_(e,t,r,e=>Math.round(e.fontSize*(1+b_))),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&(e.key===F.CHEVRON_RIGHT||e.key===F.PERIOD)});P({name:`changeFontFamily`,label:`labels.fontFamily`,trackEvent:!1,perform:(e,t,n,r)=>{let{cachedElements:i,resetAll:a,resetContainers:o,...s}=n;if(a)return{elements:x_(e,t,e=>{let t=i?.get(e.id);return t?H(e,{...t}):e},!0),appState:{...t,...s},captureUpdate:M.NEVER};let{currentItemFontFamily:c,currentHoveredFontFamily:l}=n,u=M.EVENTUALLY,d,f=!1;if(c)d=c,u=M.IMMEDIATELY;else if(l){d=l,u=M.EVENTUALLY;let n=R(e,t,{includeBoundTextElement:!0}).filter(e=>L(e));if(n.length>200)f=!0;else{let e=0,t=0;for(;e<n.length&&t<5e3;){let r=n[e];t+=r?.originalText.length||0,e++}t>5e3&&(f=!0)}}let p={appState:{...t,...s},captureUpdate:u};if(d&&!f){let n=new Map,a=new Set,s=!1,u=Array.from(ao.loadedFontsCache.values()),f=Object.entries(fl).find(([e,t])=>t===d)?.[0];l&&f&&u.some(e=>e.startsWith(f))&&(s=!0),Object.assign(p,{elements:x_(e,t,e=>{if(L(e)&&(e.fontFamily!==d||c)){let t=H(e,{fontFamily:d,lineHeight:sa(d)}),c=i?.get(e.containerId||``)||{},l=r.scene.getContainerElement(e);return o&&l&&c&&U(l,{...c},!1),s||(a=new Set([...a,...Array.from(t.originalText)])),n.set(t,l),t}return e},!0)});let m=`10px ${Mr({fontFamily:d})}`,h=Array.from(a.values()).join();if(s||window.document.fonts.check(m,h))for(let[e,t]of n)Qo(e,t,r.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(m,h).then(e=>{for(let[e,t]of n){let n=r.scene.getElement(e.id),i=t?r.scene.getElement(t.id):null;n&&Qo(n,i,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(e)})}return p},PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=(0,G.useRef)(new Map),a=(0,G.useRef)(null),[o,s]=(0,G.useState)({}),c=(0,G.useRef)(!0),l=(0,G.useMemo)(()=>{let r=(e,n)=>S_(e,t,e=>{if(L(e))return e.fontFamily;let t=Mn(e,n);return t?t.fontFamily:null},e=>L(e)||Mn(e,n)!==null,e=>e?null:t.currentItemFontFamily||rr);return o.openPopup===`fontFamily`&&t.openPopup===`fontFamily`?r(Array.from(i.current?.values()??[]),i.current):!o.openPopup&&t.openPopup!==`fontFamily`?r(e,n.scene.getNonDeletedElementsMap()):a.current},[o.openPopup,t,e,n.scene]);return(0,G.useEffect)(()=>{a.current=l},[l]),(0,G.useEffect)(()=>{Object.keys(o).length&&(r(o),s({}))},[o]),(0,G.useEffect)(()=>(c.current=!1,()=>{c.current=!0}),[]),(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.fontFamily`)}),(0,K.jsx)(v_,{isOpened:t.openPopup===`fontFamily`,selectedFontFamily:l,hoveredFontFamily:t.currentHoveredFontFamily,onSelect:e=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),i.current.clear()},onHover:e=>{s({currentHoveredFontFamily:e,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:a=>{if(a){i.current.clear();let{editingTextElement:r}=t;if(r?.type===`text`){let e=n.scene.getElement(r.id);i.current.set(r.id,H(e||r,{},!0))}else{let n=R(e,t,{includeBoundTextElement:!0});for(let e of n)i.current.set(e.id,H(e,{},!0))}s({openPopup:`fontFamily`})}else{let e={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};c.current?r({...o,...e}):s(e),i.current.clear()}}})]})}}),P({name:`changeTextAlign`,label:`Change text alignment`,trackEvent:!1,perform:(e,t,n,r)=>({elements:x_(e,t,e=>{if(L(e)){let t=H(e,{textAlign:n});return Qo(t,r.scene.getContainerElement(e),r.scene.getNonDeletedElementsMap()),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=r.scene.getNonDeletedElementsMap();return(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.textAlign`)}),(0,K.jsx)(hg,{group:`text-align`,options:[{value:`left`,text:q(`labels.left`),icon:ai,testId:`align-left`},{value:`center`,text:q(`labels.center`),icon:Gs,testId:`align-horizontal-center`},{value:`right`,text:q(`labels.right`),icon:Ve,testId:`align-right`}],value:S_(e,t,e=>{if(L(e))return e.textAlign;let t=Mn(e,i);return t?t.textAlign:null},e=>L(e)||Mn(e,i)!==null,e=>e?null:t.currentItemTextAlign),onChange:e=>n(e)})]})}}),P({name:`changeVerticalAlign`,label:`Change vertical alignment`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:x_(e,t,e=>{if(L(e)){let t=H(e,{verticalAlign:n});return Qo(t,r.scene.getContainerElement(e),r.scene.getNonDeletedElementsMap()),t}return e},!0),appState:{...t},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(`fieldset`,{children:(0,K.jsx)(hg,{group:`text-align`,options:[{value:ll.TOP,text:q(`labels.alignTop`),icon:(0,K.jsx)(Eo,{theme:t.theme}),testId:`align-top`},{value:ll.MIDDLE,text:q(`labels.centerVertically`),icon:(0,K.jsx)(Pa,{theme:t.theme}),testId:`align-middle`},{value:ll.BOTTOM,text:q(`labels.alignBottom`),icon:(0,K.jsx)($s,{theme:t.theme}),testId:`align-bottom`}],value:S_(e,t,e=>{if(L(e)&&e.containerId)return e.verticalAlign;let t=Mn(e,r.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>L(e)||Mn(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:ll.MIDDLE),onChange:e=>n(e)})})}),P({name:`changeRoundness`,label:`Change edge roundness`,trackEvent:!1,perform:(e,t,n)=>({elements:x_(e,t,e=>T(e)?e:H(e,{roundness:n===`round`?{type:st(e.type)?pt.ADAPTIVE_RADIUS:pt.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=Ic(V(e),t).some(e=>e.roundness?.type===pt.LEGACY);return(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.edges`)}),(0,K.jsx)(hg,{group:`edges`,options:[{value:`sharp`,text:q(`labels.sharp`),icon:Cc},{value:`round`,text:q(`labels.round`),icon:ua}],value:S_(e,t,e=>r?null:e.roundness?`round`:`sharp`,e=>!xu(e)&&e.hasOwnProperty(`roundness`),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)})]})}});var D_=e=>[{value:null,text:q(`labels.arrowhead_none`),keyBinding:`q`,icon:mi},{value:`arrow`,text:q(`labels.arrowhead_arrow`),keyBinding:`w`,icon:(0,K.jsx)(Wt,{flip:e})},{value:`triangle`,text:q(`labels.arrowhead_triangle`),icon:(0,K.jsx)(Qi,{flip:e}),keyBinding:`e`},{value:`triangle_outline`,text:q(`labels.arrowhead_triangle_outline`),icon:(0,K.jsx)(Ke,{flip:e}),keyBinding:`r`},{value:`circle`,text:q(`labels.arrowhead_circle`),keyBinding:`a`,icon:(0,K.jsx)(po,{flip:e})},{value:`circle_outline`,text:q(`labels.arrowhead_circle_outline`),keyBinding:`s`,icon:(0,K.jsx)(xa,{flip:e})},{value:`diamond`,text:q(`labels.arrowhead_diamond`),icon:(0,K.jsx)(tn,{flip:e}),keyBinding:`d`},{value:`diamond_outline`,text:q(`labels.arrowhead_diamond_outline`),icon:(0,K.jsx)(Tu,{flip:e}),keyBinding:`f`},{value:`bar`,text:q(`labels.arrowhead_bar`),keyBinding:`z`,icon:(0,K.jsx)(mr,{flip:e})},{value:`crowfoot_one`,text:q(`labels.arrowhead_crowfoot_one`),icon:(0,K.jsx)(zt,{flip:e}),keyBinding:`c`},{value:`crowfoot_many`,text:q(`labels.arrowhead_crowfoot_many`),icon:(0,K.jsx)(xi,{flip:e}),keyBinding:`x`},{value:`crowfoot_one_or_many`,text:q(`labels.arrowhead_crowfoot_one_or_many`),icon:(0,K.jsx)(qt,{flip:e}),keyBinding:`v`}];P({name:`changeArrowhead`,label:`Change arrowheads`,trackEvent:!1,perform:(e,t,n)=>({elements:x_(e,t,e=>{if(Ac(e)){let{position:t,type:r}=n;if(t===`start`)return H(e,{startArrowhead:r});if(t===`end`)return H(e,{endArrowhead:r})}return e}),appState:{...t,[n.position===`start`?`currentItemStartArrowhead`:`currentItemEndArrowhead`]:n.type},captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=Nh().rtl;return(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.arrowheads`)}),(0,K.jsxs)(`div`,{className:`iconSelectList buttonList`,children:[(0,K.jsx)($g,{label:`arrowhead_start`,options:D_(!r),value:S_(e,t,e=>Ac(e)&&Ks(e.type)?e.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:e=>n({position:`start`,type:e}),numberOfOptionsToAlwaysShow:4}),(0,K.jsx)($g,{label:`arrowhead_end`,group:`arrowheads`,options:D_(!!r),value:S_(e,t,e=>Ac(e)&&Ks(e.type)?e.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:e=>n({position:`end`,type:e}),numberOfOptionsToAlwaysShow:4})]})]})}}),P({name:`changeArrowType`,label:`Change arrow types`,trackEvent:!1,perform:(e,t,n,r)=>{let i=x_(e,t,i=>{if(!xu(i))return i;let a=H(i,{roundness:n===Ri.round?{type:pt.PROPORTIONAL_RADIUS}:null,elbowed:n===Ri.elbow,points:n===Ri.elbow||i.elbowed?[i.points[0],i.points[i.points.length-1]]:i.points});if(T(a)){let n=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let i=N.getPointAtIndexGlobalCoordinates(a,0,n),o=N.getPointAtIndexGlobalCoordinates(a,-1,n),s=!a.startBinding&&ar(ki(i),e,n,t.zoom,!1,!0),c=!a.endBinding&&ar(ki(o),e,n,t.zoom,!1,!0),l=s||a.startBinding&&n.get(a.startBinding.elementId),u=c||a.endBinding&&n.get(a.endBinding.elementId),d=s?_o(a,s,`start`):i,f=c?_o(a,c,`end`):o;s&&be(a,s,`start`,n),c&&be(a,c,`end`,n),U(a,{points:[d,f].map(e=>O(e[0]-a.x,e[1]-a.y)),...l&&a.startBinding?{startBinding:{...a.startBinding,...Hr(a,l,`start`,n)}}:{},...u&&a.endBinding?{endBinding:{...a.endBinding,...Hr(a,u,`end`,n)}}:{}}),N.updateEditorMidPointsCache(a,n,r.state)}return a}),a={...t,currentItemArrowType:n},o=t.selectedLinearElement?.elementId;if(o){let e=i.find(e=>e.id===o);e&&(a.selectedLinearElement=new N(e))}return{elements:i,appState:a,captureUpdate:M.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.arrowtypes`)}),(0,K.jsx)(hg,{group:`arrowtypes`,options:[{value:Ri.sharp,text:q(`labels.arrowtype_sharp`),icon:Ut,testId:`sharp-arrow`},{value:Ri.round,text:q(`labels.arrowtype_round`),icon:_r,testId:`round-arrow`},{value:Ri.elbow,text:q(`labels.arrowtype_elbowed`),icon:Nr,testId:`elbow-arrow`}],value:S_(e,t,e=>xu(e)?e.elbowed?Ri.elbow:e.roundness?Ri.round:Ri.sharp:null,e=>xu(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})]})});var O_=({viewportX:e,viewportY:t,nextZoom:n},r)=>{let i=e-r.offsetLeft,a=t-r.offsetTop,o=r.zoom.value,s=r.scrollX+(i-i/o),c=r.scrollY+(a-a/o),l=-(i-i/n),u=-(a-a/n);return{scrollX:s+l,scrollY:c+u,zoom:{value:n}}},k_=()=>{let e=document.querySelector(`.excalidraw-tooltip`);if(e)return e;let t=document.createElement(`div`);return document.body.appendChild(t),t.classList.add(`excalidraw-tooltip`),t},A_=(e,t,n=`bottom`)=>{let r=e.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,o=t.left+t.width/2-r.width/2;o<0?o=5:o+r.width>=i&&(o=i-r.width-5);let s;n===`bottom`?(s=t.top+t.height+5,s+r.height>=a&&(s=t.top-r.height-5)):(s=t.top-r.height-5,s<0&&(s=t.top+t.height+5)),Object.assign(e.style,{top:`${s}px`,left:`${o}px`})},j_=(e,t,n,r)=>{t.classList.add(`excalidraw-tooltip--visible`),t.style.minWidth=r?`50ch`:`10ch`,t.style.maxWidth=r?`50ch`:`15ch`,t.textContent=n,A_(t,e.getBoundingClientRect())},M_=({children:e,label:t,long:n=!1,style:r,disabled:i})=>((0,G.useEffect)(()=>()=>k_().classList.remove(`excalidraw-tooltip--visible`),[]),i?null:(0,K.jsx)(`div`,{className:`excalidraw-tooltip-wrapper`,onPointerEnter:e=>j_(e.currentTarget,k_(),t,n),onPointerLeave:()=>k_().classList.remove(`excalidraw-tooltip--visible`),style:r,children:e}));P({name:`changeViewBackgroundColor`,label:`labels.canvasBackground`,paletteName:`Change canvas background color`,trackEvent:!1,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:n.viewBackgroundColor?M.IMMEDIATELY:M.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>(0,K.jsx)(Jg,{palette:null,topPicks:je,label:q(`labels.canvasBackground`),type:`canvasBackground`,color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":`canvas-background-picker`,elements:e,appState:t,updateData:n})});var N_=P({name:`clearCanvas`,label:`labels.clearCanvas`,paletteName:`Clear canvas`,icon:cu,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`,perform:(e,t,n,r)=>(r.imageCache.clear(),{elements:e.map(e=>H(e,{isDeleted:!0})),appState:{...Na(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type===`image`?{...t.activeTool,type:`selection`}:t.activeTool},captureUpdate:M.IMMEDIATELY})}),P_=P({name:`zoomIn`,label:`buttons.zoomIn`,viewMode:!0,icon:Ta,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>({appState:{...t,...O_({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Ur(t.zoom.value+Qt)},t),userToFollow:null},captureUpdate:M.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(J,{type:`button`,className:`zoom-in-button zoom-button`,icon:Ta,title:`${q(`buttons.zoomIn`)} \u2014 ${B(`CtrlOrCmd++`)}`,"aria-label":q(`buttons.zoomIn`),disabled:t.zoom.value>=30,onClick:()=>{e(null)}}),keyTest:e=>(e.code===k.EQUAL||e.code===k.NUM_ADD)&&(e[F.CTRL_OR_CMD]||e.shiftKey)}),F_=P({name:`zoomOut`,label:`buttons.zoomOut`,icon:co,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>({appState:{...t,...O_({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Ur(t.zoom.value-Qt)},t),userToFollow:null},captureUpdate:M.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(J,{type:`button`,className:`zoom-out-button zoom-button`,icon:co,title:`${q(`buttons.zoomOut`)} \u2014 ${B(`CtrlOrCmd+-`)}`,"aria-label":q(`buttons.zoomOut`),disabled:t.zoom.value<=Ko,onClick:()=>{e(null)}}),keyTest:e=>(e.code===k.MINUS||e.code===k.NUM_SUBTRACT)&&(e[F.CTRL_OR_CMD]||e.shiftKey)}),I_=P({name:`resetZoom`,label:`buttons.resetZoom`,icon:Hi,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>({appState:{...t,...O_({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Ur(1)},t),userToFollow:null},captureUpdate:M.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,K.jsx)(M_,{label:q(`buttons.resetZoom`),style:{height:`100%`},children:(0,K.jsxs)(J,{type:`button`,className:`reset-zoom-button zoom-button`,title:q(`buttons.resetZoom`),"aria-label":q(`buttons.resetZoom`),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),`%`]})}),keyTest:e=>(e.code===k.ZERO||e.code===k.NUM_ZERO)&&(e[F.CTRL_OR_CMD]||e.shiftKey)}),L_=(e,t,n=1)=>{let[r,i,a,o]=e,s=a-r,c=t.width/s,l=o-i,u=t.height/l,d=Math.min(c,u)*pa(n,.1,1);return Math.min(d,1)},R_=({bounds:e,appState:t,canvasOffsets:n,fitToViewport:r=!1,viewportZoomFactor:i=1,minZoom:a=-1/0,maxZoom:o=1/0})=>{i=pa(i,Ko,30);let[s,c,l,u]=e,d=(s+l)/2,f=(c+u)/2,p=n?.left??0,m=n?.top??0,h=n?.right??0,g=n?.bottom??0,_=t.width-p-h,v=t.height-m-g,y;if(r){let e=l-s,t=u-c;y=Math.min(_/e,v/t)*i}else y=L_(e,{width:_,height:v},i);let b=Ur(pa(Oi(y,Qt,`floor`),a,o)),x=ut({scenePoint:{x:d,y:f},viewportDimensions:{width:t.width,height:t.height},offsets:n,zoom:{value:b}});return{appState:{...t,scrollX:x.scrollX,scrollY:x.scrollY,zoom:{value:b}},captureUpdate:M.EVENTUALLY}},z_=({canvasOffsets:e,targetElements:t,appState:n,fitToViewport:r,viewportZoomFactor:i,minZoom:a,maxZoom:o})=>R_({canvasOffsets:e,bounds:Zo(V(t)),appState:n,fitToViewport:r,viewportZoomFactor:i,minZoom:a,maxZoom:o});P({name:`zoomToFitSelectionInViewport`,label:`labels.zoomToFitViewport`,icon:Ot,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return z_({targetElements:i.length?i:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===k.TWO&&e.shiftKey&&!e.altKey&&!e[F.CTRL_OR_CMD]}),P({name:`zoomToFitSelection`,label:`helpDialog.zoomToSelection`,icon:Ot,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return z_({targetElements:i.length?i:e,appState:{...t,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===k.THREE&&e.shiftKey&&!e.altKey&&!e[F.CTRL_OR_CMD]}),P({name:`zoomToFit`,label:`helpDialog.zoomToFit`,icon:Ot,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>z_({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===k.ONE&&e.shiftKey&&!e.altKey&&!e[F.CTRL_OR_CMD]});var B_=P({name:`toggleTheme`,label:(e,t)=>t.theme===j.DARK?`buttons.lightMode`:`buttons.darkMode`,keywords:[`toggle`,`dark`,`light`,`mode`,`theme`],icon:e=>e.theme===j.LIGHT?os:Ca,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n)=>({appState:{...t,theme:n||(t.theme===j.LIGHT?j.DARK:j.LIGHT)},captureUpdate:M.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===k.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme});P({name:`toggleEraserTool`,label:`toolBar.eraser`,trackEvent:{category:`toolbar`},perform:(e,t)=>{let n;return n=it(t)?Ha(t,{...t.activeTool.lastActiveTool||{type:`selection`},lastActiveToolBeforeEraser:null}):Ha(t,{type:`eraser`,lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:M.IMMEDIATELY}},keyTest:e=>e.key===F.E});var V_=P({name:`toggleHandTool`,label:`toolBar.hand`,paletteName:`Toggle hand tool`,trackEvent:{category:`toolbar`},icon:So,viewMode:!1,perform:(e,t,n,r)=>{let i;return Yr(t)?i=Ha(t,{...t.activeTool.lastActiveTool||{type:`selection`},lastActiveToolBeforeEraser:null}):(i=Ha(t,{type:`hand`,lastActiveToolBeforeEraser:t.activeTool}),z(r.interactiveCanvas,W.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:i},captureUpdate:M.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[F.CTRL_OR_CMD]&&e.key===F.H}),H_=P({name:`finalize`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let{interactiveCanvas:i,focusContainer:a,scene:o}=r,s=o.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:n,startBindingElement:r,endBindingElement:i}=t.editingLinearElement,a=N.getElement(n,s);if(a)return Jt(a)&&he(a,r,i,s,o),{elements:a.points.length<2||Ii(a)?e.filter(e=>e.id!==a.id):void 0,appState:{...t,cursorButton:`up`,editingLinearElement:null},captureUpdate:M.IMMEDIATELY}}let c=e,l=t.pendingImageElementId&&o.getElement(t.pendingImageElementId);l&&U(l,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&a();let u=t.multiElement?t.multiElement:t.newElement?.type===`freedraw`?t.newElement:null;if(u){if(u.type!==`freedraw`&&t.lastPointerDownWith!==`touch`){let{points:e,lastCommittedPoint:t}=u;(!t||e[e.length-1]!==t)&&U(u,{points:u.points.slice(0,-1)})}Ii(u)&&(c=c.filter(e=>e.id!==u.id));let n=ye(u.points,t.zoom.value);if((u.type===`line`||u.type===`freedraw`)&&n){let e=u.points,t=e[0];U(u,{points:e.map((n,r)=>r===e.length-1?O(t[0],t[1]):n)})}if(Jt(u)&&!n&&u.points.length>1){let[n,r]=N.getPointAtIndexGlobalCoordinates(u,-1,E(e));Ra(u,t,{x:n,y:r},s,e)}}(!t.activeTool.locked&&t.activeTool.type!==`freedraw`||!u)&&pi(i);let d;return d=t.activeTool.type===`eraser`?Ha(t,{...t.activeTool.lastActiveTool||{type:`selection`},lastActiveToolBeforeEraser:null}):Ha(t,{type:`selection`}),{elements:c,appState:{...t,cursorButton:`up`,activeTool:(t.activeTool.locked||t.activeTool.type===`freedraw`)&&u?t.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:u&&!t.activeTool.locked&&t.activeTool.type!==`freedraw`?{...t.selectedElementIds,[u.id]:!0}:t.selectedElementIds,selectedLinearElement:u&&Ac(u)?new N(u):t.selectedLinearElement,pendingImageElementId:null},captureUpdate:M.IMMEDIATELY}},keyTest:(e,t)=>e.key===F.ESCAPE&&(t.editingLinearElement!==null||!t.newElement&&t.multiElement===null)||(e.key===F.ESCAPE||e.key===F.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>(0,K.jsx)(J,{type:`button`,icon:yr,title:q(`buttons.done`),"aria-label":q(`buttons.done`),onClick:t,visible:e.multiElement!=null,size:n?.size||`medium`,style:{pointerEvents:`all`}})}),U_=e=>{let{id:t}=yE(),[n,r]=(0,G.useState)(e.value);return(0,K.jsxs)(`div`,{className:`ProjectName`,children:[(0,K.jsx)(`label`,{className:`ProjectName-label`,htmlFor:`filename`,children:`${e.label}:`}),(0,K.jsx)(`input`,{type:`text`,className:`TextInput`,onBlur:t=>{e.ignoreFocus||pc(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{if(e.key===F.ENTER){if(e.preventDefault(),e.nativeEvent.isComposing||e.keyCode===229)return;e.currentTarget.blur()}},id:`${t}-filename`,value:n,onChange:e=>r(e.target.value)})]})},W_=e=>{let t=e.title||(e.value===j.DARK?q(`buttons.lightMode`):q(`buttons.darkMode`));return(0,K.jsx)(J,{type:`icon`,icon:e.value===j.LIGHT?G_.MOON:G_.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===j.DARK?j.LIGHT:j.DARK),"data-testid":`toggle-dark-mode`})},G_={SUN:(0,K.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z`})}),MOON:(0,K.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z`})})},K_=(e,{selectedElementIds:t},n)=>{e=V(e);let r=n&&mo(e,{selectedElementIds:t}),i=null,a=r?R(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return r&&(a.length===1&&D(a[0])?(i=a[0],a=Xs(e,i)):a.length>1&&(a=R(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:ke(a)}},q_=async(e,t,n,r,{exportBackground:i,exportPadding:a=10,viewBackgroundColor:o,name:s=n.name||`Untitled`,fileHandle:c=null,exportingFrame:l=null})=>{if(t.length===0)throw Error(q(`alerts.cannotExportEmptyCanvas`));if(e===`svg`||e===`clipboard-svg`){let u=fn(t,{exportBackground:i,exportWithDarkMode:n.exportWithDarkMode,viewBackgroundColor:o,exportPadding:a,exportScale:n.exportScale,exportEmbedScene:n.exportEmbedScene&&e===`svg`},r,{exportingFrame:l});if(e===`svg`)return ji(u.then(e=>new Blob([e.outerHTML],{type:Pr.svg})),{description:`Export to SVG`,name:s,extension:n.exportEmbedScene?`excalidraw.svg`:`svg`,mimeTypes:[ks.svg],fileHandle:c});if(e===`clipboard-svg`){let e=await u.then(e=>e.outerHTML);try{await ti(e)}catch{throw Error(q(`errors.copyToSystemClipboardFailed`))}return}}let u=St(t,n,r,{exportBackground:i,viewBackgroundColor:o,exportPadding:a,exportingFrame:l});if(e===`png`){let e=br(u);return n.exportEmbedScene&&(e=e.then(e=>v(async()=>{let{encodePngMetadata:e}=await import(`./image-GAAHSSAO-C7O7NdjH.js`);return{encodePngMetadata:e}},__vite__mapDeps([59,1,2,60,61,62,63])).then(({encodePngMetadata:i})=>i({blob:e,metadata:ve(t,n,r,`local`)})))),ji(e,{description:`Export to PNG`,name:s,extension:n.exportEmbedScene?`excalidraw.png`:`png`,mimeTypes:[ks.png],fileHandle:c})}else if(e===`clipboard`)try{await Vt(br(u))}catch(e){throw console.warn(e),e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(q(`canvasError.canvasTooBig`)):Ei&&e.name===`TypeError`?Error(`${q(`alerts.couldNotCopyToClipboard`)}
|
|
4
|
+
|
|
5
|
+
${q(`hints.firefox_clipboard_write`)}`):Error(q(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},J_=async(e,t,n,r)=>{let{exportBackground:i,viewBackgroundColor:a,fileHandle:o}=t,s=uu(o);if(!o||!ea(s))throw Error(`fileHandle should exist and should be of type svg or png when resaving`);t={...t,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:l}=K_(e,t,!1);return await q_(s,c,t,n,{exportBackground:i,viewBackgroundColor:a,name:r,fileHandle:o,exportingFrame:l}),{fileHandle:o}},Y_=({children:e,checked:t,onChange:n,className:r})=>(0,K.jsxs)(`div`,{className:I(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,K.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:Fe}),(0,K.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),X_=P({name:`changeProjectName`,label:`labels.fileTitle`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:M.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>(0,K.jsx)(U_,{label:q(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),Z_=P({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:M.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=V(e),i=mo(r,t)?R(r,t):r;return(0,K.jsx)(K.Fragment,{children:Ti.map(e=>{let[r,a]=bl(i,10,e),o=`${q(`imageExportDialog.label.scale`)} ${e}x (${r}x${a})`;return(0,K.jsx)(J,{size:`small`,type:`radio`,icon:`${e}x`,name:`export-canvas-scale`,title:o,"aria-label":o,id:`export-canvas-scale`,checked:e===t.exportScale,onChange:()=>n(e)},e)})})}}),Q_=P({name:`changeExportBackground`,label:`imageExportDialog.label.withBackground`,trackEvent:{category:`export`,action:`toggleBackground`},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:M.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,K.jsx)(Y_,{checked:e.exportBackground,onChange:e=>t(e),children:q(`imageExportDialog.label.withBackground`)})}),$_=P({name:`changeExportEmbedScene`,label:`imageExportDialog.tooltip.embedScene`,trackEvent:{category:`export`,action:`embedScene`},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:M.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,K.jsxs)(Y_,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[q(`imageExportDialog.label.embedScene`),(0,K.jsx)(M_,{label:q(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,K.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:Ae})})]})}),ev=P({name:`saveToActiveFile`,label:`buttons.save`,icon:As,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{let i=!!t.fileHandle;try{let{fileHandle:n}=_i(t.fileHandle)?await J_(e,t,r.files,r.getName()):await Il(e,t,r.files,r.getName());return{captureUpdate:M.EVENTUALLY,appState:{...t,fileHandle:n,toast:i?{message:n?.name?q(`toast.fileSavedToFilename`).replace(`{filename}`,`"${n.name}"`):q(`toast.fileSaved`)}:null}}}catch(e){return e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:M.EVENTUALLY}}},keyTest:e=>e.key===F.S&&e[F.CTRL_OR_CMD]&&!e.shiftKey}),tv=P({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:As,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{try{let{fileHandle:n}=await Il(e,{...t,fileHandle:null},r.files,r.getName());return{captureUpdate:M.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:n,toast:{message:q(`toast.fileSaved`)}}}}catch(e){return e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:M.EVENTUALLY}}},keyTest:e=>e.key===F.S&&e.shiftKey&&e[F.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,K.jsx)(J,{type:`button`,icon:ma,title:q(`buttons.saveAs`),"aria-label":q(`buttons.saveAs`),showAriaLabel:vE().editor.isMobile,hidden:!Bt,onClick:()=>e(null),"data-testid":`save-as-button`})}),nv=P({name:`loadScene`,label:`buttons.load`,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{try{let{elements:n,appState:r,files:i}=await ri(t,e);return{elements:n,appState:r,files:i,captureUpdate:M.IMMEDIATELY}}catch(n){return n?.name===`AbortError`?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:M.EVENTUALLY}}},keyTest:e=>e[F.CTRL_OR_CMD]&&e.key===F.O}),rv=P({name:`exportWithDarkMode`,label:`imageExportDialog.label.darkMode`,trackEvent:{category:`export`,action:`toggleTheme`},perform:(e,t,n)=>({appState:{...t,exportWithDarkMode:n},captureUpdate:M.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,K.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:`-45px`,marginBottom:`10px`},children:(0,K.jsx)(W_,{value:e.exportWithDarkMode?j.DARK:j.LIGHT,onChange:e=>{t(e===j.DARK)},title:q(`imageExportDialog.label.darkMode`)})})}),iv=`{}`,av=P({name:`copyStyles`,label:`labels.copyStyles`,icon:Ce,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=[],a=e.find(e=>t.selectedElementIds[e.id]);if(i.push(a),a&&Ja(a)){let e=Mn(a,r.scene.getNonDeletedElementsMap());i.push(e)}return a&&(iv=JSON.stringify(i)),{appState:{...t,toast:{message:q(`toast.copyStyles`)}},captureUpdate:M.EVENTUALLY}},keyTest:e=>e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.C}),ov=P({name:`pasteStyles`,label:`labels.pasteStyles`,icon:Ce,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=JSON.parse(iv),a=i[0],o=i[1];if(!Ka(a))return{elements:e,captureUpdate:M.EVENTUALLY};let s=R(e,t,{includeBoundTextElement:!0}),c=s.map(e=>e.id);return{elements:e.map(e=>{if(c.includes(e.id)){let t=a;if(L(e)&&e.containerId&&(t=o),!t)return e;let n=H(e,{backgroundColor:t?.backgroundColor,strokeWidth:t?.strokeWidth,strokeColor:t?.strokeColor,strokeStyle:t?.strokeStyle,fillStyle:t?.fillStyle,opacity:t?.opacity,roughness:t?.roughness,roundness:t.roundness?la(t.roundness.type,e)?t.roundness:Qr(e):null});if(L(n)){let e=t.fontSize||20,i=t.fontFamily||rr;n=H(n,{fontSize:e,fontFamily:i,textAlign:t.textAlign||`left`,lineHeight:t.lineHeight||sa(i)});let a=null;n.containerId&&(a=s.find(e=>L(n)&&e.id===n.containerId)||null),Qo(n,a,r.scene.getNonDeletedElementsMap())}return n.type===`arrow`&&xu(t)&&(n=H(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),D(e)&&(n=H(n,{roundness:null,backgroundColor:`transparent`})),n}return e}),captureUpdate:M.IMMEDIATELY}},keyTest:e=>e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.V});P({name:`toggleCanvasMenu`,label:`buttons.menu`,trackEvent:{category:`menu`},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu===`canvas`?null:`canvas`},captureUpdate:M.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,K.jsx)(J,{type:`button`,icon:Xc,"aria-label":q(`buttons.menu`),onClick:t,selected:e.openMenu===`canvas`})}),P({name:`toggleEditMenu`,label:`buttons.edit`,trackEvent:{category:`menu`},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu===`shape`?null:`shape`},captureUpdate:M.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsx)(J,{visible:Fl(t,V(e)),type:`button`,icon:De,"aria-label":q(`buttons.edit`),onClick:n,selected:t.openMenu===`shape`})});var sv=P({name:`toggleShortcuts`,label:`welcomeScreen.defaults.helpHint`,icon:Js,viewMode:!0,trackEvent:{category:`menu`,action:`toggleHelpDialog`},perform:(e,t,n,{focusContainer:r})=>(t.openDialog?.name===`help`&&r(),{appState:{...t,openDialog:t.openDialog?.name===`help`?null:{name:`help`}},captureUpdate:M.EVENTUALLY}),keyTest:e=>e.key===F.QUESTION_MARK}),cv=e=>{if(e.length>=2){let t=e[0].groupIds;for(let n of t)if(e.reduce((e,t)=>e&&jr(t,n),!0))return!0}return!1},lv=(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!cv(r)&&!Tr(r)},uv=P({name:`group`,label:`labels.group`,icon:e=>(0,K.jsx)(xr,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=La(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(i.length<2)return{appState:t,elements:e,captureUpdate:M.EVENTUALLY};let a=ot(t);if(a.length===1){let n=a[0],r=new Set(Ki(e,n).map(e=>e.id)),o=new Set(i.map(e=>e.id));if(new Set([...Array.from(r),...Array.from(o)]).size===r.size)return{appState:t,elements:e,captureUpdate:M.EVENTUALLY}}let o=[...e];new Set(i.map(e=>e.frameId)).size>1&&rs(i).forEach((e,t)=>{Qc(e,r.scene.getNonDeletedElementsMap())});let s=Yc(),c=E(i);o=o.map(e=>c.get(e.id)?H(e,{groupIds:Re(e.groupIds,s,t.editingGroupId)}):e);let l=Ki(o,s),u=l[l.length-1],d=o.lastIndexOf(u),f=o.slice(d+1),p=bs([...o.slice(0,d).filter(e=>!jr(e,s)),...l,...f],E(l));return{appState:{...t,...xc(s,{...t,selectedGroupIds:{}},V(o))},elements:p,captureUpdate:M.IMMEDIATELY}},predicate:(e,t,n,r)=>lv(e,t,r),keyTest:e=>!e.shiftKey&&e[F.CTRL_OR_CMD]&&e.key===F.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!lv(e,t,r),type:`button`,icon:(0,K.jsx)(xr,{theme:t.theme}),onClick:()=>n(null),title:`${q(`labels.group`)} \u2014 ${B(`CtrlOrCmd+G`)}`,"aria-label":q(`labels.group`),visible:mo(V(e),t)})}),dv=P({name:`ungroup`,label:`labels.ungroup`,icon:e=>(0,K.jsx)(yi,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=ot(t),a=E(e);if(i.length===0)return{appState:t,elements:e,captureUpdate:M.EVENTUALLY};let o=[...e],s=[];o=o.map(e=>{Ls(e)&&s.push(e.id);let n=Xi(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:H(e,{groupIds:n})});let c=xt(t,V(o),t,null),l=r.scene.getSelectedElements(t),u=new Set(l.filter(e=>e.frameId).map(e=>e.frameId));return Wn(e).filter(e=>u.has(e.id)).forEach(e=>{e&&(o=_a(o,El(o,e,t,a),e,r))}),c.selectedElementIds=Object.entries(c.selectedElementIds).reduce((e,[t,n])=>(n&&!s.includes(t)&&(e[t]=!0),e),{}),{appState:{...t,...c},elements:o,captureUpdate:M.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[F.CTRL_OR_CMD]&&e.key===F.G.toUpperCase(),predicate:(e,t)=>ot(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,K.jsx)(J,{type:`button`,hidden:ot(t).length===0,icon:(0,K.jsx)(yi,{theme:t.theme}),onClick:()=>n(null),title:`${q(`labels.ungroup`)} \u2014 ${B(`CtrlOrCmd+Shift+G`)}`,"aria-label":q(`labels.ungroup`),visible:mo(V(e),t)})}),fv=(e,t,n,r,i,a,o)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath(),e.fill(),o&&(e.strokeStyle=o),e.stroke()};function pv(e){let t=0;if(e.length===0)return t;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r}return t}var mv=(e,t)=>`hsl(${Math.abs(pv(t?.id||e))%37*10}, 100%, 83%)`,hv=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):`?`).toUpperCase()},gv=({context:e,renderConfig:t,appState:n,normalizedWidth:r,normalizedHeight:i})=>{for(let[a,o]of t.remotePointerViewportCoords){let{x:s,y:c}=o,l=n.collaborators.get(a);s-=n.offsetLeft,c-=n.offsetTop;let u=s<0||s>r-11||c<0||c>i-14;s=Math.max(s,0),s=Math.min(s,r-11),c=Math.max(c,0),c=Math.min(c,i-14);let d=mv(a,l);e.save(),e.strokeStyle=d,e.fillStyle=d;let f=t.remotePointerUserStates.get(a),p=u||f===`idle`||f===`away`;p&&(e.globalAlpha=.3),t.remotePointerButton.get(a)===`down`&&(e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle=`#ffffff88`,e.stroke(),e.closePath(),e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=d,e.stroke(),e.closePath());let m=n.theme===j.DARK?`#2f6330`:Wi,h=l?.isSpeaking;h&&(e.fillStyle=m,e.strokeStyle=m,e.lineWidth=10,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Ro,e.strokeStyle=Ro,e.lineWidth=6,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=d,e.strokeStyle=d,e.lineWidth=2,e.lineJoin=`round`,e.beginPath(),p?(e.moveTo(s-1,c-1),e.lineTo(s-1,c+15),e.lineTo(s+5,c+10),e.lineTo(s+12,c+9),e.closePath(),e.fill()):(e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.fill(),e.stroke());let g=t.remotePointerUsernames.get(a)||``;if(!u&&g){e.font=`600 12px sans-serif`;let t=(h?s+0:s)+11/2,n=(h?c+0:c)+14+2,r=e.measureText(g),i=r.actualBoundingBoxDescent+r.actualBoundingBoxAscent,a=Math.max(i,12),o=t-1,l=n-1,u=r.width+2+10+2,f=a+2+6+2;e.roundRect?(e.beginPath(),e.roundRect(o,l,u,f,8),e.fillStyle=d,e.fill(),e.strokeStyle=`#ffffff`,e.stroke(),h&&(e.beginPath(),e.roundRect(o-2,l-2,u+4,f+4,8),e.strokeStyle=m,e.stroke())):fv(e,o,l,u,f,8,`#ffffff`),e.fillStyle=`#1e1e1e`,e.fillText(g,t+5+1,n+3+r.actualBoundingBoxAscent+Math.floor((a-i)/2)+2),h&&(e.fillStyle=m,e.fillRect(o+u+8,l+(f/2-8/2),2,8),e.fillRect(o+u+8+5,l+(f/2-16/2),2,16),e.fillRect(o+u+8+10,l+(f/2-8/2),2,8))}e.restore(),e.closePath()}},_v=({color:e,onClick:t,name:n,src:r,className:i})=>{let a=hv(n),[o,s]=(0,G.useState)(!1),c=!o&&r,l=c?void 0:{background:e};return(0,K.jsx)(`div`,{className:I(`Avatar`,i),style:l,onClick:t,children:c?(0,K.jsx)(`img`,{className:`Avatar-img`,src:r,alt:a,referrerPolicy:`no-referrer`,onError:()=>s(!0)}):a})};P({name:`goToCollaborator`,label:`Go to a collaborator`,viewMode:!0,trackEvent:{category:`collab`},perform:(e,t,n)=>!n.socketId||t.userToFollow?.socketId===n.socketId||n.isCurrentUser?{appState:{...t,userToFollow:null},captureUpdate:M.EVENTUALLY}:{appState:{...t,userToFollow:{socketId:n.socketId,username:n.username||``},openMenu:t.openMenu===`canvas`?null:t.openMenu},captureUpdate:M.EVENTUALLY},PanelComponent:({updateData:e,data:t,appState:n})=>{let{socketId:r,collaborator:i,withName:a,isBeingFollowed:o}=t,s=mv(r,i),c=I({"is-followed":o,"is-current-user":i.isCurrentUser===!0,"is-speaking":i.isSpeaking,"is-in-call":i.isInCall,"is-muted":i.isMuted}),l=i.isInCall?i.isSpeaking?(0,K.jsxs)(`div`,{className:`UserList__collaborator-status-icon-speaking-indicator`,title:q(`userList.hint.isSpeaking`),children:[(0,K.jsx)(`div`,{}),(0,K.jsx)(`div`,{}),(0,K.jsx)(`div`,{})]}):i.isMuted?(0,K.jsx)(`div`,{className:`UserList__collaborator-status-icon-microphone-muted`,title:q(`userList.hint.micMuted`),children:fc}):(0,K.jsx)(`div`,{title:q(`userList.hint.inCall`),children:wu}):null;return a?(0,K.jsxs)(`div`,{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${c}`,style:{"--avatar-size":`1.5rem`},onClick:()=>e(i),children:[(0,K.jsx)(_v,{color:s,onClick:()=>{},name:i.username||``,src:i.avatarUrl,className:c}),(0,K.jsx)(`div`,{className:`UserList__collaborator-name`,children:i.username}),(0,K.jsxs)(`div`,{className:`UserList__collaborator-status-icons`,"aria-hidden":!0,children:[o&&(0,K.jsx)(`div`,{className:`UserList__collaborator-status-icon-is-followed`,title:q(`userList.hint.followStatus`),children:va}),l]})]}):(0,K.jsxs)(`div`,{className:`UserList__collaborator UserList__collaborator--avatar-only ${c}`,children:[(0,K.jsx)(_v,{color:s,onClick:()=>{e(i)},name:i.username||``,src:i.avatarUrl,className:c}),l&&(0,K.jsx)(`div`,{className:`UserList__collaborator-status-icon`,children:l})]})}});var vv=P({name:`addToLibrary`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let e of qa)if(i.some(t=>t.type===e))return{captureUpdate:M.EVENTUALLY,appState:{...t,errorMessage:q(`errors.libraryElementTypeError.${e}`)}};return r.library.getLatestLibrary().then(e=>r.library.setLibrary([{id:Yc(),status:`unpublished`,elements:i.map(Xt),created:Date.now()},...e])).then(()=>({captureUpdate:M.EVENTUALLY,appState:{...t,toast:{message:q(`toast.addedToLibrary`)}}})).catch(e=>({captureUpdate:M.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:`labels.addToLibrary`}),yv=(e,t,n,r)=>{let i=Sl(e,t),a=Ya(e);return i.flatMap(e=>{let t=bv(e,a,n);return e.map(n=>{let i=U(n,{x:n.x+t.x,y:n.y+t.y});return Io(n,r.getNonDeletedElementsMap(),{simultaneouslyUpdated:e}),i})})},bv=(e,t,{axis:n,position:r})=>{let i=Ya(e),[a,o]=n===`x`?[`minX`,`maxX`]:[`minY`,`maxY`],s={x:0,y:0};return r===`start`?{...s,[n]:t[a]-i[a]}:r===`end`?{...s,[n]:t[o]-i[o]}:{...s,[n]:(t[a]+t[o])/2-(i[a]+i[o])/2}},xv=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(e=>D(e))},Sv=(e,t,n,r)=>{let i=E(yv(n.scene.getSelectedElements(t),E(e),r,n.scene));return Jl(e.map(e=>i.get(e.id)||e),t,n)};P({name:`alignTop`,label:`labels.alignTop`,icon:Je,trackEvent:{category:`element`},predicate:(e,t,n,r)=>xv(t,r),perform:(e,t,n,r)=>({appState:t,elements:Sv(e,t,r,{position:`start`,axis:`y`}),captureUpdate:M.IMMEDIATELY}),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&e.key===F.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!xv(t,r),type:`button`,icon:Je,onClick:()=>n(null),title:`${q(`labels.alignTop`)} \u2014 ${B(`CtrlOrCmd+Shift+Up`)}`,"aria-label":q(`labels.alignTop`),visible:mo(V(e),t)})}),P({name:`alignBottom`,label:`labels.alignBottom`,icon:de,trackEvent:{category:`element`},predicate:(e,t,n,r)=>xv(t,r),perform:(e,t,n,r)=>({appState:t,elements:Sv(e,t,r,{position:`end`,axis:`y`}),captureUpdate:M.IMMEDIATELY}),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&e.key===F.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!xv(t,r),type:`button`,icon:de,onClick:()=>n(null),title:`${q(`labels.alignBottom`)} \u2014 ${B(`CtrlOrCmd+Shift+Down`)}`,"aria-label":q(`labels.alignBottom`),visible:mo(V(e),t)})}),P({name:`alignLeft`,label:`labels.alignLeft`,icon:oi,trackEvent:{category:`element`},predicate:(e,t,n,r)=>xv(t,r),perform:(e,t,n,r)=>({appState:t,elements:Sv(e,t,r,{position:`start`,axis:`x`}),captureUpdate:M.IMMEDIATELY}),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&e.key===F.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!xv(t,r),type:`button`,icon:oi,onClick:()=>n(null),title:`${q(`labels.alignLeft`)} \u2014 ${B(`CtrlOrCmd+Shift+Left`)}`,"aria-label":q(`labels.alignLeft`),visible:mo(V(e),t)})}),P({name:`alignRight`,label:`labels.alignRight`,icon:Ft,trackEvent:{category:`element`},predicate:(e,t,n,r)=>xv(t,r),perform:(e,t,n,r)=>({appState:t,elements:Sv(e,t,r,{position:`end`,axis:`x`}),captureUpdate:M.IMMEDIATELY}),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&e.key===F.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!xv(t,r),type:`button`,icon:Ft,onClick:()=>n(null),title:`${q(`labels.alignRight`)} \u2014 ${B(`CtrlOrCmd+Shift+Right`)}`,"aria-label":q(`labels.alignRight`),visible:mo(V(e),t)})}),P({name:`alignVerticallyCentered`,label:`labels.centerVertically`,icon:Dc,trackEvent:{category:`element`},predicate:(e,t,n,r)=>xv(t,r),perform:(e,t,n,r)=>({appState:t,elements:Sv(e,t,r,{position:`center`,axis:`y`}),captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!xv(t,r),type:`button`,icon:Dc,onClick:()=>n(null),title:q(`labels.centerVertically`),"aria-label":q(`labels.centerVertically`),visible:mo(V(e),t)})}),P({name:`alignHorizontallyCentered`,label:`labels.centerHorizontally`,icon:oo,trackEvent:{category:`element`},predicate:(e,t,n,r)=>xv(t,r),perform:(e,t,n,r)=>({appState:t,elements:Sv(e,t,r,{position:`center`,axis:`x`}),captureUpdate:M.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!xv(t,r),type:`button`,icon:oo,onClick:()=>n(null),title:q(`labels.centerHorizontally`),"aria-label":q(`labels.centerHorizontally`),visible:mo(V(e),t)})});var Cv=(e,t,n)=>{let[r,i,a,o]=n.axis===`x`?[`minX`,`midX`,`maxX`,`width`]:[`minY`,`midY`,`maxY`,`height`],s=Ya(e),c=Sl(e,t).map(e=>[e,Ya(e)]).sort((e,t)=>e[1][i]-t[1][i]),l=0;for(let e of c)l+=e[1][o];let u=(s[o]-l)/(c.length-1);if(u<0){let e=c.findIndex(e=>e[1][r]===s[r]),t=c.findIndex(e=>e[1][a]===s[a]),o=(c[t][1][i]-c[e][1][i])/(c.length-1),l=c[e][1][i];return c.flatMap(([r,a],s)=>{let c={x:0,y:0};return s!==e&&s!==t&&(l+=o,c[n.axis]=l-a[i]),r.map(e=>H(e,{x:e.x+c.x,y:e.y+c.y}))})}let d=s[r];return c.flatMap(([e,t])=>{let i={x:0,y:0};return i[n.axis]=d-t[r],d+=u,d+=t[o],e.map(e=>H(e,{x:e.x+i.x,y:e.y+i.y}))})},wv=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(e=>D(e))},Tv=(e,t,n,r)=>{let i=E(Cv(n.scene.getSelectedElements(t),n.scene.getNonDeletedElementsMap(),r));return Jl(e.map(e=>i.get(e.id)||e),t,n)};P({name:`distributeHorizontally`,label:`labels.distributeHorizontally`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:Tv(e,t,r,{space:`between`,axis:`x`}),captureUpdate:M.IMMEDIATELY}),keyTest:e=>!e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!wv(t,r),type:`button`,icon:No,onClick:()=>n(null),title:`${q(`labels.distributeHorizontally`)} \u2014 ${B(`Alt+H`)}`,"aria-label":q(`labels.distributeHorizontally`),visible:mo(V(e),t)})}),P({name:`distributeVertically`,label:`labels.distributeVertically`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:Tv(e,t,r,{space:`between`,axis:`y`}),captureUpdate:M.IMMEDIATELY}),keyTest:e=>!e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,K.jsx)(J,{hidden:!wv(t,r),type:`button`,icon:rl,onClick:()=>n(null),title:`${q(`labels.distributeVertically`)} \u2014 ${B(`Alt+V`)}`,"aria-label":q(`labels.distributeVertically`),visible:mo(V(e),t)})});var Ev=P({name:`flipHorizontal`,label:`labels.flipHorizontal`,icon:lo,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Jl(Ov(e,r.scene.getNonDeletedElementsMap(),t,`horizontal`,r),t,r),appState:t,captureUpdate:M.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===k.H}),Dv=P({name:`flipVertical`,label:`labels.flipVertical`,icon:qi,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Jl(Ov(e,r.scene.getNonDeletedElementsMap(),t,`vertical`,r),t,r),appState:t,captureUpdate:M.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===k.V&&!e[F.CTRL_OR_CMD]}),Ov=(e,t,n,r,i)=>{let a=E(kv(R(V(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,n,r,i));return e.map(e=>a.get(e.id)||e)},kv=(e,t,n,r,i)=>{if(e.every(e=>xu(e)&&(e.startBinding||e.endBinding)))return e.map(e=>{let t=e;return H(t,{startArrowhead:t.endArrowhead,endArrowhead:t.startArrowhead})});let{midX:a,midY:o}=Ya(e);Es(e,t,`nw`,i.scene,new Map(Array.from(t.values()).map(e=>[e.id,Xt(e)])),{flipByX:r===`horizontal`,flipByY:r===`vertical`,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Ge(e.filter(Ac),t,i.scene.getNonDeletedElements(),i.scene,We(n),[],n.zoom);let{elbowArrows:s,otherElements:c}=e.reduce((e,t)=>T(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:u}=Ya(e),[d,f]=[a-l,o-u];return c.forEach(e=>U(e,{x:e.x+d,y:e.y+f})),s.forEach(e=>U(e,{x:e.x+d,y:e.y+f})),e},Av=P({name:`copy`,label:`labels.copy`,icon:Tt,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Do(i,r.files,n)}catch(e){return{captureUpdate:M.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:M.EVENTUALLY}},keyTest:void 0}),jv=P({name:`paste`,label:`labels.paste`,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i;try{i=await fe()}catch(e){return e.name===`AbortError`||e.name===`NotAllowedError`?!1:(console.error(`actionPaste ${e.name}: ${e.message}`),Ei?{captureUpdate:M.EVENTUALLY,appState:{...t,errorMessage:q(`hints.firefox_clipboard_write`)}}:{captureUpdate:M.EVENTUALLY,appState:{...t,errorMessage:q(`errors.asyncPasteFailedOnRead`)}})}try{r.pasteFromClipboard(Fi({types:i}))}catch(e){return console.error(e),{captureUpdate:M.EVENTUALLY,appState:{...t,errorMessage:q(`errors.asyncPasteFailedOnParse`)}}}return{captureUpdate:M.EVENTUALLY}},keyTest:void 0}),Mv=P({name:`cut`,label:`labels.cut`,icon:Jc,trackEvent:{category:`element`},perform:(e,t,n,r)=>(Av.perform(e,t,n,r),Hh.perform(e,t,null,r)),keyTest:e=>e[F.CTRL_OR_CMD]&&e.key===F.X}),Nv=P({name:`copyAsSvg`,label:`labels.copyAsSvg`,icon:Lr,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:M.EVENTUALLY};let{exportedElements:i,exportingFrame:a}=K_(e,t,!0);try{return await q_(`clipboard-svg`,i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{toast:{message:q(`toast.copyToClipboardAsSvg`,{exportSelection:r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).length?q(`toast.selection`):q(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?q(`buttons.darkMode`):q(`buttons.lightMode`)})}},captureUpdate:M.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:M.EVENTUALLY}}},predicate:e=>gn&&e.length>0,keywords:[`svg`,`clipboard`,`copy`]}),Pv=P({name:`copyAsPng`,label:`labels.copyAsPng`,icon:Pt,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:M.EVENTUALLY};let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:a,exportingFrame:o}=K_(e,t,!0);try{return await q_(`clipboard`,a,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{appState:{...t,toast:{message:q(`toast.copyToClipboardAsPng`,{exportSelection:i.length?q(`toast.selection`):q(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?q(`buttons.darkMode`):q(`buttons.lightMode`)})}},captureUpdate:M.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:M.EVENTUALLY}}},predicate:e=>Kt&&e.length>0,keyTest:e=>e.code===k.C&&e.altKey&&e.shiftKey,keywords:[`png`,`clipboard`,`copy`]}),Fv=P({name:`copyText`,label:`labels.copyText`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{ti(cs(i))}catch{throw Error(q(`errors.copyToSystemClipboardFailed`))}return{captureUpdate:M.EVENTUALLY}},predicate:(e,t,n,r)=>gn&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(L),keywords:[`text`,`clipboard`,`copy`]}),Iv=P({name:`gridMode`,icon:ge,keywords:[`snap`],label:`labels.toggleGrid`,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:M.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[F.CTRL_OR_CMD]&&e.code===k.QUOTE}),Lv=P({name:`zenMode`,label:`buttons.zenMode`,icon:Su,paletteName:`Toggle zen mode`,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:M.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,n)=>typeof n.zenModeEnabled>`u`,keyTest:e=>!e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.Z}),Rv=P({name:`objectsSnapMode`,label:`buttons.objectsSnapMode`,icon:hr,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:M.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>`u`,keyTest:e=>!e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.S}),zv=P({name:`stats`,label:`stats.fullTitle`,icon:Nn,paletteName:`Toggle stats`,viewMode:!0,trackEvent:{category:`menu`},keywords:[`edit`,`attributes`,`customize`],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:M.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.SLASH}),Bv=P({name:`unbindText`,label:`labels.unbindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(e=>Ja(e)),perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=r.scene.getNonDeletedElementsMap();return i.forEach(e=>{let t=Mn(e,a);if(t){let{width:n,height:r}=ct(t.originalText,ko(t),t.lineHeight),i=Ct(e.id);ss(e.id);let{x:o,y:s}=Mi(e,t,a);U(t,{containerId:null,width:n,height:r,text:t.originalText,x:o,y:s}),U(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id),height:i||e.height})}}),{elements:e,appState:t,captureUpdate:M.IMMEDIATELY}}}),Vv=P({name:`bindText`,label:`labels.bindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);if(i.length===2){let e=L(i[0])||L(i[1]),t;if(Ll(i[0])?t=i[0]:Ll(i[1])&&(t=i[1]),e&&t&&Mn(t,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a,o;L(i[0])&&Ll(i[1])?(a=i[0],o=i[1]):(a=i[1],o=i[0]),U(a,{containerId:o.id,verticalAlign:ll.MIDDLE,textAlign:cc.CENTER,autoResize:!0}),U(o,{boundElements:(o.boundElements||[]).concat({type:`text`,id:a.id})});let s=o.height;return Qo(a,o,r.scene.getNonDeletedElementsMap()),sn(o.id,s),{elements:Hv(e,o,a),appState:{...t,selectedElementIds:{[o.id]:!0}},captureUpdate:M.IMMEDIATELY}}}),Hv=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===n.id);r.splice(i,1);let a=r.findIndex(e=>e.id===t.id);return r.splice(a+1,0,n),bs(r,E([t,n])),r},Uv=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===t.id);r.splice(i,1);let a=r.findIndex(e=>e.id===n.id);return r.splice(a,0,t),bs(r,E([t,n])),r},Wv=P({name:`wrapTextInContainer`,label:`labels.createContainerFromText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=i.every(e=>L(e));return i.length>0&&a},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=e.slice(),o={};for(let e of i)if(L(e)){let n=Ua({type:`rectangle`,backgroundColor:t.currentItemBackgroundColor,boundElements:[...e.boundElements||[],{id:e.id,type:`text`}],angle:e.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness===`round`?{type:st(`rectangle`)?pt.ADAPTIVE_RADIUS:pt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-5,y:e.y-5,width:vr(e.width,`rectangle`),height:vr(e.height,`rectangle`),groupIds:e.groupIds,frameId:e.frameId});if(e.boundElements?.length){let t=e.boundElements.filter(e=>e.type===`arrow`).map(e=>e.id);a.filter(e=>t.includes(e.id)).forEach(t=>{let r=t.startBinding,i=t.endBinding;r?.elementId===e.id&&(r={...r,elementId:n.id}),i?.elementId===e.id&&(i={...i,elementId:n.id}),(r||i)&&U(t,{startBinding:r,endBinding:i},!1)})}U(e,{containerId:n.id,verticalAlign:ll.MIDDLE,boundElements:null,textAlign:cc.CENTER,autoResize:!0},!1),Qo(e,n,r.scene.getNonDeletedElementsMap()),a=Uv([...a,n],n,e),o[n.id]=!0}return{elements:a,appState:{...t,selectedElementIds:o},captureUpdate:M.IMMEDIATELY}}}),Gv=380,Kv=42,qv=5,Jv=85,Yv=500,Xv=!1,Zv=new Map,Qv=({element:e,elementsMap:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:a})=>{let o=xE(),s=_E(),c=vE(),l=e.link||``,[u,d]=(0,G.useState)(l),f=(0,G.useRef)(null),p=o.showHyperlinkPopup===`editor`,m=(0,G.useCallback)(()=>{if(!f.current)return;let t=ms(f.current.value)||null;if(!e.link&&t&&Y(`hyperlink`,`create`),dt(e)){if(o.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!t){U(e,{link:null}),a(e,!1);return}if(!Hs(t,s.validateEmbeddable))t&&i({message:q(`toast.unableToEmbed`),closable:!0}),e.link&&Zv.set(e.id,e.link),U(e,{link:t}),a(e,!1);else{let{width:n,height:r}=e,o=ds(t);o?.error instanceof URIError&&i({message:q(`toast.unrecognizedLinkFormat`),closable:!0});let s=o?o.intrinsicSize.w/o.intrinsicSize.h:1;U(e,{...Zv.get(e.id)===e.link?{}:{width:o?.type===`video`?n>r?n:r*s:n,height:o?.type===`video`&&n>r?n/s:r},link:t}),a(e,!0),Zv.has(e.id)&&Zv.delete(e.id)}}else U(e,{link:t})},[e,i,s.validateEmbeddable,o.activeEmbeddable,n,a]);(0,G.useLayoutEffect)(()=>()=>{m()},[m]),(0,G.useEffect)(()=>{p&&f?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&f.current.select()},[p,c.viewport.isMobile,c.isTouchScreen]),(0,G.useEffect)(()=>{let r=null,i=i=>{p||(r&&clearTimeout(r),ay(e,t,o,O(i.clientX,i.clientY))&&(r=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},Yv)))};return window.addEventListener(`pointermove`,i,!1),()=>{window.removeEventListener(`pointermove`,i,!1),r&&clearTimeout(r)}},[o,e,p,n,t]);let h=(0,G.useCallback)(()=>{Y(`hyperlink`,`delete`),U(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e]),g=()=>{Y(`hyperlink`,`edit`,`popup-ui`),n({showHyperlinkPopup:`editor`})},{x:_,y:v}=$v(e,o,t);return o.contextMenu||o.selectedElementsAreBeingDragged||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled?null:(0,K.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer`,style:{top:`${v}px`,left:`${_}px`,width:Gv,padding:qv},children:[p?(0,K.jsx)(`input`,{className:I(`excalidraw-hyperlinkContainer-input`),placeholder:q(`labels.link.hint`),ref:f,value:u,onChange:e=>d(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[F.CTRL_OR_CMD]&&e.key===F.K&&e.preventDefault(),(e.key===F.ENTER||e.key===F.ESCAPE)&&(m(),n({showHyperlinkPopup:`info`}))}}):e.link?(0,K.jsx)(`a`,{href:ms(e.link||``),className:`excalidraw-hyperlinkContainer-link`,target:Oa(e.link)?`_self`:`_blank`,onClick:t=>{if(e.link&&r){let n=ir(`excalidraw-link`,t.nativeEvent);r({...e,link:ms(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:`noopener noreferrer`,children:e.link}):(0,K.jsx)(`div`,{className:`excalidraw-hyperlinkContainer-link`,children:q(`labels.link.empty`)}),(0,K.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer__buttons`,children:[!p&&(0,K.jsx)(J,{type:`button`,title:q(`buttons.edit`),"aria-label":q(`buttons.edit`),label:q(`buttons.edit`),onClick:g,className:`excalidraw-hyperlinkContainer--edit`,icon:Tc}),(0,K.jsx)(J,{type:`button`,title:q(`labels.linkToElement`),"aria-label":q(`labels.linkToElement`),label:q(`labels.linkToElement`),onClick:()=>{n({openDialog:{name:`elementLinkSelector`,sourceElementId:e.id}})},icon:Ss}),l&&!dt(e)&&(0,K.jsx)(J,{type:`button`,title:q(`buttons.remove`),"aria-label":q(`buttons.remove`),label:q(`buttons.remove`),onClick:h,className:`excalidraw-hyperlinkContainer--remove`,icon:cu})]})]})},$v=(e,t,n)=>{let[r,i]=Er(e,n),{x:a,y:o}=Zr({sceneX:r+e.width/2,sceneY:i},t);return{x:a-t.offsetLeft-Gv/2,y:o-t.offsetTop-Jv}},ey=(e,t)=>{let n=R(e,t);return dt(n[0])?`labels.link.editEmbed`:n[0]?.link?`labels.link.edit`:`labels.link.create`},ty=null,ny=(e,t,n)=>{ty&&clearTimeout(ty),ty=window.setTimeout(()=>ry(e,t,n),300)},ry=(e,t,n)=>{if(!e.link)return;let r=k_();r.classList.add(`excalidraw-tooltip--visible`),r.style.maxWidth=`20rem`,r.textContent=sr(e.link)?q(`labels.link.goToElement`):e.link;let[i,a,o,s]=Er(e,n),[c,l,u,d]=Yt([i,a,o,s],e.angle,t),f=Zr({sceneX:c,sceneY:l},t);A_(r,{left:f.x,top:f.y,width:u,height:d},`top`),Y(`hyperlink`,`tooltip`,`link-icon`),Xv=!0},iy=()=>{ty&&clearTimeout(ty),Xv&&(Xv=!1,k_().classList.remove(`excalidraw-tooltip--visible`))},ay=(e,t,n,[r,i])=>{let{x:a,y:o}=gl({clientX:r,clientY:i},n),s=15/n.zoom.value;if(Ea(a,o,e,t))return!1;let[c,l,u]=Er(e,t);if(a>=c&&a<=u&&o>=l-Jv&&o<=l)return!1;let{x:d,y:f}=$v(e,n,t);return!(r>=d-s&&r<=d+Gv+qv*2+s&&i>=f-s&&i<=f+s+qv*2+Kv)},oy=P({name:`hyperlink`,label:(e,t)=>ey(e,t),icon:ps,perform:(e,t)=>t.showHyperlinkPopup===`editor`?!1:{elements:e,appState:{...t,showHyperlinkPopup:`editor`,openMenu:null},captureUpdate:M.IMMEDIATELY},trackEvent:{category:`hyperlink`,action:`click`},keyTest:e=>e[F.CTRL_OR_CMD]&&e.key===F.K,predicate:(e,t)=>R(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=R(e,t);return(0,K.jsx)(J,{type:`button`,icon:ps,"aria-label":q(ey(e,t)),title:`${dt(e[0])?q(`labels.link.labelEmbed`):q(`labels.link.label`)} - ${B(`CtrlOrCmd+K`)}`,onClick:()=>n(null),selected:r.length===1&&!!r[0].link})}}),sy=e=>e.every(e=>!e.locked),cy=P({name:`toggleElementLock`,label:(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!D(r[0])?r[0].locked?`labels.elementLock.unlock`:`labels.elementLock.lock`:sy(r)?`labels.elementLock.lockAll`:`labels.elementLock.unlockAll`},icon:(e,t)=>sy(R(t,e))?io:Zl,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return i.length>0&&!i.some(e=>e.locked&&e.frameId)},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!i.length)return!1;let a=sy(i),o=E(i);return{elements:e.map(e=>o.has(e.id)?H(e,{locked:a}):e),appState:{...t,selectedLinearElement:a?null:t.selectedLinearElement},captureUpdate:M.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===F.L&&e[F.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),ly=P({name:`unlockAllElements`,paletteName:`Unlock all elements`,trackEvent:{category:`canvas`},viewMode:!1,icon:Zl,predicate:(e,t)=>R(e,t).length===0&&e.some(e=>e.locked),perform:(e,t)=>{let n=e.filter(e=>e.locked);return{elements:e.map(e=>e.locked?H(e,{locked:!1}):e),appState:{...t,selectedElementIds:Object.fromEntries(n.map(e=>[e.id,!0]))},captureUpdate:M.IMMEDIATELY}},label:`labels.elementLock.unlockAll`}),uy=()=>{let[e,t]=(0,G.useState)(null);return[e,(0,G.useCallback)(e=>t(e),[])]},dy=e=>{let{closeOnClickOutside:t=!0}=e,n=Ig({className:`excalidraw-modal-container`}),r=(0,G.useRef)(document.body.classList.contains(`excalidraw-animations-disabled`));return n?(0,_d.createPortal)((0,K.jsxs)(`div`,{className:I(`Modal`,e.className,{"animations-disabled":r.current}),role:`dialog`,"aria-modal":`true`,onKeyDown:t=>{t.key===F.ESCAPE&&(t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[(0,K.jsx)(`div`,{className:`Modal__background`,onClick:t?e.onCloseRequest:void 0}),(0,K.jsx)(`div`,{className:`Modal__content`,style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null},fy=ku(new Map),py=async e=>await tl({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Ma.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),my=(e,t,n)=>{let[r,i]=(0,G.useState)();return(0,G.useEffect)(()=>{if(t)if(e){let r=n.get(e);r?i(r):(async()=>{let r=await py(t);r.querySelector(`.style-fonts`)?.remove(),r&&(n.set(e,r),i(r))})()}else(async()=>{let e=await py(t);i(e)})()},[e,t,n,i]),r},hy=()=>{let[e]=yh(fy);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},gy=class{constructor(){w(this,`jobs`,[]),w(this,`running`,!1)}tick(){if(this.running)return;let e=this.jobs.shift();e?(this.running=!0,e.promise.resolve(Al(e.jobFactory,...e.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(e,...t){let n=vi();return this.jobs.push({jobFactory:e,promise:n,args:t}),this.tick(),n}},_y=new Wr,vy=ku({status:`loaded`,isInitialized:!1,libraryItems:[]}),yy=e=>ke(e),by=(e,t)=>!e.find(e=>e.elements.length===t.elements.length?e.elements.every((e,n)=>e.id===t.elements[n].id&&e.versionNonce===t.elements[n].versionNonce):!1),xy=(e,t)=>{let n=[];for(let r of t)by(e,r)&&n.push(r);return[...n,...e]},Sy=(e,t)=>{let n=E(t),r={deletedItems:new Map,addedItems:new Map};for(let t of e)n.has(t.id)||r.deletedItems.set(t.id,t);let i=E(e);for(let e of t)i.has(e.id)||r.addedItems.set(e.id,e);return r},Cy=class{constructor(e){w(this,`currLibraryItems`,[]),w(this,`prevLibraryItems`,yy(this.currLibraryItems)),w(this,`app`),w(this,`updateQueue`,[]),w(this,`getLastUpdateTask`,()=>this.updateQueue[this.updateQueue.length-1]),w(this,`notifyListeners`,()=>{if(this.updateQueue.length>0)wh.set(vy,e=>({status:`loading`,libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{wh.set(vy,{status:`loaded`,libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=yy(this.currLibraryItems);let t=yy(this.currLibraryItems);this.app.props.onLibraryChange?.(t),_y.trigger(Sy(e,t),t)}catch(e){console.error(e)}}}),w(this,`destroy`,()=>{this.updateQueue=[],this.currLibraryItems=[],wh.set(fy,new Map)}),w(this,`resetLibrary`,()=>this.setLibrary([])),w(this,`getLatestLibrary`,()=>new Promise(async e=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?e(this.getLatestLibrary()):e(yy(t))}catch{return e(this.currLibraryItems)}})),w(this,`updateLibrary`,async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i=`unpublished`})=>(r&&this.app.setState({openSidebar:{name:uo.name,tab:`library`}}),this.setLibrary(()=>new Promise(async(r,a)=>{try{let o=await(typeof e==`function`&&!(e instanceof Blob)?e(this.currLibraryItems):e),s;s=o instanceof Blob?await fo(o,i):li(o,i),!t||window.confirm(q(`alerts.confirmAddLibrary`,{numShapes:s.length}))?(t&&this.app.focusContainer(),r(n?xy(this.currLibraryItems,s):s)):a(new ii)}catch(e){a(e)}})))),w(this,`setLibrary`,e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),typeof e==`function`&&(e=e(this.currLibraryItems)),this.currLibraryItems=yy(await e),t(this.currLibraryItems)}catch(e){n(e)}}).catch(e=>{if(e.name===`AbortError`)return console.warn(`Library update aborted by user`),this.currLibraryItems;throw e}).finally(()=>{this.updateQueue=this.updateQueue.filter(e=>e!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t}),this.app=e}},wy=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=n=>e.slice(n*t,n*t+t).reduce((e,t)=>{let{height:n}=Ya(t.elements);return Math.max(e,n)},0),i=n=>{let r=0,i=0,a=0;for(let o of e){if(r%t===0&&(i=0),i===n){let{width:e}=Ya(o.elements);a=Math.max(a,e)}r++,i++}return a},a=0,o=0,s=0,c=0,l=0,u=0,d=0;for(let f of e){l&&l%t===0&&(o+=s+50,a=0,u=0,d++),u===0&&(s=r(d)),c=i(u);let{minX:e,minY:p,width:m,height:h}=Ya(f.elements),g=(c-m)/2,_=(s-h)/2;n.push(...f.elements.map(t=>({...t,x:t.x+a+g-e,y:t.y+o+_-p}))),a+=c+50,l++,u++}return n},Ty=class e{constructor(e){w(this,`adapter`),this.adapter=e}static async getLibraryItems(t,n,r=!0){let i=()=>new Promise(async(e,r)=>{try{e(li((await t.load({source:n}))?.libraryItems||[],`published`))}catch(e){r(e)}});return r?e.queue.push(i):i()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};w(Ty,`queue`,new gy),w(Ty,`run`,async(e,t)=>{let n=new Ty(e);return Ty.queue.push(()=>t(n))});var Ey={Row:(0,G.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,K.jsx)(`div`,{className:I(`Stack Stack_horizontal`,i),style:{"--gap":t,alignItems:n,justifyContent:r,...a},ref:o,children:e})),Col:(0,G.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,K.jsx)(`div`,{className:I(`Stack Stack_vertical`,i),style:{"--gap":t,justifyItems:n,justifyContent:r,...a},ref:o,children:e}))},Dy=({theme:e,id:t,libraryReturnUrl:n})=>{let r=n||window.location.origin+window.location.pathname;return(0,K.jsx)(`a`,{className:`library-menu-browse-button`,href:`${C.VITE_APP_LIBRARY_URL}?target=${window.name||`_blank`}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${dl.excalidrawLibrary}`,target:`_excalidraw_libraries`,children:q(`labels.libraries`)})},Oy=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:a})=>(0,K.jsxs)(`div`,{className:I(`library-menu-control-buttons`,a),style:r,children:[(0,K.jsx)(Dy,{id:n,libraryReturnUrl:e,theme:t}),i]}),ky=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,Ay=/{{([\w-]+)}}/,jy=/<([\w-]+)>/,My=/<\/([\w-]+)>/,Ny=(e,t)=>{let n=[{name:``,children:[]}];return e.split(ky).filter(Boolean).forEach(r=>{let i=r.match(jy),a=r.match(My),o=r.match(Ay);if(i!==null){let r=i[1];t.hasOwnProperty(r)?n.push({name:r,children:[]}):console.warn(`Trans: missed to pass in prop ${r} for interpolating ${e}`)}else if(a!==null)if(a[1]===n[n.length-1].name){let e=n.pop(),r=G.createElement(G.Fragment,{},...e.children),i=t[e.name];typeof i==`function`&&n[n.length-1].children.push(i(r))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(o!==null){let r=o[1];t.hasOwnProperty(r)?n[n.length-1].children.push(t[r]):console.warn(`Trans: key ${r} not in props for interpolating ${e}`)}else n[n.length-1].children.push(r)}),n.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),n[0].children},Py=({i18nKey:e,children:t,...n})=>{let{t:r}=Ih();return G.createElement(G.Fragment,{},...Ny(r(e),n))},Fy=({label:e,onClick:t,className:n,children:r,actionType:i,type:a=`button`,isLoading:o,...s})=>(0,K.jsxs)(`button`,{className:I(`Dialog__action-button`,i?`Dialog__action-button--${i}`:``,n),type:a,"aria-label":e,onClick:t,...s,children:[r&&(0,K.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:r}),(0,K.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:e}),o&&(0,K.jsx)(`div`,{style:{position:`absolute`,inset:0},children:(0,K.jsx)(Lh,{})})]}),Iy=e=>{let{onConfirm:t,onCancel:n,children:r,confirmText:i=q(`buttons.confirm`),cancelText:a=q(`buttons.cancel`),className:o=``,...s}=e,c=SE(),l=bh(pb),{container:u}=yE();return(0,K.jsxs)(bb,{onCloseRequest:n,size:`small`,...s,className:`confirm-dialog ${o}`,children:[r,(0,K.jsxs)(`div`,{className:`confirm-dialog-buttons`,children:[(0,K.jsx)(Fy,{label:a,onClick:()=>{c({openMenu:null}),l(!1),(0,_d.flushSync)(()=>{n()}),u?.focus()}}),(0,K.jsx)(Fy,{label:i,onClick:()=>{c({openMenu:null}),l(!1),(0,_d.flushSync)(()=>{t()}),u?.focus()},actionType:`danger`})]})]})},Ly=class{static has(e){try{return!!window.localStorage.getItem(e)}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),!1}}static get(e){try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),null}}};w(Ly,`set`,(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),w(Ly,`delete`,e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var Ry=async e=>{let t=tr(e,6),n=document.createElement(`canvas`);n.width=t[0].length*128+(t[0].length+1)*16-16,n.height=t.length*128+(t.length+1)*16-16;let r=n.getContext(`2d`);r.fillStyle=zc.white,r.fillRect(0,0,n.width,n.height);for(let[t,n]of e.entries()){let e=await ze({elements:n.elements,files:null,maxWidthOrHeight:128}),{width:i,height:a}=e,o=Math.floor(t/6)*144,s=t%6*144;r.drawImage(e,s+(128-i)/2+8,o+(128-a)/2+8),r.lineWidth=2,r.strokeStyle=zc.gray[4],r.strokeRect(s+8/2,o+8/2,136,136)}return await ft(new File([await br(n)],`preview`,{type:Pr.png}),{outputType:Pr.jpg,maxWidthOrHeight:5e3})},zy=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{let a=(0,G.useRef)(null),o=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let n=a.current;n&&(async()=>{let r=await tl({elements:e.elements,appState:{...t,viewBackgroundColor:zc.white,exportBackground:!0},files:null,skipInliningFonts:!0});n.innerHTML=r.outerHTML})()},[e.elements,t]),(0,K.jsxs)(`div`,{className:`single-library-item`,children:[e.status===`published`&&(0,K.jsx)(`span`,{className:`single-library-item-status`,children:q(`labels.statusPublished`)}),(0,K.jsx)(`div`,{ref:a,className:`single-library-item__svg`}),(0,K.jsx)(J,{"aria-label":q(`buttons.remove`),type:`button`,icon:Gc,className:`single-library-item--remove`,onClick:i.bind(null,e.id),title:q(`buttons.remove`)}),(0,K.jsxs)(`div`,{style:{display:`flex`,margin:`0.8rem 0`,width:`100%`,fontSize:`14px`,fontWeight:500,flexDirection:`column`},children:[(0,K.jsxs)(`label`,{style:{display:`flex`,justifyContent:`space-between`,flexDirection:`column`},children:[(0,K.jsxs)(`div`,{style:{padding:`0.5em 0`},children:[(0,K.jsx)(`span`,{style:{fontWeight:500,color:zc.gray[6]},children:q(`publishDialog.itemName`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,ref:o,style:{width:`80%`,padding:`0.2rem`},defaultValue:e.name,placeholder:`Item name`,onChange:e=>{r(e.target.value,n)}})]}),(0,K.jsx)(`span`,{className:`error`,children:e.error})]})]})},By=({onClose:e,libraryItems:t,appState:n,onSuccess:r,onError:i,updateItemsInStorage:a,onRemove:o})=>{let[s,c]=(0,G.useState)({authorName:``,githubHandle:``,name:``,description:``,twitterHandle:``,website:``}),[l,u]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=Ly.get(yc.PUBLISH_LIBRARY);e&&c(e)},[]);let[d,f]=(0,G.useState)(t.slice());(0,G.useEffect)(()=>{f(t.slice())},[t]);let p=e=>{c({...s,[e.target.name]:e.target.value})},m=async e=>{e.preventDefault(),u(!0);let t=[],n=!1;if(d.forEach(e=>{let r=``;e.name||(r=q(`publishDialog.errors.required`),n=!0),t.push({...e,error:r})}),n){f(t),u(!1);return}let a=await Ry(d),o={type:tt.excalidrawLibrary,version:dl.excalidrawLibrary,source:jt,libraryItems:d},c=JSON.stringify(o,null,2),l=new Blob([c],{type:`application/json`}),p=new FormData;p.append(`excalidrawLib`,l),p.append(`previewImage`,a),p.append(`previewImageType`,a.type),p.append(`title`,s.name),p.append(`authorName`,s.authorName),p.append(`githubHandle`,s.githubHandle),p.append(`name`,s.name),p.append(`description`,s.description),p.append(`twitterHandle`,s.twitterHandle),p.append(`website`,s.website),fetch(`${C.VITE_APP_LIBRARY_BACKEND}/submit`,{method:`post`,body:p}).then(e=>e.ok?e.json().then(({url:e})=>{Ly.delete(yc.PUBLISH_LIBRARY),r({url:e,authorName:s.authorName,items:d})}):e.json().catch(()=>{throw Error(e.statusText||`something went wrong`)}).then(t=>{throw Error(t.message||e.statusText||`something went wrong`)}),e=>{console.error(e),i(e),u(!1)}).catch(e=>{console.error(e),i(e),u(!1)})},h=()=>{let e=[];return d.forEach((t,r)=>{e.push((0,K.jsx)(`div`,{className:`single-library-item-wrapper`,children:(0,K.jsx)(zy,{libItem:t,appState:n,index:r,onChange:(e,t)=>{let n=d.slice();n[t].name=e,f(n)},onRemove:o})},r))}),(0,K.jsx)(`div`,{className:`selected-library-items`,children:e})},g=(0,G.useCallback)(()=>{a(d),Ly.set(yc.PUBLISH_LIBRARY,s),e()},[d,e,a,s]),_=!!t.length,v=t.some(e=>e.status===`published`);return(0,K.jsx)(bb,{onCloseRequest:g,title:q(`publishDialog.title`),className:`publish-library`,children:_?(0,K.jsxs)(`form`,{onSubmit:m,children:[(0,K.jsx)(`div`,{className:`publish-library-note`,children:(0,K.jsx)(Py,{i18nKey:`publishDialog.noteDescription`,link:e=>(0,K.jsx)(`a`,{href:`https://libraries.excalidraw.com`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,K.jsx)(`span`,{className:`publish-library-note`,children:(0,K.jsx)(Py,{i18nKey:`publishDialog.noteGuidelines`,link:e=>(0,K.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries#guidelines`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,K.jsx)(`div`,{className:`publish-library-note`,children:q(`publishDialog.noteItems`)}),v&&(0,K.jsx)(`span`,{className:`publish-library-note publish-library-warning`,children:q(`publishDialog.republishWarning`)}),h(),(0,K.jsxs)(`div`,{className:`publish-library__fields`,children:[(0,K.jsxs)(`label`,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:q(`publishDialog.libraryName`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,name:`name`,required:!0,value:s.name,onChange:p,placeholder:q(`publishDialog.placeholder.libraryName`)})]}),(0,K.jsxs)(`label`,{style:{alignItems:`flex-start`},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:q(`publishDialog.libraryDesc`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,K.jsx)(`textarea`,{name:`description`,rows:4,required:!0,value:s.description,onChange:p,placeholder:q(`publishDialog.placeholder.libraryDesc`)})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{children:q(`publishDialog.authorName`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,name:`authorName`,required:!0,value:s.authorName,onChange:p,placeholder:q(`publishDialog.placeholder.authorName`)})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:q(`publishDialog.githubUsername`)}),(0,K.jsx)(`input`,{type:`text`,name:`githubHandle`,value:s.githubHandle,onChange:p,placeholder:q(`publishDialog.placeholder.githubHandle`)})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:q(`publishDialog.twitterUsername`)}),(0,K.jsx)(`input`,{type:`text`,name:`twitterHandle`,value:s.twitterHandle,onChange:p,placeholder:q(`publishDialog.placeholder.twitterHandle`)})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:q(`publishDialog.website`)}),(0,K.jsx)(`input`,{type:`text`,name:`website`,pattern:`https?://.+`,title:q(`publishDialog.errors.website`),value:s.website,onChange:p,placeholder:q(`publishDialog.placeholder.website`)})]}),(0,K.jsx)(`span`,{className:`publish-library-note`,children:(0,K.jsx)(Py,{i18nKey:`publishDialog.noteLicense`,link:e=>(0,K.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE`,target:`_blank`,rel:`noopener noreferrer`,children:e})})})]}),(0,K.jsxs)(`div`,{className:`publish-library__buttons`,children:[(0,K.jsx)(Fy,{label:q(`buttons.cancel`),onClick:g,"data-testid":`cancel-clear-canvas-button`}),(0,K.jsx)(Fy,{type:`submit`,label:q(`buttons.submit`),actionType:`primary`,isLoading:l})]})]}):(0,K.jsx)(`p`,{style:{padding:`1em`,textAlign:`center`,fontWeight:500},children:q(`publishDialog.atleastOneLibItem`)})})},Vy=({className:e=``,children:t,onToggle:n,title:r,...i})=>{let a=vE();return(0,K.jsx)(`button`,{"data-prevent-outside-click":!0,className:I(`dropdown-menu-button ${e}`,`zen-mode-transition`,{"dropdown-menu-button--mobile":a.editor.isMobile}).trim(),onClick:n,type:`button`,"data-testid":`dropdown-menu-button`,title:r,...i,children:t})},Hy=Vy;Vy.displayName=`DropdownMenuTrigger`;var Uy=()=>(0,K.jsx)(`div`,{style:{height:`1px`,backgroundColor:`var(--default-border-color)`,margin:`.5rem 0`}}),Wy=Uy;Uy.displayName=`DropdownMenuSeparator`;var Gy=({children:e,onClickOutside:t,className:n=``,onSelect:r,style:i})=>{let a=vE(),o=(0,G.useRef)(null),s=Rg({onClickOutside:t});Lg(o,()=>{s.onClickOutside?.()}),(0,G.useEffect)(()=>{let e=e=>{e.key===F.ESCAPE&&(e.stopImmediatePropagation(),s.onClickOutside?.())},t={capture:!0};return document.addEventListener(`keydown`,e,t),()=>{document.removeEventListener(`keydown`,e,t)}},[s]);let c=I(`dropdown-menu ${n}`,{"dropdown-menu--mobile":a.editor.isMobile}).trim();return(0,K.jsx)(i_.Provider,{value:{onSelect:r},children:(0,K.jsx)(`div`,{ref:o,className:c,style:i,"data-testid":`dropdown-menu`,children:a.editor.isMobile?(0,K.jsx)(Ey.Col,{className:`dropdown-menu-container`,children:e}):(0,K.jsx)(Hg,{className:`dropdown-menu-container`,padding:2,style:{zIndex:2},children:e})})})};Gy.displayName=`DropdownMenuContent`;var Ky=Gy,qy=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:a=``,selected:o,rel:s=`noreferrer`,...c})=>{let l=o_(c.onClick,i);return(0,K.jsx)(`a`,{...c,href:n,target:`_blank`,rel:`noreferrer`,className:a_(a,o),title:c.title??c[`aria-label`],onClick:l,children:(0,K.jsx)(s_,{icon:e,shortcut:t,children:r})})},Jy=qy;qy.displayName=`DropdownMenuItemLink`;var Yy=({children:e,className:t=``,selected:n,...r})=>(0,K.jsx)(`div`,{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?`dropdown-menu-item--selected`:``}`.trim(),children:e}),Xy=e=>G.Children.toArray(e).find(e=>G.isValidElement(e)&&typeof e.type!=`string`&&e?.type.displayName&&e.type.displayName===`DropdownMenuTrigger`)||null,Zy=e=>G.Children.toArray(e).find(e=>G.isValidElement(e)&&typeof e.type!=`string`&&e?.type.displayName&&e.type.displayName===`DropdownMenuContent`)||null,Qy=({children:e,open:t})=>{let n=Xy(e),r=Zy(e);return(0,K.jsxs)(K.Fragment,{children:[n,t&&r]})};Qy.Trigger=Hy,Qy.Content=Ky,Qy.Item=d_,Qy.ItemLink=Jy,Qy.ItemCustom=Yy,Qy.Group=r_,Qy.Separator=Wy;var X=Qy;Qy.displayName=`DropdownMenu`;var $y=(e,t)=>e.filter(e=>t.includes(e.id)),eb=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:a,appState:o,className:s})=>{let[c]=yh(vy),[l,u]=yh(pb),d=()=>{let e=t.length?q(`alerts.removeItemsFromsLibrary`,{count:t.length}):q(`alerts.resetLibrary`);return(0,K.jsx)(Iy,{onConfirm:()=>{t.length?r():i(),p(!1)},onCancel:()=>{p(!1)},title:t.length?q(`confirmDialog.removeItemsFromLib`):q(`confirmDialog.resetLibrary`),children:(0,K.jsx)(`p`,{children:e})})},[f,p]=(0,G.useState)(!1),m=!!t.length,h=m?c.libraryItems.filter(e=>t.includes(e.id)):c.libraryItems,g=q(m?`buttons.remove`:`buttons.resetLibrary`),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null),x=(0,G.useCallback)(()=>(0,K.jsxs)(bb,{onCloseRequest:()=>b(null),title:q(`publishSuccessDialog.title`),className:`publish-library-success`,size:`small`,children:[(0,K.jsx)(`p`,{children:(0,K.jsx)(Py,{i18nKey:`publishSuccessDialog.content`,authorName:y.authorName,link:e=>(0,K.jsx)(`a`,{href:y?.url,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,K.jsx)(J,{type:`button`,title:q(`buttons.close`),"aria-label":q(`buttons.close`),label:q(`buttons.close`),onClick:()=>b(null),"data-testid":`publish-library-success-close`,className:`publish-library-success-close`})]}),[b,y]),S=(e,r)=>{v(!1),b({url:e.url,authorName:e.authorName});let i=r.slice();i.forEach(e=>{t.includes(e.id)&&(e.status=`published`)}),n.setLibrary(i)};return(0,K.jsxs)(`div`,{className:I(`library-menu-dropdown-container`,s),children:[(0,K.jsxs)(X,{open:l,children:[(0,K.jsx)(X.Trigger,{onToggle:()=>u(!l),children:un}),(0,K.jsxs)(X.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:`library-menu`,children:[!m&&(0,K.jsx)(X.Item,{onSelect:async()=>{try{await n.updateLibrary({libraryItems:Xl({description:`Excalidraw library files`}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name===`AbortError`){console.warn(t);return}e({errorMessage:q(`errors.importLibraryError`)})}},icon:su,"data-testid":`lib-dropdown--load`,children:q(`buttons.load`)}),!!h.length&&(0,K.jsx)(X.Item,{onSelect:async()=>{me(m?h:await n.getLatestLibrary()).catch(rt).catch(t=>{e({errorMessage:t.message})})},icon:As,"data-testid":`lib-dropdown--export`,children:q(`buttons.export`)}),!!h.length&&(0,K.jsx)(X.Item,{onSelect:()=>p(!0),icon:cu,children:g}),m&&(0,K.jsx)(X.Item,{icon:Or,onSelect:()=>v(!0),"data-testid":`lib-dropdown--remove`,children:q(`buttons.publishLibrary`)})]})]}),t.length>0&&(0,K.jsx)(`div`,{className:`library-actions-counter`,children:t.length}),f&&d(),_&&(0,K.jsx)(By,{onClose:()=>v(!1),libraryItems:$y(c.libraryItems,t),appState:o,onSuccess:e=>S(e,c.libraryItems),onError:e=>window.alert(e),updateItemsInStorage:()=>n.setLibrary(c.libraryItems),onRemove:e=>a(t.filter(t=>t!==e))}),y&&x()]})},tb=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:r}=gE(),{clearLibraryCache:i,deleteItemsFromLibraryCache:a}=hy(),o=Fg(),s=SE(),[c]=yh(vy),l=async n=>{let i=n.filter(t=>!e.includes(t.id));r.setLibrary(i).catch(()=>{s({errorMessage:q(`alerts.errorRemovingFromLibrary`)})}),a(e),t([])};return(0,K.jsx)(eb,{appState:o,setAppState:s,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>l(c.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})},nb=(0,G.memo)(({id:e,elements:t,isPending:n,onClick:r,selected:i,onToggle:a,onDrag:o,svgCache:s})=>{let c=(0,G.useRef)(null),l=my(e,t,s);(0,G.useEffect)(()=>{let e=c.current;if(e)return l&&(e.innerHTML=l.outerHTML),()=>{e.innerHTML=``}},[l]);let[u,d]=(0,G.useState)(!1),f=vE().editor.isMobile,p=n&&(0,K.jsx)(`div`,{className:`library-unit__adder`,children:ac});return(0,K.jsxs)(`div`,{className:I(`library-unit`,{"library-unit__active":t,"library-unit--hover":t&&u,"library-unit--selected":i,"library-unit--skeleton":!l}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,K.jsx)(`div`,{className:I(`library-unit__dragger`,{"library-unit__pulse":!!n}),ref:c,draggable:!!t,onClick:t||n?t=>{e&&t.shiftKey?a(e,t):r(e)}:void 0,onDragStart:t=>{if(!e){t.preventDefault();return}d(!1),o(e,t)}}),p,e&&t&&(u||f||i)&&(0,K.jsx)(Y_,{checked:i,onChange:(t,n)=>a(e,n),className:`library-unit__checkbox`})]})}),rb=()=>(0,K.jsx)(`div`,{className:`library-unit library-unit--skeleton`});function ib(){return[!1,(0,G.useCallback)(e=>e(),[])]}var ab=G.useTransition||ib,ob=({children:e})=>(0,K.jsx)(`div`,{className:`library-menu-items-container__grid`,children:e}),sb=(0,G.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:a,itemsRenderedPerBatch:o})=>{let[,s]=ab(),[c,l]=(0,G.useState)(0);return(0,G.useEffect)(()=>{c<e.length&&s(()=>{l(c+o)})},[c,e.length,s,o]),(0,K.jsx)(K.Fragment,{children:e.map((e,o)=>o<c?(0,K.jsx)(nb,{elements:e?.elements,isPending:!e?.id&&!!e?.elements,onClick:i,svgCache:a,id:e?.id,selected:r(e.id),onToggle:t,onDrag:n},e?.id??o):(0,K.jsx)(rb,{},o))})}),cb=ku(0),lb=e=>{let[t,n]=yh(cb);return(0,G.useEffect)(()=>{let{current:t}=e;if(!t)return;let r=(0,kp.default)(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener(`scroll`,r),()=>{r.cancel(),t.removeEventListener(`scroll`,r)}},[e,n]),t},ub=17,db=64;function fb({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:a,id:o,libraryReturnUrl:s,onSelectItems:c,selectedItems:l}){let u=(0,G.useRef)(null),d=lb(u);(0,G.useEffect)(()=>{d>0&&u.current?.scrollTo(0,d)},[]);let{svgCache:f}=hy(),p=(0,G.useMemo)(()=>t.filter(e=>e.status!==`published`),[t]),m=(0,G.useMemo)(()=>t.filter(e=>e.status===`published`),[t]),h=!t.length&&!i.length,g=!i.length&&!p.length&&!m.length,[_,v]=(0,G.useState)(null),y=(0,G.useCallback)((e,t)=>{let n=!l.includes(e),r=[...p,...m];if(n){if(t.shiftKey&&_){let t=r.findIndex(e=>e.id===_),n=r.findIndex(t=>t.id===e);if(t===-1||n===-1){c([...l,e]);return}let i=E(l);c(r.reduce((e,r,a)=>((a>=t&&a<=n||i.has(r.id))&&e.push(r.id),e),[]))}else c([...l,e]);v(e)}else v(null),c(l.filter(t=>t!==e))},[_,c,m,l,p]),b=(0,G.useCallback)(e=>{let n;return n=l.includes(e)?t.filter(e=>l.includes(e.id)):t.filter(t=>t.id===e),n.map(e=>({...e,elements:Ie(e.elements,{randomizeSeed:!0})}))},[t,l]),x=(0,G.useCallback)((e,t)=>{t.dataTransfer.setData(Pr.excalidrawlib,_u(b(e)))},[b]),S=(0,G.useCallback)(e=>e?l.includes(e):!1,[l]),ee=(0,G.useCallback)(()=>{n(i)},[i,n]),te=(0,G.useCallback)(e=>{e&&r(b(e))},[b,r]),ne=f.size>=t.length?db:ub;return(0,K.jsxs)(`div`,{className:`library-menu-items-container`,style:i.length||p.length||m.length?{justifyContent:`flex-start`}:{borderBottom:0},children:[!g&&(0,K.jsx)(tb,{selectedItems:l,onSelectItems:c,className:`library-menu-dropdown-container--in-heading`}),(0,K.jsxs)(Ey.Col,{className:`library-menu-items-container__items`,align:`start`,gap:1,style:{flex:m.length>0?1:`0 1 auto`,marginBottom:0},ref:u,children:[(0,K.jsxs)(K.Fragment,{children:[!g&&(0,K.jsx)(`div`,{className:`library-menu-items-container__header`,children:q(`labels.personalLib`)}),e&&(0,K.jsx)(`div`,{style:{position:`absolute`,top:`var(--container-padding-y)`,right:`var(--container-padding-x)`,transform:`translateY(50%)`},children:(0,K.jsx)(Lh,{})}),!i.length&&!p.length?(0,K.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[(0,K.jsx)(`div`,{className:`library-menu-items__no-items__label`,children:q(`library.noItems`)}),(0,K.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:m.length>0?q(`library.hint_emptyPrivateLibrary`):q(`library.hint_emptyLibrary`)})]}):(0,K.jsxs)(ob,{children:[i.length>0&&(0,K.jsx)(sb,{itemsRenderedPerBatch:ne,items:[{id:null,elements:i}],onItemSelectToggle:y,onItemDrag:x,onClick:ee,isItemSelected:S,svgCache:f}),(0,K.jsx)(sb,{itemsRenderedPerBatch:ne,items:p,onItemSelectToggle:y,onItemDrag:x,onClick:te,isItemSelected:S,svgCache:f})]})]}),(0,K.jsxs)(K.Fragment,{children:[(m.length>0||i.length>0||p.length>0)&&(0,K.jsx)(`div`,{className:`library-menu-items-container__header library-menu-items-container__header--excal`,children:q(`labels.excalidrawLib`)}),m.length>0?(0,K.jsx)(ob,{children:(0,K.jsx)(sb,{itemsRenderedPerBatch:ne,items:m,onItemSelectToggle:y,onItemDrag:x,onClick:te,isItemSelected:S,svgCache:f})}):p.length>0?(0,K.jsx)(`div`,{style:{margin:`1rem 0`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,width:`100%`,fontSize:`.9rem`},children:q(`library.noItems`)}):null]}),h&&(0,K.jsx)(Oy,{style:{padding:`16px 0`,width:`100%`},id:o,libraryReturnUrl:s,theme:a,children:(0,K.jsx)(tb,{selectedItems:l,onSelectItems:c})})]})]})}var pb=ku(!1),mb=({children:e})=>(0,K.jsx)(`div`,{className:`layer-ui__library`,children:e}),hb=(0,G.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:a,id:o,theme:s,selectedItems:c,onSelectItems:l})=>{let[u]=yh(vy),d=(0,G.useCallback)(e=>{(async(e,t)=>{Y(`element`,`addToLibrary`,`ui`);for(let t of qa)if(e.some(e=>e.type===t))return r({errorMessage:q(`errors.libraryElementTypeError.${t}`)});let i=[{status:`unpublished`,elements:e,id:Yc(),created:Date.now()},...t];n(),a.setLibrary(i).catch(()=>{r({errorMessage:q(`alerts.errorAddingToLibrary`)})})})(e,u.libraryItems)},[n,a,r,u.libraryItems]),f=(0,G.useMemo)(()=>u.libraryItems,[u]);if(u.status===`loading`&&!u.isInitialized)return(0,K.jsx)(mb,{children:(0,K.jsx)(`div`,{className:`layer-ui__library-message`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Lh,{size:`2em`}),(0,K.jsx)(`span`,{children:q(`labels.libraryLoadingMessage`)})]})})});let p=u.libraryItems.length>0||t.length>0;return(0,K.jsxs)(mb,{children:[(0,K.jsx)(fb,{isLoading:u.status===`loading`,libraryItems:f,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:o,libraryReturnUrl:i,theme:s,onSelectItems:l,selectedItems:c}),p&&(0,K.jsx)(Oy,{className:`library-menu-control-buttons--at-bottom`,style:{padding:`16px 12px 0 12px`},id:o,libraryReturnUrl:i,theme:s})]})}),gb=(e,t)=>({elements:e,pending:R(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),_b=(e,t)=>{let n=bE(),[r,i]=(0,G.useState)(()=>gb(n,e.selectedElementIds)),a=(0,G.useRef)(new Map);return(0,G.useEffect)(()=>{for(let e of r.pending)a.current.set(e.id,e.version)},[r.pending]),(0,G.useEffect)(()=>{t.state.cursorButton===`up`&&t.state.activeTool.type===`selection`&&i(r=>{if(!Rt(r.selectedElementIds,e.selectedElementIds))return a.current.clear(),gb(n,e.selectedElementIds);let i=t.scene.getNonDeletedElementsMap();for(let t of Object.keys(e.selectedElementIds)){let r=i.get(t)?.version;if(r&&r!==a.current.get(t))return gb(n,e.selectedElementIds)}return r})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),r.pending},vb=(0,G.memo)(()=>{let e=gE(),{onInsertElements:t}=e,n=_E(),r=Fg(),i=SE(),[a,o]=(0,G.useState)([]),s=(0,G.useMemo)(()=>e.library,[e.library]);return(0,K.jsx)(hb,{pendingElements:_b(r,e),onInsertLibraryItems:(0,G.useCallback)(e=>{t(wy(e))},[t]),onAddToLibrary:(0,G.useCallback)(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]),setAppState:i,libraryReturnUrl:n.libraryReturnUrl,library:s,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:o})});function yb(e){if(e&&typeof e==`number`)return e;switch(e){case`small`:return 550;case`wide`:return 1024;default:return 800}}var bb=e=>{let[t,n]=uy(),[r]=(0,G.useState)(document.activeElement),{id:i}=yE(),a=vE().viewport.isMobile;(0,G.useEffect)(()=>{if(!t)return;let n=Zi(t);setTimeout(()=>{n.length>0&&e.autofocus!==!1&&(n[1]||n[0]).focus()});let r=e=>{if(e.key===F.TAB){let n=Zi(t),{activeElement:r}=document,i=n.findIndex(e=>e===r);i===0&&e.shiftKey?(n[n.length-1].focus(),e.preventDefault()):i===n.length-1&&!e.shiftKey&&(n[0].focus(),e.preventDefault())}};return t.addEventListener(`keydown`,r),()=>t.removeEventListener(`keydown`,r)},[t,e.autofocus]);let o=SE(),s=bh(pb),c=()=>{o({openMenu:null}),s(!1),r.focus(),e.onCloseRequest()};return(0,K.jsx)(dy,{className:I(`Dialog`,e.className,{"Dialog--fullscreen":a}),labelledBy:`dialog-title`,maxWidth:yb(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,K.jsxs)(Hg,{ref:n,children:[e.title&&(0,K.jsx)(`h2`,{id:`${i}-dialog-title`,className:`Dialog__title`,children:(0,K.jsx)(`span`,{className:`Dialog__titleContent`,children:e.title})}),a&&(0,K.jsx)(`button`,{className:`Dialog__close`,onClick:c,title:q(`buttons.close`),"aria-label":q(`buttons.close`),type:`button`,children:Gc}),(0,K.jsx)(`div`,{className:`Dialog__content`,children:e.children})]})})},xb=({type:e=`button`,onSelect:t,selected:n,children:r,className:i=``,...a})=>(0,K.jsx)(`button`,{onClick:Wo(a.onClick,e=>{t()}),type:e,className:I(`excalidraw-button`,i,{selected:n}),...a,children:r}),Sb=(0,G.forwardRef)(({onChange:e,label:t,fullWidth:n,placeholder:r,readonly:i,selectOnRender:a,onKeyDown:o,isRedacted:s=!1,icon:c,className:l,...u},d)=>{let f=(0,G.useRef)(null);(0,G.useImperativeHandle)(d,()=>f.current),(0,G.useLayoutEffect)(()=>{a&&(f.current?.focus(),f.current?.select())},[a]);let[p,m]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:I(`ExcTextField`,l,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{f.current?.focus()},children:[c,t&&(0,K.jsx)(`div`,{className:`ExcTextField__label`,children:t}),(0,K.jsxs)(`div`,{className:I(`ExcTextField__input`,{"ExcTextField__input--readonly":i}),children:[(0,K.jsx)(`input`,{className:I({"is-redacted":`value`in u&&u.value&&s&&!p}),readOnly:i,value:`value`in u?u.value:void 0,defaultValue:`defaultValue`in u?u.defaultValue:void 0,placeholder:r,ref:f,onChange:t=>e?.(t.target.value),onKeyDown:o}),s&&(0,K.jsx)(xb,{onSelect:()=>m(!p),style:{border:0,userSelect:`none`},children:p?qr:va})]})]})}),Cb={toggleTheme:[B(`Shift+Alt+D`)],saveScene:[B(`CtrlOrCmd+S`)],loadScene:[B(`CtrlOrCmd+O`)],clearCanvas:[B(`CtrlOrCmd+Delete`)],imageExport:[B(`CtrlOrCmd+Shift+E`)],commandPalette:[B(`CtrlOrCmd+/`),B(`CtrlOrCmd+Shift+P`)],cut:[B(`CtrlOrCmd+X`)],copy:[B(`CtrlOrCmd+C`)],paste:[B(`CtrlOrCmd+V`)],copyStyles:[B(`CtrlOrCmd+Alt+C`)],pasteStyles:[B(`CtrlOrCmd+Alt+V`)],selectAll:[B(`CtrlOrCmd+A`)],deleteSelectedElements:[B(`Delete`)],duplicateSelection:[B(`CtrlOrCmd+D`),B(`Alt+${q(`helpDialog.drag`)}`)],sendBackward:[B(`CtrlOrCmd+[`)],bringForward:[B(`CtrlOrCmd+]`)],sendToBack:[B(wt?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)],bringToFront:[B(wt?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)],copyAsPng:[B(`Shift+Alt+C`)],group:[B(`CtrlOrCmd+G`)],ungroup:[B(`CtrlOrCmd+Shift+G`)],gridMode:[B(`CtrlOrCmd+'`)],zenMode:[B(`Alt+Z`)],objectsSnapMode:[B(`Alt+S`)],stats:[B(`Alt+/`)],addToLibrary:[],flipHorizontal:[B(`Shift+H`)],flipVertical:[B(`Shift+V`)],viewMode:[B(`Alt+R`)],hyperlink:[B(`CtrlOrCmd+K`)],toggleElementLock:[B(`CtrlOrCmd+Shift+L`)],resetZoom:[B(`CtrlOrCmd+0`)],zoomOut:[B(`CtrlOrCmd+-`)],zoomIn:[B(`CtrlOrCmd++`)],zoomToFitSelection:[B(`Shift+3`)],zoomToFit:[B(`Shift+1`)],zoomToFitSelectionInViewport:[B(`Shift+2`)],toggleEraserTool:[B(`E`)],toggleHandTool:[B(`H`)],setFrameAsActiveTool:[B(`F`)],saveFileToDisk:[B(`CtrlOrCmd+S`)],saveToActiveFile:[B(`CtrlOrCmd+S`)],toggleShortcuts:[B(`?`)],searchMenu:[B(`CtrlOrCmd+F`)],wrapSelectionInFrame:[]},wb=(e,t=0)=>{let n=Cb[e];return n&&n.length>0?n[t]||n[0]:``},Tb=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`),Eb=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Db={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`E`,æ:`e`,Þ:`T`,þ:`t`,ß:`s`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`I`,ij:`i`,Œ:`E`,œ:`e`,ʼn:`n`,ſ:`s`},Ob=e=>e.replace(Eb,e=>Db[e]||e).replace(Tb,``),kb=G.createContext(null),Ab=()=>G.useContext(kb),jb=md(),Mb=()=>G.useMemo(()=>({MainMenuTunnel:Hp(),WelcomeScreenMenuHintTunnel:Hp(),WelcomeScreenToolbarHintTunnel:Hp(),WelcomeScreenHelpHintTunnel:Hp(),WelcomeScreenCenterTunnel:Hp(),FooterCenterTunnel:Hp(),DefaultSidebarTriggerTunnel:Hp(),DefaultSidebarTabTriggersTunnel:Hp(),OverwriteConfirmDialogTunnel:Hp(),TTDDialogTriggerTunnel:Hp(),tunnelsJotai:jb}),[]),Nb=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return mc(e.activeTool.type)&&e.activeTool.type!==`image`&&n!==`image`&&n!==`frame`&&n!==`magicframe`||t.some(e=>mc(e.type))},Pb=(e,t)=>ou(e.activeTool.type)||t.some(e=>ou(e.type)),Fb=({appState:e,elementsMap:t,renderAction:n,app:r})=>{let i=Ic(t,e),a=!1;i.length===2&&(Ja(i[0])||Ja(i[1]))&&(a=!0);let o=!!(e.editingTextElement||e.newElement),s=vE(),c=document.documentElement.getAttribute(`dir`)===`rtl`,l=ou(e.activeTool.type)&&!na(e.currentItemBackgroundColor)||i.some(e=>ou(e.type)&&!na(e.backgroundColor)),u=i.length===1||a,d=!e.editingLinearElement&&i.length===1&&Ac(i[0])&&!T(i[0]),f=!e.croppingElementId&&i.length===1&&Mo(i[0]),p=!a&&xv(e,r);return(0,K.jsxs)(`div`,{className:`panelColumn`,children:[(0,K.jsx)(`div`,{children:Nb(e,i)&&n(`changeStrokeColor`)}),Pb(e,i)&&(0,K.jsx)(`div`,{children:n(`changeBackgroundColor`)}),l&&n(`changeFillStyle`),(er(e.activeTool.type)||i.some(e=>er(e.type)))&&n(`changeStrokeWidth`),(e.activeTool.type===`freedraw`||i.some(e=>e.type===`freedraw`))&&n(`changeStrokeShape`),(_n(e.activeTool.type)||i.some(e=>_n(e.type)))&&(0,K.jsxs)(K.Fragment,{children:[n(`changeStrokeStyle`),n(`changeSloppiness`)]}),(Co(e.activeTool.type)||i.some(e=>Co(e.type)))&&(0,K.jsx)(K.Fragment,{children:n(`changeRoundness`)}),(iu(e.activeTool.type)||i.some(e=>iu(e.type)))&&(0,K.jsx)(K.Fragment,{children:n(`changeArrowType`)}),(e.activeTool.type===`text`||i.some(L))&&(0,K.jsxs)(K.Fragment,{children:[n(`changeFontFamily`),n(`changeFontSize`),(e.activeTool.type===`text`||an(i,t))&&n(`changeTextAlign`)]}),zr(i,t)&&n(`changeVerticalAlign`),(Ks(e.activeTool.type)||i.some(e=>Ks(e.type)))&&(0,K.jsx)(K.Fragment,{children:n(`changeArrowhead`)}),n(`changeOpacity`),(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.layers`)}),(0,K.jsxs)(`div`,{className:`buttonList`,children:[n(`sendToBack`),n(`sendBackward`),n(`bringForward`),n(`bringToFront`)]})]}),p&&!a&&(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.align`)}),(0,K.jsxs)(`div`,{className:`buttonList`,children:[c?(0,K.jsxs)(K.Fragment,{children:[n(`alignRight`),n(`alignHorizontallyCentered`),n(`alignLeft`)]}):(0,K.jsxs)(K.Fragment,{children:[n(`alignLeft`),n(`alignHorizontallyCentered`),n(`alignRight`)]}),i.length>2&&n(`distributeHorizontally`),(0,K.jsx)(`div`,{style:{flexBasis:`100%`,height:0}}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`.5rem`,marginTop:`-0.5rem`},children:[n(`alignTop`),n(`alignVerticallyCentered`),n(`alignBottom`),i.length>2&&n(`distributeVertically`)]})]})]}),!o&&i.length>0&&(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{children:q(`labels.actions`)}),(0,K.jsxs)(`div`,{className:`buttonList`,children:[!s.editor.isMobile&&n(`duplicateSelection`),!s.editor.isMobile&&n(`deleteSelectedElements`),n(`group`),n(`ungroup`),u&&n(`hyperlink`),f&&n(`cropEditor`),d&&n(`toggleLinearEditor`)]})]})]})},Ib=({activeTool:e,appState:t,app:n,UIOptions:r})=>{let[i,a]=(0,G.useState)(!1),o=e.type===`frame`,s=e.type===`laser`,c=e.type===`embeddable`,{TTDDialogTriggerTunnel:l}=Ab();return(0,K.jsxs)(K.Fragment,{children:[ue.map(({value:i,icon:a,key:o,numericKey:s,fillable:c},l)=>{if(r.tools?.[i]===!1)return null;let u=q(`toolBar.${i}`),d=o&&ro(typeof o==`string`?o:o[0]),f=d?`${d} ${q(`helpDialog.or`)} ${s}`:`${s}`;return(0,K.jsx)(J,{className:I(`Shape`,{fillable:c}),type:`radio`,icon:a,checked:e.type===i,name:`editor-current-shape`,title:`${ro(u)} \u2014 ${f}`,keyBindingLabel:s||d,"aria-label":ro(u),"aria-keyshortcuts":f,"data-testid":`toolbar-${i}`,onPointerDown:({pointerType:e})=>{!t.penDetected&&e===`pen`&&n.togglePenMode(!0)},onChange:({pointerType:e})=>{t.activeTool.type!==i&&Y(`toolbar`,i,`ui`),i===`image`?n.setActiveTool({type:i,insertOnCanvasDirectly:e!==`mouse`}):n.setActiveTool({type:i})}},i)}),(0,K.jsx)(`div`,{className:`App-toolbar__divider`}),(0,K.jsxs)(X,{open:i,children:[(0,K.jsx)(X.Trigger,{className:I(`App-toolbar__extra-tools-trigger`,{"App-toolbar__extra-tools-trigger--selected":o||c||s&&!n.props.isCollaborating}),onToggle:()=>a(!i),title:q(`toolBar.extraTools`),children:Ga}),(0,K.jsxs)(X.Content,{onClickOutside:()=>a(!1),onSelect:()=>a(!1),className:`App-toolbar__extra-tools-dropdown`,children:[(0,K.jsx)(X.Item,{onSelect:()=>n.setActiveTool({type:`frame`}),icon:Pc,shortcut:F.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:o,children:q(`toolBar.frame`)}),(0,K.jsx)(X.Item,{onSelect:()=>n.setActiveTool({type:`embeddable`}),icon:ic,"data-testid":`toolbar-embeddable`,selected:c,children:q(`toolBar.embeddable`)}),(0,K.jsx)(X.Item,{onSelect:()=>n.setActiveTool({type:`laser`}),icon:oa,"data-testid":`toolbar-laser`,selected:s,shortcut:F.K.toLocaleUpperCase(),children:q(`toolBar.laser`)}),(0,K.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),n.props.aiEnabled!==!1&&(0,K.jsx)(l.Out,{}),(0,K.jsx)(X.Item,{onSelect:()=>n.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:ur,"data-testid":`toolbar-embeddable`,children:q(`toolBar.mermaidToExcalidraw`)}),n.props.aiEnabled!==!1&&n.plugins.diagramToCode&&(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(X.Item,{onSelect:()=>n.onMagicframeToolSelect(),icon:nn,"data-testid":`toolbar-magicframe`,children:[q(`toolBar.magicframe`),(0,K.jsx)(X.Item.Badge,{children:`AI`})]})})]})]})]})},Lb=({renderAction:e,zoom:t})=>(0,K.jsx)(Ey.Col,{gap:1,className:hc.ZOOM_ACTIONS,children:(0,K.jsxs)(Ey.Row,{align:`center`,children:[e(`zoomOut`),e(`resetZoom`),e(`zoomIn`)]})}),Rb=({renderAction:e,className:t})=>(0,K.jsxs)(`div`,{className:`undo-redo-buttons ${t}`,children:[(0,K.jsx)(`div`,{className:`undo-button-container`,children:(0,K.jsx)(M_,{label:q(`buttons.undo`),children:e(`undo`)})}),(0,K.jsx)(`div`,{className:`redo-button-container`,children:(0,K.jsxs)(M_,{label:q(`buttons.redo`),children:[` `,e(`redo`)]})})]}),zb=({actionManager:e,showExitZenModeBtn:t})=>(0,K.jsx)(`button`,{type:`button`,className:I(`disable-zen-mode`,{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(Lv),children:q(`buttons.exitZenMode`)}),Bb=({renderAction:e,className:t})=>(0,K.jsx)(`div`,{className:`finalize-button ${t}`,children:e(`finalize`,{size:`small`})}),Vb=e=>{let t=(0,G.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},Hb=ku(null),Ub=()=>{let[e,t]=yh(Hb),n=CE();return e&&e===`clearCanvas`?(0,K.jsx)(Iy,{onConfirm:()=>{n.executeAction(N_),t(null)},onCancel:()=>t(null),title:q(`clearCanvasDialog.title`),children:(0,K.jsxs)(`p`,{className:`clear-canvas__content`,children:[` `,q(`alerts.clearReset`)]})}):null},Wb={};ae(Wb,{toggleTheme:()=>Gb});var Gb={...B_,category:`App`,label:`Toggle theme`,perform:({actionManager:e})=>{e.executeAction(B_,`commandPalette`)}},Kb=P({name:`copyElementLink`,label:`labels.copyElementLink`,icon:gc,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=R(e,t);try{if(window.location){let n=Vc(i,t);return n?(await ti(r.props.generateLinkForSelection?r.props.generateLinkForSelection(n.id,n.type):ta(n.id,n.type)),{appState:{toast:{message:q(`toast.elementLinkCopied`),closable:!0}},captureUpdate:M.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:M.EVENTUALLY}}}catch(e){console.error(e)}return{appState:t,elements:e,app:r,captureUpdate:M.EVENTUALLY}},predicate:(e,t)=>ol(R(e,t))}),qb=P({name:`linkToElement`,label:`labels.linkToElement`,icon:Ss,perform:(e,t,n,r)=>{let i=R(e,t);return i.length!==1||!ol(i)?{elements:e,appState:t,app:r,captureUpdate:M.EVENTUALLY}:{appState:{...t,openDialog:{name:`elementLinkSelector`,sourceElementId:R(e,t)[0].id}},captureUpdate:M.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=R(e,t);return t.openDialog?.name!==`elementLinkSelector`&&i.length===1&&ol(i)},trackEvent:!1}),Jb=ku(null),Yb={app:`App`,export:`Export`,tools:`Tools`,editor:`Editor`,elements:`Elements`,links:`Links`},Xb=e=>{switch(e){case Yb.app:return 1;case Yb.export:return 2;case Yb.editor:return 3;case Yb.tools:return 4;case Yb.elements:return 5;case Yb.links:return 6;default:return 10}},Zb=({shortcut:e,className:t,children:n})=>{let r=e.replace(`++`,`+$`).split(`+`);return(0,K.jsxs)(`div`,{className:I(`shortcut`,t),children:[r.map((e,t)=>(0,K.jsx)(`div`,{className:`shortcut-wrapper`,children:(0,K.jsx)(`div`,{className:`shortcut-key`,children:e===`$`?`+`:e})},e)),(0,K.jsx)(`div`,{className:`shortcut-desc`,children:n})]})},Qb=e=>!e.altKey&&e[F.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===F.P||e.key===F.SLASH);Object.assign(e=>{let t=Fg(),n=SE();return(0,G.useEffect)(()=>{let e=e=>{Qb(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name===`commandPalette`?null:{name:`commandPalette`};return t&&Y(`command_palette`,`open`,`shortcut`),{openDialog:t}}))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[n]),t.openDialog?.name===`commandPalette`?(0,K.jsx)($b,{...e}):null},{defaultItems:Wb});function $b({customCommandPaletteItems:e}){let t=gE(),n=Fg(),r=SE(),i=_E(),a=CE(),[o,s]=yh(Jb),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null),d=Rg({uiAppState:n,customCommandPaletteItems:e,appProps:i});(0,G.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:i}=d,c=n=>{let r=``;return n.label&&(r=typeof n.label==`function`?q(n.label(t.scene.getNonDeletedElements(),e,t)):q(n.label)),r},u=n=>typeof n.icon==`function`?n.icon(e,t.scene.getNonDeletedElements()):n.icon,f=[],p=(e,t,n)=>{let r={label:c(e),icon:u(e),category:t,shortcut:wb(e.name),keywords:e.keywords,predicate:e.predicate,viewMode:e.viewMode,perform:()=>{a.executeAction(e,`commandPalette`)}};return n?n(r,e):r};if(e&&t.scene&&a){let d=[a.actions.group,a.actions.ungroup,a.actions.cut,a.actions.copy,a.actions.deleteSelectedElements,a.actions.wrapSelectionInFrame,a.actions.copyStyles,a.actions.pasteStyles,a.actions.bringToFront,a.actions.bringForward,a.actions.sendBackward,a.actions.sendToBack,a.actions.alignTop,a.actions.alignBottom,a.actions.alignLeft,a.actions.alignRight,a.actions.alignVerticallyCentered,a.actions.alignHorizontallyCentered,a.actions.duplicateSelection,a.actions.flipHorizontal,a.actions.flipVertical,a.actions.zoomToFitSelection,a.actions.zoomToFitSelectionInViewport,a.actions.increaseFontSize,a.actions.decreaseFontSize,a.actions.toggleLinearEditor,a.actions.cropEditor,oy,Kb,qb].map(e=>p(e,Yb.elements,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,r)=>R(e,t).length>0}))),m=[a.actions.toggleHandTool,a.actions.setFrameAsActiveTool].map(e=>p(e,Yb.tools)),h=[a.actions.undo,a.actions.redo,a.actions.zoomIn,a.actions.zoomOut,a.actions.resetZoom,a.actions.zoomToFit,a.actions.zenMode,a.actions.viewMode,a.actions.gridMode,a.actions.objectsSnapMode,a.actions.toggleShortcuts,a.actions.selectAll,a.actions.toggleElementLock,a.actions.unlockAllElements,a.actions.stats].map(e=>p(e,Yb.editor)),g=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(e=>p(e,Yb.export));f=[...d,...h,{label:c(N_),icon:u(N_),shortcut:wb(N_.name),category:Yb.editor,keywords:[`delete`,`destroy`],viewMode:!1,perform:()=>{wh.set(Hb,`clearCanvas`)}},{label:q(`buttons.exportImage`),category:Yb.export,icon:js,shortcut:wb(`imageExport`),keywords:[`export`,`image`,`png`,`jpeg`,`svg`,`clipboard`,`picture`],perform:()=>{r({openDialog:{name:`imageExport`}})}},...g];let _=[{label:q(`toolBar.library`),category:Yb.app,icon:Qn,viewMode:!1,perform:()=>{e.openSidebar?r({openSidebar:null}):r({openSidebar:{name:uo.name,tab:uo.defaultTab}})}},{label:q(`search.title`),category:Yb.app,icon:$a,viewMode:!0,perform:()=>{a.executeAction(nx)}},{label:q(`labels.changeStroke`),keywords:[`color`,`outline`],category:Yb.elements,icon:ts,viewMode:!1,predicate:(e,t)=>{let n=R(e,t);return n.length>0&&Nb(t,n)},perform:()=>{r(e=>({openMenu:e.openMenu===`shape`?null:`shape`,openPopup:`elementStroke`}))}},{label:q(`labels.changeBackground`),keywords:[`color`,`fill`],icon:ts,category:Yb.elements,viewMode:!1,predicate:(e,t)=>{let n=R(e,t);return n.length>0&&Pb(t,n)},perform:()=>{r(e=>({openMenu:e.openMenu===`shape`?null:`shape`,openPopup:`elementBackground`}))}},{label:q(`labels.canvasBackground`),keywords:[`color`],icon:ts,category:Yb.editor,viewMode:!1,perform:()=>{r(e=>({openMenu:e.openMenu===`canvas`?null:`canvas`,openPopup:`canvasBackground`}))}},...ue.reduce((e,n)=>{let{value:r,icon:a,key:o,numericKey:s}=n;if(i.UIOptions.tools?.[r]===!1)return e;let c=o&&ro(typeof o==`string`?o:o[0])||s,l={label:q(`toolBar.${r}`),category:Yb.tools,shortcut:c,icon:a,keywords:[`toolbar`],viewMode:!1,perform:({event:e})=>{r===`image`?t.setActiveTool({type:r,insertOnCanvasDirectly:e.type===`keydown`}):t.setActiveTool({type:r})}};return e.push(l),e},[]),...m,{label:q(`toolBar.lock`),category:Yb.tools,icon:e.activeTool.locked?io:Zl,shortcut:F.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${q(`labels.textToDiagram`)}...`,category:Yb.tools,icon:ga,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`text-to-diagram`}}))}},{label:`${q(`toolBar.mermaidToExcalidraw`)}...`,category:Yb.tools,icon:ur,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`mermaid`}}))}}],v=[...f,..._,...n||[]].map(e=>({...e,icon:e.icon||xo,order:e.order??Xb(e.category),haystack:`${Ob(e.label.toLocaleLowerCase())} ${e.keywords?.join(` `)||``}`}));l(v),s(v.find(e=>e.label===o?.label)??null)}},[d,t,a,l,o?.label,s,r]);let[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)({}),v=e=>{r({openDialog:null},e),p(``)},y=(e,t)=>{n.openDialog?.name===`commandPalette`&&(t.stopPropagation(),t.preventDefault(),document.body.classList.add(`excalidraw-animations-disabled`),v(()=>{e.perform({actionManager:a,event:t}),s(e),requestAnimationFrame(()=>{document.body.classList.remove(`excalidraw-animations-disabled`)})}))},b=Vb(e=>e.viewMode===!1&&n.viewModeEnabled?!1:typeof e.predicate==`function`?e.predicate(t.scene.getNonDeletedElements(),n,i,t):e.predicate===void 0||e.predicate),x=Vb(e=>{let t=$t(e.target)||Qb(e)||e.key===F.ESCAPE;if(t&&e.key!==F.ARROW_UP&&e.key!==F.ARROW_DOWN&&e.key!==F.ENTER)return;let n=Object.values(g).flat(),r=o&&!f&&b(o);if(e.key===F.ARROW_UP){e.preventDefault();let t=n.findIndex(e=>e.label===m?.label);if(r){if(t===0){h(o);return}if(m===o){let e=n[n.length-1];e&&h(e);return}}let i;i=t===-1||t===0?n.length-1:(t-1)%n.length;let a=n[i];a&&h(a);return}if(e.key===F.ARROW_DOWN){e.preventDefault();let t=n.findIndex(e=>e.label===m?.label);if(r){if(!m||t===n.length-1){h(o);return}if(m===o){let e=n[0];e&&h(e);return}}let i=n[(t+1)%n.length];i&&h(i);return}if(e.key===F.ENTER&&m&&setTimeout(()=>{y(m,e)}),!t){if(e.stopPropagation(),/^[a-zA-Z0-9]$/.test(e.key)){u?.current?.focus();return}e.preventDefault()}});return(0,G.useEffect)(()=>(window.addEventListener(`keydown`,x,{capture:!0}),()=>window.removeEventListener(`keydown`,x,{capture:!0})),[x]),(0,G.useEffect)(()=>{if(!c)return;let e=e=>{let t={};for(let n of e)t[n.category]?t[n.category].push(n):t[n.category]=[n];return t},t=c.filter(b).sort((e,t)=>e.order-t.order),n=!f&&o&&b(o);if(!f){_(e(n?t.filter(e=>e.label!==o?.label):t)),h(n?o:t[0]||null);return}let r=Ob(f.toLocaleLowerCase().replace(/[<>_| -]/g,``));t=Ap.default.filter(r,t,{extract:e=>e.haystack}).sort((e,t)=>t.score-e.score).map(e=>e.original),_(e(t)),h(t[0]??null)},[f,c,b,o]),(0,K.jsxs)(bb,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:`command-palette-dialog`,children:[(0,K.jsx)(Sb,{value:f,placeholder:q(`commandPalette.search.placeholder`),onChange:e=>{p(e)},selectOnRender:!0,ref:u}),!t.device.viewport.isMobile&&(0,K.jsxs)(`div`,{className:`shortcuts-wrapper`,children:[(0,K.jsx)(Zb,{shortcut:`↑↓`,children:q(`commandPalette.shortcuts.select`)}),(0,K.jsx)(Zb,{shortcut:`↵`,children:q(`commandPalette.shortcuts.confirm`)}),(0,K.jsx)(Zb,{shortcut:B(`Esc`),children:q(`commandPalette.shortcuts.close`)})]}),(0,K.jsxs)(`div`,{className:`commands`,children:[o&&!f&&(0,K.jsxs)(`div`,{className:`command-category`,children:[(0,K.jsxs)(`div`,{className:`command-category-title`,children:[q(`commandPalette.recents`),(0,K.jsx)(`div`,{className:`icon`,style:{marginLeft:`6px`},children:Nl})]}),(0,K.jsx)(ex,{command:o,isSelected:o.label===m?.label,onClick:e=>y(o,e),disabled:!b(o),onMouseMove:()=>h(o),showShortcut:!t.device.viewport.isMobile,appState:n})]}),Object.keys(g).length>0?Object.keys(g).map((e,r)=>(0,K.jsxs)(`div`,{className:`command-category`,children:[(0,K.jsx)(`div`,{className:`command-category-title`,children:e}),g[e].map(e=>(0,K.jsx)(ex,{command:e,isSelected:e.label===m?.label,onClick:t=>y(e,t),onMouseMove:()=>h(e),showShortcut:!t.device.viewport.isMobile,appState:n},e.label))]},e)):c?(0,K.jsxs)(`div`,{className:`no-match`,children:[(0,K.jsx)(`div`,{className:`icon`,children:$a}),` `,q(`commandPalette.search.noMatch`)]}):null]})]})}var ex=({command:e,isSelected:t,disabled:n,onMouseMove:r,onClick:i,showShortcut:a,appState:o})=>{let s=()=>{};return(0,K.jsxs)(`div`,{className:I(`command-item`,{"item-selected":t,"item-disabled":n}),ref:e=>{t&&!n&&e?.scrollIntoView?.({block:`nearest`})},onClick:n?s:i,onMouseMove:n?s:r,title:n?q(`commandPalette.itemNotAvailable`):``,children:[(0,K.jsxs)(`div`,{className:`name`,children:[e.icon&&(0,K.jsx)(Yg,{icon:typeof e.icon==`function`?e.icon(o):e.icon}),e.label]}),a&&e.shortcut&&(0,K.jsx)(Zb,{shortcut:e.shortcut})]})},tx=P({name:`toggleLinearEditor`,category:Yb.elements,label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`,keywords:[`line`],trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&i.length===1&&Ac(i[0])&&!T(i[0]))},perform(e,t,n,r){let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],a=t.editingLinearElement?.elementId===i.id?null:new N(i);return{appState:{...t,editingLinearElement:a},captureUpdate:M.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],i=q(r.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`);return(0,K.jsx)(J,{type:`button`,icon:Sc,title:i,"aria-label":i,onClick:()=>t(null)})}}),nx=P({name:`searchMenu`,icon:$a,keywords:[`search`,`find`],label:`search.title`,viewMode:!0,trackEvent:{category:`search_menu`,action:`toggle`,predicate:e=>e.gridModeEnabled},perform(e,t,n,r){if(t.openSidebar?.name===uo.name&&t.openSidebar.tab===`search`){let e=r.excalidrawContainerValue.container?.querySelector(`.${hc.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.matches(`:focus`)?{appState:{...t,openSidebar:null},captureUpdate:M.EVENTUALLY}:(e?.focus(),e?.select(),!1)}return{appState:{...t,openSidebar:{name:uo.name,tab:Ci},openDialog:null},captureUpdate:M.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[F.CTRL_OR_CMD]&&e.key===F.F}),rx=P({name:`cropEditor`,label:`helpDialog.cropStart`,icon:to,viewMode:!0,trackEvent:{category:`menu`},keywords:[`image`,`crop`],perform(e,t,n,r){let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:i.id},captureUpdate:M.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!!(!t.croppingElementId&&i.length===1&&Mo(i[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=q(`helpDialog.cropStart`);return(0,K.jsx)(J,{type:`button`,icon:to,title:r,"aria-label":r,onClick:()=>t(null)})}}),ix=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},ax=class e{constructor(){w(this,`onHistoryChangedEmitter`,new Wr),w(this,`undoStack`,[]),w(this,`redoStack`,[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(e,t){let n=ox.create(t,e);n.isEmpty()||(this.undoStack.push(n.inverse()),n.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ix(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,n,r){return this.perform(t,n,r,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,t))}redo(t,n,r){return this.perform(t,n,r,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,t))}perform(e,t,n,r,i){try{let a=r();if(a===null)return;let o=e,s=t,c=!1;for(;a;){try{[o,s,c]=a.applyTo(o,s,n)}finally{i(a)}if(c)break;a=r()}return[o,s]}finally{this.onHistoryChangedEmitter.trigger(new ix(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(e){if(!e.length)return null;let t=e.pop();return t===void 0?null:t}static push(e,t,n){let r=t.inverse().applyLatestChanges(n);return e.push(r)}},ox=class e{constructor(e,t){this.appStateChange=e,this.elementsChange=t}static create(t,n){return new e(t,n)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(e,t,n){let[r,i]=this.elementsChange.applyTo(e,n.elements),[a,o]=this.appStateChange.applyTo(t,r);return[r,a,i||o]}applyLatestChanges(t){let n=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,n)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}},sx=(e,t)=>{let[n,r]=(0,G.useState)(t);return(0,G.useEffect)(()=>{let t=e.on(e=>{r(e)});return()=>{t()}},[e]),n},cx=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowChartCreator.isCreatingChart){let e=n();if(!e)return{captureUpdate:M.EVENTUALLY};let[t,r]=e;return{appState:r,elements:Array.from(t.values()),captureUpdate:M.NEVER}}return{captureUpdate:M.EVENTUALLY}},lx=(e,t)=>({name:`undo`,label:`buttons.undo`,icon:di,trackEvent:{category:`history`},viewMode:!1,perform:(n,r,i,a)=>cx(a,r,()=>e.undo(E(n),r,t.snapshot)),keyTest:e=>e[F.CTRL_OR_CMD]&&eo(e,F.Z)&&!e.shiftKey,PanelComponent:({updateData:t,data:n})=>{let{isUndoStackEmpty:r}=sx(e.onHistoryChangedEmitter,new ix(e.isUndoStackEmpty,e.isRedoStackEmpty));return(0,K.jsx)(J,{type:`button`,icon:di,"aria-label":q(`buttons.undo`),onClick:t,size:n?.size||`medium`,disabled:r,"data-testid":`button-undo`})}}),ux=(e,t)=>({name:`redo`,label:`buttons.redo`,icon:fi,trackEvent:{category:`history`},viewMode:!1,perform:(n,r,i,a)=>cx(a,r,()=>e.redo(E(n),r,t.snapshot)),keyTest:e=>e[F.CTRL_OR_CMD]&&e.shiftKey&&eo(e,F.Z)||Ds&&e.ctrlKey&&!e.shiftKey&&eo(e,F.Y),PanelComponent:({updateData:t,data:n})=>{let{isRedoStackEmpty:r}=sx(e.onHistoryChangedEmitter,new ix(e.isUndoStackEmpty,e.isRedoStackEmpty));return(0,K.jsx)(J,{type:`button`,icon:fi,"aria-label":q(`buttons.redo`),onClick:t,size:n?.size||`medium`,disabled:r,"data-testid":`button-redo`})}}),dx=(e,t,n,r,i,a)=>{if(e.trackEvent)try{typeof e.trackEvent==`object`&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,a))&&Y(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.device.editor.isMobile?`mobile`:`desktop`})`)}catch(e){console.error(`error while logging action:`,e)}},fx=class{constructor(e,t,n,r){w(this,`actions`,{}),w(this,`updater`),w(this,`getAppState`),w(this,`getElementsIncludingDeleted`),w(this,`app`),w(this,`renderAction`,(e,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[e]&&`PanelComponent`in this.actions[e]&&(!(e in n)||n[e])){let n=this.actions[e],r=n.PanelComponent;r.displayName=`PanelComponent`;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return(0,K.jsx)(r,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:e=>{dx(n,`ui`,a,i,this.app,e),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),e,this.app))},appProps:this.app.props,app:this.app,data:t})}return null}),w(this,`isActionEnabled`,e=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!e.predicate||e.predicate(t,n,this.app.props,this.app)}),this.updater=t=>{if(Qe(t))t.then(t=>e(t));else return e(t)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(e){this.actions[e.name]=e}registerAll(e){e.forEach(e=>this.registerAction(e))}handleKeyDown(e){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((e,t)=>(t.keyPriority||0)-(e.keyPriority||0)).filter(n=>(n.name in t?t[n.name]:!0)&&n.keyTest&&n.keyTest(e,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn(`Canceling as multiple actions match this shortcut`,n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return dx(r,`keyboard`,a,i,this.app,null),e.preventDefault(),e.stopPropagation(),this.updater(n[0].perform(i,a,null,this.app)),!0}executeAction(e,t=`api`,n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();dx(e,t,i,r,this.app,n),this.updater(e.perform(r,i,n,this.app))}},px=e=>{let t=Array.from(e.values());return{x:hx(t,e=>e.x)/t.length,y:hx(t,e=>e.y)/t.length}},mx=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),hx=(e,t)=>e.reduce((e,n)=>e+t(n),0),gx=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,offsetLeft:a=0,offsetTop:o=0,viewportWidth:s=window.innerWidth,viewportHeight:c=window.innerHeight})=>{let l=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=l.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===F.TAB){let n=Zi(e),{activeElement:r}=document,i=n.findIndex(e=>e===r);r===e?(t.shiftKey?n[n.length-1]?.focus():n[0].focus(),t.preventDefault(),t.stopImmediatePropagation()):i===0&&t.shiftKey?(n[n.length-1]?.focus(),t.preventDefault(),t.stopImmediatePropagation()):i===n.length-1&&!t.shiftKey&&(n[0]?.focus(),t.preventDefault(),t.stopImmediatePropagation())}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);let u=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{if(i&&l.current&&n!=null&&t!=null){let e=l.current,{width:r,height:i}=e.getBoundingClientRect();if(u.current?.top===n&&u.current?.left===t)return;u.current={top:n,left:t},r>=s?(e.style.width=`${s}px`,e.style.left=`0px`,e.style.overflowX=`scroll`):t+r-a>s?e.style.left=`${s-r-10}px`:e.style.left=`${t}px`,i>=c?(e.style.height=`${c-20}px`,e.style.top=`10px`,e.style.overflowY=`scroll`):n+i-o>c?e.style.top=`${c-i}px`:e.style.top=`${n}px`}},[n,t,i,s,c,a,o]),(0,G.useEffect)(()=>{if(r){let e=e=>{l.current?.contains(e.target)||(0,_d.unstable_batchedUpdates)(()=>r(e))};return document.addEventListener(`pointerdown`,e,!1),()=>document.removeEventListener(`pointerdown`,e,!1)}},[r]),(0,K.jsx)(`div`,{className:`popover`,ref:l,tabIndex:-1,children:e})},_x=`separator`,vx=G.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{let a=xE(),o=bE(),s=t.reduce((t,n)=>(n&&(n===_x||!n.predicate||n.predicate(o,a,e.app.props,e.app))&&t.push(n),t),[]);return(0,K.jsx)(gx,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,offsetLeft:a.offsetLeft,offsetTop:a.offsetTop,viewportWidth:a.width,viewportHeight:a.height,children:(0,K.jsx)(`ul`,{className:`context-menu`,onContextMenu:e=>e.preventDefault(),children:s.map((t,n)=>{if(t===_x)return!s[n-1]||s[n-1]===_x?null:(0,K.jsx)(`hr`,{className:`context-menu-item-separator`},n);let r=t.name,c=``;return t.label&&(c=typeof t.label==`function`?q(t.label(o,a,e.app)):q(t.label)),(0,K.jsx)(`li`,{"data-testid":r,onClick:()=>{i(()=>{e.executeAction(t,`contextMenu`)})},children:(0,K.jsxs)(`button`,{type:`button`,className:I(`context-menu-item`,{dangerous:r===`deleteSelectedElements`,checkmark:t.checked?.(a)}),children:[(0,K.jsx)(`div`,{className:`context-menu-item__label`,children:c}),(0,K.jsx)(`kbd`,{className:`context-menu-item__shortcut`,children:r?wb(r):``})]})},n)})})})}),yx=({children:e,onClose:t})=>{let[n,r]=(0,G.useState)(!!e),{container:i}=yE(),a=G.useCallback(()=>{r(!1),t&&t(),i?.focus()},[t,i]);return(0,K.jsx)(K.Fragment,{children:n&&(0,K.jsx)(bb,{size:`small`,onCloseRequest:a,title:q(`errorDialog.title`),children:(0,K.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e})})})},bx=function({onChange:e,value:t,choices:n,name:r}){return(0,K.jsx)(`div`,{className:`RadioGroup`,children:n.map(n=>(0,K.jsxs)(`div`,{className:I(`RadioGroup__choice`,{active:n.value===t}),title:n.ariaLabel,children:[(0,K.jsx)(`input`,{name:r,type:`radio`,checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},xx=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>(0,K.jsx)(`div`,{className:I(`Switch`,{toggled:n,disabled:i}),children:(0,K.jsx)(`input`,{name:t,id:t,title:e,type:`checkbox`,checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:e=>{e.key===` `&&r(!n)}})}),Sx=(0,G.forwardRef)(({children:e,icon:t,onClick:n,label:r,variant:i=`filled`,color:a=`primary`,size:o=`medium`,fullWidth:s,className:c,status:l},u)=>{let[d,f]=(0,G.useState)(!1),p=async e=>{let t=n?.(e);if(Qe(t)){let e=window.setTimeout(()=>{f(!0)},50);try{await t}catch(e){if(e instanceof ii)console.warn(e);else throw e}finally{clearTimeout(e),f(!1)}}},m=d?`loading`:l;return a=m===`success`?`success`:a,(0,K.jsx)(`button`,{className:I(`ExcButton`,`ExcButton--color-${a}`,`ExcButton--variant-${i}`,`ExcButton--size-${o}`,`ExcButton--status-${m}`,{"ExcButton--fullWidth":s},c),onClick:p,type:`button`,"aria-label":r,ref:u,disabled:m===`loading`||m===`success`,children:(0,K.jsxs)(`div`,{className:`ExcButton__contents`,children:[m===`loading`?(0,K.jsx)(Lh,{className:`ExcButton__statusIcon`}):m===`success`&&(0,K.jsx)(`div`,{className:`ExcButton__statusIcon`,children:$i}),t&&(0,K.jsx)(`div`,{className:`ExcButton__icon`,"aria-hidden":!0,children:t}),i!==`icon`&&(e??r)]})})}),Cx=2e3,wx=()=>{let[e,t]=(0,G.useState)(null),n=(0,G.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,G.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t(`success`),n.current=window.setTimeout(()=>{t(null)},Cx)}}},Tx=`filter`in document.createElement(`canvas`).getContext(`2d`),Ex=()=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{children:q(`canvasError.cannotShowPreview`)}),(0,K.jsx)(`p`,{children:(0,K.jsx)(`span`,{children:q(`canvasError.canvasTooBig`)})}),(0,K.jsxs)(`em`,{children:[`(`,q(`canvasError.canvasTooBigTip`),`)`]})]}),Dx=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:a})=>{let o=mo(t,e),[s,c]=(0,G.useState)(a),[l,u]=(0,G.useState)(o),[d,f]=(0,G.useState)(e.exportBackground),[p,m]=(0,G.useState)(e.exportWithDarkMode),[h,g]=(0,G.useState)(e.exportEmbedScene),[_,v]=(0,G.useState)(e.exportScale),y=(0,G.useRef)(null),[b,x]=(0,G.useState)(null),{onCopy:S,copyStatus:ee,resetCopyStatus:te}=wx();(0,G.useEffect)(()=>{te()},[s,d,p,_,h,te]);let{exportedElements:ne,exportingFrame:re}=K_(t,e,l);return(0,G.useEffect)(()=>{let t=y.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight;r&&ze({elements:ne,appState:{...e,name:s,exportBackground:d,exportWithDarkMode:p,exportScale:_,exportEmbedScene:h},files:n,exportPadding:10,maxWidthOrHeight:Math.max(r,i),exportingFrame:re}).then(e=>(x(null),br(e).then(()=>{t.replaceChildren(e)}).catch(e=>{throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(q(`canvasError.canvasTooBig`)):e}))).catch(e=>{console.error(e),x(e)})},[e,n,ne,re,s,d,p,_,h]),(0,K.jsxs)(`div`,{className:`ImageExportModal`,children:[(0,K.jsx)(`h3`,{children:q(`imageExportDialog.header`)}),(0,K.jsxs)(`div`,{className:`ImageExportModal__preview`,children:[(0,K.jsx)(`div`,{className:`ImageExportModal__preview__canvas`,ref:y,children:b&&(0,K.jsx)(Ex,{})}),(0,K.jsx)(`div`,{className:`ImageExportModal__preview__filename`,children:!Bt&&(0,K.jsx)(`input`,{type:`text`,className:`TextInput`,value:s,style:{width:`30ch`},onChange:e=>{c(e.target.value),r.executeAction(X_,`ui`,e.target.value)}})})]}),(0,K.jsxs)(`div`,{className:`ImageExportModal__settings`,children:[(0,K.jsx)(`h3`,{children:q(`imageExportDialog.header`)}),o&&(0,K.jsx)(Ox,{label:q(`imageExportDialog.label.onlySelected`),name:`exportOnlySelected`,children:(0,K.jsx)(xx,{name:`exportOnlySelected`,checked:l,onChange:e=>{u(e)}})}),(0,K.jsx)(Ox,{label:q(`imageExportDialog.label.withBackground`),name:`exportBackgroundSwitch`,children:(0,K.jsx)(xx,{name:`exportBackgroundSwitch`,checked:d,onChange:e=>{f(e),r.executeAction(Q_,`ui`,e)}})}),Tx&&(0,K.jsx)(Ox,{label:q(`imageExportDialog.label.darkMode`),name:`exportDarkModeSwitch`,children:(0,K.jsx)(xx,{name:`exportDarkModeSwitch`,checked:p,onChange:e=>{m(e),r.executeAction(rv,`ui`,e)}})}),(0,K.jsx)(Ox,{label:q(`imageExportDialog.label.embedScene`),tooltip:q(`imageExportDialog.tooltip.embedScene`),name:`exportEmbedSwitch`,children:(0,K.jsx)(xx,{name:`exportEmbedSwitch`,checked:h,onChange:e=>{g(e),r.executeAction($_,`ui`,e)}})}),(0,K.jsx)(Ox,{label:q(`imageExportDialog.label.scale`),name:`exportScale`,children:(0,K.jsx)(bx,{name:`exportScale`,value:_,onChange:e=>{v(e),r.executeAction(Z_,`ui`,e)},choices:Ti.map(e=>({value:e,label:`${e}\xD7`}))})}),(0,K.jsxs)(`div`,{className:`ImageExportModal__settings__buttons`,children:[(0,K.jsx)(Sx,{className:`ImageExportModal__settings__buttons__button`,label:q(`imageExportDialog.title.exportToPng`),onClick:()=>i(_c.png,ne,{exportingFrame:re}),icon:ho,children:q(`imageExportDialog.button.exportToPng`)}),(0,K.jsx)(Sx,{className:`ImageExportModal__settings__buttons__button`,label:q(`imageExportDialog.title.exportToSvg`),onClick:()=>i(_c.svg,ne,{exportingFrame:re}),icon:ho,children:q(`imageExportDialog.button.exportToSvg`)}),(Kt||Ei)&&(0,K.jsx)(Sx,{className:`ImageExportModal__settings__buttons__button`,label:q(`imageExportDialog.title.copyPngToClipboard`),status:ee,onClick:async()=>{await i(_c.clipboard,ne,{exportingFrame:re}),S()},icon:gc,children:q(`imageExportDialog.button.copyPngToClipboard`)})]})]})]})},Ox=({label:e,children:t,tooltip:n,name:r})=>(0,K.jsxs)(`div`,{className:`ImageExportModal__settings__setting`,title:e,children:[(0,K.jsxs)(`label`,{htmlFor:r,className:`ImageExportModal__settings__setting__label`,children:[e,n&&(0,K.jsx)(M_,{label:n,long:!0,children:Ao})]}),(0,K.jsx)(`div`,{className:`ImageExportModal__settings__setting__content`,children:t})]}),kx=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:a,name:o})=>{let[{appStateSnapshot:s,elementsSnapshot:c}]=(0,G.useState)(()=>({appStateSnapshot:ke(t),elementsSnapshot:ke(e)}));return(0,K.jsx)(bb,{onCloseRequest:a,size:`wide`,title:!1,children:(0,K.jsx)(Dx,{elementsSnapshot:c,appStateSnapshot:s,files:n,actionManager:r,onExportImage:i,name:o})})},Ax=({children:e,side:t,className:n})=>(0,K.jsx)(`div`,{className:I(`FixedSideContainer`,`FixedSideContainer_side_${t}`,n),children:e}),jx=100,Mx=100,Nx=e=>{switch(e){case F.ARROW_UP:return`up`;case F.ARROW_DOWN:return`down`;case F.ARROW_RIGHT:return`right`;case F.ARROW_LEFT:return`left`;default:return`right`}},Px=(e,t,n,r)=>{let i=[...n.values()].reduce((r,i)=>{let a;if(T(i)&&(a=i[e===`predecessors`?`startBinding`:`endBinding`])&&i[e===`predecessors`?`endBinding`:`startBinding`]?.elementId===t.id){let o=n.get(a.elementId);if(!o)return r;jo(Va(o),`not an ExcalidrawBindableElement`);let s=e===`predecessors`?i.points[i.points.length-1]:[0,0],c=en(t,Dl(t),[s[0]+i.x,s[1]+i.y]);r.push({relative:o,heading:c})}return r},[]);switch(r){case`up`:return i.filter(e=>le(e.heading,Fr)).map(e=>e.relative);case`down`:return i.filter(e=>le(e.heading,ql)).map(e=>e.relative);case`right`:return i.filter(e=>le(e.heading,on)).map(e=>e.relative);case`left`:return i.filter(e=>le(e.heading,xs)).map(e=>e.relative)}},Fx=(e,t,n)=>Px(`successors`,e,t,n),Ix=(e,t,n)=>Px(`predecessors`,e,t,n),Lx=(e,t,n)=>{let r=Mx+e.width;if(n===`up`||n===`down`){let r=jx+e.height,i=e.x,a=e.x+e.width;if(t.every(e=>e.x+e.width<i||e.x>a))return{x:0,y:r*(n===`up`?-1:1)}}else if(n===`right`||n===`left`){let r=e.y,i=e.y+e.height;if(t.every(e=>e.y+e.height<r||e.y>i))return{x:(Mx+e.width)*(n===`left`?-1:1),y:0}}if(n===`up`||n===`down`){let i=jx+e.height,a=(t.length,i),o=t.length===0?0:(t.length+1)%2==0?(t.length+1)/2*r:t.length/2*r*-1;return n===`up`?{x:o,y:a*-1}:{x:o,y:a}}let i=jx+e.height,a=(t.length,Mx+e.width),o=t.length===0?0:(t.length+1)%2==0?(t.length+1)/2*i:t.length/2*i*-1;return n===`left`?{x:a*-1,y:o}:{x:a,y:o}},Rx=(e,t,n,r)=>{let i=Fx(e,t,r),a=Ix(e,t,r),o=Lx(e,[...i,...a],r),s=Ua({type:e.type,x:e.x+o.x,y:e.y+o.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});return jo(He(s),`not an ExcalidrawFlowchartNodeElement`),{nextNode:s,bindingArrow:Bx(e,s,t,r,n)}},zx=(e,t,n,r,i)=>{let a=[];for(let o=0;o<i;o++){let s,c;if(r===`left`||r===`right`){let t=jx*(i-1)+i*e.height,n=e.y+e.height/2-t/2,a=Mx+e.width;r===`left`&&(a*=-1),s=e.x+a,c=n+(jx+e.height)*o}else{let t=Mx*(i-1)+i*e.width,n=e.x+e.width/2-t/2,a=jx+e.height;r===`up`&&(a*=-1),c=e.y+a,s=n+(Mx+e.width)*o}let l=Ua({type:e.type,x:s,y:c,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});jo(He(l),`not an ExcalidrawFlowchartNodeElement`);let u=Bx(e,l,t,r,n);a.push(l),a.push(u)}return a},Bx=(e,t,n,r,i)=>{let a,o;switch(r){case`up`:a=e.x+e.width/2,o=e.y-6;break;case`down`:a=e.x+e.width/2,o=e.y+e.height+6;break;case`right`:a=e.x+e.width+6,o=e.y+e.height/2;break;case`left`:a=e.x-6,o=e.y+e.height/2;break}let s,c;switch(r){case`up`:s=t.x+t.width/2-a,c=t.y+t.height-o+6;break;case`down`:s=t.x+t.width/2-a,c=t.y-o-6;break;case`right`:s=t.x-a-6,c=t.y-o+t.height/2;break;case`left`:s=t.x+t.width-a+6,c=t.y-o+t.height/2;break}let l=Jr({type:`arrow`,x:a,y:o,startArrowhead:null,endArrowhead:i.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[O(0,0),O(s,c)],elbowed:!0});be(l,e,`start`,n),be(l,t,`end`,n);let u=new Map;u.set(e.id,e),u.set(t.id,t),u.set(l.id,l),N.movePoints(l,[{index:1,point:l.points[1]}]);let d=fr(l,Un(new Map([...n.entries(),[e.id,e],[t.id,t],[l.id,l]])),{points:l.points});return{...l,...d}},Vx=class{constructor(){w(this,`isExploring`,!1),w(this,`sameLevelNodes`,[]),w(this,`sameLevelIndex`,0),w(this,`direction`,null),w(this,`visitedNodes`,new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(e,t,n){if(!Va(e))return null;if(n!==this.direction&&this.clear(),this.visitedNodes.has(e.id)||this.visitedNodes.add(e.id),this.isExploring&&n===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let r=[...Fx(e,t,n),...Ix(e,t,n)];if(r.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=r,this.direction=n,this.visitedNodes.add(r[0].id),r[0].id;if(n===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(e.id);let r=[`up`,`right`,`down`,`left`].filter(e=>e!==n).map(n=>[...Fx(e,t,n),...Ix(e,t,n)]).flat().filter(e=>!this.visitedNodes.has(e.id));for(let e of r)if(!this.visitedNodes.has(e.id))return this.visitedNodes.add(e.id),this.isExploring=!0,this.direction=n,e.id}return null}},Hx=class{constructor(){w(this,`isCreatingChart`,!1),w(this,`numberOfNodes`,0),w(this,`direction`,`right`),w(this,`pendingNodes`,null)}createNodes(e,t,n,r){if(r!==this.direction){let{nextNode:i,bindingArrow:a}=Rx(e,t,n,r);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=r,this.pendingNodes=[i,a]}else{this.numberOfNodes+=1;let i=zx(e,t,n,r,this.numberOfNodes);this.isCreatingChart=!0,this.direction=r,this.pendingNodes=i}if(e.frameId){let n=t.get(e.frameId);jo(n&&pu(n),`not an ExcalidrawFrameElement`),n&&this.pendingNodes.every(e=>zn([e],n,t)||Kl(e,n,t))&&(this.pendingNodes=this.pendingNodes.map(t=>U(t,{frameId:e.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},Ux=(e,t)=>{for(let[,n]of t)if(n.type===`arrow`&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0;return!1},Wx=({appState:e,isMobile:t,device:n,app:r})=>{let{activeTool:i,isResizing:a,isRotating:o,lastPointerDownWith:s}=e,c=e.multiElement!==null;if(e.openSidebar?.name===uo.name&&e.openSidebar.tab===`search`&&e.searchMatches?.length)return q(`hints.dismissSearch`);if(e.openSidebar&&!n.editor.canFitSidebar)return null;if(it(e))return q(`hints.eraserRevert`);if(i.type===`arrow`||i.type===`line`)return c?q(`hints.linearElementMulti`):i.type===`arrow`?q(`hints.arrowTool`,{arrowShortcut:B(`A`)}):q(`hints.linearElement`);if(i.type===`freedraw`)return q(`hints.freeDraw`);if(i.type===`text`)return q(`hints.text`);if(i.type===`embeddable`)return q(`hints.embeddable`);if(e.activeTool.type===`image`&&e.pendingImageElementId)return q(`hints.placeImage`);let l=r.scene.getSelectedElements(e);if(a&&s===`mouse`&&l.length===1){let e=l[0];return Ac(e)&&e.points.length===2?q(`hints.lockAngle`):Mo(e)?q(`hints.resizeImage`):q(`hints.resize`)}if(o&&s===`mouse`)return q(`hints.rotate`);if(l.length===1&&L(l[0]))return q(`hints.text_selected`);if(e.editingTextElement)return q(`hints.text_editing`);if(e.croppingElementId)return q(`hints.leaveCropEditor`);if(l.length===1&&Mo(l[0]))return q(`hints.enterCropEditor`);if(i.type===`selection`){if(e.selectionElement&&!l.length&&!e.editingTextElement&&!e.editingLinearElement)return q(`hints.deepBoxSelect`);if(ul(r)&&e.selectedElementsAreBeingDragged)return q(`hints.disableSnapping`);if(!l.length&&!t)return q(`hints.canvasPanning`);if(l.length===1){if(Ac(l[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?q(`hints.lineEditor_pointSelected`):q(`hints.lineEditor_nothingSelected`):q(`hints.lineEditor_info`);if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Ll(l[0]))return He(l[0])?(Ux(l[0],r.scene.getNonDeletedElementsMap()),[q(`hints.bindTextToElement`),q(`hints.createFlowchart`)]):q(`hints.bindTextToElement`)}}return null},Gx=({appState:e,isMobile:t,device:n,app:r})=>{let i=Wx({appState:e,isMobile:t,device:n,app:r});return i?(0,K.jsx)(`div`,{className:`HintViewer`,children:(0,K.jsx)(`span`,{children:Array.isArray(i)?i.map(e=>B(e).replace(/\. ?$/,``)).join(`. `):B(i)})}):null},Kx=`medium`,qx={CHECKED:io,UNCHECKED:Zl},Jx=e=>(0,K.jsxs)(`label`,{className:I(`ToolIcon ToolIcon__lock`,`ToolIcon_size_${Kx}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[(0,K.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":`toolbar-lock`}),(0,K.jsx)(`div`,{className:`ToolIcon__icon`,children:e.checked?qx.CHECKED:qx.UNCHECKED})]}),Yx=({heading:e,children:t,...n})=>{let{id:r}=yE(),i=(0,K.jsx)(`h2`,{className:`visually-hidden`,id:`${r}-${e}-title`,children:q(`headings.${e}`)});return(0,K.jsx)(`section`,{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t==`function`?t(i):(0,K.jsxs)(K.Fragment,{children:[i,t]})})},Xx=4,Zx=6,Qx=`rgba(0,0,0,0.3)`,$x=(e,t,n,r)=>{if(!e.length)return{horizontal:null,vertical:null};let[i,a,o,s]=Zo(e),c=t/r.zoom.value,l=n/r.zoom.value,u=t-c,d=n-l,f={top:parseInt(Ms(`sat`))||0,bottom:parseInt(Ms(`sab`))||0,left:parseInt(Ms(`sal`))||0,right:parseInt(Ms(`sar`))||0},p=Nh().rtl,m=-r.scrollX+u/2+f.left,h=-r.scrollY+d/2+f.top,g=m+c-f.right,_=h+l-f.bottom,v=Math.min(i,m),y=Math.min(a,h),b=Math.max(o,g),x=Math.max(s,_);return{horizontal:m===v&&g===b?null:{x:Math.max(f.left,Xx)+(m-v)/(b-v)*t,y:n-Zx-Math.max(Xx,f.bottom),width:(g-m)/(b-v)*t-Math.max(Xx*2,f.left+f.right),height:Zx},vertical:h===y&&_===x?null:{x:p?Math.max(f.left,Xx):t-Zx-Math.max(f.right,Xx),y:(h-y)/(x-y)*n+Math.max(f.top,Xx),width:Zx,height:(_-h)/(x-y)*n-Math.max(Xx*2,f.top+f.bottom)}}},eS=(e,t,n)=>{let[r,i]=[e.horizontal,e.vertical].map(e=>e!=null&&e.x<=t&&t<=e.x+e.width&&e.y<=n&&n<=e.y+e.height);return{isOverEither:r||i,isOverHorizontal:r,isOverVertical:i}},tS=`medium`,nS=e=>e.penDetected?(0,K.jsxs)(`label`,{className:I(`ToolIcon ToolIcon__penMode`,`ToolIcon_size_${tS}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,K.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),(0,K.jsx)(`div`,{className:`ToolIcon__icon`,children:vs})]}):null,rS=e=>(0,K.jsx)(J,{className:I(`Shape`,{fillable:!1}),type:`radio`,icon:So,name:`editor-current-shape`,checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:F.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":F.H,"data-testid":`toolbar-hand`,onChange:()=>e.onChange?.()}),iS=({appState:e,elements:t,actionManager:n,setAppState:r,onLockToggle:i,onHandToolToggle:a,onPenModeToggle:o,renderTopRightUI:s,renderCustomStats:c,renderSidebars:l,device:u,renderWelcomeScreen:d,UIOptions:f,app:p})=>{let{WelcomeScreenCenterTunnel:m,MainMenuTunnel:h,DefaultSidebarTriggerTunnel:g}=Ab();return(0,K.jsxs)(K.Fragment,{children:[l(),!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&(0,K.jsxs)(Ax,{side:`top`,className:`App-top-bar`,children:[d&&(0,K.jsx)(m.Out,{}),(0,K.jsx)(Yx,{heading:`shapes`,children:t=>(0,K.jsx)(Ey.Col,{gap:4,align:`center`,children:(0,K.jsxs)(Ey.Row,{gap:1,className:`App-toolbar-container`,children:[(0,K.jsxs)(Hg,{padding:1,className:`App-toolbar App-toolbar--mobile`,children:[t,(0,K.jsx)(Ey.Row,{gap:1,children:(0,K.jsx)(Ib,{appState:e,activeTool:e.activeTool,UIOptions:f,app:p})})]}),s&&s(!0,e),(0,K.jsxs)(`div`,{className:`mobile-misc-tools-container`,children:[!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&(0,K.jsx)(g.Out,{}),(0,K.jsx)(nS,{checked:e.penMode,onChange:()=>o(null),title:q(`toolBar.penMode`),isMobile:!0,penDetected:e.penDetected}),(0,K.jsx)(Jx,{checked:e.activeTool.locked,onChange:i,title:q(`toolBar.lock`),isMobile:!0}),(0,K.jsx)(rS,{checked:Yr(e),onChange:()=>a(),title:q(`toolBar.hand`),isMobile:!0})]})]})})}),(0,K.jsx)(Gx,{appState:e,isMobile:!0,device:u,app:p})]}),(0,K.jsx)(`div`,{className:`App-bottom-bar`,style:{marginBottom:Zx+Xx*2,marginLeft:Zx+Xx*2,marginRight:Zx+Xx*2},children:(0,K.jsxs)(Hg,{padding:0,children:[e.openMenu===`shape`&&!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&Fl(e,t)?(0,K.jsx)(Yx,{className:`App-mobile-menu`,heading:`selectedShapeActions`,children:(0,K.jsx)(Fb,{appState:e,elementsMap:p.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:p})}):null,(0,K.jsxs)(`footer`,{className:`App-toolbar`,children:[e.viewModeEnabled||e.openDialog?.name===`elementLinkSelector`?(0,K.jsx)(`div`,{className:`App-toolbar-content`,children:(0,K.jsx)(h.Out,{})}):(0,K.jsxs)(`div`,{className:`App-toolbar-content`,children:[(0,K.jsx)(h.Out,{}),n.renderAction(`toggleEditMenu`),n.renderAction(e.multiElement?`finalize`:`duplicateSelection`),n.renderAction(`deleteSelectedElements`),(0,K.jsxs)(`div`,{children:[n.renderAction(`undo`),n.renderAction(`redo`)]})]}),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&(0,K.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Ht(t,e)}))},children:q(`buttons.scrollBackToContent`)})]})]})})]})},aS=e=>{let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(null);return(0,G.useLayoutEffect)(()=>{if(!e.spreadsheet)return;let n=Ar(e.chartType,e.spreadsheet,0,0);r(n);let i,a=t.current;return(async()=>(i=await fn(n,{exportBackground:!1,viewBackgroundColor:zc.white},null,{skipInliningFonts:!0}),i.querySelector(`.style-fonts`)?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),(0,K.jsx)(`button`,{type:`button`,className:`ChartPreview`,onClick:()=>{n&&e.onClick(e.chartType,n)},children:(0,K.jsx)(`div`,{ref:t})})},oS=({setAppState:e,appState:t,onClose:n})=>{let{onInsertElements:r}=gE(),i=G.useCallback(()=>{n&&n()},[n]),a=(t,n)=>{r(n),Y(`paste`,`chart`,t),e({currentChartType:t,pasteDialog:{shown:!1,data:null}})};return(0,K.jsx)(bb,{size:`small`,onCloseRequest:i,title:q(`labels.pasteCharts`),className:`PasteChartDialog`,autofocus:!1,children:(0,K.jsxs)(`div`,{className:`container`,children:[(0,K.jsx)(aS,{chartType:`bar`,spreadsheet:t.pasteDialog.data,selected:t.currentChartType===`bar`,onClick:a}),(0,K.jsx)(aS,{chartType:`line`,spreadsheet:t.pasteDialog.data,selected:t.currentChartType===`line`,onClick:a})]})})},sS=()=>(0,K.jsxs)(`div`,{className:`HelpDialog__header`,children:[(0,K.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://docs.excalidraw.com`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Os}),q(`helpDialog.documentation`)]}),(0,K.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://plus.excalidraw.com/blog`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Os}),q(`helpDialog.blog`)]}),(0,K.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://github.com/excalidraw/excalidraw/issues`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(`div`,{className:`HelpDialog__link-icon`,children:yn}),q(`helpDialog.github`)]}),(0,K.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://youtube.com/@excalidraw`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,K.jsx)(`div`,{className:`HelpDialog__link-icon`,children:lr}),`YouTube`]})]}),cS=e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{children:e.title}),(0,K.jsx)(`div`,{className:`HelpDialog__islands-container`,children:e.children})]}),lS=e=>(0,K.jsxs)(`div`,{className:`HelpDialog__island ${e.className}`,children:[(0,K.jsx)(`h4`,{className:`HelpDialog__island-title`,children:e.caption}),(0,K.jsx)(`div`,{className:`HelpDialog__island-content`,children:e.children})]});function*uS(e,t){let n=!0;for(let r of e)n||(yield t),n=!1,yield r}var dS=e=>e.replace(/\b[a-z]\b/,e=>e.toUpperCase()),Z=({label:e,shortcuts:t,isOr:n=!0})=>{let r=t.map(e=>(e.endsWith(`++`)?[...e.slice(0,-2).split(`+`),`+`]:e.split(`+`)).map(e=>(0,K.jsx)(fS,{children:dS(e)},e)));return(0,K.jsxs)(`div`,{className:`HelpDialog__shortcut`,children:[(0,K.jsx)(`div`,{children:e}),(0,K.jsx)(`div`,{className:`HelpDialog__key-container`,children:[...uS(r,n?q(`helpDialog.or`):null)]})]})},fS=e=>(0,K.jsx)(`kbd`,{className:`HelpDialog__key`,...e}),pS=({onClose:e})=>(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(bb,{onCloseRequest:G.useCallback(()=>{e&&e()},[e]),title:q(`helpDialog.title`),className:`HelpDialog`,children:[(0,K.jsx)(sS,{}),(0,K.jsxs)(cS,{title:q(`helpDialog.shortcuts`),children:[(0,K.jsxs)(lS,{className:`HelpDialog__island--tools`,caption:q(`helpDialog.tools`),children:[(0,K.jsx)(Z,{label:q(`toolBar.hand`),shortcuts:[F.H]}),(0,K.jsx)(Z,{label:q(`toolBar.selection`),shortcuts:[F.V,F[1]]}),(0,K.jsx)(Z,{label:q(`toolBar.rectangle`),shortcuts:[F.R,F[2]]}),(0,K.jsx)(Z,{label:q(`toolBar.diamond`),shortcuts:[F.D,F[3]]}),(0,K.jsx)(Z,{label:q(`toolBar.ellipse`),shortcuts:[F.O,F[4]]}),(0,K.jsx)(Z,{label:q(`toolBar.arrow`),shortcuts:[F.A,F[5]]}),(0,K.jsx)(Z,{label:q(`toolBar.line`),shortcuts:[F.L,F[6]]}),(0,K.jsx)(Z,{label:q(`toolBar.freedraw`),shortcuts:[F.P,F[7]]}),(0,K.jsx)(Z,{label:q(`toolBar.text`),shortcuts:[F.T,F[8]]}),(0,K.jsx)(Z,{label:q(`toolBar.image`),shortcuts:[F[9]]}),(0,K.jsx)(Z,{label:q(`toolBar.eraser`),shortcuts:[F.E,F[0]]}),(0,K.jsx)(Z,{label:q(`toolBar.frame`),shortcuts:[F.F]}),(0,K.jsx)(Z,{label:q(`toolBar.laser`),shortcuts:[F.K]}),(0,K.jsx)(Z,{label:q(`labels.eyeDropper`),shortcuts:[F.I,`Shift+S`,`Shift+G`]}),(0,K.jsx)(Z,{label:q(`helpDialog.editLineArrowPoints`),shortcuts:[B(`CtrlOrCmd+Enter`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.editText`),shortcuts:[B(`Enter`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.textNewLine`),shortcuts:[B(`Enter`),B(`Shift+Enter`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.textFinish`),shortcuts:[B(`Esc`),B(`CtrlOrCmd+Enter`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.curvedArrow`),shortcuts:[`A`,q(`helpDialog.click`),q(`helpDialog.click`),q(`helpDialog.click`)],isOr:!1}),(0,K.jsx)(Z,{label:q(`helpDialog.curvedLine`),shortcuts:[`L`,q(`helpDialog.click`),q(`helpDialog.click`),q(`helpDialog.click`)],isOr:!1}),(0,K.jsx)(Z,{label:q(`helpDialog.cropStart`),shortcuts:[q(`helpDialog.doubleClick`),B(`Enter`)],isOr:!0}),(0,K.jsx)(Z,{label:q(`helpDialog.cropFinish`),shortcuts:[B(`Enter`),B(`Escape`)],isOr:!0}),(0,K.jsx)(Z,{label:q(`toolBar.lock`),shortcuts:[F.Q]}),(0,K.jsx)(Z,{label:q(`helpDialog.preventBinding`),shortcuts:[B(`CtrlOrCmd`)]}),(0,K.jsx)(Z,{label:q(`toolBar.link`),shortcuts:[B(`CtrlOrCmd+K`)]})]}),(0,K.jsxs)(lS,{className:`HelpDialog__island--view`,caption:q(`helpDialog.view`),children:[(0,K.jsx)(Z,{label:q(`buttons.zoomIn`),shortcuts:[B(`CtrlOrCmd++`)]}),(0,K.jsx)(Z,{label:q(`buttons.zoomOut`),shortcuts:[B(`CtrlOrCmd+-`)]}),(0,K.jsx)(Z,{label:q(`buttons.resetZoom`),shortcuts:[B(`CtrlOrCmd+0`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.zoomToFit`),shortcuts:[`Shift+1`]}),(0,K.jsx)(Z,{label:q(`helpDialog.zoomToSelection`),shortcuts:[`Shift+2`]}),(0,K.jsx)(Z,{label:q(`helpDialog.movePageUpDown`),shortcuts:[`PgUp/PgDn`]}),(0,K.jsx)(Z,{label:q(`helpDialog.movePageLeftRight`),shortcuts:[`Shift+PgUp/PgDn`]}),(0,K.jsx)(Z,{label:q(`buttons.zenMode`),shortcuts:[B(`Alt+Z`)]}),(0,K.jsx)(Z,{label:q(`buttons.objectsSnapMode`),shortcuts:[B(`Alt+S`)]}),(0,K.jsx)(Z,{label:q(`labels.toggleGrid`),shortcuts:[B(`CtrlOrCmd+'`)]}),(0,K.jsx)(Z,{label:q(`labels.viewMode`),shortcuts:[B(`Alt+R`)]}),(0,K.jsx)(Z,{label:q(`labels.toggleTheme`),shortcuts:[B(`Alt+Shift+D`)]}),(0,K.jsx)(Z,{label:q(`stats.fullTitle`),shortcuts:[B(`Alt+/`)]}),(0,K.jsx)(Z,{label:q(`search.title`),shortcuts:[wb(`searchMenu`)]}),(0,K.jsx)(Z,{label:q(`commandPalette.title`),shortcuts:Ei?[wb(`commandPalette`)]:[wb(`commandPalette`),wb(`commandPalette`,1)]})]}),(0,K.jsxs)(lS,{className:`HelpDialog__island--editor`,caption:q(`helpDialog.editor`),children:[(0,K.jsx)(Z,{label:q(`helpDialog.createFlowchart`),shortcuts:[B(`CtrlOrCmd+Arrow Key`)],isOr:!0}),(0,K.jsx)(Z,{label:q(`helpDialog.navigateFlowchart`),shortcuts:[B(`Alt+Arrow Key`)],isOr:!0}),(0,K.jsx)(Z,{label:q(`labels.moveCanvas`),shortcuts:[B(`Space+${q(`helpDialog.drag`)}`),B(`Wheel+${q(`helpDialog.drag`)}`)],isOr:!0}),(0,K.jsx)(Z,{label:q(`buttons.clearReset`),shortcuts:[B(`CtrlOrCmd+Delete`)]}),(0,K.jsx)(Z,{label:q(`labels.delete`),shortcuts:[B(`Delete`)]}),(0,K.jsx)(Z,{label:q(`labels.cut`),shortcuts:[B(`CtrlOrCmd+X`)]}),(0,K.jsx)(Z,{label:q(`labels.copy`),shortcuts:[B(`CtrlOrCmd+C`)]}),(0,K.jsx)(Z,{label:q(`labels.paste`),shortcuts:[B(`CtrlOrCmd+V`)]}),(0,K.jsx)(Z,{label:q(`labels.pasteAsPlaintext`),shortcuts:[B(`CtrlOrCmd+Shift+V`)]}),(0,K.jsx)(Z,{label:q(`labels.selectAll`),shortcuts:[B(`CtrlOrCmd+A`)]}),(0,K.jsx)(Z,{label:q(`labels.multiSelect`),shortcuts:[B(`Shift+${q(`helpDialog.click`)}`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.deepSelect`),shortcuts:[B(`CtrlOrCmd+${q(`helpDialog.click`)}`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.deepBoxSelect`),shortcuts:[B(`CtrlOrCmd+${q(`helpDialog.drag`)}`)]}),(Kt||Ei)&&(0,K.jsx)(Z,{label:q(`labels.copyAsPng`),shortcuts:[B(`Shift+Alt+C`)]}),(0,K.jsx)(Z,{label:q(`labels.copyStyles`),shortcuts:[B(`CtrlOrCmd+Alt+C`)]}),(0,K.jsx)(Z,{label:q(`labels.pasteStyles`),shortcuts:[B(`CtrlOrCmd+Alt+V`)]}),(0,K.jsx)(Z,{label:q(`labels.sendToBack`),shortcuts:[B(wt?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)]}),(0,K.jsx)(Z,{label:q(`labels.bringToFront`),shortcuts:[B(wt?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)]}),(0,K.jsx)(Z,{label:q(`labels.sendBackward`),shortcuts:[B(`CtrlOrCmd+[`)]}),(0,K.jsx)(Z,{label:q(`labels.bringForward`),shortcuts:[B(`CtrlOrCmd+]`)]}),(0,K.jsx)(Z,{label:q(`labels.alignTop`),shortcuts:[B(`CtrlOrCmd+Shift+Up`)]}),(0,K.jsx)(Z,{label:q(`labels.alignBottom`),shortcuts:[B(`CtrlOrCmd+Shift+Down`)]}),(0,K.jsx)(Z,{label:q(`labels.alignLeft`),shortcuts:[B(`CtrlOrCmd+Shift+Left`)]}),(0,K.jsx)(Z,{label:q(`labels.alignRight`),shortcuts:[B(`CtrlOrCmd+Shift+Right`)]}),(0,K.jsx)(Z,{label:q(`labels.duplicateSelection`),shortcuts:[B(`CtrlOrCmd+D`),B(`Alt+${q(`helpDialog.drag`)}`)]}),(0,K.jsx)(Z,{label:q(`helpDialog.toggleElementLock`),shortcuts:[B(`CtrlOrCmd+Shift+L`)]}),(0,K.jsx)(Z,{label:q(`buttons.undo`),shortcuts:[B(`CtrlOrCmd+Z`)]}),(0,K.jsx)(Z,{label:q(`buttons.redo`),shortcuts:Ds?[B(`CtrlOrCmd+Y`),B(`CtrlOrCmd+Shift+Z`)]:[B(`CtrlOrCmd+Shift+Z`)]}),(0,K.jsx)(Z,{label:q(`labels.group`),shortcuts:[B(`CtrlOrCmd+G`)]}),(0,K.jsx)(Z,{label:q(`labels.ungroup`),shortcuts:[B(`CtrlOrCmd+Shift+G`)]}),(0,K.jsx)(Z,{label:q(`labels.flipHorizontal`),shortcuts:[B(`Shift+H`)]}),(0,K.jsx)(Z,{label:q(`labels.flipVertical`),shortcuts:[B(`Shift+V`)]}),(0,K.jsx)(Z,{label:q(`labels.showStroke`),shortcuts:[B(`S`)]}),(0,K.jsx)(Z,{label:q(`labels.showBackground`),shortcuts:[B(`G`)]}),(0,K.jsx)(Z,{label:q(`labels.showFonts`),shortcuts:[B(`Shift+F`)]}),(0,K.jsx)(Z,{label:q(`labels.decreaseFontSize`),shortcuts:[B(`CtrlOrCmd+Shift+<`)]}),(0,K.jsx)(Z,{label:q(`labels.increaseFontSize`),shortcuts:[B(`CtrlOrCmd+Shift+>`)]})]})]})]})}),mS=4,hS=8,gS=({shouldWrap:e,children:t,username:n})=>e?(0,K.jsx)(M_,{label:n||`Unknown user`,children:t}):(0,K.jsx)(K.Fragment,{children:t}),_S=({actionManager:e,collaborator:t,socketId:n,withName:r=!1,shouldWrapWithTooltip:i=!1,isBeingFollowed:a})=>{let o={socketId:n,collaborator:t,withName:r,isBeingFollowed:a},s=e.renderAction(`goToCollaborator`,o);return(0,K.jsx)(gS,{username:t.username,shouldWrap:i,children:s},n)},vS=[`avatarUrl`,`id`,`socketId`,`username`,`isInCall`,`isSpeaking`,`isMuted`],yS=G.memo(({className:e,mobile:t,collaborators:n,userToFollow:r})=>{let i=CE(),a=new Map;n.forEach((e,t)=>{let n=e.id||t;a.set(n,{...e,socketId:t})});let o=Array.from(a.values()).filter(e=>e.username?.trim()),[s,c]=G.useState(``),l=o.filter(e=>e.username?.toLowerCase().includes(s)),u=G.useRef(null);(0,G.useLayoutEffect)(()=>{if(u.current){let e=e=>{let t=Math.max(1,Math.min(8,Math.floor(e/38)));f(t)};if(e(u.current.clientWidth),!qs)return;let t=new ResizeObserver(t=>{for(let n of t){let{width:t}=n.contentRect;e(t)}});return t.observe(u.current),()=>{t.disconnect()}}},[]);let[d,f]=G.useState(mS),p=o.slice(0,d-1).map(e=>_S({actionManager:i,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}));return t?(0,K.jsx)(`div`,{className:I(`UserList UserList_mobile`,e),children:o.map(e=>_S({actionManager:i,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}))}):(0,K.jsx)(`div`,{className:`UserList__wrapper`,ref:u,children:(0,K.jsxs)(`div`,{className:I(`UserList`,e),style:{"--max-avatars":d},children:[p,o.length>d-1&&(0,K.jsxs)(Cp,{children:[(0,K.jsxs)(wp,{className:`UserList__more`,children:[`+`,o.length-d+1]}),(0,K.jsx)(Ep,{style:{zIndex:2,width:`15rem`,textAlign:`left`},align:`end`,sideOffset:10,children:(0,K.jsxs)(Hg,{padding:2,children:[o.length>=hS&&(0,K.jsx)(e_,{placeholder:q(`quickSearch.placeholder`),onChange:c}),(0,K.jsx)(t_,{className:`dropdown-menu UserList__collaborators`,placeholder:q(`userList.empty`),children:l.length>0?[(0,K.jsx)(`div`,{className:`hint`,children:q(`userList.hint.text`)}),l.map(e=>_S({actionManager:i,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===r}))]:[]}),(0,K.jsx)(Dp,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let n=t.collaborators.keys();for(let[r,i]of e.collaborators){let e=t.collaborators.get(r);if(!e||r!==n.next().value||!Rt(i,e,vS))return!1}return!0}),bS=({children:e,color:t})=>(0,K.jsx)(`div`,{className:`Card`,style:{"--card-color":t===`primary`?`var(--color-primary)`:zc[t][7],"--card-color-darker":t===`primary`?`var(--color-primary-darker)`:zc[t][8],"--card-color-darkest":t===`primary`?`var(--color-primary-darkest)`:zc[t][9]},children:e}),xS=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:a,canvas:o,onCloseRequest:s})=>{let{onExportToBackend:c}=a;return(0,K.jsx)(`div`,{className:`ExportDialog ExportDialog--json`,children:(0,K.jsxs)(`div`,{className:`ExportDialog-cards`,children:[a.saveFileToDisk&&(0,K.jsxs)(bS,{color:`lime`,children:[(0,K.jsx)(`div`,{className:`Card-icon`,children:On}),(0,K.jsx)(`h2`,{children:q(`exportDialog.disk_title`)}),(0,K.jsxs)(`div`,{className:`Card-details`,children:[q(`exportDialog.disk_details`),!Bt&&i.renderAction(`changeProjectName`)]}),(0,K.jsx)(J,{className:`Card-button`,type:`button`,title:q(`exportDialog.disk_button`),"aria-label":q(`exportDialog.disk_button`),showAriaLabel:!0,onClick:()=>{i.executeAction(tv,`ui`)}})]}),c&&(0,K.jsxs)(bS,{color:`pink`,children:[(0,K.jsx)(`div`,{className:`Card-icon`,children:ps}),(0,K.jsx)(`h2`,{children:q(`exportDialog.link_title`)}),(0,K.jsx)(`div`,{className:`Card-details`,children:q(`exportDialog.link_details`)}),(0,K.jsx)(J,{className:`Card-button`,type:`button`,title:q(`exportDialog.link_button`),"aria-label":q(`exportDialog.link_button`),showAriaLabel:!0,onClick:async()=>{try{Y(`export`,`link`,`ui (${Bs()})`),await c(e,t,r),s()}catch(e){n({errorMessage:e.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,t,r,o)]})})},SS=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:a,setAppState:o})=>{let s=G.useCallback(()=>{o({openDialog:null})},[o]);return(0,K.jsx)(K.Fragment,{children:t.openDialog?.name===`jsonExport`&&(0,K.jsx)(bb,{onCloseRequest:s,title:q(`buttons.export`),children:(0,K.jsx)(xS,{elements:e,appState:t,setAppState:o,files:n,actionManager:r,onCloseRequest:s,exportOpts:i,canvas:a})})})},CS=e=>(0,K.jsx)(`button`,{className:`help-icon`,onClick:e.onClick,type:`button`,title:`${q(`helpDialog.title`)} \u2014 ?`,"aria-label":q(`helpDialog.title`),children:En}),wS=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:i,WelcomeScreenHelpHintTunnel:a}=Ab(),o=vE(),s=!e.viewModeEnabled&&e.multiElement&&o.isTouchScreen;return(0,K.jsxs)(`footer`,{role:`contentinfo`,className:`layer-ui__wrapper__footer App-menu App-menu_bottom`,children:[(0,K.jsx)(`div`,{className:I(`layer-ui__wrapper__footer-left zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:(0,K.jsx)(Ey.Col,{gap:2,children:(0,K.jsxs)(Yx,{heading:`canvasActions`,children:[(0,K.jsx)(Lb,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&(0,K.jsx)(Rb,{renderAction:t.renderAction,className:I(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),s&&(0,K.jsx)(Bb,{renderAction:t.renderAction,className:I(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),(0,K.jsx)(i.Out,{}),(0,K.jsx)(`div`,{className:I(`layer-ui__wrapper__footer-right zen-mode-transition`,{"transition-right":e.zenModeEnabled}),children:(0,K.jsxs)(`div`,{style:{position:`relative`},children:[r&&(0,K.jsx)(a.Out,{}),(0,K.jsx)(CS,{onClick:()=>t.executeAction(sv)})]})}),(0,K.jsx)(zb,{actionManager:t,showExitZenModeBtn:n})]})},TS=wS;wS.displayName=`Footer`;var ES=G.createContext({}),DS=({children:e,className:t})=>{let n=vE(),r=(0,G.useContext)(ES),i=!!(n.editor.canFitSidebar&&r.shouldRenderDockButton);return(0,K.jsxs)(`div`,{className:I(`sidebar__header`,t),"data-testid":`sidebar-header`,children:[e,(0,K.jsxs)(`div`,{className:`sidebar__header__buttons`,children:[i&&(0,K.jsx)(M_,{label:q(`labels.sidebarLock`),children:(0,K.jsx)(xb,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:`sidebar__dock`,"data-testid":`sidebar-dock`,"aria-label":q(`labels.sidebarLock`),children:Nc})}),(0,K.jsx)(xb,{"data-testid":`sidebar-close`,className:`sidebar__close`,onSelect:r.onCloseRequest,"aria-label":q(`buttons.close`),children:Gc})]})]})};DS.displayName=`SidebarHeader`;var OS=({name:e,tab:t,icon:n,title:r,children:i,onToggle:a,className:o,style:s})=>{let c=SE();return(0,K.jsxs)(`label`,{title:r,className:`sidebar-trigger__label-element`,children:[(0,K.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,onChange:n=>{document.querySelector(`.layer-ui__wrapper`)?.classList.remove(`animate`);let r=n.target.checked;c({openSidebar:r?{name:e,tab:t}:null}),a?.(r)},checked:Fg().openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":`0`}),(0,K.jsxs)(`div`,{className:I(`sidebar-trigger`,o),style:s,children:[n&&(0,K.jsx)(`div`,{children:n}),i&&(0,K.jsx)(`div`,{className:`sidebar-trigger__label`,children:i})]})]})};OS.displayName=`SidebarTrigger`;var kS=({children:e,...t})=>(0,K.jsx)(Qm,{className:`sidebar-triggers`,...t,children:e});kS.displayName=`SidebarTabTriggers`;var AS=({children:e,tab:t,onSelect:n,...r})=>(0,K.jsx)($m,{value:t,asChild:!0,onSelect:n,children:(0,K.jsx)(`button`,{type:`button`,className:`excalidraw-button sidebar-tab-trigger`,...r,children:e})});AS.displayName=`SidebarTabTrigger`;var jS=({children:e,...t})=>{let n=Fg(),r=SE();if(!n.openSidebar)return null;let{name:i}=n.openSidebar;return(0,K.jsx)(Zm,{className:`sidebar-tabs-root`,value:n.openSidebar.tab,onValueChange:e=>r(t=>({...t,openSidebar:{...t.openSidebar,name:i,tab:e}})),...t,children:e})};jS.displayName=`SidebarTabs`;var MS=({tab:e,children:t,...n})=>(0,K.jsx)(eh,{...n,value:e,"data-testid":e,children:t});MS.displayName=`SidebarTab`;var NS=ku(!1),PS=(0,G.forwardRef)(({name:e,children:t,onDock:n,docked:r,className:i,...a},o)=>{C.DEV&&n&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=SE(),c=bh(NS);(0,G.useLayoutEffect)(()=>(c(!!r),()=>{c(!1)}),[c,r]);let l=(0,G.useRef)({});l.current.onCloseRequest=()=>{s({openSidebar:null})},l.current.onDock=e=>n?.(e),l.current=nc(l.current,{docked:r,shouldRenderDockButton:!!n&&r!=null});let u=(0,G.useRef)(null);(0,G.useImperativeHandle)(o,()=>u.current);let d=vE(),f=(0,G.useCallback)(()=>{document.querySelector(`.Dialog`)||s({openSidebar:null})},[s]);return Lg(u,(0,G.useCallback)(e=>{e.target.closest(`.sidebar-trigger`)||(!r||!d.editor.canFitSidebar)&&f()},[f,r,d.editor.canFitSidebar])),(0,G.useEffect)(()=>{let e=e=>{e.key===F.ESCAPE&&(!r||!d.editor.canFitSidebar)&&f()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[f,r,d.editor.canFitSidebar]),(0,K.jsx)(Hg,{...a,className:I(`sidebar`,{"sidebar--docked":r},i),ref:u,children:(0,K.jsx)(ES.Provider,{value:l.current,children:t})})});PS.displayName=`SidebarInner`;var FS=Object.assign((0,G.forwardRef)((e,t)=>{let n=Fg(),{onStateChange:r}=e,i=(0,G.useRef)(n.openSidebar);(0,G.useEffect)(()=>{(!n.openSidebar&&i?.current?.name===e.name||n.openSidebar?.name===e.name&&i?.current?.name!==e.name||i.current?.name===e.name)&&n.openSidebar!==i.current&&r?.(n.openSidebar?.name===e.name?n.openSidebar:null),i.current=n.openSidebar},[n.openSidebar,r,e.name]);let[a,o]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>(o(!0),()=>o(!1)),[]),a&&n.openSidebar?.name===e.name?(0,G.createElement)(PS,{...e,ref:t,key:e.name}):null}),{Header:DS,TabTriggers:kS,TabTrigger:AS,Tabs:jS,Tab:MS,Trigger:OS});FS.displayName=`Sidebar`;var IS={};ae(IS,{ChangeCanvasBackground:()=>YS,ClearCanvas:()=>qS,CommandPalette:()=>WS,Export:()=>XS,Help:()=>KS,LiveCollaborationTrigger:()=>QS,LoadScene:()=>VS,SaveAsImage:()=>US,SaveToActiveFile:()=>HS,SearchMenu:()=>GS,Socials:()=>ZS,ToggleTheme:()=>JS});var LS=ku({active:!1});async function RS({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{wh.set(LS,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}var zS=({value:e,shortcut:t,onChange:n,choices:r,children:i,name:a})=>{let o=vE();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`dropdown-menu-item-base dropdown-menu-item-bare`,children:[(0,K.jsx)(`label`,{className:`dropdown-menu-item__text`,htmlFor:a,children:i}),(0,K.jsx)(bx,{name:a,value:e,onChange:n,choices:r})]}),t&&!o.editor.isMobile&&(0,K.jsx)(`div`,{className:`dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned`,children:t})]})};zS.displayName=`DropdownMenuItemContentRadio`;var BS=zS,VS=()=>{let{t:e}=Ih(),t=CE(),n=bE();return t.isActionEnabled(nv)?(0,K.jsx)(d_,{icon:su,onSelect:async()=>{(!n.length||await RS({title:e(`overwriteConfirm.modal.loadFromFile.title`),actionLabel:e(`overwriteConfirm.modal.loadFromFile.button`),color:`warning`,description:(0,K.jsx)(Py,{i18nKey:`overwriteConfirm.modal.loadFromFile.description`,bold:e=>(0,K.jsx)(`strong`,{children:e}),br:()=>(0,K.jsx)(`br`,{})})}))&&t.executeAction(nv)},"data-testid":`load-button`,shortcut:wb(`loadScene`),"aria-label":e(`buttons.load`),children:e(`buttons.load`)}):null};VS.displayName=`LoadScene`;var HS=()=>{let{t:e}=Ih(),t=CE();return t.isActionEnabled(ev)?(0,K.jsx)(d_,{shortcut:wb(`saveScene`),"data-testid":`save-button`,onSelect:()=>t.executeAction(ev),icon:Rc,"aria-label":`${e(`buttons.save`)}`,children:`${e(`buttons.save`)}`}):null};HS.displayName=`SaveToActiveFile`;var US=()=>{let e=SE(),{t}=Ih();return(0,K.jsx)(d_,{icon:js,"data-testid":`image-export-button`,onSelect:()=>e({openDialog:{name:`imageExport`}}),shortcut:wb(`imageExport`),"aria-label":t(`buttons.exportImage`),children:t(`buttons.exportImage`)})};US.displayName=`SaveAsImage`;var WS=e=>{let t=SE(),{t:n}=Ih();return(0,K.jsx)(d_,{icon:xo,"data-testid":`command-palette-button`,onSelect:()=>{Y(`command_palette`,`open`,`menu`),t({openDialog:{name:`commandPalette`}})},shortcut:wb(`commandPalette`),"aria-label":n(`commandPalette.title`),className:e?.className,children:n(`commandPalette.title`)})};WS.displayName=`CommandPalette`;var GS=e=>{let{t}=Ih(),n=CE();return(0,K.jsx)(d_,{icon:$a,"data-testid":`search-menu-button`,onSelect:()=>{n.executeAction(nx)},shortcut:wb(`searchMenu`),"aria-label":t(`search.title`),className:e?.className,children:t(`search.title`)})};GS.displayName=`SearchMenu`;var KS=()=>{let{t:e}=Ih(),t=CE();return(0,K.jsx)(d_,{"data-testid":`help-menu-item`,icon:En,onSelect:()=>t.executeAction(sv),shortcut:`?`,"aria-label":e(`helpDialog.title`),children:e(`helpDialog.title`)})};KS.displayName=`Help`;var qS=()=>{let{t:e}=Ih(),t=bh(Hb);return CE().isActionEnabled(N_)?(0,K.jsx)(d_,{icon:cu,onSelect:()=>t(`clearCanvas`),"data-testid":`clear-canvas-button`,"aria-label":e(`buttons.clearReset`),children:e(`buttons.clearReset`)}):null};qS.displayName=`ClearCanvas`;var JS=e=>{let{t}=Ih(),n=Fg(),r=CE(),i=wb(`toggleTheme`);return r.isActionEnabled(B_)?e?.allowSystemTheme?(0,K.jsx)(BS,{name:`theme`,value:e.theme,onChange:t=>e.onSelect(t),choices:[{value:j.LIGHT,label:Ca,ariaLabel:`${t(`buttons.lightMode`)} - ${i}`},{value:j.DARK,label:os,ariaLabel:`${t(`buttons.darkMode`)} - ${i}`},{value:`system`,label:Cu,ariaLabel:t(`buttons.systemMode`)}],children:t(`labels.theme`)}):(0,K.jsx)(d_,{onSelect:t=>{if(t.preventDefault(),e?.onSelect)e.onSelect(n.theme===j.DARK?j.LIGHT:j.DARK);else return r.executeAction(B_)},icon:n.theme===j.DARK?Ca:os,"data-testid":`toggle-dark-mode`,shortcut:i,"aria-label":n.theme===j.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`),children:n.theme===j.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`)}):null};JS.displayName=`ToggleTheme`;var YS=()=>{let{t:e}=Ih(),t=Fg(),n=CE(),r=_E();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,K.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,K.jsx)(`div`,{"data-testid":`canvas-background-label`,style:{fontSize:`.75rem`,marginBottom:`.5rem`},children:e(`labels.canvasBackground`)}),(0,K.jsx)(`div`,{style:{padding:`0 0.625rem`},children:n.renderAction(`changeViewBackgroundColor`)})]})};YS.displayName=`ChangeCanvasBackground`;var XS=()=>{let{t:e}=Ih(),t=SE();return(0,K.jsx)(d_,{icon:As,onSelect:()=>{t({openDialog:{name:`jsonExport`}})},"data-testid":`json-export-button`,"aria-label":e(`buttons.export`),children:e(`buttons.export`)})};XS.displayName=`Export`;var ZS=()=>{let{t:e}=Ih();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Jy,{icon:yn,href:`https://github.com/excalidraw/excalidraw`,"aria-label":`GitHub`,children:`GitHub`}),(0,K.jsx)(Jy,{icon:nr,href:`https://x.com/excalidraw`,"aria-label":`X`,children:e(`labels.followUs`)}),(0,K.jsx)(Jy,{icon:Mt,href:`https://discord.gg/UexuTaE`,"aria-label":`Discord`,children:e(`labels.discordChat`)})]})};ZS.displayName=`Socials`;var QS=({onSelect:e,isCollaborating:t})=>{let{t:n}=Ih();return(0,K.jsx)(d_,{"data-testid":`collab-button`,icon:ya,className:I({"active-collab":t}),onSelect:e,children:n(`labels.liveCollaboration`)})};QS.displayName=`LiveCollaborationTrigger`;var $S=(e,t)=>{let n=ku(0),r=e=>{let{tunnelsJotai:{useAtom:r}}=Ab(),[,i]=r(n),a=(0,G.useRef)({preferHost:!1,counter:0});return(0,G.useLayoutEffect)(()=>{let e=a.current;return i(t=>{let n=t+1;return e.counter=n,n}),()=>{i(t=>{let n=t-1;return e.counter=n,n||(e.preferHost=!1),n})}},[i]),e.__fallback||(a.current.preferHost=!0),!a.current.counter&&e.__fallback&&a.current.preferHost||a.current.counter>1&&e.__fallback?null:(0,K.jsx)(t,{...e})};return r.displayName=e,r},eC=Object.assign($S(`MainMenu`,({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=Ab(),r=vE(),i=Fg(),a=SE(),o=r.editor.isMobile?void 0:()=>a({openMenu:null});return(0,K.jsx)(n.In,{children:(0,K.jsxs)(X,{open:i.openMenu===`canvas`,children:[(0,K.jsx)(X.Trigger,{onToggle:()=>{a({openMenu:i.openMenu===`canvas`?null:`canvas`})},"data-testid":`main-menu-trigger`,className:`main-menu-trigger`,children:Xc}),(0,K.jsxs)(X.Content,{onClickOutside:o,onSelect:Wo(t,()=>{a({openMenu:null})}),children:[e,r.editor.isMobile&&i.collaborators.size>0&&(0,K.jsxs)(`fieldset`,{className:`UserList-Wrapper`,children:[(0,K.jsx)(`legend`,{children:q(`labels.collaborators`)}),(0,K.jsx)(yS,{mobile:!0,collaborators:i.collaborators,userToFollow:i.userToFollow?.socketId||null})]})]})]})})}),{Trigger:X.Trigger,Item:X.Item,ItemLink:X.ItemLink,ItemCustom:X.ItemCustom,Group:X.Group,Separator:X.Separator,DefaultItems:IS}),tC=({title:e,children:t,actionLabel:n,onClick:r})=>(0,K.jsxs)(`div`,{className:`OverwriteConfirm__Actions__Action`,children:[(0,K.jsx)(`h4`,{children:e}),(0,K.jsx)(`div`,{className:`OverwriteConfirm__Actions__Action__content`,children:t}),(0,K.jsx)(Sx,{variant:`outlined`,color:`muted`,label:n,size:`large`,fullWidth:!0,onClick:r})]}),nC=Object.assign(({children:e})=>(0,K.jsx)(`div`,{className:`OverwriteConfirm__Actions`,children:e}),{ExportToImage:()=>{let{t:e}=Ih(),t=CE(),n=SE();return(0,K.jsx)(tC,{title:e(`overwriteConfirm.action.exportToImage.title`),actionLabel:e(`overwriteConfirm.action.exportToImage.button`),onClick:()=>{t.executeAction($_,`ui`,!0),n({openDialog:{name:`imageExport`}})},children:e(`overwriteConfirm.action.exportToImage.description`)})},SaveToDisk:()=>{let{t:e}=Ih(),t=CE();return(0,K.jsx)(tC,{title:e(`overwriteConfirm.action.saveToDisk.title`),actionLabel:e(`overwriteConfirm.action.saveToDisk.button`),onClick:()=>{t.executeAction(tv,`ui`)},children:e(`overwriteConfirm.action.saveToDisk.description`)})}}),rC=Object.assign($S(`OverwriteConfirmDialog`,({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=Ab(),[n,r]=yh(LS);return n.active?(0,K.jsx)(t.In,{children:(0,K.jsx)(bb,{onCloseRequest:()=>{n.onClose(),r(e=>({...e,active:!1}))},title:!1,size:916,children:(0,K.jsxs)(`div`,{className:`OverwriteConfirm`,children:[(0,K.jsx)(`h3`,{children:n.title}),(0,K.jsxs)(`div`,{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,K.jsx)(`div`,{className:`OverwriteConfirm__Description__icon`,children:Aa}),(0,K.jsx)(`div`,{children:n.description}),(0,K.jsx)(`div`,{className:`OverwriteConfirm__Description__spacer`}),(0,K.jsx)(Sx,{color:n.color,size:`large`,label:n.actionLabel,onClick:()=>{n.onConfirm(),r(e=>({...e,active:!1}))}})]}),(0,K.jsx)(nC,{children:e})]})})}):null}),{Actions:nC,Action:tC}),iC=ku(``),aC=ku(null),oC=350,sC=()=>{let e=gE(),t=SE(),n=(0,G.useRef)(null),[r,i]=yh(iC),a=r.trim(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)({nonce:null,items:[]}),u=(0,G.useRef)(null),d=(0,G.useRef)(void 0),[f,p]=yh(aC);(0,G.useEffect)(()=>{o||(a!==u.current||e.scene.getSceneNonce()!==d.current)&&(u.current=null,mC(a,e,(n,r)=>{l({nonce:vu(),items:n}),u.current=a,d.current=e.scene.getSceneNonce(),t({searchMatches:n.map(e=>({id:e.textElement.id,focus:!1,matchedLines:e.matchedLines}))})}))},[o,a,e.scene.getNonDeletedElementsMap(),e,t,p,d]);let m=()=>{c.items.length>0&&p(e=>e===null?0:(e+1)%c.items.length)},h=()=>{c.items.length>0&&p(e=>e===null?0:e-1<0?c.items.length-1:e-1)};(0,G.useEffect)(()=>{t(e=>({searchMatches:e.searchMatches.map((e,t)=>t===f?{...e,focus:!0}:{...e,focus:!1})}))},[f,t]),(0,G.useEffect)(()=>{if(c.items.length>0&&f!==null){let t=c.items[f];if(t){let n=e.state.zoom.value,r=Wc({text:t.searchQuery,x:t.textElement.x+(t.matchedLines[0]?.offsetX??0),y:t.textElement.y+(t.matchedLines[0]?.offsetY??0),width:t.matchedLines[0]?.width,height:t.matchedLines[0]?.height,fontSize:t.textElement.fontSize,fontFamily:t.textElement.fontFamily}),i=t.textElement.fontSize,a=i*n<14;if(!Se([r],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||a){let t;t=a?i>=14?{fitToContent:!0}:{fitToViewport:!0,maxZoom:Po(14/i,1)}:{fitToContent:!0},e.scrollToContent(r,{animate:!0,duration:300,...t,canvasOffsets:e.getEditorUIOffsets()})}}}},[f,c,e]),(0,G.useEffect)(()=>()=>{p(null),u.current=null,d.current=void 0,t({searchMatches:[]}),s(!1)},[t,p]);let g=Rg({goToNextItem:m,goToPreviousItem:h,searchMatches:c});(0,G.useEffect)(()=>ec(window,`keydown`,r=>{if(r.key===F.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){r.preventDefault(),r.stopPropagation(),t({openSidebar:null});return}r[F.CTRL_OR_CMD]&&r.key===F.F&&(r.preventDefault(),r.stopPropagation(),n.current?.matches(`:focus`)?t({openSidebar:null}):(e.state.openDialog&&t({openDialog:null}),n.current?.focus(),n.current?.select())),r.target instanceof HTMLElement&&r.target.closest(`.layer-ui__search`)&&g.searchMatches.items.length&&(r.key===F.ENTER&&(r.stopPropagation(),g.goToNextItem()),r.key===F.ARROW_UP?(r.stopPropagation(),g.goToPreviousItem()):r.key===F.ARROW_DOWN&&(r.stopPropagation(),g.goToNextItem()))},{capture:!0,passive:!1}),[t,g,e]);let _=`${c.items.length} ${c.items.length===1?q(`search.singleResult`):q(`search.multipleResults`)}`;return(0,K.jsxs)(`div`,{className:`layer-ui__search`,children:[(0,K.jsx)(`div`,{className:`layer-ui__search-header`,children:(0,K.jsx)(Sb,{className:hc.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:n,placeholder:q(`search.placeholder`),icon:$a,onChange:n=>{i(n),s(!0);let r=n.trim();mC(r,e,(n,i)=>{l({nonce:vu(),items:n}),p(i),u.current=r,d.current=e.scene.getSceneNonce(),t({searchMatches:n.map(e=>({id:e.textElement.id,focus:!1,matchedLines:e.matchedLines}))}),s(!1)})},selectOnRender:!0})}),(0,K.jsxs)(`div`,{className:`layer-ui__search-count`,children:[c.items.length>0&&(0,K.jsxs)(K.Fragment,{children:[f!==null&&f>-1?(0,K.jsxs)(`div`,{children:[f+1,` / `,_]}):(0,K.jsx)(`div`,{children:_}),(0,K.jsxs)(`div`,{className:`result-nav`,children:[(0,K.jsx)(xb,{onSelect:()=>{m()},className:`result-nav-btn`,children:$l}),(0,K.jsx)(xb,{onSelect:()=>{h()},className:`result-nav-btn`,children:tu})]})]}),c.items.length===0&&a&&u.current&&(0,K.jsx)(`div`,{style:{margin:`1rem auto`},children:q(`search.noMatch`)})]}),(0,K.jsx)(lC,{matches:c,onItemClick:p,focusIndex:f,searchQuery:a})]})},cC=e=>{let t=[e.preview.moreBefore?`...`:``,e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?`...`:``];return(0,K.jsx)(`div`,{tabIndex:-1,className:I(`layer-ui__result-item`,{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:`auto`,block:`nearest`})},children:(0,K.jsx)(`div`,{className:`preview-text`,children:t.flatMap((e,t)=>(0,K.jsx)(G.Fragment,{children:t===2?(0,K.jsx)(`b`,{children:e}):e},t))})})},lC=(0,G.memo)(e=>(0,K.jsx)(`div`,{className:`layer-ui__search-result-container`,children:e.matches.items.map((t,n)=>(0,K.jsx)(cC,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.textElement.id+t.index))}),(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex),uC=(e,t,n)=>{let r=e.slice(0,t),i=r.split(/\s+/),a=r.endsWith(` `),o=i.length-2-1-!a,s=i.slice(o<=0?0:o).join(` `)+(a?` `:``);s=s.length>20?s.slice(-20):s;let c=e.slice(t+n.length),l=c.split(/\s+/),u=!c.startsWith(` `),d=u?6:5,f=(u?``:` `)+l.slice(0,d).join(` `);return{indexInSearchQuery:s.length,previewText:s+n+f,moreBefore:o>0,moreAfter:l.length>d}},dC=(e,t)=>{let n=e.split(`
|
|
6
|
+
`),r=[],i=0;for(let e=0;e<n.length;e++){let a=n[e],o=n[e+1];if(o){let e=t.indexOf(o,i);if(e>a.length+i){let t=e-(a.length+i);for(;t>0;)a+=` `,t--}}r.push(a),i+=a.length}return r.join(`
|
|
7
|
+
`)},fC=(e,t,n)=>{let r=dC(e.text,e.originalText).split(`
|
|
8
|
+
`),i=[],a=0,o=0;for(let e of r){let t=a,n=t+e.length-1;i.push({line:e,startIndex:t,endIndex:n,lineNumber:o}),a=n+1,o++}let s=n,c=e.originalText.slice(n,n+t.length),l=[];for(let t of i){if(c===``)break;if(s>=t.startIndex&&s<=t.endIndex){let n=t.endIndex+1-s,r=t.line.slice(0,s-t.startIndex),i=c.slice(0,n);c=c.slice(n);let a=ct(r,ko(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=ct(t.line,ko(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=ct(i,ko(e),e.lineHeight),d=a.width,f=t.lineNumber*a.height;l.push({offsetX:d,offsetY:f,width:o,height:u}),s+=n}}return l},pC=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),mC=(0,th.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements().filter(e=>L(e));r.sort((e,t)=>e.y-t.y);let i=[],a=new RegExp(pC(e),`gi`);for(let t of r){let n=null,r=t.originalText;for(;(n=a.exec(r))!==null;){let a=uC(r,n.index,e),o=fC(t,e,n.index);o.length>0&&i.push({textElement:t,searchQuery:e,preview:a,index:n.index,matchedLines:o})}}let o=new Set(t.visibleElements.map(e=>e.id));n(i,i.findIndex(e=>o.has(e.textElement.id))??null)},oC),hC=$S(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=Ab();return(0,K.jsx)(t.In,{children:(0,K.jsx)(FS.Trigger,{...e,className:`default-sidebar-trigger`,name:uo.name})})});hC.displayName=`DefaultSidebarTrigger`;var gC=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=Ab();return(0,K.jsx)(t.In,{children:e})};gC.displayName=`DefaultTabTriggers`;var _C=Object.assign($S(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=Fg(),o=SE(),{DefaultSidebarTabTriggersTunnel:s}=Ab(),c=a.openSidebar?.tab===Ci;return(0,G.createElement)(FS,{...i,name:`default`,key:`default`,className:I(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:Wo(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,K.jsxs)(FS.Tabs,{children:[(0,K.jsx)(FS.Header,{children:(0,K.jsxs)(FS.TabTriggers,{children:[(0,K.jsx)(FS.TabTrigger,{tab:Ci,children:$a}),(0,K.jsx)(FS.TabTrigger,{tab:pl,children:Qn}),(0,K.jsx)(s.Out,{})]})}),(0,K.jsx)(FS.Tab,{tab:pl,children:(0,K.jsx)(vb,{})}),(0,K.jsx)(FS.Tab,{tab:Ci,children:(0,K.jsx)(sC,{})}),e]}))}),{Trigger:hC,TabTriggers:gC}),vC=`small`,yC=e=>(0,K.jsxs)(`label`,{className:I(`ToolIcon ToolIcon__LaserPointer`,`ToolIcon_size_${vC}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,K.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":`toolbar-LaserPointer`}),(0,K.jsx)(`div`,{className:`ToolIcon__icon`,children:oa})]}),bC=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},xC=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i})=>{let a=e.current,o=a?.parentElement;if(!(!a||!o)){if(!n){bC({canvasRef:e,setError:r});return}try{let e=await t.api,s;try{s=await e.parseMermaidToExcalidraw(n)}catch{s=await e.parseMermaidToExcalidraw(n.replace(/"/g,`'`))}let{elements:c,files:l={}}=s;r(null),i.current={elements:nT(c,{regenerateIds:!0}),files:l};let u=await ze({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(o.offsetWidth,o.offsetHeight)*window.devicePixelRatio});try{await br(u)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(q(`canvasError.canvasTooBig`)):e}o.style.background=`var(--default-bg-color)`,a.replaceChildren(u)}catch(e){throw o.style.background=`var(--default-bg-color)`,n&&r(e),e}}},SC=e=>{Ly.set(yc.MERMAID_TO_EXCALIDRAW,e)},CC=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:r})=>{let{elements:i,files:a}=t.current;i.length&&(e.addElementsFromPasteOrLibrary({elements:i,files:a,position:`center`,fitToContent:!0}),e.setOpenDialog(null),r&&n&&SC(n))},wC=({children:e})=>(0,K.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),TC=({label:e,children:t,panelAction:n,panelActionDisabled:r=!1,onTextSubmitInProgess:i,renderTopRight:a,renderSubmitShortcut:o,renderBottomRight:s})=>(0,K.jsxs)(`div`,{className:`ttd-dialog-panel`,children:[(0,K.jsxs)(`div`,{className:`ttd-dialog-panel__header`,children:[(0,K.jsx)(`label`,{children:e}),a?.()]}),t,(0,K.jsxs)(`div`,{className:I(`ttd-dialog-panel-button-container`,{invisible:!n}),style:{display:`flex`,alignItems:`center`},children:[(0,K.jsxs)(xb,{className:`ttd-dialog-panel-button`,onSelect:n?n.action:()=>{},disabled:r||i,children:[(0,K.jsxs)(`div`,{className:I({invisible:i}),children:[n?.label,n?.icon&&(0,K.jsx)(`span`,{children:n.icon})]}),i&&(0,K.jsx)(Lh,{})]}),!r&&!i&&o?.(),s?.()]})]}),EC=({input:e,placeholder:t,onChange:n,onKeyboardSubmit:r})=>{let i=(0,G.useRef)(null),a=(0,G.useRef)(r);return a.current=r,(0,G.useEffect)(()=>{if(!a.current)return;let e=i.current;if(e){let t=e=>{e[F.CTRL_OR_CMD]&&e.key===F.ENTER&&(e.preventDefault(),a.current?.())};return e.addEventListener(`keydown`,t),()=>{e.removeEventListener(`keydown`,t)}}},[]),(0,K.jsx)(`textarea`,{className:`ttd-dialog-input`,onChange:n,value:e,placeholder:t,autoFocus:!0,ref:i})},DC=({error:e})=>(0,K.jsxs)(`div`,{"data-testid":`ttd-dialog-output-error`,className:`ttd-dialog-output-error`,children:[`Error! `,(0,K.jsx)(`p`,{children:e})]}),OC=({error:e,canvasRef:t,loaded:n})=>(0,K.jsxs)(`div`,{className:`ttd-dialog-output-wrapper`,children:[e&&(0,K.jsx)(DC,{error:e.message}),n?(0,K.jsx)(`div`,{ref:t,style:{opacity:e?`0.15`:1},className:`ttd-dialog-output-canvas-container`}):(0,K.jsx)(Lh,{size:`2rem`})]}),kC=()=>(0,K.jsxs)(`div`,{className:`ttd-dialog-submit-shortcut`,children:[(0,K.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:B(`CtrlOrCmd`)}),(0,K.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:B(`Enter`)})]}),AC=`flowchart TD
|
|
9
|
+
A[Christmas] -->|Get money| B(Go shopping)
|
|
10
|
+
B --> C{Let me think}
|
|
11
|
+
C -->|One| D[Laptop]
|
|
12
|
+
C -->|Two| E[iPhone]
|
|
13
|
+
C -->|Three| F[Car]`,jC=Zc(SC,300),MC=({mermaidToExcalidrawLib:e})=>{let[t,n]=(0,G.useState)(()=>Ly.get(yc.MERMAID_TO_EXCALIDRAW)||AC),r=(0,G.useDeferredValue)(t.trim()),[i,a]=(0,G.useState)(null),o=(0,G.useRef)(null),s=(0,G.useRef)({elements:[],files:null}),c=gE();(0,G.useEffect)(()=>{xC({canvasRef:o,data:s,mermaidToExcalidrawLib:e,setError:a,mermaidDefinition:r}).catch(e=>{ru()&&console.error(`Failed to parse mermaid definition`,e)}),jC(r)},[r,e]),(0,G.useEffect)(()=>()=>{jC.flush()},[]);let l=()=>{CC({app:c,data:s,text:t,shouldSaveMermaidDataToStorage:!0})};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,K.jsx)(Py,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,K.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,children:e}),sequenceLink:e=>(0,K.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,children:e}),classLink:e=>(0,K.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,children:e})})}),(0,K.jsxs)(wC,{children:[(0,K.jsx)(TC,{label:q(`mermaid.syntax`),children:(0,K.jsx)(EC,{input:t,placeholder:`Write Mermaid diagram defintion here...`,onChange:e=>n(e.target.value),onKeyboardSubmit:()=>{l()}})}),(0,K.jsx)(TC,{label:q(`mermaid.preview`),panelAction:{action:()=>{l()},label:q(`mermaid.button`),icon:cn},renderSubmitShortcut:()=>(0,K.jsx)(kC,{}),children:(0,K.jsx)(OC,{canvasRef:o,loaded:e.loaded,error:i})})]})]})},NC=e=>{let t=SE(),n=(0,G.useRef)(null),r=(0,G.useRef)(0);return(0,K.jsx)(Zm,{ref:n,className:`ttd-dialog-tabs-root`,value:e.tab,onValueChange:i=>{if(!i)return;let a=n.current?.closest(`.Modal__content`);if(a){let e=a.offsetHeight||0;e>r.current&&(r.current=e,a.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog===`ttd`&&so([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};NC.displayName=`TTDDialogTabs`;var PC=NC,FC=({children:e,...t})=>(0,K.jsx)(Qm,{className:`ttd-dialog-triggers`,...t,children:e});FC.displayName=`TTDDialogTabTriggers`;var IC=({children:e,tab:t,onSelect:n,...r})=>(0,K.jsx)($m,{value:t,asChild:!0,onSelect:n,children:(0,K.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});IC.displayName=`TTDDialogTabTrigger`;var LC=({tab:e,children:t,...n})=>(0,K.jsx)(eh,{...n,value:e,children:t});LC.displayName=`TTDDialogTab`;var RC=3,zC=1e3,BC=ku(null),VC=ku(null),HC=e=>{let t=Fg();return t.openDialog?.name===`ttd`?(0,K.jsx)(UC,{...e,tab:t.openDialog.tab}):null},UC=$S(`TTDDialogBase`,({tab:e,...t})=>{let n=gE(),r=SE(),i=(0,G.useRef)(null),[a,o]=yh(VC),[s,c]=(0,G.useState)(a?.prompt??``),l=s.trim(),u=e=>{c(e.target.value),o(t=>({generatedResponse:t?.generatedResponse??null,prompt:e.target.value}))},[d,f]=(0,G.useState)(!1),[p,m]=yh(BC),h=async()=>{if(l.length>zC||l.length<RC||d||p?.rateLimitRemaining===0||`__fallback`in t){l.length<RC&&S(Error(`Prompt is too short (min ${RC} characters)`)),l.length>zC&&S(Error(`Prompt is too long (max ${zC} characters)`));return}try{f(!0),Y(`ai`,`generate`,`ttd`);let{generatedResponse:e,error:n,rateLimit:r,rateLimitRemaining:a}=await t.onTextSubmit(l);if(typeof e==`string`&&o(t=>({generatedResponse:e,prompt:t?.prompt??null})),go(r)&&go(a)&&m({rateLimit:r,rateLimitRemaining:a}),n){S(n);return}if(!e){S(Error(`Generation failed`));return}try{await xC({canvasRef:i,data:b,mermaidToExcalidrawLib:_,setError:S,mermaidDefinition:e}),Y(`ai`,`mermaid parse success`,`ttd`)}catch(e){console.info(`%cTTD mermaid render errror: ${e.message}`,`color: red`),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
14
|
+
TTD mermaid definition render errror: ${e.message}`,`color: yellow`),Y(`ai`,`mermaid parse failed`,`ttd`),S(Error(`Generated an invalid diagram :(. You may also try a different prompt.`))}}catch(e){let t=e.message;(!t||t===`Failed to fetch`)&&(t=`Request failed`),S(Error(t))}finally{f(!1)}},g=(0,G.useRef)(h);g.current=h;let[_,y]=(0,G.useState)({loaded:!1,api:v(()=>import(`./dist-DAGGreTm.js`),__vite__mapDeps([64,2,65,61,66,67,62,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))});(0,G.useEffect)(()=>{(async()=>{await _.api,y(e=>({...e,loaded:!0}))})()},[_.api]);let b=(0,G.useRef)({elements:[],files:null}),[x,S]=(0,G.useState)(null);return(0,K.jsx)(bb,{className:`ttd-dialog`,onCloseRequest:()=>{n.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:(0,K.jsxs)(PC,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,K.jsx)(`p`,{className:`dialog-mermaid-title`,children:q(`mermaid.title`)}):(0,K.jsxs)(FC,{children:[(0,K.jsx)(IC,{tab:`text-to-diagram`,children:(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[q(`labels.textToDiagram`),(0,K.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`1px 6px`,marginLeft:`10px`,fontSize:10,borderRadius:`12px`,background:`var(--color-promo)`,color:`var(--color-surface-lowest)`},children:`AI Beta`})]})}),(0,K.jsx)(IC,{tab:`mermaid`,children:`Mermaid`})]}),(0,K.jsx)(LC,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,K.jsx)(MC,{mermaidToExcalidrawLib:_})}),!(`__fallback`in t)&&(0,K.jsxs)(LC,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:[(0,K.jsx)(`div`,{className:`ttd-dialog-desc`,children:`Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar.`}),(0,K.jsxs)(wC,{children:[(0,K.jsx)(TC,{label:q(`labels.prompt`),panelAction:{action:h,label:`Generate`,icon:cn},onTextSubmitInProgess:d,panelActionDisabled:l.length>zC||p?.rateLimitRemaining===0,renderTopRight:()=>p?(0,K.jsxs)(`div`,{className:`ttd-dialog-rate-limit`,style:{fontSize:12,marginLeft:`auto`,color:p.rateLimitRemaining===0?`var(--color-danger)`:void 0},children:[p.rateLimitRemaining,` requests left today`]}):null,renderSubmitShortcut:()=>(0,K.jsx)(kC,{}),renderBottomRight:()=>{if(typeof a?.generatedResponse==`string`)return(0,K.jsxs)(`div`,{className:`excalidraw-link`,style:{marginLeft:`auto`,fontSize:14},onClick:()=>{typeof a?.generatedResponse==`string`&&(SC(a.generatedResponse),r({openDialog:{name:`ttd`,tab:`mermaid`}}))},children:[`View as Mermaid`,(0,K.jsx)(Yg,{icon:cn})]});let e=l.length/zC;return e>.8?(0,K.jsxs)(`div`,{style:{marginLeft:`auto`,fontSize:12,fontFamily:`monospace`,color:e>1?`var(--color-danger)`:void 0},children:[`Length: `,l.length,`/`,zC]}):null},children:(0,K.jsx)(EC,{onChange:u,input:s,placeholder:`Describe what you want to see...`,onKeyboardSubmit:()=>{g.current()}})}),(0,K.jsx)(TC,{label:`Preview`,panelAction:{action:()=>{console.info(`Panel action clicked`),CC({app:n,data:b})},label:`Insert`,icon:cn},children:(0,K.jsx)(OC,{canvasRef:i,error:x,loaded:_.loaded})})]})]})]})})}),WC=.01,GC=(e,t)=>!(t===`height`&&L(e)||t===`width`&&L(e)||t===`angle`&&D(e)),KC=(e,t)=>{let n=e+t/2;return n-n%t},qC=(e,t,n)=>Object.keys(e).map(e=>({original:(n??t).get(e),latest:t.get(e)})).filter(e=>e.original!==void 0&&e.latest!==void 0),JC=(e,t,n,r,i,a,o,s=!0)=>{let c=r.get(n.id);if(!c)return;let[l,u]=[n.x+n.width/2,n.y+n.height/2],[d,f]=uc(O(n.x,n.y),O(l,u),n.angle),p=e-d,m=t-f,[h,g]=uc(O(e,t),O(l+p,u+m),-n.angle);U(c,{x:h,y:g},s),XC(c,r,i,a);let _=Mn(n,o);if(_){let e=r.get(_.id);e&&U(e,{x:_.x+p,y:_.y+m},s)}},YC=(e,t)=>{let n=ot(t).map(t=>Ki(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!ka(e)).forEach(e=>{n.push({[e.id]:!0})}),n},XC=(e,t,n,r,i)=>{Ac(e)?Ge([e],t,n,r,!0,[],i?.zoom):Io(e,t,i)},ZC=({label:e,icon:t,dragInputCallback:n,value:r,elements:i,editable:a=!0,shouldKeepAspectRatio:o,property:s,scene:c,appState:l,sensitivity:u=1})=>{let d=gE(),f=(0,G.useRef)(null),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(r.toString()),g=(0,G.useRef)(null);g.current||={originalAppState:ke(l),originalElements:i,lastUpdatedValue:m,updatePending:!1},(0,G.useEffect)(()=>{let e=r.toString();h(e),g.current.lastUpdatedValue=e},[r]);let _=(e,t,i)=>{if(!g.current.updatePending)return!1;g.current.updatePending=!1;let a=Number(e);if(isNaN(a)){h(r.toString());return}let l=Number(a.toFixed(2)),u=Number(r);(isNaN(u)||Math.abs(l-u)>=WC)&&(g.current.lastUpdatedValue=e,n({accumulatedChange:0,instantChange:0,originalElements:t,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:o,shouldChangeByStepSize:!1,scene:c,nextValue:l,property:s,originalAppState:i,setInputValue:e=>h(String(e))}),d.syncActionResult({captureUpdate:M.IMMEDIATELY}))},v=(0,G.useRef)({});return v.current.handleInputValue=_,(0,G.useEffect)(()=>{let e=f.current,t=v.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,g.current.originalElements,g.current.originalAppState),window.removeEventListener(`pointermove`,t.onPointerMove,!1),window.removeEventListener(`pointerup`,t.onPointerUp,!1)}},[a]),a?(0,K.jsxs)(`div`,{className:I(`drag-input-container`,!a&&`disabled`),"data-testid":e,children:[(0,K.jsx)(`div`,{className:`drag-input-label`,ref:p,onPointerDown:e=>{if(f.current&&a){document.body.classList.add(`excalidraw-cursor-resize`);let e=Number(f.current.value);isNaN(e)&&(e=0);let t=null,r=d.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,Xt(t)),e),new Map),a=i.map(e=>r.get(e.id)),p=ke(l),m=0,g=0,_=e=>{if(t&&r!==null&&a!==null){let i=e.clientX-t.x;i!==0&&(g+=i,Math.abs(g)>=u&&(g=Math.sign(g)*Math.floor(Math.abs(g)/u),m+=g,n({accumulatedChange:m,instantChange:g,originalElements:a,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:e.shiftKey,property:s,scene:c,originalAppState:p,setInputValue:e=>h(String(e))}),g=0))}t={x:e.clientX,y:e.clientY}},y=()=>{window.removeEventListener(`pointermove`,_,!1),d.syncActionResult({captureUpdate:M.IMMEDIATELY}),t=null,m=0,g=0,a=null,r=null,document.body.classList.remove(`excalidraw-cursor-resize`),window.removeEventListener(`pointerup`,y,!1)};v.current.onPointerMove=_,v.current.onPointerUp=y,window.addEventListener(`pointermove`,_,!1),window.addEventListener(`pointerup`,y,!1)}},onPointerEnter:()=>{p.current&&(p.current.style.cursor=`ew-resize`)},children:t?(0,K.jsx)(Yg,{icon:t}):e}),(0,K.jsx)(`input`,{className:`drag-input`,autoComplete:`off`,spellCheck:`false`,onKeyDown:e=>{if(a){let t=e.target;t instanceof HTMLInputElement&&e.key===F.ENTER&&(_(t.value,i,l),d.focusContainer())}},ref:f,value:m,onChange:e=>{g.current.updatePending=!0,h(e.target.value)},onFocus:e=>{e.target.select(),g.current.originalElements=i,g.current.originalAppState=ke(l)},onBlur:e=>{m?a&&_(e.target.value,g.current.originalElements,g.current.originalAppState):h(r.toString())},disabled:!a})]}):null},QC=10,$C=e=>e.type===`image`,ew=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:r,shouldChangeByStepSize:i,nextValue:a,property:o,originalAppState:s,instantChange:c,scene:l})=>{let u=l.getNonDeletedElementsMap(),d=t[0],f=u.get(d.id);if(d&&f){let t=r||$C(d),l=d.width/d.height;if(s.croppingElementId===d.id){let e=u.get(d.id);if(!e||!Mo(e)||!e.crop)return;let t=e.crop,n={...t},r=e.scale[0]===-1,i=e.scale[1]===-1,{width:s,height:l}=ui(e),f=t.naturalWidth/s,p=t.naturalHeight/l,m=r?t.width+t.x:t.naturalWidth-t.x,h=i?t.height+t.y:t.naturalHeight-t.y,g=10*f,_=10*p;if(a!==void 0){if(o===`width`){let e=pa(a*f,g,m);n={...n,width:e,x:r?t.x+t.width-e:t.x}}else if(o===`height`){let e=pa(a*p,_,h);n={...n,height:e,y:i?t.y+t.height-e:t.y}}U(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/l)});return}let v=o===`width`?c:0,y=o===`height`?c:0,b=pa(t.width+v,g,m),x=pa(t.height+y,g,h);n={...t,x:r?t.x+t.width-b:t.x,y:i?t.y+t.height-x:t.y,width:b,height:x},U(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/l)});return}if(a!==void 0){Cr(Math.max(o===`width`?a:t?a*l:d.width,1),Math.max(o===`height`?a:t?a/l:d.height,1),f,d,u,n,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t});return}let p=o===`width`?e:0,m=o===`height`?e:0,h=Math.max(0,d.width+p);o===`width`&&(h=i?KC(h,QC):Math.round(h));let g=Math.max(0,d.height+m);o===`height`&&(g=i?KC(g,QC):Math.round(g)),t&&(o===`width`?g=Math.round(h/l*100)/100:h=Math.round(g*l*100)/100),g=Math.max(1,g),h=Math.max(1,h),Cr(h,g,f,d,u,n,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t})}},tw=({property:e,element:t,scene:n,appState:r})=>{let i=Po(e===`width`?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&Mo(t)&&t.crop){let{width:n,height:r}=ui(t);if(e===`width`){let e=n/t.crop.naturalWidth;i=Po(t.crop.width*e,2)}if(e===`height`){let e=r/t.crop.naturalHeight;i=Po(t.crop.height*e,2)}}return(0,K.jsx)(ZC,{label:e===`width`?`W`:`H`,elements:[t],dragInputCallback:ew,value:i,editable:GC(t,e),scene:n,appState:r,property:e})},nw=15,rw=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=i.getNonDeletedElements(),s=t[0];if(s&&!T(s)){let t=a.get(s.id);if(!t)return;if(r!==void 0){let e=we(r);U(t,{angle:e}),XC(t,a,o,i);let n=Mn(t,a);n&&!xu(t)&&U(n,{angle:e});return}let c=(Math.round(Ps(s.angle)*100)/100+Math.round(e))%360;n&&(c=KC(c,nw)),c=c<0?c+360:c;let l=we(c);U(t,{angle:l}),XC(t,a,o,i);let u=Mn(t,a);u&&!xu(t)&&U(u,{angle:l})}},iw=({element:e,scene:t,appState:n,property:r})=>(0,K.jsx)(ZC,{label:`A`,icon:mn,value:Math.round(Ps(e.angle)%360*100)/100,elements:[e],dragInputCallback:rw,editable:GC(e,`angle`),scene:t,appState:n,property:r}),aw=4,ow=4,sw=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t[0];if(o){let t=a.get(o.id);if(!t||!L(t))return;let s;if(r!==void 0)s=Math.max(Math.round(r),aw);else if(o.type===`text`){let t=Math.round(o.fontSize);s=Math.max(t+Math.round(e),aw),n&&(s=KC(s,ow))}s&&(U(t,{fontSize:s}),Qo(t,i.getContainerElement(t),i.getNonDeletedElementsMap()))}},cw=({element:e,scene:t,appState:n,property:r})=>{let i=L(e)?e:Ja(e)?Mn(e,t.getNonDeletedElementsMap()):null;return i?(0,K.jsx)(ZC,{label:`F`,value:Math.round(i.fontSize*10)/10,elements:[i],dragInputCallback:sw,icon:Ze,appState:n,scene:t,property:r}):null},lw=10,uw=(e,t,n,r)=>{let i=r.x-e,a=r.y-t,o=r.width*n,s=r.height*n;return{width:o,height:s,x:e+i*n,y:t+a*n,...dc(r,o,s,!1),...L(r)?{fontSize:r.fontSize*n}:{}}},dw=(e,t,n,r,i,a,o,s)=>{let c=uw(e,t,r,a);U(i,c,!1);let l=Mn(a,s);if(l){let e=l.fontSize*r;Io(i,o,{newSize:{width:c.width,height:c.height}});let t=o.get(l.id);t&&L(t)&&(U(t,{fontSize:e},!1),Dr(i,o,n===`width`?`e`:`s`,!0))}},fw=(e,t,n,r,i,a,o,s,c,l)=>{a===`width`?t=Math.round(e/r*100)/100:e=Math.round(t*r*100)/100;let u=t/n;for(let e=0;e<s.length;e++){let t=s[e],n=o[e];dw(i[0],i[1],a,u,n,t,c,l)}},pw=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:r,shouldChangeByStepSize:i,nextValue:a,scene:o,property:s})=>{let c=o.getNonDeletedElementsMap(),l=YC(t,r);if(a!==void 0){for(let e of l){let t=qC(e,c,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[i,o,l,u]=Zo(r),d=l-i,f=u-o,p=d/f;fw(Math.max(1,s===`width`?Math.max(0,a):d),Math.max(1,s===`height`?Math.max(0,a):f),f,p,O(i,o),s,e,r,c,n)}else{let[e]=t,r=e?.latest,o=e?.original;if(r&&o&&GC(r,s)){let e=s===`width`?Math.max(0,a):r.width;s===`width`&&(e=i?KC(e,lw):Math.round(e));let t=s===`height`?Math.max(0,a):r.height;s===`height`&&(t=i?KC(t,lw):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),Cr(e,t,r,o,c,n,s===`width`?`e`:`s`,{shouldInformMutation:!1})}}}o.triggerUpdate();return}let u=s===`width`?e:0,d=s===`height`?e:0;for(let e of l){let t=qC(e,c,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[a,o,l,f]=Zo(r),p=l-a,m=f-o,h=p/m,g=Math.max(0,p+u);s===`width`&&(g=i?KC(g,lw):Math.round(g));let _=Math.max(0,m+d);s===`height`&&(_=i?KC(_,lw):Math.round(_)),g=Math.max(1,g),_=Math.max(1,_),fw(g,_,m,h,O(a,o),s,e,r,c,n)}else{let[e]=t,r=e?.latest,a=e?.original;if(r&&a&&GC(r,s)){let e=Math.max(0,a.width+u);s===`width`&&(e=i?KC(e,lw):Math.round(e));let t=Math.max(0,a.height+d);s===`height`&&(t=i?KC(t,lw):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),Cr(e,t,r,a,c,n,s===`width`?`e`:`s`,{shouldInformMutation:!1})}}}o.triggerUpdate()},mw=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,G.useMemo)(()=>r.map(t=>{let r=qC(t,n);if(r.length>1){let[t,n,i,a]=Zo(r.map(e=>e.latest));return Math.round((e===`width`?i-t:a-n)*100)/100}let[i]=r;return Math.round((e===`width`?i.latest.width:i.latest.height)*100)/100}),[n,r,e]),s=new Set(o).size===1?Math.round(o[0]*100)/100:`Mixed`,c=o.length>0;return(0,K.jsx)(ZC,{label:e===`width`?`W`:`H`,elements:t,dragInputCallback:pw,value:s,editable:c,appState:a,property:e,scene:i})},hw=15,gw=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a})=>{let o=a.getNonDeletedElementsMap(),s=t.map(e=>o.get(e.id)).filter(e=>e&&!ka(e)&&GC(e,i)),c=t.filter(e=>!ka(e)&&GC(e,i));if(r!==void 0){let e=we(r);for(let t of s){if(!t)continue;U(t,{angle:e},!1);let n=Mn(t,o);n&&!xu(t)&&U(n,{angle:e},!1)}a.triggerUpdate();return}for(let t=0;t<s.length;t++){let r=s[t];if(!r)continue;let i=c[t],a=(Math.round(Ps(i.angle)*100)/100+Math.round(e))%360;n&&(a=KC(a,hw)),a=a<0?a+360:a;let l=we(a);U(r,{angle:l},!1);let u=Mn(r,o);u&&!xu(r)&&U(u,{angle:l},!1)}a.triggerUpdate()},_w=({elements:e,scene:t,appState:n,property:r})=>{let i=e.filter(e=>!ka(e)&&GC(e,`angle`)),a=i.map(e=>Math.round(Ps(e.angle)%360*100)/100);return(0,K.jsx)(ZC,{label:`A`,icon:mn,value:new Set(a).size===1?a[0]:`Mixed`,elements:e,dragInputCallback:gw,editable:i.some(e=>GC(e,`angle`)),appState:n,scene:t,property:r})},vw=4,yw=4,bw=(e,t)=>e.reduce((e,n)=>{if(!n||ka(n))return e;if(L(n))return e.push(n),e;if(Ja(n)){let r=Mn(n,t);if(r)return e.push(r),e}return e},[]),xw=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t.map(e=>a.get(e.id)),s;if(r){s=Math.max(Math.round(r),vw);for(let e of o)U(e,{fontSize:s},!1),Qo(e,i.getContainerElement(e),a,!1);i.triggerUpdate()}else{let r=t;for(let t=0;t<o.length;t++){let s=o[t],c=r[t],l=Math.round(c.fontSize),u=Math.max(l+Math.round(e),vw);n&&(u=KC(u,yw)),U(s,{fontSize:u},!1),Qo(s,i.getContainerElement(s),a,!1)}i.triggerUpdate()}},Sw=({elements:e,scene:t,appState:n,property:r,elementsMap:i})=>{let a=bw(e,i);if(!a.length)return null;let o=a.map(e=>Math.round(e.fontSize*10)/10);return(0,K.jsx)(ZC,{label:`F`,icon:Ze,elements:a,dragInputCallback:xw,value:new Set(o).size===1?o[0]:`Mixed`,editable:o.length>0,scene:t,property:r,appState:n})},Cw=10,ww=({accumulatedChange:e,instantChange:t,originalElements:n,originalElementsMap:r,shouldChangeByStepSize:i,nextValue:a,property:o,scene:s,originalAppState:c})=>{let l=s.getNonDeletedElementsMap(),u=s.getNonDeletedElements(),d=n[0],[f,p]=[d.x+d.width/2,d.y+d.height/2],[m,h]=uc(O(d.x,d.y),O(f,p),d.angle);if(c.croppingElementId===d.id){let e=l.get(d.id);if(!e||!Mo(e)||!e.crop)return;let n=e.crop,r=n,i=e.scale[0]===-1,s=e.scale[1]===-1,{width:c,height:u}=ui(e);if(a!==void 0){if(o===`x`){let e=a*(n.naturalWidth/c);r=i?{...n,x:pa(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:pa(a*(n.naturalWidth/c),0,n.naturalWidth-n.width)}}o===`y`&&(r={...n,y:pa(a*(n.naturalHeight/u),0,n.naturalHeight-n.height)}),U(e,{crop:r});return}let f=(o===`x`?t:0)*(i?-1:1),p=(o===`y`?t:0)*(s?-1:1);r={...n,x:pa(n.x+f,0,n.naturalWidth-n.width),y:pa(n.y+p,0,n.naturalHeight-n.height)},U(e,{crop:r});return}if(a!==void 0){JC(o===`x`?a:m,o===`y`?a:h,d,l,u,s,r);return}let g=o===`x`?e:0,_=o===`y`?e:0;JC(o===`x`?Math.round(i?KC(d.x+g,Cw):m+g):m,o===`y`?Math.round(i?KC(d.y+_,Cw):h+_):h,d,l,u,s,r)},Tw=({property:e,element:t,elementsMap:n,scene:r,appState:i})=>{let[a,o]=uc(O(t.x,t.y),O(t.x+t.width/2,t.y+t.height/2),t.angle),s=Po(e===`x`?a:o,2);if(i.croppingElementId===t.id&&Mo(t)&&t.crop){let n=Vl(t);n&&(s=Po(e===`x`?n.x:n.y,2))}return(0,K.jsx)(ZC,{label:e===`x`?`X`:`Y`,elements:[t],dragInputCallback:ww,scene:r,value:s,property:e,appState:i})},Ew=10,Dw=(e,t,n,r,i,a,o,s)=>{for(let c=0;c<r.length;c++){let l=i[c],[u,d]=[l.x+l.width/2,l.y+l.height/2],[f,p]=uc(O(l.x,l.y),O(u,d),l.angle);JC(e===`x`?Math.round(f+t):f,e===`y`?Math.round(p+n):p,l,a,r,s,o,!1)}},Ow=(e,t,n,r,i,a,o)=>{let[s,c,,]=Zo(n),l=e-s,u=t-c;for(let e=0;e<n.length;e++){let t=n[e],s=r.get(t.id);if(s&&(!L(s)||!s.containerId)){let[e,n]=[s.x+s.width/2,s.y+s.height/2],[c,d]=uc(O(s.x,s.y),O(e,n),s.angle);JC(c+l,d+u,t,r,i,o,a,!1)}}},kw=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:o,originalAppState:s})=>{let c=o.getNonDeletedElementsMap(),l=o.getNonDeletedElements();if(i!==void 0){for(let e of YC(t,s)){let t=qC(e,c,n);if(t.length>1){let[e,r,,]=Zo(t.map(e=>e.latest));Ow(a===`x`?i:e,a===`y`?i:r,t.map(e=>e.original),c,l,n,o)}else{let e=t[0]?.original,r=t[0]?.latest;if(e&&r&&GC(r,a)){let[t,r]=[e.x+e.width/2,e.y+e.height/2],[s,u]=uc(O(e.x,e.y),O(t,r),e.angle);JC(a===`x`?i:s,a===`y`?i:u,e,c,l,o,n,!1)}}}o.triggerUpdate();return}let u=r?KC(e,Ew):e;Dw(a,a===`x`?u:0,a===`y`?u:0,t,t,c,n,o),o.triggerUpdate()},Aw=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,G.useMemo)(()=>r.map(t=>{let r=Object.keys(t).map(e=>n.get(e)).filter(e=>e!==void 0);if(r.length>1){let[t,n]=Zo(r);return Math.round((e===`x`?t:n)*100)/100}let[i]=r,[a,o]=[i.x+i.width/2,i.y+i.height/2],[s,c]=uc(O(i.x,i.y),O(a,o),i.angle);return Math.round((e===`x`?s:c)*100)/100}),[r,n,e]),s=new Set(o).size===1?o[0]:`Mixed`;return(0,K.jsx)(ZC,{label:e===`x`?`X`:`Y`,elements:t,dragInputCallback:kw,value:s,property:e,scene:i,appState:a})},jw=5,Mw=({property:e,scene:t,appState:n,setAppState:r})=>(0,K.jsx)(ZC,{label:`Grid step`,sensitivity:8,elements:[],dragInputCallback:({nextValue:e,instantChange:t,shouldChangeByStepSize:n,setInputValue:i})=>{r(r=>{let a;return e?a=e:t&&(a=n?KC(r.gridStep+jw*Math.sign(t),jw):r.gridStep+t),a?(a=Ul(a),i(a),{gridStep:a}):(i(r.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),Nw=50,Pw=e=>{let t=xE(),n=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),i=ul(e.app);return(0,K.jsx)(Iw,{...e,appState:t,sceneNonce:n,selectedElements:r,gridModeEnabled:i})},Q=({children:e,columns:t=1,heading:n,style:r,...i})=>(0,K.jsx)(`div`,{className:I(`exc-stats__row`,{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...i,children:e});Q.displayName=`StatsRow`;var Fw=({children:e,order:t,style:n,...r})=>(0,K.jsx)(`div`,{className:`exc-stats__rows`,style:{order:t,...n},...r,children:e});Fw.displayName=`StatsRows`,Pw.StatsRow=Q,Pw.StatsRows=Fw;var Iw=(0,G.memo)(({app:e,onClose:t,renderCustomStats:n,selectedElements:r,appState:i,sceneNonce:a,gridModeEnabled:o})=>{let s=e.scene,c=s.getNonDeletedElements(),l=s.getNonDeletedElementsMap(),u=SE(),d=r.length===1?r[0]:null,f=r.length>1?r:null,p=i.croppingElementId&&Mo(d),m=p?ui(d):null,[h,g]=(0,G.useState)({width:0,height:0}),_=(0,G.useMemo)(()=>(0,kp.default)(e=>{let t=Zo(e);g({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},Nw),[]);(0,G.useEffect)(()=>{_(c)},[a,c,_]),(0,G.useEffect)(()=>()=>_.cancel(),[_]);let v=(0,G.useMemo)(()=>YC(r,i),[r,i]),y=(0,G.useMemo)(()=>Tr(r),[r]);return(0,K.jsx)(`div`,{className:`exc-stats`,children:(0,K.jsxs)(Hg,{padding:3,children:[(0,K.jsxs)(`div`,{className:`title`,children:[(0,K.jsx)(`h2`,{children:q(`stats.title`)}),(0,K.jsx)(`div`,{className:`close`,onClick:t,children:Gc})]}),(0,K.jsxs)(Xg,{label:(0,K.jsx)(`h3`,{children:q(`stats.generalStats`)}),open:!!(i.stats.panels&Ui.generalStats),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^Ui.generalStats}})),children:[(0,K.jsxs)(Fw,{children:[(0,K.jsx)(Q,{heading:!0,children:q(`stats.scene`)}),(0,K.jsxs)(Q,{columns:2,children:[(0,K.jsx)(`div`,{children:q(`stats.shapes`)}),(0,K.jsx)(`div`,{children:c.length})]}),(0,K.jsxs)(Q,{columns:2,children:[(0,K.jsx)(`div`,{children:q(`stats.width`)}),(0,K.jsx)(`div`,{children:h.width})]}),(0,K.jsxs)(Q,{columns:2,children:[(0,K.jsx)(`div`,{children:q(`stats.height`)}),(0,K.jsx)(`div`,{children:h.height})]}),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Q,{heading:!0,children:`Canvas`}),(0,K.jsx)(Q,{children:(0,K.jsx)(Mw,{property:`gridStep`,scene:s,appState:i,setAppState:u})})]})]}),n?.(c,i)]}),!y&&r.length>0&&(0,K.jsx)(`div`,{id:`elementStats`,style:{marginTop:12},children:(0,K.jsx)(Xg,{label:(0,K.jsx)(`h3`,{children:q(`stats.elementProperties`)}),open:!!(i.stats.panels&Ui.elementProperties),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^Ui.elementProperties}})),children:(0,K.jsxs)(Fw,{children:[d&&(0,K.jsxs)(K.Fragment,{children:[p&&(0,K.jsx)(Q,{heading:!0,children:q(`labels.unCroppedDimension`)}),i.croppingElementId&&Mo(d)&&m&&(0,K.jsxs)(Q,{columns:2,children:[(0,K.jsx)(`div`,{children:q(`stats.width`)}),(0,K.jsx)(`div`,{children:Po(m.width,2)})]}),i.croppingElementId&&Mo(d)&&m&&(0,K.jsxs)(Q,{columns:2,children:[(0,K.jsx)(`div`,{children:q(`stats.height`)}),(0,K.jsx)(`div`,{children:Po(m.height,2)})]}),(0,K.jsx)(Q,{heading:!0,"data-testid":`stats-element-type`,children:i.croppingElementId?q(`labels.imageCropping`):q(`element.${d.type}`)}),(0,K.jsx)(Q,{children:(0,K.jsx)(Tw,{element:d,property:`x`,elementsMap:l,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(Tw,{element:d,property:`y`,elementsMap:l,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(tw,{property:`width`,element:d,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(tw,{property:`height`,element:d,scene:s,appState:i})}),!T(d)&&(0,K.jsx)(Q,{children:(0,K.jsx)(iw,{property:`angle`,element:d,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(cw,{property:`fontSize`,element:d,scene:s,appState:i})})]}),f&&(0,K.jsxs)(K.Fragment,{children:[se(f)&&(0,K.jsx)(Q,{heading:!0,children:q(`element.group`)}),(0,K.jsxs)(Q,{columns:2,style:{margin:`0.3125rem 0`},children:[(0,K.jsx)(`div`,{children:q(`stats.shapes`)}),(0,K.jsx)(`div`,{children:r.length})]}),(0,K.jsx)(Q,{children:(0,K.jsx)(Aw,{property:`x`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(Aw,{property:`y`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(mw,{property:`width`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(mw,{property:`height`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(_w,{property:`angle`,elements:f,scene:s,appState:i})}),(0,K.jsx)(Q,{children:(0,K.jsx)(Sw,{property:`fontSize`,elements:f,scene:s,appState:i,elementsMap:l})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId),Lw=({sourceElementId:e,onClose:t,elementsMap:n,appState:r,generateLinkForSelection:i=ta})=>{let a=n.get(e)?.link??null,[o,s]=(0,G.useState)(a),[c,l]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=R(n,r),t=a;if(e.length>0&&i){let n=Vc(e,r);n&&(t=ms(i(n.id,n.type)))}s(t)},[n,r,r.selectedElementIds,a,i]);let u=(0,G.useCallback)(()=>{if(o&&o!==n.get(e)?.link){let t=n.get(e);t&&U(t,{link:o})}if(!o&&c&&e){let t=n.get(e);t&&U(t,{link:null})}t?.()},[e,o,n,c,t]);return(0,G.useEffect)(()=>{let e=e=>{r.openDialog?.name===`elementLinkSelector`&&e.key===F.ENTER&&u(),r.openDialog?.name===`elementLinkSelector`&&e.key===F.ESCAPE&&t?.()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r,t,u]),(0,K.jsxs)(`div`,{className:`ElementLinkDialog`,children:[(0,K.jsxs)(`div`,{className:`ElementLinkDialog__header`,children:[(0,K.jsx)(`h2`,{children:q(`elementLink.title`)}),(0,K.jsx)(`p`,{children:q(`elementLink.desc`)})]}),(0,K.jsxs)(`div`,{className:`ElementLinkDialog__input`,children:[(0,K.jsx)(Sb,{value:o??``,onChange:e=>{c||l(!0),s(e)},onKeyDown:e=>{e.key===F.ENTER&&u()},className:`ElementLinkDialog__input-field`,selectOnRender:!0}),a&&o&&(0,K.jsx)(J,{type:`button`,title:q(`buttons.remove`),"aria-label":q(`buttons.remove`),label:q(`buttons.remove`),onClick:()=>{s(null),l(!0)},className:`ElementLinkDialog__remove`,icon:cu})]}),(0,K.jsxs)(`div`,{className:`ElementLinkDialog__actions`,children:[(0,K.jsx)(Fy,{label:q(`buttons.cancel`),onClick:()=>{t?.()},style:{marginRight:10}}),(0,K.jsx)(Fy,{label:q(`buttons.confirm`),onClick:u,actionType:`primary`})]})]})},Rw=({UIOptions:e})=>(0,K.jsxs)(eC,{__fallback:!0,children:[(0,K.jsx)(eC.DefaultItems.LoadScene,{}),(0,K.jsx)(eC.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,K.jsx)(eC.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,K.jsx)(eC.DefaultItems.SaveAsImage,{}),(0,K.jsx)(eC.DefaultItems.SearchMenu,{}),(0,K.jsx)(eC.DefaultItems.Help,{}),(0,K.jsx)(eC.DefaultItems.ClearCanvas,{}),(0,K.jsx)(eC.Separator,{}),(0,K.jsx)(eC.Group,{title:`Excalidraw links`,children:(0,K.jsx)(eC.DefaultItems.Socials,{})}),(0,K.jsx)(eC.Separator,{}),(0,K.jsx)(eC.DefaultItems.ToggleTheme,{}),(0,K.jsx)(eC.DefaultItems.ChangeCanvasBackground,{})]}),zw=()=>(0,K.jsxs)(rC,{__fallback:!0,children:[(0,K.jsx)(rC.Actions.SaveToDisk,{}),(0,K.jsx)(rC.Actions.ExportToImage,{})]}),Bw=({actionManager:e,appState:t,files:n,setAppState:r,elements:i,canvas:a,onLockToggle:o,onHandToolToggle:s,onPenModeToggle:c,showExitZenModeBtn:l,renderTopRightUI:u,renderCustomStats:d,UIOptions:f,onExportImage:p,renderWelcomeScreen:m,children:h,app:g,isCollaborating:_,generateLinkForSelection:v})=>{let y=vE(),b=Mb(),x=b.tunnelsJotai.Provider,[S,ee]=yh(zg),te=()=>f.canvasActions.export?(0,K.jsx)(SS,{elements:i,appState:t,files:n,actionManager:e,exportOpts:f.canvasActions.export,canvas:a,setAppState:r}):null,ne=()=>!f.canvasActions.saveAsImage||t.openDialog?.name!==`imageExport`?null:(0,K.jsx)(kx,{elements:i,appState:t,files:n,actionManager:e,onExportImage:p,onCloseRequest:()=>r({openDialog:null}),name:g.getName()}),re=()=>(0,K.jsxs)(`div`,{style:{position:`relative`},children:[(0,K.jsx)(b.MainMenuTunnel.Out,{}),m&&(0,K.jsx)(b.WelcomeScreenMenuHintTunnel.Out,{})]}),C=()=>(0,K.jsx)(Yx,{heading:`selectedShapeActions`,className:I(`selected-shape-actions zen-mode-transition`,{"transition-left":t.zenModeEnabled}),children:(0,K.jsx)(Hg,{className:hc.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:(0,K.jsx)(Fb,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g})})}),w=()=>{let n=Fl(t,i),r=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`;return(0,K.jsx)(Ax,{side:`top`,children:(0,K.jsxs)(`div`,{className:`App-menu App-menu_top`,children:[(0,K.jsxs)(Ey.Col,{gap:6,className:I(`App-menu_top__left`),children:[re(),n&&C()]}),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(0,K.jsx)(Yx,{heading:`shapes`,className:`shapes-section`,children:e=>(0,K.jsxs)(`div`,{style:{position:`relative`},children:[m&&(0,K.jsx)(b.WelcomeScreenToolbarHintTunnel.Out,{}),(0,K.jsx)(Ey.Col,{gap:4,align:`start`,children:(0,K.jsxs)(Ey.Row,{gap:1,className:I(`App-toolbar-container`,{"zen-mode":t.zenModeEnabled}),children:[(0,K.jsxs)(Hg,{padding:1,className:I(`App-toolbar`,{"zen-mode":t.zenModeEnabled}),children:[(0,K.jsx)(Gx,{appState:t,isMobile:y.editor.isMobile,device:y,app:g}),e,(0,K.jsxs)(Ey.Row,{gap:1,children:[(0,K.jsx)(nS,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>c(null),title:q(`toolBar.penMode`),penDetected:t.penDetected}),(0,K.jsx)(Jx,{checked:t.activeTool.locked,onChange:o,title:q(`toolBar.lock`)}),(0,K.jsx)(`div`,{className:`App-toolbar__divider`}),(0,K.jsx)(rS,{checked:Yr(t),onChange:()=>s(),title:q(`toolBar.hand`),isMobile:!0}),(0,K.jsx)(Ib,{appState:t,activeTool:t.activeTool,UIOptions:f,app:g})]})]}),_&&(0,K.jsx)(Hg,{style:{marginLeft:8,alignSelf:`center`,height:`fit-content`},children:(0,K.jsx)(yC,{title:q(`toolBar.laser`),checked:t.activeTool.type===hl.laser,onChange:()=>g.setActiveTool({type:hl.laser}),isMobile:!0})})]})})]})}),(0,K.jsxs)(`div`,{className:I(`layer-ui__wrapper__top-right zen-mode-transition`,{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&(0,K.jsx)(yS,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),u?.(y.editor.isMobile,t),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(!ae||t.openSidebar?.name!==uo.name)&&(0,K.jsx)(b.DefaultSidebarTriggerTunnel.Out,{}),r&&(0,K.jsx)(Pw,{app:g,onClose:()=>{e.executeAction(zv)},renderCustomStats:d})]})]})})},ie=()=>(0,K.jsx)(_C,{__fallback:!0,onDock:e=>{Y(`sidebar`,`toggleDock (${e?`dock`:`undock`})`,`(${y.editor.isMobile?`mobile`:`desktop`})`)}}),ae=xh(NS),oe=(0,K.jsxs)(K.Fragment,{children:[h,(0,K.jsx)(Rw,{UIOptions:f}),(0,K.jsx)(_C.Trigger,{__fallback:!0,icon:Qn,title:ro(q(`toolBar.library`)),onToggle:e=>{e&&Y(`sidebar`,`${uo.name} (open)`,`button (${y.editor.isMobile?`mobile`:`desktop`})`)},tab:uo.defaultTab,children:q(`toolBar.library`)}),(0,K.jsx)(zw,{}),t.openDialog?.name===`ttd`&&(0,K.jsx)(HC,{__fallback:!0}),t.isLoading&&(0,K.jsx)(Rh,{delay:250}),t.errorMessage&&(0,K.jsx)(yx,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),S&&!y.editor.isMobile&&(0,K.jsx)(Bg,{colorPickerType:S.colorPickerType,onCancel:()=>{ee(null)},onChange:(e,t,n,{altKey:i})=>{if(!(e!==`elementBackground`&&e!==`elementStroke`))if(n.length){for(let r of n)U(r,{[i&&S.swapPreviewOnAlt?e===`elementBackground`?`strokeColor`:`backgroundColor`:e===`elementBackground`?`backgroundColor`:`strokeColor`]:t},!1),za.delete(r);fa.getScene(n[0])?.triggerUpdate()}else r(e===`elementBackground`?{currentItemBackgroundColor:t}:{currentItemStrokeColor:t})},onSelect:(e,t)=>{ee(e=>e?.keepOpenOnAlt&&t.altKey?e:null),S?.onSelect?.(e,t)}}),t.openDialog?.name===`help`&&(0,K.jsx)(pS,{onClose:()=>{r({openDialog:null})}}),(0,K.jsx)(Ub,{}),t.openDialog?.name===`elementLinkSelector`&&(0,K.jsx)(Lw,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},elementsMap:g.scene.getNonDeletedElementsMap(),appState:t,generateLinkForSelection:v}),(0,K.jsx)(b.OverwriteConfirmDialogTunnel.Out,{}),ne(),te(),t.pasteDialog.shown&&(0,K.jsx)(oS,{setAppState:r,appState:t,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&(0,K.jsx)(iS,{app:g,appState:t,elements:i,actionManager:e,renderJSONExportDialog:te,renderImageExportDialog:ne,setAppState:r,onLockToggle:o,onHandToolToggle:s,onPenModeToggle:c,renderTopRightUI:u,renderCustomStats:d,renderSidebars:ie,device:y,renderWelcomeScreen:m,UIOptions:f}),!y.editor.isMobile&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`layer-ui__wrapper`,style:t.openSidebar&&ae&&y.editor.canFitSidebar?{width:`calc(100% - var(--right-sidebar-width))`}:{},children:[m&&(0,K.jsx)(b.WelcomeScreenCenterTunnel.Out,{}),w(),(0,K.jsx)(TS,{appState:t,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:m}),t.scrolledOutside&&(0,K.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Ht(i,e)}))},children:q(`buttons.scrollBackToContent`)})]}),ie()]})]});return(0,K.jsx)(Pg.Provider,{value:t,children:(0,K.jsx)(x,{children:(0,K.jsx)(kb.Provider,{value:b,children:oe})})})},Vw=e=>{let{suggestedBindings:t,startBoundElement:n,cursorButton:r,scrollX:i,scrollY:a,...o}=e;return o},Hw=G.memo(Bw,(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:r,...i}=e,{canvas:a,appState:o,...s}=t;return Rt(Vw(r),Vw(o),{selectedElementIds:Rt,selectedGroupIds:Rt})&&Rt(i,s)}),Uw=5e3,Ww=({message:e,onClose:t,closable:n=!1,duration:r=Uw,style:i})=>{let a=(0,G.useRef)(0),o=r!==1/0,s=(0,G.useCallback)(()=>{o&&(a.current=window.setTimeout(()=>t(),r))},[t,r,o]);return(0,G.useEffect)(()=>{if(o)return s(),()=>clearTimeout(a.current)},[s,e,r,o]),(0,K.jsxs)(`div`,{className:`Toast`,onMouseEnter:o?()=>clearTimeout(a?.current):void 0,onMouseLeave:o?s:void 0,style:i,children:[(0,K.jsx)(`p`,{className:`Toast__message`,children:e}),n&&(0,K.jsx)(J,{icon:Gc,"aria-label":`close`,type:`icon`,onClick:t,className:`close`})]})},Gw=P({name:`viewMode`,label:`labels.viewMode`,paletteName:`Toggle view mode`,icon:va,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:M.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,n)=>typeof n.viewModeEnabled>`u`,keyTest:e=>!e[F.CTRL_OR_CMD]&&e.altKey&&e.code===k.R}),Kw=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length===1&&D(n[0])},qw=P({name:`selectAllElementsInFrame`,label:`labels.selectAllElementsInFrame`,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;if(D(i)){let n=Pl(V(e),i.id).filter(e=>!(e.type===`text`&&e.containerId));return{elements:e,appState:{...t,selectedElementIds:n.reduce((e,t)=>(e[t.id]=!0,e),{})},captureUpdate:M.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:M.EVENTUALLY}},predicate:(e,t,n,r)=>Kw(t,r)}),Jw=P({name:`removeAllElementsFromFrame`,label:`labels.removeAllElementsFromFrame`,trackEvent:{category:`history`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;return D(i)?{elements:Ql(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},captureUpdate:M.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:M.EVENTUALLY}},predicate:(e,t,n,r)=>Kw(t,r)});P({name:`updateFrameRendering`,label:`labels.updateFrameRendering`,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:M.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),P({name:`setFrameAsActiveTool`,label:`toolBar.frame`,trackEvent:{category:`toolbar`},icon:Pc,viewMode:!1,perform:(e,t,n,r)=>{let i=Ha(t,{type:`frame`});return cl(r.interactiveCanvas,{...t,activeTool:i}),{elements:e,appState:{...t,activeTool:Ha(t,{type:`frame`})},captureUpdate:M.EVENTUALLY}},keyTest:e=>!e[F.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===F.F});var Yw=P({name:`wrapSelectionInFrame`,label:`labels.wrapSelectionInFrame`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=R(e,t);return i.length>0&&!i.some(e=>D(e))},perform:(e,t,n,r)=>{let i=R(e,t),[a,o,s,c]=Zo(i,r.scene.getNonDeletedElementsMap()),l=Qs({x:a-16,y:o-16,width:s-a+32,height:c-o+32});if(t.editingGroupId){let e=Ki(i,t.editingGroupId);for(let n of e){let e=n.groupIds.indexOf(t.editingGroupId);U(n,{groupIds:n.groupIds.slice(0,e)},!1)}}return{elements:Hc([...r.scene.getElementsIncludingDeleted(),l],i,l,t),appState:{selectedElementIds:{[l.id]:!0}},captureUpdate:M.IMMEDIATELY}}}),Xw=()=>(0,K.jsxs)(`div`,{"data-testid":`brave-measure-text-error`,children:[(0,K.jsx)(`p`,{children:(0,K.jsx)(Py,{i18nKey:`errors.brave_measure_text_error.line1`,bold:e=>(0,K.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,K.jsx)(`p`,{children:(0,K.jsx)(Py,{i18nKey:`errors.brave_measure_text_error.line2`,bold:e=>(0,K.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,K.jsx)(`p`,{children:(0,K.jsx)(Py,{i18nKey:`errors.brave_measure_text_error.line3`,link:e=>(0,K.jsx)(`a`,{href:`http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser`,children:e})})}),(0,K.jsx)(`p`,{children:(0,K.jsx)(Py,{i18nKey:`errors.brave_measure_text_error.line4`,issueLink:e=>(0,K.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw/issues/new`,children:e}),discordLink:e=>(0,K.jsxs)(`a`,{href:`https://discord.gg/UexuTaE`,children:[e,`.`]})})})]}),Zw={width:100,height:0},Qw=100,$w=(e,t,n)=>{let r=Wc({x:0,y:0,textAlign:cc.CENTER,verticalAlign:ll.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:`text`,id:r.id})}),Qo(r,e,n),[e,r]},eT=(e,t,n,r,i)=>{let a,o;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let n=t?.width??Qw,o=t?.height??Qw,s;t.id&&(s=r.getElement(t.id),s||console.error(`No element for start binding with id ${t.id} found`));let c=t.x||e.x-n,l=t.y||e.y-o/2,u=s?s.type:t.type;if(u){if(u===`text`){let n=``;s&&s.type===`text`?n=s.text:t.type===`text`&&(n=t.text),n||console.error(`No text found for start binding text element for ${e.id}`),a=Wc({x:c,y:l,type:`text`,...s,...t,text:n}),Object.assign(a,{x:t.x||e.x-a.width,y:t.y||e.y-a.height/2})}else switch(u){case`rectangle`:case`ellipse`:case`diamond`:a=Ua({x:c,y:l,width:n,height:o,...s,...t,type:u});break;default:es(e,`Unhandled element start type "${t.type}"`,!0)}be(e,a,`start`,i)}}if(n){let t=n?.height??Qw,a=n?.width??Qw,s;n.id&&(s=r.getElement(n.id),s||console.error(`No element for end binding with id ${n.id} found`));let c=n.x||e.x+e.width,l=n.y||e.y-t/2,u=s?s.type:n.type;if(u){if(u===`text`){let t=``;s&&s.type===`text`?t=s.text:n.type===`text`&&(t=n.text),t||console.error(`No text found for end binding text element for ${e.id}`),o=Wc({x:c,y:l,type:`text`,...s,...n,text:t}),Object.assign(o,{y:n.y||e.y-o.height/2})}else switch(u){case`rectangle`:case`ellipse`:case`diamond`:o=Ua({x:c,y:l,width:a,height:t,...s,...n,type:u});break;default:es(e,`Unhandled element end type "${u}"`,!0)}be(e,o,`end`,i)}}if(e.points.length<2)return{linearElement:e,startBoundElement:a,endBoundElement:o};let s=e.points.length-1,c=.5,l=ke(e.points);return e.points[s][0]>e.points[s-1][0]&&(l[0][0]=c,l[s][0]-=c),e.points[s][0]<e.points[s-1][0]&&(l[0][0]=-.5,l[s][0]+=c),e.points[s][1]>e.points[s-1][1]&&(l[0][1]=c,l[s][1]-=c),e.points[s][1]<e.points[s-1][1]&&(l[0][1]=-.5,l[s][1]+=c),Object.assign(e,{points:l}),{linearElement:e,startBoundElement:a,endBoundElement:o}},tT=class{constructor(){w(this,`excalidrawElements`,new Map),w(this,`add`,e=>{e&&this.excalidrawElements.set(e.id,e)}),w(this,`getElements`,()=>ja(Array.from(this.excalidrawElements.values()))),w(this,`getElementsMap`,()=>Un(E(this.getElements()))),w(this,`getElement`,e=>this.excalidrawElements.get(e))}},nT=(e,t)=>{if(!e)return[];let n=ke(e),r=new tT,i=new Map,a=new Map;for(let e of n){let n,o=e.id;switch(t?.regenerateIds!==!1&&Object.assign(e,{id:Yc()}),e.type){case`rectangle`:case`ellipse`:case`diamond`:{let t=e?.label?.text&&e.width===void 0?0:e?.width||Qw,r=e?.label?.text&&e.height===void 0?0:e?.height||Qw;n=Ua({...e,width:t,height:r});break}case`line`:{let t=e.width||Zw.width,r=e.height||Zw.height;n=ei({width:t,height:r,points:[O(0,0),O(t,r)],...e});break}case`arrow`:{let t=e.width||Zw.width,r=e.height||Zw.height;n=Jr({width:t,height:r,endArrowhead:`arrow`,points:[O(0,0),O(t,r)],...e,type:`arrow`}),Object.assign(n,mu(n.points));break}case`text`:{let t=e?.fontFamily||rr,r=e?.fontSize||20,i=e?.lineHeight||sa(t),a=ct(Ln(e.text??``),ko({fontFamily:t,fontSize:r}),i);n=Wc({width:a.width,height:a.height,fontFamily:t,fontSize:r,...e});break}case`image`:n=dn({width:e?.width||Qw,height:e?.height||Qw,...e});break;case`frame`:n=Qs({x:0,y:0,...e});break;case`magicframe`:n=_s({x:0,y:0,...e});break;case`freedraw`:case`iframe`:case`embeddable`:n=e;break;default:n=e,es(e,`Unhandled element type "${e.type}"`,!0)}r.getElement(n.id)?console.error(`Duplicate id found for ${n.id}`):(r.add(n),i.set(n.id,e),o&&a.set(o,n.id))}let o=r.getElementsMap();for(let[e,t]of i){let n=r.getElement(e);switch(t.type){case`rectangle`:case`ellipse`:case`diamond`:case`arrow`:if(t.label?.text){let[e,i]=$w(n,t?.label,o);if(r.add(e),r.add(i),xu(e)){let n=t.type===`arrow`?t?.start:void 0,i=t.type===`arrow`?t?.end:void 0;if(n&&n.id){let e=a.get(n.id);e&&Object.assign(n,{id:e})}if(i&&i.id){let e=a.get(i.id);e&&Object.assign(i,{id:e})}let{linearElement:s,startBoundElement:c,endBoundElement:l}=eT(e,n,i,r,o);e=s,r.add(s),r.add(c),r.add(l)}}else switch(t.type){case`arrow`:{let{start:e,end:i}=t;if(e&&e.id){let t=a.get(e.id);Object.assign(e,{id:t})}if(i&&i.id){let e=a.get(i.id);Object.assign(i,{id:e})}let{linearElement:s,startBoundElement:c,endBoundElement:l}=eT(n,e,i,r,o);r.add(s),r.add(c),r.add(l);break}}break}}for(let[e,t]of i){if(t.type!==`frame`&&t.type!==`magicframe`)continue;let n=r.getElement(e);if(!n)throw Error(`Excalidraw element with id ${e} doesn't exist`);let i=[];t.children.forEach(e=>{let t=a.get(e);if(!t)throw Error(`Element with ${e} wasn't mapped correctly`);let o=r.getElement(t);if(!o)throw Error(`Frame element with id ${t} doesn't exist`);Object.assign(o,{frameId:n.id}),o?.boundElements?.forEach(e=>{let t=r.getElement(e.id);if(!t)throw Error(`Bound element with id ${e.id} doesn't exist`);Object.assign(t,{frameId:n.id}),i.push(t)}),i.push(o)});let[o,s,c,l]=Zo(i);o-=10,s-=10,c+=10,l+=10;let u=n?.x||o,d=n?.y||s,f=n?.width||c-o,p=n?.height||l-s;Object.assign(n,{x:u,y:d,width:f,height:p}),ru()&&t.children.length&&(n?.x||n?.y||n?.width||n?.height)&&console.info(`User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically`)}return r.getElements()},rT=e=>t=>{(0,_d.unstable_batchedUpdates)(e,t)},iT=e=>gi(t=>{(0,_d.unstable_batchedUpdates)(e,t)}),aT=(()=>{let e;try{let t=G.version.split(`.`);e=Number(t[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn(`Excalidraw: render throttling is disabled on React versions < 18.`)),!1):!1})(),oT=`#ff6b6b`,sT=`#ff0000`,cT=1,lT=2,uT=(e,t)=>{if(!t.snapLines.length)return;let n=t.theme===j.LIGHT||t.zenModeEnabled?oT:sT,r=(t.zenModeEnabled?cT*1.5:cT)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let i of t.snapLines)i.type===`pointer`?(e.lineWidth=r,e.strokeStyle=n,fT(i,e,t)):i.type===`gap`?(e.lineWidth=r,e.strokeStyle=n,hT(i.points[0],i.points[1],i.direction,t,e)):i.type===`points`&&(e.lineWidth=r,e.strokeStyle=n,dT(i,e,t));e.restore()},dT=(e,t,n)=>{if(!n.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];mT(n,r,t)}for(let r of e.points)pT(r,n,t)},fT=(e,t,n)=>{pT(e.points[0],n,t),n.zenModeEnabled||mT(e.points[0],e.points[1],t)},pT=([e,t],n,r)=>{r.save();let i=(n.zenModeEnabled?lT*1.5:lT)/n.zoom.value;r.beginPath(),r.moveTo(e-i,t-i),r.lineTo(e+i,t+i),r.moveTo(e+i,t-i),r.lineTo(e-i,t+i),r.stroke(),r.restore()},mT=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},hT=(e,t,n,r,i)=>{let a=8/r.zoom.value,o=a/2,s=a/4;if(n===`horizontal`){let n=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||mT(O(e[0],e[1]-a),O(e[0],e[1]+a),i),mT(O(n[0]-s,n[1]-o),O(n[0]-s,n[1]+o),i),mT(O(n[0]+s,n[1]-o),O(n[0]+s,n[1]+o),i),r.zenModeEnabled||(mT(O(t[0],t[1]-a),O(t[0],t[1]+a),i),mT(e,t,i))}else{let n=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||mT(O(e[0]-a,e[1]),O(e[0]+a,e[1]),i),mT(O(n[0]-o,n[1]-s),O(n[0]+o,n[1]-s),i),mT(O(n[0]-o,n[1]+s),O(n[0]+o,n[1]+s),i),r.zenModeEnabled||(mT(O(t[0]-a,t[1]),O(t[0]+a,t[1]),i),mT(e,t,i))}},gT=(e,t)=>{jo(t.selectedLinearElement,`selectedLinearElement is null`);let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;jo(n,`midPointCoords is null`),e.save(),e.translate(t.scrollX,t.scrollY),vT(n,e,t),e.restore()},_T=(e,t,n)=>{let{elementId:r,hoverPointIndex:i}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(i))return;let a=N.getElement(r,n);if(!a)return;let o=N.getPointAtIndexGlobalCoordinates(a,i,n);e.save(),e.translate(t.scrollX,t.scrollY),vT(o,e,t),e.restore()},vT=(e,t,n)=>{t.fillStyle=`rgba(105, 101, 219, 0.4)`,Vr(t,e[0],e[1],N.POINT_HANDLE_SIZE/n.zoom.value,!1)},yT=(e,t,n,r,i,a,o,s,c=!1,l=0)=>{e.save(),e.translate(a,o),e.rotate(s),c&&e.fillRect(t-a,n-o,r,i),l&&e.roundRect?(e.beginPath(),e.roundRect(t-a,n-o,r,i,l),e.stroke(),e.closePath()):e.strokeRect(t-a,n-o,r,i),e.restore()},bT=(e,t,n,r,i,a)=>{e.save(),e.translate(r,i),e.rotate(a),e.beginPath(),e.moveTo(0,n/2),e.lineTo(t/2,0),e.lineTo(0,-n/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},xT=(e,t,n,r,i,a=!1)=>{e.strokeStyle=`#5e5ad8`,e.setLineDash([]),e.fillStyle=`rgba(255, 255, 255, 0.9)`,i?e.fillStyle=`rgba(134, 131, 226, 0.9)`:a&&(e.fillStyle=`rgba(177, 151, 252, 0.7)`),Vr(e,n[0],n[1],r/t.zoom.value,!a)},ST=(e,t,n,r,i,a)=>{e.beginPath(),e.ellipse(r,i,t/2,n/2,a,0,Math.PI*2),e.stroke()},CT=(e,t,n,r)=>{let[i,a,o,s]=Er(t,n),c=o-i,l=s-a;e.strokeStyle=`rgba(0,0,0,.05)`,e.lineWidth=10/(r.value<1?r.value:1);let u=e.lineWidth/2+4,d=Dn(Math.min(t.width,t.height),t);switch(t.type){case`rectangle`:case`text`:case`image`:case`iframe`:case`embeddable`:case`frame`:case`magicframe`:yT(e,i-u,a-u,c+u*2,l+u*2,i+c/2,a+l/2,t.angle,void 0,d);break;case`diamond`:let n=Math.hypot(c,l),r=u*n/l,o=u*n/c;bT(e,c+r*2,l+o*2,i+c/2,a+l/2,t.angle);break;case`ellipse`:ST(e,c+u*2,l+u*2,i+c/2,a+l/2,t.angle);break}},wT=(e,t,n,r)=>{let[i,a,o]=t,s=Di(o,o.width,o.height,r);e.strokeStyle=`rgba(0,0,0,0)`,e.fillStyle=`rgba(0,0,0,.05)`,(a===`both`?[0,-1]:a===`start`?[0]:[-1]).forEach(t=>{let[r,a]=N.getPointAtIndexGlobalCoordinates(i,t,n);Vr(e,r,a,s)})},TT=(e,t,n)=>{let{angle:r,x1:i,y1:a,x2:o,y2:s,selectionColors:c,cx:l,cy:u,dashed:d,activeEmbeddable:f}=n,p=o-i,m=s-a,h=(n.padding??4)/t.zoom.value,g=8/t.zoom.value,_=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(f?4:1)/t.zoom.value;let v=c.length;for(let t=0;t<v;++t)e.strokeStyle=c[t],d&&e.setLineDash([g,_+(g+_)*(v-1)]),e.lineDashOffset=(g+_)*t,yT(e,i-h,a-h,p+h*2,m+h*2,l,u,r);e.restore()},ET=(e,t,n,r)=>{let i=Array.isArray(n)?wT:CT;e.save(),e.translate(t.scrollX,t.scrollY),i(e,n,r,t.zoom),e.restore()},DT=(e,t,n,r)=>{let[i,a,o,s]=Er(n,r),c=o-i,l=s-a;e.strokeStyle=`rgb(0,118,255)`,e.lineWidth=In.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),yT(e,i,a,c,l,i+c/2,a+l/2,n.angle,!1,In.radius/t.zoom.value),e.restore()},OT=(e,t,n)=>{let r=n.filter(e=>e.groupIds.length===0),i=n.filter(e=>e.groupIds.length>0),a=e=>{let[t,n,r,i]=Zo(e);return{angle:0,x1:t,x2:r,y1:n,y2:i,selectionColors:[`rgb(0,118,255)`],dashed:!1,cx:t+(r-t)/2,cy:n+(i-n)/2,activeEmbeddable:!1}},o=e=>{let t=Ki(n,e);return a(t)};Object.entries(xn(i,t)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>o(e)).concat(r.map(e=>a([e]))).forEach(n=>TT(e,t,n))},kT=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let i=N.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:a}=N,o=t.editingLinearElement?a:a/2;if(i.forEach((r,a)=>{if(T(n)&&a!==0&&a!==i.length-1)return;let s=!!t.editingLinearElement?.selectedPointsIndices?.includes(a);xT(e,t,r,o,s)}),T(n)){let r=n.fixedSegments?.map(e=>e.index)||[];i.slice(0,-1).forEach((o,s)=>{N.isSegmentTooShort(n,i[s+1],i[s],s,t.zoom)||xT(e,t,O((o[0]+i[s+1][0])/2,(o[1]+i[s+1][1])/2),a/2,!1,!r.includes(s+1))})}else N.getEditorMidPoints(n,r,t).filter((e,t,r)=>e!==null&&!(T(n)&&(t===0||t===r.length-1))).forEach(n=>{(t.editingLinearElement||i.length===2)&&xT(e,t,n,a/2,!1,!0)});e.restore()},AT=(e,t,n,r,i)=>{Object.keys(r).forEach(a=>{let o=r[a];if(o!==void 0){let[r,s,c,l]=o;e.save(),e.lineWidth=1/n.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),a===`rotation`?Vr(e,r+c/2,s+l/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(r,s,c,l,2/n.zoom.value),e.fill(),e.stroke()):yT(e,r,s,c,l,r+c/2,s+l/2,i,!0),e.restore()}})},jT=(e,t,n,r,i)=>{let[a,o,,,s,c]=Er(r,i),l=3/n.zoom.value,u=l/2,d=s-a+l,f=c-o+l,p=Math.min(20/n.zoom.value,d),m=Math.min(20/n.zoom.value,f);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=l,[[[-d,-f],[0,u],[p,u],[u,0],[u,m]],[[d-u,-f],[u,u],[-p+u,u],[0,0],[0,m]],[[-d,f],[0,-u],[p,-u],[u,0],[u,-m]],[[d-u,f],[u,-u],[-p+u,-u],[0,0],[0,-m]]].forEach(t=>{let[[n,i],[a,o],[l,u],[d,f],[p,m]]=t;e.save(),e.translate(s,c),e.rotate(r.angle),e.beginPath(),e.moveTo(n+a,i+o),e.lineTo(n+l,i+u),e.stroke(),e.beginPath(),e.moveTo(n+d,i+f),e.lineTo(n+p,i+m),e.stroke(),e.restore()}),e.restore()},MT=(e,t,n,r)=>{t.save();let i=4/n.zoom.value,a=e.width+i*2,o=e.height+i*2,s=e.x+a/2,c=e.y+o/2,l=-(a/2+i),u=-(o/2+i);t.translate(s+n.scrollX,c+n.scrollY),t.rotate(e.angle),t.lineWidth=1/n.zoom.value,t.strokeStyle=r,t.strokeRect(l,u,a,o),t.restore()},NT=({canvas:e,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:a,appState:o,renderConfig:s,device:c})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[l,u]=Zn(e,a),d=wo({canvas:e,scale:a,normalizedWidth:l,normalizedHeight:u});d.save(),d.scale(o.zoom.value,o.zoom.value);let f;if(n.forEach(e=>{o.editingLinearElement?.elementId===e.id&&e&&(f=e)}),f&&kT(d,o,f,t),o.selectionElement&&!o.isCropping)try{ra(o.selectionElement,d,o,s.selectionColor)}catch(e){console.error(e)}if(o.editingTextElement&&L(o.editingTextElement)){let e=i.get(o.editingTextElement.id);e&&!e.autoResize&&MT(e,d,o,s.selectionColor)}o.isBindingEnabled&&o.suggestedBindings.filter(e=>e!=null).forEach(e=>{ET(d,o,e,t)}),o.frameToHighlight&&DT(d,o,o.frameToHighlight,t),o.elementsToHighlight&&OT(d,o,o.elementsToHighlight);let p=r.some(e=>D(e));if(r.length===1&&o.editingLinearElement?.elementId===r[0].id&&kT(d,o,r[0],t),T(r[0])&&o.selectedLinearElement&&o.selectedLinearElement.segmentMidPointHoveredCoords?gT(d,o):o.selectedLinearElement&&o.selectedLinearElement.hoverPointIndex>=0&&!(T(r[0])&&o.selectedLinearElement.hoverPointIndex>0&&o.selectedLinearElement.hoverPointIndex<r[0].points.length-1)&&_T(d,o,t),!o.multiElement&&!o.editingLinearElement){let e=Vi(r,o),n=r.length===1&&Ac(r[0]);n&&o.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&kT(d,o,r[0],t);let i=s.selectionColor||zc.black;if(e){let e=E(r),a=[];for(let r of t.values()){let c=[],l=s.remoteSelectedElementIds.get(r.id);if(n&&T(r)&&(r.startBinding||r.endBinding)||(e.has(r.id)&&!Fo(o,r)&&c.push(i),l&&c.push(...l.map(e=>mv(e,o.collaborators.get(e))))),c.length){let[e,n,i,s,u,d]=Er(r,t,!0);a.push({angle:r.angle,x1:e,y1:n,x2:i,y2:s,selectionColors:c,dashed:!!l,cx:u,cy:d,activeEmbeddable:o.activeEmbeddable?.element===r&&o.activeEmbeddable.state===`active`,padding:r.id===o.croppingElementId||Mo(r)?0:void 0})}}let c=e=>{let[n,r,i,o]=Zo(Ki(t,e));a.push({angle:0,x1:n,x2:i,y1:r,y2:o,selectionColors:[zc.black],dashed:!0,cx:n+(i-n)/2,cy:r+(o-r)/2,activeEmbeddable:!1})};for(let e of ot(o))c(e);o.editingGroupId&&c(o.editingGroupId),a.forEach(e=>TT(d,o,e))}if(d.save(),d.translate(o.scrollX,o.scrollY),r.length===1){d.fillStyle=zc.white;let n=oc(r[0],o.zoom,t,`mouse`,Ai(c));if(!o.viewModeEnabled&&e&&!L(o.editingTextElement)&&!o.croppingElementId&&AT(d,s,o,n,r[0].angle),o.croppingElementId&&!o.isCropping){let e=t.get(o.croppingElementId);e&&Mo(e)&&jT(d,s,o,e,t)}}else if(r.length>1&&!o.isRotating){let e=4/o.zoom.value;d.fillStyle=zc.white;let[t,n,a,l]=Zo(r),u=d.getLineDash();d.setLineDash([2/o.zoom.value]);let f=d.lineWidth;d.lineWidth=1/o.zoom.value,d.strokeStyle=i,yT(d,t-e,n-e,a-t+e*2,l-n+e*2,(t+a)/2,(n+l)/2,0),d.lineWidth=f,d.setLineDash(u);let m=Ye([t,n,a,l,(t+a)/2,(n+l)/2],0,o.zoom,`mouse`,p?{...Ai(c),rotation:!0}:Ai(c));r.some(e=>!e.locked)&&AT(d,s,o,m,0)}d.restore()}o.searchMatches.forEach(({id:e,focus:n,matchedLines:r})=>{let i=t.get(e);if(i&&L(i)){let[e,a,,,s,c]=Er(i,t,!0);d.save(),o.theme===j.LIGHT?n?d.fillStyle=`rgba(255, 124, 0, 0.4)`:d.fillStyle=`rgba(255, 226, 0, 0.4)`:n?d.fillStyle=`rgba(229, 82, 0, 0.4)`:d.fillStyle=`rgba(99, 52, 0, 0.4)`,d.translate(o.scrollX,o.scrollY),d.translate(s,c),d.rotate(i.angle),r.forEach(t=>{d.fillRect(e+t.offsetX-s,a+t.offsetY-c,t.width,t.height)}),d.restore()}}),uT(d,o),d.restore(),gv({context:d,renderConfig:s,appState:o,normalizedWidth:l,normalizedHeight:u});let m;return s.renderScrollbars&&(m=$x(n,l,u,o),d.save(),d.fillStyle=Qx,d.strokeStyle=`rgba(255,255,255,0.8)`,[m.horizontal,m.vertical].forEach(e=>{e&&fv(d,e.x,e.y,e.width,e.height,Zx/2)}),d.restore()),{scrollBars:m,atLeastOneVisibleElement:n.length>0,elementsMap:t}},PT=gi(e=>{let t=NT(e);e.callback?.(t)},{trailing:!0}),FT=(e,t)=>{if(t){PT(e);return}let n=NT(e);return e.callback(n),n},IT=e=>{let t=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(!t.current){t.current=!0;return}let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map;e.appState.collaborators.forEach((t,s)=>{if(t.selectedElementIds)for(let e of Object.keys(t.selectedElementIds))i.has(e)||i.set(e,[]),i.get(e).push(s);!t.pointer||t.pointer.renderCursor===!1||(t.username&&a.set(s,t.username),t.userState&&o.set(s,t.userState),r.set(s,Zr({sceneX:t.pointer.x,sceneY:t.pointer.y},e.appState)),n.set(s,t.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue(`--color-selection`)||`#6965db`;FT({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:o,selectionColor:s,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},aT())}),(0,K.jsx)(`canvas`,{className:`excalidraw__canvas interactive`,style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?W.GRAB:W.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:q(`labels.drawingCanvas`)})},LT=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches}),RT=G.memo(IT,(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:Rt(LT(e.appState),LT(t.appState))),zT=e=>{let t=(0,G.useRef)(null),n=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{let r=t.current;if(!r)return;let i=e.canvas;n.current||(n.current=!0,r.replaceChildren(i),i.classList.add(`excalidraw__canvas`,`static`));let a=`${e.appState.width}px`,o=`${e.appState.height}px`;i.style.width!==a&&(i.style.width=a),i.style.height!==o&&(i.style.height=o);let s=e.appState.width*e.scale,c=e.appState.height*e.scale;i.width!==s&&(i.width=s),i.height!==c&&(i.height=c),du({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},aT())}),(0,K.jsx)(`div`,{className:`excalidraw__canvas-wrapper`,ref:t})},BT=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),VT=G.memo(zT,(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Rt(BT(e.appState),BT(t.appState))&&Rt(e.renderConfig,t.renderConfig)),HT=class{constructor(e){w(this,`scene`),w(this,`getRenderableElements`,(()=>{let e=({elementsMap:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s})=>{let c=[];for(let l of e.values())wr(l,s,o,{zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a},e)&&c.push(l);return c},t=({elements:e,editingTextElement:t,newElementId:n,pendingImageElementId:r})=>{let i=Un(new Map);for(let a of e)Mo(a)&&r===a.id||n!==a.id&&(!t||t.type!==`text`||a.id!==t.id)&&i.set(a.id,a);return i};return ia(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o,height:s,width:c,editingTextElement:l,newElementId:u,pendingImageElementId:d,sceneNonce:f})=>{let p=this.scene.getNonDeletedElements(),m=t({elements:p,editingTextElement:l,newElementId:u,pendingImageElementId:d});return{elementsMap:m,visibleElements:e({elementsMap:m,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o,height:s,width:c})}})})()),this.scene=e}destroy(){PT.cancel(),Oc.cancel(),this.getRenderableElements.clear()}},UT=({trails:e})=>{let t=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,K.jsx)(`div`,{className:`SVGLayer`,children:(0,K.jsx)(`svg`,{ref:t})})},WT=5,GT=(e,t,n)=>{let[r,i]=Er(e,n),{x:a,y:o}=Zr({sceneX:r+e.width,sceneY:i},t);return{x:a-t.offsetLeft+10,y:o-t.offsetTop}},KT=({children:e,element:t,elementsMap:n})=>{let r=xE();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:i,y:a}=GT(t,r,n);return(0,K.jsx)(`div`,{className:`excalidraw-canvas-buttons`,style:{top:`${a}px`,left:`${i}px`,padding:WT},children:e})},qT=`small`,JT=e=>(0,K.jsxs)(`label`,{className:I(`ToolIcon ToolIcon__MagicButton`,`ToolIcon_size_${qT}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,K.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),(0,K.jsx)(`div`,{className:`ToolIcon__icon`,children:e.icon})]}),YT=({height:e,width:t,userToFollow:n,onDisconnect:r})=>(0,K.jsx)(`div`,{className:`follow-mode`,style:{width:t,height:e},children:(0,K.jsxs)(`div`,{className:`follow-mode__badge`,children:[(0,K.jsxs)(`div`,{className:`follow-mode__badge__label`,children:[`Following`,` `,(0,K.jsx)(`span`,{className:`follow-mode__badge__username`,title:n.username,children:n.username})]}),(0,K.jsx)(`button`,{type:`button`,onClick:r,className:`follow-mode__disconnect-btn`,children:Gc})]})}),XT=class{constructor(){w(this,`targets`,new WeakMap),w(this,`rafIds`,new WeakMap)}register(e,t){this.targets.set(e,{callback:t,stopped:!0})}start(e){let t=this.targets.get(e);t&&(this.rafIds.has(e)||(this.targets.set(e,{...t,stopped:!1}),this.scheduleFrame(e)))}stop(e){let t=this.targets.get(e);t&&!t.stopped&&this.targets.set(e,{...t,stopped:!0}),this.cancelFrame(e)}constructFrame(e){return t=>{let n=this.targets.get(e);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(e):this.cancelFrame(e)}}scheduleFrame(e){let t=requestAnimationFrame(this.constructFrame(e));this.rafIds.set(e,t)}cancelFrame(e){if(this.rafIds.has(e)){let t=this.rafIds.get(e);cancelAnimationFrame(t)}this.rafIds.delete(e)}onFrame(e,t){return e.callback(t)??!1}},ZT=class{constructor(e,t,n){this.animationFrameHandler=e,this.app=t,this.options=n,w(this,`currentTrail`),w(this,`pastTrails`,[]),w(this,`container`),w(this,`trailElement`),this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(xl,`path`)}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(e,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===e&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(e){e&&(this.container=e),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(e,t){this.currentTrail=new _h(this.options),this.currentTrail.addPoint([e,t,performance.now()]),this.update()}addPointToPath(e,t){this.currentTrail&&(this.currentTrail.addPoint([e,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){let e=[];for(let t of this.pastTrails)e.push(this.drawTrail(t,this.app.state));if(this.currentTrail){let t=this.drawTrail(this.currentTrail,this.app.state);e.push(t)}this.pastTrails=this.pastTrails.filter(e=>e.getStrokeOutline().length!==0),e.length===0&&this.stop();let t=e.join(` `).trim();this.trailElement.setAttribute(`d`,t),this.trailElement.setAttribute(`fill`,(this.options.fill??(()=>`black`))(this))}drawTrail(e,t){return yo(e.getStrokeOutline(e.options.size/t.zoom.value).map(([e,n])=>{let r=Zr({sceneX:e,sceneY:n},t);return[r.x,r.y]}),!0)}},QT=class{constructor(e,t){this.animationFrameHandler=e,this.app=t,w(this,`localTrail`),w(this,`collabTrails`,new Map),w(this,`container`),this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new ZT(e,t,{...this.getTrailOptions(),fill:()=>`red`})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/1e3),n=(50-Math.min(50,e.totalLength-e.currentIndex))/50;return Math.min(yu(n),yu(t))}}}startPath(e,t){this.localTrail.startPath(e,t)}addPointToPath(e,t){this.localTrail.addPointToPath(e,t)}endPath(){this.localTrail.endPath()}start(e){this.container=e,this.animationFrameHandler.start(this),this.localTrail.start(e)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[e,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(e)?n=this.collabTrails.get(e):(n=new ZT(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||mv(e,t)}),n.start(this.container),this.collabTrails.set(e,n)),t.pointer&&t.pointer.tool===`laser`&&(t.button===`down`&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button===`down`&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button===`up`&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let e of this.collabTrails.keys())this.app.state.collaborators.has(e)||(this.collabTrails.get(e).stop(),this.collabTrails.delete(e))}}},$T=(e,t,n,r,i,a)=>{let{zoom:o}=r,s=180*n/Math.PI,c=e*(o.value-1)/2,l=t*(o.value-1)/2;return e>i&&o.value!==1&&(c=i*(o.value-1)/2),t>a&&o.value!==1&&(l=a*(o.value-1)/2),`translate(${c}px, ${l}px) scale(${o.value}) rotate(${s}deg)`},eE=({id:e,onChange:t,onSubmit:n,getViewportCoords:r,element:i,canvas:a,excalidrawContainer:o,app:s,autoSelect:c=!0})=>{let l=(e,t)=>{if(!t.style.fontFamily||!t.style.fontSize)return!1;let n=t.style.fontFamily.replace(/"/g,``);return Mr({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize},u=()=>{let t=s.state,n=fa.getScene(i)?.getElement(e);if(!n)return;let{textAlign:a,verticalAlign:o}=n,c=s.scene.getNonDeletedElementsMap();if(n&&L(n)){let e=n.x,i=n.y,u=ce(n,s.scene.getNonDeletedElementsMap()),f=n.width,p=n.height,m=n.width,h=n.height;if(u&&n.containerId){if(xu(u)){let t=N.getBoundTextElementPosition(u,n,c);e=t.x,i=t.y}let t=l(n,d),r;if(t?r=sn(u.id,u.height):(r=tc[u.id],r||=sn(u.id,u.height)),m=jl(u,n),h=Yl(u,n),!xu(u)&&p>h){U(u,{height:vr(p,u.type)});return}else if(!xu(u)&&u.height>r.height&&p<h)U(u,{height:vr(p,u.type)});else{let{y:e}=Mi(u,n,c);i=e}}let[g,_]=r(e,i),v=d.selectionStart,y=d.selectionEnd,b=d.value.length;if(v===y&&y!==b){let e=b-y;d.selectionStart=d.value.length-e,d.selectionEnd=d.value.length-e}u?f+=.5:(m=(t.width-8-g)/t.zoom.value,f=Math.min(f,m)),p*=1.05;let x=ko(n),S=(t.height-_)/t.zoom.value;Object.assign(d.style,{font:x,lineHeight:n.lineHeight,width:`${f}px`,height:`${p}px`,left:`${g}px`,top:`${_}px`,transform:$T(f,p,$o(n,u),t,m,S),textAlign:a,verticalAlign:o,color:n.strokeColor,opacity:n.opacity/100,filter:`var(--theme-filter)`,maxHeight:`${S}px`}),d.scrollTop=0,Xe()&&(d.style.fontFamily=Mr(n)),U(n,{x:e,y:i})}},d=document.createElement(`textarea`);d.dir=`auto`,d.tabIndex=0,d.dataset.type=`wysiwyg`,d.wrap=`off`,d.classList.add(`excalidraw-wysiwyg`);let f=`pre`,p=`normal`;(Ls(i)||!i.autoResize)&&(f=`pre-wrap`,p=`break-word`),Object.assign(d.style,{position:`absolute`,display:`inline-block`,minHeight:`1em`,backfaceVisibility:`hidden`,margin:0,padding:0,border:0,outline:0,resize:`none`,background:`transparent`,overflow:`hidden`,zIndex:`var(--zIndex-wysiwyg)`,wordBreak:p,whiteSpace:f,overflowWrap:`break-word`,boxSizing:`content-box`}),d.value=i.originalText,u(),t&&(d.onpaste=async e=>{let t=await zi(e,!0);if(!t.text)return;let n=Ln(t.text);if(!n)return;let r=ce(i,s.scene.getNonDeletedElementsMap()),a=ko({fontSize:s.state.currentItemFontSize,fontFamily:s.state.currentItemFontFamily});if(r){let e=Mn(r,s.scene.getNonDeletedElementsMap()),t=gr(bi(`${d.value}${n}`,a,jl(r,e)),a);d.style.width=`${t}px`}},d.oninput=()=>{let e=Ln(d.value);if(d.value!==e){let t=d.selectionStart;d.value=e,d.selectionStart=t,d.selectionEnd=t}t(d.value)}),d.onkeydown=e=>{if(!e.shiftKey&&P_.keyTest(e))e.preventDefault(),s.actionManager.executeAction(P_),u();else if(!e.shiftKey&&F_.keyTest(e))e.preventDefault(),s.actionManager.executeAction(F_),u();else if(!e.shiftKey&&I_.keyTest(e))e.preventDefault(),s.actionManager.executeAction(I_),u();else if(T_.keyTest(e))s.actionManager.executeAction(T_);else if(E_.keyTest(e))s.actionManager.executeAction(E_);else if(e.key===F.ESCAPE)e.preventDefault(),b=!0,x();else if(e.key===F.ENTER&&e[F.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||e.keyCode===229)return;b=!0,x()}else if(e.key===F.TAB||e[F.CTRL_OR_CMD]&&(e.code===k.BRACKET_LEFT||e.code===k.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===k.BRACKET_LEFT?_():g(),d.dispatchEvent(new Event(`input`))}};let m=` `.repeat(4),h=RegExp(`^ {1,4}`),g=()=>{let{selectionStart:e,selectionEnd:t}=d,n=v(),r=d.value;n.forEach(e=>{let t=r.slice(0,e),n=r.slice(e);r=`${t}${m}${n}`}),d.value=r,d.selectionStart=e+4,d.selectionEnd=t+4*n.length},_=()=>{let{selectionStart:e,selectionEnd:t}=d,n=v(),r=[],i=d.value;n.forEach(e=>{let t=i.slice(e,e+4).match(h);t&&(i=`${i.slice(0,e)}${i.slice(e+t[0].length)}`,r.push(e))}),d.value=i,r.length&&(e>r[r.length-1]?d.selectionStart=Math.max(e-4,r[r.length-1]):d.selectionStart=e,d.selectionEnd=Math.max(d.selectionStart,t-4*r.length))},v=()=>{let{selectionStart:e,selectionEnd:t,value:n}=d,r=n.slice(0,e).match(/[^\n]*$/)[0].length;return e-=r,n.slice(e,t).split(`
|
|
15
|
+
`).reduce((t,n,r,i)=>t.concat(r?t[r-1]+i[r-1].length+1:e),[]).reverse()},y=e=>{e.target instanceof HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},b=!1,x=()=>{if(w)return;w=!0,S();let e=fa.getScene(i)?.getElement(i.id);if(!e)return;let t=ce(e,s.scene.getNonDeletedElementsMap());if(t){if(d.value.trim()){let e=kl(t);!e||e!==i.id?U(t,{boundElements:(t.boundElements||[]).concat({type:`text`,id:i.id})}):xu(t)&&pe(t)}else U(t,{boundElements:t.boundElements?.filter(e=>!L(e))});Qo(e,t,s.scene.getNonDeletedElementsMap())}n({viaKeyboard:b,nextOriginalText:d.value})},S=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,ie&&ie.disconnect(),window.removeEventListener(`resize`,u),window.removeEventListener(`wheel`,y,!0),window.removeEventListener(`pointerdown`,ne),window.removeEventListener(`pointerup`,ee),window.removeEventListener(`blur`,x),window.removeEventListener(`beforeunload`,x),re(),C(),d.remove()},ee=e=>{window.removeEventListener(`pointerup`,ee);let t=e?.target,n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`);setTimeout(()=>{d.onblur=x,n||d.focus()})},te=()=>{d.onblur=null,window.addEventListener(`pointerup`,ee),window.addEventListener(`blur`,x)},ne=e=>{let t=e?.target;if(e.button===bc.WHEEL){t instanceof HTMLTextAreaElement&&(e.preventDefault(),s.handleCanvasPanUsingWheelOrSpaceDrag(e)),te();return}let n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`);(e.target instanceof HTMLElement||e.target instanceof SVGElement)&&e.target.closest(`.${hc.SHAPE_ACTIONS_MENU}, .${hc.ZOOM_ACTIONS}`)&&!$t(e.target)||n?te():e.target instanceof HTMLCanvasElement&&!Xe()&&requestAnimationFrame(()=>{x()})},re=s.scene.onUpdate(()=>{u(),document.activeElement?.closest(`.properties-content`)||d.focus()}),C=s.onScrollChangeEmitter.on(()=>{u()}),w=!1;c&&d.select(),ee();let ie=null;a&&`ResizeObserver`in window?(ie=new window.ResizeObserver(()=>{u()}),ie.observe(a)):window.addEventListener(`resize`,u),d.onpointerdown=e=>e.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener(`pointerdown`,ne,{capture:!0})}),window.addEventListener(`beforeunload`,x),o?.querySelector(`.excalidraw-textEditorContainer`).appendChild(d)},tE=P({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=R(e,t);return i.length===1&&L(i[0])&&!i[0].autoResize},perform:(e,t,n,r)=>{let i=R(e,t);return{appState:t,elements:e.map(e=>{if(e.id===i[0].id&&L(e)){let t=ct(e.originalText,ko(e),e.lineHeight);return H(e,{autoResize:!0,width:t.width,height:t.height,text:e.originalText})}return e}),captureUpdate:M.IMMEDIATELY}}}),nE=e=>RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${[`flowchart`,`graph`,`sequenceDiagram`,`classDiagram`,`stateDiagram`,`stateDiagram-v2`,`erDiagram`,`journey`,`gantt`,`pie`,`quadrantChart`,`requirementDiagram`,`gitGraph`,`C4Context`,`mindmap`,`timeline`,`zenuml`,`sankey`,`xychart`,`block`].map(e=>`\\s*${e}(-beta)?`).join(`|`)})\\b`).test(e.trim()),rE=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let[c,l]=Zn(e,a),u=wo({canvas:e,scale:a,normalizedWidth:c,normalizedHeight:l});u.save(),u.scale(o.zoom.value,o.zoom.value),n&&n.type!==`selection`?lt(n,r,i,t,u,s,o):u.clearRect(0,0,c,l)}},iE=gi(e=>{rE(e)},{trailing:!0}),aE=(e,t)=>{if(t){iE(e);return}rE(e)},oE=e=>{let t=(0,G.useRef)(null);return(0,G.useEffect)(()=>{t.current&&aE({canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},aT())}),(0,K.jsx)(`canvas`,{className:`excalidraw__canvas`,style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},sE=G.createContext(null),cE=G.createContext(null),lE={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},uE=G.createContext(lE);uE.displayName=`DeviceContext`;var dE=G.createContext({container:null,id:null});dE.displayName=`ExcalidrawContainerContext`;var fE=G.createContext([]);fE.displayName=`ExcalidrawElementsContext`;var pE=G.createContext({...Na(),width:0,height:0,offsetLeft:0,offsetTop:0});pE.displayName=`ExcalidrawAppStateContext`;var mE=G.createContext(()=>{console.warn(`Uninitialized ExcalidrawSetAppStateContext context!`)});mE.displayName=`ExcalidrawSetAppStateContext`;var hE=G.createContext(null);hE.displayName=`ExcalidrawActionManagerContext`;var gE=()=>(0,G.useContext)(sE),_E=()=>(0,G.useContext)(cE),vE=()=>(0,G.useContext)(uE),yE=()=>(0,G.useContext)(dE),bE=()=>(0,G.useContext)(fE),xE=()=>(0,G.useContext)(pE),SE=()=>(0,G.useContext)(mE),CE=()=>(0,G.useContext)(hE),wE=!1,TE=0,EE=!1,DE=!1,OE=!1,kE={horizontal:null,vertical:null},AE=0,jE=!1,ME=new Map,NE=!1,PE=0,FE=!1,IE=null,$={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},LE=class e extends G.Component{constructor(t){super(t),w(this,`canvas`),w(this,`interactiveCanvas`,null),w(this,`rc`),w(this,`unmounted`,!1),w(this,`actionManager`),w(this,`device`,lE),w(this,`excalidrawContainerRef`,G.createRef()),w(this,`scene`),w(this,`fonts`),w(this,`renderer`),w(this,`visibleElements`),w(this,`resizeObserver`),w(this,`nearestScrollableContainer`),w(this,`library`),w(this,`libraryItemsFromStorage`),w(this,`id`),w(this,`store`),w(this,`history`),w(this,`excalidrawContainerValue`),w(this,`files`,{}),w(this,`imageCache`,new Map),w(this,`iFrameRefs`,new Map),w(this,`embedsValidationStatus`,new Map),w(this,`initializedEmbeds`,new Set),w(this,`elementsPendingErasure`,new Set),w(this,`flowChartCreator`,new Hx),w(this,`flowChartNavigator`,new Vx),w(this,`hitLinkElement`),w(this,`lastPointerDownEvent`,null),w(this,`lastPointerUpEvent`,null),w(this,`lastPointerMoveEvent`,null),w(this,`lastPointerMoveCoords`,null),w(this,`lastViewportPosition`,{x:0,y:0}),w(this,`animationFrameHandler`,new XT),w(this,`laserTrails`,new QT(this.animationFrameHandler,this)),w(this,`eraserTrail`,new ZT(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/200),n=(10-Math.min(10,e.totalLength-e.currentIndex))/10;return Math.min(yu(n),yu(t))},fill:()=>this.state.theme===j.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`})),w(this,`onChangeEmitter`,new Wr),w(this,`onPointerDownEmitter`,new Wr),w(this,`onPointerUpEmitter`,new Wr),w(this,`onUserFollowEmitter`,new Wr),w(this,`onScrollChangeEmitter`,new Wr),w(this,`missingPointerEventCleanupEmitter`,new Wr),w(this,`onRemoveEventListenersEmitter`,new Wr),w(this,`getEffectiveGridSize`,()=>ul(this)?this.state.gridSize:null),w(this,`updateEmbedValidationStatus`,(e,t)=>{this.embedsValidationStatus.set(e.id,t),za.delete(e)}),w(this,`updateEmbeddables`,()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if(dt(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=Hs(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else gu(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),w(this,`getFrameNameDOMId`,e=>`${this.id}-frame-name-${e.id}`),w(this,`frameNameBoundsCache`,{get:e=>{let t=this.frameNameBoundsCache._cache.get(e.id);if(!t||t.zoom!==this.state.zoom.value||t.versionNonce!==e.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(e));if(n){let r=n.getBoundingClientRect(),i=gl({clientX:r.x,clientY:r.y},this.state),a=gl({clientX:r.right,clientY:r.bottom},this.state);return t={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:e.versionNonce},this.frameNameBoundsCache._cache.set(e.id,t),t}return null}return t},_cache:new Map}),w(this,`resetEditingFrame`,e=>{e&&U(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),w(this,`renderFrameNames`,()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===j.DARK;return this.scene.getNonDeletedFramesLikes().map(t=>{if(!wr(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===t.id&&this.resetEditingFrame(t),null;let{x:n,y:r}=Zr({sceneX:t.x,sceneY:t.y},this.state),i,a=Is(t);if(t.id===this.state.editingFrame){let r=a;i=(0,K.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>{U(t,{name:e.target.value})},onFocus:e=>e.target.select(),onBlur:()=>this.resetEditingFrame(t),onKeyDown:e=>{(e.key===F.ESCAPE||e.key===F.ENTER)&&this.resetEditingFrame(t)},style:{background:this.state.viewBackgroundColor,filter:e?ns:`none`,zIndex:2,border:`none`,display:`block`,padding:`6px`,borderRadius:4,boxShadow:`inset 0 0 0 1px var(--color-primary)`,fontFamily:`Assistant`,fontSize:`14px`,transform:`translate(-6px, 6px)`,color:`var(--color-gray-80)`,overflow:`hidden`,maxWidth:`${document.body.clientWidth-n-6}px`},size:r.length+1||1,dir:`auto`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`})}else i=a;return(0,K.jsx)(`div`,{id:this.getFrameNameDOMId(t),style:{position:`absolute`,bottom:`${this.state.height+In.nameOffsetY-r+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:In.nameFontSize,color:e?In.nameColorDarkTheme:In.nameColorLightTheme,lineHeight:In.nameLineHeight,width:`max-content`,maxWidth:`${t.width}px`,overflow:t.id===this.state.editingFrame?`visible`:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,cursor:W.MOVE,pointerEvents:this.state.viewModeEnabled?Kc.disabled:Kc.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onWheel:e=>this.handleWheel(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:i},t.id)})}),w(this,`focusContainer`,()=>{this.excalidrawContainerRef.current?.focus()}),w(this,`getSceneElementsIncludingDeleted`,()=>this.scene.getElementsIncludingDeleted()),w(this,`getSceneElements`,()=>this.scene.getNonDeletedElements()),w(this,`onInsertElements`,e=>{this.addElementsFromPasteOrLibrary({elements:e,position:`center`,files:null})}),w(this,`onExportImage`,async(e,t,n)=>{Y(`export`,e,`ui`);let r=await q_(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(rt).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&r&&_i(r)&&this.setState({fileHandle:r})}),w(this,`magicGenerations`,new Map),w(this,`updateMagicGeneration`,({frameElement:e,data:t})=>{t.status===`pending`?U(e,{customData:{generationData:void 0}},!1):U(e,{customData:{generationData:t}},!1),this.magicGenerations.set(e.id,t),this.triggerRender()}),w(this,`plugins`,{}),w(this,`onMagicframeToolSelect`,()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(e.length===0)this.setActiveTool({type:hl.magicframe}),Y(`ai`,`tool-select (empty-selection)`,`d2c`);else{let t=e.length===1&&$e(e[0])&&e[0];if(!t&&e.some(e=>D(e)||e.frameId)){this.setActiveTool({type:hl.magicframe});return}Y(`ai`,`tool-select (existing selection)`,`d2c`);let n;if(t)n=t;else{let[t,r,i,a]=Zo(e);n=_s({...In,x:t-50,y:r-50,width:i-t+100,height:a-r+100,opacity:100,locked:!1}),this.scene.insertElement(n);for(let t of e)U(t,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,`upstream`)}}),w(this,`openEyeDropper`,({type:e})=>{wh.set(zg,{swapPreviewOnAlt:!0,colorPickerType:e===`stroke`?`elementStroke`:`elementBackground`,onSelect:(t,n)=>{let r=e===`background`&&n.altKey||e===`stroke`&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!==`selection`?r?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:t},captureUpdate:M.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:t},captureUpdate:M.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(e=>this.state.selectedElementIds[e.id]?H(e,{[r?`strokeColor`:`backgroundColor`]:t}):e),captureUpdate:M.IMMEDIATELY})},keepOpenOnAlt:!1})}),w(this,`dismissLinearEditor`,()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})}),w(this,`syncActionResult`,rT(e=>{if(this.unmounted||e===!1)return;e.captureUpdate===M.NEVER?this.store.shouldUpdateSnapshot():e.captureUpdate===M.IMMEDIATELY&&this.store.shouldCaptureIncrement();let t=!1,n=null;if(e.elements&&(this.scene.replaceAllElements(e.elements),t=!0),e.files&&(this.addMissingFiles(e.files,e.replaceFiles),this.addNewImagesToImageCache()),e.appState||n||this.state.contextMenu){let r=e?.appState?.viewModeEnabled||!1,i=e?.appState?.zenModeEnabled||!1,a=e?.appState?.theme||this.props.theme||j.LIGHT,o=e?.appState?.name??this.state.name,s=e?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<`u`&&(r=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<`u`&&(i=this.props.zenModeEnabled),n=e.appState?.editingTextElement||null,e.elements&&n&&e.elements.forEach(e=>{n?.id===e.id&&n!==e&&Pe(e)&&L(e)&&(n=e)}),n?.isDeleted&&(n=null),this.setState(t=>{let c=e.appState||{};return{...t,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:r,zenModeEnabled:i,theme:a,name:o,errorMessage:s}}),t=!0}!t&&e.captureUpdate!==M.EVENTUALLY&&this.scene.triggerUpdate()})),w(this,`onBlur`,rT(()=>{EE=!1,this.setState({isBindingEnabled:!0})})),w(this,`onUnload`,()=>{this.onBlur()}),w(this,`disableEvent`,e=>{e.preventDefault()}),w(this,`resetHistory`,()=>{this.history.clear()}),w(this,`resetStore`,()=>{this.store.clear()}),w(this,`resetScene`,rT(e=>{this.scene.replaceAllElements([]),this.setState(t=>({...Na(),isLoading:e?.resetLoadingState?!1:t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),w(this,`initializeScene`,async()=>{`launchQueue`in window&&`LaunchParams`in window&&window.launchQueue.setConsumer(async e=>{if(!e.files.length)return;let t=e.files[0],n=await t.getFile();this.loadFileToCanvas(new File([n],n.name||``,{type:n.type}),t)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let e=null;try{e=typeof this.props.initialData==`function`?await this.props.initialData()||null:await this.props.initialData||null,e?.libraryItems&&this.library.updateLibrary({libraryItems:e.libraryItems,merge:!0}).catch(e=>{console.error(e)})}catch(t){console.error(t),e={appState:{errorMessage:t.message||`Encountered an error during importing or restoring scene data`}}}let t=vt(e,null,null,{repairBindings:!0});t.appState={...t.appState,theme:this.props.theme||t.appState.theme,openSidebar:t.appState?.openSidebar||this.state.openSidebar,activeTool:t.appState.activeTool.type===`image`?{...t.appState.activeTool,type:`selection`}:t.appState.activeTool,isLoading:!1,toast:this.state.toast},e?.scrollToContent&&(t.appState={...t.appState,...Ht(t.elements,{...t.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...t,captureUpdate:M.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),sr(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})}),w(this,`isMobileBreakpoint`,(e,t)=>e<730||t<500&&e<1e3),w(this,`refreshViewportBreakpoints`,()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:e,clientHeight:t}=document.body,n=this.device.viewport,r=nc(n,{isLandscape:e>t,isMobile:this.isMobileBreakpoint(e,t)});return n===r?!1:(this.device={...this.device,viewport:r},!0)}),w(this,`refreshEditorBreakpoints`,()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),r=this.props.UIOptions.dockedSidebarBreakpoint==null?Bn:this.props.UIOptions.dockedSidebarBreakpoint,i=this.device.editor,a=nc(i,{isMobile:this.isMobileBreakpoint(t,n),canFitSidebar:t>r});return i===a?!1:(this.device={...this.device,editor:a},!0)}),w(this,`onResize`,rT(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>za.delete(e)),this.refreshViewportBreakpoints(),this.updateDOMRect(),qs||this.refreshEditorBreakpoints(),this.setState({})})),w(this,`onFullscreenChange`,()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),w(this,`renderInteractiveSceneCallback`,({atLeastOneVisibleElement:e,scrollBars:t,elementsMap:n})=>{t&&(kE=t);let r=this.state.editingTextElement?!1:!e&&n.size>0;this.state.scrolledOutside!==r&&this.setState({scrolledOutside:r}),this.scheduleImageRefresh()}),w(this,`onScroll`,Zc(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},100)),w(this,`onCut`,rT(e=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||$t(e.target)||(this.actionManager.executeAction(Mv,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),w(this,`onCopy`,rT(e=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||$t(e.target)||(this.actionManager.executeAction(Av,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),w(this,`onTouchStart`,t=>{if(hi&&t.preventDefault(),!wE){wE=!0,clearTimeout(TE),TE=window.setTimeout(e.resetTapTwice,300);return}if(wE&&t.touches.length===1){let e=t.touches[0];this.handleCanvasDoubleClick({clientX:e.clientX,clientY:e.clientY}),wE=!1,clearTimeout(TE)}t.touches.length===2&&this.setState({selectedElementIds:A({},this.state),activeEmbeddable:null})}),w(this,`onTouchEnd`,e=>{this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:A(this.state.previousSelectedElementIds,this.state)}):$.pointers.clear()}),w(this,`pasteFromClipboard`,rT(async e=>{let t=!!NE,n=document.activeElement,r=this.excalidrawContainerRef.current?.contains(n);if(e&&!r)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(e&&(!(i instanceof HTMLCanvasElement)||$t(n)))return;let{x:a,y:o}=gl({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),s=e?.clipboardData?.files[0],c=await zi(e,t);if(!s&&!t){if(c.mixedContent)return this.addElementsFromMixedContentPaste(c.mixedContent,{isPlainPaste:t,sceneX:a,sceneY:o});if(c.text){let e=c.text.trim();e.startsWith(`<svg`)&&e.endsWith(`</svg>`)&&(s=nu(e))}}if(kt(s)&&!c.spreadsheet){if(!this.isToolSupported(`image`)){this.setState({errorMessage:q(`errors.imageToolNotSupported`)});return}let e=this.createImageElement({sceneX:a,sceneY:o});this.insertImageElement(e,s),this.initializeImageDimensions(e),this.setState({selectedElementIds:A({[e.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(c,e)===!1)return}catch(e){console.error(e)}if(c.errorMessage)this.setState({errorMessage:c.errorMessage});else if(c.spreadsheet&&!t)this.setState({pasteDialog:{data:c.spreadsheet,shown:!0}});else if(c.elements){let e=c.programmaticAPI?nT(c.elements):c.elements;this.addElementsFromPasteOrLibrary({elements:e,files:c.files||null,position:`cursor`,retainSeed:t})}else if(c.text){if(c.text&&nE(c.text)){let e=await v(()=>import(`./dist-DAGGreTm.js`),__vite__mapDeps([64,2,65,61,66,67,62,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]));try{let{elements:t,files:n={}}=await e.parseMermaidToExcalidraw(c.text),r=nT(t,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:r,files:n,position:`cursor`});return}catch(e){console.warn(`parsing pasted text as mermaid definition failed: ${e.message}`)}}let e=Rs(c.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),n=e.map(e=>Fs(e)).filter(e=>Hs(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||ds(e)?.type===`video`));if(!NE&&n.length>0&&n.length===e.length){let e=[];for(let t of n){let n=e[e.length-1],r=this.insertEmbeddableElement({sceneX:n?n.x+n.width+20:a,sceneY:o,link:ms(t)});r&&e.push(r)}e.length&&this.setState({selectedElementIds:Object.fromEntries(e.map(e=>[e.id,!0]))});return}this.addTextFromPaste(c.text,t)}this.setActiveTool({type:`selection`}),e?.preventDefault()})),w(this,`addElementsFromPasteOrLibrary`,e=>{let t=ml(e.elements,null,void 0),[n,r,i,a]=Zo(t),o=dr(n,i)/2,s=dr(r,a)/2,{x:c,y:l}=gl({clientX:typeof e.position==`object`?e.position.clientX:e.position===`cursor`?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,clientY:typeof e.position==`object`?e.position.clientY:e.position===`cursor`?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop},this.state),[u,d]=kr(c-o,l-s,this.getEffectiveGridSize()),f=Ie(t.map(e=>H(e,{x:e.x+u-n,y:e.y+d-r})),{randomizeSeed:!e.retainSeed}),p=this.scene.getElementsIncludingDeleted(),m=[...p,...f];m=this.props.onDuplicate?.(m,p)||m,bs(m,E(f));let h=this.getTopLayerFrameAtSceneCoords({x:c,y:l});if(h){let e=Xo(f,h);Hc(m,e,h,this.state)}this.scene.replaceAllElements(m),f.forEach(e=>{L(e)&&Ls(e)&&Qo(e,ce(e,this.scene.getElementsMapIncludingDeleted()),this.scene.getElementsMapIncludingDeleted())}),Go&&ao.loadElementsFonts(f).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files),this.store.shouldCaptureIncrement();let g=Fc(f);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&wh.get(NS)?this.state.openSidebar:null,...xt({editingGroupId:null,selectedElementIds:g.reduce((e,t)=>(Ls(t)||(e[t.id]=!0),e),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:`selection`}),e.fitToContent&&this.scrollToContent(f,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})}),w(this,`setAppState`,(e,t)=>{this.setState(e,t)}),w(this,`removePointer`,e=>{AE&&this.resetContextMenuTimer(),$.pointers.delete(e.pointerId)}),w(this,`toggleLock`,(e=`ui`)=>{this.state.activeTool.locked||Y(`toolbar`,`toggleLock`,`${e} (${this.device.editor.isMobile?`mobile`:`desktop`})`),this.setState(e=>({activeTool:{...e.activeTool,...Ha(this.state,e.activeTool.locked?{type:`selection`}:e.activeTool),locked:!e.activeTool.locked}}))}),w(this,`updateFrameRendering`,e=>{this.setState(t=>{let n=typeof e==`function`?e(t.frameRendering):e;return{frameRendering:{enabled:n?.enabled??t.frameRendering.enabled,clip:n?.clip??t.frameRendering.clip,name:n?.name??t.frameRendering.name,outline:n?.outline??t.frameRendering.outline}}})}),w(this,`togglePenMode`,e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0}))}),w(this,`onHandToolToggle`,()=>{this.actionManager.executeAction(V_)}),w(this,`zoomCanvas`,e=>{this.setState({...O_({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Ur(e)},this.state)})}),w(this,`cancelInProgressAnimation`,null),w(this,`scrollToContent`,(e=this.scene.getNonDeletedElements(),t)=>{if(typeof e==`string`){let n;if(n=sr(e)?Rn(e):e,n){let r=this.scene.getElementsFromId(n);r?.length?this.scrollToContent(r,{fitToContent:t?.fitToContent??!0,animate:t?.animate??!0}):sr(e)&&this.setState({toast:{message:q(`elementLink.notFound`),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(e)?e:[e],r=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(t?.fitToContent||t?.fitToViewport){let{appState:e}=z_({canvasOffsets:t.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!t?.fitToViewport,viewportZoomFactor:t?.viewportZoomFactor,minZoom:t?.minZoom,maxZoom:t?.maxZoom});r=e.zoom,i=e.scrollX,a=e.scrollY}else{let e=Ht(n,this.state);i=e.scrollX,a=e.scrollY}if(t?.animate){let e=this.state.scrollX,n=this.state.scrollY,o=this.state.zoom.value,s=Ml({fromValues:{scrollX:e,scrollY:n,zoom:o},toValues:{scrollX:i,scrollY:a,zoom:r.value},interpolateValue:(e,t,n,r)=>{if(r===`zoom`)return e*(t/e)**+yu(n)},onStep:({scrollX:e,scrollY:t,zoom:n})=>{this.setState({scrollX:e,scrollY:t,zoom:{value:n}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:t?.duration??500});this.cancelInProgressAnimation=()=>{s(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:i,scrollY:a,zoom:r})}),w(this,`maybeUnfollowRemoteUser`,()=>{this.state.userToFollow&&this.setState({userToFollow:null})}),w(this,`translateCanvas`,e=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(e)}),w(this,`setToast`,e=>{this.setState({toast:e})}),w(this,`restoreFileFromShare`,async()=>{try{let e=await caches.open(`web-share-target`),t=await e.match(`shared-file`);if(t){let n=await t.blob(),r=new File([n],n.name||``,{type:n.type});this.loadFileToCanvas(r,null),await e.delete(`shared-file`),window.history.replaceState(null,Sa,window.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),w(this,`addFiles`,rT(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),w(this,`addMissingFiles`,(e,t=!1)=>{let n=t?{}:{...this.files},r={},i=Array.isArray(e)?e:Object.values(e);for(let e of i)if(!n[e.id]&&(r[e.id]=e,n[e.id]=e,e.mimeType===Pr.svg))try{let t=il(wn(ys(e.dataURL)),Pr.svg);e.dataURL!==t&&(e.version=(e.version??1)+1,e.dataURL=t)}catch(e){console.error(e)}return this.files=n,{addedFiles:r}}),w(this,`updateScene`,rT(e=>{let t=ja(e.elements??[]);if(e.captureUpdate&&e.captureUpdate!==M.EVENTUALLY){let n=this.store.snapshot.appState,r=this.store.snapshot.elements,i=e.appState?Object.assign({},n,e.appState):n,a=e.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),E(t)):r;e.captureUpdate===M.IMMEDIATELY?this.store.captureIncrement(a,i):e.captureUpdate===M.NEVER&&this.store.updateSnapshot(a,i)}e.appState&&this.setState(e.appState),e.elements&&this.scene.replaceAllElements(t),e.collaborators&&this.setState({collaborators:e.collaborators})})),w(this,`triggerRender`,e=>{e===!0?this.scene.triggerUpdate():this.setState({})}),w(this,`toggleSidebar`,({name:e,tab:t,force:n})=>{let r;r=n===void 0?this.state.openSidebar?.name===e&&this.state.openSidebar?.tab===t?null:e:n?e:null;let i=r?{name:r}:null;return i&&t&&(i.tab=t),this.setState({openSidebar:i}),!!r}),w(this,`updateCurrentCursorPosition`,rT(e=>{this.lastViewportPosition.x=e.clientX,this.lastViewportPosition.y=e.clientY})),w(this,`getEditorUIOffsets`,()=>{let e=this.excalidrawContainerRef?.current?.querySelector(`.App-toolbar`)?.getBoundingClientRect()?.bottom??0,t=this.excalidrawContainerRef?.current?.querySelector(`.sidebar`)?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(`.App-menu__left`)?.getBoundingClientRect();return Nh().rtl?{top:e+16,right:Math.max(this.state.width-(n?.left??this.state.width),0)+16,bottom:16,left:Math.max(t?.right??0,0)+16}:{top:e+16,right:Math.max(this.state.width-(t?.left??this.state.width)+16,0),bottom:16,left:Math.max(n?.right??0,0)+16}}),w(this,`onKeyDown`,rT(e=>{if(`Proxy`in window&&(!e.shiftKey&&/^[A-Z]$/.test(e.key)||e.shiftKey&&/^[a-z]$/.test(e.key))&&(e=new Proxy(e,{get(t,n){let r=t[n];return typeof r==`function`?r.bind(t):n===`key`?e.shiftKey?t.key.toUpperCase():t.key.toLowerCase():r}})),!kc(e.target)){if((e.key===F.ESCAPE||e.key===F.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let t=R(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&Mo(t[0])&&e.key===F.ENTER){this.startImageCropping(t[0]);return}if(e.key===F.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let n=hu(e.key);if(e[F.CTRL_OR_CMD]&&n&&!e.shiftKey){e.preventDefault();let t=R(this.scene.getNonDeletedElementsMap(),this.state);t.length===1&&He(t[0])&&this.flowChartCreator.createNodes(t[0],this.scene.getNonDeletedElementsMap(),this.state,Nx(e.key)),this.flowChartCreator.pendingNodes?.length&&!Se(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(e.altKey){let t=R(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&n){e.preventDefault();let n=this.flowChartNavigator.exploreByDirection(t[0],this.scene.getNonDeletedElementsMap(),Nx(e.key));if(n){this.setState(e=>({selectedElementIds:A({[n]:!0},e)}));let e=this.scene.getNonDeletedElementsMap().get(n);e&&!Se([e],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(e,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(e[F.CTRL_OR_CMD]&&e.key===F.P&&!e.shiftKey&&!e.altKey){this.setToast({message:q(`commandPalette.shortcutHint`,{shortcut:wb(`commandPalette`)})}),e.preventDefault();return}if(e[F.CTRL_OR_CMD]&&e.key.toLowerCase()===F.V&&(NE=e.shiftKey,clearTimeout(PE),PE=window.setTimeout(()=>{NE=!1},100)),e[F.CTRL_OR_CMD]&&$t(e.target)&&(e.code===k.MINUS||e.code===k.EQUAL)){e.preventDefault();return}if($t(e.target)&&e.key!==F.ESCAPE||hu(e.key)&&kc(e.target))return;if(e.key===F.QUESTION_MARK){this.setState({openDialog:{name:`help`}});return}else if(e.key.toLowerCase()===F.E&&e.shiftKey&&e[F.CTRL_OR_CMD]){e.preventDefault(),this.setState({openDialog:{name:`imageExport`}});return}if(e.key===F.PAGE_UP||e.key===F.PAGE_DOWN){let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;e.key===F.PAGE_DOWN&&(t=-t),e.shiftKey?this.translateCanvas(e=>({scrollX:e.scrollX+t})):this.translateCanvas(e=>({scrollY:e.scrollY+t}))}if(this.state.openDialog?.name===`elementLinkSelector`||this.actionManager.handleKeyDown(e)||this.state.viewModeEnabled)return;if(e[F.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),hu(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=t.find(T),r=new Set;t.filter(T).filter(e=>{let n=e.startBinding&&!t.some(t=>t.id===e.startBinding?.elementId),r=e.endBinding&&!t.some(t=>t.id===e.endBinding?.elementId);return n||r}).forEach(e=>r.add(e.id)),t=t.filter(e=>!r.has(e.id));let i=this.getEffectiveGridSize()&&(e.shiftKey?1:this.getEffectiveGridSize())||(e.shiftKey?5:1),a=0,o=0;e.key===F.ARROW_LEFT?a=-i:e.key===F.ARROW_RIGHT?a=i:e.key===F.ARROW_UP?o=-i:e.key===F.ARROW_DOWN&&(o=i),t.forEach(e=>{U(e,{x:e.x+a,y:e.y+o},!1),Io(e,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:t})}),this.setState({suggestedBindings:or(t.filter(e=>e.id!==n?.id||i!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===F.ENTER){let t=this.scene.getSelectedElements(this.state);if(t.length===1){let n=t[0];if(e[F.CTRL_OR_CMD])Ac(n)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==t[0].id)&&(this.store.shouldCaptureIncrement(),T(n)||this.setState({editingLinearElement:new N(n)}));else if(L(n)||Ee(n)){let t;L(n)||(t=n);let r=wc(n,this.state,this.scene.getNonDeletedElementsMap()),i=r.x,a=r.y;this.startTextEditing({sceneX:i,sceneY:a,container:t}),e.preventDefault();return}else D(n)&&this.setState({editingFrame:n.id})}}else if(!e.ctrlKey&&!e.altKey&&!e.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let t=gs(e.key);t?(this.state.activeTool.type!==t&&Y(`toolbar`,t,`keyboard (${this.device.editor.isMobile?`mobile`:`desktop`})`),t===`arrow`&&this.state.activeTool.type===`arrow`&&this.setState(e=>({currentItemArrowType:e.currentItemArrowType===Ri.sharp?Ri.round:e.currentItemArrowType===Ri.round?Ri.elbow:Ri.sharp})),this.setActiveTool({type:t}),e.stopPropagation()):e.key===F.Q&&(this.toggleLock(`keyboard`),e.stopPropagation())}if(e.key===F.SPACE&&$.pointers.size===0&&(EE=!0,z(this.interactiveCanvas,W.GRAB),e.preventDefault()),(e.key===F.G||e.key===F.S)&&!e.altKey&&!e[F.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;e.key===F.G&&(ou(this.state.activeTool.type)||t.some(e=>ou(e.type)))&&(this.setState({openPopup:`elementBackground`}),e.stopPropagation()),e.key===F.S&&(this.setState({openPopup:`elementStroke`}),e.stopPropagation())}if(!e[F.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===F.F){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;(this.state.activeTool.type===`text`||t.find(e=>L(e)||Mn(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:`fontFamily`}))}if(e.key===F.K&&!e.altKey&&!e[F.CTRL_OR_CMD]){this.state.activeTool.type===`laser`?this.setActiveTool({type:`selection`}):this.setActiveTool({type:`laser`});return}e[F.CTRL_OR_CMD]&&(e.key===F.BACKSPACE||e.key===F.DELETE)&&wh.set(Hb,`clearCanvas`);let t=e.key.toLocaleLowerCase(),n=t===F.S&&e.shiftKey,r=e.key===F.I||t===F.G&&e.shiftKey;(n||r)&&this.openEyeDropper({type:n?`stroke`:`background`})})),w(this,`onKeyUp`,rT(e=>{if(e.key===F.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`?z(this.interactiveCanvas,W.GRAB):this.state.activeTool.type===`selection`?pi(this.interactiveCanvas):(cl(this.interactiveCanvas,this.state),this.setState({selectedElementIds:A({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),EE=!1),!e[F.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),hu(e.key)&&(Ge(this.scene.getSelectedElements(this.state).filter(Ac),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,We(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),e.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:M.IMMEDIATELY})),!e[F.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let e=this.flowChartCreator.pendingNodes?.[0];e&&(this.setState(t=>({selectedElementIds:A({[e.id]:!0},t)})),Se([e],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(e,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:M.IMMEDIATELY})}})),w(this,`isToolSupported`,e=>this.props.UIOptions.tools?.[e]!==!1),w(this,`setActiveTool`,e=>{if(!this.isToolSupported(e.type)){console.warn(`"${e.type}" tool is disabled via "UIOptions.canvasActions.tools.${e.type}"`);return}let t=Ha(this.state,e);t.type===`hand`?z(this.interactiveCanvas,W.GRAB):EE||cl(this.interactiveCanvas,{...this.state,activeTool:t}),Vn(document.activeElement)&&this.focusContainer(),Bl(t.type)||this.setState({suggestedBindings:[]}),t.type===`image`&&this.onImageAction({insertOnCanvasDirectly:(e.type===`image`&&e.insertOnCanvasDirectly)??!1}),this.setState(e=>{let n={snapLines:e.snapLines.length?[]:e.snapLines,originSnapOffset:null,activeEmbeddable:null};return t.type===`freedraw`&&this.store.shouldCaptureIncrement(),t.type===`selection`?{...e,activeTool:t,...n}:{...e,activeTool:t,selectedElementIds:A({},e),selectedGroupIds:A({},e),editingGroupId:null,multiElement:null,...n}})}),w(this,`setOpenDialog`,e=>{this.setState({openDialog:e})}),w(this,`setCursor`,e=>{z(this.interactiveCanvas,e)}),w(this,`resetCursor`,()=>{pi(this.interactiveCanvas)}),w(this,`isTouchScreenMultiTouchGesture`,()=>$.pointers.size>=2),w(this,`getName`,()=>this.state.name||this.props.name||`${q(`labels.untitled`)}-${nt()}`),w(this,`onGestureStart`,rT(e=>{e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:A({},this.state),activeEmbeddable:null}),$.initialScale=this.state.zoom.value})),w(this,`onGestureChange`,rT(e=>{if(e.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let t=$.initialScale;t&&this.setState(n=>({...O_({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Ur(t*e.scale)},n)}))})),w(this,`onGestureEnd`,rT(e=>{e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:A(this.state.previousSelectedElementIds,this.state)}),$.initialScale=null})),w(this,`startTextEditing`,({sceneX:e,sceneY:t,insertAtParentCenter:n=!0,container:r,autoEdit:i=!0})=>{let a=!1,o=n&&this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r);r&&o&&(Mn(r,this.scene.getNonDeletedElementsMap())||(a=!0));let s=null,c=this.scene.getSelectedElements(this.state);s=c.length===1?L(c[0])?c[0]:r?Mn(c[0],this.scene.getNonDeletedElementsMap()):this.getTextElementAtPosition(e,t):this.getTextElementAtPosition(e,t);let l=s?.fontFamily||this.state.currentItemFontFamily,u=s?.lineHeight||sa(l),d=this.state.currentItemFontSize;if(!s&&a&&r&&!xu(r)){let n=Ws(ko({fontSize:d,fontFamily:l}),u),i=bu(d,u),a=Math.max(r.height,i),s=Math.max(r.width,n);U(r,{height:a,width:s}),e=r.x+s/2,t=r.y+a/2,o&&=this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r)}let f=this.getTopLayerFrameAtSceneCoords({x:e,y:t}),p=s||Wc({x:o?o.elementCenterX:e,y:o?o.elementCenterY:t,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:``,fontSize:d,fontFamily:l,textAlign:o?`center`:this.state.currentItemTextAlign,verticalAlign:o?ll.MIDDLE:`top`,containerId:a?r?.id:void 0,groupIds:r?.groupIds??[],lineHeight:u,angle:r?.angle??0,frameId:f?f.id:null});if(!s&&a&&r&&U(r,{boundElements:(r.boundElements||[]).concat({type:`text`,id:p.id})}),this.setState({editingTextElement:p}),!s)if(r&&a){let e=this.scene.getElementIndex(r.id);this.scene.insertElementAtIndex(p,e+1)}else this.scene.insertElement(p);i||s||r?this.handleTextWysiwyg(p,{isExistingElement:!!s}):this.setState({newElement:p,multiElement:null})}),w(this,`startImageCropping`,e=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:e.id})}),w(this,`finishImageCropping`,()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))}),w(this,`handleCanvasDoubleClick`,e=>{if(this.state.multiElement||this.state.activeTool.type!==`selection`)return;let t=this.scene.getSelectedElements(this.state),{x:n,y:r}=gl(e,this.state);if(t.length===1&&Ac(t[0])){if(e[F.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==t[0].id)&&!T(t[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new N(t[0])});return}else if(this.state.selectedLinearElement&&T(t[0])){let e=N.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),i=e?N.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(i&&i>-1){this.store.shouldCaptureIncrement(),N.deleteFixedSegment(t[0],i);let a=N.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),o=a?N.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,a,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:o,value:e,added:!1}},segmentMidPointHoveredCoords:a}});return}}}if(t.length===1&&Mo(t[0])){this.startImageCropping(t[0]);return}if(pi(this.interactiveCanvas),ot(this.state).length>0){let e=this.getElementAtPosition(n,r),t=e&&lc(e,this.state.selectedGroupIds);if(t){this.store.shouldCaptureIncrement(),this.setState(n=>({...n,...xt({editingGroupId:t,selectedElementIds:{[e.id]:!0}},this.scene.getNonDeletedElements(),n,this)}));return}}if(pi(this.interactiveCanvas),!e[F.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let t=this.getElementAtPosition(n,r);if(Oo(t)){this.setState({activeEmbeddable:{element:t,state:`active`}});return}let i=this.getTextBindableContainerAtPosition(n,r);if(i&&(Ja(i)||!na(i.backgroundColor)||Rl({x:n,y:r,element:i,shape:Cs(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let e=wc(i,this.state,this.scene.getNonDeletedElementsMap());n=e.x,r=e.y}this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:i})}}),w(this,`getElementLinkAtPosition`,(e,t)=>{let n=this.scene.getNonDeletedElements(),r=-1;for(let i=n.length-1;i>=0;i--){let a=n[i];if(t&&a.id===t.id&&(r=i),a.link&&i>=r&&Yn(a,this.scene.getNonDeletedElementsMap(),this.state,O(e.x,e.y),this.device.editor.isMobile))return a}}),w(this,`redirectToLink`,(e,t)=>{let n=Kn(O(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),O(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>10)return;let r=gl(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Yn(this.hitLinkElement,i,this.state,O(r.x,r.y),this.device.editor.isMobile),o=gl(this.lastPointerUpEvent,this.state),s=Yn(this.hitLinkElement,i,this.state,O(o.x,o.y),this.device.editor.isMobile);if(a&&s){iy();let t=this.hitLinkElement.link;if(t){t=ms(t);let n;if(this.props.onLinkOpen&&(n=ir(`excalidraw-link`,e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=Oa(t)?`_self`:`_blank`,n=window.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),w(this,`getTopLayerFrameAtSceneCoords`,e=>{let t=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(n=>Us(e,n,t));return n.length?n[n.length-1]:null}),w(this,`handleCanvasPointerMove`,e=>{this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent,$.pointers.has(e.pointerId)&&$.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=$.initialScale;if($.pointers.size===2&&$.lastCenter&&t&&$.initialDistance){let e=px($.pointers),n=e.x-$.lastCenter.x,r=e.y-$.lastCenter.y;$.lastCenter=e;let i=mx(Array.from($.pointers.values())),a=this.state.activeTool.type===`freedraw`&&this.state.penMode?1:i/$.initialDistance,o=a?Ur(t*a):this.state.zoom.value;this.setState(t=>{let i=O_({viewportX:e.x,viewportY:e.y,nextZoom:o},t);this.translateCanvas({zoom:i.zoom,scrollX:i.scrollX+n/o*2,scrollY:i.scrollY+r/o*2,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else $.lastCenter=$.initialDistance=$.initialScale=null;if(EE||DE||OE||Yr(this.state))return;let n=eS(kE,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(n?pi(this.interactiveCanvas):cl(this.interactiveCanvas,this.state));let r=gl(e,this.state),{x:i,y:a}=r;if(!this.state.newElement&&Gi(this.state.activeTool.type)){let{originOffset:t,snapLines:n}=ht(this.scene.getNonDeletedElements(),this,{x:i,y:a},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let r=oe(e.snapLines,n),i=e.originSnapOffset?oe(e.originSnapOffset,t):t;return e.snapLines===r&&e.originSnapOffset===i?null:{snapLines:r,originSnapOffset:i}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(e=>e.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let t=N.handlePointerMove(e,i,a,this,this.scene.getNonDeletedElementsMap());t&&t!==this.state.editingLinearElement&&(0,_d.flushSync)(()=>{this.setState({editingLinearElement:t})}),t?.lastUncommittedPoint==null?(0,_d.flushSync)(()=>{this.setState({suggestedBindings:[]})}):this.maybeSuggestBindingAtCursor(r,t.elbowed)}if(is(this.state.activeTool.type)){let{newElement:e}=this.state;Jt(e,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(e,[r],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(r,!1)}if(this.state.multiElement){let{multiElement:t}=this.state,{x:n,y:r}=t,{points:o,lastCommittedPoint:s}=t,c=o[o.length-1];if(cl(this.interactiveCanvas,this.state),c===s)Kn(O(i-n,a-r),c)>=8?U(t,{points:[...o,O(i-n,a-r)]},!1):z(this.interactiveCanvas,W.POINTER);else if(o.length>2&&s&&Kn(O(i-n,a-r),s)<8)z(this.interactiveCanvas,W.POINTER),U(t,{points:o.slice(0,-1)},!1);else{let[s,c]=kr(i,a,e[F.CTRL_OR_CMD]||T(t)?null:this.getEffectiveGridSize()),[l,u]=t?.lastCommittedPoint??[0,0],d=s-n-l,f=c-r-u;Xa(e)&&({width:d,height:f}=cr(l+n,u+r,s,c)),ye(o,this.state.zoom.value)&&z(this.interactiveCanvas,W.POINTER),U(t,{points:[...o.slice(0,-1),O(l+d,u+f)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(e.buttons||this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`eraser`)return;let o=this.scene.getNonDeletedElements(),s=this.scene.getSelectedElements(this.state);if(s.length===1&&!n&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,i,a),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!==`elementLinkSelector`&&!(s.length===1&&T(s[0]))){let t=Za(o,this.state,i,a,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(t&&t.transformHandleType){z(this.interactiveCanvas,Yo(t));return}}}else if(s.length>1&&!n&&this.state.openDialog?.name!==`elementLinkSelector`){let t=as(Zo(s),i,a,this.state.zoom,e.pointerType,this.device);if(t){z(this.interactiveCanvas,Yo({transformHandleType:t}));return}}let c=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,c),!it(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(z(this.interactiveCanvas,W.POINTER),ny(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(iy(),c&&(c.link||dt(c))&&this.state.selectedElementIds[c.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:`info`}):this.state.activeTool.type===`text`?z(this.interactiveCanvas,L(c)?W.TEXT:W.CROSSHAIR):this.state.viewModeEnabled?z(this.interactiveCanvas,W.GRAB):this.state.openDialog?.name===`elementLinkSelector`||n?z(this.interactiveCanvas,W.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,i,a):e[F.CTRL_OR_CMD]?z(this.interactiveCanvas,W.AUTO):(c||this.isHittingCommonBoundingBoxOfSelectedElements(r,s))&&!c?.locked&&(c&&Oo(c)&&this.isIframeLikeElementCenter(c,e,i,a)?(z(this.interactiveCanvas,W.POINTER),this.setState({activeEmbeddable:{element:c,state:`hover`}})):(!c||!T(c))&&(z(this.interactiveCanvas,W.MOVE),this.state.activeEmbeddable?.state===`hover`&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name===`elementLinkSelector`&&c?this.setState(e=>({hoveredElementIds:oe(e.hoveredElementIds,xt({editingGroupId:e.editingGroupId,selectedElementIds:{[c.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name===`elementLinkSelector`&&!c&&this.setState(e=>({hoveredElementIds:oe(e.hoveredElementIds,{})})))}),w(this,`handleEraser`,(e,t,n)=>{this.eraserTrail.addPointToPath(n.x,n.y);let r=!1,i=new Set,a=this.scene.getNonDeletedElements(),o=t=>{for(let n of t){if(n.locked)return;if(e.altKey?this.elementsPendingErasure.delete(n.id)&&(r=!0):this.elementsPendingErasure.has(n.id)||(r=!0,this.elementsPendingErasure.add(n.id)),r&&n.groupIds?.length){let t=n.groupIds.at(-1);if(!i.has(t)){i.add(t);let n=Ki(a,t);for(let t of n)e.altKey?this.elementsPendingErasure.delete(t.id):this.elementsPendingErasure.add(t.id)}}}},s=Kn(O(t.lastCoords.x,t.lastCoords.y),O(n.x,n.y)),c=this.getElementHitThreshold(),l={...t.lastCoords},u=0;for(;u<=s&&(o(this.getElementsAtPosition(l.x,l.y)),u!==s);){u=Math.min(u+c,s);let e=u/s,t=(1-e)*l.x+e*n.x,r=(1-e)*l.y+e*n.y;l.x=t,l.y=r}if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r){for(let t of this.scene.getNonDeletedElements())Ls(t)&&(this.elementsPendingErasure.has(t.id)||this.elementsPendingErasure.has(t.containerId))&&(e.altKey?(this.elementsPendingErasure.delete(t.id),this.elementsPendingErasure.delete(t.containerId)):(this.elementsPendingErasure.add(t.id),this.elementsPendingErasure.add(t.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}}),w(this,`handleTouchMove`,e=>{jE=!0}),w(this,`handleCanvasPointerDown`,e=>{let t=e.target;if(t.setPointerCapture&&t.setPointerCapture(e.pointerId),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(e=>({searchMatches:e.searchMatches.map(e=>({...e,focus:!1}))})),wh.set(aC,null)),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(e),e.pointerType===`touch`&&this.state.newElement&&this.state.newElement.type===`freedraw`){let e=this.state.newElement;this.updateScene({...e.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:A(Object.keys(this.state.selectedElementIds).filter(t=>t!==e.id).reduce((e,t)=>(e[t]=this.state.selectedElementIds[t],e),{}),this.state)},captureUpdate:this.state.openDialog?.name===`elementLinkSelector`?M.EVENTUALLY:M.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(e),!this.state.penDetected&&e.pointerType===`pen`&&this.setState(e=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&[`pen`,`touch`].includes(e.pointerType)&&(this.device=nc(this.device,{isTouchScreen:!0})),DE||(this.lastPointerDownEvent=e,this.handleCanvasPanUsingWheelOrSpaceDrag(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:`down`}),this.savePointer(e.clientX,e.clientY,`down`),e.button===bc.ERASER&&this.state.activeTool.type!==hl.eraser){this.setState({activeTool:Ha(this.state,{type:hl.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),r?.(),it(this.state)&&this.setState({activeTool:Ha(this.state,{...this.state.activeTool.lastActiveTool||{type:hl.selection},lastActiveToolBeforeEraser:null})})},n=ec(window,`pointerup`,t,{once:!0}),r;requestAnimationFrame(()=>{r=this.missingPointerEventCleanupEmitter.once(t)})});return}if(e.button!==bc.MAIN&&e.button!==bc.TOUCH&&e.button!==bc.ERASER||$.pointers.size>1)return;let r=this.initialPointerDownState(e);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(e,r)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(e),this.handleSelectionOnPointerDown(e,r))||!(!this.state.penMode||e.pointerType!==`touch`||this.state.activeTool.type===`selection`||this.state.activeTool.type===`text`||this.state.activeTool.type===`image`))return;if(this.state.activeTool.type===`text`)this.handleTextOnPointerDown(e,r);else if(this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`)this.handleLinearElementOnPointerDown(e,this.state.activeTool.type,r);else if(this.state.activeTool.type===`image`){z(this.interactiveCanvas,W.CROSSHAIR);let t=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!t)return;this.setState({newElement:t,pendingImageElementId:null,multiElement:null});let{x:n,y:r}=gl(e,this.state),i=this.getTopLayerFrameAtSceneCoords({x:n,y:r});U(t,{x:n,y:r,frameId:i?i.id:null})}else this.state.activeTool.type===`freedraw`?this.handleFreeDrawElementOnPointerDown(e,this.state.activeTool.type,r):this.state.activeTool.type===`custom`?cl(this.interactiveCanvas,this.state):this.state.activeTool.type===hl.frame||this.state.activeTool.type===hl.magicframe?this.createFrameElementOnPointerDown(r,this.state.activeTool.type):this.state.activeTool.type===`laser`?this.laserTrails.startPath(r.lastCoords.x,r.lastCoords.y):this.state.activeTool.type!==`eraser`&&this.state.activeTool.type!==`hand`&&this.createGenericElementOnPointerDown(this.state.activeTool.type,r);this.props?.onPointerDown?.(this.state.activeTool,r),this.onPointerDownEmitter.trigger(this.state.activeTool,r,e),this.state.activeTool.type===`eraser`&&this.eraserTrail.startPath(r.lastCoords.x,r.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(r),a=this.onPointerUpFromPointerDownHandler(r),o=this.onKeyDownFromPointerDownHandler(r),s=this.onKeyUpFromPointerDownHandler(r);this.missingPointerEventCleanupEmitter.once(t=>a(t||e.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type===`laser`)&&(window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`keydown`,o),window.addEventListener(`keyup`,s),r.eventListeners.onMove=i,r.eventListeners.onUp=a,r.eventListeners.onKeyUp=s,r.eventListeners.onKeyDown=o)}),w(this,`handleCanvasPointerUp`,e=>{this.removePointer(e),this.lastPointerUpEvent=e;let t=gl({clientX:e.clientX,clientY:e.clientY},this.state),n=e.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let n=this.getElementAtPosition(t.x,t.y);if(Oo(n)&&this.isIframeLikeElementCenter(n,e,t.x,t.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let e=this.getElementAtPosition(t.x,t.y);this.hitLinkElement=this.getElementLinkAtPosition(t,e)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Oo(this.hitLinkElement)&&!rc(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,O(t.x,t.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(e,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}),w(this,`maybeOpenContextMenuAfterPointerDownOnTouchDevices`,e=>{e.pointerType===`touch`&&(jE=!1,AE?jE=!0:AE=window.setTimeout(()=>{AE=0,jE||this.handleCanvasContextMenu(e)},500))}),w(this,`resetContextMenuTimer`,()=>{clearTimeout(AE),AE=0,jE=!1}),w(this,`maybeCleanupAfterMissingPointerUp`,e=>{IE?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),w(this,`handleCanvasPanUsingWheelOrSpaceDrag`,e=>{if(!($.pointers.size<=1&&(e.button===bc.WHEEL||e.button===bc.MAIN&&EE||Yr(this.state)||this.state.viewModeEnabled)))return!1;DE=!0,this.focusContainer(),this.state.editingTextElement||e.preventDefault();let t=!1,n=/Linux/.test(window.navigator.platform);z(this.interactiveCanvas,W.GRABBING);let{clientX:r,clientY:i}=e,a=iT(e=>{let a=r-e.clientX,o=i-e.clientY;if(r=e.clientX,i=e.clientY,n&&!t&&(Math.abs(a)>1||Math.abs(o)>1)){t=!0;let e=t=>{document.body.removeEventListener(`paste`,e),t.stopPropagation()},n=()=>{setTimeout(()=>{document.body.removeEventListener(`paste`,e),window.removeEventListener(`pointerup`,n)},100)};document.body.addEventListener(`paste`,e),window.addEventListener(`pointerup`,n)}this.translateCanvas({scrollX:this.state.scrollX-a/this.state.zoom.value,scrollY:this.state.scrollY-o/this.state.zoom.value})}),o=rT(IE=()=>{IE=null,DE=!1,EE||(this.state.viewModeEnabled?z(this.interactiveCanvas,W.GRAB):cl(this.interactiveCanvas,this.state)),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`blur`,o),a.flush()});return window.addEventListener(`blur`,o),window.addEventListener(`pointermove`,a,{passive:!0}),window.addEventListener(`pointerup`,o),!0}),w(this,`clearSelectionIfNotUsingSelection`,()=>{this.state.activeTool.type!==`selection`&&this.setState({selectedElementIds:A({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),w(this,`handleSelectionOnPointerDown`,(e,t)=>{if(this.state.activeTool.type===`selection`){let n=this.scene.getNonDeletedElements(),r=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement&&!T(i[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let r=Za(n,this.state,t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.device);r!=null&&(r.transformHandleType===`rotation`?(this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType))}else i.length>1&&(t.resize.handleType=as(Zo(i),t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.device));if(t.resize.handleType)t.resize.isResizing=!0,t.resize.offset=ki(Ns(t.resize.handleType,i,r,t.origin.x,t.origin.y)),i.length===1&&Ac(i[0])&&i[0].points.length===2&&(t.resize.arrowDirection=rn(t.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let n=this.state.editingLinearElement||this.state.selectedLinearElement,r=N.handlePointerDown(e,this,this.store,t.origin,n,this.scene);if(r.hitElement&&(t.hit.element=r.hitElement),r.linearElementEditor&&(this.setState({selectedLinearElement:r.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:r.linearElementEditor})),r.didAddPoint)return!0}if(t.hit.element=t.hit.element??this.getElementAtPosition(t.origin.x,t.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(t.origin,t.hit.element),this.hitLinkElement)return!0;if(this.state.croppingElementId&&t.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),t.hit.element&&this.getElementLinkAtPosition({x:t.origin.x,y:t.origin.y},t.hit.element))return!1;t.hit.allHitElements=this.getElementsAtPosition(t.origin.x,t.origin.y);let n=t.hit.element,r=t.hit.allHitElements.some(e=>this.isASelectedElement(e));if((n===null||!r)&&!e.shiftKey&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(n),this.state.editingLinearElement)this.setState({selectedElementIds:A({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(n!=null){if(e[F.CTRL_OR_CMD])return this.state.selectedElementIds[n.id]||(t.hit.wasAddedToSelection=!0),this.setState(e=>({...qo(e,n),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[n.id]||(this.state.editingGroupId&&!jr(n,this.state.editingGroupId)&&this.setState({selectedElementIds:A({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!r&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(e=>{let t={...e.selectedElementIds,[n.id]:!0},r=[];if(Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&r.push(t)}),D(n))Pl(r,n.id).forEach(e=>{delete t[e.id]});else if(n.frameId)t[n.frameId]&&delete t[n.id];else{let e=n.groupIds,i=new Set(e.flatMap(e=>Ki(this.scene.getNonDeletedElements(),e)).filter(e=>D(e)).map(e=>e.id));i.size>0&&r.forEach(e=>{e.frameId&&i.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>Ki(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return e.openDialog?.name===`elementLinkSelector`&&(n.groupIds.some(t=>e.selectedGroupIds[t])||(t={[n.id]:!0})),{...xt({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:n.link||dt(n)?`info`:!1}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),w(this,`handleTextOnPointerDown`,(e,t)=>{if(this.state.editingTextElement)return;let n=t.origin.x,r=t.origin.y,i=this.getElementAtPosition(n,r,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(n,r);Ja(i)&&(a=i,n=i.x+i.width/2,r=i.y+i.height/2),this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:a,autoEdit:!1}),pi(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Ha(this.state,{type:`selection`})})}),w(this,`handleFreeDrawElementOnPointerDown`,(e,t,n)=>{let[r,i]=kr(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),o=e.pressure===.5,s=Lc({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:o,locked:!1,frameId:a?a.id:null,points:[O(0,0)],pressures:o?[]:[e.pressure]});this.scene.insertElement(s),this.setState(e=>{let t={...e.selectedElementIds};return delete t[s.id],{selectedElementIds:A(t,e)}});let c=ar(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:s,startBoundElement:c,suggestedBindings:[]})}),w(this,`insertIframeElement`,({sceneX:e,sceneY:t,width:n,height:r})=>{let[i,a]=kr(e,t,this.lastPointerDownEvent?.[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=Li({type:`iframe`,x:i,y:a,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness(`iframe`),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:r});return this.scene.insertElement(o),o}),w(this,`insertEmbeddableElement`,({sceneX:e,sceneY:t,link:n})=>{let[r,i]=kr(e,t,this.lastPointerDownEvent?.[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=ds(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:q(`toast.unrecognizedLinkFormat`),closable:!0});let o=Hn({type:`embeddable`,x:r,y:i,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness(`embeddable`),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:n});return this.scene.insertElement(o),o}),w(this,`createImageElement`,({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[r,i]=kr(e,t,this.lastPointerDownEvent?.[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=n?this.getTopLayerFrameAtSceneCoords({x:r,y:i}):null;return dn({type:`image`,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})}),w(this,`handleLinearElementOnPointerDown`,(e,t,n)=>{if(this.state.multiElement){let{multiElement:e}=this.state;if(e.type===`line`&&ye(e.points,this.state.zoom.value)){U(e,{lastCommittedPoint:e.points[e.points.length-1]}),this.actionManager.executeAction(H_);return}if(T(e)&&e.points.length>1){U(e,{lastCommittedPoint:e.points[e.points.length-1]}),this.actionManager.executeAction(H_);return}let{x:t,y:r,lastCommittedPoint:i}=e;if(e.points.length>1&&i&&Kn(O(n.origin.x-t,n.origin.y-r),i)<8){this.actionManager.executeAction(H_);return}this.setState(t=>({selectedElementIds:A({...t.selectedElementIds,[e.id]:!0},t)})),U(e,{lastCommittedPoint:e.points[e.points.length-1]}),z(this.interactiveCanvas,W.POINTER)}else{let[r,i]=kr(n.origin.x,n.origin.y,e[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),{currentItemStartArrowhead:o,currentItemEndArrowhead:s}=this.state,[c,l]=t===`arrow`?[o,s]:[null,null],u=t===`arrow`?Jr({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Ri.round?{type:pt.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:l,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Ri.elbow,fixedSegments:this.state.currentItemArrowType===Ri.elbow?[]:null}):ei({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness===`round`?{type:pt.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null});this.setState(e=>{let t={...e.selectedElementIds};return delete t[u.id],{selectedElementIds:A(t,e)}}),U(u,{points:[...u.points,O(0,0)]});let d=ar(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,T(u),T(u));this.scene.insertElement(u),this.setState({newElement:u,startBoundElement:d,suggestedBindings:[]})}}),w(this,`createGenericElementOnPointerDown`,(e,t)=>{let[n,r]=kr(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.getTopLayerFrameAtSceneCoords({x:n,y:r}),a={x:n,y:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(e),locked:!1,frameId:i?i.id:null},o;o=e===`embeddable`?Hn({type:`embeddable`,...a}):Ua({type:e,...a}),o.type===`selection`?this.setState({selectionElement:o}):(this.scene.insertElement(o),this.setState({multiElement:null,newElement:o}))}),w(this,`createFrameElementOnPointerDown`,(e,t)=>{let[n,r]=kr(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:r,opacity:this.state.currentItemOpacity,locked:!1,...In},a=t===hl.magicframe?_s(i):Qs(i);this.scene.insertElement(a),this.setState({multiElement:null,newElement:a})}),w(this,`restoreReadyToEraseElements`,()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),w(this,`eraseElements`,()=>{let e=!1,t=this.scene.getElementsIncludingDeleted().map(t=>this.elementsPendingErasure.has(t.id)||t.frameId&&this.elementsPendingErasure.has(t.frameId)||Ls(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,H(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(t))}),w(this,`initializeImage`,async({imageFile:e,imageElement:t,showCursorImagePreview:n=!1})=>{if(!kt(e))throw Error(q(`errors.unsupportedFileType`));let r=e.type;if(z(this.interactiveCanvas,`wait`),r===Pr.svg)try{e=nu(wn(await e.text()),e.name)}catch(e){throw console.warn(e),Error(q(`errors.svgImageInsertError`))}let i=await(this.props.generateIdForFile?.(e)||Bc(e));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(q(`errors.imageInsertError`));if(!this.files[i]?.dataURL){try{e=await ft(e,{maxWidthOrHeight:fu})}catch(e){console.error(`Error trying to resizing image file on insertion`,e)}if(e.size>4194304)throw Error(q(`errors.fileTooBig`,{maxSize:`${Math.trunc(bo/1024/1024)}MB`}))}if(n){let t=this.files[i]?.dataURL,n=t&&Gr(t);this.setImagePreviewCursor(n||e)}let a=this.files[i]?.dataURL||await hs(e),o=U(t,{fileId:i},!1);return new Promise(async(e,t)=>{try{this.addMissingFiles([{mimeType:r,id:i,dataURL:a,created:Date.now(),lastRetrieved:Date.now()}]);let t=this.imageCache.get(i);t||(this.addNewImagesToImageCache(),await this.updateImageCache([o])),t?.image instanceof Promise&&await t.image,this.state.pendingImageElementId!==o.id&&this.state.newElement?.id!==o.id&&this.initializeImageDimensions(o,!0),e(o)}catch(e){console.error(e),t(Error(q(`errors.imageInsertError`)))}finally{n||pi(this.interactiveCanvas)}})}),w(this,`insertImageElement`,async(e,t,n)=>{if(!this.isToolSupported(`image`)){this.setState({errorMessage:q(`errors.imageToolNotSupported`)});return}this.scene.insertElement(e);try{return await this.initializeImage({imageFile:t,imageElement:e,showCursorImagePreview:n})}catch(t){return U(e,{isDeleted:!0}),this.actionManager.executeAction(H_),this.setState({errorMessage:t.message||q(`errors.imageInsertError`)}),null}}),w(this,`setImagePreviewCursor`,async e=>{let t;try{t=await ft(e,{maxWidthOrHeight:96})}catch(e){throw e.cause===`UNSUPPORTED`?Error(q(`errors.unsupportedFileType`)):e}let n=await hs(t);if(e.type===Pr.svg){let e=await Gt(n),t=Math.min(e.height,96),r=t*(e.width/e.height);r>96&&(r=96,t=r*(e.height/e.width));let i=document.createElement(`canvas`);i.height=t,i.width=r,i.getContext(`2d`).drawImage(e,0,0,r,t),n=i.toDataURL(Pr.svg)}this.state.pendingImageElementId&&z(this.interactiveCanvas,`url(${n}) 4 4, auto`)}),w(this,`onImageAction`,async({insertOnCanvasDirectly:e})=>{try{let{x:t,y:n}=gl({clientX:this.state.width/2+this.state.offsetLeft,clientY:this.state.height/2+this.state.offsetTop},this.state),r=await Xl({description:`Image`,extensions:Object.keys(ks)}),i=this.createImageElement({sceneX:t,sceneY:n,addToFrameUnderCursor:!1});e?(this.insertImageElement(i,r),this.initializeImageDimensions(i),this.setState({selectedElementIds:A({[i.id]:!0},this.state)},()=>{this.actionManager.executeAction(H_)})):this.setState({pendingImageElementId:i.id},()=>{this.insertImageElement(i,r,!0)})}catch(e){e.name===`AbortError`?console.warn(e):console.error(e),this.setState({pendingImageElementId:null,newElement:null,activeTool:Ha(this.state,{type:`selection`})},()=>{this.actionManager.executeAction(H_)})}}),w(this,`initializeImageDimensions`,(e,t=!1)=>{let n=Ir(e)&&this.imageCache.get(e.fileId)?.image;if(!n||n instanceof Promise){if(e.width<10/this.state.zoom.value&&e.height<10/this.state.zoom.value){let t=100/this.state.zoom.value;U(e,{x:e.x-t/2,y:e.y-t/2,width:t,height:t})}return}if(t||e.width<10/this.state.zoom.value&&e.height<10/this.state.zoom.value){let t=Math.max(this.state.height-120,160),r=Math.min(t,Math.floor(this.state.height*.5)/this.state.zoom.value),i=Math.min(n.naturalHeight,r),a=i*(n.naturalWidth/n.naturalHeight);U(e,{x:e.x+e.width/2-a/2,y:e.y+e.height/2-i/2,width:a,height:i,crop:null})}}),w(this,`updateImageCache`,async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:r}=await Lt({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});if(n.size||r.size)for(let t of e)n.has(t.fileId)&&za.delete(t);return r.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>Ir(e)&&r.has(e.fileId)?H(e,{status:`error`}):e)),{updatedFiles:n,erroredFiles:r}}),w(this,`addNewImagesToImageCache`,async(e=fs(this.scene.getNonDeletedElements()),t=this.files)=>{let n=e.filter(e=>!e.isDeleted&&!this.imageCache.has(e.fileId));if(n.length){let{updatedFiles:e}=await this.updateImageCache(n,t);e.size&&this.scene.triggerUpdate()}}),w(this,`scheduleImageRefresh`,(0,kp.default)(()=>{this.addNewImagesToImageCache()},500)),w(this,`updateBindingEnabledOnPointerMove`,e=>{let t=Ba(e);this.state.isBindingEnabled!==t&&this.setState({isBindingEnabled:t})}),w(this,`maybeSuggestBindingAtCursor`,(e,t)=>{let n=ar(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,t);this.setState({suggestedBindings:n==null?[]:[n]})}),w(this,`maybeSuggestBindingsForLinearElementAtCoords`,(e,t,n)=>{if(!t.length)return;let r=t.reduce((t,r)=>{let i=ar(r,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,T(e),T(e));return i!=null&&!ln(e,n?.id,i)&&t.push(i),t},[]);this.setState({suggestedBindings:r})}),w(this,`handleInteractiveCanvasRef`,e=>{e===null?(this.interactiveCanvas?.removeEventListener(`touchstart`,this.onTouchStart),this.interactiveCanvas?.removeEventListener(`touchend`,this.onTouchEnd)):(this.interactiveCanvas=e,this.interactiveCanvas.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(`touchend`,this.onTouchEnd))}),w(this,`handleAppOnDrop`,async e=>{let{file:t,fileHandle:n}=await Be(e),{x:r,y:i}=gl(e,this.state);try{if(kt(t)&&this.isToolSupported(`image`)){if(t?.type===Pr.png||t?.type===Pr.svg)try{let e=await Jn(t,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...e,appState:{...e.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:M.IMMEDIATELY});return}catch(e){if(e.name!==`EncodingError`)throw Error(q(`alerts.couldNotLoadInvalidFile`))}let e=this.createImageElement({sceneX:r,sceneY:i});this.insertImageElement(e,t),this.initializeImageDimensions(e),this.setState({selectedElementIds:A({[e.id]:!0},this.state)});return}}catch(e){return this.setState({isLoading:!1,errorMessage:e.message})}let a=e.dataTransfer.getData(Pr.excalidrawlib);if(a&&typeof a==`string`){try{let t=nl(a);this.addElementsFromPasteOrLibrary({elements:wy(t),position:e,files:null})}catch(e){this.setState({errorMessage:e.message})}return}if(t&&await this.loadFileToCanvas(t,n),e.dataTransfer?.types?.includes(`text/plain`)){let t=e.dataTransfer?.getData(`text`);if(t&&Hs(t,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(t)||ds(t)?.type===`video`)){let e=this.insertEmbeddableElement({sceneX:r,sceneY:i,link:ms(t)});e&&this.setState({selectedElementIds:{[e.id]:!0}})}}}),w(this,`loadFileToCanvas`,async(e,t)=>{e=await Pn(e);try{let n=this.scene.getElementsIncludingDeleted(),r;try{r=await Ne(e,this.state,n,t)}catch(e){let t=e instanceof qe;if(t&&e.code===`IMAGE_NOT_CONTAINS_SCENE_DATA`&&!this.isToolSupported(`image`)){this.setState({isLoading:!1,errorMessage:q(`errors.imageToolNotSupported`)});return}let n=q(t?`alerts.cannotRestoreFromImage`:`alerts.couldNotLoadInvalidFile`);this.setState({isLoading:!1,errorMessage:n})}if(!r)return;r.type===Pr.excalidraw?(ja(n.concat(r.data.elements)),this.store.updateSnapshot(E(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...r.data,appState:{...r.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:M.IMMEDIATELY})):r.type===Pr.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:q(`errors.importLibraryError`)})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),w(this,`handleCanvasContextMenu`,e=>{if(e.preventDefault(),(`pointerType`in e.nativeEvent&&e.nativeEvent.pointerType===`touch`||`pointerType`in e.nativeEvent&&e.nativeEvent.pointerType===`pen`&&e.button!==bc.SECONDARY)&&this.state.activeTool.type!==`selection`)return;let{x:t,y:n}=gl(e,this.state),r=this.getElementAtPosition(t,n,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:t,y:n},i),o=r||a?`element`:`canvas`,{top:s,left:c}=this.excalidrawContainerRef.current.getBoundingClientRect(),l=e.clientX-c,u=e.clientY-s;Y(`contextMenu`,`openContextMenu`,o),this.setState({...r&&!this.state.selectedElementIds[r.id]?{...this.state,...xt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[r.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ac(r)?new N(r):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:l,items:this.getContextMenuItems(o)}})})}),w(this,`maybeDragNewGenericElement`,(e,t,n=!0)=>{let r=this.state.selectionElement,i=e.lastCoords;if(r&&this.state.activeTool.type!==`eraser`){jn({newElement:r,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:i.x,y:i.y,width:dr(e.origin.x,i.x),height:dr(e.origin.y,i.y),shouldMaintainAspectRatio:jc(t),shouldResizeFromCenter:_e(t),zoom:this.state.zoom.value,informMutation:n});return}let a=this.state.newElement;if(!a)return;let[o,s]=kr(i.x,i.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=Ir(a)&&this.imageCache.get(a.fileId)?.image,l=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(t,[a]);let{snapOffset:u,snapLines:d}=Yi(a,this,t,{x:e.originInGrid.x+(this.state.originSnapOffset?.x??0),y:e.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:o-e.originInGrid.x,y:s-e.originInGrid.y},this.scene.getNonDeletedElementsMap());o+=u.x,s+=u.y,this.setState({snapLines:d}),jn({newElement:a,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:o,y:s,width:dr(e.originInGrid.x,o),height:dr(e.originInGrid.y,s),shouldMaintainAspectRatio:Mo(a)?!jc(t):jc(t),shouldResizeFromCenter:_e(t),zoom:this.state.zoom.value,widthAspectRatio:l,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:a}),(this.state.activeTool.type===hl.frame||this.state.activeTool.type===hl.magicframe)&&this.setState({elementsToHighlight:El(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})}),w(this,`maybeHandleCrop`,(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,r=e.lastCoords,[i,a]=kr(r.x-e.resize.offset.x,r.y-e.resize.offset.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&o&&Mo(o)){let s=e.originalElements.get(o.id),c=Ir(o)&&this.imageCache.get(o.fileId)?.image;if(s&&Mo(s)&&c&&!(c instanceof Promise)){let[l,u]=kr(r.x,r.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d={x:l-e.originInGrid.x,y:u-e.originInGrid.y};this.maybeCacheReferenceSnapPoints(t,[o]);let{snapOffset:f,snapLines:p}=no([o],[s],this,t,d,n);U(o,$c(o,n,c.naturalWidth,c.naturalHeight,i+f.x,a+f.y,t.shiftKey?s.width/s.height:void 0)),Io(o,this.scene.getNonDeletedElementsMap(),{newSize:{width:o.width,height:o.height}}),this.setState({isCropping:n&&n!==`rotation`,snapLines:p})}return!0}return!1}),w(this,`maybeHandleResize`,(e,t)=>{let n=this.scene.getSelectedElements(this.state),r=n.filter(e=>D(e)),i=e.resize.handleType;if(r.length>0&&i===`rotation`||n.length===1&&T(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:i&&i!==`rotation`,isRotating:i===`rotation`,activeEmbeddable:null});let a=e.lastCoords,[o,s]=kr(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(r.forEach(e=>{Pl(this.scene.getNonDeletedElements(),e.id).forEach(t=>{c.set(e.id+t.id,{x:t.x-e.x,y:t.y-e.y})})}),!this.state.selectedElementsAreBeingDragged){let[r,c]=kr(a.x,a.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:r-e.originInGrid.x,y:c-e.originInGrid.y},u=[...e.originalElements.values()];this.maybeCacheReferenceSnapPoints(t,n);let{snapOffset:d,snapLines:f}=no(n,R(u,this.state),this,t,l,i);o+=d.x,s+=d.y,this.setState({snapLines:f})}if(Kr(e.originalElements,i,n,this.scene.getElementsMapIncludingDeleted(),this.scene,Xa(t),_e(t),n.some(e=>Mo(e))?!jc(t):jc(t),o,s,e.resize.center.x,e.resize.center.y)){let e=or(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),t=new Set;return r.forEach(e=>{El(this.scene.getNonDeletedElements(),e,this.state,this.scene.getNonDeletedElementsMap()).forEach(e=>t.add(e))}),this.setState({elementsToHighlight:[...t],suggestedBindings:e}),!0}return!1}),w(this,`getContextMenuItems`,e=>{let t=[];return t.push(Pv,Nv),e===`canvas`?this.state.viewModeEnabled?[...t,Iv,Lv,Gw,zv]:[jv,_x,Pv,Nv,Fv,_x,sg,ly,_x,Iv,Rv,Lv,Gw,zv]:(t.push(Fv),this.state.viewModeEnabled?[Av,...t]:[_x,Mv,Av,jv,_x,qw,Jw,Yw,_x,rx,_x,...t,_x,av,ov,_x,uv,tE,Bv,Vv,Wv,dv,_x,vv,_x,rg,ig,ag,og,_x,Ev,Dv,_x,tx,_x,oy,Kb,_x,dg,cy,_x,Hh])}),w(this,`handleWheel`,rT(e=>{if(!(e.target instanceof HTMLCanvasElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLIFrameElement)){e[F.CTRL_OR_CMD]&&e.preventDefault();return}if(e.preventDefault(),DE)return;let{deltaX:t,deltaY:n}=e;if(e.metaKey||e.ctrlKey){let e=Math.sign(n),t=Qt*100,r=Math.abs(n),i=n;r>t&&(i=t*e);let a=this.state.zoom.value-i/100;a+=Math.log10(Math.max(1,this.state.zoom.value))*-e*Math.min(1,r/20),this.translateCanvas(e=>({...O_({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Ur(a)},e),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(e.shiftKey){this.translateCanvas(({zoom:e,scrollX:r})=>({scrollX:r-(n||t)/e.value}));return}this.translateCanvas(({zoom:e,scrollX:r,scrollY:i})=>({scrollX:r-t/e.value,scrollY:i-n/e.value}))})),w(this,`savePointer`,(e,t,n)=>{if(!e||!t)return;let{x:r,y:i}=gl({clientX:e,clientY:t},this.state),a={x:r,y:i,tool:this.state.activeTool.type===`laser`?`laser`:`pointer`};this.props.onPointerUpdate?.({pointer:a,button:n,pointersMap:$.pointers})}),w(this,`resetShouldCacheIgnoreZoomDebounced`,Zc(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),w(this,`updateDOMRect`,e=>{if(this.excalidrawContainerRef?.current){let{width:t,height:n,left:r,top:i}=this.excalidrawContainerRef.current.getBoundingClientRect(),{width:a,height:o,offsetTop:s,offsetLeft:c}=this.state;if(t===a&&n===o&&r===c&&i===s){e&&e();return}this.setState({width:t,height:n,offsetLeft:r,offsetTop:i},()=>{e&&e()})}}),w(this,`refresh`,()=>{this.setState({...this.getCanvasOffsets()})});let n=Na(),{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:o=!1,objectsSnapModeEnabled:s=!1,theme:c=n.theme,name:l=`${q(`labels.untitled`)}-${nt()}`}=t;if(this.state={...n,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:o??n.gridModeEnabled,name:l,width:window.innerWidth,height:window.innerHeight},this.id=vn(),this.library=new Cy(this),this.actionManager=new fx(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new fa,this.canvas=document.createElement(`canvas`),this.rc=Pi.canvas(this.canvas),this.renderer=new HT(this.scene),this.visibleElements=[],this.store=new Lo,this.history=new ax,r){let e={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:e=>{this.actionManager.registerAction(e)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:e=>this.onChangeEmitter.on(e),onPointerDown:e=>this.onPointerDownEmitter.on(e),onPointerUp:e=>this.onPointerUpEmitter.on(e),onScrollChange:e=>this.onScrollChangeEmitter.on(e),onUserFollow:e=>this.onUserFollowEmitter.on(e)};typeof r==`function`?r(e):console.error(`excalidrawAPI should be a function!`)}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new ao(this.scene),this.history=new ax,this.actionManager.registerAll(pn),this.actionManager.registerAction(lx(this.history,this.store)),this.actionManager.registerAction(ux(this.history,this.store))}onWindowMessage(e){if(e.origin!==`https://player.vimeo.com`&&e.origin!==`https://www.youtube.com`)return;let t=null;try{t=JSON.parse(e.data)}catch{}if(t)switch(e.origin){case`https://player.vimeo.com`:if(t.method===`paused`){let n=null,r=document.body.querySelectorAll(`iframe.excalidraw__embeddable`);if(!r)break;for(let t of r)t.contentWindow===e.source&&(n=t.contentWindow);n?.postMessage(JSON.stringify({method:t.value?`play`:`pause`,value:!0}),`*`)}break;case`https://www.youtube.com`:if(t.event===`infoDelivery`&&t.info&&t.id&&typeof t.info.playerState==`number`){let e=t.id,n=t.info.playerState;Object.values(zs).includes(n)&&ME.set(e,n)}break}}cacheEmbeddableRef(e,t){t&&this.iFrameRefs.set(e.id,t)}getHTMLIFrameElement(e){return this.iFrameRefs.get(e.id)}handleEmbeddableCenterClick(e){if(this.state.activeEmbeddable?.element===e&&this.state.activeEmbeddable?.state===`active`||(setTimeout(()=>{this.setState({activeEmbeddable:{element:e,state:`active`},selectedElementIds:{[e.id]:!0},newElement:null,selectionElement:null})},100),gu(e)))return;let t=this.getHTMLIFrameElement(e);if(t?.contentWindow){if(t.src.includes(`youtube`)){let n=ME.get(e.id);switch(n||(ME.set(e.id,zs.UNSTARTED),t.contentWindow.postMessage(JSON.stringify({event:`listening`,id:e.id}),`*`)),n){case zs.PLAYING:case zs.BUFFERING:t.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`pauseVideo`,args:``}),`*`);break;default:t.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`playVideo`,args:``}),`*`)}}t.src.includes(`player.vimeo.com`)&&t.contentWindow.postMessage(JSON.stringify({method:`paused`}),`*`)}}isIframeLikeElementCenter(e,t,n,r){return e&&!t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(this.state.activeEmbeddable?.element!==e||this.state.activeEmbeddable?.state===`hover`||!this.state.activeEmbeddable)&&n>=e.x+e.width/3&&n<=e.x+2*e.width/3&&r>=e.y+e.height/3&&r<=e.y+2*e.height/3}renderEmbeddables(){let e=this.state.zoom.value,t=this.state.width,n=this.state.height;return(0,K.jsx)(K.Fragment,{children:this.scene.getNonDeletedElements().filter(e=>dt(e)&&this.embedsValidationStatus.get(e.id)===!0||gu(e)).map(r=>{let{x:i,y:a}=Zr({sceneX:r.x,sceneY:r.y},this.state),o=wr(r,t,n,this.state,this.scene.getNonDeletedElementsMap()),s=this.initializedEmbeds.has(r.id);if(o&&!s&&this.initializedEmbeds.add(r.id),!(o||s))return null;let c;if(gu(r)){c=null;let e=(r.customData?.generationData??this.magicGenerations.get(r.id))||{status:`error`,message:`No generation data`,code:`ERR_NO_GENERATION_DATA`};if(e.status===`done`){let t=e.html;c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>t}}else if(e.status===`pending`)c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Zt(`
|
|
16
|
+
<style>
|
|
17
|
+
html, body {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
color: ${this.state.theme===j.DARK?`white`:`black`};
|
|
21
|
+
}
|
|
22
|
+
body {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: 1rem;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.Spinner {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
margin-left: auto;
|
|
35
|
+
margin-right: auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.Spinner svg {
|
|
39
|
+
animation: rotate 1.6s linear infinite;
|
|
40
|
+
transform-origin: center center;
|
|
41
|
+
width: 40px;
|
|
42
|
+
height: 40px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.Spinner circle {
|
|
46
|
+
stroke: currentColor;
|
|
47
|
+
animation: dash 1.6s linear 0s infinite;
|
|
48
|
+
stroke-linecap: round;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@keyframes rotate {
|
|
52
|
+
100% {
|
|
53
|
+
transform: rotate(360deg);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@keyframes dash {
|
|
58
|
+
0% {
|
|
59
|
+
stroke-dasharray: 1, 300;
|
|
60
|
+
stroke-dashoffset: 0;
|
|
61
|
+
}
|
|
62
|
+
50% {
|
|
63
|
+
stroke-dasharray: 150, 300;
|
|
64
|
+
stroke-dashoffset: -200;
|
|
65
|
+
}
|
|
66
|
+
100% {
|
|
67
|
+
stroke-dasharray: 1, 300;
|
|
68
|
+
stroke-dashoffset: -280;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
72
|
+
<div class="Spinner">
|
|
73
|
+
<svg
|
|
74
|
+
viewBox="0 0 100 100"
|
|
75
|
+
>
|
|
76
|
+
<circle
|
|
77
|
+
cx="50"
|
|
78
|
+
cy="50"
|
|
79
|
+
r="46"
|
|
80
|
+
stroke-width="8"
|
|
81
|
+
fill="none"
|
|
82
|
+
stroke-miter-limit="10"
|
|
83
|
+
/>
|
|
84
|
+
</svg>
|
|
85
|
+
</div>
|
|
86
|
+
<div>Generating...</div>
|
|
87
|
+
`)};else{let t;t=e.code===`ERR_GENERATION_INTERRUPTED`?`Generation was interrupted...`:e.message||`Generation failed`,c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Zt(`
|
|
88
|
+
<style>
|
|
89
|
+
html, body {
|
|
90
|
+
height: 100%;
|
|
91
|
+
}
|
|
92
|
+
body {
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
color: ${Ma.red[3]};
|
|
98
|
+
}
|
|
99
|
+
h1, h3 {
|
|
100
|
+
margin-top: 0;
|
|
101
|
+
margin-bottom: 0.5rem;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
104
|
+
<h1>Error!</h1>
|
|
105
|
+
<h3>${t}</h3>
|
|
106
|
+
`)}}}else c=ds(el(r.link||``));let l=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`,u=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`hover`;return(0,K.jsx)(`div`,{className:I(`excalidraw__embeddable-container`,{"is-hovered":u}),style:{transform:o?`translate(${i-this.state.offsetLeft}px, ${a-this.state.offsetTop}px) scale(${e})`:`none`,display:o?`block`:`none`,opacity:_t(r,Mc(r,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name===`elementLinkSelector`?wi:1),"--embeddable-radius":`${Dn(Math.min(r.width,r.height),r)}px`},children:(0,K.jsxs)(`div`,{className:`excalidraw__embeddable-container__inner`,style:{width:o?`${r.width}px`:0,height:o?`${r.height}px`:0,transform:o?`rotate(${r.angle}rad)`:`none`,pointerEvents:l?Kc.enabled:Kc.disabled},children:[u&&(0,K.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:q(`buttons.embeddableInteractionButton`)}),(0,K.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(dt(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,K.jsx)(`iframe`,{ref:e=>this.cacheEmbeddableRef(r,e),className:`excalidraw__embeddable`,srcDoc:c?.type===`document`?c.srcdoc(this.state.theme):void 0,src:c?.type===`document`?void 0:c?.link??``,scrolling:`no`,referrerPolicy:`no-referrer-when-downgrade`,title:`Excalidraw Embedded Content`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,sandbox:`${c?.sandbox?.allowSameOrigin?`allow-same-origin`:``} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},r.id)})})}toggleOverscrollBehavior(e){document.documentElement.style.overscrollBehaviorX=e.type===`pointerenter`?`none`:`auto`}render(){let e=this.scene.getSelectedElements(this.state),{renderTopRightUI:t,renderCustomStats:n}=this.props,r=this.scene.getSceneNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({sceneNonce:r,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=a;let o=this.scene.getNonDeletedElementsMap(),s=`setPointerCapture`in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type===`laser`&&this.state.cursorButton===`down`,c=e[0];return(0,K.jsx)(`div`,{className:I(`excalidraw excalidraw-container`,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":s?Kc.disabled:Kc.enabled,"--right-sidebar-width":`302px`},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:(0,K.jsx)(sE.Provider,{value:this,children:(0,K.jsx)(cE.Provider,{value:this.props,children:(0,K.jsx)(dE.Provider,{value:this.excalidrawContainerValue,children:(0,K.jsx)(uE.Provider,{value:this.device,children:(0,K.jsx)(mE.Provider,{value:this.setAppState,children:(0,K.jsx)(pE.Provider,{value:this.state,children:(0,K.jsxs)(fE.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,K.jsxs)(hE.Provider,{value:this.actionManager,children:[(0,K.jsx)(Hw,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Nh().code,renderTopRightUI:t,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>`u`&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===`selection`&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),(0,K.jsx)(`div`,{className:`excalidraw-textEditorContainer`}),(0,K.jsx)(`div`,{className:`excalidraw-contextMenuContainer`}),(0,K.jsx)(`div`,{className:`excalidraw-eye-dropper-container`}),(0,K.jsx)(UT,{trails:[this.laserTrails,this.eraserTrail]}),e.length===1&&this.state.openDialog?.name!==`elementLinkSelector`&&this.state.showHyperlinkPopup&&(0,K.jsx)(Qv,{element:c,elementsMap:o,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&e.length===1&&$e(c)&&(0,K.jsx)(KT,{element:c,elementsMap:i,children:(0,K.jsx)(JT,{title:q(`labels.convertToCode`),icon:nn,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,`button`)})}),e.length===1&&gu(c)&&c.customData?.generationData?.status===`done`&&(0,K.jsxs)(KT,{element:c,elementsMap:i,children:[(0,K.jsx)(JT,{title:q(`labels.copySource`),icon:gc,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),(0,K.jsx)(JT,{title:`Enter fullscreen`,icon:qc,checked:!1,onChange:()=>{let e=this.getHTMLIFrameElement(c);if(e)try{e.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:`active`},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(e){console.warn(e),this.setState({errorMessage:`Couldn't enter fullscreen`})}}})]}),this.state.toast!==null&&(0,K.jsx)(Ww,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&(0,K.jsx)(vx,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:e=>{this.setState({contextMenu:null},()=>{this.focusContainer(),e?.()})}}),(0,K.jsx)(VT,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:o,visibleElements:a,sceneNonce:r,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:ul(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&(0,K.jsx)(oE,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:i,allElementsMap:o,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),(0,K.jsx)(RT,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:o,selectedElements:e,sceneNonce:r,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&(0,K.jsx)(YT,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(e){Object.assign(this.plugins,e)}async onMagicFrameGenerate(e,t){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:`No diagram to code plugin found`});return}let r=Xs(this.scene.getNonDeletedElements(),e).filter(e=>!$e(e));if(!r.length){t===`button`?(this.setState({errorMessage:`Cannot generate from an empty frame`}),Y(`ai`,`generate (no-children)`,`d2c`)):this.setActiveTool({type:`magicframe`});return}let i=this.insertIframeElement({sceneX:e.x+e.width+30,sceneY:e.y,width:e.width,height:e.height});if(i){this.updateMagicGeneration({frameElement:i,data:{status:`pending`}}),this.setState({selectedElementIds:{[i.id]:!0}}),Y(`ai`,`generate (start)`,`d2c`);try{let{html:t}=await n({frame:e,children:r});if(Y(`ai`,`generate (success)`,`d2c`),!t.trim()){this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:`Nothing genereated :(`}});return}let a=t.includes(`<!DOCTYPE html>`)&&t.includes(`</html>`)?t.slice(t.indexOf(`<!DOCTYPE html>`),t.indexOf(`</html>`)+7):t;this.updateMagicGeneration({frameElement:i,data:{status:`done`,html:a}})}catch(e){Y(`ai`,`generate (failed)`,`d2c`),this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:e.message||`Unknown error during generation`}})}}}onIframeSrcCopy(e){e.customData?.generationData?.status===`done`&&(ti(e.customData.generationData.html),this.setToast({message:`copied to clipboard`,closable:!1,duration:1500}))}clearImageShapeCache(e){let t=e??this.files;this.scene.getNonDeletedElements().forEach(e=>{Ir(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),za.delete(e))})}async componentDidMount(){this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(C.MODE===Si.TEST||C.DEV)&&(this.setState.bind(this),Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...e)=>this.setState(...e)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})),this.store.onStoreIncrementEmitter.on(e=>{this.history.record(e.elementsChange,e.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Xe()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),qs&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has(`web-share-target`)?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),$r()&&!mt()&&this.setState({errorMessage:(0,K.jsx)(Xw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new fa,this.fonts=new ao(this.scene),this.renderer=new HT(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),za.destroy(),da.destroy(),clearTimeout(AE),mo.clearCache(),xt.clearCache(),AE=0,document.documentElement.style.overscrollBehaviorX=``}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ec(document,`keydown`,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ec(this.excalidrawContainerRef.current,`wheel`,this.handleWheel,{passive:!1}),ec(window,`message`,this.onWindowMessage,!1),ec(document,`pointerup`,this.removePointer,{passive:!1}),ec(document,`copy`,this.onCopy,{passive:!1}),ec(document,`keyup`,this.onKeyUp,{passive:!0}),ec(document,`pointermove`,this.updateCurrentCursorPosition,{passive:!1}),ec(document.fonts,`loadingdone`,e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),ec(document,`gesturestart`,this.onGestureStart,!1),ec(document,`gesturechange`,this.onGestureChange,!1),ec(document,`gestureend`,this.onGestureEnd,!1),ec(window,`focus`,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ec(document,`fullscreenchange`,this.onFullscreenChange,{passive:!1}),ec(document,`paste`,this.pasteFromClipboard,{passive:!1}),ec(document,`cut`,this.onCut,{passive:!1}),ec(window,`resize`,this.onResize,!1),ec(window,`unload`,this.onUnload,!1),ec(window,`blur`,this.onBlur,!1),ec(this.excalidrawContainerRef.current,`wheel`,this.handleWheel,{passive:!1}),ec(this.excalidrawContainerRef.current,`dragover`,this.disableEvent,!1),ec(this.excalidrawContainerRef.current,`drop`,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ec(Uo(this.excalidrawContainerRef.current),`scroll`,this.onScroll,{passive:!1})))}componentDidUpdate(e,t){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),r=this.scene.getElementsMapIncludingDeleted(),i=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),e.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),t.userToFollow&&!this.state.collaborators.has(t.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(t.zoom.value!==this.state.zoom.value||t.scrollX!==this.state.scrollX||t.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),t.userToFollow!==this.state.userToFollow&&(t.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:t.userToFollow,action:`UNFOLLOW`}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:`FOLLOW`})),Object.keys(this.state.selectedElementIds).length&&it(this.state)&&this.setState({activeTool:Ha(this.state,{type:`selection`})}),this.state.activeTool.type===`eraser`&&t.theme!==this.state.theme&&Ho(this.interactiveCanvas,this.state.theme),t.activeTool.type===`selection`&&this.state.activeTool.type!==`selection`&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),e.langCode!==this.props.langCode&&this.updateLanguage(),it(t)&&!it(this.state)&&this.eraserTrail.endPath(),e.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),t.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(t.openDialog?.name===`elementLinkSelector`||this.state.openDialog?.name===`elementLinkSelector`)&&t.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),e.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),e.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle(`theme--dark`,this.state.theme===j.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(H_)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:a}=t;t.activeTool!==this.state.activeTool&&a!=null&&We(this.state)&&Jt(a,!1)&&Ra(a,this.state,ki(N.getPointAtIndexGlobalCoordinates(a,-1,i)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(r,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){wE=!1}async addElementsFromMixedContentPaste(e,{isPlainPaste:t,sceneX:n,sceneY:r}){if(!t&&e.some(e=>e.type===`imageUrl`)&&this.isToolSupported(`image`)){let t=e.filter(e=>e.type===`imageUrl`).map(e=>e.value),i=await Promise.all(t.map(async e=>{try{return{file:await Vs(e)}}catch(e){let t=e.message;return e.cause===`FETCH_ERROR`?t=q(`errors.failedToFetchImage`):e.cause===`UNSUPPORTED`&&(t=q(`errors.unsupportedFileType`)),{errorMessage:t}}})),a=r,o=!1,s={};for(let e of i)if(e.file){let t=this.createImageElement({sceneX:n,sceneY:a}),r=await this.insertImageElement(t,e.file);r&&(o||(o=!0,a-=r.height/2),U(r,{y:a},!1),a=t.y+t.height+25,s[t.id]=!0)}this.setState({selectedElementIds:A(s,this.state)});let c=i.find(e=>!!e.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let n=e.filter(e=>e.type===`text`);n.length&&this.addTextFromPaste(n.map(e=>e.value).join(`
|
|
107
|
+
|
|
108
|
+
`),t)}}addTextFromPaste(e,t=!1){let{x:n,y:r}=gl({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:n,y:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:e,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:Sn,verticalAlign:`top`,locked:!1},a=ko({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=sa(i.fontFamily),[s,,c]=aa(this.state),l=Math.max(Math.min((c-s)*.5,800),200),u=r,d=t?[e]:e.split(`
|
|
109
|
+
`),f=d.reduce((e,t,r)=>{let s=Ln(t).trim();if(s.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),r=ct(s,a,o),c=r.width>l,d=c?bi(s,a,l):s;r=c?ct(d,a,o):r;let f=n-r.width/2,p=u-r.height/2,m=Wc({...i,x:f,y:p,text:d,originalText:s,lineHeight:o,autoResize:!c,frameId:t?t.id:null});e.push(m),u+=m.height+10}else d[r-1]?.trim()&&(u+=Xn(i.fontSize,o)+10);return e},[]);f.length!==0&&(this.scene.insertElements(f),this.setState({selectedElementIds:A(Object.fromEntries(f.map(e=>[e.id,!0])),this.state)}),!t&&f.length>1&&FE===!1&&!this.device.editor.isMobile&&(this.setToast({message:q(`toast.pasteAsSingleElement`,{shortcut:B(`CtrlOrCmd+Shift+V`)}),duration:5e3}),FE=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(e,{isExistingElement:t=!1}){let n=this.scene.getElementsMapIncludingDeleted(),r=(t,r)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(i=>i.id===e.id&&L(i)?H(i,{originalText:t,isDeleted:r??i.isDeleted,...qn(i,ce(i,n),n,t)}):i)])};eE({id:e.id,canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=Zr({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,r-this.state.offsetTop]},onChange:rT(t=>{r(t,!1),Pe(e)&&Io(e,this.scene.getNonDeletedElementsMap())}),onSubmit:rT(({viaKeyboard:n,nextOriginalText:i})=>{let a=!i.trim();if(r(i,a),!a&&n){let t=e.containerId?e.containerId:e.id;(0,_d.flushSync)(()=>{this.setState(e=>({selectedElementIds:A({...e.selectedElementIds,[t]:!0},e)}))})}a&&eu(this.scene.getNonDeletedElements(),[e]),(!a||t)&&this.store.shouldCaptureIncrement(),(0,_d.flushSync)(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&cl(this.interactiveCanvas,this.state),this.focusContainer()}),element:e,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),r(e.originalText,!1)}deselectElements(){this.setState({selectedElementIds:A({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&L(n)&&!n.isDeleted?n:null}getElementAtPosition(e,t,n){let r=this.getElementsAtPosition(e,t,n?.includeBoundTextElement,n?.includeLockedElements);if(r.length>1){if(n?.preferSelected){for(let e=r.length-1;e>-1;e--)if(this.state.selectedElementIds[r[e].id])return r[e]}let i=r[r.length-1];return Rl({x:e,y:t,element:i,shape:Cs(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:D(i)?this.frameNameBoundsCache.get(i):null})?i:r[r.length-2]}return r.length===1?r[0]:null}getElementsAtPosition(e,t,n=!1,r=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(n&&r?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(r||!e.locked)&&(n||!(L(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let r=Mc(n,a);return r&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Us({x:e,y:t},r,a):!0}).filter(e=>gu(e)?(i.push(e),!1):!0).concat(i)}getElementHitThreshold(){return Zs/this.state.zoom.value}hitElement(e,t,n,r=!0){if(r&&this.state.selectedElementIds[n.id]&&Vi([n],this.state)){let r=Et(n,this.scene.getNonDeletedElementsMap(),Mo(n)?0:this.getElementHitThreshold());if(Ji(O(e,t),r))return!0}return Ue(e,t,Fn(n,this.scene.getNonDeletedElementsMap()))?!0:Rl({x:e,y:t,element:n,shape:Cs(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:D(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(e,t){let n=this.scene.getNonDeletedElements(),r=this.scene.getSelectedElements(this.state);if(r.length===1)return Ll(r[0],!1)?r[0]:null;let i=null;for(let r=n.length-1;r>=0;--r){if(n[r].isDeleted)continue;let[a,o,s,c]=Er(n[r],this.scene.getNonDeletedElementsMap());if(xu(n[r])&&Rl({x:e,y:t,element:n[r],shape:Cs(n[r],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){i=n[r];break}else if(a<e&&e<s&&o<t&&t<c){i=n[r];break}}return Ll(i,!1)?i:null}handleHoverSelectedLinearElement(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=N.getElement(e.elementId,r);if(i)if(this.state.selectedLinearElement){let a=-1,o=null;Rl({x:t,y:n,element:i,shape:Cs(i,this.scene.getNonDeletedElementsMap())})?(a=N.getPointIndexUnderCursor(i,r,this.state.zoom,t,n),o=N.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,this.scene.getNonDeletedElementsMap()),(T(i)?a===0||a===i.points.length-1:a>=0)||o?z(this.interactiveCanvas,W.POINTER):this.hitElement(t,n,i)&&z(this.interactiveCanvas,W.MOVE)):this.hitElement(t,n,i)&&(!T(i)||!(i.startBinding||i.endBinding))&&z(this.interactiveCanvas,W.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),N.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,o)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:o}})}else z(this.interactiveCanvas,W.AUTO)}updateGestureOnPointerDown(e){$.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),$.pointers.size===2&&($.lastCenter=px($.pointers),$.initialScale=this.state.zoom.value,$.initialDistance=mx(Array.from($.pointers.values())))}initialPointerDownState(e){let t=gl(e,this.state),n=this.scene.getSelectedElements(this.state),[r,i,a,o]=Zo(n),s=n.findIndex(T)===0;return{origin:t,withCmdOrCtrl:e[F.CTRL_OR_CMD],originInGrid:ki(kr(t.x,t.y,e[F.CTRL_OR_CMD]||s?null:this.getEffectiveGridSize())),scrollbars:eS(kE,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,Xt(t)),e),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:`origin`,center:{x:(a+r)/2,y:(o+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(t,n)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(e,t){if(!(t.scrollbars.isOverEither&&!this.state.multiElement))return!1;OE=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=iT(e=>{e.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),r=rT(()=>{IE=null,OE=!1,cl(this.interactiveCanvas,this.state),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),n.flush()});return IE=r,window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),!0}isASelectedElement(e){return e!=null&&this.state.selectedElementIds[e.id]}isHittingCommonBoundingBoxOfSelectedElements(e,t){if(t.length<2)return!1;let n=this.getElementHitThreshold(),[r,i,a,o]=Zo(t);return e.x>r-n&&e.x<a+n&&e.y>i-n&&e.y<o+n}getCurrentItemRoundness(e){return this.state.currentItemRoundness===`round`?{type:st(e)?pt.ADAPTIVE_RADIUS:pt.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(e,t,n=!1){Fa({event:e,app:this,selectedElements:t})&&(n||!da.getReferenceSnapPoints())&&da.setReferenceSnapPoints(sl(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){Fa({event:e,app:this,selectedElements:t})&&(n||!da.getVisibleGaps())&&da.setVisibleGaps(ca(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return rT(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return rT(t=>{t.key===F.ALT&&t.preventDefault(),!this.maybeHandleResize(e,t)&&this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return iT(t=>{if(this.state.openDialog?.name===`elementLinkSelector`)return;let n=gl(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[e,r]=kr(n.x,n.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(i<0){let t=N.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:r},this.state,this.scene.getNonDeletedElementsMap());i=t?N.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let a=N.moveFixedSegment(this.state.selectedLinearElement,i,e,r,this.scene.getNonDeletedElementsMap());(0,_d.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:a.segmentMidPointHoveredCoords,pointerDownState:a.pointerDownState}})});return}let r=this.lastPointerMoveCoords??e.origin;if(this.lastPointerMoveCoords=n,e.drag.offset===null&&(e.drag.offset=ki(et(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(t,e))return;if(it(this.state)){this.handleEraser(t,e,n);return}this.state.activeTool.type===`laser`&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=kr(n.x,n.y,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!e.drag.hasOccurred&&(this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`)&&Kn(O(n.x,n.y),O(e.origin.x,e.origin.y))<10)return;if(e.resize.isResizing&&(e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeHandleCrop(e,t)||this.maybeHandleResize(e,t)))return!0;let o=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let r=this.state.editingLinearElement||this.state.selectedLinearElement;if(N.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,o)){let e=N.addMidpoint(this.state.selectedLinearElement,n,this,!t[F.CTRL_OR_CMD],o);if(!e)return;(0,_d.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices}})});return}else if(r.pointerDownState.segmentMidpoint.value!==null&&!r.pointerDownState.segmentMidpoint.added)return;if(N.handlePointDragging(t,this,n.x,n.y,(e,t)=>{this.maybeSuggestBindingsForLinearElementAtCoords(e,t)},r,this.scene)){e.lastCoords.x=n.x,e.lastCoords.y=n.y,e.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let s=e.hit.allHitElements.some(e=>this.isASelectedElement(e)),c=this.state.editingLinearElement&&t.shiftKey&&this.state.editingLinearElement.elementId===e.hit.element?.id;if((s||e.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c){let i=this.scene.getSelectedElements(this.state);if(i.every(e=>e.locked))return;let a=i.find(e=>D(e)),s=this.getTopLayerFrameAtSceneCoords(n),c=s&&!a?s:null;if(this.state.frameToHighlight!==c&&(0,_d.flushSync)(()=>{this.setState({frameToHighlight:c})}),e.drag.hasOccurred=!0,i.length>0&&!e.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!==`active`){let a={x:n.x-e.origin.x,y:n.y-e.origin.y},s=[...e.originalElements.values()],c=t.shiftKey;if(c){let e=Math.abs(a.x),t=Math.abs(a.y),n=c&&e<t,r=c&&e>t;n&&(a.x=0),r&&(a.y=0)}if(this.state.croppingElementId){let t=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(t&&Mo(t)&&t.crop!==null&&e.hit.element===t){let e=t.crop,i=Ir(t)&&this.imageCache.get(t.fileId)?.image;if(i&&!(i instanceof Promise)){let a=Oe(An(n.x-r.x,n.y-r.y),Math.max(this.state.zoom.value,2)),[s,c,l,u,d,f]=Er(t,o),p=Jo(uc(O(s,c),O(d,f),t.angle)),m=Jo(uc(O(l,c),O(d,f),t.angle)),h=Jo(uc(O(s,u),O(d,f),t.angle)),g=To(It(m,p)),_=To(It(h,p)),v=An(Ys(a,g),Ys(a,_));U(t,{crop:{...e,x:pa(e.x-v[0]*Math.sign(t.scale[0]),0,i.naturalWidth-e.width),y:pa(e.y-v[1]*Math.sign(t.scale[1]),0,i.naturalHeight-e.height)}});return}}}this.maybeCacheVisibleGaps(t,i),this.maybeCacheReferenceSnapPoints(t,i);let{snapOffset:l,snapLines:u}=hn(s,a,this,t,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:u}),this.state.editingFrame||Da(e,i,a,this.scene,l,t[F.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(i.length!==1||!T(i[0]))&&this.setState({suggestedBindings:or(i,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),t.altKey&&!e.hit.hasBeenDuplicated){e.hit.hasBeenDuplicated=!0;let n=[],r=[],a=new Map,o=new Map,s=e.hit.element,c=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(e=>e.id)),l=this.scene.getElementsIncludingDeleted();for(let t of l){let i=c.has(t.id)||t.id===s?.id&&e.hit.wasAddedToSelection;if(Math.abs(t.x)>1e7||Math.abs(t.x)>1e7||Math.abs(t.width)>1e7||Math.abs(t.height)>1e7){console.error(`Alt+dragging element in scene with invalid dimensions`,t.x,t.y,t.width,t.height,i);return}if(i){let i=kn(this.state.editingGroupId,a,t);if(Math.abs(i.x)>1e7||Math.abs(i.x)>1e7||Math.abs(i.width)>1e7||Math.abs(i.height)>1e7){console.error(`Alt+dragging duplicated element with invalid dimensions`,i.x,i.y,i.width,i.height);return}let s=e.originalElements.get(t.id);if(Math.abs(s.x)>1e7||Math.abs(s.x)>1e7||Math.abs(s.width)>1e7||Math.abs(s.height)>1e7){console.error(`Alt+dragging duplicated element with invalid dimensions`,s.x,s.y,s.width,s.height);return}U(i,{x:s.x,y:s.y}),e.originalElements.set(i.id,i),n.push(i),r.push(t),o.set(t.id,i.id)}else n.push(t)}let u=[...n,...r];u=this.props.onDuplicate?.(u,l)||u,bs(u,E(r)),Wl(n,r,o),vc(u,r,o,`duplicatesServeAsOld`),Cn(u,r,o),this.scene.replaceAllElements(u),this.maybeCacheVisibleGaps(t,i,!0),this.maybeCacheReferenceSnapPoints(t,i,!0)}return}}if(this.state.selectionElement)e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t);else{let r=this.state.newElement;if(!r)return;if(r.type===`freedraw`){let e=r.points,i=n.x-r.x,a=n.y-r.y,o=e.length>0&&e[e.length-1];if(!(o&&o[0]===i&&o[1]===a)){let n=r.simulatePressure?r.pressures:[...r.pressures,t.pressure];U(r,{points:[...e,O(i,a)],pressures:n},!1),this.setState({newElement:r})}}else if(Ac(r)){e.drag.hasOccurred=!0;let o=r.points,s=i-r.x,c=a-r.y;Xa(t)&&o.length===2&&({width:s,height:c}=cr(r.x,r.y,n.x,n.y)),o.length===1?U(r,{points:[...o,O(s,c)]},!1):(o.length===2||o.length>1&&T(r))&&U(r,{points:[...o.slice(0,-1),O(s,c)]},!1,{isDragging:!0}),this.setState({newElement:r}),Jt(r,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(r,[n],this.state.startBoundElement)}else e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t,!1)}if(this.state.activeTool.type===`selection`){e.boxSelection.hasOccurred=!0;let n=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)N.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let r=!0;!t.shiftKey&&mo(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>xt({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):r=!1);let i=this.state.selectionElement?ci(n,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(t=>{let n={...r&&t.selectedElementIds,...i.reduce((e,t)=>(e[t.id]=!0,e),{})};return e.hit.element&&(i.length?delete n[e.hit.element.id]:n[e.hit.element.id]=!0),t=r?t:{...t,selectedGroupIds:{},editingGroupId:null},{...xt({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:i.length===1&&Ac(i[0])?new N(i[0]):null,showHyperlinkPopup:i.length===1&&(i[0].link||dt(i[0]))?`info`:!1}})}}})}handlePointerMoveOverScrollbars(e,t){if(t.scrollbars.isOverHorizontal){let n=e.clientX,r=n-t.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-r/this.state.zoom.value}),t.lastCoords.x=n,!0}if(t.scrollbars.isOverVertical){let n=e.clientY,r=n-t.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-r/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return rT(t=>{this.removePointer(t),e.eventListeners.onMove&&e.eventListeners.onMove.flush();let{newElement:n,resizingElement:r,croppingElementId:i,multiElement:a,activeTool:o,isResizing:s,isRotating:c,isCropping:l}=this.state;this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:`up`,snapLines:oe(e.snapLines,[]),originSnapOffset:null})),this.lastPointerMoveCoords=null,da.setReferenceSnapPoints(null),da.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,`up`),this.setState({selectedElementsAreBeingDragged:!1});let u=this.scene.getNonDeletedElementsMap();if(e.drag.hasOccurred&&e.hit?.element?.id){let t=u.get(e.hit.element.id);Va(t)&&t.boundElements?.filter(e=>e.type===`arrow`).map(e=>u.get(e.id)).filter(e=>T(e)).forEach(e=>{e&&U(e,{},!0)})}if(this.state.editingLinearElement)if(!e.boxSelection.hasOccurred&&e.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(H_);else{let e=N.handlePointerUp(t,this.state.editingLinearElement,this.state,this.scene);e!==this.state.editingLinearElement&&this.setState({editingLinearElement:e,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=N.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&U(e,{},!0)}if(e.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let e=N.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:n,endBindingElement:r}=e,i=this.scene.getElement(e.elementId);Jt(i)&&he(i,n,r,u,this.scene),e!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...e,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(`pointermove`,e.eventListeners.onMove),window.removeEventListener(`pointerup`,e.eventListeners.onUp),window.removeEventListener(`keydown`,e.eventListeners.onKeyDown),window.removeEventListener(`keyup`,e.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(o,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),n?.type===`freedraw`){let e=gl(t,this.state),r=n.points,i=e.x-n.x,a=e.y-n.y;i===r[0][0]&&a===r[0][1]&&(a+=1e-4,i+=1e-4);let o=n.simulatePressure?[]:[...n.pressures,t.pressure];U(n,{points:[...r,O(i,a)],pressures:o,lastCommittedPoint:O(i,a)}),this.actionManager.executeAction(H_);return}if(Mo(n)){let e=n;try{this.initializeImageDimensions(e),this.setState({selectedElementIds:A({[e.id]:!0},this.state)},()=>{this.actionManager.executeAction(H_)})}catch(t){console.error(t),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)),this.actionManager.executeAction(H_)}return}if(Ac(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let r=gl(t,this.state);!e.drag.hasOccurred&&n&&!a?(U(n,{points:[...n.points,O(r.x-n.x,r.y-n.y)]}),this.setState({multiElement:n,newElement:n})):e.drag.hasOccurred&&!a&&(We(this.state)&&Jt(n,!1)&&Ra(n,this.state,r,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),o.locked?this.setState(e=>({newElement:null})):(pi(this.interactiveCanvas),this.setState(e=>({newElement:null,activeTool:Ha(this.state,{type:`selection`}),selectedElementIds:A({...e.selectedElementIds,[n.id]:!0},e),selectedLinearElement:new N(n)}))),this.scene.triggerUpdate());return}if(L(n)){let e=ws(ko({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<e&&U(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(o.type!==`selection`&&n&&Ii(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==n.id),appState:{newElement:null},captureUpdate:M.NEVER});return}if(D(n)){let e=al(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Hc(this.scene.getElementsMapIncludingDeleted(),e,n,this.state))}if(n&&(U(n,Cl(n)),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=gl(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let e=this.scene.getElement(this.state.selectedLinearElement.elementId);if(e?.frameId){let t=Mc(e,u);t&&e&&(Kl(e,t,this.scene.getNonDeletedElementsMap())||(U(e,{groupIds:[]}),Qc([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.getTopLayerFrameAtSceneCoords(e),n=this.scene.getSelectedElements(this.state),r=this.scene.getElementsMapIncludingDeleted(),i=e=>{if(e.length>0){for(let t of e){let e=t.groupIds.indexOf(this.state.editingGroupId);U(t,{groupIds:t.groupIds.slice(0,e)},!1)}r.forEach(e=>{e.groupIds.length&&Ki(r,e.groupIds[e.groupIds.length-1]).length<2&&U(e,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(t&&!this.state.selectedElementIds[t.id]){let e=n.filter(e=>e.frameId!==t.id&&yt(e,r,this.state));this.state.editingGroupId&&i(e),r=Hc(r,e,t,this.state)}else!t&&this.state.editingGroupId&&i(n.filter(e=>e.frameId&&!yt(e,r,this.state)));r=Jl(r,this.state,this),this.scene.replaceAllElements(r)}}if(r&&this.store.shouldCaptureIncrement(),r&&Ii(r)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==r.id),captureUpdate:M.NEVER}),e.resize.isResizing){let e=Jl(this.scene.getElementsIncludingDeleted(),this.state,this),t=this.scene.getSelectedElements(this.state).filter(e=>D(e));for(let n of t)e=_a(e,El(this.scene.getElementsIncludingDeleted(),n,this.state,u),n,this);this.scene.replaceAllElements(e)}let d=e.hit.element;this.state.selectedLinearElement?.elementId!==d?.id&&Ac(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new N(d)}),(!i||i&&(!d&&!l||d&&d.id!==i))&&this.finishImageCropping();let f=this.lastPointerDownEvent,p=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(it(this.state)&&f&&p){if(this.eraserTrail.endPath(),Kn(O(f.clientX,f.clientY),O(p.clientX,p.clientY))===0){let e=gl({clientX:p.clientX,clientY:p.clientY},this.state);this.getElementsAtPosition(e.x,e.y).forEach(e=>this.elementsPendingErasure.add(e.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!e.boxSelection.hasOccurred)&&(t.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?Fo(this.state,d)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of d.groupIds.flatMap(e=>Ki(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...d.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:A(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[d.id];let n=R(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...xt({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:n.length===1&&Ac(n[0])?new N(n[0]):e.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[d.id]:!0};return delete t[d.frameId],(this.scene.getElement(d.frameId)?.groupIds??[]).flatMap(e=>Ki(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...xt({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:d.link||dt(d)?`info`:!1}}):this.setState(e=>({selectedElementIds:A({...e.selectedElementIds,[d.id]:!0},e)})):this.setState(e=>({...xt({editingGroupId:e.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:Ac(d)&&e.selectedLinearElement?.elementId!==d.id?new N(d):e.selectedLinearElement}))),!(d&&T(d))&&!e.drag.hasOccurred&&!this.state.isResizing&&(d&&vl({x:e.origin.x,y:e.origin.y,element:d,shape:Cs(d,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:D(d)?this.frameNameBoundsCache.get(d):null},u)||!d&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:A({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),z(this.interactiveCanvas,W.AUTO);return}if(!o.locked&&o.type!==`freedraw`&&n&&this.setState(e=>({selectedElementIds:A({...e.selectedElementIds,[n.id]:!0},e),showHyperlinkPopup:dt(n)&&!n.link?`editor`:e.showHyperlinkPopup})),(o.type!==`selection`||mo(this.scene.getNonDeletedElements(),this.state)||!Rt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),(e.drag.hasOccurred||s||c||l)&&Ge(this.scene.getSelectedElements(this.state).filter(Ac),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,We(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),o.type===`laser`){this.laserTrails.endPath();return}!o.locked&&o.type!==`freedraw`?(pi(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Ha(this.state,{type:`selection`})})):this.setState({newElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&$.pointers.size<=1&&Oo(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,e.origin.x,e.origin.y)&&this.handleEmbeddableCenterClick(d)})}clearSelection(e){this.setState(t=>({selectedElementIds:A({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&e!=null&&jr(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:A({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(e,t,n,r){if(r){let i=r.x+r.width/2,a=r.y+r.height/2,o=wc(r,n,this.scene.getNonDeletedElementsMap());if(o&&(i=o.x,a=o.y),Math.hypot(e-i,t-a)<30){let{x:e,y:t}=Zr({sceneX:i,sceneY:a},n);return{viewportX:e,viewportY:t,elementCenterX:i,elementCenterY:a}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let{left:e,top:t}=this.excalidrawContainerRef.current.getBoundingClientRect();return{offsetLeft:e,offsetTop:t}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){await Mh(Oh.find(e=>e.code===this.props.langCode)||Dh),this.setAppState({})}};(C.MODE===Si.TEST||C.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(ja(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var RE=LE,zE=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML=``,this.append(...e)})},BE=({children:e})=>{let{FooterCenterTunnel:t}=Ab(),n=Fg();return(0,K.jsx)(t.In,{children:(0,K.jsx)(`div`,{className:I(`footer-center zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})};BE.displayName=`FooterCenter`;var VE=()=>(0,K.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`ExcalidrawLogo-icon`,children:(0,K.jsx)(`path`,{d:`M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z`,fill:`currentColor`})}),HE=()=>(0,K.jsxs)(`svg`,{viewBox:`0 0 450 55`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:`ExcalidrawLogo-text`,children:[(0,K.jsx)(`path`,{d:`M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z`,transform:`translate(-144.023 -51.76)`}),(0,K.jsx)(`path`,{d:`M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z`,transform:`translate(-144.023 -51.76)`}),(0,K.jsx)(`path`,{d:`M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z`,transform:`translate(-144.023 -51.76)`}),(0,K.jsx)(`path`,{d:`m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z`,fill:`currentColor`,transform:`translate(-144.023 -51.76)`})]}),UE=({style:e,size:t=`small`,withText:n})=>(0,K.jsxs)(`div`,{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,K.jsx)(VE,{}),n&&(0,K.jsx)(HE,{})]}),WE=({icon:e,shortcut:t,children:n})=>{let r=vE();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`welcome-screen-menu-item__icon`,children:e}),(0,K.jsx)(`div`,{className:`welcome-screen-menu-item__text`,children:n}),t&&!r.editor.isMobile&&(0,K.jsx)(`div`,{className:`welcome-screen-menu-item__shortcut`,children:t})]})};WE.displayName=`WelcomeScreenMenuItemContent`;var GE=({onSelect:e,children:t,icon:n,shortcut:r,className:i=``,...a})=>(0,K.jsx)(`button`,{...a,type:`button`,className:`welcome-screen-menu-item ${i}`,onClick:e,children:(0,K.jsx)(WE,{icon:n,shortcut:r,children:t})});GE.displayName=`WelcomeScreenMenuItem`;var KE=({children:e,href:t,icon:n,shortcut:r,className:i=``,...a})=>(0,K.jsx)(`a`,{...a,className:`welcome-screen-menu-item ${i}`,href:t,target:`_blank`,rel:`noreferrer`,children:(0,K.jsx)(WE,{icon:n,shortcut:r,children:e})});KE.displayName=`WelcomeScreenMenuItemLink`;var qE=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=Ab();return(0,K.jsx)(t.In,{children:(0,K.jsx)(`div`,{className:`welcome-screen-center`,children:e||(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(JE,{}),(0,K.jsx)(YE,{children:q(`welcomeScreen.defaults.center_heading`)}),(0,K.jsxs)(XE,{children:[(0,K.jsx)(QE,{}),(0,K.jsx)(ZE,{})]})]})})})};qE.displayName=`Center`;var JE=({children:e})=>(0,K.jsx)(`div`,{className:`welcome-screen-center__logo excalifont welcome-screen-decor`,children:e||(0,K.jsx)(UE,{withText:!0})});JE.displayName=`Logo`;var YE=({children:e})=>(0,K.jsx)(`div`,{className:`welcome-screen-center__heading welcome-screen-decor excalifont`,children:e});YE.displayName=`Heading`;var XE=({children:e})=>(0,K.jsx)(`div`,{className:`welcome-screen-menu`,children:e});XE.displayName=`Menu`;var ZE=()=>{let e=CE();return(0,K.jsx)(GE,{onSelect:()=>e.executeAction(sv),shortcut:`?`,icon:En,children:q(`helpDialog.title`)})};ZE.displayName=`MenuItemHelp`;var QE=()=>{let e=Fg(),t=CE();return e.viewModeEnabled?null:(0,K.jsx)(GE,{onSelect:()=>t.executeAction(nv),shortcut:wb(`loadScene`),icon:su,children:q(`buttons.load`)})};QE.displayName=`MenuItemLoadScene`;var $E=({onSelect:e})=>{let{t}=Ih();return(0,K.jsx)(GE,{shortcut:null,onSelect:e,icon:ya,children:t(`labels.liveCollaboration`)})};$E.displayName=`MenuItemLiveCollaborationTrigger`,qE.Logo=JE,qE.Heading=YE,qE.Menu=XE,qE.MenuItem=GE,qE.MenuItemLink=KE,qE.MenuItemHelp=ZE,qE.MenuItemLoadScene=QE,qE.MenuItemLiveCollaborationTrigger=$E;var eD=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=Ab();return(0,K.jsx)(t.In,{children:(0,K.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu`,children:[zo,(0,K.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||q(`welcomeScreen.defaults.menuHint`)})]})})};eD.displayName=`MenuHint`;var tD=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=Ab();return(0,K.jsx)(t.In,{children:(0,K.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar`,children:[(0,K.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||q(`welcomeScreen.defaults.toolbarHint`)}),au]})})};tD.displayName=`ToolbarHint`;var nD=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=Ab();return(0,K.jsx)(t.In,{children:(0,K.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help`,children:[(0,K.jsx)(`div`,{children:e||q(`welcomeScreen.defaults.helpHint`)}),Ec]})})};nD.displayName=`HelpHint`;var rD=e=>(0,K.jsx)(K.Fragment,{children:e.children||(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qE,{}),(0,K.jsx)(eD,{}),(0,K.jsx)(tD,{}),(0,K.jsx)(nD,{})]})});rD.displayName=`WelcomeScreen`,rD.Center=qE,rD.Hints={MenuHint:eD,ToolbarHint:tD,HelpHint:nD};var iD=({isCollaborating:e,onSelect:t,...n})=>{let r=Fg(),i=r.width<830;return(0,K.jsxs)(xb,{...n,className:I(`collab-button`,{active:e}),type:`button`,onSelect:t,style:{position:`relative`,width:i?void 0:`auto`},title:q(`labels.liveCollaboration`),children:[i?$n:q(`labels.share`),r.collaborators.size>0&&(0,K.jsx)(`div`,{className:`CollabButton-collaborators`,children:r.collaborators.size})]})};iD.displayName=`LiveCollaborationTrigger`,(0,kp.default)((e,t,n)=>{(C.DEV||C.MODE===Si.TEST||window?.DEBUG_FRACTIONAL_INDICES)&&zl(ja(e.map(e=>({...e}))),{shouldThrow:C.DEV||C.MODE===Si.TEST,includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})},1e3*60,{leading:!0,trailing:!1});var aD=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:n}=Ab(),r=SE();return(0,K.jsx)(n.In,{children:(0,K.jsxs)(X.Item,{onSelect:()=>{Y(`ai`,`dialog open`,`ttd`),r({openDialog:{name:`ttd`,tab:`text-to-diagram`}})},icon:t??ls,children:[e??q(`labels.textToDiagram`),(0,K.jsx)(X.Item.Badge,{children:`AI`})]})})};aD.displayName=`TTDDialogTrigger`,zE();var oD=G.memo(e=>{let{onChange:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:o,langCode:s=Dh.code,viewModeEnabled:c,zenModeEnabled:l,gridModeEnabled:u,libraryReturnUrl:d,theme:f,name:p,renderCustomStats:m,onPaste:h,detectScroll:g=!0,handleKeyboardGlobally:_=!1,onLibraryChange:y,autoFocus:b=!1,generateIdForFile:x,onLinkOpen:S,generateLinkForSelection:ee,onPointerDown:te,onPointerUp:ne,onScrollChange:re,onDuplicate:C,children:w,validateEmbeddable:ie,renderEmbeddable:ae,aiEnabled:oe,showDeprecatedFonts:se}=e,ce=e.UIOptions?.canvasActions,T={...e.UIOptions,canvasActions:{...xe.canvasActions,...ce},tools:{image:e.UIOptions?.tools?.image??!0}};return ce?.export&&(T.canvasActions.export.saveFileToDisk=ce.export?.saveFileToDisk??xe.canvasActions.export.saveFileToDisk),T.canvasActions.toggleTheme===null&&typeof f>`u`&&(T.canvasActions.toggleTheme=!0),(0,G.useEffect)(()=>{(async()=>{await v(()=>import(`./roundRect-D01gJrlt.js`),[])})();let e=e=>{typeof e.scale==`number`&&e.scale!==1&&e.preventDefault()};return document.addEventListener(`touchmove`,e,{passive:!1}),()=>{document.removeEventListener(`touchmove`,e)}},[]),(0,K.jsx)(Ch,{store:wh,children:(0,K.jsx)(zh,{langCode:s,theme:f,children:(0,K.jsx)(RE,{onChange:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:o,langCode:s,viewModeEnabled:c,zenModeEnabled:l,gridModeEnabled:u,libraryReturnUrl:d,theme:f,name:p,renderCustomStats:m,UIOptions:T,onPaste:h,detectScroll:g,handleKeyboardGlobally:_,onLibraryChange:y,autoFocus:b,generateIdForFile:x,onLinkOpen:S,generateLinkForSelection:ee,onPointerDown:te,onPointerUp:ne,onScrollChange:re,onDuplicate:C,validateEmbeddable:ie,renderEmbeddable:ae,aiEnabled:oe!==!1,showDeprecatedFonts:se,children:w})})})},(e,t)=>{if(e.children!==t.children)return!1;let{initialData:n,UIOptions:r={},...i}=e,{initialData:a,UIOptions:o={},...s}=t,c=Object.keys(r),l=Object.keys(o);return c.length===l.length?c.every(e=>e===`canvasActions`?Object.keys(r.canvasActions).every(e=>e===`export`&&r?.canvasActions?.export&&o?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===o.canvasActions.export.saveFileToDisk:r?.canvasActions?.[e]===o?.canvasActions?.[e]):r[e]===o[e])&&Rt(i,s):!1});oD.displayName=`Excalidraw`;var sD=class extends Error{status;constructor(e,t){super(e),this.status=t}};function cD(e){let t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function lD(e){return e.replace(/^\.\//,``).replace(/^\/+/,``)}function uD(e,t){return!e||!t?!1:lD(e)===lD(t)}function dD(){return(0,K.jsxs)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2Z`}),(0,K.jsx)(`path`,{d:`M17 21v-8H7v8`}),(0,K.jsx)(`path`,{d:`M7 3v5h8`})]})}function fD(){return(0,K.jsxs)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`path`,{d:`M21 12a9 9 0 1 1-2.64-6.36`}),(0,K.jsx)(`path`,{d:`M21 3v6h-6`})]})}function pD({open:e}){return(0,K.jsx)(`svg`,{"aria-hidden":`true`,className:`h-4 w-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,K.jsx)(`path`,{d:e?`m18 15-6-6-6 6`:`m6 9 6 6 6-6`})})}var mD=`Make this sketch into a polished diagram illustration.`,hD=`boring-diagram:render-prompts:v1`,gD=20;function _D(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(hD),t=e?JSON.parse(e):[];return Array.isArray(t)?t.flatMap(e=>!e||typeof e.prompt!=`string`||!e.prompt.trim()?[]:[{id:typeof e.id==`string`&&e.id?e.id:xD(),label:typeof e.label==`string`&&e.label?e.label:yD(e.prompt),prompt:e.prompt,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:new Date().toISOString()}]).slice(0,gD):[]}catch{return[]}}function vD(e){if(!(typeof window>`u`))try{window.localStorage.setItem(hD,JSON.stringify(e.slice(0,gD)))}catch{}}function yD(e){let t=e.trim().replace(/\s+/g,` `);return t.length>48?`${t.slice(0,45)}…`:t||`Untitled prompt`}function bD(e,t){let n=t.trim();if(!n)return e;let r=new Date().toISOString(),i=e.find(e=>e.prompt.trim()===n),a=i?{...i,label:yD(n),updatedAt:r}:{id:xD(),label:yD(n),prompt:n,updatedAt:r};return[a,...e.filter(e=>e.id!==a.id&&e.prompt.trim()!==n)].slice(0,gD)}function xD(){return globalThis.crypto?.randomUUID?.()??`prompt-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}async function SD(e){return(await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=()=>n(r.error??Error(`Failed to read image blob`)),r.readAsDataURL(e)})).replace(/^data:[^;]+;base64,/,``)}function CD(e){return`${e.provider}:${e.id}`}function wD(e,t,n,r){return ve(t,{...n,name:te(e)},r,`local`)}async function TD(e){if(!e.trim())return{elements:[],appState:{},files:{}};let t=JSON.parse(e);return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState&&typeof t.appState==`object`?t.appState:{},files:t.files&&typeof t.files==`object`?t.files:{}}}function ED(e){return e.replace(/\.png$/i,`.json`)}async function DD(e,t){if(e.byteLength===0)return{elements:[],appState:{},files:{}};let n=await Jn(new Blob([cD(e)],{type:t}),null,null);return{elements:n.elements??[],appState:n.appState??{},files:n.files??{}}}function OD({params:e}){let t=e?.path??``,n=typeof e?.filesystem==`string`&&e.filesystem?e.filesystem:void 0,r=n&&n!==`user`?n:void 0,i=e?.mode===`view`,o=(0,G.useMemo)(()=>te(t),[t]),s=(0,G.useMemo)(()=>S(t),[t]),c=(0,G.useMemo)(()=>ne(t),[t]),l=re(),d=y(),f=(0,G.useRef)(null),p=(0,G.useRef)(0),m=(0,G.useRef)(!1),h=(0,G.useRef)(!1),g=(0,G.useRef)(!1),_=(0,G.useRef)(null),v=(0,G.useRef)(``),b=(0,G.useRef)(null),x=(0,G.useRef)(!1),C=(0,G.useRef)(null),w=(0,G.useRef)(0),ie=(0,G.useRef)({}),ae=(0,G.useRef)(new Set),oe=(0,G.useRef)(async()=>{}),se=(0,G.useRef)(async()=>{}),ce=(0,G.useRef)([]),[T,le]=(0,G.useState)(0),[ue,de]=(0,G.useState)(0),[fe,pe]=(0,G.useState)(!1),[me,he]=(0,G.useState)(`Loading editor…`),[ge,_e]=(0,G.useState)(!1),[ve,ye]=(0,G.useState)(null),[be,xe]=(0,G.useState)(`diagram`),[Se,Ce]=(0,G.useState)(!1),[we,Te]=(0,G.useState)(mD),[Ee,De]=(0,G.useState)(()=>_D()),[Oe,ke]=(0,G.useState)([]),[Ae,je]=(0,G.useState)(null),[Me,Ne]=(0,G.useState)(null),[Pe,Fe]=(0,G.useState)(!1),[Ie,Re]=(0,G.useState)(null),[ze,Be]=(0,G.useState)(0),[Ve,He]=(0,G.useState)(!1),[Ue,We]=(0,G.useState)(null),[Ge,Ke]=(0,G.useState)(null),[qe,Je]=(0,G.useState)(!1),E=(0,G.useMemo)(()=>[t,r??`user`,i?`view`:`edit`,String(T)].join(`\0`),[r,t,T,i]),Ye=(0,G.useRef)(null),D=(0,G.useMemo)(()=>{let e={};return d&&(e[`x-boring-workspace-id`]=String(d)),e},[d]);(0,G.useEffect)(()=>{xe(`diagram`),Re(null),Be(0),He(!1),We(null),Ke(null),Je(!1)},[E]);let Xe=(0,G.useCallback)(e=>{let t=new URLSearchParams({path:e});return r&&t.set(`filesystem`,r),t.toString()},[r]),Ze=(0,G.useCallback)(async e=>{let t=await fetch(`${l}/api/v1/files?${Xe(e)}`,{credentials:`include`,headers:D});if(!t.ok)throw new sD(`Failed to load ${e}: ${t.status}`,t.status);let n=await t.json();return{content:typeof n.content==`string`?n.content:``,mtimeMs:typeof n.mtimeMs==`number`?n.mtimeMs:void 0,access:n.access===`readonly`||n.access===`readwrite`?n.access:void 0}},[l,Xe,D]);(0,G.useEffect)(()=>{if(!c)return;let e=!1;return fetch(`${l}/api/v1/files/raw?${Xe(c)}`,{credentials:`include`,headers:D}).then(t=>{e||!t.ok||(Re(c),Be(Date.now()),He(!1))}).catch(()=>{}),()=>{e=!0}},[l,Xe,c,D]);let Qe=(0,G.useCallback)(async e=>{try{let t=await Ze(e);ie.current[e]=t.mtimeMs}catch(t){ie.current[e]=void 0,t instanceof sD&&t.status===404&&ae.current.add(e)}},[Ze]),$e=(0,G.useCallback)((e,t)=>{let n=f.current;if(!n)return;w.current=Date.now()+1e3,n.resetScene(),n.updateScene({elements:e.elements,appState:e.appState});let r=Object.values(e.files);r.length>0&&n.addFiles(r),n.history.clear(),b.current=e,v.current=wD(t,e.elements,e.appState,e.files)},[]),et=(0,G.useCallback)(async()=>{if(!fe)return;let e=f.current;if(!e)return;if(await se.current(),Ye.current===null)Ye.current=E;else if(Ye.current!==E){Ye.current=E,f.current=null,pe(!1),de(e=>e+1);return}let n=++p.current;m.current=!1,g.current=!1,_.current=null,v.current=``,b.current=null,x.current=!1,C.current!==null&&window.clearTimeout(C.current),ie.current={},ae.current=new Set,_e(!1),ye(null);try{if(!t){let t=await Ze(s).catch(e=>{if(e instanceof sD&&e.status===404)return ae.current.add(s),null;throw e});if(n!==p.current)return;if(t){let e=await TD(t.content);ie.current[s]=t.mtimeMs,$e(e,s);let n=i||t.access===`readonly`;g.current=n,_e(n),m.current=!0,he(n?`Loaded ${s} read-only`:`Loaded ${s}`);return}e.resetScene(),e.history.clear(),b.current={elements:[],appState:{},files:{}},v.current=wD(s,[],{},{}),g.current=i,_e(i),m.current=!0,he(i?`New drawing — read-only`:`New drawing — saves to ${s}`);return}he(`Loading ${o}…`);let a,c=!1,u;if(t.toLowerCase().endsWith(`.excalidraw`)){let e=await Ze(t);if(n!==p.current)return;ie.current[s]=e.mtimeMs,u=e.access,a=await TD(e.content)}else{let e=await Ze(s).catch(e=>{if(e instanceof sD&&e.status===404)return ae.current.add(s),null;throw e});if(n!==p.current)return;if(e){ie.current[s]=e.mtimeMs,u=e.access;try{a=await TD(e.content),he(`Loaded ${s} sidecar for ${t}`)}catch(e){if(r)throw e;let i=await fetch(`${l}/api/v1/files/raw?${Xe(t)}`,{credentials:`include`,headers:D});if(!i.ok)throw Error(`Failed to load ${t}: ${i.status}`);let o=await i.arrayBuffer();if(n!==p.current)return;u=`readonly`,a=await DD(new Uint8Array(o),i.headers.get(`content-type`)??`image/png`),he(`Loaded embedded PNG from ${t}; ${s} sidecar is invalid and was not overwritten`)}}else{if(r)throw u=(await Ze(t).catch(()=>null))?.access,Error(`Opening ${t} from filesystem ${r} requires an existing ${s} sidecar; binary PNG import is only supported for workspace files.`);let e=await fetch(`${l}/api/v1/files/raw?${Xe(t)}`,{credentials:`include`,headers:D});if(!e.ok)throw Error(`Failed to load ${t}: ${e.status}`);let i=await e.arrayBuffer();if(n!==p.current)return;await Qe(s),c=!0,a=await DD(new Uint8Array(i),e.headers.get(`content-type`)??`image/png`)}}if(n!==p.current)return;$e(a,s);let d=i||u===`readonly`;g.current=d,_e(d),m.current=!0,c&&!d&&await oe.current({token:n,target:s,json:v.current}),he(d?`Loaded ${t} read-only`:t===s?`Loaded ${t}`:`Loaded ${t} — edits save to ${s}`)}catch(e){if(n!==p.current)return;m.current=!1;let t=e instanceof Error?e.message:String(e);ye(t),he(`Load failed — saving disabled`)}},[l,$e,fe,Xe,E,t,Ze,Qe,D,s,o,i]),tt=(0,G.useCallback)(async e=>{if(!(e.token!==p.current||!m.current||g.current)){if(h.current){_.current=e,he(`Save queued for ${e.target}…`),await new Promise(e=>ce.current.push(e));return}h.current=!0,he(`Saving ${e.target}…`),ye(null);try{let t={path:e.target,content:e.json,createDirs:!0};r&&(t.filesystem=r);let n=ie.current[e.target];typeof n==`number`&&(t.expectedMtimeMs=n),typeof n!=`number`&&ae.current.has(e.target)&&await Ze(e.target).then(()=>{throw Error(`${e.target} now exists. Reload before saving again.`)},e=>{if(!(e instanceof sD&&e.status===404))throw e});let i=await fetch(`${l}/api/v1/files`,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`,...D},body:JSON.stringify(t)});if(i.status===409)throw Error(`Save conflict: file changed on disk. Reload before saving again.`);if(!i.ok){let t=await i.text().catch(()=>``);throw Error(`Failed to save ${e.target}: ${i.status}${t?` ${t}`:``}`)}let a=await i.json().catch(()=>null);if(e.token!==p.current)return;ie.current[e.target]=typeof a?.mtimeMs==`number`?a.mtimeMs:void 0,ae.current.delete(e.target),he(`Saved ${e.target}`)}catch(t){if(e.token!==p.current)return;m.current=!1,_.current=null;let n=t instanceof Error?t.message:String(t);ye(n),he(`Save disabled — reload required`)}finally{h.current=!1;let e=_.current;if(_.current=null,e&&e.token===p.current&&m.current&&await tt(e),!h.current&&!_.current){let e=ce.current.splice(0);for(let t of e)t()}}}},[l,r,D]);oe.current=tt;let nt=(0,G.useCallback)(()=>{let e=f.current;if(g.current){he(`Read-only — saving disabled`);return}if(!e||!m.current){ye(`Refusing to save before the workspace file has loaded successfully`),he(`Save unavailable`);return}let t={elements:e.getSceneElements(),appState:e.getAppState(),files:e.getFiles()};b.current=t;let n=wD(s,t.elements,t.appState,t.files);v.current=n,x.current=!1,tt({token:p.current,target:s,json:n})},[s,tt]),rt=(0,G.useCallback)(async()=>{let e=await fetch(`${l}/api/v1/plugins/diagram/render/models`,{credentials:`include`,headers:D});if(!e.ok)throw Error(`Failed to load render models: ${e.status}`);let t=await e.json(),n=Array.isArray(t.models)?t.models:[];ke(n),Ne(t.authHint??null);let r=n.find(e=>e.available),i=t.defaultModel,a=i&&n.some(e=>CD(e)===CD(i))?i:r?{provider:r.provider,id:r.id}:null;je(e=>e&&n.some(t=>CD(t)===CD(e))?e:a)},[l,D]),it=(0,G.useCallback)(()=>{let e=bD(Ee,we);De(e),vD(e)},[Ee,we]),at=(0,G.useCallback)(async()=>{let e=f.current;if(!e||!m.current){ye(`Refusing to render before the workspace file has loaded successfully`),he(`Render unavailable`);return}if(r){ye(`Render is only supported for default workspace files right now`),he(`Render unavailable`);return}let n=we.trim();if(!n){ye(`Enter a render prompt`),he(`Render prompt required`);return}Fe(!0),ye(null),he(`Rendering image…`);try{if(await se.current(),!m.current)throw Error(`Save failed before render. Reload or resolve the save conflict before rendering.`);let r={elements:e.getSceneElements(),appState:e.getAppState(),files:e.getFiles()};b.current=r;let i={...r.appState,exportWithDarkMode:!1,viewBackgroundColor:r.appState.viewBackgroundColor??`#ffffff`},a=await SD(await Le({elements:r.elements.filter(e=>!e.isDeleted),appState:i,files:r.files,mimeType:`image/png`,exportPadding:32})),o=await fetch(`${l}/api/v1/plugins/diagram/render`,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`,...D},body:JSON.stringify({path:t,prompt:n,model:Ae?CD(Ae):void 0,sketchPngBase64:a,mimeType:`image/png`})}),s=await o.json().catch(()=>({})),c=typeof s.error==`string`?s.error:s.error?.message;if(!o.ok||!s.path)throw Error(c||`Render failed: ${o.status}`);Re(s.path),Be(Date.now()),He(!1),xe(`image`);let u=bD(Ee,n);De(u),vD(u),he(`Rendered ${s.path}`)}catch(e){let t=e instanceof Error?e.message:String(e);ye(t),he(`Render failed`)}finally{Fe(!1)}},[l,r,t,Ee,we,D,Ae]),ot=(0,G.useCallback)((e,t,n)=>{if(Date.now()<w.current||(b.current={elements:e,appState:t,files:n},g.current||!m.current))return;let r;try{r=wD(s,e,t,n)}catch(e){m.current=!1,ye(e instanceof Error?e.message:String(e)),he(`Editor error — saving disabled`);return}r!==v.current&&(Ie&&He(!0),x.current=!0,C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{m.current&&(x.current=!1,v.current=r,tt({token:p.current,target:s,json:r}))},900))},[Ie,s,tt]);return(0,G.useEffect)(()=>{et()},[et,T]),(0,G.useEffect)(()=>{Se&&rt().catch(e=>{ke([]),Ne(e instanceof Error?e.message:String(e))})},[rt,Se]),(0,G.useEffect)(()=>{if(!Ie){We(null),Ke(null);return}let e=!1,t=ED(Ie);return Ze(t).then(t=>{e||(We(JSON.parse(t.content)),Ke(null))}).catch(t=>{e||(We(null),Ke(t instanceof Error?t.message:String(t)))}),()=>{e=!0}},[Ze,Ie,ze]),(0,G.useEffect)(()=>{if(typeof EventSource>`u`)return;let e=new URLSearchParams;d&&e.set(`workspaceId`,String(d));let n=`${l}/api/v1/fs/events${e.toString()?`?${e.toString()}`:``}`,r=new EventSource(n,{withCredentials:!0}),i=e=>{let n=e.change;if(!n||n.op===`mkdir`)return!1;let r=n.path,i=n.oldPath,a=uD(r,t)||uD(i,t),o=uD(r,s)||uD(i,s);if(!a&&!o||h.current||x.current)return!1;let c=ie.current[s];return!(n.op===`write`&&typeof c==`number`&&n.mtimeMs===c)},a=e=>{he(`${e} — reloading…`),le(e=>e+1)};return r.addEventListener(`change`,e=>{try{let t=JSON.parse(e.data);i(t)&&a(`External file change detected`)}catch{}}),r.addEventListener(`resync-required`,()=>a(`File watcher resync required`)),r.addEventListener(`unsupported`,()=>r.close()),()=>r.close()},[l,t,s,d]),se.current=async()=>{if(C.current!==null&&(window.clearTimeout(C.current),C.current=null),!g.current&&x.current&&m.current){let e=f.current,t=e?{elements:e.getSceneElements(),appState:e.getAppState(),files:e.getFiles()}:b.current;if(t){let e=wD(s,t.elements,t.appState,t.files);x.current=!1,e!==v.current&&(v.current=e,await tt({token:p.current,target:s,json:e}))}}(h.current||_.current)&&await new Promise(e=>ce.current.push(e))},(0,G.useEffect)(()=>()=>{se.current()},[]),(0,K.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground`,children:[(0,K.jsxs)(u,{className:`shrink-0 border-b border-border px-3 py-2`,children:[(0,K.jsx)(a,{children:(0,K.jsxs)(`div`,{className:`inline-flex rounded-md border border-border bg-muted/50 p-0.5 text-xs`,children:[(0,K.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 ${be===`diagram`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>{xe(`diagram`),Ce(!1)},children:`Diagram`}),(0,K.jsxs)(`button`,{type:`button`,className:`rounded px-2 py-1 ${be===`image`?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>{xe(`image`),Ce(!0)},children:[`Image`,Ve?` *`:``]})]})}),(0,K.jsx)(a,{children:(0,K.jsxs)(`span`,{className:`max-w-[42vw] truncate text-xs text-muted-foreground`,title:ve?`${me} — ${ve}`:me,children:[me,ge?` — read-only`:``,Ve?` — render stale`:``,ve?` — ${ve}`:``]})}),(0,K.jsxs)(a,{className:`ml-auto gap-1`,children:[(0,K.jsx)(`button`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,type:`button`,disabled:ge,onClick:nt,"aria-label":ge?`Read-only`:`Save now`,title:ge?`Read-only`:`Save now`,children:(0,K.jsx)(dD,{})}),(0,K.jsx)(`button`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,type:`button`,"aria-label":`Reload`,title:`Reload`,onClick:()=>{(async()=>{await se.current(),le(e=>e+1)})()},children:(0,K.jsx)(fD,{})})]})]}),be===`image`?(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-background/95 text-sm shadow-sm`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center justify-between px-3 text-left text-xs font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground`,"aria-expanded":Se,onClick:()=>Ce(e=>!e),children:[(0,K.jsxs)(`span`,{children:[`Image render controls`,Ve?` — stale`:``]}),(0,K.jsx)(pD,{open:Se})]}),Se?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 pb-3 md:flex-row md:items-end`,children:[(0,K.jsxs)(`label`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:[`Prompt`,(0,K.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 sm:flex-row`,children:[(0,K.jsxs)(`select`,{className:`h-9 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm text-foreground outline-none focus:border-ring disabled:opacity-60`,value:``,disabled:Ee.length===0,"aria-label":`Prompt catalog`,onChange:e=>{let t=Ee.find(t=>t.id===e.target.value);t&&Te(t.prompt)},children:[(0,K.jsx)(`option`,{value:``,children:Ee.length===0?`No saved prompts`:`Saved prompts…`}),Ee.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,K.jsx)(`button`,{type:`button`,className:`inline-flex h-9 shrink-0 items-center justify-center rounded-md border border-border px-3 text-sm text-muted-foreground hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!we.trim(),onClick:it,children:`Save prompt`})]}),(0,K.jsx)(`textarea`,{className:`mt-2 h-20 w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-ring`,placeholder:`Make this sketch into a polished product architecture illustration…`,value:we,onChange:e=>Te(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),at())}})]}),(0,K.jsxs)(`div`,{className:`w-full text-xs font-medium text-muted-foreground md:w-72`,children:[`Model`,(0,K.jsx)(`div`,{className:`mt-1`,children:(0,K.jsx)(ee,{value:Ae,onChange:je,options:Oe,disabled:Pe||Oe.length===0})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,className:`inline-flex h-9 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:Pe||!we.trim()||!Ae,onClick:()=>void at(),children:Pe?`Rendering…`:`Render`}),(0,K.jsx)(`button`,{type:`button`,className:`inline-flex h-9 items-center rounded-md px-3 text-sm text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>Ce(!1),children:`Cancel`})]})]}),Me?(0,K.jsx)(`div`,{className:`px-3 pb-3 text-xs text-amber-600`,children:Me}):null]}):null]}):null,(0,K.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 bg-white text-black`,children:[(0,K.jsx)(`div`,{className:be===`diagram`?`h-full`:`hidden h-full`,children:(0,K.jsx)(oD,{excalidrawAPI:e=>{f.current=e,pe(!0)},onChange:ot,viewModeEnabled:ge,UIOptions:{canvasActions:{loadScene:!0,saveToActiveFile:!1,export:{saveFileToDisk:!0}}}},ue)}),be===`image`?(0,K.jsx)(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/20 text-foreground`,children:Ie?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`shrink-0 border-b border-border bg-background/95 text-sm shadow-sm`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center justify-between gap-3 px-3 text-left text-xs font-medium text-muted-foreground hover:bg-muted/60 hover:text-foreground`,"aria-expanded":qe,onClick:()=>Je(e=>!e),children:[(0,K.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Render metadata`,Ue?.model?.provider?` — ${Ue.model.provider}:${Ue.model.id??``}`:``,Ue?.generatedAt?` — ${new Date(Ue.generatedAt).toLocaleString()}`:``,!Ue&&Ge?` — unavailable`:``]}),(0,K.jsx)(pD,{open:qe})]}),qe?(0,K.jsxs)(`div`,{className:`space-y-3 px-3 pb-3 text-sm text-foreground`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[`Metadata file: `,ED(Ie)]}),(0,K.jsxs)(`span`,{children:[`Output: `,Ue?.outputPath||Ie]})]}),Ue?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Prompt`}),(0,K.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap rounded-md bg-muted/50 p-2 text-xs leading-relaxed`,children:Ue.prompt?.text||`—`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs md:grid-cols-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Model`}),(0,K.jsx)(`div`,{className:`mt-0.5 break-words`,children:Ue.model?.provider?`${Ue.model.provider}:${Ue.model.id??``}`:`—`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Generated`}),(0,K.jsx)(`div`,{className:`mt-0.5 break-words`,children:Ue.generatedAt?new Date(Ue.generatedAt).toLocaleString():`—`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Source`}),(0,K.jsx)(`div`,{className:`mt-0.5 break-words`,children:Ue.sourcePath||`—`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium text-muted-foreground`,children:`Output`}),(0,K.jsx)(`div`,{className:`mt-0.5 break-words`,children:Ue.outputPath||Ie})]})]}),(0,K.jsxs)(`details`,{className:`text-xs`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:`Raw JSON`}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-md bg-muted/50 p-2 text-[11px] leading-relaxed`,children:JSON.stringify(Ue,null,2)})]})]}):(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Ge?`Metadata unavailable: ${Ge}`:`Loading metadata…`})]}):null]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-6`,children:(0,K.jsx)(`img`,{className:`max-h-full max-w-full rounded-lg border border-border bg-white object-contain shadow-sm`,src:`${l}/api/v1/files/raw?${Xe(Ie)}&renderVersion=${ze}`,alt:`Rendered ${Ie}`})})]}):(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center text-sm text-muted-foreground`,children:[(0,K.jsx)(`div`,{children:`No rendered image yet.`}),(0,K.jsxs)(`div`,{children:[`Use Render to create `,c,` from the current diagram.`]}),(0,K.jsx)(`button`,{type:`button`,className:`inline-flex h-9 items-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground`,onClick:()=>{xe(`image`),Ce(!0)},children:`Open render prompt`})]})}):null]})]})}export{OD as DiagramPane};
|