@dwelle/excalidraw 0.5.0-b8a955d → 0.5.0-ba41ca2
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/CHANGELOG.md +201 -0
- package/README.md +111 -14
- package/dist/dev/{chunk-KB3DXHSJ.js → chunk-63SUNQT5.js} +11160 -6728
- package/dist/dev/chunk-63SUNQT5.js.map +7 -0
- package/dist/dev/chunk-72CYJXY3.js +69 -0
- package/dist/dev/chunk-72CYJXY3.js.map +7 -0
- package/dist/dev/{chunk-VHBP2L6P.js → chunk-GLSDDV5C.js} +2 -2
- package/dist/dev/{chunk-XIXZ3HJO.js → chunk-ZKWD6VD3.js} +58 -10
- package/dist/dev/chunk-ZKWD6VD3.js.map +7 -0
- package/dist/dev/components/TTDDialog/CodeMirrorEditor-YNPNZUA4.js +259 -0
- package/dist/dev/components/TTDDialog/CodeMirrorEditor-YNPNZUA4.js.map +7 -0
- package/dist/dev/data/{image-YTAF2QAV.js → image-LSHTDYDI.js} +3 -3
- package/dist/dev/index.css +955 -752
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +13606 -7440
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{ar-SA-JK5MQ7TT.js → ar-SA-EW44IW4V.js} +127 -28
- package/dist/dev/locales/ar-SA-EW44IW4V.js.map +7 -0
- package/dist/dev/locales/{az-AZ-2PAD62G4.js → az-AZ-AI7WAYA2.js} +103 -4
- package/dist/dev/locales/az-AZ-AI7WAYA2.js.map +7 -0
- package/dist/dev/locales/{bg-BG-HUKVYCRK.js → bg-BG-43ZNGDXF.js} +104 -5
- package/dist/dev/locales/bg-BG-43ZNGDXF.js.map +7 -0
- package/dist/dev/locales/{bn-BD-V2CQI46P.js → bn-BD-PU4CN7NP.js} +103 -4
- package/dist/dev/locales/bn-BD-PU4CN7NP.js.map +7 -0
- package/dist/dev/locales/{bn-IN-MBEO4C3J.js → bn-IN-54CF43JL.js} +103 -4
- package/dist/dev/locales/bn-IN-54CF43JL.js.map +7 -0
- package/dist/dev/locales/{ca-ES-KWEKW4C3.js → ca-ES-RHJO3QDO.js} +105 -6
- package/dist/dev/locales/ca-ES-RHJO3QDO.js.map +7 -0
- package/dist/dev/locales/{cs-CZ-W5AHZB5H.js → cs-CZ-ZRSAO3BA.js} +104 -5
- package/dist/dev/locales/cs-CZ-ZRSAO3BA.js.map +7 -0
- package/dist/dev/locales/{da-DK-ITTM6YM4.js → da-DK-OAB6DEJX.js} +103 -4
- package/dist/dev/locales/da-DK-OAB6DEJX.js.map +7 -0
- package/dist/dev/locales/{de-CH-OAWPDQFJ.js → de-CH-QF7JLXTF.js} +181 -82
- package/dist/dev/locales/de-CH-QF7JLXTF.js.map +7 -0
- package/dist/dev/locales/{de-DE-ZRDYEPMS.js → de-DE-5ZO4KOPT.js} +175 -76
- package/dist/dev/locales/de-DE-5ZO4KOPT.js.map +7 -0
- package/dist/dev/locales/{el-GR-QXASZLPE.js → el-GR-F74ZSUEO.js} +105 -6
- package/dist/dev/locales/el-GR-F74ZSUEO.js.map +7 -0
- package/dist/dev/locales/{en-RTISGYJB.js → en-JNOPSYVP.js} +6 -2
- package/dist/dev/locales/{es-ES-VLQBB7FJ.js → es-ES-3B3IENPS.js} +162 -63
- package/dist/dev/locales/es-ES-3B3IENPS.js.map +7 -0
- package/dist/dev/locales/{eu-ES-TF2DGTZU.js → eu-ES-NH447TVU.js} +221 -122
- package/dist/dev/locales/eu-ES-NH447TVU.js.map +7 -0
- package/dist/dev/locales/{fa-IR-ITKFQ7QV.js → fa-IR-GHKV6Q2J.js} +110 -11
- package/dist/dev/locales/fa-IR-GHKV6Q2J.js.map +7 -0
- package/dist/dev/locales/{fi-FI-UWZRVXFI.js → fi-FI-ZXSYWCC4.js} +104 -5
- package/dist/dev/locales/fi-FI-ZXSYWCC4.js.map +7 -0
- package/dist/dev/locales/{fr-FR-A72LKGCO.js → fr-FR-RJSOSEYS.js} +105 -6
- package/dist/dev/locales/fr-FR-RJSOSEYS.js.map +7 -0
- package/dist/dev/locales/{gl-ES-2QCVIBFP.js → gl-ES-NAUVMVFY.js} +104 -5
- package/dist/dev/locales/gl-ES-NAUVMVFY.js.map +7 -0
- package/dist/dev/locales/{he-IL-WJNUHU26.js → he-IL-JBKWWR75.js} +162 -63
- package/dist/dev/locales/he-IL-JBKWWR75.js.map +7 -0
- package/dist/dev/locales/{hi-IN-XGMO235V.js → hi-IN-SD773MVZ.js} +113 -14
- package/dist/dev/locales/hi-IN-SD773MVZ.js.map +7 -0
- package/dist/dev/locales/{hu-HU-37FDQFIS.js → hu-HU-OTA7GOAV.js} +193 -94
- package/dist/dev/locales/hu-HU-OTA7GOAV.js.map +7 -0
- package/dist/dev/locales/{id-ID-EJIDCO4E.js → id-ID-2JAZWVTQ.js} +155 -56
- package/dist/dev/locales/id-ID-2JAZWVTQ.js.map +7 -0
- package/dist/dev/locales/{it-IT-X34PIOJ2.js → it-IT-GHWUAT77.js} +105 -6
- package/dist/dev/locales/it-IT-GHWUAT77.js.map +7 -0
- package/dist/dev/locales/{ja-JP-37FC23PR.js → ja-JP-YMGRGBPS.js} +207 -108
- package/dist/dev/locales/ja-JP-YMGRGBPS.js.map +7 -0
- package/dist/dev/locales/{kaa-7ZYDFVKA.js → kaa-RRE7XUCW.js} +103 -4
- package/dist/dev/locales/kaa-RRE7XUCW.js.map +7 -0
- package/dist/dev/locales/{kab-KAB-MILWXBA6.js → kab-KAB-ZCYVOJU4.js} +104 -5
- package/dist/dev/locales/kab-KAB-ZCYVOJU4.js.map +7 -0
- package/dist/dev/locales/{kk-KZ-7BWTPIAV.js → kk-KZ-TO6XEFJC.js} +103 -4
- package/dist/dev/locales/kk-KZ-TO6XEFJC.js.map +7 -0
- package/dist/dev/locales/{km-KH-BV4P2KSZ.js → km-KH-3HTDL5HB.js} +104 -5
- package/dist/dev/locales/km-KH-3HTDL5HB.js.map +7 -0
- package/dist/dev/locales/{ko-KR-TSXE5P7B.js → ko-KR-O4L4O7L6.js} +184 -85
- package/dist/dev/locales/ko-KR-O4L4O7L6.js.map +7 -0
- package/dist/dev/locales/{ku-TR-ASSXNN3U.js → ku-TR-AFJWDY67.js} +104 -5
- package/dist/dev/locales/ku-TR-AFJWDY67.js.map +7 -0
- package/dist/dev/locales/{lt-LT-G7RZYQQU.js → lt-LT-7QOT2VDQ.js} +103 -4
- package/dist/dev/locales/lt-LT-7QOT2VDQ.js.map +7 -0
- package/dist/dev/locales/{lv-LV-DXNPBJZU.js → lv-LV-WV6C4NYF.js} +104 -5
- package/dist/dev/locales/lv-LV-WV6C4NYF.js.map +7 -0
- package/dist/dev/locales/{mr-IN-7F2ZCTCF.js → mr-IN-3TLYWOEI.js} +106 -7
- package/dist/dev/locales/mr-IN-3TLYWOEI.js.map +7 -0
- package/dist/dev/locales/{my-MM-NBI3KQGW.js → my-MM-NNL2QJT3.js} +103 -4
- package/dist/dev/locales/my-MM-NNL2QJT3.js.map +7 -0
- package/dist/dev/locales/{nb-NO-4DCTQT6L.js → nb-NO-PG3XLMEV.js} +105 -6
- package/dist/dev/locales/nb-NO-PG3XLMEV.js.map +7 -0
- package/dist/dev/locales/{nl-NL-XGZJ7V2V.js → nl-NL-MMOYEKKQ.js} +109 -10
- package/dist/dev/locales/nl-NL-MMOYEKKQ.js.map +7 -0
- package/dist/dev/locales/{nn-NO-FR534JV5.js → nn-NO-AAC2I2YX.js} +103 -4
- package/dist/dev/locales/nn-NO-AAC2I2YX.js.map +7 -0
- package/dist/dev/locales/{oc-FR-YQCIKZIK.js → oc-FR-SR6MFB4N.js} +105 -6
- package/dist/dev/locales/oc-FR-SR6MFB4N.js.map +7 -0
- package/dist/dev/locales/{pa-IN-UM43JGD2.js → pa-IN-ADGMQLQI.js} +104 -5
- package/dist/dev/locales/pa-IN-ADGMQLQI.js.map +7 -0
- package/dist/dev/locales/{percentages-OGWD7R2K.js → percentages-DKKGPYTW.js} +2 -2
- package/dist/dev/locales/{pl-PL-2UGKA6HK.js → pl-PL-FNIPTMVP.js} +105 -6
- package/dist/dev/locales/pl-PL-FNIPTMVP.js.map +7 -0
- package/dist/dev/locales/{pt-BR-H23QFYE3.js → pt-BR-67FMCDNE.js} +154 -55
- package/dist/dev/locales/pt-BR-67FMCDNE.js.map +7 -0
- package/dist/dev/locales/{pt-PT-RHKJH5I5.js → pt-PT-4G3GI4SF.js} +153 -54
- package/dist/dev/locales/pt-PT-4G3GI4SF.js.map +7 -0
- package/dist/dev/locales/{ro-RO-IIFONL3T.js → ro-RO-CUZFN555.js} +108 -9
- package/dist/dev/locales/ro-RO-CUZFN555.js.map +7 -0
- package/dist/dev/locales/{ru-RU-QEP6D7GK.js → ru-RU-4GHINTII.js} +107 -8
- package/dist/dev/locales/ru-RU-4GHINTII.js.map +7 -0
- package/dist/dev/locales/{si-LK-LZYJQLHF.js → si-LK-SSNT7T4A.js} +105 -6
- package/dist/dev/locales/si-LK-SSNT7T4A.js.map +7 -0
- package/dist/dev/locales/{sk-SK-RWC6UWGY.js → sk-SK-J7TKZQEH.js} +105 -6
- package/dist/dev/locales/sk-SK-J7TKZQEH.js.map +7 -0
- package/dist/dev/locales/{sl-SI-QJT2CAUO.js → sl-SI-SIBF67NE.js} +105 -6
- package/dist/dev/locales/sl-SI-SIBF67NE.js.map +7 -0
- package/dist/dev/locales/{sv-SE-3MAT3NDX.js → sv-SE-YTR46NVM.js} +149 -50
- package/dist/dev/locales/sv-SE-YTR46NVM.js.map +7 -0
- package/dist/dev/locales/{ta-IN-J7XOYF2T.js → ta-IN-7AW6CTGA.js} +103 -4
- package/dist/dev/locales/ta-IN-7AW6CTGA.js.map +7 -0
- package/dist/dev/locales/{th-TH-2OI52EOQ.js → th-TH-DTLYJYKV.js} +134 -35
- package/dist/dev/locales/th-TH-DTLYJYKV.js.map +7 -0
- package/dist/dev/locales/{tr-TR-G7TAUHUI.js → tr-TR-UDQGNXAG.js} +145 -46
- package/dist/dev/locales/tr-TR-UDQGNXAG.js.map +7 -0
- package/dist/dev/locales/{uk-UA-IVSVBJIG.js → uk-UA-25HL2NCU.js} +126 -27
- package/dist/dev/locales/uk-UA-25HL2NCU.js.map +7 -0
- package/dist/dev/locales/{uz-UZ-KCVDUVDE.js → uz-UZ-OPSBAY4H.js} +103 -4
- package/dist/dev/locales/uz-UZ-OPSBAY4H.js.map +7 -0
- package/dist/dev/locales/{vi-VN-KBZAVWP5.js → vi-VN-DK367UGA.js} +103 -4
- package/dist/dev/locales/vi-VN-DK367UGA.js.map +7 -0
- package/dist/dev/locales/{zh-CN-IS26RG2D.js → zh-CN-QCVKNWUH.js} +106 -7
- package/dist/dev/locales/zh-CN-QCVKNWUH.js.map +7 -0
- package/dist/dev/locales/{zh-HK-KBWQ6SJC.js → zh-HK-WFGYHWPG.js} +103 -4
- package/dist/dev/locales/zh-HK-WFGYHWPG.js.map +7 -0
- package/dist/dev/locales/{zh-TW-JKJWJQ4J.js → zh-TW-WHQS4ZSD.js} +151 -52
- package/dist/dev/locales/zh-TW-WHQS4ZSD.js.map +7 -0
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-5XKZK2GL.js +1 -0
- package/dist/prod/chunk-6XMTGF46.js +34 -0
- package/dist/prod/chunk-7L3NUBYQ.js +12 -0
- package/dist/prod/{chunk-GTEFJJHD.js → chunk-FUN3GFKR.js} +1 -1
- package/dist/prod/components/TTDDialog/CodeMirrorEditor-T6RKT6RA.js +1 -0
- package/dist/prod/data/image-UAXVGXRE.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +65 -89
- package/dist/prod/locales/ar-SA-5WIASEJP.js +10 -0
- package/dist/prod/locales/az-AZ-V5EUQD6C.js +1 -0
- package/dist/prod/locales/bg-BG-EXASCMTR.js +5 -0
- package/dist/prod/locales/bn-BD-U4SYNFCO.js +3 -0
- package/dist/prod/locales/bn-IN-HKDJIITE.js +3 -0
- package/dist/prod/locales/ca-ES-2KGUU5XB.js +8 -0
- package/dist/prod/locales/cs-CZ-VUCGPRML.js +7 -0
- package/dist/prod/locales/da-DK-NNDP2IVP.js +2 -0
- package/dist/prod/locales/de-CH-I7RAVIZN.js +11 -0
- package/dist/prod/locales/de-DE-WBQ3DQLR.js +11 -0
- package/dist/prod/locales/el-GR-TYQHVGXW.js +7 -0
- package/dist/prod/locales/en-E6R7JWZO.js +1 -0
- package/dist/prod/locales/es-ES-JEUOREKJ.js +12 -0
- package/dist/prod/locales/eu-ES-SO5DEEAN.js +8 -0
- package/dist/prod/locales/fa-IR-FIYUE2GQ.js +9 -0
- package/dist/prod/locales/fi-FI-REAEF6HQ.js +6 -0
- package/dist/prod/locales/fr-FR-SUCL7J6B.js +12 -0
- package/dist/prod/locales/gl-ES-KHCSOGVH.js +6 -0
- package/dist/prod/locales/he-IL-JYXVXV2Q.js +9 -0
- package/dist/prod/locales/hi-IN-BU52H3BO.js +3 -0
- package/dist/prod/locales/hu-HU-OWADXDQ3.js +3 -0
- package/dist/prod/locales/id-ID-EOMR5R3I.js +8 -0
- package/dist/prod/locales/it-IT-FC2VTM3L.js +12 -0
- package/dist/prod/locales/ja-JP-JBNTKYP4.js +12 -0
- package/dist/prod/locales/kaa-TC3VIB7V.js +1 -0
- package/dist/prod/locales/kab-KAB-UOUDSQKM.js +4 -0
- package/dist/prod/locales/kk-KZ-P5H2X7YS.js +1 -0
- package/dist/prod/locales/km-KH-IHMV2US7.js +7 -0
- package/dist/prod/locales/ko-KR-ZTMANIDF.js +5 -0
- package/dist/prod/locales/ku-TR-GPJTRB5G.js +6 -0
- package/dist/prod/locales/lt-LT-V3XDOK3P.js +3 -0
- package/dist/prod/locales/lv-LV-DVQ3FADO.js +4 -0
- package/dist/prod/locales/mr-IN-VZ6HH5FE.js +9 -0
- package/dist/prod/locales/my-MM-XYKWHRK6.js +1 -0
- package/dist/prod/locales/nb-NO-UNO2GGZJ.js +8 -0
- package/dist/prod/locales/nl-NL-76EFHT4P.js +13 -0
- package/dist/prod/locales/nn-NO-CFKD7ABE.js +4 -0
- package/dist/prod/locales/oc-FR-YBJTCJ3J.js +4 -0
- package/dist/prod/locales/pa-IN-SNOXSMRV.js +4 -0
- package/dist/prod/locales/percentages-Q7USCRWZ.js +1 -0
- package/dist/prod/locales/pl-PL-BSY6YFZ3.js +12 -0
- package/dist/prod/locales/pt-BR-CZDV62R3.js +10 -0
- package/dist/prod/locales/pt-PT-JO57XJJW.js +12 -0
- package/dist/prod/locales/ro-RO-UZ5ICYYN.js +12 -0
- package/dist/prod/locales/ru-RU-AN7JPREC.js +10 -0
- package/dist/prod/locales/si-LK-7CBLD6QQ.js +1 -0
- package/dist/prod/locales/sk-SK-SWR6DKBI.js +7 -0
- package/dist/prod/locales/sl-SI-JRML4FIH.js +6 -0
- package/dist/prod/locales/sv-SE-4ZPKFFXF.js +12 -0
- package/dist/prod/locales/ta-IN-V6NHHU6Z.js +6 -0
- package/dist/prod/locales/th-TH-P7CTMGDK.js +1 -0
- package/dist/prod/locales/tr-TR-GUFYG22B.js +4 -0
- package/dist/prod/locales/uk-UA-K6SV5NFQ.js +6 -0
- package/dist/prod/locales/uz-UZ-TVKTZO2G.js +1 -0
- package/dist/prod/locales/vi-VN-7FKFXJNO.js +7 -0
- package/dist/prod/locales/zh-CN-AOKVLNNK.js +11 -0
- package/dist/prod/locales/zh-HK-CDKPF5DC.js +1 -0
- package/dist/prod/locales/zh-TW-ZVGYESGW.js +13 -0
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/debug.d.ts +21 -0
- package/dist/types/common/src/appEventBus.d.ts +27 -0
- package/dist/types/common/src/colors.d.ts +16 -2
- package/dist/types/common/src/constants.d.ts +16 -7
- package/dist/types/common/src/index.d.ts +3 -0
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/utils.d.ts +5 -50
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +8 -4
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +30 -0
- package/dist/types/element/src/arrows/helpers.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +29 -15
- package/dist/types/element/src/bounds.d.ts +23 -8
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +4 -3
- package/dist/types/element/src/comparisons.d.ts +5 -4
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/distribute.d.ts +3 -2
- package/dist/types/element/src/dragElements.d.ts +27 -0
- package/dist/types/element/src/duplicate.d.ts +4 -3
- package/dist/types/element/src/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +7 -7
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +9 -8
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/index.d.ts +7 -1
- package/dist/types/element/src/linearElementEditor.d.ts +22 -10
- package/dist/types/element/src/mutateElement.d.ts +2 -0
- package/dist/types/element/src/newElement.d.ts +14 -0
- package/dist/types/element/src/renderElement.d.ts +0 -3
- package/dist/types/element/src/resizeElements.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +12 -8
- package/dist/types/element/src/shape.d.ts +13 -1
- package/dist/types/element/src/sortElements.d.ts +10 -0
- package/dist/types/element/src/textElement.d.ts +13 -10
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/element/src/transform.d.ts +2 -2
- package/dist/types/element/src/typeChecks.d.ts +26 -25
- package/dist/types/element/src/types.d.ts +13 -3
- package/dist/types/element/src/utils.d.ts +6 -4
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +83 -56
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +57 -39
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +355 -811
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +56 -38
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +28 -19
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +89 -59
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +165 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +24 -19
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +57 -39
- package/dist/types/excalidraw/actions/actionExport.d.ts +152 -409
- package/dist/types/excalidraw/actions/actionFrame.d.ts +95 -240
- package/dist/types/excalidraw/actions/actionGroup.d.ts +72 -54
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +34 -21
- package/dist/types/excalidraw/actions/actionLink.d.ts +29 -20
- package/dist/types/excalidraw/actions/actionMenu.d.ts +24 -19
- package/dist/types/excalidraw/actions/actionProperties.d.ts +84 -54
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +33 -24
- package/dist/types/excalidraw/actions/actionStyles.d.ts +28 -18
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleArrowBinding.d.ts} +43 -33
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +32 -24
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +181 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +29 -20
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +28 -24
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +29 -20
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +30 -21
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +29 -20
- package/dist/types/excalidraw/actions/index.d.ts +4 -2
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +8 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +33 -24
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +7 -0
- package/dist/types/excalidraw/clipboard.d.ts +6 -7
- package/dist/types/excalidraw/components/Actions.d.ts +17 -12
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +30 -0
- package/dist/types/excalidraw/components/App.d.ts +418 -85
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
- package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +5 -3
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +1 -3
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +2 -6
- package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +11 -7
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +4 -0
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/Toast.d.ts +8 -4
- package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +146 -0
- package/dist/types/excalidraw/components/UserList.d.ts +3 -2
- package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +30 -16
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +3 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +11 -12
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +29 -10
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -3
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -14
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/data/blob.d.ts +179 -160
- package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
- package/dist/types/excalidraw/data/index.d.ts +6 -7
- package/dist/types/excalidraw/data/json.d.ts +98 -80
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/data/restore.d.ts +1 -1
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +35 -9
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -3
- package/dist/types/excalidraw/scene/Renderer.d.ts +426 -19
- package/dist/types/excalidraw/scene/export.d.ts +3 -3
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +4 -4
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +512 -77
- package/dist/types/excalidraw/viewport.d.ts +275 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +6 -3
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +36 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +4 -1
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/point.d.ts +8 -2
- package/dist/types/math/src/polygon.d.ts +25 -1
- package/dist/types/math/src/types.d.ts +25 -1
- package/package.json +9 -6
- package/dist/dev/chunk-DJHLEOOZ.js +0 -69
- package/dist/dev/chunk-DJHLEOOZ.js.map +0 -7
- package/dist/dev/chunk-KB3DXHSJ.js.map +0 -7
- package/dist/dev/chunk-XIXZ3HJO.js.map +0 -7
- package/dist/dev/locales/ar-SA-JK5MQ7TT.js.map +0 -7
- package/dist/dev/locales/az-AZ-2PAD62G4.js.map +0 -7
- package/dist/dev/locales/bg-BG-HUKVYCRK.js.map +0 -7
- package/dist/dev/locales/bn-BD-V2CQI46P.js.map +0 -7
- package/dist/dev/locales/bn-IN-MBEO4C3J.js.map +0 -7
- package/dist/dev/locales/ca-ES-KWEKW4C3.js.map +0 -7
- package/dist/dev/locales/cs-CZ-W5AHZB5H.js.map +0 -7
- package/dist/dev/locales/da-DK-ITTM6YM4.js.map +0 -7
- package/dist/dev/locales/de-CH-OAWPDQFJ.js.map +0 -7
- package/dist/dev/locales/de-DE-ZRDYEPMS.js.map +0 -7
- package/dist/dev/locales/el-GR-QXASZLPE.js.map +0 -7
- package/dist/dev/locales/es-ES-VLQBB7FJ.js.map +0 -7
- package/dist/dev/locales/eu-ES-TF2DGTZU.js.map +0 -7
- package/dist/dev/locales/fa-IR-ITKFQ7QV.js.map +0 -7
- package/dist/dev/locales/fi-FI-UWZRVXFI.js.map +0 -7
- package/dist/dev/locales/fr-FR-A72LKGCO.js.map +0 -7
- package/dist/dev/locales/gl-ES-2QCVIBFP.js.map +0 -7
- package/dist/dev/locales/he-IL-WJNUHU26.js.map +0 -7
- package/dist/dev/locales/hi-IN-XGMO235V.js.map +0 -7
- package/dist/dev/locales/hu-HU-37FDQFIS.js.map +0 -7
- package/dist/dev/locales/id-ID-EJIDCO4E.js.map +0 -7
- package/dist/dev/locales/it-IT-X34PIOJ2.js.map +0 -7
- package/dist/dev/locales/ja-JP-37FC23PR.js.map +0 -7
- package/dist/dev/locales/kaa-7ZYDFVKA.js.map +0 -7
- package/dist/dev/locales/kab-KAB-MILWXBA6.js.map +0 -7
- package/dist/dev/locales/kk-KZ-7BWTPIAV.js.map +0 -7
- package/dist/dev/locales/km-KH-BV4P2KSZ.js.map +0 -7
- package/dist/dev/locales/ko-KR-TSXE5P7B.js.map +0 -7
- package/dist/dev/locales/ku-TR-ASSXNN3U.js.map +0 -7
- package/dist/dev/locales/lt-LT-G7RZYQQU.js.map +0 -7
- package/dist/dev/locales/lv-LV-DXNPBJZU.js.map +0 -7
- package/dist/dev/locales/mr-IN-7F2ZCTCF.js.map +0 -7
- package/dist/dev/locales/my-MM-NBI3KQGW.js.map +0 -7
- package/dist/dev/locales/nb-NO-4DCTQT6L.js.map +0 -7
- package/dist/dev/locales/nl-NL-XGZJ7V2V.js.map +0 -7
- package/dist/dev/locales/nn-NO-FR534JV5.js.map +0 -7
- package/dist/dev/locales/oc-FR-YQCIKZIK.js.map +0 -7
- package/dist/dev/locales/pa-IN-UM43JGD2.js.map +0 -7
- package/dist/dev/locales/pl-PL-2UGKA6HK.js.map +0 -7
- package/dist/dev/locales/pt-BR-H23QFYE3.js.map +0 -7
- package/dist/dev/locales/pt-PT-RHKJH5I5.js.map +0 -7
- package/dist/dev/locales/ro-RO-IIFONL3T.js.map +0 -7
- package/dist/dev/locales/ru-RU-QEP6D7GK.js.map +0 -7
- package/dist/dev/locales/si-LK-LZYJQLHF.js.map +0 -7
- package/dist/dev/locales/sk-SK-RWC6UWGY.js.map +0 -7
- package/dist/dev/locales/sl-SI-QJT2CAUO.js.map +0 -7
- package/dist/dev/locales/sv-SE-3MAT3NDX.js.map +0 -7
- package/dist/dev/locales/ta-IN-J7XOYF2T.js.map +0 -7
- package/dist/dev/locales/th-TH-2OI52EOQ.js.map +0 -7
- package/dist/dev/locales/tr-TR-G7TAUHUI.js.map +0 -7
- package/dist/dev/locales/uk-UA-IVSVBJIG.js.map +0 -7
- package/dist/dev/locales/uz-UZ-KCVDUVDE.js.map +0 -7
- package/dist/dev/locales/vi-VN-KBZAVWP5.js.map +0 -7
- package/dist/dev/locales/zh-CN-IS26RG2D.js.map +0 -7
- package/dist/dev/locales/zh-HK-KBWQ6SJC.js.map +0 -7
- package/dist/dev/locales/zh-TW-JKJWJQ4J.js.map +0 -7
- package/dist/prod/chunk-2INXXNZN.js +0 -12
- package/dist/prod/chunk-7ECCIQPE.js +0 -33
- package/dist/prod/chunk-AJI3LATG.js +0 -1
- package/dist/prod/data/image-E5KTZOPE.js +0 -1
- package/dist/prod/locales/ar-SA-IYHKZRSE.js +0 -8
- package/dist/prod/locales/az-AZ-WL5GYRHK.js +0 -1
- package/dist/prod/locales/bg-BG-FXZYTRPD.js +0 -5
- package/dist/prod/locales/bn-BD-KO6YL5G2.js +0 -3
- package/dist/prod/locales/bn-IN-PC6JHKYB.js +0 -3
- package/dist/prod/locales/ca-ES-AREX5NEO.js +0 -8
- package/dist/prod/locales/cs-CZ-HXAZMFYH.js +0 -7
- package/dist/prod/locales/da-DK-5X7ZLFU3.js +0 -2
- package/dist/prod/locales/de-CH-76ZNVSOF.js +0 -7
- package/dist/prod/locales/de-DE-G3JVZ4MQ.js +0 -7
- package/dist/prod/locales/el-GR-4AZTZGY6.js +0 -7
- package/dist/prod/locales/en-YGAMZJ7C.js +0 -1
- package/dist/prod/locales/es-ES-ART7BI3G.js +0 -7
- package/dist/prod/locales/eu-ES-BIF4XBMT.js +0 -7
- package/dist/prod/locales/fa-IR-D4HHKAAI.js +0 -9
- package/dist/prod/locales/fi-FI-O35ZY7UI.js +0 -6
- package/dist/prod/locales/fr-FR-XEFNCM4I.js +0 -12
- package/dist/prod/locales/gl-ES-U4NYM3X5.js +0 -6
- package/dist/prod/locales/he-IL-656ABAVQ.js +0 -8
- package/dist/prod/locales/hi-IN-Z55GAFFR.js +0 -3
- package/dist/prod/locales/hu-HU-UJ62DVIW.js +0 -3
- package/dist/prod/locales/id-ID-FLZFU3OO.js +0 -8
- package/dist/prod/locales/it-IT-GIGIGIBJ.js +0 -12
- package/dist/prod/locales/ja-JP-43VXGDWI.js +0 -7
- package/dist/prod/locales/kaa-L3IMSDYL.js +0 -1
- package/dist/prod/locales/kab-KAB-XKPWJLNL.js +0 -4
- package/dist/prod/locales/kk-KZ-SXPDDY2H.js +0 -1
- package/dist/prod/locales/km-KH-DOS4CPGC.js +0 -7
- package/dist/prod/locales/ko-KR-BGC6VCY4.js +0 -5
- package/dist/prod/locales/ku-TR-J7IUITIA.js +0 -6
- package/dist/prod/locales/lt-LT-AC3LV5KG.js +0 -3
- package/dist/prod/locales/lv-LV-I6AY7QG2.js +0 -4
- package/dist/prod/locales/mr-IN-5SP4HV5B.js +0 -9
- package/dist/prod/locales/my-MM-S7ECRBYZ.js +0 -1
- package/dist/prod/locales/nb-NO-6PNHTF4R.js +0 -8
- package/dist/prod/locales/nl-NL-R4C4SUIG.js +0 -13
- package/dist/prod/locales/nn-NO-3TFXTM7Y.js +0 -4
- package/dist/prod/locales/oc-FR-IK6GIE7H.js +0 -4
- package/dist/prod/locales/pa-IN-YAKHYJET.js +0 -4
- package/dist/prod/locales/percentages-OL6W367U.js +0 -1
- package/dist/prod/locales/pl-PL-BIY22ZWU.js +0 -12
- package/dist/prod/locales/pt-BR-Q23NUPD6.js +0 -6
- package/dist/prod/locales/pt-PT-LOPEJLPJ.js +0 -8
- package/dist/prod/locales/ro-RO-W3D2ZATV.js +0 -12
- package/dist/prod/locales/ru-RU-DCTW7QSH.js +0 -10
- package/dist/prod/locales/si-LK-FYRRHO3C.js +0 -1
- package/dist/prod/locales/sk-SK-MC7UOHQO.js +0 -7
- package/dist/prod/locales/sl-SI-L6B6HFY5.js +0 -6
- package/dist/prod/locales/sv-SE-KMY6L2BA.js +0 -8
- package/dist/prod/locales/ta-IN-ZQCYE2JK.js +0 -6
- package/dist/prod/locales/th-TH-WS7ECBAV.js +0 -1
- package/dist/prod/locales/tr-TR-S5FI7JRW.js +0 -4
- package/dist/prod/locales/uk-UA-4EZUWUSQ.js +0 -6
- package/dist/prod/locales/uz-UZ-OKHL6AFA.js +0 -1
- package/dist/prod/locales/vi-VN-K34TWHF7.js +0 -7
- package/dist/prod/locales/zh-CN-JE4UZWNO.js +0 -11
- package/dist/prod/locales/zh-HK-RM35YDXX.js +0 -1
- package/dist/prod/locales/zh-TW-ONGLV6Y5.js +0 -9
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/charts.d.ts +0 -27
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/shapes.d.ts +0 -190
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/excalidraw/scene/scrollConstraints.d.ts +0 -46
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/index.d.ts +0 -4
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
- /package/dist/dev/{chunk-VHBP2L6P.js.map → chunk-GLSDDV5C.js.map} +0 -0
- /package/dist/dev/data/{image-YTAF2QAV.js.map → image-LSHTDYDI.js.map} +0 -0
- /package/dist/dev/locales/{en-RTISGYJB.js.map → en-JNOPSYVP.js.map} +0 -0
- /package/dist/dev/locales/{percentages-OGWD7R2K.js.map → percentages-DKKGPYTW.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{$ as ue,$a as ox,$b as Ex,$c as en,$d as Zt,$e as uy,$f as _y,$g as oE,$h as xE,A as rs,Aa as ud,Ab as Ft,Ac as Ut,Ad as YC,Ae as oy,Af as Sa,Ag as Gy,Ah as mm,B as R0,Ba as ls,Bb as sh,Bc as rr,Bd as Kx,Be as ry,Bf as _e,Bg as Nh,Bh as Ms,C as ad,Ca as Zr,Cb as Ae,Cc as Ld,Cd as Ii,Ce as ny,Cf as Jd,Cg as Oh,Ch as sE,D as N0,Da as Yt,Db as px,Dc as Ad,Dd as ut,De as wh,Df as rn,Dg as Wy,Dh as cE,E as Zu,Ea as hd,Eb as ch,Ec as Po,Ed as Zx,Ee as Yd,Ef as Sh,Eg as Yy,Eh as dE,F as O0,Fa as mt,Fb as ux,Fc as mh,Fd as Pn,Fe as Rn,Ff as Ri,Fg as Vy,Fh as QC,G as Xu,Ga as In,Gb as so,Gc as Mx,Gd as bs,Ge as Vd,Gf as Mh,Gg as Ky,Gh as Wi,H as Pe,Ha as Z0,Hb as ya,Hc as wa,Hd as xe,He as ay,Hf as vr,Hg as Fi,Hh as Ls,I as fr,Ia as ss,Ib as yt,Ic as Lx,Id as Do,Ie as iy,If as Is,Ig as Zy,Ih as As,J as pa,Ja as io,Jb as hx,Jc as An,Jd as Nd,Je as Th,Jf as Ni,Jg as nm,Jh as On,K as ns,Ka as pt,Kb as Sn,Kc as Ue,Kd as Xx,Ke as Be,Kf as Ty,Kg as Xy,Kh as Yi,L as nt,La as X0,Lb as vd,Lc as Vt,Ld as gh,Le as ae,Lf as Cy,Lg as $y,Lh as mE,M as ua,Ma as $0,Mb as tr,Mc as Ta,Md as fh,Me as _i,Mf as XC,Mg as am,N as It,Na as j0,Nb as gx,Nc as Ti,Nd as $x,Ne as Oe,Nf as nn,Ng as zh,Nh as pE,O as ne,Oa as kn,Ob as fx,Oc as $,Od as ki,Oe as Kd,Of as ar,Og as Bh,P as We,Pa as Xr,Pb as Ea,Pc as _d,Pd as xs,Pe as ly,Pf as D,Pg as Fh,Ph as uE,Q as ha,Qa as gd,Qb as ms,Qc as le,Qd as Od,Qe as Ch,Qf as Iy,Qg as jy,Qh as hE,R as xi,Ra as q0,Rb as Ne,Rc as Ci,Rd as bh,Re as sy,Rf as ky,Rg as Hi,Rh as pm,S as id,Sa as ga,Sb as Ye,Sc as ge,Sd as jx,Se as No,Sf as ks,Sg as qy,Sh as gE,T as $u,Ta as J0,Tb as kt,Tc as tt,Td as Si,Te as cy,Tf as Sy,Tg as Jy,Th as Zh,U as ld,Ua as Q0,Ub as ps,Uc as Me,Ud as zd,Ue as dy,Uf as My,Ug as Qy,Uh as Xh,V as Lo,Va as ex,Vb as wd,Vc as Se,Vd as qx,Ve as mo,Vf as Qd,Vg as eE,Vh as um,W as as,Wa as $r,Wb as Td,Wc as Pd,Wd as Jx,We as my,Wf as wr,Wg as $C,Wh as fE,X as ju,Xa as fd,Xb as Cd,Xc as Ax,Xd as Ro,Xe as ka,Xf as Oi,Xg as Hh,Xh as $h,Y as z0,Ya as bd,Yb as bx,Yc as co,Yd as Mi,Ye as py,Yf as Lh,Yg as Uh,Yh as Pa,Z as qu,Za as xd,Zb as xx,Zc as _x,Zd as Bd,Ze as Pi,Zf as Ly,Zg as ve,Zh as bE,_ as is,_a as tx,_b as yx,_c as Dd,_d as Fd,_e as Zd,_f as Ay,_g as Gh,_h as jh,a as $e,aa as B0,ab as rx,ac as vx,ad as Px,ae as re,af as br,ag as Ah,ah as Aa,ai as yE,b as Mo,ba as sd,bb as nx,bc as ie,bd as Rd,be as tn,bf as xr,bg as em,bh as vo,bi as hm,c as L0,ca as Tn,cb as jr,cc as wx,cd as ft,ce as Hd,cf as hy,cg as tm,ch as rE,ci as qh,d as Uu,da as F0,db as cs,dc as Qr,dd as it,de as Qx,df as Ih,dg as om,dh as Ui,di as EE,e as fi,ea as H0,eb as fa,ec as Ht,ed as Dx,ee as Li,ef as gy,eg as Ma,eh as nE,ei as vE,f as bi,fa as U0,fb as ax,fc as Id,fd as _n,fe as Ud,ff as kh,fg as Py,fh as Yh,fi as wE,g as Gu,ga as G0,gb as qr,gc as kd,gd as Rx,ge as ys,gf as fy,gg as Tr,gh as kr,gi as _s,h as od,ha as W0,hb as ix,hc as vi,hd as Nx,he as xh,hf as Xd,hg as _h,hh as Nn,i as Wu,ia as yi,ib as lo,ic as Tx,id as Ca,ie as yh,if as $d,ig as Dy,ih as _a,j as Yu,ja as Ju,jb as yd,jc as Mn,jd as ph,je as on,jf as by,jg as rm,jh as jC,k as A0,ka as Qu,kb as Jr,kc as us,kd as Ox,ke as Dn,kf as xy,kg as Ph,kh as qC,l as Vu,la as Y0,lb as lx,lc as at,ld as uh,le as Eh,lf as yy,lg as Cr,lh as po,m as L,ma as cd,mb as sx,mc as Ln,md as hh,me as vh,mf as Ey,mg as Ry,mh as ir,n as _0,na as dd,nb as cx,nc as Cx,nd as hs,ne as Gd,nf as vy,ng as Ny,nh as Gi,o as Ge,oa as eh,ob as ah,oc as je,od as zx,oe as X,of as yr,og as Ir,oh as im,p as wn,pa as md,pb as ba,pc as Ix,pd as Bx,pe as VC,pf as Es,pg as zi,ph as Vh,q as Ql,qa as Cn,qb as ih,qc as Sd,qd as gs,qe as KC,qf as vs,qg as Oy,qh as Ss,r as Ku,ra as V0,rb as dx,rc as or,rd as Fx,re as ZC,rf as ws,rg as Dh,rh as lm,s as P0,sa as th,sb as mx,sc as wi,sd as Hx,se as ey,sf as Ts,sg as La,sh as Kh,t as D0,ta as oh,tb as he,tc as Ve,td as Kt,te as bt,tf as Cs,tg as zy,th as JC,u as rd,ua as K0,ub as T,uc as kx,ud as Ux,ue as Wd,uf as Di,ug as Bi,uh as aE,v as Eo,va as pd,vb as Ed,vc as Sx,vd as Gx,ve as nr,vf as Er,vg as Rh,vh as iE,w as es,wa as rh,wb as xa,wc as dh,wd as Wx,we as Ia,wf as jd,wg as By,wh as lE,x as ts,xa as Ao,xb as lh,xc as Md,xd as fs,xe as ty,xf as wy,xg as Fy,xh as sm,y as nd,ya as nh,yb as Ei,yc as _o,yd as Yx,ye as Ai,yf as At,yg as Hy,yh as cm,z as os,za as Lt,zb as ds,zc as va,zd as Vx,ze as Ke,zf as qd,zg as Uy,zh as dm}from"./chunk-7ECCIQPE.js";import{a as I}from"./chunk-GTEFJJHD.js";import{M as Wh}from"./chunk-2INXXNZN.js";import{c as tE}from"./chunk-AJI3LATG.js";import{b as M0,c as td,d as k}from"./chunk-SRAX5OIU.js";import Z7,{useEffect as X7}from"react";import wC from"clsx";import b7 from"lodash.throttle";import Kr,{useContext as da}from"react";import{flushSync as Jo}from"react-dom";import x7 from"roughjs/bin/rough";import{nanoid as y7}from"nanoid";var t3={};td(t3,{actionAddToLibrary:()=>Ip,actionAlignBottom:()=>d2,actionAlignHorizontallyCentered:()=>h2,actionAlignLeft:()=>m2,actionAlignRight:()=>p2,actionAlignTop:()=>c2,actionAlignVerticallyCentered:()=>u2,actionBindText:()=>Ap,actionBringForward:()=>Wm,actionBringToFront:()=>Vm,actionChangeArrowProperties:()=>Sv,actionChangeBackgroundColor:()=>xv,actionChangeExportBackground:()=>bp,actionChangeFillStyle:()=>yv,actionChangeFontFamily:()=>Cv,actionChangeFontSize:()=>Tv,actionChangeOpacity:()=>wv,actionChangeProjectName:()=>fp,actionChangeSloppiness:()=>vv,actionChangeStrokeColor:()=>bv,actionChangeStrokeWidth:()=>Ev,actionChangeTextAlign:()=>Iv,actionChangeVerticalAlign:()=>kv,actionChangeViewBackgroundColor:()=>Rv,actionClearCanvas:()=>Dr,actionCopy:()=>ei,actionCopyAsPng:()=>hc,actionCopyAsSvg:()=>uc,actionCopyStyles:()=>yp,actionCut:()=>pc,actionDeleteSelected:()=>tl,actionDuplicateSelection:()=>Xm,actionFinalize:()=>$t,actionFlipHorizontal:()=>kp,actionFlipVertical:()=>Sp,actionGoToCollaborator:()=>s2,actionGroup:()=>vp,actionLink:()=>xl,actionLoadScene:()=>Ja,actionPasteStyles:()=>Ep,actionResetZoom:()=>ic,actionSaveFileToDisk:()=>ul,actionSaveToActiveFile:()=>jn,actionSelectAll:()=>Zm,actionSendBackward:()=>Gm,actionSendToBack:()=>Ym,actionSetEmbeddableAsActiveTool:()=>Bv,actionShortcuts:()=>qn,actionToggleCropEditor:()=>eu,actionToggleElementLock:()=>yl,actionToggleGridMode:()=>fc,actionToggleLinearEditor:()=>ai,actionToggleObjectsSnapMode:()=>Mp,actionToggleSearchMenu:()=>Pl,actionToggleStats:()=>oi,actionToggleTheme:()=>Xn,actionToggleZenMode:()=>ti,actionUnbindText:()=>Lp,actionUngroup:()=>wp,actionZoomIn:()=>nc,actionZoomOut:()=>ac,actionZoomToFit:()=>Ov,copyText:()=>gc,distributeHorizontally:()=>b2,distributeVertically:()=>x2});import{atom as we,createStore as e6}from"jotai";import{createIsolation as t6}from"jotai-scope";var TE=t6();var{useAtom:te,useSetAtom:Sr,useAtomValue:Vi,useStore:eP}=TE,CE=TE.Provider,Et=e6();var o6=M0({"./locales/ar-SA.json":()=>import("./locales/ar-SA-IYHKZRSE.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-WL5GYRHK.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-FXZYTRPD.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-KO6YL5G2.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-PC6JHKYB.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-AREX5NEO.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-HXAZMFYH.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5X7ZLFU3.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-76ZNVSOF.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-G3JVZ4MQ.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-4AZTZGY6.js"),"./locales/en.json":()=>import("./locales/en-YGAMZJ7C.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-ART7BI3G.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-BIF4XBMT.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-D4HHKAAI.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-O35ZY7UI.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-XEFNCM4I.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-U4NYM3X5.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-656ABAVQ.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Z55GAFFR.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-UJ62DVIW.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-FLZFU3OO.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-GIGIGIBJ.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-43VXGDWI.js"),"./locales/kaa.json":()=>import("./locales/kaa-L3IMSDYL.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-XKPWJLNL.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-SXPDDY2H.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-DOS4CPGC.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-BGC6VCY4.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-J7IUITIA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-AC3LV5KG.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-I6AY7QG2.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-5SP4HV5B.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-S7ECRBYZ.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-6PNHTF4R.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-R4C4SUIG.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-3TFXTM7Y.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-IK6GIE7H.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-YAKHYJET.js"),"./locales/percentages.json":()=>import("./locales/percentages-OL6W367U.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-BIY22ZWU.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-Q23NUPD6.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-LOPEJLPJ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-W3D2ZATV.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-DCTW7QSH.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-FYRRHO3C.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-MC7UOHQO.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-L6B6HFY5.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-KMY6L2BA.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-ZQCYE2JK.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-WS7ECBAV.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-S5FI7JRW.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-4EZUWUSQ.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-OKHL6AFA.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-K34TWHF7.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-JE4UZWNO.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-RM35YDXX.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-ONGLV6Y5.js")});var r6=85,Mr={code:"en",label:"English"},Zi=[Mr,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>tE[e.code]>=r6).sort((e,o)=>e.label>o.label?1:-1)],fm="__test__";Ht()&&Zi.unshift({code:fm,label:"test language"},{code:`${fm}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ki=Mr,gm={},bm=async e=>{if(Ki=e,document.documentElement.dir=Ki.rtl?"rtl":"ltr",document.documentElement.lang=Ki.code,e.code.startsWith(fm))gm={};else try{gm=await o6(`./locales/${Ki.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),gm=Wh}Et.set(kE,e.code)},an=()=>Ki,IE=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},u=(e,o,t)=>{if(Ki.code.startsWith(fm))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=IE(gm,r)||IE(Wh,r)||t;if(n===void 0){let a=`Can't find translation for ${e}`;if(I.PROD)return console.warn(a),"";throw new Error(a)}if(o)for(let a in o)n=n.replace(`{{${a}}}`,String(o[a]));return n},kE=we(Mr.code),dt=()=>{let e=Vi(kE);return{t:u,langCode:e}};var AE={};td(AE,{AlignBottomIcon:()=>Lm,AlignLeftIcon:()=>Am,AlignRightIcon:()=>_m,AlignTopIcon:()=>Mm,ArrowIcon:()=>Ds,ArrowRightIcon:()=>sn,ArrowheadArrowIcon:()=>Bg,ArrowheadBarIcon:()=>Ug,ArrowheadCircleIcon:()=>Fg,ArrowheadCircleOutlineIcon:()=>Hg,ArrowheadCrowfootIcon:()=>Kg,ArrowheadCrowfootOneIcon:()=>Zg,ArrowheadCrowfootOneOrManyIcon:()=>Xg,ArrowheadDiamondIcon:()=>Yg,ArrowheadDiamondOutlineIcon:()=>Vg,ArrowheadNoneIcon:()=>zg,ArrowheadTriangleIcon:()=>Gg,ArrowheadTriangleOutlineIcon:()=>Wg,BringForwardIcon:()=>Cm,BringToFrontIcon:()=>km,CenterHorizontallyIcon:()=>Dm,CenterVerticallyIcon:()=>Pm,CloseIcon:()=>wo,DeviceDesktopIcon:()=>Af,DiamondIcon:()=>Na,DiscordIcon:()=>mg,DistributeHorizontallyIcon:()=>vg,DistributeVerticallyIcon:()=>wg,DotsHorizontalIcon:()=>eg,DotsIcon:()=>Qh,DuplicateIcon:()=>Xi,EdgeRoundIcon:()=>Og,EdgeSharpIcon:()=>Ng,EllipseIcon:()=>Oa,EmbedIcon:()=>Fa,EraserIcon:()=>Rs,ExcalLogo:()=>i6,ExportIcon:()=>Fn,ExportImageIcon:()=>zs,ExternalLinkIcon:()=>vm,FillCrossHatchIcon:()=>kg,FillHachureIcon:()=>Ig,FillSolidIcon:()=>Sg,FillZigZagIcon:()=>Cg,FontFamilyCodeIcon:()=>Fs,FontFamilyHeadingIcon:()=>Qg,FontFamilyNormalIcon:()=>Ji,FontSizeExtraLargeIcon:()=>Jg,FontSizeLargeIcon:()=>qg,FontSizeMediumIcon:()=>jg,FontSizeSmallIcon:()=>$g,FreedrawIcon:()=>lr,GithubIcon:()=>Ns,GroupIcon:()=>Rm,HamburgerMenuIcon:()=>cg,HelpIcon:()=>Ha,HelpIconThin:()=>dg,HomeIcon:()=>a6,ImageIcon:()=>Ba,LassoIcon:()=>ln,LibraryIcon:()=>Ps,LineIcon:()=>za,LinkIcon:()=>qi,LoadIcon:()=>Ua,LockedIcon:()=>Da,LockedIconFilled:()=>og,MagicIcon:()=>Un,MagicIconThin:()=>I6,MoonIcon:()=>$i,OpenAIIcon:()=>k6,PenModeIcon:()=>ig,PinIcon:()=>tg,PlusIcon:()=>Jh,RectangleIcon:()=>Ra,RedoIcon:()=>Tm,RetryIcon:()=>pf,SelectionIcon:()=>Bn,SendBackwardIcon:()=>Im,SendToBackIcon:()=>Sm,SloppinessArchitectIcon:()=>Pg,SloppinessArtistIcon:()=>Dg,SloppinessCartoonistIcon:()=>Rg,StrokeStyleDashedIcon:()=>Ag,StrokeStyleDottedIcon:()=>_g,StrokeStyleSolidIcon:()=>v6,StrokeWidthBaseIcon:()=>Om,StrokeWidthBoldIcon:()=>Mg,StrokeWidthExtraBoldIcon:()=>Lg,SunIcon:()=>ji,TextAlignBottomIcon:()=>nf,TextAlignCenterIcon:()=>tf,TextAlignLeftIcon:()=>ef,TextAlignMiddleIcon:()=>af,TextAlignRightIcon:()=>of,TextAlignTopIcon:()=>rf,TextIcon:()=>sr,TextSizeIcon:()=>lg,TrashIcon:()=>_t,UndoIcon:()=>wm,UngroupIcon:()=>Nm,UnlockedIcon:()=>zn,WelcomeScreenHelpArrow:()=>ng,WelcomeScreenMenuArrow:()=>rg,WelcomeScreenTopToolbarArrow:()=>ag,XBrandIcon:()=>pg,ZoomInIcon:()=>ym,ZoomOutIcon:()=>Em,ZoomResetIcon:()=>sg,abacusIcon:()=>Tf,adjustmentsIcon:()=>Of,alertTriangleIcon:()=>Gs,angleIcon:()=>Hs,boltIcon:()=>el,brainIcon:()=>ff,brainIconThin:()=>bf,bucketFillIcon:()=>Os,checkIcon:()=>ug,chevronLeftIcon:()=>L6,clipboard:()=>l6,clone:()=>x6,codeIcon:()=>zm,coffeeIcon:()=>Lf,collapseDownIcon:()=>Ys,collapseUpIcon:()=>Rf,copyIcon:()=>Ga,createIcon:()=>_,cropIcon:()=>Hm,cutIcon:()=>sf,done:()=>xg,downloadIcon:()=>Bm,elbowArrowIcon:()=>Ka,elementLinkIcon:()=>Vs,eraser:()=>w6,exportToFileIcon:()=>bg,exportToPlus:()=>h6,extraToolsIcon:()=>Qi,eyeClosedIcon:()=>gf,eyeDropperIcon:()=>mf,eyeIcon:()=>Ya,file:()=>E6,flipHorizontal:()=>If,flipVertical:()=>Cf,fontSizeIcon:()=>Hn,frameToolIcon:()=>zo,fullscreenIcon:()=>hf,gridIcon:()=>Pf,handIcon:()=>Us,helpIcon:()=>cf,historyCommandIcon:()=>xf,historyIcon:()=>yf,iconFillColor:()=>Oo,laserPointerToolIcon:()=>cn,lineEditorIcon:()=>Df,loginIcon:()=>S6,magnetIcon:()=>Mf,menu:()=>m6,mermaidLogoIcon:()=>Wa,messageCircleIcon:()=>A6,microphoneIcon:()=>Ef,microphoneMutedIcon:()=>vf,paintIcon:()=>Fm,palette:()=>s6,pencilIcon:()=>Bf,playerPlayIcon:()=>T6,playerStopFilledIcon:()=>C6,pngIcon:()=>Sf,polygonIcon:()=>xm,presentationIcon:()=>_6,publishIcon:()=>lf,questionCircle:()=>yg,resetZoom:()=>f6,resizeIcon:()=>M6,roundArrowIcon:()=>Za,save:()=>hg,saveAs:()=>gg,searchIcon:()=>uo,selectAllIcon:()=>wf,share:()=>Eg,shareIOS:()=>u6,shareWindows:()=>g6,sharpArrowIcon:()=>Va,shield:()=>y6,sidebarRightIcon:()=>Ff,slashIcon:()=>fg,stackPushIcon:()=>uf,start:()=>b6,stop:()=>Tg,strokeIcon:()=>zf,svgIcon:()=>kf,tablerCheckIcon:()=>df,upIcon:()=>Nf,usersIcon:()=>Bs,warning:()=>p6,youtubeIcon:()=>_f,zoomAreaIcon:()=>Ws,zoomIn:()=>c6,zoomOut:()=>d6});import n6 from"clsx";import Gt from"react";import{Fragment as Fe,jsx as g,jsxs as F}from"react/jsx-runtime";var Oo=e=>"var(--icon-fill-color)",SE=e=>e===ne.LIGHT?"#fff":"#1e1e1e",_=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:a,...i}=typeof o=="number"?{width:o}:o;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:n6({"rtl-mirror":n}),style:a,...i,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},G={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},a6=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("polyline",{points:"5 12 3 12 12 3 21 12 19 12"}),g("path",{d:"M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7"}),g("path",{d:"M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"})]}),G),Ps=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),G),Jh=_(F("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),G),Qh=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),G),eg=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),g("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),g("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),G),tg=_(F("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),G),xm=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M6.5 9.5l3.5 -3"}),g("path",{d:"M14 5.5l3 1.5"}),g("path",{d:"M18.5 10l-2.5 7"}),g("path",{d:"M13.5 17.5l-7 -5"})]}),G),zn=_(F("g",{children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),Da=_(F("g",{strokeWidth:"1.25",children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),og=_(g("g",{fill:"currentColor",children:g("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),rg=_(F(Fe,{children:[g("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),ng=_(F(Fe,{children:[g("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),ag=_(F(Fe,{children:[g("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),i6=_(g("g",{fill:"currentColor",children:g("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"})}),{width:40,height:40,fill:"none"}),Bn=_(F("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ln=_(F("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[g("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),g("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Ra=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),G),Na=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),G),Oa=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),G),Ds=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),G),za=_(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),ig=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),G),lr=_(F("g",{strokeWidth:"1.25",children:[g("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),sr=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),G),lg=_(F("g",{stroke:"currentColor",strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),G),Ba=_(F("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),Rs=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),G),ym=_(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),Em=_(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),sg=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),g("path",{d:"M3 4v4h4"})]}),G),_t=_(g("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),Fa=_(F("g",{strokeWidth:"1.5",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),me),Xi=_(F("g",{strokeWidth:"1.25",children:[g("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),$i=_(g("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),ji=_(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),cg=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),G),Fn=_(g("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),Ha=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),G),dg=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),G),vm=_(g("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),Ns=_(g("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),mg=_(F("g",{strokeWidth:"1.25",children:[g("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),g("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),pg=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),G),ug=_(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),qi=_(F("g",{strokeWidth:"1.25",children:[g("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),g("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),hg=_("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),gg=_("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Ua=_(g("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),l6=_("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),s6=_("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Os=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),G),fg=_(g("g",{strokeWidth:1.5,children:g("path",{d:"M6 18l12 -12"})}),G),zs=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),G),bg=_("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),c6=_("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),d6=_("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),xg=_("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),m6=_("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),wm=_(g("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Tm=_(g("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),yg=_("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),Eg=_(g("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),p6=_("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),u6=_("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),h6=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),G),g6=_(F(Fe,{children:[g("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),g("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),f6=_(g("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),ME=F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),LE=F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),Cm=_(LE,G),Im=_(LE,{...G,style:{transform:"rotate(180deg)"}}),km=_(ME,G),Sm=_(ME,{...G,style:{transform:"rotate(180deg)"}}),Mm=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Lm=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Am=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),_m=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),vg=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),wg=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Pm=_(F("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Dm=_(F("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),Bs=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),G),b6=_("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),Tg=_("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),wo=_(F(Fe,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),x6=_("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),y6=_("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),E6=_("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Rm=Gt.memo(({theme:e})=>_(F(Fe,{children:[g("path",{d:"M25 26H111V111H25",fill:Oo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Oo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Oo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Oo(e),strokeWidth:"2"}),F("g",{fill:SE(e),stroke:Oo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Nm=Gt.memo(({theme:e})=>_(F(Fe,{children:[g("path",{d:"M25 26H111V111H25",fill:Oo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Oo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:Oo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Oo(e),strokeWidth:"2"}),F("g",{fill:SE(e),stroke:Oo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Cg=_(g("g",{strokeWidth:1.25,children:g("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),Ig=_(F(Fe,{children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),kg=_(F(Fe,{children:[F("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Sg=_(F(Fe,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Om=_(g(Fe,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Mg=_(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),Lg=_(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),v6=Gt.memo(({theme:e})=>_(g("path",{d:"M6 10H34",stroke:Oo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Ag=_(F("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),G),_g=_(F("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),G),Pg=_(g("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),Dg=_(g("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),Rg=_(g("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),Ng=_(F("svg",{strokeWidth:"1.5",children:[g("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),me),Og=_(F("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),G),zg=_(F("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[g("path",{d:"M12 12l9 0"}),g("path",{d:"M3 9l6 6"}),g("path",{d:"M3 15l6 -6"})]}),G),Bg=Gt.memo(({flip:e=!1})=>_(F("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Fg=Gt.memo(({flip:e=!1})=>_(F("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Hg=Gt.memo(({flip:e=!1})=>_(F("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Ug=Gt.memo(({flip:e=!1})=>_(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Gg=Gt.memo(({flip:e=!1})=>_(F("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Wg=Gt.memo(({flip:e=!1})=>_(F("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Yg=Gt.memo(({flip:e=!1})=>_(F("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Vg=Gt.memo(({flip:e=!1})=>_(F("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Kg=Gt.memo(({flip:e=!1})=>_(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Zg=Gt.memo(({flip:e=!1})=>_(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Xg=Gt.memo(({flip:e=!1})=>_(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),$g=_(F(Fe,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),jg=_(F(Fe,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),qg=_(F(Fe,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Jg=_(g(Fe,{children:g("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Hn=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),G),Qg=_(g(Fe,{children:F("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),G),Ji=_(g(Fe,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),zm=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 8l-4 4l4 4"}),g("path",{d:"M17 8l4 4l-4 4"}),g("path",{d:"M14 4l-4 16"})]}),G),Fs=zm,ef=_(F("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),G),tf=_(F("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),G),of=_(F("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),G),rf=Gt.memo(({theme:e})=>_(F("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),G)),nf=Gt.memo(({theme:e})=>_(F("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),G)),af=Gt.memo(({theme:e})=>_(F("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),G)),Hs=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),G),lf=_(g("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),w6=_(g("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Us=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),G),Bm=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),G),Ga=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),G),sf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),G),cf=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),G),T6=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),G),C6=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),G),df=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),G),Gs=_(F(Fe,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),G),mf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),G),Qi=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),G),zo=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),G),Wa=_(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),pf=_(F("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),g("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),G),uf=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),g("path",{d:"M4 15l8 4l8 -4"}),g("path",{d:"M12 4v7"}),g("path",{d:"M15 8l-3 3l-3 -3"})]}),G),sn=_(F("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),cn=_(F("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),g("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Un=_(F("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),G),I6=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),G),k6=_(F("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),G),hf=_(F("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),G),Ya=_(F("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),G),gf=_(F("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),g("path",{d:"M3 3l18 18"})]}),G),ff=_(F("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),G),bf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),G),uo=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),G),xf=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),G),yf=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 8l0 4l2 2"}),g("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),G),Ef=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),G),vf=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),G),el=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),G),wf=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),G),Tf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),G),Cf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),G),If=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),G),Fm=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),G),Ws=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),G),kf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),G),Sf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),G),Mf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),G),Lf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),G),Af=_(F("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...G,strokeWidth:1.5}),S6=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),G),_f=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),G),Pf=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),G),Df=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),G),Va=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),G),Ka=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),G),Za=_(F("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),G),Ys=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),G),Rf=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),G),Nf=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),G),Hm=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),G),Vs=_(F("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),G),M6=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),g("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),G),Of=_(F("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 6l8 0"}),g("path",{d:"M16 6l4 0"}),g("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 12l2 0"}),g("path",{d:"M10 12l10 0"}),g("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 18l11 0"}),g("path",{d:"M19 18l1 0"})]}),G),zf=_(F("g",{strokeWidth:1,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),G),Bf=_(F("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),g("path",{d:"M13.5 6.5l4 4"})]}),G),L6=_(F("g",{strokeWidth:1,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l-5 5l5 5"}),g("path",{d:"M17 7l-5 5l5 5"})]}),G),Ff=_(F("g",{strokeWidth:"1.75",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),g("path",{d:"M15 4l0 16"})]}),G),A6=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),G),_6=_(F("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 4l18 0"}),g("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),g("path",{d:"M12 16l0 4"}),g("path",{d:"M9 20l6 0"}),g("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),G);import _E from"clsx";import Uf,{useEffect as R6,useRef as PE,useState as N6}from"react";import P6 from"react";import{jsx as Hf}from"react/jsx-runtime";var D6=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let a=-(P6.useRef(Date.now()).current%1600);return Hf("div",{className:`Spinner ${r}`,children:Hf("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${a}ms`:0},children:Hf("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Wt=D6;import{jsx as Ks,jsxs as Zs}from"react/jsx-runtime";var J=Uf.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:a}=qe(),i=Uf.useRef(null);Uf.useImperativeHandle(n,()=>i.current);let l=`ToolIcon_size_${e}`,[s,c]=N6(!1),m=PE(!0),p=async h=>{let b="onClick"in r&&r.onClick?.(h);if(Mn(b))try{c(!0),await b}catch(f){if(f instanceof Ui)console.warn(f);else throw f}finally{m.current&&c(!1)}};R6(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=PE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let h=r.type==="icon"?"button":r.type;return Zs("button",{className:_E("ToolIcon_type_button",l,t,o&&!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:h,onClick:p,ref:i,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Zs("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Ks("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Ks(Wt,{})]}),r.showAriaLabel&&Zs("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&Ks(Wt,{})]}),r.children]})}return Zs("label",{className:_E("ToolIcon",t),title:r.title,onPointerDown:h=>{d.current=h.pointerType||null,r.onPointerDown?.({pointerType:h.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[Ks("input",{className:`ToolIcon_type_radio ${l}`,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:d.current})},checked:r.checked,ref:i}),Zs("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Ks("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});J.displayName="ToolButton";var Um=[],H=e=>(Um=Um.concat(e),e);import{jsx as z6}from"react/jsx-runtime";var O6=(e,o,t)=>{let r=new Set(ae(e.filter(m=>le(m)),o).map(m=>m.id)),n={},a=t.scene.getNonDeletedElementsMap(),i=new Set;for(let m of r){let p=No(e,m);for(let d of p)if(!i.has(d.id)){if(it(d)){let h=Do(d,a);h&&(n[h.id]=!0)}else n[d.id]=!0;i.add(d.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=it(m)?Do(m,a):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):p?.frameId&&r.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let h=t.scene.getNonDeletedElementsMap().get(d.id);h&&Se(h)&&t.scene.mutateElement(h,{startBinding:m.id===h.startBinding?.elementId?null:h.startBinding,endBinding:m.id===h.endBinding?.elementId?null:h.endBinding})}),re(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,it(m)||(n[m.id]=!0),re(m,{frameId:null})):it(m)&&o.selectedElementIds[m.containerId]?re(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=Ke(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{c=null,m[0]&&(n[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(b=>b===o.editingGroupId),h=p.groupIds[d+1];if(h){let b=Ke(s,h).filter(f=>!f.isDeleted);b.length>1&&(c=h,b.forEach(f=>{n[f.id]=!0}))}}}}return{elements:s,appState:{...o,...bt({selectedElementIds:n,editingGroupId:c},s,o,null)}}},DE=(e,o)=>{if(e.editingGroupId){let t=Ke(ve(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},tl=H({name:"deleteSelectedElements",label:"labels.delete",icon:_t,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:i,selectedPointsIndices:l}=o.selectedLinearElement,s=r.scene.getNonDeletedElementsMap(),c=X.getElement(i,s);if(!c||l==null)return!1;if(l.length>=c.points.length){let m=e.map(d=>d.id===c.id?re(d,{isDeleted:!0}):d),p=DE(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:D.IMMEDIATELY}}return X.deletePoints(c,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:D.IMMEDIATELY}}let{elements:n,appState:a}=O6(e,o,r);return Gd(n,n.filter(i=>i.isDeleted)),a=DE(a,n),{elements:n,appState:{...a,activeTool:Ne(o,{type:r.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Be(ve(e),o)?D.IMMEDIATELY:D.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===T.BACKSPACE||e.key===T.DELETE)&&!e[T.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Pt()==="mobile";return z6(J,{type:"button",icon:_t,title:u("labels.delete"),"aria-label":u("labels.delete"),onClick:()=>t(null),disabled:!Be(ve(e),o),style:{...n&&o.openPopup!=="compactOtherProperties"?Xr:{}}})}});var B=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,lo?u("keys.option"):u("keys.alt")).replace(/\bShift\b/i,u("keys.shift")).replace(/\b(Enter|Return)\b/i,u("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,lo?u("keys.cmd"):u("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,u("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,u("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,u("keys.delete"));import{jsx as Km}from"react/jsx-runtime";var Gm=H({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Im,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:qy(e,o,r.scene),appState:o,captureUpdate:D.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===he.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Km("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${u("labels.sendBackward")} \u2014 ${B("CtrlOrCmd+[")}`,children:Im})}),Wm=H({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Cm,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Jy(e,o,r.scene),appState:o,captureUpdate:D.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===he.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Km("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${u("labels.bringForward")} \u2014 ${B("CtrlOrCmd+]")}`,children:Cm})}),Ym=H({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Sm,trackEvent:{category:"element"},perform:(e,o)=>({elements:Qy(e,o),appState:o,captureUpdate:D.IMMEDIATELY}),keyTest:e=>lo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.BRACKET_LEFT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===he.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Km("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${u("labels.sendToBack")} \u2014 ${lo?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")}`,children:Sm})}),Vm=H({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:km,trackEvent:{category:"element"},perform:(e,o)=>({elements:eE(e,o),appState:o,captureUpdate:D.IMMEDIATELY}),keyTest:e=>lo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.BRACKET_RIGHT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===he.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Km("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${u("labels.bringToFront")} \u2014 ${lo?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")}`,children:km})});var Zm=H({name:"selectAll",label:"labels.selectAll",icon:wf,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(a=>!a.isDeleted&&!($(a)&&a.containerId)&&!a.locked).reduce((a,i)=>(a[i.id]=!0,a),{});return{appState:{...o,...bt({editingGroupId:null,selectedElementIds:n},ve(e),o,r),selectedLinearElement:Object.keys(n).length===1&&ge(e[0])?new X(e[0],ie(e)):null},captureUpdate:D.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as B6}from"react/jsx-runtime";var Xm=H({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Xi,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let i=X.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:i,captureUpdate:D.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:a}=nn({type:"in-place",elements:e,idsOfElementsToDuplicate:ie(ae(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:i,origIdToDuplicateId:l})=>{let s=i.frameId&&l.get(i.frameId);return{x:i.x+qu/2,y:i.y+qu/2,frameId:s??i.frameId}}});if(r.props.onDuplicate&&a){let i=r.props.onDuplicate(a,e);i&&(a=i)}return{elements:wr(a,ie(n)),appState:{...o,...Kd(n,ve(a),o)},captureUpdate:D.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Pt()==="mobile";return B6(J,{type:"button",icon:Xi,title:`${u("labels.duplicateSelection")} \u2014 ${B("CtrlOrCmd+D")}`,"aria-label":u("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Be(ve(e),o),style:{...n&&o.openPopup!=="compactOtherProperties"?Xr:{}}})}});import{useEffect as l1,useMemo as u4,useRef as s1,useState as h4}from"react";var F6=new Set(["command_palette","export"]),pe=(e,o,t,r)=>{try{if(typeof window>"u"||I.VITE_WORKER_ID||I.VITE_APP_ENABLE_TRACKING!=="true"||!F6.has(e)||Ht())return;I.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import W6 from"clsx";import H6 from"clsx";import{forwardRef as U6}from"react";import{jsx as G6}from"react/jsx-runtime";var ol=U6((e,o)=>{let{title:t,className:r,testId:n,active:a,standalone:i,icon:l,onClick:s}=e;return G6("button",{type:"button",ref:o,title:t,"data-testid":n,className:H6(r,{standalone:i,active:a}),onClick:s,style:e.style,children:l},t)});import{Fragment as V6,jsx as Gf,jsxs as Y6}from"react/jsx-runtime";var Bo=e=>Gf(V6,{children:e.options.map(o=>e.type==="button"?Gf(ol,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):Y6("label",{className:W6({active:e.value===o.value}),title:o.text,children:[Gf("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as op from"@radix-ui/react-popover";import jE from"clsx";import{useRef as qE,useEffect as _I}from"react";import{jsx as K6}from"react/jsx-runtime";var $m=()=>K6("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as j6,useRef as q6}from"react";import{createPortal as J6}from"react-dom";import RE from"react";var Wf=RE.createContext(null),Le=()=>RE.useContext(Wf);import{useState as Z6,useLayoutEffect as NE}from"react";var jm=e=>{let[o,t]=Z6(null),r=Te(),{theme:n}=Le(),{container:a}=qe();return NE(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.formFactor==="phone"),o.classList.toggle("theme--dark",n===ne.DARK))},[o,n,r.formFactor,e?.className]),NE(()=>{let i=e?.parentSelector?a?.querySelector(e.parentSelector):document.body;if(!i)return;let l=document.createElement("div");return i.appendChild(l),t(l),()=>{i.removeChild(l)}},[a,e?.parentSelector]),o};import{useEffect as X6}from"react";function rl(e,o,t){X6(()=>{function r(n){let a=n;if(!e.current)return;let i=t?.(a,e.current);if(i===!0)return;if(i===!1)return o(a);e.current.contains(a.target)||!document.documentElement.contains(a.target)||a.target.closest("[data-radix-portal]")||a.target===document.documentElement&&document.body.style.pointerEvents==="none"||a.target.closest("[data-prevent-outside-click]")||o(a)}return document.addEventListener("pointerdown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("pointerdown",r),document.removeEventListener("touchstart",r)}},[e,o,t])}import{useRef as $6}from"react";var Gn=e=>{let o=$6(e);return Object.assign(o.current,e),o.current};import{jsx as Q6}from"react/jsx-runtime";var Wn=we(null),OE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=jm({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),a=Le(),i=Yn(),l=lt(),s=ae(i,a),c=Gn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=qe();j6(()=>{let d=p.current;if(!d||!l.canvas||!n)return;let h=!1,b=l.canvas.getContext("2d"),f=({clientX:S,clientY:A})=>{let M=b.getImageData((S-a.offsetLeft)*window.devicePixelRatio,(A-a.offsetTop)*window.devicePixelRatio,1,1).data;return nx(M[0],M[1],M[2])},E=({clientX:S,clientY:A,altKey:M})=>{d.style.top=`${A+20}px`,d.style.left=`${S+20}px`;let N=f({clientX:S,clientY:A});h&&c.onChange(r,N,c.selectedElements,{altKey:M}),d.style.background=N},v=()=>{c.onCancel()},x=(S,A)=>{c.onSelect(S,A)},y=S=>{h=!0,S.stopImmediatePropagation()},w=S=>{h=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),x(f(S),S)},C=S=>{S.key===T.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),v())};return n.tabIndex=-1,n.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",C),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",w),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener("blur",v),()=>{h=!1,n.removeEventListener("keydown",C),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",w),window.removeEventListener("pointermove",E),window.removeEventListener("blur",v)}},[c,l.canvas,n,r,m,a.offsetLeft,a.offsetTop]);let p=q6(null);return rl(p,()=>{e()},d=>!!d.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?J6(Q6("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),n):null};import*as nl from"@radix-ui/react-popover";import rI from"clsx";import nI from"react";import eI from"react";import tI from"clsx";import{jsx as oI}from"react/jsx-runtime";var xt=eI.forwardRef(({children:e,padding:o,className:t,style:r},n)=>oI("div",{className:tI("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Yf,jsxs as aI}from"react/jsx-runtime";var dn=nI.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:a,onFocusOutside:i,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=Te(),d=p.formFactor==="phone"&&!p.isLandscape;return Yf(nl.Portal,{container:o,children:aI(nl.Content,{ref:m,className:rI("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:a,onFocusOutside:i,onPointerDownOutside:s,onOpenAutoFocus:h=>{c&&p.isTouchScreen&&h.preventDefault()},onCloseAutoFocus:h=>{h.stopPropagation(),h.preventDefault(),o&&!ux(document.activeElement)&&o.focus(),n()},children:[Yf(xt,{padding:3,style:r,children:t}),Yf(nl.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as iI,useCallback as Vf}from"react";var qm=()=>document.querySelector(".excalidraw-wysiwyg"),Jm=()=>{let e=qm();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Xs=e=>{setTimeout(()=>{let o=qm();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},$s=(e,o,t,r)=>{o&&r&&r();let n=o&&t?Jm():null;e(),o&&t&&Xs(n)},zE=()=>{let[e,o]=iI(null),t=Vf(()=>{let a=Jm();o(a)},[]),r=Vf(()=>{setTimeout(()=>{let a=qm();a&&(a.focus(),e&&(a.selectionStart=e.start,a.selectionEnd=e.end,o(null)))},0)},[e]),n=Vf(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:r,clearSavedPosition:n,hasSavedPosition:!!e}},BE=(e=100)=>{let o=qm();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import lI from"clsx";import{useCallback as sI,useEffect as Zf,useRef as HE,useState as cI}from"react";var Vn=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},js=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Kf=({color:e,palette:o})=>!Object.values(o).flat().includes(e),FE=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(i=>{if(i.isDeleted)return!1;let l=i[r[o]];return Kf({color:l,palette:t})}),a=new Map;return n.forEach(i=>{let l=i[r[o]];a.has(l)?a.set(l,a.get(l)+1):a.set(l,1)}),[...a.entries()].sort((i,l)=>l[1]-i[1]).map(i=>i[0]).slice(0,q0)},Fo=we(null);import{Fragment as dI,jsx as Qm,jsxs as UE}from"react/jsx-runtime";var GE=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let a=Te(),[i,l]=cI(e),[s,c]=te(Fo);Zf(()=>{l(e)},[e]);let m=sI(f=>{let E=f.toLowerCase(),v=ax(E);v&&o(v),l(E)},[o]),p=HE(null),d=HE(null);Zf(()=>{p.current&&p.current.focus()},[s]);let[h,b]=te(Wn);return Zf(()=>()=>{b(null)},[b]),UE("div",{className:"color-picker__input-label",children:[Qm("div",{className:"color-picker__input-hash",children:"#"}),Qm("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:f=>{m(f.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:f=>{f.key!==T.TAB&&(f.key===T.ESCAPE&&d.current?.focus(),f.stopPropagation())},placeholder:n}),a.formFactor!=="phone"&&UE(dI,{children:[Qm("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Qm("div",{ref:d,className:lI("excalidraw-eye-dropper-trigger",{selected:h}),onClick:()=>b(f=>f?null:{keepOpenOnAlt:!1,onSelect:E=>o(E),colorPickerType:r}),title:`${u("labels.eyeDropper")} \u2014 ${T.I.toLocaleUpperCase()} or ${B("Alt")} `,children:mf})]})]})};import qf,{useEffect as Jf,useImperativeHandle as MI,useState as LI}from"react";import uI from"clsx";import{useEffect as hI,useRef as gI}from"react";import{jsxs as pI}from"react/jsx-runtime";var mI=({color:e,keyLabel:o,isShade:t=!1})=>pI("div",{className:"color-picker__button__hotkey-label",style:{color:fa(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),al=mI;import{jsx as Xf,jsxs as fI}from"react/jsx-runtime";var WE=({colors:e,color:o,onChange:t,label:r})=>{let[n,a]=te(Fo),i=gI(null);return hI(()=>{i.current&&i.current.focus()},[o,n]),Xf("div",{className:"color-picker-content--default",children:e.map((l,s)=>fI("button",{ref:o===l?i:void 0,tabIndex:-1,type:"button",className:uI("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),a("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Xf("div",{className:"color-picker__button-outline"}),Xf(al,{color:l,keyLabel:s+1})]},s))})};import bI from"clsx";import{useEffect as xI,useRef as yI}from"react";import{jsx as $f,jsxs as vI}from"react/jsx-runtime";var EI=({palette:e,color:o,onChange:t,activeShade:r,showHotKey:n=!0})=>{let a=Vn({color:o,palette:e}),[i,l]=te(Fo),s=yI(null);return xI(()=>{s.current&&i==="baseColors"&&s.current.focus()},[a?.colorName,i]),$f("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[r]:m)||"transparent",h=js[p],b=u(`colors.${c.replace(/\d+/,"")}`,null,"");return vI("button",{ref:a?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:bI("color-picker__button color-picker__button--large has-outline",{active:a?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),l("baseColors")},title:`${b}${d.startsWith("#")?` ${d}`:""} \u2014 ${h}`,"aria-label":`${b} \u2014 ${h}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[$f("div",{className:"color-picker__button-outline"}),n&&$f(al,{color:d,keyLabel:h})]},c)})})},YE=EI;import{jsx as TI}from"react/jsx-runtime";var wI=({children:e})=>TI("div",{className:"color-picker__heading",children:e}),il=wI;import CI from"clsx";import{useEffect as II,useRef as kI}from"react";import{jsx as qs,jsxs as VE}from"react/jsx-runtime";var KE=({color:e,onChange:o,palette:t,showHotKey:r})=>{let n=Vn({color:e||"transparent",palette:t}),[a,i]=te(Fo),l=kI(null);if(II(()=>{l.current&&a==="shades"&&l.current.focus()},[n,a]),n){let{colorName:s,shade:c}=n,m=t[s];if(Array.isArray(m))return qs("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>VE("button",{ref:d===c&&a==="shades"?l:void 0,tabIndex:-1,type:"button",className:CI("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),i("shades")},children:[qs("div",{className:"color-picker__button-outline"}),r&&qs(al,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return VE("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[qs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),qs("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:u("colorPicker.noShades")})]})};var jf=(e,o,t)=>{let r=Math.ceil(t/ga);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+ga;return n>=t?o%ga:n}case"ArrowUp":{let n=o-ga,a=n<0?ga*r+n:n;return a>=t?void 0:a}}},SI=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:a,activeShade:i})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),a("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),a("custom"),!0;if(js.includes(e.key)){let l=js.indexOf(e.key),s=Object.keys(r)[l],c=r[s],m=Array.isArray(c)?c[i]:c;return t(m),a("baseColors"),!0}return!1},ZE=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:a,setActiveColorPickerSection:i,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[T.CTRL_OR_CMD])return!1;if(e.key===T.ESCAPE)return m(e),!0;if(e.key===T.ALT)return c(!0),!0;if(e.key===T.I)return c(),!0;let p=Vn({color:r,palette:t});if(e.key===T.TAB){let d={custom:!!a.length,baseColors:!0,shades:p?.shade!=null,hex:!0},h=Object.entries(d).reduce((x,[y,w])=>(w&&x.push(y),x),[]),b=h.indexOf(o),f=e.shiftKey?-1:1,E=b+f>h.length-1?0:b+f<0?h.length-1:b+f,v=h[E];return v&&i(v),v==="custom"?n(a[0]):v==="baseColors"&&(Object.entries(t).find(([y,w])=>Array.isArray(w)?w.includes(r):w===r?y:null)||n($r.charcoal)),e.preventDefault(),e.stopPropagation(),!0}if(SI({e,colorObj:p,onChange:n,palette:t,customColors:a,setActiveColorPickerSection:i,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,h=jf(e.key,d,ga);if(h!==void 0)return n(t[p.colorName][h]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,h=Object.keys(t),b=h.indexOf(d),f=jf(e.key,b,h.length);if(f!==void 0){let E=h[f],v=t[E];return n(Array.isArray(v)?v[s]:v),!0}}if(o==="custom"){let d=r!=null?a.indexOf(r):0,h=jf(e.key,d,a.length);if(h!==void 0){let b=a[h];return n(b),!0}}return!1};import{jsx as Kn,jsxs as ep}from"react/jsx-runtime";var XE=qf.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:a,children:i,showTitle:l,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=l?t==="elementStroke"?u("labels.stroke"):t==="elementBackground"?u("labels.background"):null:null,[h]=qf.useState(()=>t==="canvasBackground"?[]:FE(r,t,n)),[b,f]=te(Fo),E=Vn({color:e,palette:n});Jf(()=>{if(!b){let w=!!e&&Kf({color:e,palette:n}),C=w&&!h.includes(e);f(C?null:w?"custom":E?.shade!=null?"shades":"baseColors")}},[b,e,n,f,E,h]);let[v,x]=LI(E?.shade??(t==="elementBackground"?ex:Q0));Jf(()=>{E?.shade!=null&&x(E.shade);let w=C=>{C.key===T.ALT&&s(!1)};return document.addEventListener("keyup",w,{capture:!0}),()=>{document.removeEventListener("keyup",w,{capture:!0})}},[E,s]);let y=qf.useRef(null);return MI(p,()=>y.current),Jf(()=>{y?.current?.focus()},[]),Kn("div",{role:"dialog","aria-modal":"true","aria-label":u("labels.colorPicker"),children:ep("div",{ref:y,onKeyDown:w=>{ZE({event:w,activeColorPickerSection:b,palette:n,color:e,onChange:o,onEyeDropperToggle:s,customColors:h,setActiveColorPickerSection:f,updateData:a,activeShade:v,onEscape:c})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&Kn("div",{className:"color-picker__title",children:d}),!!h.length&&ep("div",{children:[Kn(il,{children:u("colorPicker.mostUsedCustomColors")}),Kn(WE,{colors:h,color:e,label:u("colorPicker.mostUsedCustomColors"),onChange:o})]}),ep("div",{children:[Kn(il,{children:u("colorPicker.colors")}),Kn(YE,{color:e,palette:n,onChange:o,activeShade:v,showHotKey:m})]}),ep("div",{children:[Kn(il,{children:u("colorPicker.shades")}),Kn(KE,{color:e,onChange:o,palette:n,showHotKey:m})]}),i]})})});import AI from"clsx";import{jsx as Qf}from"react/jsx-runtime";var $E=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=fd),o==="elementBackground"&&(n=bd),o==="canvasBackground"&&(n=xd),r&&(n=r),n?Qf("div",{className:"color-picker__top-picks",children:n.map(a=>Qf("button",{className:AI("color-picker__button",{active:a===t,"is-transparent":a==="transparent"||!a,"has-outline":!fa(a,cs)}),style:{"--swatch-color":a},type:"button",title:a,onClick:()=>e(a),"data-testid":`color-top-pick-${a}`,children:Qf("div",{className:"color-picker__button-outline"})},a))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Ho,jsxs as tp}from"react/jsx-runtime";var PI=({type:e,color:o,onChange:t,label:r,elements:n,palette:a=$r,updateData:i,getOpenPopup:l,appState:s})=>{let{container:c}=qe(),m=Pt(),p=m!=="full",d=m==="mobile",[,h]=te(Fo),[b,f]=te(Wn),E=tp("div",{children:[Ho(il,{children:u("colorPicker.hexCode")}),Ho(GE,{color:o||"",label:r,onChange:y=>{t(y)},colorPickerType:e,placeholder:u("colorPicker.color")})]}),v=qE(null),x=()=>{v.current?.focus()};return Ho(dn,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:y=>{so(y.target)||x(),y.preventDefault()},onPointerDownOutside:y=>{b&&y.preventDefault()},onClose:()=>{l()===e&&i({openPopup:null}),h(null),s.editingTextElement&&setTimeout(()=>{let y=document.querySelector(".excalidraw-wysiwyg");y&&y.focus()},0)},children:a?Ho(XE,{ref:v,palette:a,color:o,onChange:y=>{let w=s.editingTextElement?Jm():null;t(y),s.editingTextElement&&w&&Xs(w)},onEyeDropperToggle:y=>{f(w=>y?(w=w||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},w.keepOpenOnAlt=!0,w):y===!1||w?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:y=>{b?f(null):i({openPopup:null})},type:e,elements:n,updateData:i,showTitle:p,showHotKey:!d,children:E}):E})},DI=({label:e,color:o,type:t,mode:r="background",onToggle:n,editingTextElement:a})=>{let i=Pt(),l=i!=="full",s=i==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),a&&BE(),n()};return tp(op.Trigger,{type:"button",className:jE("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!fa(o,cs),"compact-sizing":l,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?u("labels.showStroke"):u("labels.showBackground"),"data-openpopup":t,onClick:c,children:[Ho("div",{className:"color-picker__button-outline",children:!o&&fg}),l&&o&&r==="stroke"&&Ho("div",{className:"color-picker__button-background",children:Ho("span",{style:{color:o&&fa(o,cs)?"#fff":"#111"},children:zf})})]})},Js=({type:e,color:o,onChange:t,label:r,elements:n,palette:a=$r,topPicks:i,updateData:l,appState:s})=>{let c=qE(s.openPopup);_I(()=>{c.current=s.openPopup},[s.openPopup]);let p=Pt()!=="full";return Ho("div",{children:tp("div",{role:"dialog","aria-modal":"true",className:jE("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&Ho($E,{activeColor:o,onChange:t,type:e,topPicks:i}),!p&&Ho($m,{}),tp(op.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&l({openPopup:e})},children:[Ho(DI,{color:o,label:r,type:e,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Ho(PI,{type:e,color:o,onChange:t,label:r,elements:n,palette:a,updateData:l,getOpenPopup:()=>c.current,appState:s})]})]})})};import*as lv from"@radix-ui/react-popover";import t4 from"clsx";import o4,{useCallback as r4,useMemo as n4}from"react";import jI,{useMemo as Zn,useState as qI,useRef as JI,useEffect as QI,useCallback as tv}from"react";import RI from"clsx";import NI from"react";import{jsx as OI,jsxs as zI}from"react/jsx-runtime";var rp=NI.forwardRef(({className:e,placeholder:o,onChange:t},r)=>zI("div",{className:RI("QuickSearch__wrapper",e),children:[uo,OI("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import BI from"clsx";import{Children as FI}from"react";import{jsx as JE}from"react/jsx-runtime";var np=({className:e,placeholder:o,children:t})=>{let r=!FI.count(t);return JE("div",{className:BI("ScrollableList__wrapper",e),role:"menu",children:r?JE("div",{className:"empty",children:o}):t})};import{jsx as HI,jsxs as UI}from"react/jsx-runtime";var QE=({children:e,className:o="",style:t,title:r})=>UI("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&HI("p",{className:"dropdown-menu-group-title",children:r}),e]}),Qs=QE;QE.displayName="DropdownMenuGroup";import{useEffect as XI,useRef as $I}from"react";import{jsx as GI}from"react/jsx-runtime";var ec=({children:e,...o})=>GI("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as YI,jsx as ap,jsxs as VI}from"react/jsx-runtime";var WI=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=Te();return VI(YI,{children:[o&&ap("div",{className:"dropdown-menu-item__icon",children:o}),ap("div",{style:e,className:"dropdown-menu-item__text",children:ap(ec,{children:r})}),t&&n.formFactor!=="phone"&&ap("div",{className:"dropdown-menu-item__shortcut",children:t})]})},ip=WI;import KI,{useContext as ZI}from"react";var e1=KI.createContext({}),lp=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
-
${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),sp=(e,o)=>{let t=ZI(e1);return Ln(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as t1}from"react/jsx-runtime";var o1=({icon:e,value:o,order:t,children:r,shortcut:n,className:a,hovered:i,selected:l,textStyle:s,onSelect:c,onClick:m,...p})=>{let d=sp(m,c),h=$I(null);return XI(()=>{i&&(t===0?h.current?.scrollIntoView({block:"end"}):h.current?.scrollIntoView({block:"nearest"}))},[i,t]),t1("button",{...p,ref:h,value:o,onClick:d,className:lp(a,l,i),title:p.title??p["aria-label"],children:t1(ip,{textStyle:s,icon:e,shortcut:n,children:r})})};o1.displayName="DropdownMenuItem";var ll={GREEN:"green",RED:"red",BLUE:"blue"},cp=({type:e=ll.BLUE,children:o})=>{let{theme:t}=Lr(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===ne.LIGHT?"1.5px solid white":"none"};switch(e){case ll.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ll.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ll.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return t1("div",{className:"DropDownMenuItemBadge",style:r,children:o})};cp.displayName="DropdownMenuItemBadge";o1.Badge=cp;var Jt=o1;var ev=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:a,onHover:i})=>{if(!e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===T.F)return o.current?.focus(),!0;if(e.key===T.ESCAPE)return n(),!0;if(e.key===T.ENTER)return t?.value&&a(t.value),!0;if(e.key===T.ARROW_DOWN)return t?.next?i(t.next.value):r[0]?.value&&i(r[0].value),!0;if(e.key===T.ARROW_UP)return t?.prev?i(t.prev.value):r[r.length-1]?.value&&i(r[r.length-1].value),!0};import{jsx as tc,jsxs as ov}from"react/jsx-runtime";var e4=e=>{switch(e){case It.Excalifont:case It.Virgil:return lr;case It.Nunito:case It.Helvetica:return Ji;case It["Lilita One"]:return Qg;case It["Comic Shanns"]:case It.Cascadia:return Fs;default:return Ji}},rv=jI.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:a,onClose:i})=>{let{container:l}=qe(),s=lt(),{fonts:c}=s,{showDeprecatedFonts:m}=Ar(),p=Pt(),[d,h]=qI(""),b=JI(null),f=Zn(()=>Array.from(Nn.registered.entries()).filter(([P,{metadata:O}])=>!O.private&&!O.fallback).map(([P,{metadata:O,fontFaces:Y}])=>{let Q={value:P,icon:e4(P),text:Y[0]?.fontFace?.family??"Unknown"};return O.deprecated&&Object.assign(Q,{deprecated:O.deprecated,badge:{type:ll.RED,placeholder:u("fontList.badge.old")}}),Q}).sort((P,O)=>P.text.toLowerCase()>O.text.toLowerCase()?1:-1),[]),E=Zn(()=>new Set(c.getSceneFamilies()),[e]),v=Zn(()=>f.filter(P=>E.has(P.value)),[f,E]),x=Zn(()=>f.filter(P=>!E.has(P.value)&&(m||!P.deprecated)),[f,E,m]),y=Zn(()=>wx([...v,...x].filter(P=>P.text?.toLowerCase().includes(d))),[v,x,d]),w=Zn(()=>{let P;return o?P=y.find(O=>O.value===o):e&&(P=y.find(O=>O.value===e)),!P&&d&&(y[0]?.value?r(y[0].value):n()),P},[o,e,d,y,r,n]),C=tv(P=>{let O=null;if(s.state.editingTextElement){let Y=document.querySelector(".excalidraw-wysiwyg");Y&&(O={start:Y.selectionStart,end:Y.selectionEnd})}t(P),s.state.editingTextElement&&O&&setTimeout(()=>{let Y=document.querySelector(".excalidraw-wysiwyg");Y&&O&&(Y.focus(),Y.selectionStart=O.start,Y.selectionEnd=O.end)},0)},[t,s.state.editingTextElement]),S=tv(P=>{ev({event:P,inputRef:b,hoveredFont:w,filteredFonts:y,onSelect:C,onHover:r,onClose:i})&&(P.preventDefault(),P.stopPropagation())},[w,y,C,r,i]);QI(()=>(a(),()=>{i()}),[]);let A=Zn(()=>y.filter(P=>E.has(P.value)),[y,E]),M=Zn(()=>y.filter(P=>!E.has(P.value)),[y,E]),N=(P,O)=>ov(Jt,{icon:P.icon,value:P.value,order:O,textStyle:{fontFamily:ya({fontFamily:P.value})},hovered:P.value===w?.value,selected:P.value===e,tabIndex:P.value===e?0:-1,onClick:Y=>{C(Number(Y.currentTarget.value))},onMouseMove:()=>{w?.value!==P.value&&r(P.value)},children:[P.text,P.badge&&tc(cp,{type:P.badge.type,children:P.badge.placeholder})]},P.value),R=[];return A.length&&R.push(tc(Qs,{title:u("fontList.sceneFonts"),children:A.map(N)},"group_1")),M.length&&R.push(tc(Qs,{title:u("fontList.availableFonts"),children:M.map((P,O)=>N(P,O+A.length))},"group_2")),ov(dn,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{i(),s.state.editingTextElement&&setTimeout(()=>{let P=document.querySelector(".excalidraw-wysiwyg");P&&P.focus()},0)},onPointerLeave:n,onKeyDown:S,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&tc(rp,{ref:b,placeholder:u("quickSearch.placeholder"),onChange:Sn(h,20)}),tc(np,{className:"dropdown-menu fonts manual-hover",placeholder:u("fontList.empty"),children:R.length?R:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as nv from"@radix-ui/react-popover";import{jsx as r1}from"react/jsx-runtime";var av=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let r=ye(),n=t?{...Xr,width:"2rem",height:"2rem"}:{};return r1(nv.Trigger,{asChild:!0,children:r1("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:r1(ol,{standalone:!0,icon:sr,title:u("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{r(a=>({openPopup:a.openPopup==="fontFamily"?null:a.openPopup}))},style:{border:"none",...n}})})})};import{jsx as oc,jsxs as iv}from"react/jsx-runtime";var sv=[{value:It.Excalifont,icon:lr,text:u("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:It.Nunito,icon:Ji,text:u("labels.normal"),testId:"font-family-normal"},{value:It["Comic Shanns"],icon:Fs,text:u("labels.code"),testId:"font-family-code"}],xz=new Set(sv.map(e=>e.value));var cv=o4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:a,onPopupChange:i,compactMode:l=!1})=>{let s=n4(()=>sv,[]),c=r4(m=>{m&&r(m)},[r]);return iv("div",{role:"dialog","aria-modal":"true",className:t4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&oc("div",{className:"buttonList",children:oc(Bo,{type:"button",options:s,value:o,onClick:c})}),!l&&oc($m,{}),iv(lv.Root,{open:e,onOpenChange:i,children:[oc(av,{selectedFontFamily:o,isOpened:e,compactMode:l}),e&&oc(rv,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:n,onLeave:a,onOpen:()=>i(!0),onClose:()=>i(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as sl from"@radix-ui/react-popover";import s4 from"clsx";import dp,{useEffect as c4}from"react";import{jsx as a4}from"react/jsx-runtime";var _r=({className:e,icon:o,size:t="1em"})=>a4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as l4,jsx as dv,jsxs as mv}from"react/jsx-runtime";var i4=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:a=!0})=>mv(l4,{children:[mv("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,a&&dv(_r,{icon:o?Rf:Ys})]}),o&&dv("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),rc=i4;import{jsx as Xa,jsxs as n1}from"react/jsx-runtime";var d4=we(!1);function m4({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:a=e.length}){let i=Te(),{container:l}=qe(),s=f=>{let E=e.find(v=>v.keyBinding===f.key.toLowerCase());if(!(f.metaKey||f.altKey||f.ctrlKey)&&E)r(E.value),f.preventDefault();else if(f.key===T.TAB){let v=e.findIndex(y=>y.value===o),x=f.shiftKey?(e.length+v-1)%e.length:(v+1)%e.length;r(e[x].value)}else if(xa(f.key)){let v=an().rtl,x=e.findIndex(y=>y.value===o);if(x!==-1){let y=e.length,w=x;switch(f.key){case(v?T.ARROW_LEFT:T.ARROW_RIGHT):w=(x+1)%y;break;case(v?T.ARROW_RIGHT:T.ARROW_LEFT):w=(y+x-1)%y;break;case T.ARROW_DOWN:{w=(x+(a??1))%y;break}case T.ARROW_UP:{w=(y+x-(a??1))%y;break}}r(e[w].value)}f.preventDefault()}else(f.key===T.ESCAPE||f.key===T.ENTER)&&(f.preventDefault(),n());f.nativeEvent.stopImmediatePropagation(),f.stopPropagation()},[c,m]=te(d4),p=dp.useMemo(()=>e.slice(0,a),[e,a]),d=dp.useMemo(()=>e.slice(a),[e,a]);c4(()=>{p.some(f=>f.value===o)||m(!0)},[o,p,m]);let h=f=>Xa("div",{className:"picker-content",children:f.map((E,v)=>n1("button",{type:"button",className:s4("picker-option",{active:o===E.value}),onClick:x=>{r(E.value)},title:`${E.text} ${E.keyBinding&&`\u2014 ${E.keyBinding.toUpperCase()}`}`,"aria-label":E.text||"none","aria-keyshortcuts":E.keyBinding||void 0,ref:x=>{o===E.value&&setTimeout(()=>{x?.focus()},0)},children:[E.icon,E.keyBinding&&Xa("span",{className:"picker-keybinding",children:E.keyBinding})]},E.text))}),b=i.formFactor==="phone";return Xa(sl.Content,{side:b?"right":"bottom",align:"start",sideOffset:b?8:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:s,collisionBoundary:l??void 0,children:n1("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[h(p),d.length>0&&Xa(rc,{label:u("labels.more_options"),open:c,openTrigger:()=>{m(f=>!f)},className:"picker-collapsible",children:h(d)})]})})}function a1({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:a}){let[i,l]=dp.useState(!1),s=dp.useRef(null);return Xa("div",{children:n1(sl.Root,{open:i,onOpenChange:c=>l(c),children:[Xa(sl.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!i),ref:s,className:i?"active":"",children:t.find(c=>c.value===e)?.icon}),i&&Xa(m4,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:a})]})})}import pv,{useEffect as p4}from"react";import{jsx as i1,jsxs as uv}from"react/jsx-runtime";var hv=({updateData:e,app:o,testId:t})=>{let r=pv.useRef(null),n=pv.useRef(null),a=o.scene.getSelectedElements(o.state),i=!0,l=a.at(0),c=a.reduce((m,p)=>(m!=null&&m!==p.opacity&&(i=!1),m==null||m>p.opacity?p.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return p4(()=>{if(r.current&&n.current){let m=r.current,p=n.current,d=m.offsetWidth,h=15,b=c/100*(d-h)+h/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),uv("label",{className:"control-label",children:[u("labels.opacity"),uv("div",{className:"range-wrapper",children:[i1("input",{style:{"--color-slider-track":i?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),i1("div",{className:"value-bubble",ref:n,children:c!==0?c:null}),i1("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as p1,jsx as ce,jsxs as eo}from"react/jsx-runtime";var fv=.1,cl=e=>{let o=ba(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},Qt=(e,o,t,r=!1)=>{let n=ie(ae(e,o,{includeBoundTextElement:r}));return e.map(a=>n.get(a.id)||a.id===o.editingTextElement?.id?t(a):a)},Xt=function(e,o,t,r,n){let a=o.state.editingTextElement,i=ve(e),l=null;if(a&&(l=t(a)),!l)if(Be(i,o.state)){let c=o.scene.getSelectedElements(o.state),m=r===!0?c:c.filter(p=>r(p));l=Md(m,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},g4=(e,o,t)=>it(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),c1=(e,o,t,r,n)=>{let a=new Set,i=Qt(e,o,l=>{if($(l)){let s=r(l);a.add(s);let c=re(l,{fontSize:s});return ut(c,t.scene.getContainerElement(l),t.scene),c=g4(l,c,t.scene),c}return l},!0);return ae(e,o,{includeBoundTextElement:!0}).forEach(l=>{$(l)&&on(l,t.scene)}),{elements:i,appState:{...o,currentItemFontSize:a.size===1?[...a][0]:n??o.currentItemFontSize},captureUpdate:D.IMMEDIATELY}},bv=H({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:Qt(e,o,r=>Es(r.type)?re(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?D.IMMEDIATELY:D.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{stylesPanelMode:a}=cl(r);return eo(p1,{children:[a==="full"&&ce("h3",{"aria-hidden":"true",children:u("labels.stroke")}),ce(Js,{topPicks:fd,palette:tx,type:"elementStroke",label:u("labels.stroke"),color:Xt(e,r,i=>i.strokeColor,!0,i=>i?null:o.currentItemStrokeColor),onChange:i=>t({currentItemStrokeColor:i}),elements:e,appState:o,updateData:t})]})}}),xv=H({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:D.EVENTUALLY};let n,a=r.scene.getSelectedElements(o);if(!jr(t.currentItemBackgroundColor)&&a.every(l=>tt(l)&&Ox(l.points))){let l=ie(a);n=e.map(s=>l.has(s.id)&&tt(s)?re(s,{backgroundColor:t.currentItemBackgroundColor,...jd(s,!0)}):s)}else n=Qt(e,o,l=>re(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:D.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{stylesPanelMode:a}=cl(r);return eo(p1,{children:[a==="full"&&ce("h3",{"aria-hidden":"true",children:u("labels.background")}),ce(Js,{topPicks:bd,palette:ox,type:"elementBackground",label:u("labels.background"),color:Xt(e,r,i=>i.backgroundColor,!0,i=>i?null:o.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:o,updateData:t})]})}}),yv=H({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(pe("element","changeFillStyle",`${t} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Qt(e,o,n=>re(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=ae(e,o),a=n.length>0&&n.every(i=>i.fillStyle==="zigzag");return eo("fieldset",{children:[ce("legend",{children:u("labels.fill")}),ce("div",{className:"buttonList",children:ce(Bo,{type:"button",options:[{value:"hachure",text:`${a?u("labels.zigzag"):u("labels.hachure")} (${B("Alt-Click")})`,icon:a?Cg:Ig,active:a?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:u("labels.crossHatch"),icon:kg,testId:"fill-cross-hatch"},{value:"solid",text:u("labels.solid"),icon:Sg,testId:"fill-solid"}],value:Xt(e,r,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:o.currentItemFillStyle),onClick:(i,l)=>{let s=l.altKey&&i==="hachure"&&n.every(c=>c.fillStyle==="hachure")?"zigzag":i;t(s)}})})]})}}),Ev=H({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Qt(e,o,r=>re(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>eo("fieldset",{children:[ce("legend",{children:u("labels.strokeWidth")}),ce("div",{className:"buttonList",children:ce(Bo,{group:"stroke-width",options:[{value:ud.thin,text:u("labels.thin"),icon:Om,testId:"strokeWidth-thin"},{value:ud.bold,text:u("labels.bold"),icon:Mg,testId:"strokeWidth-bold"},{value:ud.extraBold,text:u("labels.extraBold"),icon:Lg,testId:"strokeWidth-extraBold"}],value:Xt(e,r,a=>a.strokeWidth,a=>a.hasOwnProperty("strokeWidth"),a=>a?null:o.currentItemStrokeWidth),onChange:a=>t(a)})})]})}),vv=H({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Qt(e,o,r=>re(r,{seed:va(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>eo("fieldset",{children:[ce("legend",{children:u("labels.sloppiness")}),ce("div",{className:"buttonList",children:ce(Bo,{group:"sloppiness",options:[{value:0,text:u("labels.architect"),icon:Pg},{value:1,text:u("labels.artist"),icon:Dg},{value:2,text:u("labels.cartoonist"),icon:Rg}],value:Xt(e,r,a=>a.roughness,a=>a.hasOwnProperty("roughness"),a=>a?null:o.currentItemRoughness),onChange:a=>t(a)})})]})}),wB=H({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Qt(e,o,r=>re(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>eo("fieldset",{children:[ce("legend",{children:u("labels.strokeStyle")}),ce("div",{className:"buttonList",children:ce(Bo,{group:"strokeStyle",options:[{value:"solid",text:u("labels.strokeStyle_solid"),icon:Om},{value:"dashed",text:u("labels.strokeStyle_dashed"),icon:Ag},{value:"dotted",text:u("labels.strokeStyle_dotted"),icon:_g}],value:Xt(e,r,a=>a.strokeStyle,a=>a.hasOwnProperty("strokeStyle"),a=>a?null:o.currentItemStrokeStyle),onChange:a=>t(a)})})]})}),wv=H({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Qt(e,o,r=>re(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>ce(hv,{updateData:o,app:e,testId:"opacity"})}),Tv=H({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>c1(e,o,r,()=>(je(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{isCompact:a}=cl(r);return eo("fieldset",{children:[ce("legend",{children:u("labels.fontSize")}),ce("div",{className:"buttonList",children:ce(Bo,{group:"font-size",options:[{value:ua.sm,text:u("labels.small"),icon:$g,testId:"fontSize-small"},{value:ua.md,text:u("labels.medium"),icon:jg,testId:"fontSize-medium"},{value:ua.lg,text:u("labels.large"),icon:qg,testId:"fontSize-large"},{value:ua.xl,text:u("labels.veryLarge"),icon:Jg,testId:"fontSize-veryLarge"}],value:Xt(e,r,i=>{if($(i))return i.fontSize;let l=xe(i,r.scene.getNonDeletedElementsMap());return l?l.fontSize:null},i=>$(i)||xe(i,r.scene.getNonDeletedElementsMap())!==null,i=>i?null:o.currentItemFontSize||ha),onChange:i=>{$s(()=>t(i),a,!!o.editingTextElement,n?.onPreventClose)}})})]})}}),d1=H({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Hn,trackEvent:!1,perform:(e,o,t,r)=>c1(e,o,r,n=>Math.round(1/(1+fv)*n.fontSize)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_LEFT||e.key===T.COMMA)}),m1=H({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Hn,trackEvent:!1,perform:(e,o,t,r)=>c1(e,o,r,n=>Math.round(n.fontSize*(1+fv))),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_RIGHT||e.key===T.PERIOD)}),Cv=H({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:a,resetContainers:i,...l}=t;if(a)return{elements:Qt(e,o,f=>{let E=n?.get(f.id);return E?re(f,{...E}):f},!0),appState:{...o,...l},captureUpdate:D.NEVER};je(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=D.EVENTUALLY,p,d=!1;if(s)p=s,m=D.IMMEDIATELY;else if(c){p=c,m=D.EVENTUALLY;let b=ae(e,o,{includeBoundTextElement:!0}).filter(f=>$(f));if(b.length>200)d=!0;else{let f=0,E=0;for(;f<b.length&&E<5e3;){let v=b[f];E+=v?.originalText.length||0,f++}E>5e3&&(d=!0)}}let h={appState:{...o,...l},captureUpdate:m};if(p&&!d){let b=new Map,f=new Set,E=!1,v=Array.from(Nn.loadedFontsCache.values()),x=Object.entries(It).find(([C,S])=>S===p)?.[0];c&&x&&v.some(C=>C.startsWith(x))&&(E=!0),Object.assign(h,{elements:Qt(e,o,C=>{if($(C)&&(C.fontFamily!==p||s)){let S=re(C,{fontFamily:p,lineHeight:qr(p)}),A=n?.get(C.containerId||"")||{},M=r.scene.getContainerElement(C);return i&&M&&A&&r.scene.mutateElement(M,{...A}),E||(f=new Set([...f,...Array.from(S.originalText)])),b.set(S,M),S}return C},!0)});let y=`10px ${ya({fontFamily:p})}`,w=Array.from(f.values()).join();if(E||window.document.fonts.check(y,w))for(let[C,S]of b)ut(C,S,r.scene);else window.document.fonts.load(y,w).then(C=>{for(let[S,A]of b){let M=r.scene.getElement(S.id),N=A?r.scene.getElement(A.id):null;M&&ut(M,N,r.scene)}r.fonts.onLoaded(C)})}return h},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=s1(new Map),a=s1(null),[i,l]=h4({}),s=s1(!0),{stylesPanelMode:c,isCompact:m}=cl(t),p=u4(()=>{let d=(h,b)=>Xt(h,t,f=>{if($(f))return f.fontFamily;let E=xe(f,b);return E?E.fontFamily:null},f=>$(f)||xe(f,b)!==null,f=>f?null:o.currentItemFontFamily||xi);return i.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(n.current?.values()??[]),n.current):!i.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):a.current},[i.openPopup,o,e,t]);return l1(()=>{a.current=p},[p]),l1(()=>{Object.keys(i).length&&(r(i),l({}))},[i]),l1(()=>(s.current=!1,()=>{s.current=!0}),[]),eo(p1,{children:[c==="full"&&ce("legend",{children:u("labels.fontFamily")}),ce(cv,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{$s(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),n.current.clear()},m,!!o.editingTextElement)},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:d=>{if(d){n.current.clear();let{editingTextElement:h}=o;if(h?.type==="text"){let b=t.scene.getElement(h.id);n.current.set(h.id,re(b||h,{},!0))}else{let b=ae(e,o,{includeBoundTextElement:!0});for(let f of b)n.current.set(f.id,re(f,{},!0))}l({...i,openPopup:"fontFamily"})}else{let h={currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};l({...h}),n.current.clear(),m&&o.editingTextElement&&Xs(null)}}})]})}}),Iv=H({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Qt(e,o,n=>{if($(n)){let a=re(n,{textAlign:t});return ut(a,r.scene.getContainerElement(n),r.scene),a}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let a=r.scene.getNonDeletedElementsMap(),{isCompact:i}=cl(r);return eo("fieldset",{children:[ce("legend",{children:u("labels.textAlign")}),ce("div",{className:"buttonList",children:ce(Bo,{group:"text-align",options:[{value:"left",text:u("labels.left"),icon:ef,testId:"align-left"},{value:"center",text:u("labels.center"),icon:tf,testId:"align-horizontal-center"},{value:"right",text:u("labels.right"),icon:of,testId:"align-right"}],value:Xt(e,r,l=>{if($(l))return l.textAlign;let s=xe(l,a);return s?s.textAlign:null},l=>$(l)||xe(l,a)!==null,l=>l?null:o.currentItemTextAlign),onChange:l=>{$s(()=>t(l),i,!!o.editingTextElement,n?.onPreventClose)}})})]})}}),kv=H({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Qt(e,o,n=>{if($(n)){let a=re(n,{verticalAlign:t});return ut(a,r.scene.getContainerElement(n),r.scene),a}return n},!0),appState:{...o},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,data:n})=>{let{isCompact:a}=cl(r);return ce("fieldset",{children:ce("div",{className:"buttonList",children:ce(Bo,{group:"text-align",options:[{value:Ao.TOP,text:u("labels.alignTop"),icon:ce(rf,{theme:o.theme}),testId:"align-top"},{value:Ao.MIDDLE,text:u("labels.centerVertically"),icon:ce(af,{theme:o.theme}),testId:"align-middle"},{value:Ao.BOTTOM,text:u("labels.alignBottom"),icon:ce(nf,{theme:o.theme}),testId:"align-bottom"}],value:Xt(e,r,i=>{if($(i)&&i.containerId)return i.verticalAlign;let l=xe(i,r.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},i=>$(i)||xe(i,r.scene.getNonDeletedElementsMap())!==null,i=>i?null:Ao.MIDDLE),onChange:i=>{$s(()=>t(i),a,!!o.editingTextElement,n?.onPreventClose)}})})})}}),TB=H({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Qt(e,o,r=>Se(r)?r:re(r,{roundness:t==="round"?{type:_n(r.type)?Lt.ADAPTIVE_RADIUS:Lt.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let i=_i(ve(e),o).some(l=>l.roundness?.type===Lt.LEGACY);return eo("fieldset",{children:[ce("legend",{children:u("labels.edges")}),eo("div",{className:"buttonList",children:[ce(Bo,{group:"edges",options:[{value:"sharp",text:u("labels.sharp"),icon:Ng},{value:"round",text:u("labels.round"),icon:Og}],value:Xt(e,r,l=>i?null:l.roundness?"round":"sharp",l=>!Me(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),gv=e=>[{value:null,text:u("labels.arrowhead_none"),keyBinding:"q",icon:zg},{value:"arrow",text:u("labels.arrowhead_arrow"),keyBinding:"w",icon:ce(Bg,{flip:e})},{value:"triangle",text:u("labels.arrowhead_triangle"),icon:ce(Gg,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:u("labels.arrowhead_triangle_outline"),icon:ce(Wg,{flip:e}),keyBinding:"r"},{value:"circle",text:u("labels.arrowhead_circle"),keyBinding:"a",icon:ce(Fg,{flip:e})},{value:"circle_outline",text:u("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ce(Hg,{flip:e})},{value:"diamond",text:u("labels.arrowhead_diamond"),icon:ce(Yg,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:u("labels.arrowhead_diamond_outline"),icon:ce(Vg,{flip:e}),keyBinding:"f"},{value:"bar",text:u("labels.arrowhead_bar"),keyBinding:"z",icon:ce(Ug,{flip:e})},{value:"crowfoot_one",text:u("labels.arrowhead_crowfoot_one"),icon:ce(Zg,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:u("labels.arrowhead_crowfoot_many"),icon:ce(Kg,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:u("labels.arrowhead_crowfoot_one_or_many"),icon:ce(Xg,{flip:e}),keyBinding:"v"}],CB=H({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(je(t,"actionChangeArrowhead: value must be defined"),{elements:Qt(e,o,r=>{if(ge(r)){let{position:n,type:a}=t;if(n==="start")return re(r,{startArrowhead:a});if(n==="end")return re(r,{endArrowhead:a})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=an().rtl;return eo("fieldset",{children:[ce("legend",{children:u("labels.arrowheads")}),eo("div",{className:"iconSelectList buttonList",children:[ce(a1,{label:"arrowhead_start",options:gv(!n),value:Xt(e,r,a=>ge(a)&&Di(a.type)?a.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:a=>t({position:"start",type:a}),numberOfOptionsToAlwaysShow:4}),ce(a1,{label:"arrowhead_end",group:"arrowheads",options:gv(!!n),value:Xt(e,r,a=>ge(a)&&Di(a.type)?a.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:a=>t({position:"end",type:a}),numberOfOptionsToAlwaysShow:4})]})]})}}),Sv=H({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,r)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>eo("div",{className:"selected-shape-actions",children:[n("changeArrowhead"),n("changeArrowType")]})}),IB=H({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Qt(e,o,l=>{if(!Me(l))return l;let s=r.scene.getNonDeletedElementsMap(),c=X.getPointAtIndexGlobalCoordinates(l,0,s),m=X.getPointAtIndexGlobalCoordinates(l,-1,s),p=re(l,{x:t===pt.elbow?c[0]:l.x,y:t===pt.elbow?c[1]:l.y,roundness:t===pt.round?{type:Lt.PROPORTIONAL_RADIUS}:null,elbowed:t===pt.elbow,angle:t===pt.elbow?0:l.angle,points:t===pt.elbow||l.elbowed?[X.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},c,s),X.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},m,s)]:l.points});if(Se(p)){p.fixedSegments=null;let d=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let h=X.getPointAtIndexGlobalCoordinates(p,0,d),b=X.getPointAtIndexGlobalCoordinates(p,-1,d),f=p.startBinding&&d.get(p.startBinding.elementId),E=p.endBinding&&d.get(p.endBinding.elementId),v=f&&p.startBinding?{...p.startBinding,...Eh(p,f,"start",d)}:null,x=E&&p.endBinding?{...p.endBinding,...Eh(p,E,"end",d)}:null;p={...p,startBinding:v,endBinding:x,...Fd(p,d,{points:[h,b].map(y=>L(y[0]-p.x,y[1]-p.y)),startBinding:v,endBinding:x,fixedSegments:null})}}else{let d=r.scene.getNonDeletedElementsMap();if(p.startBinding){let h=d.get(p.startBinding.elementId);h&&xh(p,h,o.bindMode==="inside"?"inside":"orbit","start",r.scene)}if(p.endBinding){let h=d.get(p.endBinding.elementId);h&&xh(p,h,o.bindMode==="inside"?"inside":"orbit","end",r.scene)}}return p}),a={...o,currentItemArrowType:t},i=o.selectedLinearElement?.elementId;if(i){let l=n.find(s=>s.id===i);l&&(a.selectedLinearElement=new X(l,ie(e)))}return{elements:n,appState:a,captureUpdate:D.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>eo("fieldset",{children:[ce("legend",{children:u("labels.arrowtypes")}),ce("div",{className:"buttonList",children:ce(Bo,{group:"arrowtypes",options:[{value:pt.sharp,text:u("labels.arrowtype_sharp"),icon:Va,testId:"sharp-arrow"},{value:pt.round,text:u("labels.arrowtype_round"),icon:Za,testId:"round-arrow"},{value:pt.elbow,text:u("labels.arrowtype_elbowed"),icon:Ka,testId:"elbow-arrow"}],value:Xt(e,r,n=>Me(n)?n.elbowed?pt.elbow:n.roundness?pt.round:pt.sharp:null,n=>Me(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{useEffect as f4}from"react";import{jsx as x4}from"react/jsx-runtime";var dl=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},u1=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,a=window.innerHeight,i=5,l=o.left+o.width/2-r.width/2;l<0?l=i:l+r.width>=n&&(l=n-r.width-i);let s;t==="bottom"?(s=o.top+o.height+i,s+r.height>=a&&(s=o.top-r.height-i)):(s=o.top-r.height-i,s<0&&(s=o.top+o.height+i)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},b4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();u1(o,n)},To=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(f4(()=>()=>dl().classList.remove("excalidraw-tooltip--visible"),[]),n?null:x4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:a=>b4(a.currentTarget,dl(),o,t),onPointerLeave:()=>dl().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));var Lv='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',y4='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',Av='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',E4=`data:${ue.svg},${encodeURIComponent(`${Lv}${Av}</svg>`)}`,v4=`data:${ue.svg},${encodeURIComponent(`${Lv}${y4}${Av}</svg>`)}`,Co=e=>{e&&(e.style.cursor="")},He=(e,o)=>{e&&(e.style.cursor=o)},Pr,Mv,h1=(e,o)=>{let r=()=>{let n=o===ne.DARK;Pr=document.createElement("canvas"),Pr.theme=o,Pr.height=20,Pr.width=20;let a=Pr.getContext("2d");a.lineWidth=1,a.beginPath(),a.arc(Pr.width/2,Pr.height/2,5,0,2*Math.PI),a.fillStyle=n?"#000":"#fff",a.fill(),a.strokeStyle=n?"#fff":"#000",a.stroke(),Mv=Pr.toDataURL(ue.svg)};(!Pr||Pr.theme!==o)&&r(),He(e,`url(${Mv}) ${20/2} ${20/2}, auto`)},Uo=(e,o)=>{if(e)if(o.activeTool.type==="selection")Co(e);else if(ir(o))e.style.cursor=Pe.GRAB;else if(po(o))h1(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===ne.LIGHT?E4:v4;e.style.cursor=`url(${t}), auto`}else if(!["image","custom"].includes(o.activeTool.type))e.style.cursor=Pe.CROSSHAIR;else if(o.activeTool.type==="custom"&&o.activeTool.customType==="comment"){let t=`data:${ue.svg},${encodeURIComponent(`
|
|
1
|
+
import{$ as Js,$a as Co,$b as ic,$c as re,$d as xv,$e as Nv,$f as qm,$g as fl,$h as $M,A as js,Aa as el,Ab as ge,Ac as il,Ad as lc,Ae as kv,Af as Wv,Ag as dw,Ah as _f,Ai as o2,B as Ja,Ba as cy,Bb as I,Bc as _e,Bd as av,Be as ui,Bf as Tc,Bg as mw,Bh as Pf,C as qE,Ca as Gr,Cb as vm,Cc as Ky,Cd as Rm,Ce as pa,Cf as Ym,Cg as pw,Ch as Df,Ci as r2,D as cm,Da as ec,Db as ni,Dc as Xy,Dd as lv,De as xc,Df as hl,Dg as uw,Dh as Yw,E as JE,Ea as gn,Eb as of,Ec as af,Ed as sc,Ee as Mv,Ef as Km,Eg as hw,Eh as xl,Ei as n2,F as Ug,Fa as ao,Fb as rl,Fc as km,Fd as sv,Fe as Ec,Ff as Vv,Fg as KM,Fh as Sc,Fi as i2,G as QE,Ga as bm,Gb as ii,Gc as qo,Gd as cv,Ge as yc,Gf as Kr,Gg as Sn,Gh as Rf,Gi as dp,H as Gg,Ha as ht,Hb as Ly,Hc as lf,Hd as lt,He as uf,Hf as Xr,Hg as Mr,Hh as Kw,Hi as a2,I as Fe,Ia as oi,Ib as Qt,Ic as En,Id as cl,Ie as ko,If as Yv,Ig as N,Ih as Xw,Ii as Gf,J as Xo,Ja as dy,Jb as rf,Jc as So,Jd as dv,Je as hi,Jf as yf,Jg as gw,Jh as XM,Ji as Wf,K as ta,Ka as tc,Kb as Vt,Kc as Sr,Kd as mv,Ke as Av,Kf as Kv,Kg as fw,Kh as Nf,Ki as mp,L as qs,La as To,Lb as _y,Lc as Mm,Ld as cc,Le as hf,Lf as vf,Lg as Ic,Lh as Of,Li as l2,M as et,Ma as gt,Mb as nf,Mc as Am,Md as dc,Me as gf,Mf as Xv,Mg as bw,Mh as or,Mi as Vf,N as $o,Na as my,Nb as Py,Nc as Jo,Nd as pv,Ne as zm,Nf as Xm,Ng as Sf,Nh as de,Ni as Ea,O as ct,Oa as py,Ob as lo,Oc as $y,Od as VM,Oe as ff,Of as $m,Og as xw,Oh as Bf,Oi as s2,P as J,Pa as qg,Pb as la,Pc as Zy,Pd as uv,Pe as Lv,Pf as $v,Pg as Ew,Ph as Zr,Pi as Yf,Q as tt,Qa as ri,Qb as dt,Qc as sf,Qd as hv,Qe as Z,Qf as Zv,Qg as yw,Qh as xi,Qi as c2,R as Qn,Ra as fn,Rb as Dy,Rc as jy,Rd as wn,Re as _v,Rf as jv,Rg as vw,Rh as ba,Ri as d2,S as Qa,Sa as uy,Sb as xn,Sc as yn,Sd as gv,Se as kt,Sf as qv,Sg as kf,Sh as El,Si as pp,T as dm,Ta as hy,Tb as rc,Tc as qy,Td as St,Te as Hm,Tf as Jv,Tg as ep,Th as Ei,Ti as Kf,U as Wg,Ua as Jt,Ub as jo,Uc as si,Ud as fv,Ue as kr,Uf as tr,Ug as tp,Uh as Zw,Ui as m2,V as oa,Va as gy,Vb as Ry,Vc as ot,Vd as di,Ve as ua,Vf as Zm,Vg as op,Vh as yl,Vi as p2,W as Ho,Wa as fy,Wb as sa,Wc as so,Wd as mc,We as Pv,Wf as Qv,Wg as ga,Wh as jw,Wi as u2,X as ra,Xa as ia,Xb as nc,Xc as ca,Xd as ve,Xe as ml,Xf as Yt,Xg as ww,Xh as zf,Xi as Dc,Y as Vg,Ya as by,Yb as ft,Yc as al,Yd as Vr,Ye as He,Yf as jm,Yg as Mf,Yh as jr,Z as ey,Za as xy,Zb as ze,Zc as ee,Zd as Nm,Ze as Dv,Zf as fi,Zg as fa,Zh as kn,_ as Yg,_a as xm,_b as Ft,_c as Lm,_d as bv,_e as Rv,_f as we,_g as Tw,_h as Mn,a as KE,aa as pe,ab as tl,ac as Ny,ad as ll,ae as Ev,af as bf,ag as In,ah as Cw,ai as ZM,b as qe,ba as ty,bb as ol,bc as wm,bd as Se,be as mf,bf as Um,bg as wf,bh as Iw,bi as rr,c as Ur,ca as mm,cb as Em,cc as Tm,cd as at,ce as dl,cf as gi,cg as ew,ch as Sw,ci as kc,d as Rg,da as ei,db as ym,dc as Cm,dd as Te,de as pc,df as Gm,dg as gl,dh as kw,di as vl,e as ja,ea as oy,eb as Ey,ec as Oy,ed as Re,ee as Om,ef as Ov,eg as Tf,eh as Mw,ei as ip,f as qa,fa as ry,fb as Jg,fc as Fy,fd as _m,fe as uc,ff as Fv,fg as YM,fh as Aw,fi as Hf,g as Ng,ga as Kg,gb as yy,gc as By,gd as Jy,ge as mi,gf as xf,gg as ha,gh as Lw,gi as Mc,h as am,ha as ny,hb as vy,hc as zy,hd as zt,he as hc,hf as Ge,hg as $r,hh as _w,hi as ap,i as Og,ia as iy,ib as Qg,ic as Hy,id as Qy,ie as yv,if as ae,ig as Cc,ih as Pw,ii as Uf,j as Fg,ja as Qs,jb as Uo,jc as ie,jd as da,je as pf,jf as pl,jg as Jm,jh as Dw,ji as jM,k as Bg,ka as pm,kb as oc,kc as Uy,kd as vn,ke as vv,kf as Be,kg as tw,kh as Rw,ki as qw,l as _,la as ay,lb as Cr,lc as Wr,ld as sl,le as wv,lf as vc,lg as ow,lh as Nw,li as Jw,m as XE,ma as ly,mb as wy,mc as Bt,md as Pm,me as Tv,mf as wc,mg as Ao,mh as Ow,mi as lp,n as ke,na as um,nb as ho,nc as Gy,nd as Ht,ne as gc,nf as Bv,ng as Cf,nh as Fw,ni as Ac,o as Ko,oa as hm,ob as Ty,oc as Im,od as mt,oe as Cv,of as Wm,og as rw,oh as Af,oi as sp,p as zg,pa as Xg,pb as Io,pc as nl,pd as ev,pe as pi,pf as Yr,pg as Qm,ph as Lf,pi as cp,q as $E,qa as gm,qb as Cy,qc as Wy,qd as ci,qe as Fm,qf as ul,qg as If,qh as Bw,qi as Lc,r as ZE,ra as ti,rb as bn,rc as ai,rd as tv,re as Iv,rf as Vm,rg as nw,rh as zw,ri as Qw,s as lm,sa as na,sb as Iy,sc as ac,sd as ov,se as Sv,sf as Ef,sg as eo,sh as Hw,si as e2,t as zo,ta as $g,tb as Sy,tc as Lt,td as ma,te as Qo,tf as zv,tg as iw,th as Uw,ti as t2,u as $s,ua as sy,ub as ky,uc as li,ud as cf,ue as fc,uf as er,ug as aw,uh as bl,ui as qM,v as Zs,va as fm,vb as ef,vc as Vy,vd as rv,ve as bc,vf as Hv,vg as to,vh as Gw,vi as wl,w as ea,wa as Zg,wb as aa,wc as it,wd as nv,we as Bm,wf as Uv,wg as bi,wh as rp,wi as _c,x as jE,xa as Zo,xb as tf,xc as Yy,xd as df,xe as co,xf as Mo,xg as lw,xh as Ww,xi as Pc,y as Hg,ya as jg,yb as My,yc as Sm,yd as iv,ye as se,yf as Gv,yg as sw,yh as Vw,yi as Tl,z as sm,za as At,zb as Ay,zc as Ir,zd as Dm,ze as Tn,zf as Cn,zg as cw,zh as np,zi as xa}from"./chunk-6XMTGF46.js";import{a as k}from"./chunk-FUN3GFKR.js";import{O as Ff}from"./chunk-7L3NUBYQ.js";import{c as $w}from"./chunk-5XKZK2GL.js";import{b as YE,c as Dg,d as C}from"./chunk-SRAX5OIU.js";import xO,{useCallback as EO,useContext as yO,useEffect as vO,useRef as wO,useState as TO}from"react";import IM from"clsx";import G9 from"lodash.throttle";import yr,{useContext as jn}from"react";import{flushSync as Bo}from"react-dom";import W9 from"roughjs/bin/rough";import{nanoid as V9}from"nanoid";var xS={};Dg(xS,{actionAddToLibrary:()=>Uu,actionAlignBottom:()=>EC,actionAlignHorizontallyCentered:()=>TC,actionAlignLeft:()=>yC,actionAlignRight:()=>vC,actionAlignTop:()=>xC,actionAlignVerticallyCentered:()=>wC,actionBindText:()=>Yu,actionBringForward:()=>Kp,actionBringToFront:()=>$p,actionChangeArrowProperties:()=>RT,actionChangeBackgroundColor:()=>CT,actionChangeBucketFillBackgroundColor:()=>ad,actionChangeExportBackground:()=>Du,actionChangeFillStyle:()=>IT,actionChangeFontFamily:()=>_T,actionChangeFontSize:()=>LT,actionChangeFreedrawMode:()=>MT,actionChangeOpacity:()=>AT,actionChangeProjectName:()=>Pu,actionChangeSloppiness:()=>kT,actionChangeStrokeColor:()=>TT,actionChangeStrokeWidth:()=>ST,actionChangeTextAlign:()=>PT,actionChangeVerticalAlign:()=>DT,actionChangeViewBackgroundColor:()=>FT,actionClearCanvas:()=>nn,actionCopy:()=>Ra,actionCopyAsPng:()=>gd,actionCopyAsSvg:()=>hd,actionCopyStyles:()=>Nu,actionCut:()=>ud,actionDeleteSelected:()=>Nl,actionDeselect:()=>jT,actionDuplicateSelection:()=>qp,actionFinalize:()=>Gt,actionFlipHorizontal:()=>Gu,actionFlipVertical:()=>Wu,actionGoToCollaborator:()=>bC,actionGroup:()=>Fu,actionLink:()=>os,actionLoadScene:()=>Pa,actionPasteStyles:()=>Ou,actionResetZoom:()=>cd,actionSaveFileToDisk:()=>$l,actionSaveToActiveFile:()=>Di,actionSelectAll:()=>jp,actionSendBackward:()=>Yp,actionSendToBack:()=>Xp,actionShortcuts:()=>Ri,actionToggleArrowBinding:()=>Ql,actionToggleCropEditor:()=>bh,actionToggleElementLock:()=>rs,actionToggleGridMode:()=>Na,actionToggleLinearEditor:()=>Ba,actionToggleMidpointSnapping:()=>es,actionToggleObjectsSnapMode:()=>Jl,actionToggleSearchMenu:()=>gs,actionToggleStats:()=>Hn,actionToggleTheme:()=>Bn,actionToggleZenMode:()=>zn,actionUnbindText:()=>Vu,actionUngroup:()=>Bu,actionZoomIn:()=>ld,actionZoomOut:()=>sd,actionZoomToFit:()=>BT,copyText:()=>fd,distributeHorizontally:()=>SC,distributeVertically:()=>kC});import{atom as Ce,createStore as JM}from"jotai";import{createIsolation as QM}from"jotai-scope";var h2=QM();var{useAtom:ne,useSetAtom:qr,useAtomValue:Cl,useStore:AO}=h2,g2=h2.Provider,bt=JM();var e6=YE({"./locales/ar-SA.json":()=>import("./locales/ar-SA-5WIASEJP.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-V5EUQD6C.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-EXASCMTR.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-U4SYNFCO.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-HKDJIITE.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-2KGUU5XB.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-VUCGPRML.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-NNDP2IVP.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-I7RAVIZN.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-WBQ3DQLR.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-TYQHVGXW.js"),"./locales/en.json":()=>import("./locales/en-E6R7JWZO.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-JEUOREKJ.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-SO5DEEAN.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-FIYUE2GQ.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-REAEF6HQ.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-SUCL7J6B.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-KHCSOGVH.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-JYXVXV2Q.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-BU52H3BO.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-OWADXDQ3.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-EOMR5R3I.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-FC2VTM3L.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-JBNTKYP4.js"),"./locales/kaa.json":()=>import("./locales/kaa-TC3VIB7V.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-UOUDSQKM.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5H2X7YS.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-IHMV2US7.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-ZTMANIDF.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-GPJTRB5G.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-V3XDOK3P.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-DVQ3FADO.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-VZ6HH5FE.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-XYKWHRK6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-UNO2GGZJ.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-76EFHT4P.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-CFKD7ABE.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-YBJTCJ3J.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-SNOXSMRV.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-BSY6YFZ3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-CZDV62R3.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-JO57XJJW.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-UZ5ICYYN.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-AN7JPREC.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-7CBLD6QQ.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-SWR6DKBI.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-JRML4FIH.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-4ZPKFFXF.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-V6NHHU6Z.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-P7CTMGDK.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-GUFYG22B.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-K6SV5NFQ.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-TVKTZO2G.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-7FKFXJNO.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-AOKVLNNK.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-CDKPF5DC.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-ZVGYESGW.js")});var t6=85,Jr={code:"en",label:"English"},Sl=[Jr,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>$w[e.code]>=t6).sort((e,t)=>e.label>t.label?1:-1)],hp="__test__";Bt()&&Sl.unshift({code:hp,label:"test language"},{code:`${hp}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Il=Jr,up={},gp=async e=>{if(Il=e,document.documentElement.dir=Il.rtl?"rtl":"ltr",document.documentElement.lang=Il.code,e.code.startsWith(hp))up={};else try{up=await e6(`./locales/${Il.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),up=Ff}bt.set(b2,e.code)},Qr=()=>Il,f2=(e,t)=>{for(let o=0;o<t.length;++o){let r=t[o];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},h=(e,t,o)=>{if(Il.code.startsWith(hp))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=f2(up,r)||f2(Ff,r)||o;if(n===void 0){let i=`Can't find translation for ${e}`;if(k.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)n=n.replace(`{{${i}}}`,String(t[i]));return n},b2=Ce(Jr.code),Ue=()=>{let e=Cl(b2);return{t:h,langCode:e}};var v2={};Dg(v2,{AlignBottomIcon:()=>Mp,AlignLeftIcon:()=>Ap,AlignRightIcon:()=>Lp,AlignTopIcon:()=>kp,ArrowIcon:()=>tb,ArrowRightIcon:()=>_n,ArrowheadArrowIcon:()=>Rb,ArrowheadBarIcon:()=>Ub,ArrowheadCardinalityExactlyOneIcon:()=>Yb,ArrowheadCardinalityManyIcon:()=>Wb,ArrowheadCardinalityOneIcon:()=>Gb,ArrowheadCardinalityOneOrManyIcon:()=>Vb,ArrowheadCardinalityZeroOrManyIcon:()=>Xb,ArrowheadCardinalityZeroOrOneIcon:()=>Kb,ArrowheadCircleIcon:()=>Fb,ArrowheadCircleOutlineIcon:()=>Bb,ArrowheadDiamondIcon:()=>zb,ArrowheadDiamondOutlineIcon:()=>Hb,ArrowheadNoneIcon:()=>Db,ArrowheadTriangleIcon:()=>Nb,ArrowheadTriangleOutlineIcon:()=>Ob,BringForwardIcon:()=>Tp,BringToFrontIcon:()=>Ip,CenterHorizontallyIcon:()=>Pp,CenterVerticallyIcon:()=>_p,CloseIcon:()=>Go,DeviceDesktopIcon:()=>A1,DiamondIcon:()=>Oc,DiscordIcon:()=>sb,DistributeHorizontallyIcon:()=>bb,DistributeVerticallyIcon:()=>xb,DotsHorizontalIcon:()=>$f,DotsIcon:()=>yi,DuplicateIcon:()=>Al,EdgeRoundIcon:()=>Pb,EdgeSharpIcon:()=>_b,EllipseIcon:()=>Fc,EmbedIcon:()=>Ln,EraserIcon:()=>nb,ExcalLogo:()=>n6,ExportIcon:()=>wi,ExportImageIcon:()=>Hc,ExternalLinkIcon:()=>Ep,FillCrossHatchIcon:()=>wb,FillHachureIcon:()=>vb,FillSolidIcon:()=>Tb,FillZigZagIcon:()=>yb,FontFamilyCodeIcon:()=>Gc,FontFamilyHeadingIcon:()=>Jb,FontFamilyNormalIcon:()=>Dl,FontSizeExtraLargeIcon:()=>qb,FontSizeLargeIcon:()=>jb,FontSizeMediumIcon:()=>Zb,FontSizeSmallIcon:()=>$b,FreedrawIcon:()=>An,GithubIcon:()=>Bc,GroupIcon:()=>Dp,HamburgerMenuIcon:()=>ab,HelpIcon:()=>wa,HelpIconThin:()=>lb,HomeIcon:()=>r6,ImageIcon:()=>Ml,LassoIcon:()=>kl,LibraryIcon:()=>Rc,LineIcon:()=>va,LinkIcon:()=>Pl,LoadIcon:()=>Ta,LockedIcon:()=>ya,LockedIconFilled:()=>jf,MagicIcon:()=>Ii,MagicIconThin:()=>T6,MoonIcon:()=>Ll,OpenAIIcon:()=>C6,PenModeIcon:()=>ob,PinIcon:()=>Zf,PlusIcon:()=>Xf,RectangleIcon:()=>Nc,RedoIcon:()=>wp,RetryIcon:()=>m1,SelectionIcon:()=>eb,SendBackwardIcon:()=>Cp,SendToBackIcon:()=>Sp,SloppinessArchitectIcon:()=>Mb,SloppinessArtistIcon:()=>Ab,SloppinessCartoonistIcon:()=>Lb,StrokeStyleDashedIcon:()=>Sb,StrokeStyleDottedIcon:()=>kb,StrokeStyleSolidIcon:()=>E6,StrokeWidthBaseIcon:()=>Np,StrokeWidthBoldIcon:()=>Cb,StrokeWidthExtraBoldIcon:()=>Ib,SunIcon:()=>_l,TextAlignBottomIcon:()=>r1,TextAlignCenterIcon:()=>e1,TextAlignLeftIcon:()=>Qb,TextAlignMiddleIcon:()=>n1,TextAlignRightIcon:()=>t1,TextAlignTopIcon:()=>o1,TextIcon:()=>en,TextSizeIcon:()=>rb,TrashIcon:()=>Kt,UndoIcon:()=>vp,UngroupIcon:()=>Rp,UnlockedIcon:()=>vi,WelcomeScreenHelpArrow:()=>Jf,WelcomeScreenMenuArrow:()=>qf,WelcomeScreenTopToolbarArrow:()=>Qf,XBrandIcon:()=>cb,ZoomInIcon:()=>bp,ZoomOutIcon:()=>xp,ZoomResetIcon:()=>ib,abacusIcon:()=>w1,adjustmentsIcon:()=>N1,alertTriangleIcon:()=>Vc,angleIcon:()=>Wc,boltIcon:()=>Rl,brainIcon:()=>g1,brainIconThin:()=>f1,bucketFillIcon:()=>fo,bucketFillIconSvgPaths:()=>yp,checkIcon:()=>zc,chevronDownIcon:()=>z1,chevronLeftIcon:()=>k6,chevronRight:()=>H1,clipboard:()=>i6,clone:()=>f6,codeIcon:()=>Bp,coffeeIcon:()=>M1,collapseDownIcon:()=>Kc,collapseUpIcon:()=>D1,copyIcon:()=>Ca,createIcon:()=>R,cropIcon:()=>Gp,cutIcon:()=>l1,done:()=>hb,downloadIcon:()=>zp,drawShapeToolIcon:()=>Ci,elbowArrowIcon:()=>Dn,elementLinkIcon:()=>Xc,emptyIcon:()=>$c,eraser:()=>y6,exportToFileIcon:()=>ub,exportToPlus:()=>p6,eyeClosedIcon:()=>h1,eyeDropperIcon:()=>d1,eyeDropperIconSvgPaths:()=>Hp,eyeIcon:()=>Sa,file:()=>x6,flipHorizontal:()=>C1,flipVertical:()=>T1,fontSizeIcon:()=>Ti,frameToolIcon:()=>Ar,fullscreenIcon:()=>u1,gridIcon:()=>_1,handIcon:()=>a1,helpIcon:()=>s1,historyCommandIcon:()=>b1,historyIcon:()=>x1,iconFillColor:()=>nr,laserPointerToolIcon:()=>Lr,lineEditorIcon:()=>P1,loginIcon:()=>I6,magnetIcon:()=>k1,menu:()=>c6,mermaidLogoIcon:()=>Ia,messageCircleIcon:()=>M6,microphoneIcon:()=>E1,microphoneMutedIcon:()=>y1,paintIcon:()=>Up,palette:()=>a6,pencilIcon:()=>F1,playerPlayIcon:()=>v6,playerStopFilledIcon:()=>w6,pngIcon:()=>S1,polygonIcon:()=>fp,presentationIcon:()=>A6,publishIcon:()=>i1,questionCircle:()=>gb,resetZoom:()=>h6,resizeIcon:()=>S6,roundArrowIcon:()=>Rn,save:()=>db,saveAs:()=>mb,searchIcon:()=>Lo,selectAllIcon:()=>v1,settingsIcon:()=>U1,share:()=>fb,shareIOS:()=>m6,shareWindows:()=>u6,sharpArrowIcon:()=>Pn,shield:()=>b6,sidebarRightIcon:()=>B1,slashIcon:()=>pb,stackPushIcon:()=>p1,start:()=>g6,stop:()=>Eb,strokeIcon:()=>O1,strokeVariabilityConstantIcon:()=>Op,strokeVariabilityVariableIcon:()=>Fp,svgIcon:()=>I1,tablerCheckIcon:()=>c1,upIcon:()=>R1,usersIcon:()=>Uc,warning:()=>d6,youtubeIcon:()=>L1,zoomAreaIcon:()=>Yc,zoomIn:()=>l6,zoomOut:()=>s6});import o6 from"clsx";import _t from"react";import{Fragment as Ke,jsx as g,jsxs as z}from"react/jsx-runtime";var nr=e=>"var(--icon-fill-color)",x2=e=>e===J.LIGHT?"#fff":"#1e1e1e",R=(e,t=512)=>{let{width:o=512,height:r=o,mirror:n,style:i,...l}=typeof t=="number"?{width:t}:t;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${o} ${r}`,className:o6({"rtl-mirror":n}),style:i,...l,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},Y={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},xe={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},go={width:40,height:20},r6=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("polyline",{points:"5 12 3 12 12 3 21 12 19 12"}),g("path",{d:"M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7"}),g("path",{d:"M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"})]}),Y),Rc=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),Y),Xf=R(z("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),Y),yi=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),Y),$f=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),g("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),g("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),Y),Zf=R(z("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),Y),fp=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M6.5 9.5l3.5 -3"}),g("path",{d:"M14 5.5l3 1.5"}),g("path",{d:"M18.5 10l-2.5 7"}),g("path",{d:"M13.5 17.5l-7 -5"})]}),Y),vi=R(z("g",{children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),xe),ya=R(z("g",{strokeWidth:"1.25",children:[g("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),xe),jf=R(g("g",{fill:"currentColor",children:g("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),qf=R(z(Ke,{children:[g("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),Jf=R(z(Ke,{children:[g("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),Qf=R(z(Ke,{children:[g("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),n6=R(g("g",{fill:"currentColor",children:g("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"})}),{width:40,height:40,fill:"none"}),eb=R(z("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),kl=R(z("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[g("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),g("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Nc=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),Y),Oc=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),Y),Fc=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),Y),tb=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),Y),va=R(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),xe),ob=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),Y),An=R(z("g",{strokeWidth:"1.25",children:[g("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),xe),en=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),Y),rb=R(z("g",{stroke:"currentColor",strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),Y),Ml=R(z("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),xe),nb=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),Y),bp=R(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),xe),xp=R(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),xe),ib=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),g("path",{d:"M3 4v4h4"})]}),Y),Kt=R(g("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),xe),Ln=R(z("g",{strokeWidth:"1.5",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),xe),Al=R(z("g",{strokeWidth:"1.25",children:[g("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),g("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),xe),Ll=R(g("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),xe),_l=R(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...xe,strokeWidth:1.5}),ab=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),Y),wi=R(g("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),xe),wa=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),lb=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),Ep=R(g("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),xe),Bc=R(g("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),xe),sb=R(z("g",{strokeWidth:"1.25",children:[g("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),g("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),xe),cb=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),Y),zc=R(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Pl=R(z("g",{strokeWidth:"1.25",children:[g("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),g("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),xe),db=R("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),mb=R("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Ta=R(g("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),xe),i6=R("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),a6=R("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),yp=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],fo=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),yp.map(e=>g("path",{d:e},e))]}),Y),pb=R(g("g",{strokeWidth:1.5,children:g("path",{d:"M6 18l12 -12"})}),Y),Hc=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),Y),ub=R("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),l6=R("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),s6=R("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),hb=R("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),c6=R("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),vp=R(g("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),xe),wp=R(g("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),xe),gb=R("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),fb=R(g("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),xe),d6=R("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),m6=R("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),p6=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),Y),u6=R(z(Ke,{children:[g("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),g("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),h6=R(g("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),E2=z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),y2=z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),Tp=R(y2,Y),Cp=R(y2,{...Y,style:{transform:"rotate(180deg)"}}),Ip=R(E2,Y),Sp=R(E2,{...Y,style:{transform:"rotate(180deg)"}}),kp=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),Mp=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),Ap=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),Lp=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),bb=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),xb=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),_p=R(z("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),xe),Pp=R(z("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),xe),Uc=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),Y),g6=R("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),Eb=R("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Go=R(z(Ke,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),f6=R("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),b6=R("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),x6=R("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Dp=_t.memo(({theme:e})=>R(z(Ke,{children:[g("path",{d:"M25 26H111V111H25",fill:nr(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:nr(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:nr(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:nr(e),strokeWidth:"2"}),z("g",{fill:x2(e),stroke:nr(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Rp=_t.memo(({theme:e})=>R(z(Ke,{children:[g("path",{d:"M25 26H111V111H25",fill:nr(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:nr(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:nr(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:nr(e),strokeWidth:"2"}),z("g",{fill:x2(e),stroke:nr(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),yb=R(g("g",{strokeWidth:1.25,children:g("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),xe),vb=R(z(Ke,{children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),xe),wb=R(z(Ke,{children:[z("g",{clipPath:"url(#a)",children:[g("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),Tb=R(z(Ke,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...xe,fill:"currentColor"}),Np=R(g(Ke,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),xe),Cb=R(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),xe),Ib=R(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),xe),E6=_t.memo(({theme:e})=>R(g("path",{d:"M6 10H34",stroke:nr(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Sb=R(z("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),Y),kb=R(z("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),Y),Mb=R(g("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),xe),Ab=R(g("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),xe),Lb=R(g("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),xe),Op=R(z("g",{children:[g("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),Y),Fp=R(z("g",{children:[g("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),Y),_b=R(z("svg",{strokeWidth:"1.5",children:[g("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),xe),Pb=R(z("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),Y),Db=_t.memo(({flip:e=!1})=>R(z("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[g("path",{d:"M7,11 H19"}),g("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),go)),Rb=_t.memo(({flip:e=!1})=>R(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),go)),Nb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[g("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),g("path",{d:"M23,5 L35,11 L23,17 Z"})]}),go)),Ob=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[g("path",{d:"M7,11 H23"}),g("path",{d:"M23,5 L35,11 L23,17 Z"})]}),go)),Fb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),g("circle",{cx:"29",cy:"11",r:"4"})]}),go)),Bb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M7,11 H25",strokeLinecap:"round"}),g("circle",{cx:"29",cy:"11",r:"4"})]}),go)),zb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[g("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),g("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),go)),Hb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[g("path",{d:"M7,11 H21"}),g("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),go)),Ub=_t.memo(({flip:e=!1})=>R(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:g("path",{d:"M11,11 H31 M31,5 V17"})}),go)),Gb=_t.memo(({flip:e=!1})=>R(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M35,11 H7 M15,5 V17"})}),go)),Wb=_t.memo(({flip:e=!1})=>R(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),go)),Vb=_t.memo(({flip:e=!1})=>R(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),go)),Yb=_t.memo(({flip:e=!1})=>R(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),go)),Kb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),g("circle",{cx:"15",cy:"11",r:"4"})]}),go)),Xb=_t.memo(({flip:e=!1})=>R(z("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),g("circle",{cx:"23",cy:"11",r:"4"})]}),go)),$b=R(z(Ke,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),Zb=R(z(Ke,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),jb=R(z(Ke,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),xe),qb=R(g(Ke,{children:g("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),xe),Ti=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),Y),Jb=R(g(Ke,{children:z("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),Y),Dl=R(g(Ke,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),xe),Bp=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 8l-4 4l4 4"}),g("path",{d:"M17 8l4 4l-4 4"}),g("path",{d:"M14 4l-4 16"})]}),Y),Gc=Bp,Qb=R(z("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),Y),e1=R(z("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),Y),t1=R(z("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),Y),o1=_t.memo(({theme:e})=>R(z("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),Y)),r1=_t.memo(({theme:e})=>R(z("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),Y)),n1=_t.memo(({theme:e})=>R(z("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),Y)),Wc=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),Y),i1=R(g("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),y6=R(g("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),a1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),Y),zp=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),Y),Ca=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),g("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),Y),l1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),Y),s1=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),v6=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),Y),w6=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),Y),c1=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),Y),Vc=R(z(Ke,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),Y),Hp=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],d1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Hp.map(e=>g("path",{d:e},e))]}),Y),Ar=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),Y),Ia=R(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),m1=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),g("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),Y),p1=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),g("path",{d:"M4 15l8 4l8 -4"}),g("path",{d:"M12 4v7"}),g("path",{d:"M15 8l-3 3l-3 -3"})]}),Y),_n=R(z("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),xe),Ci=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),g("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),Y),Lr=R(z("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),g("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Ii=R(z("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),Y),T6=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),g("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),Y),C6=R(z("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),Y),u1=R(z("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),Y),Sa=R(z("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),Y),h1=R(z("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),g("path",{d:"M3 3l18 18"})]}),Y),g1=R(z("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),Y),f1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),g("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),Y),Lo=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),Y),b1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),Y),x1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 8l0 4l2 2"}),g("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),Y),E1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),Y),y1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),Y),Rl=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),Y),v1=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),Y),w1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),Y),T1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),Y),C1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),Y),Up=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),Y),Yc=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),Y),I1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),Y),S1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),Y),k1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),Y),M1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),Y),A1=R(z("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...Y,strokeWidth:1.5}),I6=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),Y),L1=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),Y),_1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),Y),P1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),Y),Pn=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),Y),Dn=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),Y),Rn=R(z("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),Y),Kc=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),Y),D1=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),Y),R1=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),Y),Gp=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),Y),Xc=R(z("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),Y),S6=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),g("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),Y),N1=R(z("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 6l8 0"}),g("path",{d:"M16 6l4 0"}),g("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 12l2 0"}),g("path",{d:"M10 12l10 0"}),g("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 18l11 0"}),g("path",{d:"M19 18l1 0"})]}),Y),O1=R(z("g",{strokeWidth:1,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),Y),F1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),g("path",{d:"M13.5 6.5l4 4"})]}),Y),k6=R(z("g",{strokeWidth:1,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l-5 5l5 5"}),g("path",{d:"M17 7l-5 5l5 5"})]}),Y),B1=R(z("g",{strokeWidth:"1.75",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),g("path",{d:"M15 4l0 16"})]}),Y),M6=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),Y),A6=R(z("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 4l18 0"}),g("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),g("path",{d:"M12 16l0 4"}),g("path",{d:"M9 20l6 0"}),g("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),Y),$c=g("div",{style:{width:"1rem",height:"1rem"}}),z1=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("polyline",{points:"6 9 12 15 18 9"})]}),Y),H1=R(z("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("polyline",{points:"9 6 15 12 9 18"})]}),Y),U1=R(z("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 6l8 0"}),g("path",{d:"M16 6l4 0"}),g("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 12l2 0"}),g("path",{d:"M10 12l10 0"}),g("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M4 18l11 0"}),g("path",{d:"M19 18l1 0"})]}),Y);import w2 from"clsx";import W1,{useEffect as P6,useRef as T2,useState as D6}from"react";import L6 from"react";import{jsx as G1}from"react/jsx-runtime";var _6=({size:e="1em",circleWidth:t=8,synchronized:o=!1,className:r=""})=>{let i=-(L6.useRef(Date.now()).current%1600);return G1("div",{className:`Spinner ${r}`,children:G1("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":o?`${i}ms`:0},children:G1("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Pt=_6;import{jsx as Zc,jsxs as Wp}from"react/jsx-runtime";var Q=W1.forwardRef(({size:e="medium",visible:t=!0,className:o="",...r},n)=>{let i=W1.useRef(null);W1.useImperativeHandle(n,()=>i.current);let l=`ToolIcon_size_${e}`,[a,s]=D6(!1),c=T2(!0),d=async p=>{let u="onClick"in r&&r.onClick?.(p);if(ai(u))try{s(!0),await u}catch(b){if(b instanceof yl)console.warn(b);else throw b}finally{c.current&&s(!1)}};P6(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=T2(null);return r.type==="button"||r.type==="icon"?Wp("button",{className:w2("ToolIcon_type_button",l,o,t&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"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:"button",onClick:d,ref:i,disabled:a||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Wp("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Zc("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Zc(Pt,{})]}),r.showAriaLabel&&Wp("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",a&&Zc(Pt,{})]}),r.children]}):Zc("button",{className:w2("ToolIcon","ToolIcon_type_toggle",l,o,{"ToolIcon--checked":r.checked}),type:"button",style:r.style,title:r.title,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"aria-pressed":r.checked,"data-testid":r["data-testid"],disabled:!!r.disabled,"aria-disabled":!!r.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{r.onSelect?.({pointerType:m.current})},ref:i,children:Wp("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Zc("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})})});Q.displayName="IconButton";var Vp=[],G=e=>(Vp=Vp.concat(e),e);import{jsx as N6}from"react/jsx-runtime";var R6=(e,t,o)=>{let r=new Set(ae(e.filter(d=>re(d)),t).map(d=>d.id)),n={},i=o.scene.getNonDeletedElementsMap(),l=new Set;for(let d of r){let m=er(e,d);for(let p of m)if(!l.has(p.id)){if(mt(p)){let u=Vr(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;l.add(p.id)}}let a=!0,s=e.map(d=>{if(t.selectedElementIds[d.id]){let m=mt(d)?Vr(d,i):null;return d.frameId&&r.has(d.frameId)?(a=!1,n[d.id]=!0,d):m?.frameId&&r.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=o.scene.getNonDeletedElementsMap().get(p.id);u&&Re(u)&&o.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),se(d,{isDeleted:!0}))}return d.frameId&&r.has(d.frameId)?(a=!1,mt(d)||(n[d.id]=!0),se(d,{frameId:null})):mt(d)&&t.selectedElementIds[d.containerId]?se(d,{isDeleted:!0}):d}),c=t.editingGroupId;if(a&&t.editingGroupId){let d=He(s,t.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(n[d[0].id]=!0);else{c=null,d[0]&&(n[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(b=>b===t.editingGroupId),u=m.groupIds[p+1];if(u){let b=He(s,u).filter(f=>!f.isDeleted);b.length>1&&(c=u,b.forEach(f=>{n[f.id]=!0}))}}}}return{elements:s,appState:{...t,...kt({selectedElementIds:n,editingGroupId:c},de(s),t,null)}}},C2=(e,t)=>{if(e.editingGroupId){let o=He(de(t),e.editingGroupId);if(o.length)return{...e,selectedElementIds:{[o[0].id]:!0}}}return e},Nl=G({name:"deleteSelectedElements",label:"labels.delete",icon:Kt,trackEvent:{category:"element",action:"delete"},perform:(e,t,o,r)=>{if(t.selectedLinearElement?.isEditing){let{elementId:l,selectedPointsIndices:a}=t.selectedLinearElement,s=r.scene.getNonDeletedElementsMap(),c=Z.getElement(l,s);if(!c||a==null)return!1;if(a.length>=c.points.length){let d=e.map(p=>p.id===c.id?se(p,{isDeleted:!0}):p),m=C2(t,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:N.IMMEDIATELY}}return Z.deletePoints(c,r,a),{elements:e,appState:{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:a?.[0]>0?[a[0]-1]:[0]}},captureUpdate:N.IMMEDIATELY}}let{elements:n,appState:i}=R6(e,t,r);return zm(n,n.filter(l=>l.isDeleted)),i=C2(i,n),{elements:n,appState:{...i,activeTool:ft(t,{type:r.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ge(de(e),t)?N.IMMEDIATELY:N.EVENTUALLY}},keyTest:(e,t,o)=>(e.key===I.BACKSPACE||e.key===I.DELETE)&&!e[I.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>{let n=Ut()==="mobile";return N6(Q,{type:"button",icon:Kt,title:h("labels.delete"),"aria-label":h("labels.delete"),onClick:()=>o(null),disabled:!Ge(de(e),t),style:{...n&&t.openPopup!=="compactOtherProperties"?fn:{}}})}});var H=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,Io?h("keys.option"):h("keys.alt")).replace(/\bShift\b/i,h("keys.shift")).replace(/\b(Enter|Return)\b/i,h("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,Io?h("keys.cmd"):h("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,h("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,h("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,h("keys.delete"));import{jsx as Zp}from"react/jsx-runtime";var Yp=G({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Cp,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:kw(e,t,r.scene),appState:t,captureUpdate:N.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[I.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ge.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Zp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendBackward")} \u2014 ${H("CtrlOrCmd+[")}`,children:Cp})}),Kp=G({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Tp,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:Mw(e,t,r.scene),appState:t,captureUpdate:N.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[I.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ge.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Zp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.bringForward")} \u2014 ${H("CtrlOrCmd+]")}`,children:Tp})}),Xp=G({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Sp,trackEvent:{category:"element"},perform:(e,t)=>({elements:Aw(e,t),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>Io?e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.BRACKET_LEFT:e[I.CTRL_OR_CMD]&&e.shiftKey&&e.code===ge.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>Zp("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendToBack")} \u2014 ${Io?H("CtrlOrCmd+Alt+["):H("CtrlOrCmd+Shift+[")}`,children:Sp})}),$p=G({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Ip,trackEvent:{category:"element"},perform:(e,t)=>({elements:Lw(e,t),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>Io?e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.BRACKET_RIGHT:e[I.CTRL_OR_CMD]&&e.shiftKey&&e.code===ge.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>Zp("button",{type:"button",className:"zIndexButton",onClick:o=>e(null),title:`${h("labels.bringToFront")} \u2014 ${Io?H("CtrlOrCmd+Alt+]"):H("CtrlOrCmd+Shift+]")}`,children:Ip})});var jp=G({name:"selectAll",label:"labels.selectAll",icon:v1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,o,r)=>{if(t.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(ee(i)&&i.containerId)&&!i.locked).reduce((i,l)=>(i[l.id]=!0,i),{});return{appState:{...t,...kt({editingGroupId:null,selectedElementIds:n},de(e),t,r),selectedLinearElement:Object.keys(n).length===1&&Se(e[0])?new Z(e[0],ie(e)):null},captureUpdate:N.IMMEDIATELY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.A});import{jsx as O6}from"react/jsx-runtime";var qp=G({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Al,trackEvent:{category:"element"},perform:(e,t,o,r)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.selectedLinearElement?.isEditing)try{let l=Z.duplicateSelectedPoints(t,r.scene);return{elements:e,appState:l,captureUpdate:N.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=Sn({type:"in-place",elements:e,idsOfElementsToDuplicate:ie(ae(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:l,origIdToDuplicateId:a})=>{let s=l.frameId&&a.get(l.frameId);return{x:l.x+Yg/2,y:l.y+Yg/2,frameId:s??l.frameId}}});if(r.props.onDuplicate&&i){let l=r.props.onDuplicate(i,e);l&&(i=l)}return{elements:Yr(i,ie(n)),appState:{...t,...vc(n,de(i),t)},captureUpdate:N.IMMEDIATELY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.D,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>{let n=Ut()==="mobile";return O6(Q,{type:"button",icon:Al,title:`${h("labels.duplicateSelection")} \u2014 ${H("CtrlOrCmd+D")}`,"aria-label":h("labels.duplicateSelection"),onClick:()=>o(null),disabled:!Ge(de(e),t),style:{...n&&t.openPopup!=="compactOtherProperties"?fn:{}}})}});import{useEffect as s0,useMemo as d0,useRef as c0,useState as CA}from"react";var F6=new Set(["command_palette","export","ai"]),Ee=(e,t,o,r)=>{try{if(typeof window>"u"||k.VITE_WORKER_ID||k.VITE_APP_ENABLE_TRACKING!=="true"||!F6.has(e)||Bt())return;k.PROD||console.info("trackEvent",{category:e,action:t,label:o,value:r}),window.sa_event&&window.sa_event(t,{category:e,label:o,value:r})}catch(n){console.error("error during analytics",n)}};import U6 from"clsx";import B6 from"clsx";import{forwardRef as z6}from"react";import{jsx as H6}from"react/jsx-runtime";var I2=z6((e,t)=>{let{title:o,className:r,testId:n,active:i,icon:l,onClick:a}=e;return H6("button",{type:"button",ref:t,title:o,"data-testid":n,className:B6(r,{active:i}),onClick:a,style:e.style,children:l},o)});import{Fragment as W6,jsx as V1,jsxs as G6}from"react/jsx-runtime";var Wo=e=>V1(W6,{children:e.options.map(t=>e.type==="button"?V1(I2,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:o=>e.onClick(t.value,o)},t.text):G6("label",{className:U6({active:e.value===t.value}),title:t.text,children:[V1("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});import{Popover as eT}from"radix-ui";import tT from"clsx";import{memo as P4,useRef as oT,useEffect as D4}from"react";import{jsx as V6}from"react/jsx-runtime";var Jp=()=>V6("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as $6,useLayoutEffect as Z6,useRef as j6}from"react";import{createPortal as q6}from"react-dom";import S2 from"react";var Y1=S2.createContext(null),be=()=>S2.useContext(Y1);import{useState as Y6,useLayoutEffect as k2}from"react";var Qp=e=>{let[t,o]=Y6(null),r=Me(),{theme:n}=be(),{container:i}=Je();return k2(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",r.formFactor==="phone"),t.classList.toggle("theme--dark",n===J.DARK))},[t,n,r.formFactor,e?.className]),k2(()=>{let l=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!l)return;let a=document.createElement("div");return l.appendChild(a),o(a),()=>{l.removeChild(a)}},[i,e?.parentSelector]),t};import{useEffect as K6}from"react";function Ol(e,t,o){K6(()=>{function r(n){let i=n;if(!e.current)return;let l=o?.(i,e.current);if(l===!0)return;if(l===!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,o])}import{useRef as X6}from"react";var Si=e=>{let t=X6(e);return Object.assign(t.current,e),t.current};var M2=({cursorPosition:e,elementSize:t,containerSize:o,gap:r})=>{let n=e+r+t>o?e-r-t:e+r;return qe(n,0,Math.max(0,o-t))},eu=({cursor:e,element:t,container:o,gap:r})=>({left:M2({cursorPosition:e.x-o.left,elementSize:t.width,containerSize:o.width,gap:r}),top:M2({cursorPosition:e.y-o.top,elementSize:t.height,containerSize:o.height,gap:r})});import{jsx as Q6}from"react/jsx-runtime";var A2=Hp.map((e,t)=>`<path fill="${t===0?"#fff":""}" d="${e}" />`).join(""),J6=`url(data:${pe.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${A2}</g><g stroke="#1b1b1f" stroke-width="1.25">${A2}</g></svg>`)}) 2 21, auto`,Po=Ce(null),L2=({onCancel:e,onChange:t,onSelect:o,colorPickerType:r})=>{let n=Qp({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=be(),l=ki(),a=Xe(),s=ae(l,i),c=Si({app:a,onCancel:e,onChange:t,onSelect:o,selectedElements:s}),{container:d}=Je();Z6(()=>{if(n)return n.style.cursor=J6,()=>{n.style.cursor=""}},[n]),$6(()=>{let p=m.current;if(!p||!a.canvas||!n)return;let u=!1,b=a.canvas.getContext("2d"),f=({clientX:A,clientY:M})=>{let O=b.getImageData((A-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return vy(O[0],O[1],O[2])},x=A=>i.theme===J.DARK?gy(A):A,v=({clientX:A,clientY:M,altKey:O})=>{let{top:P,left:L}=eu({cursor:{x:A,y:M},element:{width:p.offsetWidth,height:p.offsetHeight},container:n.getBoundingClientRect(),gap:7});p.style.top=`${P}px`,p.style.left=`${L}px`;let D=f({clientX:A,clientY:M});u&&c.onChange(r,x(D),c.selectedElements,{altKey:O}),p.style.background=D,p.style.setProperty("--eye-dropper-preview-border-color",Cr(D)?"#fff":"#222")},y=()=>{c.onCancel()},E=(A,M)=>{c.onSelect(A,M)},w=A=>{u=!0,A.stopImmediatePropagation()},T=A=>{u=!1,d?.focus(),A.stopImmediatePropagation(),A.preventDefault(),E(x(f(A)),A)},S=A=>{A.key===I.ESCAPE&&(A.preventDefault(),A.stopImmediatePropagation(),y())};return n.tabIndex=-1,n.focus(),v({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),n.addEventListener("keydown",S),n.addEventListener("pointerdown",w),n.addEventListener("pointerup",T),window.addEventListener("pointermove",v,{passive:!0}),window.addEventListener("blur",y),()=>{u=!1,n.removeEventListener("keydown",S),n.removeEventListener("pointerdown",w),n.removeEventListener("pointerup",T),window.removeEventListener("pointermove",v),window.removeEventListener("blur",y)}},[c,a.canvas,n,r,d,i.offsetLeft,i.offsetTop,i.theme]);let m=j6(null);return Ol(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?q6(Q6("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),n):null};import{Popover as K1}from"radix-ui";import r4 from"clsx";import n4 from"react";import e4 from"react";import t4 from"clsx";import{jsx as o4}from"react/jsx-runtime";var yt=e4.forwardRef(({children:e,padding:t,className:o,style:r,"data-viewport-ui":n,"data-viewport-ui-name":i},l)=>o4("div",{className:t4("Island",o),style:{"--padding":t,...r},"data-viewport-ui":n,"data-viewport-ui-name":i,ref:l,children:e}));import{jsx as X1,jsxs as i4}from"react/jsx-runtime";var Nn=n4.forwardRef(({className:e,container:t,children:o,style:r,onClose:n,onKeyDown:i,onFocusOutside:l,onPointerLeave:a,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},d)=>{let m=Me(),p=m.formFactor==="phone"&&!m.isLandscape;return X1(K1.Portal,{container:t,children:i4(K1.Content,{ref:d,className:r4("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:t??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:a,onKeyDown:i,onFocusOutside:l,onPointerDownOutside:s,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),t&&!Py(document.activeElement)&&t.focus(),n()},children:[X1(yt,{padding:3,style:r,children:o}),X1(K1.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import{useState as a4,useCallback as $1}from"react";var tu=()=>document.querySelector(".excalidraw-wysiwyg"),ou=()=>{let e=tu();return e?{start:e.selectionStart,end:e.selectionEnd}:null},jc=e=>{setTimeout(()=>{let t=tu();t&&(t.focus(),e&&(t.selectionStart=e.start,t.selectionEnd=e.end))},0)},qc=(e,t,o,r)=>{t&&r&&r();let n=t&&o?ou():null;e(),t&&o&&jc(n)},_2=()=>{let[e,t]=a4(null),o=$1(()=>{let i=ou();t(i)},[]),r=$1(()=>{setTimeout(()=>{let i=tu();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,t(null)))},0)},[e]),n=$1(()=>{t(null)},[]);return{saveCaretPosition:o,restoreCaretPosition:r,clearSavedPosition:n,hasSavedPosition:!!e}},P2=(e=100)=>{let t=tu();if(t){let o=t.onblur;t.onblur=null,setTimeout(()=>{t.onblur=o},e)}};import R2 from"clsx";import{useCallback as l4,useEffect as j1,useRef as N2,useState as O2}from"react";var Mi=({palette:e,color:t})=>{if(!t)return null;for(let[o,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(t);if(n>-1)return{colorName:o,shade:n}}else if(r===t)return{colorName:o,shade:null};return null},Jc=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Z1=({color:e,palette:t})=>!Object.values(t).flat().includes(e),D2=(e,t,o)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(l=>{if(l.isDeleted)return!1;let a=l[r[t]];return!Uo(a)&&Z1({color:a,palette:o})}),i=new Map;return n.forEach(l=>{let a=l[r[t]];i.has(a)?i.set(a,i.get(a)+1):i.set(a,1)}),[...i.entries()].sort((l,a)=>a[1]-l[1]).map(l=>l[0]).slice(0,fy)},ir=Ce(null);import{Fragment as s4,jsx as Qc,jsxs as q1}from"react/jsx-runtime";var F2=({color:e,onChange:t,label:o,colorPickerType:r,placeholder:n})=>{let i=Me(),[l,a]=O2(e),[s,c]=O2(null),[d,m]=ne(ir);j1(()=>{a(e)},[e]);let p=l4(v=>{let y=v.toLowerCase().trim(),E=wy(y);E?(t(E),c(null)):y.length===0?c(null):/^#?[0-9a-f]+$/.test(y)?c(h("colorPicker.invalidHexLength")):c(h("colorPicker.invalidColor")),a(y)},[t]),u=N2(null),b=N2(null);j1(()=>{u.current&&u.current.focus()},[d]);let[f,x]=ne(Po);return j1(()=>()=>{x(null)},[x]),q1("div",{className:"color-picker__input-label-container",children:[q1("div",{className:R2("color-picker__input-label",{"has-error":s}),children:[Qc("div",{className:"color-picker__input-hash",children:"#"}),Qc("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":o,"aria-invalid":!!s,onChange:v=>{p(v.target.value)},value:(l||"").replace(/^#/,""),onBlur:()=>{a(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:v=>{v.key!==I.TAB&&(v.key===I.ESCAPE&&b.current?.focus(),v.stopPropagation())},placeholder:n}),i.formFactor!=="phone"&&q1(s4,{children:[Qc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Qc("div",{ref:b,className:R2("excalidraw-eye-dropper-trigger",{selected:f}),onClick:()=>x(v=>v?null:{keepOpenOnAlt:!1,onSelect:y=>t(y),colorPickerType:r}),title:`${h("labels.eyeDropper")} \u2014 ${I.I.toLocaleUpperCase()} or ${H("Alt")} `,children:d1})]})]}),s&&Qc("div",{className:"color-picker__error-message",role:"alert",children:s})]})};import e0,{useEffect as t0,useImperativeHandle as L4,useState as _4}from"react";import g4 from"clsx";import{useEffect as f4,useRef as b4}from"react";import{jsxs as d4}from"react/jsx-runtime";var c4=({color:e,keyLabel:t,isShade:o=!1})=>d4("div",{className:"color-picker__button__hotkey-label",style:{color:Cr(e)?"#fff":"#000"},children:[o&&"\u21E7",t]}),Fl=c4;import{createContext as m4,useContext as p4,useEffect as u4,useMemo as B2,useRef as z2,useState as h4}from"react";var ka="excalidraw-color-dnd-ghost",H2="excalidraw-color-dnd-active",U2=10,G2=100,W2=(e,t)=>{if(e.toLowerCase()===t.toLowerCase())return!0;let o=Qg(e);return o!==null&&o===Qg(t)},J1=m4(null),ar=()=>p4(J1),V2=({enabled:e,picks:t,onPicksChange:o})=>{let[r,n]=h4(null),i=z2(null),l=z2({enabled:e,picks:t,onPicksChange:o});l.current={enabled:e,picks:t,onPicksChange:o};let a=B2(()=>{let s=null,c=()=>{s?.activated?n({color:s.color,origin:s.origin,overIndex:s.overIndex,duplicateIndex:s.duplicateIndex,slotSpan:s.slotSpan}):n(null)},d=()=>{let L=i.current;if(!L||!s)return!1;let D=Array.from(L.querySelectorAll("[data-top-pick-index]")).sort((W,q)=>Number(W.dataset.topPickIndex)-Number(q.dataset.topPickIndex));if(!D.length)return!1;s.slotRects=D.map(W=>W.getBoundingClientRect());let[U,K]=s.slotRects;s.slotSpan=K?K.left-U.left:U.width+4;let F=L.getBoundingClientRect(),$=Math.max(Math.abs(s.slotSpan)/2,10);return s.hitRect={left:F.left-$,right:F.right+$,top:F.top-14,bottom:F.bottom+14},!0},m=(L,D)=>{s?.ghost&&(s.ghost.style.transform=`translate(${L-s.ghostW/2}px, ${D-s.ghostH/2}px)`)},p=(L,D,U,K)=>{s?.ghost&&(s.ghostW!==L||s.ghostH!==D)&&(s.ghostW=L,s.ghostH=D,s.ghost.style.width=`${L}px`,s.ghost.style.height=`${D}px`,m(U,K))},u=(L,D)=>{if(!s)return;let{sourceRect:U,sourceEl:K,color:F}=s,$=document.createElement("div");$.className=ka;let W=document.createElement("div");if(W.className=`${ka}__swatch`,Uo(F))W.classList.add("is-transparent");else{let q=getComputedStyle(K).backgroundColor;W.style.backgroundColor=q&&q!=="rgba(0, 0, 0, 0)"?q:F}$.appendChild(W),document.body.appendChild($),s.ghost=$,s.ghostW=U.width,s.ghostH=U.height,$.style.width=`${U.width}px`,$.style.height=`${U.height}px`,m(L,D),requestAnimationFrame(()=>{s?.ghost===$&&$.classList.add(`${ka}--lifted`)}),document.body.classList.add(H2),s.activated=!0,c()},b=(L,D)=>{if(!s?.hitRect)return;let{hitRect:U,slotRects:K}=s,F=null,$=null;if(L>=U.left&&L<=U.right&&D>=U.top&&D<=U.bottom){let W=0,q=1/0;if(K.forEach((oe,B)=>{let V=Math.abs(L-(oe.left+oe.width/2));V<q&&(q=V,W=B)}),s.origin.kind==="swatch"){let oe=l.current.picks.findIndex(B=>W2(B,s.color));oe!==-1?$=oe:F=W}else F=W}if(F!==s.overIndex||$!==s.duplicateIndex){s.overIndex=F,s.duplicateIndex=$;let{ghost:W}=s;W&&(W.classList.toggle(`${ka}--over`,F!==null),W.classList.toggle(`${ka}--blocked`,$!==null)),c()}if(F!==null){let W=s.slotRects[F];p(W.width,W.height,L,D)}else p(s.sourceRect.width,s.sourceRect.height,L,D)},f=L=>{if(!s?.ghost)return;let{ghost:D}=s;s.ghost=null,D.classList.add(`${ka}--dropping`);let U=L.rect;U&&(D.style.width=`${U.width}px`,D.style.height=`${U.height}px`,D.style.transform=`translate(${U.left}px, ${U.top}px)`),window.setTimeout(()=>{D.classList.add(`${ka}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},x=()=>{let L=i.current;if(!L||!s?.activated)return;let D=Array.from(L.querySelectorAll("[data-top-pick-index]"));for(let U of D)U.style.transition="none",U.style.transform="none";L.offsetWidth;for(let U of D)U.style.transition=""},v=()=>{let L=D=>{D.preventDefault(),D.stopPropagation()};window.addEventListener("click",L,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",L,{capture:!0})},100)},y=()=>{window.removeEventListener("pointermove",S,!0),window.removeEventListener("pointerup",A,!0),window.removeEventListener("pointercancel",M,!0),window.removeEventListener("keydown",O,!0)},E=()=>{y(),document.body.classList.remove(H2),s?.activationTimer!=null&&window.clearTimeout(s.activationTimer),s=null,n(null)},w=L=>{s&&(x(),s.ghost&&(L?f({rect:s.sourceRect}):(s.ghost.remove(),s.ghost=null)),E())},T=(L,D)=>{if(!(!s||s.activated)){if(!d()){E();return}u(L,D),b(L,D)}},S=L=>{if(!(!s||L.pointerId!==s.pointerId)){if(s.lastX=L.clientX,s.lastY=L.clientY,!s.activated){if(Math.hypot(L.clientX-s.startX,L.clientY-s.startY)<U2){s.activationTimer!==null&&(window.clearTimeout(s.activationTimer),s.activationTimer=null);return}let D=performance.now()-s.startTime;if(D<G2){s.activationTimer===null&&(s.activationTimer=window.setTimeout(()=>{s&&(s.activationTimer=null,Math.hypot(s.lastX-s.startX,s.lastY-s.startY)>=U2&&T(s.lastX,s.lastY))},G2-D));return}if(T(L.clientX,L.clientY),!s?.activated)return}L.preventDefault(),m(L.clientX,L.clientY),b(L.clientX,L.clientY)}},A=L=>{if(!s||L.pointerId!==s.pointerId)return;if(!s.activated){E();return}L.preventDefault(),L.stopPropagation(),v();let{overIndex:D,origin:U,color:K,slotRects:F}=s,{picks:$,onPicksChange:W}=l.current;if(x(),D!==null){if(U.kind==="swatch"){if(!$.some(q=>W2(q,K))){let q=[...$];q[D]=K,W(q)}}else if(U.index!==D){let q=[...$],[oe]=q.splice(U.index,1);q.splice(D,0,oe),W(q)}f({rect:F[D]})}else f({rect:s.sourceRect});E()},M=L=>{s&&L.pointerId===s.pointerId&&w(!0)},O=L=>{s?.activated&&L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),w(!0))};return{begin:(L,D,U)=>{!l.current.enabled||s||L.button!==0||!D||(s={pointerId:L.pointerId,startX:L.clientX,startY:L.clientY,startTime:performance.now(),lastX:L.clientX,lastY:L.clientY,activationTimer:null,color:D,origin:U,sourceEl:L.currentTarget,sourceRect:L.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",S,!0),window.addEventListener("pointerup",A,!0),window.addEventListener("pointercancel",M,!0),window.addEventListener("keydown",O,!0))},destroy:()=>w(!1)}},[]);return u4(()=>()=>a.destroy(),[a]),B2(()=>({dragState:r,startSwatchDrag:(s,c)=>a.begin(s,c,{kind:"swatch"}),startPickDrag:(s,c,d)=>a.begin(s,d,{kind:"pick",index:c}),setStripEl:s=>{i.current=s}}),[r,a])};import{jsx as Q1,jsxs as x4}from"react/jsx-runtime";var Y2=({theme:e,colors:t,color:o,onChange:r,label:n})=>{let[i,l]=ne(ir),a=ar(),s=b4(null);return f4(()=>{s.current&&s.current.focus()},[o,i]),Q1("div",{className:"color-picker-content--default",children:t.map((c,d)=>{let m=Jt(c,e===J.DARK);return x4("button",{ref:o===c?s:void 0,tabIndex:-1,type:"button",className:g4("color-picker__button color-picker__button--large has-outline",{active:o===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{r(c),l("custom")},onPointerDown:a?p=>a.startSwatchDrag(p,c):void 0,title:c,"aria-label":n,style:{"--swatch-color":m},children:[Q1("div",{className:"color-picker__button-outline"}),Q1(Fl,{color:m,keyLabel:d+1})]},d)})})};import E4 from"clsx";import{useEffect as y4,useRef as v4}from"react";import{jsx as ru,jsxs as T4}from"react/jsx-runtime";var w4=({theme:e,palette:t,color:o,onChange:r,activeShade:n,showHotKey:i=!0,excludedColors:l})=>{let a=Mi({color:o,palette:t}),[s,c]=ne(ir),d=ar(),m=v4(null);return y4(()=>{m.current&&s==="baseColors"&&m.current.focus()},[a?.colorName,s]),ru("div",{className:"color-picker-content--default",children:Object.entries(t).map(([p,u],b)=>{let f=(Array.isArray(u)?u[n]:u)||"transparent";if(l?.includes(f))return ru("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let x=Jc[b],v=Jt(f,e===J.DARK),y=h(`colors.${p.replace(/\d+/,"")}`,null,"");return T4("button",{ref:a?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:E4("color-picker__button color-picker__button--large",{"has-outline":!Cr(f,255),active:a?.colorName===p,"is-transparent":f==="transparent"||!f}),onClick:()=>{r(f),c("baseColors")},onPointerDown:d?E=>d.startSwatchDrag(E,f):void 0,title:`${y}${f.startsWith("#")?` ${f}`:""} \u2014 ${x}`,"aria-label":`${y} \u2014 ${x}`,style:f?{"--swatch-color":v}:void 0,"data-testid":`color-${p}`,children:[ru("div",{className:"color-picker__button-outline"}),i&&ru(Fl,{color:v,keyLabel:x})]},p)})})},K2=w4;import{jsx as I4}from"react/jsx-runtime";var C4=({children:e})=>I4("div",{className:"color-picker__heading",children:e}),Bl=C4;import S4 from"clsx";import{useEffect as k4,useRef as M4}from"react";import{jsx as ed,jsxs as X2}from"react/jsx-runtime";var $2=({theme:e,color:t,onChange:o,palette:r,showHotKey:n})=>{let i=Mi({color:t||"transparent",palette:r}),[l,a]=ne(ir),s=ar(),c=M4(null);if(k4(()=>{c.current&&l==="shades"&&c.current.focus()},[i,l]),i){let{colorName:d,shade:m}=i,p=r[d];if(Array.isArray(p))return ed("div",{className:"color-picker-content--default shades",children:p.map((u,b)=>{let f=Jt(u,e===J.DARK);return X2("button",{ref:b===m&&l==="shades"?c:void 0,tabIndex:-1,type:"button",className:S4("color-picker__button color-picker__button--large",{active:b===m}),"aria-label":"Shade",title:`${d} - ${b+1}`,style:u?{"--swatch-color":f}:void 0,onClick:()=>{o(u),a("shades")},onPointerDown:s?x=>s.startSwatchDrag(x,u):void 0,children:[ed("div",{className:"color-picker__button-outline"}),n&&ed(Fl,{color:f,keyLabel:b+1,isShade:!0})]},b)})})}return X2("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ed("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ed("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:h("colorPicker.noShades")})]})};var nu=(e,t,o)=>{let r=Math.ceil(o/ia);switch(t=t??-1,e){case"ArrowLeft":{let n=t-1;return n<0?o-1:n}case"ArrowRight":return(t+1)%o;case"ArrowDown":{let n=t+ia;return n>=o?t%ia:n}case"ArrowUp":{let n=t-ia,i=n<0?ia*r+n:n;return i>=o?void 0:i}}},A4=({e,colorObj:t,onChange:o,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:l,excludedColors:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return o(r[t.colorName][s]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return o(n[Number(e.key)-1]),i("custom"),!0;if(Jc.includes(e.key)){let s=Jc.indexOf(e.key),c=Object.keys(r)[s],d=r[c],m=Array.isArray(d)?d[l]:d;return m==null||a?.includes(m)||(o(m),i("baseColors")),!0}return!1},Z2=({event:e,activeColorPickerSection:t,palette:o,color:r,onChange:n,customColors:i,setActiveColorPickerSection:l,updateData:a,activeShade:s,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[I.CTRL_OR_CMD])return!1;if(e.key===I.ESCAPE)return d(e),!0;if(e.key===I.ALT)return c(!0),!0;if(e.key===I.I)return c(),!0;let p=Mi({color:r,palette:o});if(e.key===I.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},b=Object.entries(u).reduce((E,[w,T])=>(T&&E.push(w),E),[]),f=b.indexOf(t),x=e.shiftKey?-1:1,v=f+x>b.length-1?0:f+x<0?b.length-1:f+x,y=b[v];return y&&l(y),y==="custom"?n(i[0]):y==="baseColors"&&(Object.entries(o).find(([w,T])=>Array.isArray(T)?T.includes(r):T===r?w:null)||n(Co.charcoal)),e.preventDefault(),e.stopPropagation(),!0}if(A4({e,colorObj:p,onChange:n,palette:o,customColors:i,setActiveColorPickerSection:l,activeShade:s,excludedColors:m}))return!0;if(t==="shades"&&p){let{shade:u}=p,b=nu(e.key,u,ia);if(b!==void 0)return n(o[p.colorName][b]),!0}if(t==="baseColors"&&p){let{colorName:u}=p,b=Object.keys(o),f=b.indexOf(u),x=nu(e.key,f,b.length),v=0;for(;x!==void 0&&v++<b.length;){let y=o[b[x]],E=Array.isArray(y)?y[s]:y;if(!m?.includes(E))break;x=nu(e.key,x,b.length)}if(x!==void 0){let y=b[x],E=o[y];return n(Array.isArray(E)?E[s]:E),!0}}if(t==="custom"){let u=r!=null?i.indexOf(r):0,b=nu(e.key,u,i.length);if(b!==void 0){let f=i[b];return n(f),!0}}return!1};import{jsx as On,jsxs as iu}from"react/jsx-runtime";var j2=e0.forwardRef(({theme:e,color:t,onChange:o,type:r,elements:n,palette:i,updateData:l,children:a,showTitle:s,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let b=s?r==="elementStroke"?h("labels.stroke"):r==="elementBackground"?h("labels.background"):null:null,[f]=e0.useState(()=>r==="canvasBackground"?[]:D2(n,r,i)),[x,v]=ne(ir),y=ar(),E=Mi({color:t,palette:i});t0(()=>{if(!x){let A=!!t&&Z1({color:t,palette:i}),M=A&&!f.includes(t);v(M?null:A?"custom":E?.shade!=null?"shades":"baseColors")}},[x,t,i,v,E,f]);let[w,T]=_4(E?.shade??(r==="elementBackground"?xm:xy));t0(()=>{E?.shade!=null&&T(E.shade);let A=M=>{M.key===I.ALT&&c(!1)};return document.addEventListener("keyup",A,{capture:!0}),()=>{document.removeEventListener("keyup",A,{capture:!0})}},[E,c]);let S=e0.useRef(null);return L4(u,()=>S.current),t0(()=>{S?.current?.focus()},[]),On("div",{role:"dialog","aria-modal":"true","aria-label":h("labels.colorPicker"),children:iu("div",{ref:S,onKeyDown:A=>{Z2({event:A,activeColorPickerSection:x,palette:i,color:t,onChange:o,onEyeDropperToggle:c,customColors:f,setActiveColorPickerSection:v,updateData:l,activeShade:w,onEscape:d,excludedColors:p})&&(A.preventDefault(),A.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[b&&On("div",{className:"color-picker__title",children:b}),!!f.length&&iu("div",{children:[On(Bl,{children:h("colorPicker.mostUsedCustomColors")}),On(Y2,{theme:e,colors:f,color:t,label:h("colorPicker.mostUsedCustomColors"),onChange:o})]}),iu("div",{children:[On(Bl,{children:h("colorPicker.colors")}),On(K2,{theme:e,color:t,palette:i,onChange:o,activeShade:w,showHotKey:m,excludedColors:p})]}),iu("div",{children:[On(Bl,{children:h("colorPicker.shades")}),On($2,{theme:e,color:t,onChange:o,palette:i,showHotKey:m})]}),a,y&&On("div",{className:"color-picker__tip",children:h("colorPicker.topPicksTip")})]})})});import q2 from"clsx";import{ContextMenu as td}from"radix-ui";import{jsx as Ai,jsxs as J2}from"react/jsx-runtime";var Q2=({theme:e,onChange:t,type:o,activeColor:r,topPicks:n,onReset:i,isCustomized:l})=>{let a=ar(),s=a?.dragState??null,{container:c}=Je(),d;if(o==="elementStroke"&&(d=tl),o==="elementBackground"&&(d=ol),o==="canvasBackground"&&(d=ym),n&&(d=n),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!s||s.origin.kind!=="pick"||s.overIndex===null)return 0;let b=s.origin.index,f=s.overIndex;if(b===f)return 0;let x=u;return u===b?x=f:(u>b&&(x-=1),x>=f&&(x+=1)),(x-u)*s.slotSpan},p=J2("div",{className:q2("color-picker__top-picks",{"is-dnd-active":!!s}),ref:a?.setStripEl,children:[s&&Ai("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:Ai("rect",{})}),d.map((u,b)=>{let f=m(b),x=Jt(u,e===J.DARK);return Ai("button",{className:q2("color-picker__button",{active:u===r,"is-transparent":u==="transparent"||!u,"has-outline":!Cr(u,oc),"is-dnd-source":s?.origin.kind==="pick"&&s.origin.index===b,"is-dnd-target":s?.origin.kind==="swatch"&&s.overIndex===b,"is-dnd-duplicate":s?.duplicateIndex===b}),style:{"--swatch-color":x,transform:f?`translateX(${f}px)`:void 0},type:"button",title:u,onClick:()=>t(u),onPointerDown:a?v=>a.startPickDrag(v,b,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":b,children:Ai("div",{className:"color-picker__button-outline"})},u)})]});return i?J2(td.Root,{children:[Ai(td.Trigger,{asChild:!0,children:p}),Ai(td.Portal,{container:c,children:Ai(td.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:Ai(td.Item,{className:"color-picker__context-menu-item",disabled:!l,onSelect:i,children:h("colorPicker.resetTopPicks")})})})]}):p};import{jsx as lr,jsxs as au}from"react/jsx-runtime";var R4=({type:e,color:t,onChange:o,label:r,elements:n,palette:i=Co,updateData:l,getOpenPopup:a,appState:s,excludedColors:c})=>{let{container:d}=Je(),m=Ut(),p=m!=="full",u=m==="mobile",[,b]=ne(ir),[f,x]=ne(Po),v=au("div",{children:[lr(Bl,{children:h("colorPicker.hexCode")}),lr(F2,{color:t||"",label:r,onChange:w=>{o(w)},colorPickerType:e,placeholder:h("colorPicker.color")})]}),y=oT(null),E=()=>{y.current?.focus()};return lr(Nn,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:w=>{if(w.target instanceof HTMLElement&&w.target.closest(".color-picker__context-menu")){w.preventDefault();return}lo(w.target)||(w.target instanceof HTMLElement&&w.target.matches(":active")?window.addEventListener("pointerup",E,{once:!0}):E()),w.preventDefault()},onPointerDownOutside:w=>{f&&w.preventDefault()},onClose:()=>{a()===e&&l({openPopup:null}),b(null),s.editingTextElement&&setTimeout(()=>{let w=document.querySelector(".excalidraw-wysiwyg");w&&w.focus()},0)},children:i?lr(j2,{ref:y,palette:i,excludedColors:c,color:t,theme:s.theme,onChange:w=>{let T=s.editingTextElement?ou():null;o(w),s.editingTextElement&&T&&jc(T)},onEyeDropperToggle:w=>{x(T=>w?(T=T||{keepOpenOnAlt:!0,onSelect:o,colorPickerType:e},T.keepOpenOnAlt=!0,T):w===!1||T?null:{keepOpenOnAlt:!1,onSelect:o,colorPickerType:e})},onEscape:w=>{f?x(null):l({openPopup:null})},type:e,elements:n,updateData:l,showTitle:p,showHotKey:!u,children:v}):v})},N4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",O4=({label:e,color:t,type:o,theme:r,mode:n="background",onToggle:i,editingTextElement:l})=>{let a=Ut(),s=a!=="full",c=a==="mobile",d=ar(),m=t?Jt(t,r===J.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),l&&P2(),i()};return au(eT.Trigger,{type:"button",className:tT("color-picker__button active-color properties-trigger",{"is-transparent":!t||t==="transparent","has-outline":!t||!Cr(t,oc),"compact-sizing":s,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:o==="elementStroke"?h("labels.showStroke"):h("labels.showBackground"),"data-openpopup":o,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,t):void 0,children:[lr("div",{className:"color-picker__button-outline",children:!t&&pb}),s&&t&&n==="stroke"&&lr("div",{className:"color-picker__button-background",children:lr("span",{style:{color:m&&Cr(m,oc)?"#fff":"#111"},children:O1})})]})},F4=({type:e,color:t,onChange:o,label:r,elements:n,palette:i=Co,topPicks:l,updateData:a,appState:s,excludedColors:c,customizableTopPicks:d})=>{let m=oT(s.openPopup);D4(()=>{m.current=s.openPopup},[s.openPopup]);let u=Ut()!=="full",b=!!d&&!u,f=b&&d?s.colorTopPicks?.[d]:null,x=f?.length?f:l??(e==="elementStroke"?tl:ol),v=V2({enabled:b,picks:x,onPicksChange:y=>{d&&a({colorTopPicks:{...s.colorTopPicks,[d]:y}})}});return lr(J1.Provider,{value:b?v:null,children:au("div",{role:"dialog","aria-modal":"true",className:tT("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&lr(Q2,{theme:s.theme,activeColor:t,onChange:y=>{o(y),N4(s.openPopup)&&s.openPopup!==e&&setTimeout(()=>a({openPopup:e}),0)},type:e,topPicks:f?.length?f:l,isCustomized:!!f?.length,onReset:b&&d?()=>{a({colorTopPicks:{...s.colorTopPicks,[d]:null}})}:void 0}),!u&&lr(Jp,{}),au(eT.Root,{open:s.openPopup===e,onOpenChange:y=>{y&&a({openPopup:e})},children:[lr(O4,{color:t,label:r,type:e,theme:s.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?a({openPopup:null}):s.openPopup?a({openPopup:e}):a({openPopup:e})}}),s.openPopup===e&&lr(R4,{type:e,color:t,onChange:o,label:r,elements:n,palette:i,excludedColors:c,updateData:a,getOpenPopup:()=>m.current,appState:s})]})]})})},B4=(e,t)=>e.appState.openPopup===e.type||t.appState.openPopup===t.type?!1:e.type===t.type&&e.color===t.color&&e.label===t.label&&e.appState.openPopup===t.appState.openPopup&&e.palette===t.palette&&e.topPicks===t.topPicks&&e.excludedColors===t.excludedColors&&e.customizableTopPicks===t.customizableTopPicks&&e.appState.theme===t.appState.theme&&e.appState.colorTopPicks===t.appState.colorTopPicks&&!!e.appState.editingTextElement==!!t.appState.editingTextElement,zl=P4(F4,B4);import{Popover as aA}from"radix-ui";import lA from"clsx";import sA,{useCallback as cA,useMemo as dA}from"react";import eA,{useMemo as Pi,useState as tA,useRef as aT,useEffect as lT,useCallback as sT}from"react";import z4 from"clsx";import H4 from"react";import{jsx as U4,jsxs as G4}from"react/jsx-runtime";var lu=H4.forwardRef(({className:e,placeholder:t,onChange:o},r)=>G4("div",{className:z4("QuickSearch__wrapper",e),children:[Lo,U4("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:t,onChange:n=>o(n.target.value.trim().toLowerCase())})]}));import W4 from"clsx";import{Children as V4}from"react";import{jsx as rT}from"react/jsx-runtime";var su=({className:e,placeholder:t,children:o})=>{let r=!V4.count(o);return rT("div",{className:W4("ScrollableList__wrapper",e),role:"menu",children:r?rT("div",{className:"empty",children:t}):o})};import{jsx as Y4,jsxs as K4}from"react/jsx-runtime";var nT=({children:e,className:t="",style:o,title:r})=>K4("div",{className:`dropdown-menu-group ${t}`,style:o,children:[r&&Y4("p",{className:"dropdown-menu-group-title",children:r}),e]}),od=nT;nT.displayName="DropdownMenuGroup";import{DropdownMenu as Q4}from"radix-ui";import X4,{useContext as $4}from"react";var o0=X4.createContext({}),Li=(e="",t=!1,o=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?"dropdown-menu-item--selected":""} ${o?"dropdown-menu-item--hovered":""}`.trim(),cu=e=>{let t=$4(o0);return li(e,o=>{t.onSelect?.(o)})};import{jsx as Z4}from"react/jsx-runtime";var Ma=({children:e,...t})=>Z4("span",{...t,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...t.style},children:e});import{Fragment as q4,jsx as rd,jsxs as J4}from"react/jsx-runtime";var j4=({textStyle:e,icon:t,shortcut:o,children:r,badge:n})=>{let i=Me();return J4(q4,{children:[t&&rd("div",{className:"dropdown-menu-item__icon",children:t}),rd("div",{style:e,className:"dropdown-menu-item__text",children:rd(Ma,{children:r})}),n&&rd("div",{className:"dropdown-menu-item__badge",children:n}),o&&i.formFactor!=="phone"&&rd("div",{className:"dropdown-menu-item__shortcut",children:o})]})},_i=j4;import{jsx as du}from"react/jsx-runtime";var r0=({icon:e,badge:t,value:o,children:r,shortcut:n,className:i,selected:l,onSelect:a,...s})=>{let c=cu(a);return du(Q4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:du("button",{...s,value:o,className:Li(i,l),title:s.title??s["aria-label"],children:du(_i,{icon:e,shortcut:n,badge:t,children:r})})})};r0.displayName="DropdownMenuItem";var Hl={GREEN:"green",RED:"red",BLUE:"blue"},mu=({type:e=Hl.BLUE,children:t})=>{let{theme:o}=tn(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:o===J.LIGHT?"1.5px solid white":"none"};switch(e){case Hl.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Hl.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case Hl.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return du("div",{className:"DropDownMenuItemBadge",style:r,children:t})};mu.displayName="DropdownMenuItemBadge";r0.Badge=mu;var bo=r0;var iT=({event:e,inputRef:t,hoveredFont:o,filteredFonts:r,onClose:n,onSelect:i,onHover:l})=>{if(!e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===I.F)return t.current?.focus(),!0;if(e.key===I.ESCAPE)return n(),!0;if(e.key===I.ENTER)return o?.value&&i(o.value),!0;if(e.key===I.ARROW_DOWN)return o?.next?l(o.next.value):r[0]?.value&&l(r[0].value),!0;if(e.key===I.ARROW_UP)return o?.prev?l(o.prev.value):r[r.length-1]?.value&&l(r[r.length-1].value),!0};import{jsx as Fn,jsxs as nA}from"react/jsx-runtime";var oA=e=>{switch(e){case ct.Excalifont:case ct.Virgil:return An;case ct.Nunito:case ct.Helvetica:return Dl;case ct["Lilita One"]:return Jb;case ct["Comic Shanns"]:case ct.Cascadia:return Gc;default:return Dl}},rA=(e,t)=>Object.entries(ct).find(([,o])=>o===e)?.[0]??t[0]?.fontFace?.family??"Unknown",cT=eA.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:n,onOpen:i,onClose:l})=>{let{container:a}=Je(),s=Xe(),{fonts:c}=s,{showDeprecatedFonts:d}=xo(),m=Ut(),[p,u]=tA(""),b=aT(null),f=Pi(()=>Array.from(kn.registered.entries()).filter(([L,{metadata:D}])=>!D.private&&!D.fallback).map(([L,{metadata:D,fontFaces:U}])=>{let K={value:L,icon:oA(L),text:rA(L,U)};return D.deprecated&&Object.assign(K,{deprecated:D.deprecated,badge:{type:Hl.RED,placeholder:h("fontList.badge.old")}}),K}).sort((L,D)=>L.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),x=Pi(()=>new Set(c.getSceneFamilies()),[e]),v=Pi(()=>f.filter(L=>x.has(L.value)),[f,x]),y=Pi(()=>f.filter(L=>!x.has(L.value)&&(d||!L.deprecated)),[f,x,d]),E=Pi(()=>Uy([...v,...y].filter(L=>L.text?.toLowerCase().includes(p))),[v,y,p]),w=Pi(()=>{let L;return t?L=E.find(D=>D.value===t):e&&(L=E.find(D=>D.value===e)),!L&&p&&(E[0]?.value?r(E[0].value):n()),L},[t,e,p,E,r,n]),T=sT(L=>{let D=null;if(s.state.editingTextElement){let U=document.querySelector(".excalidraw-wysiwyg");U&&(D={start:U.selectionStart,end:U.selectionEnd})}o(L),s.state.editingTextElement&&D&&setTimeout(()=>{let U=document.querySelector(".excalidraw-wysiwyg");U&&D&&(U.focus(),U.selectionStart=D.start,U.selectionEnd=D.end)},0)},[o,s.state.editingTextElement]),S=sT(L=>{iT({event:L,inputRef:b,hoveredFont:w,filteredFonts:E,onSelect:T,onHover:r,onClose:l})&&(L.preventDefault(),L.stopPropagation())},[w,E,T,r,l]);lT(()=>(i(),()=>{l()}),[]);let A=Pi(()=>E.filter(L=>x.has(L.value)),[E,x]),M=Pi(()=>E.filter(L=>!x.has(L.value)),[E,x]),O=({font:L,order:D})=>{let U=aT(null),K=L.value===w?.value,F=L.value===e;return lT(()=>{K&&(D===0?U.current?.scrollIntoView?.({block:"end"}):U.current?.scrollIntoView?.({block:"nearest"}))},[K,D]),Fn("button",{ref:U,type:"button",value:L.value,className:Li("",F,K),title:L.text,tabIndex:F?0:-1,onClick:$=>{T(Number($.currentTarget.value))},onMouseMove:()=>{w?.value!==L.value&&r(L.value)},children:Fn(_i,{icon:L.icon,badge:L.badge&&Fn(mu,{type:L.badge.type,children:L.badge.placeholder}),textStyle:{fontFamily:la({fontFamily:L.value})},children:L.text})})},P=[];return A.length&&P.push(Fn(od,{title:h("fontList.sceneFonts"),children:A.map((L,D)=>Fn(O,{font:L,order:D},L.value))},"group_1")),M.length&&P.push(Fn(od,{title:h("fontList.availableFonts"),children:M.map((L,D)=>Fn(O,{font:L,order:D+A.length},L.value))},"group_2")),nA(Nn,{className:"properties-content",container:a,style:{width:"15rem"},onClose:()=>{l(),s.state.editingTextElement&&setTimeout(()=>{let L=document.querySelector(".excalidraw-wysiwyg");L&&L.focus()},0)},onPointerLeave:n,onKeyDown:S,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[m==="full"&&Fn(lu,{ref:b,placeholder:h("quickSearch.placeholder"),onChange:xn(u,20)}),Fn(su,{className:"dropdown-menu fonts manual-hover",placeholder:h("fontList.empty"),children:P.length?P:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import{Popover as iA}from"radix-ui";import{jsx as n0}from"react/jsx-runtime";var dT=({selectedFontFamily:e,isOpened:t=!1,compactMode:o=!1})=>{let r=Ie(),n=o?{...fn,width:"2rem",height:"2rem"}:{};return n0(iA.Trigger,{asChild:!0,children:n0("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:n0(Q,{type:"toggle",icon:en,title:h("labels.showFonts"),"aria-label":h("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:t,onSelect:()=>{r(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...n}})})})};import{jsx as nd,jsxs as mT}from"react/jsx-runtime";var pT=[{value:ct.Excalifont,icon:An,text:h("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:ct.Nunito,icon:Dl,text:h("labels.normal"),testId:"font-family-normal"},{value:ct["Comic Shanns"],icon:Gc,text:h("labels.code"),testId:"font-family-code"}],gW=new Set(pT.map(e=>e.value));var uT=sA.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:o,onSelect:r,onHover:n,onLeave:i,onPopupChange:l,compactMode:a=!1})=>{let s=dA(()=>pT,[]),c=cA(d=>{d&&r(d)},[r]);return mT("div",{role:"dialog","aria-modal":"true",className:lA("FontPicker__container",{"FontPicker__container--compact":a}),children:[!a&&nd("div",{className:"buttonList",children:nd(Wo,{type:"button",options:s,value:t,onClick:c})}),!a&&nd(Jp,{}),mT(aA.Root,{open:e,onOpenChange:l,children:[nd(dT,{selectedFontFamily:t,isOpened:e,compactMode:a}),e&&nd(cT,{selectedFontFamily:t,hoveredFontFamily:o,onSelect:c,onHover:n,onLeave:i,onOpen:()=>l(!0),onClose:()=>l(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import{Popover as i0}from"radix-ui";import hA from"clsx";import bT,{useEffect as gA,useMemo as fA}from"react";import{jsx as mA}from"react/jsx-runtime";var on=({className:e,icon:t,size:o="1em"})=>mA("span",{className:e,style:{width:o,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:t});import{Fragment as uA,jsx as hT,jsxs as gT}from"react/jsx-runtime";var pA=({label:e,open:t,openTrigger:o,children:r,className:n,showCollapsedIcon:i=!0})=>gT(uA,{children:[gT("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:o,children:[e,i&&hT(on,{icon:t?D1:Kc})]}),t&&hT("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),id=pA;import{jsx as rn,jsxs as uu}from"react/jsx-runtime";var bA=Ce(!1),pu=4,xA="default",EA=e=>e.flatMap(t=>t.options),fT=(e,t)=>{for(let o of e){let r=o.options.find(t);if(r)return r}return null},yA=(e,t)=>e.some(o=>o.options.some(t)),vA=e=>e.flatMap(t=>Array.from({length:Math.ceil(t.options.length/pu)},(o,r)=>t.options.slice(r*pu,r*pu+pu)));function wA({visibleSections:e,hiddenSections:t=[],value:o,label:r,onChange:n,onClose:i}){let{container:l}=Je(),[a,s]=ne(bA),c=[...e,...t],d=EA(c),m=vA([...e,...a?t:[]]),p=f=>{let x=d.find(v=>v.keyBinding===f.key.toLowerCase());if(!(f.metaKey||f.altKey||f.ctrlKey)&&x)n(x.value),f.preventDefault();else if(f.key===I.TAB){let v=d.findIndex(E=>E.value===o),y=f.shiftKey?(d.length+v-1)%d.length:(v+1)%d.length;n(d[y].value)}else if(ni(f.key)){let v=Qr().rtl,y=d.findIndex(E=>E.value===o);if(y!==-1){let E=d.length,w=y;switch(f.key){case(v?I.ARROW_LEFT:I.ARROW_RIGHT):w=(y+1)%E;break;case(v?I.ARROW_RIGHT:I.ARROW_LEFT):w=(E+y-1)%E;break;case I.ARROW_DOWN:{let T=m.findIndex(A=>A.some(M=>M.value===o)),S=m[T];if(T!==-1&&S){let A=S.findIndex(P=>P.value===o),M=m[(T+1)%m.length],O=M[Math.min(A,M.length-1)]??d[y];n(O.value),f.preventDefault(),f.nativeEvent.stopImmediatePropagation(),f.stopPropagation();return}break}case I.ARROW_UP:{let T=m.findIndex(A=>A.some(M=>M.value===o)),S=m[T];if(T!==-1&&S){let A=S.findIndex(P=>P.value===o),M=m[(m.length+T-1)%m.length],O=M[Math.min(A,M.length-1)]??d[y];n(O.value),f.preventDefault(),f.nativeEvent.stopImmediatePropagation(),f.stopPropagation();return}break}}n(d[w].value)}f.preventDefault()}else(f.key===I.ESCAPE||f.key===I.ENTER)&&(f.preventDefault(),i());f.nativeEvent.stopImmediatePropagation(),f.stopPropagation()};gA(()=>{yA(t,f=>f.value===o)&&s(!0)},[o,t,s]);let u=f=>rn("div",{className:"picker-content",children:f.map(x=>uu("button",{type:"button",className:hA("picker-option",{active:o===x.value}),onClick:()=>{n(x.value)},title:x.keyBinding?`${x.text} \u2014 ${x.keyBinding.toUpperCase()}`:x.text,"aria-label":x.text||"none","aria-keyshortcuts":x.keyBinding||void 0,ref:v=>{o===x.value&&setTimeout(()=>{v?.focus()},0)},children:[x.icon,x.keyBinding&&rn("span",{className:"picker-keybinding",children:x.keyBinding})]},x.text))}),b=f=>f.map((x,v)=>x.name===xA?rn(bT.Fragment,{children:u(x.options)},`${x.name}-${v}`):uu("div",{className:"picker-section",children:[rn("div",{className:"picker-section-label",children:x.name}),u(x.options)]},`${x.name}-${v}`));return rn(i0.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":r,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:l??void 0,children:uu("div",{className:"picker-sections",children:[b(e),t.length>0&&rn(id,{label:h("labels.more_options"),open:a,openTrigger:()=>{s(f=>!f)},className:"picker-collapsible",children:rn("div",{className:"picker-sections",children:b(t)})})]})})}function a0({value:e,label:t,visibleSections:o,hiddenSections:r,onChange:n}){let[i,l]=bT.useState(!1),a=fA(()=>fT(o,s=>s.value===e)??fT(r??[],s=>s.value===e),[o,r,e]);return rn("div",{children:uu(i0.Root,{open:i,onOpenChange:s=>l(s),children:[rn(i0.Trigger,{type:"button","aria-label":t,onClick:()=>l(!i),className:i?"active":"",children:a?.icon}),i&&rn(wA,{visibleSections:o,hiddenSections:r,value:e,label:t,onChange:n,onClose:()=>{l(!1)}})]})})}import xT,{useEffect as TA}from"react";import{jsx as l0,jsxs as ET}from"react/jsx-runtime";var yT=({label:e,value:t,onChange:o,min:r=0,max:n=100,step:i=10,minLabel:l=r,hasCommonValue:a=!0,testId:s})=>{let c=xT.useRef(null),d=xT.useRef(null);return TA(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,b=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,f=(t-r)/(n-r||1)*100,x=f/100*(u-b)+b/2;p.style.left=`${x}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${f}%, var(--button-bg) ${f}%, var(--button-bg) 100%)`}},[n,r,t]),ET("label",{className:"control-label",children:[e,ET("div",{className:"range-wrapper",children:[l0("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:c,type:"range",min:r,max:n,step:i,onChange:m=>{o(+m.target.value)},value:t,className:"range-input","data-testid":s}),l0("div",{className:"value-bubble",ref:d,children:t!==r?t:null}),l0("div",{className:"zero-label",children:l})]})]})};import{Fragment as hu,jsx as le,jsxs as oo}from"react/jsx-runtime";var wT=.1,Aa=e=>{let t=aa(e.editorInterface);return{stylesPanelMode:t,isCompact:t!=="full",isMobile:t==="mobile"}},mo=(e,t,o,r=!1)=>{let n=ie(ae(e,t,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===t.editingTextElement?.id?(or(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),o(i)):i)},Xt=function(e,t,o,r,n){let i=t.state.editingTextElement,l=de(e),a=null;if(i&&(a=o(i)),!a)if(Ge(l,t.state)){let c=t.scene.getSelectedElements(t.state),d=r===!0?c:c.filter(m=>r(m));a=km(d,o)??(typeof n=="function"?n(!0):n)}else a=typeof n=="function"?n(!1):n;return a},IA=(e,t,o)=>mt(t)||!t.autoResize?t:o.mutateElement(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}),m0=(e,t,o,r,n)=>{let i=new Set,l=mo(e,t,a=>{if(ee(a)){let s=r(a);i.add(s);let c=se(a,{fontSize:s});return St(c,o.scene.getContainerElement(a),o.scene),c=IA(a,c,o.scene),c}return a},!0);return ae(e,t,{includeBoundTextElement:!0}).forEach(a=>{ee(a)&&ko(a,o.scene)}),{elements:l,appState:{...t,currentItemFontSize:i.size===1?[...i][0]:n??t.currentItemFontSize},captureUpdate:N.IMMEDIATELY}},TT=G({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,o)=>({...o?.currentItemStrokeColor&&{elements:mo(e,t,r=>hc(r.type)?se(r,{strokeColor:o.currentItemStrokeColor}):r,!0)},appState:{...t,...o},captureUpdate:o?.currentItemStrokeColor?N.IMMEDIATELY:N.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>{let{stylesPanelMode:i}=Aa(r);return oo(hu,{children:[i==="full"&&le("h3",{"aria-hidden":"true",children:h("labels.stroke")}),le(zl,{topPicks:tl,palette:Ey,customizableTopPicks:"elementStroke",type:"elementStroke",label:h("labels.stroke"),color:Xt(e,r,l=>l.strokeColor,!0,l=>l?null:t.currentItemStrokeColor),onChange:l=>o({currentItemStrokeColor:l}),elements:e,appState:t,updateData:o})]})}}),CT=G({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,o,r)=>{if(!o?.currentItemBackgroundColor)return{appState:{...t,...o},captureUpdate:N.EVENTUALLY};let n,i=r.scene.getSelectedElements(t);if(!Uo(o.currentItemBackgroundColor)&&i.every(a=>at(a)&&rv(a.points))){let a=ie(i);n=e.map(s=>a.has(s.id)&&at(s)?se(s,{backgroundColor:o.currentItemBackgroundColor,...Zm(s,!0)}):s)}else n=mo(e,t,a=>se(a,{backgroundColor:o.currentItemBackgroundColor}));return{elements:n,appState:{...t,...o},captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>{let{stylesPanelMode:i}=Aa(r);return oo(hu,{children:[i==="full"&&le("h3",{"aria-hidden":"true",children:h("labels.background")}),le(zl,{topPicks:ol,palette:Jg,customizableTopPicks:"elementBackground",type:"elementBackground",label:h("labels.background"),color:Xt(e,r,l=>l.backgroundColor,!0,l=>l?null:t.currentItemBackgroundColor),onChange:l=>o({currentItemBackgroundColor:l}),elements:e,appState:t,updateData:o})]})}}),ad=G({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,o)=>({appState:{...t,...o},captureUpdate:N.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>{let{stylesPanelMode:n}=Aa(r);return oo(hu,{children:[n==="full"&&le("h3",{"aria-hidden":"true",children:h("labels.background")}),le(zl,{topPicks:Em,palette:Jg,excludedColors:[Co.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:h("labels.background"),color:r.bucketFill.getBucketFillBackgroundColor(t.currentItemBackgroundColor),onChange:i=>o({currentItemBackgroundColor:i}),elements:e,appState:t,updateData:o})]})}}),IT=G({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,o,r)=>(Ee("element","changeFillStyle",`${o} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:mo(e,t,n=>se(n,{fillStyle:o})),appState:{...t,currentItemFillStyle:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>{let n=ae(e,t),i=n.length>0&&n.every(l=>l.fillStyle==="zigzag");return oo("fieldset",{children:[le("legend",{children:h("labels.fill")}),le("div",{className:"buttonList",children:le(Wo,{type:"button",options:[{value:"hachure",text:`${i?h("labels.zigzag"):h("labels.hachure")} (${H("Alt-Click")})`,icon:i?yb:vb,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:h("labels.crossHatch"),icon:wb,testId:"fill-cross-hatch"},{value:"solid",text:h("labels.solid"),icon:Tb,testId:"fill-solid"}],value:Xt(e,r,l=>l.fillStyle,l=>l.hasOwnProperty("fillStyle"),l=>l?null:t.currentItemFillStyle),onClick:(l,a)=>{let s=a.altKey&&l==="hachure"&&n.every(c=>c.fillStyle==="hachure")?"zigzag":l;o(s)}})})]})}}),SA=e=>cy.find(t=>Gr(e.type,t)===e.strokeWidth)??null,kA=(e,t)=>Gr(e.type,t),ST=G({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,o)=>(it(o,"actionChangeStrokeWidth: value must be defined"),{elements:mo(e,t,r=>se(r,{strokeWidth:kA(r,o)})),appState:{...t,currentItemStrokeWidthKey:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>oo("fieldset",{children:[le("legend",{children:h("labels.strokeWidth")}),le("div",{className:"buttonList",children:le(Wo,{group:"stroke-width",options:[{value:"thin",text:h("labels.thin"),icon:Np,testId:"strokeWidth-thin"},{value:"medium",text:h("labels.medium"),icon:Cb,testId:"strokeWidth-medium"},{value:"bold",text:h("labels.bold"),icon:Ib,testId:"strokeWidth-bold"}],value:Xt(e,r,SA,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:t.currentItemStrokeWidthKey),onChange:i=>o(i)})})]})}),kT=G({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,o)=>({elements:mo(e,t,r=>se(r,{seed:En(),roughness:o})),appState:{...t,currentItemRoughness:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>oo("fieldset",{children:[le("legend",{children:h("labels.sloppiness")}),le("div",{className:"buttonList",children:le(Wo,{group:"sloppiness",options:[{value:0,text:h("labels.architect"),icon:Mb},{value:1,text:h("labels.artist"),icon:Ab},{value:2,text:h("labels.cartoonist"),icon:Lb}],value:Xt(e,r,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:t.currentItemRoughness),onChange:i=>o(i)})})]})}),MT=G({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,t,o)=>{let r=o||"constant";return{elements:mo(e,t,n=>n.type!=="freedraw"?n:se(n,{strokeOptions:{...n.strokeOptions,variability:r}})),appState:{...t,currentItemStrokeVariability:r},captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>{let i=Xt(e,r,l=>l.strokeOptions?.variability,l=>l.type==="freedraw",l=>l?null:t.currentItemStrokeVariability)??t.currentItemStrokeVariability;if(n?.cycle){let l=i==="variable";return le(Q,{type:"button",icon:l?Fp:Op,title:h("labels.pressure"),"aria-label":h("labels.pressure"),onClick:()=>o(l?"constant":"variable")})}return oo("fieldset",{children:[le("legend",{children:h("labels.pressure")}),le("div",{className:"buttonList",children:le(Wo,{group:"strokeOptions.variability",options:[{value:"constant",text:h("labels.pressure_constant"),icon:Op},{value:"variable",text:h("labels.pressure_variable"),icon:Fp}],value:i,onChange:l=>o(l)})})]})}}),vV=G({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,o)=>({elements:mo(e,t,r=>se(r,{strokeStyle:o})),appState:{...t,currentItemStrokeStyle:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>oo("fieldset",{children:[le("legend",{children:h("labels.strokeStyle")}),le("div",{className:"buttonList",children:le(Wo,{group:"strokeStyle",options:[{value:"solid",text:h("labels.strokeStyle_solid"),icon:Np},{value:"dashed",text:h("labels.strokeStyle_dashed"),icon:Sb},{value:"dotted",text:h("labels.strokeStyle_dotted"),icon:kb}],value:Xt(e,r,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:t.currentItemStrokeStyle),onChange:i=>o(i)})})]})}),AT=G({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,o)=>({elements:mo(e,t,r=>se(r,{opacity:o}),!0),appState:{...t,currentItemOpacity:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,app:o,updateData:r})=>{let n=Xt(e,o,i=>i.opacity,!0,i=>i?null:t.currentItemOpacity);return le(yT,{label:h("labels.opacity"),value:n??t.currentItemOpacity,hasCommonValue:n!==null,onChange:r,min:0,max:100,step:10,testId:"opacity"})}}),LT=G({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,o,r)=>m0(e,t,r,()=>(it(o,"actionChangeFontSize: Expected a font size value"),o),o),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>{let{isCompact:i}=Aa(r);return oo("fieldset",{children:[le("legend",{children:h("labels.fontSize")}),le("div",{className:"buttonList",children:le(Wo,{group:"font-size",options:[{value:$o.sm,text:h("labels.small"),icon:$b,testId:"fontSize-small"},{value:$o.md,text:h("labels.medium"),icon:Zb,testId:"fontSize-medium"},{value:$o.lg,text:h("labels.large"),icon:jb,testId:"fontSize-large"},{value:$o.xl,text:h("labels.veryLarge"),icon:qb,testId:"fontSize-veryLarge"}],value:Xt(e,r,l=>{if(ee(l))return l.fontSize;let a=ve(l,r.scene.getNonDeletedElementsMap());return a?a.fontSize:null},l=>ee(l)||ve(l,r.scene.getNonDeletedElementsMap())!==null,l=>l?null:t.currentItemFontSize||Qn),onChange:l=>{qc(()=>o(l),i,!!t.editingTextElement,n?.onPreventClose)}})})]})}}),p0=G({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Ti,trackEvent:!1,perform:(e,t,o,r)=>m0(e,t,r,n=>Math.round(1/(1+wT)*n.fontSize)),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&(e.key===I.CHEVRON_LEFT||e.key===I.COMMA)}),u0=G({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Ti,trackEvent:!1,perform:(e,t,o,r)=>m0(e,t,r,n=>Math.round(n.fontSize*(1+wT))),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&(e.key===I.CHEVRON_RIGHT||e.key===I.PERIOD)}),_T=G({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,o,r)=>{let{cachedElements:n,resetAll:i,resetContainers:l,...a}=o;if(i)return{elements:mo(e,t,f=>{let x=n?.get(f.id);return x?se(f,{...x}):f},!0),appState:{...t,...a},captureUpdate:N.NEVER};it(o,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=o,d=N.EVENTUALLY,m,p=!1;if(s)m=s,d=N.IMMEDIATELY;else if(c){m=c,d=N.EVENTUALLY;let b=ae(e,t,{includeBoundTextElement:!0}).filter(f=>ee(f));if(b.length>200)p=!0;else{let f=0,x=0;for(;f<b.length&&x<5e3;){let v=b[f];x+=v?.originalText.length||0,f++}x>5e3&&(p=!0)}}let u={appState:{...t,...a},captureUpdate:d};if(m&&!p){let b=new Map,f=new Set,x=!1,v=Array.from(kn.loadedFontsCache.values()),y=Object.entries(ct).find(([T,S])=>S===m)?.[0];c&&y&&v.some(T=>T.startsWith(y))&&(x=!0),Object.assign(u,{elements:mo(e,t,T=>{if(ee(T)&&(T.fontFamily!==m||s)){let S=se(T,{fontFamily:m,lineHeight:ho(m)}),A=n?.get(T.containerId||"")||{},M=r.scene.getContainerElement(T);return l&&M&&A&&r.scene.mutateElement(M,{...A}),x||(f=new Set([...f,...Array.from(S.originalText)])),b.set(S,M),S}return T},!0)});let E=`10px ${la({fontFamily:m})}`,w=Array.from(f.values()).join();if(x||window.document.fonts.check(E,w))for(let[T,S]of b)St(T,S,r.scene);else window.document.fonts.load(E,w).then(T=>{for(let[S,A]of b){let M=r.scene.getElement(S.id),O=A?r.scene.getElement(A.id):null;M&&St(M,O,r.scene)}r.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:t,app:o,updateData:r})=>{let n=c0(new Map),i=c0(null),[l,a]=CA({}),s=c0(!0),{stylesPanelMode:c,isCompact:d}=Aa(o),m=d0(()=>{let p=(u,b)=>Xt(u,o,f=>{if(ee(f))return f.fontFamily;let x=ve(f,b);return x?x.fontFamily:null},f=>ee(f)||ve(f,b)!==null,f=>f?null:t.currentItemFontFamily||Qa);return l.openPopup==="fontFamily"&&t.openPopup==="fontFamily"?p(Array.from(n.current?.values()??[]),n.current):!l.openPopup&&t.openPopup!=="fontFamily"?p(e,o.scene.getNonDeletedElementsMap()):i.current},[l.openPopup,t,e,o]);return s0(()=>{i.current=m},[m]),s0(()=>{Object.keys(l).length&&(r(l),a({}))},[l]),s0(()=>(s.current=!1,()=>{s.current=!0}),[]),oo(hu,{children:[c==="full"&&le("legend",{children:h("labels.fontFamily")}),le(uT,{isOpened:t.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:t.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{qc(()=>{a({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),n.current.clear()},d,!!t.editingTextElement)},onHover:p=>{a({currentHoveredFontFamily:p,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{a({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:p=>{if(p){n.current.clear();let{editingTextElement:u}=t;if(u?.type==="text"){let b=o.scene.getElement(u.id);n.current.set(u.id,se(b||u,{},!0))}else{let b=ae(e,t,{includeBoundTextElement:!0});for(let f of b)n.current.set(f.id,se(f,{},!0))}a({...l,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};a({...u}),n.current.clear(),d&&t.editingTextElement&&jc(null)}}})]})}}),PT=G({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,o,r)=>({elements:mo(e,t,n=>{if(ee(n)){let i=se(n,{textAlign:o});return St(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...t,currentItemTextAlign:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>{let i=r.scene.getNonDeletedElementsMap(),{isCompact:l}=Aa(r);return oo("fieldset",{children:[le("legend",{children:h("labels.textAlign")}),le("div",{className:"buttonList",children:le(Wo,{group:"text-align",options:[{value:"left",text:h("labels.left"),icon:Qb,testId:"align-left"},{value:"center",text:h("labels.center"),icon:e1,testId:"align-horizontal-center"},{value:"right",text:h("labels.right"),icon:t1,testId:"align-right"}],value:Xt(e,r,a=>{if(ee(a))return a.textAlign;let s=ve(a,i);return s?s.textAlign:null},a=>ee(a)||ve(a,i)!==null,a=>a?null:t.currentItemTextAlign),onChange:a=>{qc(()=>o(a),l,!!t.editingTextElement,n?.onPreventClose)}})})]})}}),DT=G({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:mo(e,t,n=>{if(ee(n)){let i=se(n,{verticalAlign:o});return St(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...t},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,data:n})=>{let{isCompact:i}=Aa(r);return le("fieldset",{children:le("div",{className:"buttonList",children:le(Wo,{group:"text-align",options:[{value:Zo.TOP,text:h("labels.alignTop"),icon:le(o1,{theme:t.theme}),testId:"align-top"},{value:Zo.MIDDLE,text:h("labels.centerVertically"),icon:le(n1,{theme:t.theme}),testId:"align-middle"},{value:Zo.BOTTOM,text:h("labels.alignBottom"),icon:le(r1,{theme:t.theme}),testId:"align-bottom"}],value:Xt(e,r,l=>{if(ee(l)&&l.containerId)return l.verticalAlign;let a=ve(l,r.scene.getNonDeletedElementsMap());return a?a.verticalAlign:null},l=>ee(l)||ve(l,r.scene.getNonDeletedElementsMap())!==null,l=>l?null:Zo.MIDDLE),onChange:l=>{qc(()=>o(l),i,!!t.editingTextElement,n?.onPreventClose)}})})})}}),wV=G({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,o)=>({elements:mo(e,t,r=>Re(r)?r:se(r,{roundness:o==="round"?{type:ci(r.type)?At.ADAPTIVE_RADIUS:At.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:o},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r,renderAction:n})=>{let l=pl(de(e),t).some(a=>a.roundness?.type===At.LEGACY);return oo("fieldset",{children:[le("legend",{children:h("labels.edges")}),oo("div",{className:"buttonList",children:[le(Wo,{group:"edges",options:[{value:"sharp",text:h("labels.sharp"),icon:_b},{value:"round",text:h("labels.round"),icon:Pb}],value:Xt(e,r,a=>l?null:a.roundness?"round":"sharp",a=>!Te(a)&&a.hasOwnProperty("roundness"),a=>a?null:t.currentItemRoundness),onChange:a=>o(a)}),n("togglePolygon")]})]})}}),vT=e=>({visibleSections:[{name:"default",options:[{value:null,text:h("labels.arrowhead_none"),keyBinding:"q",icon:le(Db,{flip:e})},{value:"arrow",text:h("labels.arrowhead_arrow"),keyBinding:"w",icon:le(Rb,{flip:e})},{value:"triangle",text:h("labels.arrowhead_triangle"),icon:le(Nb,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:h("labels.arrowhead_triangle_outline"),icon:le(Ob,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:h("labels.arrowhead_circle"),keyBinding:"a",icon:le(Fb,{flip:e})},{value:"circle_outline",text:h("labels.arrowhead_circle_outline"),keyBinding:"s",icon:le(Bb,{flip:e})},{value:"diamond",text:h("labels.arrowhead_diamond"),icon:le(zb,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:h("labels.arrowhead_diamond_outline"),icon:le(Hb,{flip:e}),keyBinding:"f"},{value:"bar",text:h("labels.arrowhead_bar"),keyBinding:"z",icon:le(Ub,{flip:e})}]},{name:h("labels.cardinality"),options:[{value:"cardinality_one",text:h("labels.arrowhead_cardinality_one"),icon:le(Gb,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:h("labels.arrowhead_cardinality_many"),icon:le(Wb,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:h("labels.arrowhead_cardinality_one_or_many"),icon:le(Vb,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:h("labels.arrowhead_cardinality_exactly_one"),icon:le(Yb,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:h("labels.arrowhead_cardinality_zero_or_one"),icon:le(Kb,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:h("labels.arrowhead_cardinality_zero_or_many"),icon:le(Xb,{flip:e}),keyBinding:null}]}]}),TV=G({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,o)=>(it(o,"actionChangeArrowhead: value must be defined"),{elements:mo(e,t,r=>{if(Se(r)){let{position:n,type:i}=o;if(n==="start")return se(r,{startArrowhead:i});if(n==="end")return se(r,{endArrowhead:i})}return r}),appState:{...t,[o.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:o.type},captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>{let n=Qr().rtl,i=d0(()=>vT(!n),[n]),l=d0(()=>vT(!!n),[n]);return oo("fieldset",{children:[le("legend",{children:h("labels.arrowheads")}),oo("div",{className:"iconSelectList buttonList",children:[le(a0,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:Xt(e,r,a=>Se(a)&&gc(a.type)?Rf(a.startArrowhead):t.currentItemStartArrowhead,!0,a=>a?null:t.currentItemStartArrowhead),onChange:a=>o({position:"start",type:a})}),le(a0,{visibleSections:l.visibleSections,hiddenSections:l.hiddenSections,label:"arrowhead_end",value:Xt(e,r,a=>Se(a)&&gc(a.type)?Rf(a.endArrowhead):t.currentItemEndArrowhead,!0,a=>a?null:t.currentItemEndArrowhead),onChange:a=>o({position:"end",type:a})})]})]})}}),RT=G({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,t,o,r)=>!1,PanelComponent:({elements:e,appState:t,updateData:o,app:r,renderAction:n})=>oo("div",{className:"selected-shape-actions",children:[n("changeArrowhead"),n("changeArrowType")]})}),CV=G({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,o,r)=>{let n=mo(e,t,a=>{if(!Te(a))return a;let s=r.scene.getNonDeletedElementsMap(),c=Z.getPointAtIndexGlobalCoordinates(a,0,s),d=Z.getPointAtIndexGlobalCoordinates(a,-1,s),m=se(a,{x:o===gt.elbow?c[0]:a.x,y:o===gt.elbow?c[1]:a.y,roundness:o===gt.round?{type:At.PROPORTIONAL_RADIUS}:null,elbowed:o===gt.elbow,angle:o===gt.elbow?0:a.angle,points:o===gt.elbow||a.elbowed?[Z.pointFromAbsoluteCoords({...a,x:c[0],y:c[1],angle:0},c,s),Z.pointFromAbsoluteCoords({...a,x:c[0],y:c[1],angle:0},d,s)]:a.points});if(Re(m)){m.fixedSegments=null;let p=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let u=Z.getPointAtIndexGlobalCoordinates(m,0,p),b=Z.getPointAtIndexGlobalCoordinates(m,-1,p),f=m.startBinding&&p.get(m.startBinding.elementId),x=m.endBinding&&p.get(m.endBinding.elementId),v=f&&m.startBinding?{...m.startBinding,...hf(m,f,"start",p,t.isBindingEnabled)}:null,y=x&&m.endBinding?{...m.endBinding,...hf(m,x,"end",p,t.isBindingEnabled)}:null;m={...m,startBinding:v,endBinding:y,...Bm(m,p,{points:[u,b].map(E=>_(E[0]-m.x,E[1]-m.y)),startBinding:v,endBinding:y,fixedSegments:null})}}else{let p=r.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&yc(m,u,t.bindMode==="inside"?"inside":"orbit","start",r.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&yc(m,u,t.bindMode==="inside"?"inside":"orbit","end",r.scene)}}return m}),i={...t,currentItemArrowType:o},l=t.selectedLinearElement?.elementId;if(l){let a=n.find(s=>s.id===l);a&&(i.selectedLinearElement=new Z(a,ie(e)))}return{elements:n,appState:i,captureUpdate:N.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>oo("fieldset",{children:[le("legend",{children:h("labels.arrowtypes")}),le("div",{className:"buttonList",children:le(Wo,{group:"arrowtypes",options:[{value:gt.sharp,text:h("labels.arrowtype_sharp"),icon:Pn,testId:"sharp-arrow"},{value:gt.round,text:h("labels.arrowtype_round"),icon:Rn,testId:"round-arrow"},{value:gt.elbow,text:h("labels.arrowtype_elbowed"),icon:Dn,testId:"elbow-arrow"}],value:Xt(e,r,n=>Te(n)?n.elbowed?gt.elbow:n.roundness?gt.round:gt.sharp:null,n=>Te(n),n=>n?null:t.currentItemArrowType),onChange:n=>o(n)})})]})});import{useEffect as MA}from"react";import{jsx as LA}from"react/jsx-runtime";var Ul=()=>{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},h0=(e,t,o="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,l=5,a=t.left+t.width/2-r.width/2;a<0?a=l:a+r.width>=n&&(a=n-r.width-l);let s;o==="bottom"?(s=t.top+t.height+l,s+r.height>=i&&(s=t.top-r.height-l)):(s=t.top-r.height-l,s<0&&(s=t.top+t.height+l)),Object.assign(e.style,{top:`${s}px`,left:`${a}px`})},AA=(e,t,o,r)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=r?"50ch":"10ch",t.style.maxWidth=r?"50ch":"15ch",t.textContent=o;let n=e.getBoundingClientRect();h0(t,n)},Eo=({children:e,label:t,long:o=!1,style:r,disabled:n})=>(MA(()=>()=>Ul().classList.remove("excalidraw-tooltip--visible"),[]),n?null:LA("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>AA(i.currentTarget,Ul(),t,o),onPointerLeave:()=>Ul().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import{useEffect as NT,useRef as OT,useState as _A}from"react";var PA=(e,t)=>typeof t=="function"?t(e):Array.isArray(t)?e:e[t],gu=(e,t,o)=>{if(e?.isDestroyed)return;let r=e?.getAppState();if(!r){if(!o)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),r=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0,scrollConstraints:null},Mn())}return PA(r,t)};function Gl(e,t=!0){let o=fu(),[,r]=_A(0),n=OT(null);return n.current||(n.current={selector:e,isInitialized:!!o,latestValue:gu(o,e,t)}),n.current.selector=e,!n.current.isInitialized&&o&&!o.isDestroyed&&(n.current.isInitialized=!0,n.current.latestValue=gu(o,e,t)),NT(()=>{let i=n.current;if(!o||o.isDestroyed||!i)return;let l=gu(o,i.selector,t);return l!==i.latestValue&&(i.latestValue=l,r(a=>a+1)),o.onStateChange(i.selector,a=>{i.latestValue=a,r(s=>s+1)})},[o,t]),n.current.latestValue}function DA(e,t){let o=fu(),r=OT({selector:e,callback:t});r.current.selector=e,r.current.callback=t,NT(()=>{if(!(!o||o.isDestroyed))return r.current.callback(gu(o,r.current.selector,!0),o.getAppState()),o.onStateChange(r.current.selector,(n,i)=>{r.current.callback(n,i)})},[o])}import{jsx as bu,jsxs as RA}from"react/jsx-runtime";var FT=G({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,o)=>({appState:{...t,...o},captureUpdate:o?.viewBackgroundColor?N.IMMEDIATELY:N.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,appProps:r,data:n})=>bu(zl,{palette:null,topPicks:ym,label:h("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:i=>o({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:o})}),nn=G({name:"clearCanvas",label:"labels.clearCanvas",icon:Kt,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector",perform:(e,t,o,r)=>(r.imageCache.clear(),{elements:e.map(n=>se(n,{isDeleted:!0})),appState:{...Mn(),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,colorTopPicks:t.colorTopPicks,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:r.state.preferredSelectionTool.type}:t.activeTool},captureUpdate:N.IMMEDIATELY})}),ld=G({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:bp,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>r.isNavigationEnabled(),perform:(e,t,o,r)=>(r.requestUnfollow(),{appState:{...t,...xi({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Ei(t.zoom.value+Qs)},t)},captureUpdate:N.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=Gl(o=>o.zoom.value);return bu(Q,{type:"button",className:"zoom-in-button zoom-button",icon:bp,title:`${h("buttons.zoomIn")} \u2014 ${H("CtrlOrCmd++")}`,"aria-label":h("buttons.zoomIn"),disabled:t>=ay,onClick:()=>{e(null)}})},keyTest:e=>(e.code===ge.EQUAL||e.code===ge.NUM_ADD)&&(e[I.CTRL_OR_CMD]||e.shiftKey)}),sd=G({name:"zoomOut",label:"buttons.zoomOut",icon:xp,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>r.isNavigationEnabled(),perform:(e,t,o,r)=>(r.requestUnfollow(),{appState:{...t,...xi({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Ei(t.zoom.value-Qs)},t)},captureUpdate:N.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=Gl(o=>o.zoom.value);return bu(Q,{type:"button",className:"zoom-out-button zoom-button",icon:xp,title:`${h("buttons.zoomOut")} \u2014 ${H("CtrlOrCmd+-")}`,"aria-label":h("buttons.zoomOut"),disabled:t<=pm,onClick:()=>{e(null)}})},keyTest:e=>(e.code===ge.MINUS||e.code===ge.NUM_SUBTRACT)&&(e[I.CTRL_OR_CMD]||e.shiftKey)}),cd=G({name:"resetZoom",label:"buttons.resetZoom",icon:ib,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>r.isNavigationEnabled(),perform:(e,t,o,r)=>{r.requestUnfollow();let n=t.scrollConstraints?.lockZoom?t.scrollConstraints.zoom:1;return{appState:{...t,...xi({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Ei(n)},t)},captureUpdate:N.EVENTUALLY}},PanelComponent:({updateData:e})=>{let t=Gl(o=>o.zoom.value);return bu(Eo,{label:h("buttons.resetZoom"),style:{height:"100%"},children:RA(Q,{type:"button",className:"reset-zoom-button zoom-button",title:h("buttons.resetZoom"),"aria-label":h("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===ge.ZERO||e.code===ge.NUM_ZERO)&&(e[I.CTRL_OR_CMD]||e.shiftKey)}),g0=e=>[e.x,e.y,e.x+e.width,e.y+e.height],rY=G({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Yc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>r.isNavigationEnabled(),perform:(e,t,o,r)=>{r.requestUnfollow();let n=r.scene.getSelectedElements(t),i=n.length?we(de(n)):t.scrollConstraints?g0(t.scrollConstraints):we(de(e)),l=ba({bounds:i,appState:t,fit:"scale-down",canvasOffsets:r.viewport.getOffsets()});return{...l,appState:{...l.appState,...Zr(l.appState)}}},keyTest:e=>e.code===ge.TWO&&e.shiftKey&&!e.altKey&&!e[I.CTRL_OR_CMD]}),nY=G({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Yc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>r.isNavigationEnabled(),perform:(e,t,o,r)=>{r.requestUnfollow();let n=r.scene.getSelectedElements(t),i=n.length?we(de(n)):t.scrollConstraints?g0(t.scrollConstraints):we(de(e)),l=ba({bounds:i,appState:t,fit:"contain",canvasOffsets:r.viewport.getOffsets()});return{...l,appState:{...l.appState,...Zr(l.appState)}}},keyTest:e=>e.code===ge.THREE&&e.shiftKey&&!e.altKey&&!e[I.CTRL_OR_CMD]}),BT=G({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Yc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,t,o,r)=>r.isNavigationEnabled(),perform:(e,t,o,r)=>{r.requestUnfollow();let n=t.scrollConstraints?g0(t.scrollConstraints):we(de(e)),i=ba({bounds:n,appState:t,fit:"scale-down",canvasOffsets:r.viewport.getOffsets()});return{...i,appState:{...i.appState,...Zr(i.appState)}}},keyTest:e=>e.code===ge.ONE&&e.shiftKey&&!e.altKey&&!e[I.CTRL_OR_CMD]}),Bn=G({name:"toggleTheme",label:(e,t)=>t.theme===J.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,t)=>e.theme===J.LIGHT?Ll:_l,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,r)=>{let n=o||(t.theme===J.LIGHT?J.DARK:J.LIGHT);return r.props.onThemeChange?(r.props.onThemeChange(n),!1):{appState:{...t,theme:n},captureUpdate:N.EVENTUALLY}},keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===ge.D,predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.toggleTheme});import BA from"clsx";import{useEffect as zA,useState as HA}from"react";import{useEffect as NA,useState as OA}from"react";import zT from"clsx";import{Popover as f0}from"radix-ui";import{jsx as xu,jsxs as FA}from"react/jsx-runtime";var Wl=({app:e,options:t,activeTool:o,defaultOption:r,"data-testid":n,onToolChange:i,displayedOption:l})=>{let[a,s]=OA(!1),c=o.type,d=l.type===c,m=16,{container:p}=Je();return!t.some(u=>u.type===c)&&a&&s(!1),NA(()=>{let u=e.onPointerDownEmitter.on(()=>{s(!1)});return()=>u?.()},[e]),FA(f0.Root,{open:a,children:[xu(f0.Trigger,{asChild:!0,children:xu(Q,{className:zT({fillable:l.fillable}),type:"toggle",icon:l.icon,checked:d,disabled:t.every(u=>Dt(e,u.type)),title:Vt(l.title),"aria-label":Vt(l.title),"data-testid":n,onSelect:()=>{s(u=>!u),i(r)}})}),xu(f0.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:t.map(({type:u,icon:b,title:f,fillable:x})=>xu(Q,{className:zT({fillable:x}),type:"toggle",icon:b,checked:c===u,disabled:Dt(e,u),title:Vt(u),"aria-label":Vt(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Ee("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as b0}from"react/jsx-runtime";var UA=e=>e,vt=UA({hand:{icon:a1,letterKey:I.H,toggle:!0},selection:{icon:eb,letterKey:I.V,numericKey:I[1],fillable:!0},rectangle:{icon:Nc,letterKey:I.R,numericKey:I[2],fillable:!0},diamond:{icon:Oc,letterKey:I.D,numericKey:I[3],fillable:!0},ellipse:{icon:Fc,letterKey:I.O,numericKey:I[4],fillable:!0},arrow:{icon:tb,letterKey:I.A,numericKey:I[5],fillable:!0},line:{icon:va,letterKey:I.L,numericKey:I[6],fillable:!0},freedraw:{icon:An,letterKey:[I.P,I.X],numericKey:I[7]},text:{icon:en,letterKey:I.T,numericKey:I[8]},image:{icon:Ml,numericKey:I[9]},eraser:{icon:nb,letterKey:I.E,numericKey:I[0],toggle:!0},frame:{icon:Ar,letterKey:I.F},autoshape:{icon:Ci,letterKey:I.X,shiftKey:!0,fillable:!1},embeddable:{icon:Ln},laser:{icon:Lr,letterKey:I.K},bucketfill:{icon:fo,letterKey:I.B},lasso:{icon:kl,fillable:!1}}),Vl=Object.keys(vt).filter(e=>vt[e].toggle),Eu=e=>{let{letterKey:t,shiftKey:o}=vt[e];if(!t)return t;let r=Vt(typeof t=="string"?t:t[0]);return o?H(`Shift+${r}`):r},dd=e=>{let t=Eu(e),{numericKey:o}=vt[e];return t&&o!=null?`${t} ${h("helpDialog.or")} ${o}`:`${t||o}`},HT=(e,t,o=!1)=>{let r=e.toLowerCase();for(let n of Object.keys(vt)){let{letterKey:i,numericKey:l,shiftKey:a}=vt[n];if(o===!!a&&(l!=null&&e===l||i&&(typeof i=="string"?i===r:i.includes(r))))return n==="selection"?t.state.preferredSelectionTool.type:n}return null},Dt=(e,t)=>e.props.activeTool!=null&&e.props.activeTool.type!==t,Vo=(e,t)=>{let o=vt[e],r=t?.shortcutType??e,n=({app:i,activeTool:l,hideKeyBinding:a,hideShortcut:s})=>{let c=Vt(h(`toolBar.${e}`)),d=s?null:dd(r);return b0(Q,{className:BA({fillable:o.fillable}),type:"toggle",icon:o.icon,checked:l.type===e,disabled:Dt(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:a||s?void 0:vt[r].numericKey||Eu(r),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),t?.onSelect){t.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Ee("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return n.displayName=`${Vt(e)}IconButton`,n},yu=Vo("hand"),UT=Vo("rectangle"),GT=Vo("diamond"),WT=Vo("ellipse"),VT=Vo("arrow"),YT=Vo("line"),KT=Vo("freedraw"),vu=Vo("text"),wu=Vo("image"),Tu=Vo("eraser"),XT=Vo("frame"),$T=Vo("selection",{onSelect:(e,{pointerType:t})=>{if(e.state.activeTool.type==="selection"&&t!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ee("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),ZT=Vo("lasso",{shortcutType:"selection"}),Cu=({app:e,activeTool:t,setAppState:o})=>{let r=[{type:"selection",icon:vt.selection.icon,fillable:vt.selection.fillable,title:Vt(h("toolBar.selection"))},{type:"lasso",icon:vt.lasso.icon,fillable:vt.lasso.fillable,title:Vt(h("toolBar.lasso"))}],n=r.find(i=>i.type===e.state.preferredSelectionTool.type)||r[0];return b0(Wl,{app:e,options:r,activeTool:t,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),o({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:n})},Iu=({app:e,activeTool:t})=>{let o=[{type:"freedraw",icon:vt.freedraw.icon,fillable:vt.freedraw.fillable,title:Vt(h("toolBar.freedraw"))},{type:"autoshape",icon:vt.autoshape.icon,fillable:vt.autoshape.fillable,title:Vt(h("toolBar.autoshape"))}],[r,n]=HA(t.type==="autoshape"?"autoshape":"freedraw");zA(()=>{(t.type==="freedraw"||t.type==="autoshape")&&n(t.type)},[t.type]);let i=o.find(l=>l.type===r)||o[0];return b0(Wl,{app:e,options:o,activeTool:t,defaultOption:r,"data-testid":"toolbar-freedraw",onToolChange:l=>{(l==="freedraw"||l==="autoshape")&&(n(l),e.setActiveTool({type:l}))},displayedOption:i})};import{jsx as GA}from"react/jsx-runtime";var Gt=G({name:"finalize",label:"",trackEvent:!1,perform:(e,t,o,r)=>{let n=!0,i=e,{focusContainer:l,scene:a}=r,s=a.getNonDeletedElementsMap(),c=t.activeTool.type==="autoshape";if(o&&t.selectedLinearElement){let{event:x,sceneCoords:v}=o,y=Z.getElement(t.selectedLinearElement.elementId,s);it(y,"Arrow element should exist if selectedLinearElement is set"),it(v,"sceneCoords should be defined if actionFinalize is called with event");let E=Z.handlePointerUp(x,t.selectedLinearElement,t,r.scene);if(zt(y)&&!t.selectedLinearElement.segmentMidPointHoveredCoords){let w=!!t.newElement,T=w||!t.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:t.selectedLinearElement.selectedPointsIndices,S=ii(x),A=x[I.CTRL_OR_CMD]?null:r.getEffectiveGridSize(),M=T.reduce((O,P)=>(O.set(P,{point:S?y.points[P]:Z.createPointAt(y,s,v.x-E.pointerOffset.x,v.y-E.pointerOffset.y,A)}),O),new Map)??new Map;xc(y,M,v.x,v.y,a,t,{newArrow:w,altKey:x.altKey,angleLocked:S,gridSize:r.getEffectiveGridSize()})}else at(y)&&t.selectedLinearElement?.isEditing&&!t.newElement&&!cf(y.points)&&a.mutateElement(y,{polygon:!1});if(E!==t.selectedLinearElement){y&&$r(y)&&(i=i.map(T=>T.id===y.id?se(T,{isDeleted:!0}):T));let w=t.activeTool?.locked;return{elements:y.points.length<2||$r(y)?e.map(T=>T.id===y.id?se(T,{isDeleted:!0}):T):i,appState:{...t,cursorButton:"up",selectedElementIds:c?{}:t.selectedElementIds,selectedLinearElement:w||c?null:{...E,selectedPointsIndices:null,isEditing:!1,initialState:{...E.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:N.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&l();let d=r.drawShape.hasPendingGesture();(d||c)&&(r.drawShape.finalize(),d&&(i=r.scene.getElementsIncludingDeleted()));let m=null;if(t.multiElement)m=t.multiElement;else if(!c&&!d&&(t.newElement?.type==="freedraw"||zt(t.newElement)))m=t.newElement;else if(Object.keys(t.selectedElementIds).length===1){let x=s.get(Object.keys(t.selectedElementIds)[0]);x&&(m=x)}if(m){if(t.selectedLinearElement&&t.multiElement&&m.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:x}=m,{lastCommittedPoint:v}=t.selectedLinearElement;if((!v||x[x.length-1]!==v)&&(n=!1,a.mutateElement(m,{points:m.points.slice(0,-1)}),zt(m)&&m.endBinding&&m.points.length>1)){let y=!!t.newElement,E=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),w=Z.getPointAtIndexGlobalCoordinates(m,-1,s);xc(m,E,w[0],w[1],a,t,{newArrow:y})}}if(m&&$r(m)&&(i=i.map(x=>x.id===m?.id?se(x,{isDeleted:!0}):x)),Se(m)||ll(m)){if(lc(m.points,t.zoom.value)&&(at(m)||ll(m))){let v=m.points,y=v[0],E=v.map((w,T)=>T===v.length-1?_(y[0],y[1]):w);at(m)?a.mutateElement(m,{points:E,polygon:!0}):a.mutateElement(m,{points:E})}at(m)&&!cf(m.points)&&a.mutateElement(m,{polygon:!1})}}let p;Vl.includes(t.activeTool.type)?p=ft(t,{...t.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveTool:null}):p=ft(t,{type:r.state.preferredSelectionTool.type});let u=r.isToolLocked(),b=t.activeTool.type==="autoshape"||(u||t.activeTool.type==="freedraw")&&!!m;b||r.cursor.applyForTool(p);let f=m&&Se(m)?new Z(m,ie(i)):t.selectedLinearElement;return f=f&&{...f,isEditing:t.newElement?!1:f.isEditing,initialState:{...f.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...t,cursorButton:"up",activeTool:b?t.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[m.id]:!0}:t.selectedElementIds,selectedLinearElement:c?null:f},captureUpdate:n?N.IMMEDIATELY:N.NEVER}},keyTest:(e,t)=>e.key===I.ESCAPE&&t.selectedLinearElement?.isEditing||(e.key===I.ESCAPE||e.key===I.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:o})=>GA(Q,{type:"button",icon:hb,title:h("buttons.done"),"aria-label":h("buttons.done"),onClick:t,visible:e.multiElement!=null,size:o?.size||"medium",style:{pointerEvents:"all"}})});var WA=(e,t)=>Vl.includes(e.activeTool.type)?ft(e,{...e.activeTool.lastActiveTool||{type:t.state.preferredSelectionTool.type},lastActiveTool:null}):ft(e,{type:t.state.preferredSelectionTool.type}),VA=(e,t,o)=>{if(!e.editingGroupId)return null;let r=t.scene.getNonDeletedElements(),n=t.scene.getSelectedElements({selectedElementIds:o,elements:r}),i=n.length?n:He(r,e.editingGroupId);for(let l of i){let a=l.groupIds.indexOf(e.editingGroupId);if(a!==-1&&l.groupIds[a+1])return l.groupIds[a+1]}return null},jT=G({name:"deselect",label:"",trackEvent:!1,perform:(e,t,o,r)=>{let n=WA(t,r);if(r.cursor.applyForTool(n),t.editingGroupId){let i=r.scene.getNonDeletedElements(),l=Object.keys(t.selectedElementIds).length>0?t.selectedElementIds:He(i,t.editingGroupId).reduce((a,s)=>(a[s.id]=!0,a),{});return{appState:{...t,...kt({editingGroupId:VA(t,r,l),selectedElementIds:l},i,t,r),activeEmbeddable:null,activeTool:n,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:N.IMMEDIATELY}}return{appState:{...t,activeEmbeddable:null,activeTool:n,editingGroupId:null,selectedElementIds:Be({},t),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:N.IMMEDIATELY}},keyTest:(e,t,o,r)=>e.key!==I.ESCAPE||lo(e.target)?!1:!t.newElement&&t.multiElement===null&&!t.selectedLinearElement?.isEditing&&(t.activeEmbeddable!==null||t.activeTool.type!==r.state.preferredSelectionTool.type||!!t.editingGroupId||!!t.selectedLinearElement||Ge(r.scene.getNonDeletedElements(),t))});import YA from"clsx";import{jsx as qT,jsxs as KA}from"react/jsx-runtime";var md=({children:e,checked:t,onChange:o,className:r})=>KA("div",{className:YA("Checkbox",r,{"is-checked":t}),onClick:n=>{o(!t,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[qT("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:zc}),qT("div",{className:"Checkbox-label",children:e})]});import{jsx as pd}from"react/jsx-runtime";var QT=e=>{let t=e.title||(e.value===J.DARK?h("buttons.lightMode"):h("buttons.darkMode"));return pd(Q,{type:"icon",icon:e.value===J.LIGHT?JT.MOON:JT.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===J.DARK?J.LIGHT:J.DARK),"data-testid":"toggle-dark-mode"})},JT={SUN:pd("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:pd("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:pd("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:pd("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"})})};import{useState as XA}from"react";import{jsx as eC,jsxs as $A}from"react/jsx-runtime";var tC=e=>{let{id:t}=Je(),[o,r]=XA(e.value),n=l=>{e.ignoreFocus||zy(l.target);let a=l.target.value;a!==e.value&&e.onChange(a)},i=l=>{if(l.key===I.ENTER){if(l.preventDefault(),l.nativeEvent.isComposing||l.keyCode===229)return;l.currentTarget.blur()}};return $A("div",{className:"ProjectName",children:[eC("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),eC("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${t}-filename`,value:o,onChange:l=>r(l.target.value)})]})};import{useCallback as ZA,useEffect as jA,useRef as qA}from"react";import{jsx as Su,jsxs as tL}from"react/jsx-runtime";var JA=5e3,QA=({progress:e})=>Su("div",{className:"Toast__progress-bar",children:Su("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),eL=({message:e,onClose:t,closable:o=!1,duration:r=JA,style:n})=>{let i=qA(0),l=r!==1/0,a=ZA(()=>{l&&(i.current=window.setTimeout(()=>t(),r))},[t,r,l]);return jA(()=>{if(l)return a(),()=>clearTimeout(i.current)},[a,e,r,l]),tL("div",{className:"Toast",role:"status",onMouseEnter:l?()=>clearTimeout(i?.current):void 0,onMouseLeave:l?a:void 0,style:n,children:[Su("div",{className:"Toast__message",children:e}),o&&Su(Q,{icon:Go,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})},ku=Object.assign(eL,{ProgressBar:QA});var $K="clipboard"in navigator&&"readText"in navigator.clipboard,Mu="clipboard"in navigator&&"writeText"in navigator.clipboard,Yl="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,oL=e=>!!([ei.excalidraw,ei.excalidrawClipboard,ei.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),oC=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let o=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){t=t||[],t.push(n);continue}try{if(o.clipboardData?.items.add(n,r),o.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(t){let r=-1;for(let n of t){r++;try{if(o.clipboardData?.items.add(n),o.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return o},rL=({elements:e,files:t})=>{let o=ie(e),r=new Set(e.filter(a=>re(a))),n=!1,i=e.reduce((a,s)=>(si(s)&&(n=!0,t&&t[s.fileId]&&(a[s.fileId]=t[s.fileId])),a),{});n&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let l={type:ei.excalidrawClipboard,elements:e.map(a=>{if(Cn(a,o)&&!r.has(Cn(a,o))){let s=Mr(a);return co(s,o,{frameId:null}),s}return a}),files:t?i:void 0};return JSON.stringify(l)},Au=async(e,t,o)=>{let r=rL({elements:e,files:t});await _r({[pe.excalidrawClipboard]:r,[pe.text]:r},o)};function rC(e){let t=[];for(let o of e.childNodes)if(o.nodeType===3){let r=o.textContent?.trim();r&&t.push({type:"text",value:r})}else if(o instanceof HTMLImageElement){let r=o.getAttribute("src");r&&r.startsWith("http")&&t.push({type:"imageUrl",value:r})}else t=t.concat(rC(o));return t}var nL=e=>{let t=e.value;try{let o=new DOMParser().parseFromString(t,pe.html),r=rC(o.body);if(r.length)return{type:"mixedContent",value:r}}catch(o){console.error(`error in parseHTMLFromPaste: ${o.message}`)}return null},nC=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(o){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);let r=await navigator.clipboard?.readText();if(r)return{[pe.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw o}for(let o of t)for(let r of o.types)if(Sm(ty,r))try{if(r===pe.text||r===pe.html)e[r]=await(await o.getType(r)).text();else if(a2(r)){let n=await o.getType(r),i=u2(n,r,void 0);e[r]=i}else throw new zf(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof zf?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},iL=async(e,t=!1)=>{try{let o=e.findByType(pe.html),r=!t&&o&&nL(o);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.getData(pe.text)??r.value.map(n=>n.value).join(`
|
|
2
|
+
`).trim()}:r:{type:"text",value:(e.getData(pe.text)||"").trim()}}catch{return{type:"text",value:""}}},aL=function(e){return this.find(t=>t.type===e)||null},lL=function(e){return this.find(o=>o.type===e)?.value??null},sL=function(){return this.filter(e=>e.kind==="file")},iC=e=>{let t;aC(e)?t=e.clipboardData?.items:t=e.dataTransfer?.items;let o=new Set;for(let r of Array.from(t||[]))o.has(r.type)||o.add(r.type);return o},Kl=async e=>{let t;aC(e)?t=e.clipboardData?.items:t=e.dataTransfer?.items;let o=(await Promise.all(Array.from(t||[]).map(async r=>{if(r.kind==="file"){let n=r.getAsFile();if(n){let i=await p2(r);return n=await Dc(n),{type:n.type,kind:"file",file:n,fileHandle:i}}}else if(r.kind==="string"){let{type:n}=r,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(n):i=await new Promise(l=>{r.getAsString(a=>l(a))}),{type:n,kind:"string",value:i}}return null}))).filter(r=>r!=null);return Object.assign(o,{findByType:aL,getData:lL,getFiles:sL})},Lu=async(e,t=!1)=>{let o=await iL(e,t);if(o.type==="mixedContent")return{mixedContent:o.value};try{let r=JSON.parse(o.value),n=r.type===ei.excalidrawClipboardWithAPI;if(oL(r))return{elements:r.elements,files:r.files,text:t?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:o.value}},_u=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[pe.png]:e})])}catch(t){if(ai(e))await navigator.clipboard.write([new ClipboardItem({[pe.png]:await e})]);else throw t}},_r=async(e,t)=>{e=e||"";let o=Object.entries(typeof e=="string"?{[pe.text]:e}:e);try{if(t){for(let[n,i]of o)if(t.clipboardData?.setData(n,i),t.clipboardData?.getData(n)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(n){console.error(n)}let r=o.find(([n])=>n===pe.text);if(Mu&&r)try{await navigator.clipboard.writeText(r[1]);return}catch(n){console.error(n)}if(r&&!cL(r[1]))throw new Error("Error copying to clipboard.")},cL=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",o=document.createElement("textarea");o.style.border="0",o.style.padding="0",o.style.margin="0",o.style.position="absolute",o.style[t?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;o.style.top=`${r}px`,o.style.fontSize="12pt",o.setAttribute("readonly",""),o.value=e,document.body.appendChild(o);let n=!1;try{o.select(),o.setSelectionRange(0,o.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return o.remove(),n},aC=e=>e.type==="paste"||e.type==="copy"||e.type==="cut";var La=(e,{selectedElementIds:t},o)=>{let r=de(e),n=ie(r),i=o&&Ge(r,{selectedElementIds:t}),l=null,a=i?ae(r,{selectedElementIds:t},{includeBoundTextElement:!0}):r;if(i){let s=a[0];a.length===1&&re(s)?(l=s,a=Xm(r,s,n)):a.length>1&&(a=ae(r,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:l,exportedElements:Ir(a)}},_a=async({type:e,data:t,config:o})=>{let r=Object.assign({},o);if(r.padding=r.padding??ti,r.fileHandle=r.fileHandle??null,r.exportingFrame=r.exportingFrame??null,r.name=r.name||t.appState.name||dy,t.elements.length===0)throw new Error(h("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let i=xa({data:{elements:t.elements,appState:{exportBackground:r.exportBackground,exportWithDarkMode:t.appState.exportWithDarkMode,viewBackgroundColor:t.appState.viewBackgroundColor,exportPadding:r.padding,exportScale:t.appState.exportScale,exportEmbedScene:t.appState.exportEmbedScene&&e==="svg"},files:t.files},config:{exportingFrame:r.exportingFrame}});if(e==="svg")return Hf(i.then(l=>new Blob([sy+l.outerHTML],{type:pe.svg})),{description:"Export to SVG",name:r.name,extension:t.appState.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Js.svg],fileHandle:r.fileHandle});if(e==="clipboard-svg"){let l=await i.then(a=>a.outerHTML);try{await _r(l)}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return}}let n=Tl({data:t,config:{canvasBackgroundColor:r.exportBackground?r.viewBackgroundColor:!1,padding:r.padding,theme:t.appState.exportWithDarkMode?"dark":"light",scale:t.appState.exportScale,fit:"none",exportingFrame:r.exportingFrame}});if(e==="png"){let i=Ea(n);return t.appState.exportEmbedScene&&(i=i.then(l=>import("./data/image-UAXVGXRE.js").then(({encodePngMetadata:a})=>a({blob:l,metadata:Mc(t.elements,t.appState,t.files,"local")})))),Hf(i,{description:"Export to PNG",name:r.name,extension:t.appState.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Js.png],fileHandle:r.fileHandle})}else if(e==="clipboard")try{let i=Ea(n);await _u(i)}catch(i){throw console.warn(i),i.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):bn&&i.name==="TypeError"?new Error(`${h("alerts.couldNotCopyToClipboard")}
|
|
3
|
+
|
|
4
|
+
${h("hints.firefox_clipboard_write")}`):new Error(h("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var lC=async(e,t,o)=>{let r=n2(t);if(!i2(r))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:n,appState:i,files:l}=await e,{exportBackground:a,viewBackgroundColor:s}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=La(n,i,!1);return await _a({type:r,data:{elements:c,appState:i,files:l},config:{exportBackground:a,viewBackgroundColor:s,name:o,fileHandle:t,exportingFrame:d}}),{fileHandle:t}};import{Fragment as mC,jsx as an,jsxs as pC}from"react/jsx-runtime";var Pu=G({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,o)=>({appState:{...t,name:o},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:o,data:r,app:n})=>an(tC,{label:h("labels.fileTitle"),value:n.getName(),onChange:i=>t(i),ignoreFocus:r?.ignoreFocus??!1})}),sC=G({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,o)=>({appState:{...t,exportScale:o},captureUpdate:N.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let r=de(e),i=Ge(r,t)?ae(r,t):r,l=(a,s,c)=>{let[,,d,m]=o2(a).map(p=>Math.trunc(p*c));return[d+s*2,m+s*2]};return an(mC,{children:gm.map(a=>{let[s,c]=l(i,ti,a),d=`${h("imageExportDialog.label.scale")} ${a}x (${s}x${c})`;return an(Q,{size:"small",type:"toggle",icon:`${a}x`,title:d,"aria-label":d,checked:a===t.exportScale,onSelect:()=>o(a)},a)})})}}),Du=G({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,o)=>({appState:{...t,exportBackground:o},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>an(md,{checked:e.exportBackground,onChange:o=>t(o),children:h("imageExportDialog.label.withBackground")})}),Ru=G({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,o)=>({appState:{...t,exportEmbedScene:o},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>pC(md,{checked:e.exportEmbedScene,onChange:o=>t(o),children:[h("imageExportDialog.label.embedScene"),an(Eo,{label:h("imageExportDialog.tooltip.embedScene"),long:!0,children:an("div",{className:"excalidraw-tooltip-icon",children:gb})})]})}),Xl=!1,x0=(e,t)=>{let o=t.message??h("progressDialog.defaultMessage");e.setAppState({toast:{message:t.progress!=null?pC(mC,{children:[o,an(ku.ProgressBar,{progress:t.progress})]}):o,duration:1/0}})};async function dL(e,t){if(t.app.state.isLoading&&(x0(t.app,{progress:null}),await t.app.onStateChange({predicate:o=>!o.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let o of e){if(t.signal.aborted){e.return();return}if(o.type==="progress")x0(t.app,{message:o.message,progress:o.progress??null});else if(o.type==="done")return}return}e instanceof Promise&&(x0(t.app,{progress:null}),await e)}function cC(e,t,o,r){let n=new AbortController,i=n.signal,l=new Promise(async a=>{try{r.props.onExport&&await dL(r.props.onExport("json",{elements:e,appState:t,files:o},{signal:i}),{app:r,signal:i})}catch(s){s?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",s)}a({elements:e,appState:t,files:r.files})});return{abortController:n,data:l}}var Di=G({name:"saveToActiveFile",label:"buttons.save",icon:wi,trackEvent:{category:"export"},predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,o,r)=>{if(Xl)return!1;Xl=!0;let n=t.fileHandle,i=r.getName(),{abortController:l,data:a}=cC(e,t,r.files,r);try{let{fileHandle:s}=dp(n)?await lC(a,n,i):await ap({data:a,filename:i,fileHandle:n});return{captureUpdate:N.NEVER,appState:{fileHandle:s,toast:{message:n&&s?.name?h("toast.fileSavedToFilename").replace("{filename}",`"${s.name}"`):h("toast.fileSaved"),duration:1500}}}}catch(s){return l.abort(),s?.name!=="AbortError"?console.error(s):console.warn(s),{captureUpdate:N.NEVER,appState:{toast:null}}}finally{Xl=!1}},keyTest:e=>e.key===I.S&&e[I.CTRL_OR_CMD]&&!e.shiftKey}),$l=G({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:wi,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,o,r)=>{if(Xl)return!1;Xl=!0;let{abortController:n,data:i}=cC(e,t,r.files,r);try{let{fileHandle:l}=await ap({data:i,filename:r.getName(),fileHandle:null});return{captureUpdate:N.NEVER,appState:{openDialog:null,fileHandle:l,toast:{message:h("toast.fileSaved"),duration:3e3}}}}catch(l){return n.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:N.NEVER,appState:{toast:null}}}finally{Xl=!1}},keyTest:e=>e.key.toLowerCase()===I.S&&e.shiftKey&&e[I.CTRL_OR_CMD],PanelComponent:({updateData:e})=>an(Q,{type:"button",icon:mb,title:h("buttons.saveAs"),"aria-label":h("buttons.saveAs"),showAriaLabel:Me().formFactor==="phone",hidden:!vl,onClick:()=>e(null),"data-testid":"save-as-button"})}),Pa=G({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,o,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,o,r)=>{try{let{elements:n,appState:i,files:l}=await Uf(t,e);return{elements:n,appState:i,files:l,captureUpdate:N.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:N.EVENTUALLY}}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.O}),dC=G({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,o,r)=>(r.setSessionExportThemeOverride(o?J.DARK:J.LIGHT),{appState:{...t,exportWithDarkMode:o},captureUpdate:N.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>an("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:an(QT,{value:e.exportWithDarkMode?J.DARK:J.LIGHT,onChange:o=>{t(o===J.DARK)},title:h("imageExportDialog.label.darkMode")})})});var uC="{}",Nu=G({name:"copyStyles",label:"labels.copyStyles",icon:Up,trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=[],i=e.find(l=>t.selectedElementIds[l.id]);if(n.push(i),i&&Ht(i)){let l=ve(i,r.scene.getNonDeletedElementsMap());n.push(l)}return i&&(uC=JSON.stringify(n)),{appState:{...t,toast:{message:h("toast.copyStyles")}},captureUpdate:N.EVENTUALLY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.C}),Ou=G({name:"pasteStyles",label:"labels.pasteStyles",icon:Up,trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=JSON.parse(uC),i=n[0],l=n[1];if(!sl(i))return{elements:e,captureUpdate:N.EVENTUALLY};let a=ae(e,t,{includeBoundTextElement:!0}),s=a.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let d=i;if(ee(c)&&c.containerId&&(d=l),!d)return c;let m=se(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?tv(d.roundness.type,c)?d.roundness:ov(c):null});if(ee(m)){let p=d.fontSize||Qn,u=d.fontFamily||Qa,b=se(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||dm,lineHeight:d.lineHeight||ho(u)});m=b;let f=null;b.containerId&&(f=a.find(x=>x.id===b.containerId)||null),St(b,f,r.scene)}return m.type==="arrow"&&Te(d)&&(m=se(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),re(c)&&(m=se(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:N.IMMEDIATELY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.V});var Ri=G({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:lb,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,o,{focusContainer:r})=>(t.openDialog?.name==="help"&&r(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:N.EVENTUALLY}),keyTest:e=>e.key===I.QUESTION_MARK});import{jsx as Zl}from"react/jsx-runtime";var mL=(e,t)=>{if(e.length>=2){let o=t?e[0].groupIds.indexOf(t):-1,r=o>-1?e[0].groupIds.slice(0,o):e[0].groupIds;for(let n of r)if(e.every(i=>ml(i,n)))return!0}return!1},E0=(e,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return o.length>=2&&!mL(o,e.editingGroupId)&&!$m(o)},Fu=G({name:"group",label:"labels.group",icon:e=>Zl(Dp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,r)=>{if(!E0(t,r))return!1;let n=Uv(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:t,elements:e,captureUpdate:N.EVENTUALLY};let i=kr(t);if(i.length===1){let x=i[0],v=new Set(He(e,x).map(w=>w.id)),y=new Set(n.map(w=>w.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:t,elements:e,captureUpdate:N.EVENTUALLY}}let l=[...e];new Set(n.map(x=>x.frameId)).size>1&&zv(n).forEach((v,y)=>{Km(v,r.scene.getNonDeletedElementsMap())});let s=So(),c=ie(n);l=l.map(x=>c.get(x.id)?se(x,{groupIds:Rv(x.groupIds,s,t.editingGroupId)}):x);let d=He(l,s),m=d[d.length-1],p=l.lastIndexOf(m),u=l.slice(p+1),b=l.slice(0,p).filter(x=>!ml(x,s)),f=Yr([...b,...d,...u],ie(d));return{appState:{...t,..._v(s,{...t,selectedGroupIds:{}},de(l))},elements:f,captureUpdate:N.IMMEDIATELY}},predicate:(e,t,o,r)=>E0(t,r),keyTest:e=>!e.shiftKey&&e[I.CTRL_OR_CMD]&&e.key===I.G,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>Zl(Q,{hidden:!E0(t,r),type:"button",icon:Zl(Dp,{theme:t.theme}),onClick:()=>o(null),title:`${h("labels.group")} \u2014 ${H("CtrlOrCmd+G")}`,"aria-label":h("labels.group"),visible:Ge(de(e),t)})}),Bu=G({name:"ungroup",label:"labels.ungroup",icon:e=>Zl(Rp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=kr(t),i=ie(e);if(n.length===0)return{appState:t,elements:e,captureUpdate:N.EVENTUALLY};let l=[...e],a=[];l=l.map(p=>{mt(p)&&a.push(p.id);let u=Nv(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:se(p,{groupIds:u})});let s=kt(t,de(l),t,null),c=r.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return Hv(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(l=Kr(l,Mo(l,p,t,i),p))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,b])=>(b&&!a.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:l,captureUpdate:N.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[I.CTRL_OR_CMD]&&e.key===I.G.toUpperCase(),predicate:(e,t)=>kr(t).length>0,PanelComponent:({elements:e,appState:t,updateData:o})=>Zl(Q,{type:"button",hidden:kr(t).length===0,icon:Zl(Rp,{theme:t.theme}),onClick:()=>o(null),title:`${h("labels.ungroup")} \u2014 ${H("CtrlOrCmd+Shift+G")}`,"aria-label":h("labels.ungroup"),visible:Ge(de(e),t)})});import gL from"clsx";var zu=(e,t,o,r,n,i,l)=>{e.beginPath(),e.moveTo(t+i,o),e.lineTo(t+r-i,o),e.quadraticCurveTo(t+r,o,t+r,o+i),e.lineTo(t+r,o+n-i),e.quadraticCurveTo(t+r,o+n,t+r-i,o+n),e.lineTo(t+i,o+n),e.quadraticCurveTo(t,o+n,t,o+n-i),e.lineTo(t,o+i),e.quadraticCurveTo(t,o,t+i,o),e.closePath(),e.fill(),l&&(e.strokeStyle=l),e.stroke()};function pL(e){let t=0;if(e.length===0)return t;for(let o=0;o<e.length;o++){let r=e.charCodeAt(o);t=(t<<5)-t+r}return t}var Da=(e,t)=>`hsl(${Math.abs(pL(t?.id||e))%37*10}, 100%, 83%)`,hC=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},gC=({context:e,renderConfig:t,appState:o,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,l]of t.remotePointerViewportCoords){let{x:a,y:s}=l,c=o.collaborators.get(i);a-=o.offsetLeft,s-=o.offsetTop;let d=11,m=14,p=a<0||a>r-d||s<0||s>n-m;a=Math.max(a,0),a=Math.min(a,r-d),s=Math.max(s,0),s=Math.min(s,n-m);let u=Da(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let b=t.remotePointerUserStates.get(i),f=p||b==="idle"||b==="away";f&&(e.globalAlpha=.3),t.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(a,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(a,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=o.theme===J.DARK?"#2f6330":ey,v=c?.isSpeaking;v&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Ho,e.strokeStyle=Ho,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),f?(e.moveTo(a-1,s-1),e.lineTo(a-1,s+15),e.lineTo(a+5,s+10),e.lineTo(a+12,s+9),e.closePath(),e.fill()):(e.moveTo(a,s),e.lineTo(a+0,s+14),e.lineTo(a+4,s+9),e.lineTo(a+11,s+8),e.closePath(),e.fill(),e.stroke());let y=t.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let E=(v?a+0:a)+d/2,w=(v?s+0:s)+m+2,T=5,S=3,A=e.measureText(y),M=A.actualBoundingBoxDescent+A.actualBoundingBoxAscent,O=Math.max(M,12),P=E-1,L=w-1,D=A.width+2+T*2+2,U=O+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,L,D,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=Ho,e.stroke(),v&&(e.beginPath(),e.roundRect(P-2,L-2,D+4,U+4,8),e.strokeStyle=x,e.stroke())):zu(e,P,L,D,U,8,Ho),e.fillStyle=ra,e.fillText(y,E+T+1,w+S+A.actualBoundingBoxAscent+Math.floor((O-M)/2)+2),v){e.fillStyle=x;let K=8,F=8,$=5;e.fillRect(P+D+F,L+(U/2-K/2),2,K),e.fillRect(P+D+F+$,L+(U/2-K*2/2),2,K*2),e.fillRect(P+D+F+$*2,L+(U/2-K/2),2,K)}}e.restore(),e.closePath()}};import uL from"clsx";import{useState as hL}from"react";import{jsx as fC}from"react/jsx-runtime";var y0=({color:e,onClick:t,name:o,src:r,className:n})=>{let i=hC(o),[l,a]=hL(!1),s=!l&&r,c=s?void 0:{background:e};return fC("div",{className:uL("Avatar",n),style:c,onClick:t,children:s?fC("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>a(!0)}):i})};import{jsx as ln,jsxs as Hu}from"react/jsx-runtime";var bC=G({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,o,r)=>(it(o,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!o.socketId||r.props.userToFollow?.socketId===o.socketId||o.isCurrentUser?(r.requestUnfollow(),{appState:t,captureUpdate:N.EVENTUALLY}):(r.emitUserFollowIntent({userToFollow:{socketId:o.socketId,username:o.username||""},action:"FOLLOW"}),{appState:{...t,openMenu:t.openMenu==="canvas"?null:t.openMenu},captureUpdate:N.EVENTUALLY})),PanelComponent:({updateData:e,data:t,appState:o})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:l}=t,a=Da(r,n),s=gL({"is-followed":l,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?Hu("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:h("userList.hint.isSpeaking"),children:[ln("div",{}),ln("div",{}),ln("div",{})]}):n.isMuted?ln("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:h("userList.hint.micMuted"),children:y1}):ln("div",{title:h("userList.hint.inCall"),children:E1}):null;return i?Hu("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:n.isCurrentUser?void 0:()=>e(n),children:[ln(y0,{color:a,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),ln("div",{className:"UserList__collaborator-name",children:n.username}),Hu("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[l&&ln("div",{className:"UserList__collaborator-status-icon-is-followed",title:h("userList.hint.followStatus"),children:Sa}),n.isCurrentUser&&` (${h("labels.you")})`,c]})]}):Hu("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[ln(y0,{color:a,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&ln("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var Uu=G({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of bm)if(n.some(l=>l.type===i))return{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:h(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:So(),status:"unpublished",elements:n.map(Mr),created:Date.now()},...i])).then(()=>({captureUpdate:N.EVENTUALLY,appState:{...t,toast:{message:h("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{jsx as ql}from"react/jsx-runtime";var Do=(e,t)=>{let o=t.scene.getSelectedElements(e);return Gm(o,t.scene.getNonDeletedElementsMap(),e).length>1&&!o.some(r=>re(r))},jl=(e,t,o,r)=>{let n=o.scene.getSelectedElements(t),i=ow(n,r,o.scene,t),l=ie(i);return Xr(e.map(a=>l.get(a.id)||a),t,o)},xC=G({name:"alignTop",label:"labels.alignTop",icon:kp,trackEvent:{category:"element"},predicate:(e,t,o,r)=>Do(t,r),perform:(e,t,o,r)=>({appState:t,elements:jl(e,t,r,{position:"start",axis:"y"}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>ql(Q,{hidden:!Do(t,r),type:"button",icon:kp,onClick:()=>o(null),title:`${h("labels.alignTop")} \u2014 ${H("CtrlOrCmd+Shift+Up")}`,"aria-label":h("labels.alignTop"),visible:Ge(de(e),t)})}),EC=G({name:"alignBottom",label:"labels.alignBottom",icon:Mp,trackEvent:{category:"element"},predicate:(e,t,o,r)=>Do(t,r),perform:(e,t,o,r)=>({appState:t,elements:jl(e,t,r,{position:"end",axis:"y"}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>ql(Q,{hidden:!Do(t,r),type:"button",icon:Mp,onClick:()=>o(null),title:`${h("labels.alignBottom")} \u2014 ${H("CtrlOrCmd+Shift+Down")}`,"aria-label":h("labels.alignBottom"),visible:Ge(de(e),t)})}),yC=G({name:"alignLeft",label:"labels.alignLeft",icon:Ap,trackEvent:{category:"element"},predicate:(e,t,o,r)=>Do(t,r),perform:(e,t,o,r)=>({appState:t,elements:jl(e,t,r,{position:"start",axis:"x"}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>ql(Q,{hidden:!Do(t,r),type:"button",icon:Ap,onClick:()=>o(null),title:`${h("labels.alignLeft")} \u2014 ${H("CtrlOrCmd+Shift+Left")}`,"aria-label":h("labels.alignLeft"),visible:Ge(de(e),t)})}),vC=G({name:"alignRight",label:"labels.alignRight",icon:Lp,trackEvent:{category:"element"},predicate:(e,t,o,r)=>Do(t,r),perform:(e,t,o,r)=>({appState:t,elements:jl(e,t,r,{position:"end",axis:"x"}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>ql(Q,{hidden:!Do(t,r),type:"button",icon:Lp,onClick:()=>o(null),title:`${h("labels.alignRight")} \u2014 ${H("CtrlOrCmd+Shift+Right")}`,"aria-label":h("labels.alignRight"),visible:Ge(de(e),t)})}),wC=G({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:_p,trackEvent:{category:"element"},predicate:(e,t,o,r)=>Do(t,r),perform:(e,t,o,r)=>({appState:t,elements:jl(e,t,r,{position:"center",axis:"y"}),captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>ql(Q,{hidden:!Do(t,r),type:"button",icon:_p,onClick:()=>o(null),title:h("labels.centerVertically"),"aria-label":h("labels.centerVertically"),visible:Ge(de(e),t)})}),TC=G({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Pp,trackEvent:{category:"element"},predicate:(e,t,o,r)=>Do(t,r),perform:(e,t,o,r)=>({appState:t,elements:jl(e,t,r,{position:"center",axis:"x"}),captureUpdate:N.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>ql(Q,{hidden:!Do(t,r),type:"button",icon:Pp,onClick:()=>o(null),title:h("labels.centerHorizontally"),"aria-label":h("labels.centerHorizontally"),visible:Ge(de(e),t)})});import{jsx as MC}from"react/jsx-runtime";var CC=(e,t)=>{let o=t.scene.getSelectedElements(e);return Gm(o,t.scene.getNonDeletedElementsMap(),e).length>2&&!o.some(r=>re(r))},IC=(e,t,o,r)=>{let n=o.scene.getSelectedElements(t),i=xw(n,o.scene.getNonDeletedElementsMap(),r,t,o.scene),l=ie(i);return Xr(e.map(a=>l.get(a.id)||a),t,o)},SC=G({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,o,r)=>({appState:t,elements:IC(e,t,r,{space:"between",axis:"x"}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.H,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>MC(Q,{hidden:!CC(t,r),type:"button",icon:bb,onClick:()=>o(null),title:`${h("labels.distributeHorizontally")} \u2014 ${H("Alt+H")}`,"aria-label":h("labels.distributeHorizontally"),visible:Ge(de(e),t)})}),kC=G({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,o,r)=>({appState:t,elements:IC(e,t,r,{space:"between",axis:"y"}),captureUpdate:N.IMMEDIATELY}),keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.V,PanelComponent:({elements:e,appState:t,updateData:o,app:r})=>MC(Q,{hidden:!CC(t,r),type:"button",icon:xb,onClick:()=>o(null),title:`${h("labels.distributeVertically")} \u2014 ${H("Alt+V")}`,"aria-label":h("labels.distributeVertically"),visible:Ge(de(e),t)})});var Gu=G({name:"flipHorizontal",label:"labels.flipHorizontal",icon:C1,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:Xr(AC(e,r.scene.getNonDeletedElementsMap(),t,"horizontal",r),t,r),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ge.H}),Wu=G({name:"flipVertical",label:"labels.flipVertical",icon:T1,trackEvent:{category:"element"},perform:(e,t,o,r)=>({elements:Xr(AC(e,r.scene.getNonDeletedElementsMap(),t,"vertical",r),t,r),appState:t,captureUpdate:N.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ge.V&&!e[I.CTRL_OR_CMD]}),AC=(e,t,o,r,n)=>{let i=ae(de(e),o,{includeBoundTextElement:!0,includeElementsInFrames:!0}),l=fL(i,t,r,n),a=ie(l);return e.map(s=>a.get(s.id)||s)},fL=(e,t,o,r)=>{if(e.every(p=>Te(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return se(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:n,midY:i}=In(e);Gw(e,t,"nw",r.scene,new Map(Array.from(t.values()).map(p=>[p.id,Mr(p)])),{flipByX:o==="horizontal",flipByY:o==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Ec(e.filter(Te),r.scene,r.state);let{elbowArrows:l,otherElements:a}=e.reduce((p,u)=>Re(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=In(e),[d,m]=[n-s,i-c];return a.forEach(p=>r.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),l.forEach(p=>r.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};var Ra=G({name:"copy",label:"labels.copy",icon:Al,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Au(n,r.files,o)}catch(i){return{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:i.message}}}return{captureUpdate:N.EVENTUALLY}},keyTest:void 0}),v0=G({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,o,r)=>{let n;try{n=await nC()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),bn?{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:h("hints.firefox_clipboard_write")}}:{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:h("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(oC({types:n}))}catch(i){return console.error(i),{captureUpdate:N.EVENTUALLY,appState:{...t,errorMessage:h("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:N.EVENTUALLY}},keyTest:void 0}),ud=G({name:"cut",label:"labels.cut",icon:l1,trackEvent:{category:"element"},perform:(e,t,o,r)=>(Ra.perform(e,t,o,r),Nl.perform(e,t,null,r)),keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.X}),hd=G({name:"copyAsSvg",label:"labels.copyAsSvg",icon:I1,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{if(!r.canvas)return{captureUpdate:N.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=La(e,t,!0);try{await _a({type:"clipboard-svg",data:{elements:n,appState:t,files:r.files},config:{...t,exportingFrame:i,name:r.getName()}});let l=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:h("toast.copyToClipboardAsSvg",{exportSelection:l.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:t.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:N.EVENTUALLY}}catch(l){return console.error(l),{appState:{errorMessage:l.message},captureUpdate:N.EVENTUALLY}}},predicate:e=>Mu&&e.length>0,keywords:["svg","clipboard","copy"]}),gd=G({name:"copyAsPng",label:"labels.copyAsPng",icon:S1,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{if(!r.canvas)return{captureUpdate:N.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:l}=La(e,t,!0);try{return await _a({type:"clipboard",data:{elements:i,appState:t,files:r.files},config:{...t,exportingFrame:l,name:t.name||r.getName()}}),{appState:{...t,toast:{message:h("toast.copyToClipboardAsPng",{exportSelection:n.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:t.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:N.EVENTUALLY}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},captureUpdate:N.EVENTUALLY}}},predicate:e=>Yl&&e.length>0,keyTest:e=>e.code===ge.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),fd=G({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{_r(uc(n))}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return{captureUpdate:N.EVENTUALLY}},predicate:(e,t,o,r)=>Mu&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(ee),keywords:["text","clipboard","copy"]});var Na=G({name:"gridMode",icon:_1,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:N.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[I.CTRL_OR_CMD]&&e.code===ge.QUOTE});var zn=G({name:"zenMode",label:"buttons.zenMode",icon:M1,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:N.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,o,r)=>r.editorInterface.formFactor!=="phone"&&typeof o.zenModeEnabled>"u",keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.Z});var Jl=G({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:k1,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:N.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,o)=>typeof o.objectsSnapModeEnabled>"u",keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.S});var Ql=G({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,t){let o=t.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...t,bindingPreference:o,isBindingEnabled:o==="enabled"},captureUpdate:N.NEVER}},checked:e=>e.bindingPreference==="enabled"});var es=G({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,t){return{appState:{...t,isMidpointSnappingEnabled:!this.checked(t)},captureUpdate:N.NEVER}},checked:e=>e.isMidpointSnappingEnabled});var Hn=G({name:"stats",label:"stats.fullTitle",icon:w1,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:N.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.SLASH});var Vu=G({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,o,r)=>r.scene.getSelectedElements(t).some(i=>Ht(i)),perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i=r.scene.getNonDeletedElementsMap();return n.forEach(l=>{let a=ve(l,i);if(a){let{width:s,height:c}=lt(a.originalText,dt(a),a.lineHeight),d=cv(l.id);sv(l.id);let{x:m,y:p}=di(l,a,i);r.scene.mutateElement(a,{containerId:null,width:s,height:c,text:a.originalText,x:m,y:p}),r.scene.mutateElement(l,{boundElements:l.boundElements?.filter(u=>u.id!==a.id),height:d||l.height})}}),{elements:e,appState:t,captureUpdate:N.IMMEDIATELY}}}),Yu=G({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);if(n.length===2){let i=ee(n[0])||ee(n[1]),l;if(vn(n[0])?l=n[0]:vn(n[1])&&(l=n[1]),i&&l&&ve(l,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i,l;ee(n[0])&&vn(n[1])?(i=n[0],l=n[1]):(i=n[1],l=n[0]),r.scene.mutateElement(i,{containerId:l.id,verticalAlign:Zo.MIDDLE,textAlign:jg.CENTER,autoResize:!0,angle:Te(l)?0:l?.angle??0}),r.scene.mutateElement(l,{boundElements:(l.boundElements||[]).concat({type:"text",id:i.id})});let a=l.height;return St(i,l,r.scene),sc(l.id,a),{elements:bL(e,l,i),appState:{...t,selectedElementIds:{[l.id]:!0}},captureUpdate:N.IMMEDIATELY}}}),bL=(e,t,o)=>{let r=e.slice(),n=r.findIndex(l=>l.id===o.id);r.splice(n,1);let i=r.findIndex(l=>l.id===t.id);return r.splice(i+1,0,o),Yr(r,ie([t,o])),r},xL=(e,t,o)=>{let r=e.slice(),n=r.findIndex(l=>l.id===t.id);r.splice(n,1);let i=r.findIndex(l=>l.id===o.id);return r.splice(i,0,t),Yr(r,ie([t,o])),r},LC=G({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i=n.some(l=>ee(l)&&!mt(l));return n.length>0&&i},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t),i=e.slice(),l={};for(let a of n)if(ee(a)&&!mt(a)){let s=Ao({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...a.boundElements||[],{id:a.id,type:"text"}],angle:a.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:Gr("rectangle",t.currentItemStrokeWidthKey),strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:ci("rectangle")?At.ADAPTIVE_RADIUS:At.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:a.x-Zg,y:a.y-Zg,width:dl(a.width,"rectangle"),height:dl(a.height,"rectangle"),groupIds:a.groupIds,frameId:a.frameId});if(a.boundElements?.length){let c=a.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===a.id&&(p={...p,elementId:s.id}),u?.elementId===a.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(m,{startBinding:p,endBinding:u})})}r.scene.mutateElement(a,{containerId:s.id,verticalAlign:Zo.MIDDLE,boundElements:null,textAlign:jg.CENTER,autoResize:!0}),St(a,s,r.scene),i=xL([...i,s],s,a),l[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:l},captureUpdate:N.IMMEDIATELY}}});import EL from"clsx";import{useCallback as _C,useEffect as PC,useLayoutEffect as yL,useRef as vL,useState as wL}from"react";import{jsx as ts,jsxs as DC}from"react/jsx-runtime";var C0=380,TL=42,w0=5,RC=85,CL=500,T0=!1,Ku=new Map,NC=({element:e,scene:t,setAppState:o,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let l=t.getNonDeletedElementsMap(),a=tn(),s=xo(),c=Me(),d=e.link||"",[m,p]=wL(d),u=vL(null),b=a.showHyperlinkPopup==="editor",f=_C(()=>{if(!u.current)return;let w=Sr(u.current.value)||null;if(!e.link&&w&&Ee("hyperlink","create"),so(e)){if(a.activeEmbeddable?.element===e&&o({activeEmbeddable:null}),!w){t.mutateElement(e,{link:null}),i(e,!1);return}if(!fl(w,s.validateEmbeddable))w&&n({message:h("toast.unableToEmbed"),closable:!0}),e.link&&Ku.set(e.id,e.link),t.mutateElement(e,{link:w}),i(e,!1);else{let{width:T,height:S}=e,A=fa(w);A?.error instanceof URIError&&n({message:h("toast.unrecognizedLinkFormat"),closable:!0});let M=A?A.intrinsicSize.w/A.intrinsicSize.h:1,O=Ku.get(e.id)!==e.link;t.mutateElement(e,{...O?{width:A?.type==="video"?T>S?T:S*M:T,height:A?.type==="video"&&T>S?T/M:S}:{},link:w}),i(e,!0),Ku.has(e.id)&&Ku.delete(e.id)}}else t.mutateElement(e,{link:w})},[e,t,n,s.validateEmbeddable,a.activeEmbeddable,o,i]);yL(()=>()=>{f()},[f]),PC(()=>{b&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[b,c.formFactor,c.isTouchScreen]),PC(()=>{let w=null,T=S=>{if(b)return;w&&clearTimeout(w),SL(e,l,a,_(S.clientX,S.clientY))&&(w=window.setTimeout(()=>{o({showHyperlinkPopup:!1})},CL))};return window.addEventListener("pointermove",T,!1),()=>{window.removeEventListener("pointermove",T,!1),w&&clearTimeout(w)}},[a,e,b,o,l]);let x=_C(()=>{Ee("hyperlink","delete"),t.mutateElement(e,{link:null}),o({showHyperlinkPopup:!1})},[o,e,t]),v=()=>{Ee("hyperlink","edit","popup-ui"),o({showHyperlinkPopup:"editor"})},{x:y,y:E}=OC(e,a,l);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:DC("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${E}px`,left:`${y}px`,width:C0,padding:w0},children:[b?ts("input",{className:EL("excalidraw-hyperlinkContainer-input"),placeholder:h("labels.link.hint"),ref:u,value:m,onChange:w=>p(w.target.value),autoFocus:!0,onKeyDown:w=>{w.stopPropagation(),w[I.CTRL_OR_CMD]&&w.key===I.K&&w.preventDefault(),(w.key===I.ENTER||w.key===I.ESCAPE)&&(f(),o({showHyperlinkPopup:"info"}))}}):e.link?ts("a",{href:Sr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Mm(e.link)?"_self":"_blank",onClick:w=>{if(e.link&&r){let T=Im("excalidraw-link",w.nativeEvent);r({...e,link:Sr(e.link)},T),T.defaultPrevented&&w.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ts("div",{className:"excalidraw-hyperlinkContainer-link",children:h("labels.link.empty")}),DC("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!b&&ts(Q,{type:"button",title:h("buttons.edit"),"aria-label":h("buttons.edit"),label:h("buttons.edit"),onClick:v,className:"excalidraw-hyperlinkContainer--edit",icon:An}),ts(Q,{type:"button",title:h("labels.linkToElement"),"aria-label":h("labels.linkToElement"),label:h("labels.linkToElement"),onClick:()=>{o({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Xc}),d&&!so(e)&&ts(Q,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Kt})]})]})},OC=(e,t,o)=>{let[r,n]=Yt(e,o),{x:i,y:l}=Ft({sceneX:r+e.width/2,sceneY:n},t),a=i-t.offsetLeft-C0/2,s=l-t.offsetTop-RC;return{x:a,y:s}},I0=(e,t)=>{let o=ae(e,t);return so(o[0])?"labels.link.editEmbed":o[0]?.link?"labels.link.edit":"labels.link.create"},bd=null,FC=(e,t,o)=>{bd&&clearTimeout(bd),bd=window.setTimeout(()=>IL(e,t,o),ly)},IL=(e,t,o)=>{if(!e.link)return;let r=Ul();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=ga(e.link)?h("labels.link.goToElement"):e.link;let[n,i,l,a]=Yt(e,o),[s,c,d,m]=Jw([n,i,l,a],e.angle,t),p=Ft({sceneX:s,sceneY:c},t);h0(r,{left:p.x,top:p.y,width:d,height:m},"top"),Ee("hyperlink","tooltip","link-icon"),T0=!0},Xu=()=>{bd&&clearTimeout(bd),T0&&(T0=!1,Ul().classList.remove("excalidraw-tooltip--visible"))},SL=(e,t,o,[r,n])=>{let{x:i,y:l}=ze({clientX:r,clientY:n},o),a=15/o.zoom.value;if(Fm(_(i,l),e,t))return!1;let[s,c,d]=Yt(e,t);if(i>=s&&i<=d&&l>=c-RC&&l<=c)return!1;let{x:m,y:p}=OC(e,o,t);return!(r>=m-a&&r<=m+C0+w0*2+a&&n>=p-a&&n<=p+a+w0*2+TL)};import{jsx as kL}from"react/jsx-runtime";var os=G({name:"hyperlink",label:(e,t)=>I0(de(e),t),icon:Pl,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:N.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.K,predicate:(e,t)=>ae(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:o})=>{let r=ae(e,t);return kL(Q,{type:"toggle",icon:Pl,"aria-label":h(I0(de(e),t)),title:`${so(e[0])?h("labels.link.labelEmbed"):h("labels.link.label")} - ${H("CtrlOrCmd+K")}`,onSelect:()=>o(null),checked:r.length===1&&!!r[0].link})}});var S0=e=>e.every(t=>!t.locked),rs=G({name:"toggleElementLock",label:(e,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return S0(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,t)=>{let o=ae(t,e);return S0(o)?ya:vi},trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=S0(n),l=ie(n),a=n.length>1&&Um(n),c=n.length===1||a?null:So(),d={...t.lockedMultiSelections};if(i)d={...t.lockedMultiSelections,...c?{[c]:!0}:{}};else if(a){let v=n[0].groupIds.at(-1);delete d[v]}let m=e.map(v=>{if(!l.has(v.id))return v;let y=v.groupIds;return i?c&&(y=[...y,c]):y=y.filter(E=>!t.lockedMultiSelections[E]),se(v,{locked:i,groupIds:y.length!==v.groupIds.length?y:v.groupIds})}),p=ie(m),u=i?{}:Object.fromEntries(n.map(v=>[v.id,!0])),b=n.map(v=>p.get(v.id)||v),f=i?{}:ua(de(b),t),x=i?c||(a?n[0].groupIds.at(-1):n[0].id):null;return{elements:m,appState:{...t,selectedElementIds:u,selectedGroupIds:f,selectedLinearElement:i?null:t.selectedLinearElement,lockedMultiSelections:d,activeLockedId:x},captureUpdate:N.IMMEDIATELY}},keyTest:(e,t,o,r)=>e.key.toLocaleLowerCase()===I.L&&e[I.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),BC=G({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:vi,predicate:(e,t)=>ae(e,t).length===0&&e.some(r=>r.locked),perform:(e,t)=>{let o=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let s=a.groupIds.filter(c=>!t.lockedMultiSelections[c]);return se(a,{locked:!1,groupIds:a.groupIds.length!==s.length?s:a.groupIds})}return a}),n=ie(r),i=o.map(a=>n.get(a.id)||a),l=de(i);return{elements:r,appState:{...t,selectedElementIds:Object.fromEntries(l.map(a=>[a.id,!0])),selectedGroupIds:ua(l,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:N.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import hS from"clsx";import HP from"fuzzy";import{useEffect as gh,useRef as gS,useMemo as UP,useState as hh}from"react";import{useEffect as yd,useMemo as zC,useRef as M0,useState as ML}from"react";import{jsx as _0}from"react/jsx-runtime";var AL=8,LL=10,xd=["rectangle","diamond","ellipse"],Ed=["line","sharpArrow","curvedArrow","elbowArrow"],_L=new Set(xd),PL=new Set(Ed),is=e=>_L.has(e),Zu=e=>e==="arrow"||PL.has(e),sr=Ce(null),vd=new Map,wd=new Map,DL=({app:e})=>{let t=e.scene.getSelectedElements(e.state),o=M0(null);return yd(()=>{if(t.length===0){e.updateEditorAtom(sr,null);return}let r=as(t);r&&!o.current?o.current=r:(o.current&&!r||o.current&&r!==o.current)&&(e.updateEditorAtom(sr,null),o.current=null)},[t,e]),yd(()=>()=>{vd.clear(),wd.clear()},[]),_0(RL,{app:e,elements:t})},RL=({app:e,elements:t})=>{let o=as(t),r=zC(()=>o==="generic"?WC(t):[],[o,t]),n=zC(()=>o==="linear"?L0(t):[],[o,t]),i=o==="generic"?r.every(m=>m.type===r[0].type):o==="linear"?n.every(m=>ma(m)===ma(n[0])):!1,[l,a]=ML({x:0,y:0}),s=M0(""),c=M0(null);yd(()=>{let m=[...r,...n].sort((x,v)=>x.id.localeCompare(v.id)),p=`
|
|
5
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(m.length===1){let[x,,,v,y,E]=Yt(m[0],e.scene.getNonDeletedElementsMap());u=ke(_(x,v),_(y,E),m[0].angle)}else{let{minX:x,maxY:v}=In(m);u=_(x,v)}let{x:b,y:f}=Ft({sceneX:u[0],sceneY:u[1]},e.state);a({x:b,y:f})},[r,n,e.scene,e.state]),yd(()=>{for(let m of n){let p=A0(m.id,zL(m));wd.has(p)||wd.set(p,m)}},[n]),yd(()=>{for(let m of r)if(!vd.has(m.id)){let p=ve(m,e.scene.getNonDeletedElementsMap());p&&vd.set(m.id,{fontSize:p.fontSize})}},[r,e.scene]);let d=o==="linear"?[["line",va],["sharpArrow",Pn],["curvedArrow",Rn],["elbowArrow",Dn]]:o==="generic"?[["rectangle",Nc],["diamond",Oc],["ellipse",Fc]]:[];return _0("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${l.y+(LL+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${l.x-e.state.offsetLeft-AL}px`,zIndex:2},className:et.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(o==="generic"&&r[0].type===m||o==="linear"&&ma(n[0])===m);return _0(Q,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ee("convertElementType",m,"ui"),P0(e,{conversionType:o,nextType:m}),c.current?.focus())}},`${t[0].id}${t[0].version}_${m}`)})})},NL=(e,t,o)=>{let r=pc(e,t),n=Om(e,t),i=wn(t.text,dt(t),r),l=lt(i,dt(t),t.lineHeight),a=t.fontSize;for(;(l.width>r||l.height>n)&&a>0;){a-=1;let s={...t,fontSize:a};l=lt(t.text,dt(s),t.lineHeight)}co(t,o.getNonDeletedElementsMap(),{fontSize:a,width:l.width,height:l.height}),St(t,e,o)},P0=(e,{conversionType:t,nextType:o,direction:r="right"})=>{if(!t)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((a,s)=>({...a,[s.id]:!0}),{}),l=r==="right"?1:-1;if(t==="generic"){let a=WC(n),c=a.every(d=>d.type===a[0].type)?xd.indexOf(a[0].type):-1;if(o=o??xd[(c+xd.length+l)%xd.length],o&&is(o)){let d={};for(let p of a){let u=UC(p,o,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=ve(p,e.scene.getNonDeletedElementsMap());u&&(vd.get(p.id)&&co(u,e.scene.getNonDeletedElementsMap(),{fontSize:vd.get(p.id)?.fontSize??u.fontSize}),NL(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:ft(p,{type:"selection"})}))}}if(t==="linear"){let a=L0(n);if(!o){let c=km(a,ma),d=c?Ed.indexOf(c):-1;o=Ed[(d+Ed.length+l)%Ed.length]}if(Zu(o)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of a){let p=wd.get(A0(m.id,o));if(p&&ma(p)===o)d.set(p.id,p),c.push(p);else{let u=UC(m,o,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Se(m))if(Re(m)){let p=OL(m);if(p.length<2)continue;let u=[];for(let f=1;f<p.length-2;f++)u.push({start:p[f],end:p[f+1],index:f+1});let b=Bm(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});co(m,e.scene.getNonDeletedElementsMap(),{...b,endArrowhead:"arrow"})}else{let p=Oy(["line","sharpArrow","curvedArrow"],u=>wd.get(A0(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let s=L0(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new Z(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ft(c,{type:"selection"})}))}return!0},as=e=>{if(e.length===0)return null;let t=!1;for(let o of e){if(is(o.type))return"generic";GC(o)&&(t=!0)}return t?"linear":null},GC=e=>Se(e)&&(!Te(e)||!ev(e)&&!Ht(e)),A0=(e,t)=>`${e}:${t}`,WC=e=>e.filter(t=>is(t.type)),L0=e=>e.filter(t=>GC(t)),$u=20,ns=(e,t)=>e[0]===t[0],k0=(e,t)=>e[1]===t[1],HC=(e,t)=>ns(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),OL=e=>{let t=[e.points[0]],o=FL(e.points);for(let i=1;i<o.length;++i){let l=t[t.length-1],a=[...o[i]];Math.abs(a[0]-l[0])<$u?a[0]=l[0]:Math.abs(a[1]-l[1])<$u&&(a[1]=l[1]),ns(l,a)||k0(l,a)||t.push(_(l[0],a[1])),t.push(a)}let r=[t[0]];for(let i=1;i<t.length-1;++i)ns(t[i-1],t[i])&&ns(t[i],t[i+1])||k0(t[i-1],t[i])&&k0(t[i],t[i+1])||r.push(t[i]);r.push(t[t.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let l=n[n.length-1],a=r[i],s=r[i+1],c=ns(l,a),d=ns(a,s);if(c!==d){let m=HC(l,a),p=HC(a,s);if(m<$u||p<$u){if(p<m)c?s[0]=l[0]:s[1]=l[1];else if(d)for(let u=n.length-1;u>=0&&n[u][0]===l[0];--u)n[u][0]=a[0];else for(let u=n.length-1;u>=0&&n[u][1]===l[1];--u)n[u][1]=a[1];continue}}n.push(a)}return n.push(r[r.length-1]),n},FL=e=>{if(e.length===0)return[];let t=[e[0]];for(let o=1;o<e.length;o++){let[r,n]=t[t.length-1],[i,l]=e[o];(r!==i||n!==l)&&t.push(e[o])}return t},UC=(e,t,o)=>{if(!BL(e.type,t)){if(!Gy())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(tr.delete(e),is(t)){let r=Tn(Ao({...e,type:t,roundness:e.roundness?{type:ci(t)?At.ADAPTIVE_RADIUS:At.PROPORTIONAL_RADIUS}:e.roundness}));return hi(r,o.scene,o.state),r}if(Zu(t))switch(t){case"line":return Tn(to({...e,type:"line"}));case"sharpArrow":return Tn(bi({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"curvedArrow":return Tn(bi({...e,type:"arrow",elbowed:!1,roundness:{type:At.PROPORTIONAL_RADIUS},startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"elbowArrow":return Tn(bi({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return Vy(t,`unhandled conversion type: ${t}`),e},BL=(e,t)=>!!(is(e)&&is(t)||Zu(e)&&Zu(t)),zL=e=>Se(e)?ma(e):e.type,VC=DL;var YC=G({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,t,o,r){return bt.set(sr,{type:"panel"}),{captureUpdate:N.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>as(e)!==null});var ju=G({name:"copyElementLink",label:"labels.copyElementLink",icon:Ca,trackEvent:{category:"element"},perform:async(e,t,o,r)=>{let n=ae(e,t);try{if(window.location){let i=tp(n,t);return i?(await _r(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):ep(i.id,i.type)),{appState:{toast:{message:h("toast.elementLinkCopied"),closable:!0}},captureUpdate:N.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:N.EVENTUALLY}}}catch(i){console.error(i)}return{appState:t,elements:e,app:r,captureUpdate:N.EVENTUALLY}},predicate:(e,t)=>op(ae(e,t))}),KC=G({name:"linkToElement",label:"labels.linkToElement",icon:Xc,perform:(e,t,o,r)=>{let n=ae(e,t);return n.length!==1||!op(n)?{elements:e,appState:t,app:r,captureUpdate:N.EVENTUALLY}:{appState:{...t,openDialog:{name:"elementLinkSelector",sourceElementId:ae(e,t)[0].id}},captureUpdate:N.IMMEDIATELY}},predicate:(e,t,o,r)=>{let n=ae(e,t);return t.openDialog?.name!=="elementLinkSelector"&&n.length===1&&op(n)},trackEvent:!1});var HL={toggleTheme:[H("Shift+Alt+D")],saveScene:[H("CtrlOrCmd+S")],loadScene:[H("CtrlOrCmd+O")],clearCanvas:[H("CtrlOrCmd+Delete")],imageExport:[H("CtrlOrCmd+Shift+E")],commandPalette:[H("CtrlOrCmd+/"),H("CtrlOrCmd+Shift+P")],cut:[H("CtrlOrCmd+X")],copy:[H("CtrlOrCmd+C")],paste:[H("CtrlOrCmd+V")],copyStyles:[H("CtrlOrCmd+Alt+C")],pasteStyles:[H("CtrlOrCmd+Alt+V")],selectAll:[H("CtrlOrCmd+A")],deleteSelectedElements:[H("Delete")],duplicateSelection:[H("CtrlOrCmd+D"),H(`Alt+${h("helpDialog.drag")}`)],sendBackward:[H("CtrlOrCmd+[")],bringForward:[H("CtrlOrCmd+]")],sendToBack:[Io?H("CtrlOrCmd+Alt+["):H("CtrlOrCmd+Shift+[")],bringToFront:[Io?H("CtrlOrCmd+Alt+]"):H("CtrlOrCmd+Shift+]")],copyAsPng:[H("Shift+Alt+C")],group:[H("CtrlOrCmd+G")],ungroup:[H("CtrlOrCmd+Shift+G")],gridMode:[H("CtrlOrCmd+'")],zenMode:[H("Alt+Z")],objectsSnapMode:[H("Alt+S")],stats:[H("Alt+/")],addToLibrary:[],flipHorizontal:[H("Shift+H")],flipVertical:[H("Shift+V")],viewMode:[H("Alt+R")],hyperlink:[H("CtrlOrCmd+K")],toggleElementLock:[H("CtrlOrCmd+Shift+L")],resetZoom:[H("CtrlOrCmd+0")],zoomOut:[H("CtrlOrCmd+-")],zoomIn:[H("CtrlOrCmd++")],zoomToFitSelection:[H("Shift+3")],zoomToFit:[H("Shift+1")],zoomToFitSelectionInViewport:[H("Shift+2")],saveFileToDisk:[H("CtrlOrCmd+S")],saveToActiveFile:[H("CtrlOrCmd+S")],toggleShortcuts:[H("?")],searchMenu:[H("CtrlOrCmd+F")],wrapSelectionInFrame:[],toolLock:[H("Q")]},rt=(e,t=0)=>{let o=HL[e];return o&&o.length>0?o[t]||o[0]:""};var UL="\\u0300-\\u036f",GL="\\ufe20-\\ufe2f",WL="\\u20d0-\\u20ff",VL=UL+GL+WL,YL=`[${VL}]`,KL=RegExp(YL,"g"),XL=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$L={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},Oa=e=>e.replace(XL,t=>$L[t]||t).replace(KL,"");import LP from"clsx";import{useEffect as _P,useState as PP}from"react";import{useCallback as ZL,useState as jL}from"react";var XC=()=>{let[e,t]=jL(null),o=ZL(r=>t(r),[]);return[e,o]};import{useState as YI,useCallback as Z0,useMemo as KI,useEffect as j0,memo as XI,useRef as TP}from"react";import{useEffect as qC,useRef as JC}from"react";var ls=async({data:e,config:t})=>Tl({data:e,config:t}),$C=async({data:e,config:t})=>{let{mimeType:o=pe.png,quality:r}=t||{};o===pe.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${pe.png}" mimeType`),o==="image/jpg"&&(o=pe.jpg),o===pe.jpg&&t?.canvasBackgroundColor===!1&&(console.warn(`Defaulting "exportBackground" to "true" for "${pe.jpg}" mimeType`),t={...t,canvasBackgroundColor:e.appState?.viewBackgroundColor||Ho});let n=await Tl({data:e,config:t});return r=r||(/image\/jpe?g/.test(o)?.92:.8),new Promise((i,l)=>{n.toBlob(async a=>{if(!a)return l(new Error("couldn't export to blob"));a&&o===pe.png&&e.appState?.exportEmbedScene&&(a=await r2({blob:a,metadata:Mc(e.elements,e.appState,e.files||{},"local")})),i(a)},o,r)})},ss=async({data:e,config:t})=>{let o=wl(e.elements,null,{deleteInvisibleElements:!0}),n={..._c(e.appState,null),exportPadding:t?.padding},i=de(o),l=e.files||{};return xa({data:{elements:i,appState:n,files:l},config:{exportingFrame:t?.exportingFrame,renderEmbeddables:t?.renderEmbeddables,skipInliningFonts:t?.skipInliningFonts,reuseImages:t?.reuseImages}})},qL=async({type:e,data:t,config:o})=>{if(e==="svg"){let r=await ss({data:t,config:o});await _r(r.outerHTML)}else if(e==="png")await _u($C({data:t,config:o}));else if(e==="json")await Au(t.elements,t.files);else throw new Error("Invalid export type")};import{useEffect as ZC,useState as JL}from"react";var D0=Ce(new Map),jC=async e=>await ss({data:{elements:e,appState:{exportBackground:!1,viewBackgroundColor:Co.white},files:null},config:{renderEmbeddables:!1,skipInliningFonts:!0}}),qu=(e,t,o,r)=>{let[n,i]=JL();return ZC(()=>{if(t)if(e){let l=o.get(e);l?i(l):(async()=>{let a=await jC(t);a.querySelector(".style-fonts")?.remove(),a&&(o.set(e,a),i(a))})()}else(async()=>{let l=await jC(t);i(l)})()},[e,t,o,i]),ZC(()=>{let l=r.current;if(l)return n&&(l.innerHTML=n.outerHTML),()=>{l.innerHTML=""}},[n,r]),n},cs=()=>{let[e]=ne(D0);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var QL=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],eI=new Jo,sn=Ce({status:"loaded",isInitialized:!1,libraryItems:[]}),Td=e=>Ir(e),e_=(e,t)=>!e.find(o=>o.elements.length!==t.elements.length?!1:o.elements.every((r,n)=>r.id===t.elements[n].id&&r.versionNonce===t.elements[n].versionNonce)),tI=(e,t)=>{let o=[];for(let r of t)e_(e,r)&&o.push(r);return[...o,...e]},oI=(e,t)=>{let o=ie(t),r={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)o.has(i.id)||r.deletedItems.set(i.id,i);let n=ie(e);for(let i of t){let l=n.get(i.id);l?O0(l)!==O0(i)&&r.updatedItems.set(i.id,i):r.addedItems.set(i.id,i)}return r},R0=class{constructor(t){C(this,"currLibraryItems",[]);C(this,"prevLibraryItems",Td(this.currLibraryItems));C(this,"app");C(this,"updateQueue",[]);C(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);C(this,"notifyListeners",()=>{if(this.updateQueue.length>0)bt.set(sn,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{bt.set(sn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=Td(this.currLibraryItems);let o=Td(this.currLibraryItems);this.app.props.onLibraryChange?.(o),eI.trigger(oI(t,o),o)}catch(t){console.error(t)}}});C(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],bt.set(D0,new Map)});C(this,"resetLibrary",()=>this.setLibrary([]));C(this,"getLatestLibrary",()=>new Promise(async t=>{try{let o=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(Td(o))}catch{return t(this.currLibraryItems)}}));C(this,"updateLibrary",async({libraryItems:t,prompt:o=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:ao.name,tab:ec}}),this.setLibrary(()=>new Promise(async(l,a)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;s instanceof Blob?c=await Vf(s,i):c=Pc(s,i),!o||window.confirm(h("alerts.confirmAddLibrary",{numShapes:c.length}))?(o&&this.app.focusContainer(),l(r?tI(this.currLibraryItems,c):c)):a(new yl)}catch(s){a(s)}}))));C(this,"setLibrary",t=>{let o=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=Td(await t),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==o),this.notifyListeners()});return this.updateQueue.push(o),this.notifyListeners(),o});this.app=t}},rI=R0,ms=e=>{let o=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*o,u*o+o).reduce((f,x)=>{let{height:v}=In(x.elements);return Math.max(f,v)},0),i=u=>{let b=0,f=0,x=0;for(let v of e){if(b%o===0&&(f=0),f===u){let{width:y}=In(v.elements);x=Math.max(x,y)}b++,f++}return x},l=0,a=0,s=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%o===0&&(a+=s+50,l=0,m=0,p++),m===0&&(s=n(p)),c=i(m);let{minX:b,minY:f,width:x,height:v}=In(u.elements),y=(c-x)/2,E=(s-v)/2;r.push(...u.elements.map(w=>({...w,x:w.x+l+y-b,y:w.y+a+E-f}))),l+=c+50,d++,m++}return r},t_=(e,t=QL)=>{if(typeof t=="function"?t(e):t.some(o=>{let r=new URL(`https://${o.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},N0=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(hm.addLibrary)||new URLSearchParams(window.location.search).get(um.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},Ni=class Ni{constructor(t){C(this,"adapter");this.adapter=t}static async getLibraryItems(t,o,r=!0){let n=()=>new Promise(async(i,l)=>{try{let a=await t.load({source:o});i(Pc(a?.libraryItems||[],"published"))}catch(a){l(a)}});return r?Ni.queue.push(n):n()}getLibraryItems(t){return Ni.getLibraryItems(this.adapter,t,!1)}};C(Ni,"queue",new Ty),C(Ni,"run",async(t,o)=>{let r=new Ni(t);return Ni.queue.push(()=>o(r))});var ds=Ni,Cd=0,Ju=0,O0=e=>`${e.id}:${e.name||""}:${Nf(e.elements)}`,Qu=e=>Of(e.map(t=>O0(t)).sort().join()),QC=async(e,t)=>{try{return Ju++,await ds.run(e,async o=>{let r=ie(await o.getLibraryItems("save"));for(let[a]of t.deletedItems)r.delete(a);let n=[];for(let[a,s]of t.addedItems)r.has(a)?r.set(a,s):n.push(s);if(t.updatedItems)for(let[a,s]of t.updatedItems)r.set(a,s);let i=n.concat(Array.from(r.values())),l=Qu(i);return l!==Cd&&await e.save({libraryItems:i}),Cd=l,i})}finally{Ju--}},o_=e=>{let{excalidrawAPI:t}=e,o=JC(e);o.current=e;let r=JC(!1);qC(()=>{if(!t)return;r.current=!1;let n=async({libraryUrl:a,idToken:s})=>{let c=new Promise(async(m,p)=>{try{a=decodeURIComponent(a),a=Am(a),t_(a,o.current.validateLibraryUrl);let b=await(await fetch(a)).blob();m(b)}catch(u){p(u)}}),d=s!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw t.updateScene({appState:{errorMessage:m.message}}),m}finally{if(window.location.hash.includes(hm.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(hm.addLibrary),window.history.replaceState({},js,`#${m.toString()}`)}else if(window.location.search.includes(um.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(um.addLibrary),window.history.replaceState({},js,`?${m.toString()}`)}}},i=a=>{a.preventDefault();let s=N0();s&&(a.stopImmediatePropagation(),window.history.replaceState({},"",a.oldURL),n(s))},l=N0();if(l&&n(l),"getInitialLibraryItems"in o.current&&o.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(o.current.getInitialLibraryItems()).then(a=>{t.updateLibrary({libraryItems:a,merge:!0})}).catch(a=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${a?.message}`)})),"adapter"in o.current&&o.current.adapter){let a=o.current.adapter,s=o.current.migrationAdapter,c=Fy();s?c.resolve(af(s.load).then(async d=>{let m=null;try{if(!d)return ds.getLibraryItems(a,"load");m=Pc(d.libraryItems||[],"published");let p=await QC(a,oI([],m));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),ds.getLibraryItems(a,"load")))):c.resolve(af(ds.getLibraryItems,a,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return Cd=Qu(m),m}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[t]),qC(()=>{let n=eI.on(async(l,a)=>{let s=r.current,c="adapter"in o.current&&o.current.adapter||null;try{c&&Cd!==Qu(a)&&await QC(c,l)}catch(d){console.error(`couldn't persist library update: ${d.message}`,l),s&&o.current.excalidrawAPI&&o.current.excalidrawAPI.updateScene({appState:{errorMessage:h("errors.saveLibraryError")}})}}),i=l=>{Ju&&Hy(l)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Cd=0,Ju=0}},[])};import i_ from"clsx";import{jsx as n_}from"react/jsx-runtime";var r_=({theme:e,id:t,libraryReturnUrl:o})=>{let r=o||window.location.origin+window.location.pathname;return n_("a",{className:"library-menu-browse-button",href:`${k.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${fm.excalidrawLibrary}`,target:"_excalidraw_libraries",children:h("labels.libraries")})},nI=r_;import{jsx as a_,jsxs as l_}from"react/jsx-runtime";var eh=({libraryReturnUrl:e,theme:t,id:o,style:r,children:n,className:i})=>l_("div",{className:i_("library-menu-control-buttons",i),style:r,children:[a_(nI,{id:o,libraryReturnUrl:e,theme:t}),n]});import{useCallback as hs,useEffect as Y0,useMemo as K0,useRef as HI,useState as UI}from"react";import yP from"clsx";import s_ from"lodash.throttle";import{useEffect as c_}from"react";var d_=Ce(0),iI=e=>{let[t,o]=ne(d_);return c_(()=>{let{current:r}=e;if(!r)return;let n=s_(()=>{let{scrollTop:i}=r;o(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,o]),t};import J_ from"clsx";import{useCallback as Q_,useState as G0}from"react";import{flushSync as aI}from"react-dom";import m_ from"clsx";import{jsx as th,jsxs as u_}from"react/jsx-runtime";var p_=({label:e,onClick:t,className:o,children:r,actionType:n,type:i="button",isLoading:l,...a})=>{let s=n?`Dialog__action-button--${n}`:"";return u_("button",{className:m_("Dialog__action-button",s,o),type:i,"aria-label":e,onClick:t,...a,children:[r&&th("div",{style:l?{visibility:"hidden"}:{},children:r}),th("div",{style:l?{visibility:"hidden"}:{},children:e}),l&&th("div",{style:{position:"absolute",inset:0},children:th(Pt,{})})]})},Un=p_;import{jsx as lI,jsxs as sI}from"react/jsx-runtime";var h_=e=>{let{onConfirm:t,onCancel:o,children:r,confirmText:n=h("buttons.confirm"),cancelText:i=h("buttons.cancel"),className:l="",...a}=e,s=Ie(),c=qr(ps),{container:d}=Je();return sI(Mt,{onCloseRequest:o,size:"small",...a,className:`confirm-dialog ${l}`,children:[r,sI("div",{className:"confirm-dialog-buttons",children:[lI(Un,{label:i,onClick:()=>{s({openMenu:null}),c(!1),aI(()=>{o()}),d?.focus()}}),lI(Un,{label:n,onClick:()=>{s({openMenu:null}),c(!1),aI(()=>{t()}),d?.focus()},actionType:"danger"})]})]})},oh=h_;import{useCallback as v_,useEffect as B0,useRef as cI,useState as F0}from"react";var cr=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),!1}}static get(t){try{let o=window.localStorage.getItem(t);return o?JSON.parse(o):null}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),null}}};C(cr,"set",(t,o)=>{try{return window.localStorage.setItem(t,JSON.stringify(o)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),C(cr,"delete",t=>{try{window.localStorage.removeItem(t)}catch(o){console.warn(`localStorage.removeItem error: ${o.message}`)}});import rh from"react";var g_=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,f_=/{{([\w-]+)}}/,b_=/<([\w-]+)>/,x_=/<\/([\w-]+)>/,E_=(e,t)=>{let o=[{name:"",children:[]}];return e.split(g_).filter(Boolean).forEach(r=>{let n=r.match(b_),i=r.match(x_),l=r.match(f_);if(n!==null){let a=n[1];t.hasOwnProperty(a)?o.push({name:a,children:[]}):console.warn(`Trans: missed to pass in prop ${a} for interpolating ${e}`)}else if(i!==null)if(i[1]===o[o.length-1].name){let s=o.pop(),c=rh.createElement(rh.Fragment,{},...s.children),d=t[s.name];typeof d=="function"&&o[o.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(l!==null){let a=l[1];t.hasOwnProperty(a)?o[o.length-1].children.push(t[a]):console.warn(`Trans: key ${a} not in props for interpolating ${e}`)}else o[o.length-1].children.push(r)}),o.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),o[0].children},y_=({i18nKey:e,children:t,...o})=>{let{t:r}=Ue();return rh.createElement(rh.Fragment,{},...E_(r(e),o))},yo=y_;import{jsx as Ae,jsxs as po}from"react/jsx-runtime";var w_=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=Ry(e,6),l=document.createElement("canvas");l.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,l.height=i.length*128+(i.length+1)*(r*2)-r*2;let a=l.getContext("2d");a.fillStyle=Ho,a.fillRect(0,0,l.width,l.height);for(let[s,c]of e.entries()){let d=await ls({data:{elements:c.elements,files:null},config:{maxWidthOrHeight:128}}),{width:m,height:p}=d,u=Math.floor(s/6)*(128+r*2),b=s%6*(128+r*2);a.drawImage(d,b+(128-m)/2+r,u+(128-p)/2+r),a.lineWidth=n,a.strokeStyle="#ced4da",a.strokeRect(b+r/2,u+r/2,128+r,128+r)}return await pp(new File([await Ea(l)],"preview",{type:pe.png}),{outputType:pe.jpg,maxWidthOrHeight:5e3})},T_=({libItem:e,appState:t,index:o,onChange:r,onRemove:n})=>{let i=cI(null),l=cI(null);return B0(()=>{let a=i.current;a&&(async()=>{let s=await ss({data:{elements:e.elements,appState:{...t,viewBackgroundColor:Ho,exportBackground:!0},files:null},config:{skipInliningFonts:!0}});a.innerHTML=s.outerHTML})()},[e.elements,t]),po("div",{className:"single-library-item",children:[e.status==="published"&&Ae("span",{className:"single-library-item-status",children:h("labels.statusPublished")}),Ae("div",{ref:i,className:"single-library-item__svg"}),Ae(Q,{"aria-label":h("buttons.remove"),type:"button",icon:Go,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:h("buttons.remove")}),po("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[po("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[po("div",{style:{padding:"0.5em 0"},children:[Ae("span",{style:{fontWeight:500,color:"#868e96"},children:h("publishDialog.itemName")}),Ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ae("input",{type:"text",ref:l,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:a=>{r(a.target.value,o)}})]}),Ae("span",{className:"error",children:e.error})]})]})},C_=({onClose:e,libraryItems:t,appState:o,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:l})=>{let[a,s]=F0({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=F0(!1);B0(()=>{let E=cr.get(oi.PUBLISH_LIBRARY);E&&s(E)},[]);let[m,p]=F0(t.slice());B0(()=>{p(t.slice())},[t]);let u=E=>{s({...a,[E.target.name]:E.target.value})},b=async E=>{E.preventDefault(),d(!0);let w=[],T=!1;if(m.forEach(L=>{let D="";L.name||(D=h("publishDialog.errors.required"),T=!0),w.push({...L,error:D})}),T){p(w),d(!1);return}let S=await w_(m),A={type:ei.excalidrawLibrary,version:fm.excalidrawLibrary,source:oy(),libraryItems:m},M=JSON.stringify(A,null,2),O=new Blob([M],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",O),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",a.name),P.append("authorName",a.authorName),P.append("githubHandle",a.githubHandle),P.append("name",a.name),P.append("description",a.description),P.append("twitterHandle",a.twitterHandle),P.append("website",a.website),fetch(`${k.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(L=>L.ok?L.json().then(({url:D})=>{cr.delete(oi.PUBLISH_LIBRARY),r({url:D,authorName:a.authorName,items:m})}):L.json().catch(()=>{throw new Error(L.statusText||"something went wrong")}).then(D=>{throw new Error(D.message||L.statusText||"something went wrong")}),L=>{console.error(L),n(L),d(!1)}).catch(L=>{console.error(L),n(L),d(!1)})},f=()=>{let E=[];return m.forEach((w,T)=>{E.push(Ae("div",{className:"single-library-item-wrapper",children:Ae(T_,{libItem:w,appState:o,index:T,onChange:(S,A)=>{let M=m.slice();M[A].name=S,p(M)},onRemove:l})},T))}),Ae("div",{className:"selected-library-items",children:E})},x=v_(()=>{i(m),cr.set(oi.PUBLISH_LIBRARY,a),e()},[m,e,i,a]),v=!!t.length,y=t.some(E=>E.status==="published");return Ae(Mt,{onCloseRequest:x,title:h("publishDialog.title"),className:"publish-library",children:v?po("form",{onSubmit:b,children:[Ae("div",{className:"publish-library-note",children:Ae(yo,{i18nKey:"publishDialog.noteDescription",link:E=>Ae("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:E})})}),Ae("span",{className:"publish-library-note",children:Ae(yo,{i18nKey:"publishDialog.noteGuidelines",link:E=>Ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:E})})}),Ae("div",{className:"publish-library-note",children:h("publishDialog.noteItems")}),y&&Ae("span",{className:"publish-library-note publish-library-warning",children:h("publishDialog.republishWarning")}),f(),po("div",{className:"publish-library__fields",children:[po("label",{children:[po("div",{children:[Ae("span",{children:h("publishDialog.libraryName")}),Ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ae("input",{type:"text",name:"name",required:!0,value:a.name,onChange:u,placeholder:h("publishDialog.placeholder.libraryName")})]}),po("label",{style:{alignItems:"flex-start"},children:[po("div",{children:[Ae("span",{children:h("publishDialog.libraryDesc")}),Ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ae("textarea",{name:"description",rows:4,required:!0,value:a.description,onChange:u,placeholder:h("publishDialog.placeholder.libraryDesc")})]}),po("label",{children:[po("div",{children:[Ae("span",{children:h("publishDialog.authorName")}),Ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ae("input",{type:"text",name:"authorName",required:!0,value:a.authorName,onChange:u,placeholder:h("publishDialog.placeholder.authorName")})]}),po("label",{children:[Ae("span",{children:h("publishDialog.githubUsername")}),Ae("input",{type:"text",name:"githubHandle",value:a.githubHandle,onChange:u,placeholder:h("publishDialog.placeholder.githubHandle")})]}),po("label",{children:[Ae("span",{children:h("publishDialog.twitterUsername")}),Ae("input",{type:"text",name:"twitterHandle",value:a.twitterHandle,onChange:u,placeholder:h("publishDialog.placeholder.twitterHandle")})]}),po("label",{children:[Ae("span",{children:h("publishDialog.website")}),Ae("input",{type:"text",name:"website",pattern:"https?://.+",title:h("publishDialog.errors.website"),value:a.website,onChange:u,placeholder:h("publishDialog.placeholder.website")})]}),Ae("span",{className:"publish-library-note",children:Ae(yo,{i18nKey:"publishDialog.noteLicense",link:E=>Ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:E})})})]}),po("div",{className:"publish-library__buttons",children:[Ae(Un,{label:h("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),Ae(Un,{type:"submit",label:h("buttons.submit"),actionType:"primary",isLoading:c})]})]}):Ae("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:h("publishDialog.atleastOneLibItem")})})},dI=C_;import DI from"react";import{DropdownMenu as Z_}from"radix-ui";import k_ from"clsx";import{useCallback as M_,useEffect as A_,useRef as L_}from"react";import{DropdownMenu as __}from"radix-ui";import{forwardRef as mI}from"react";import pI from"clsx";import{jsx as uI}from"react/jsx-runtime";var I_=mI(({children:e,gap:t,align:o,justifyContent:r,className:n,style:i},l)=>uI("div",{className:pI("Stack Stack_horizontal",n),style:{"--gap":t,alignItems:o,justifyContent:r,...i},ref:l,children:e})),S_=mI(({children:e,gap:t,align:o,justifyContent:r,className:n,style:i},l)=>uI("div",{className:pI("Stack Stack_vertical",n),style:{"--gap":t,justifyItems:o,justifyContent:r,...i},ref:l,children:e})),ro={Row:I_,Col:S_};import{jsx as nh}from"react/jsx-runtime";var hI=({children:e,onClickOutside:t,className:o="",onSelect:r,open:n=!0,align:i="end",style:l})=>{let a=Me(),s=L_(null),c=Si({onClickOutside:t});Ol(s,M_(m=>{s.current?.closest(`.${et.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),A_(()=>{if(!n)return;let m=u=>{u.key===I.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener("keydown",m,p),()=>{document.removeEventListener("keydown",m,p)}},[c,n]);let d=k_(`dropdown-menu ${o}`,{"dropdown-menu--mobile":a.formFactor==="phone"}).trim();return nh(o0.Provider,{value:{onSelect:r},children:nh(__.Content,{ref:s,className:d,style:l,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:a.formFactor==="phone"?nh(ro.Col,{className:"dropdown-menu-container",children:e}):nh(yt,{className:"dropdown-menu-container",padding:2,children:e})})})};hI.displayName="DropdownMenuContent";var gI=hI;import{jsx as D_}from"react/jsx-runtime";var P_=({children:e,className:t="",selected:o,...r})=>D_("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${o?"dropdown-menu-item--selected":""}`.trim(),children:e}),fI=P_;import{DropdownMenu as R_}from"radix-ui";import{jsx as z0}from"react/jsx-runtime";var bI=({icon:e,shortcut:t,href:o,children:r,onSelect:n,className:i="",selected:l,rel:a="noopener",...s})=>{let c=cu(n);return z0(R_.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:z0("a",{...s,href:o,target:"_blank",rel:`noopener ${a}`,className:Li(i,l),title:s.title??s["aria-label"],children:z0(_i,{icon:e,shortcut:t,children:r})})})},us=bI;bI.displayName="DropdownMenuItemLink";import{jsx as N_}from"react/jsx-runtime";var xI=()=>N_("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),EI=xI;xI.displayName="DropdownMenuSeparator";import{DropdownMenu as G_}from"radix-ui";import O_ from"clsx";import{DropdownMenu as F_}from"radix-ui";import{useCallback as B_,useState as yI}from"react";import{jsx as U0}from"react/jsx-runtime";var H0=-4,z_=4,vI=({children:e,className:t})=>{let o=Me(),r=O_(`dropdown-menu dropdown-submenu ${t}`,{"dropdown-menu--mobile":o.formFactor==="phone"}).trim(),n=B_(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,b=window.innerWidth-m.right;b<p+20&&(l(b-p+H0),s(H0+8))}}},[]),[i,l]=yI(z_),[a,s]=yI(H0);return U0(F_.SubContent,{className:r,sideOffset:i,alignOffset:a,collisionPadding:8,ref:n,children:o.formFactor==="phone"?U0(ro.Col,{className:"dropdown-menu-container",children:e}):U0(yt,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},wI=vI;vI.displayName="DropdownMenuSubContent";import{DropdownMenu as H_}from"radix-ui";import{jsx as TI,jsxs as U_}from"react/jsx-runtime";var CI=({children:e,icon:t,shortcut:o,className:r})=>U_(H_.SubTrigger,{className:`${Li(r)} dropdown-menu__submenu-trigger`,children:[TI(_i,{icon:t,shortcut:o,children:e}),TI("div",{className:"dropdown-menu__submenu-trigger-icon",children:H1})]}),II=CI;CI.displayName="DropdownMenuSubTrigger";import SI from"react";var ih=e=>t=>{let o=SI.Children.toArray(t).find(r=>SI.isValidElement(r)&&typeof r.type!="string"&&r?.type.displayName&&r.type.displayName===e);return o||null},kI=ih("DropdownMenuTrigger"),MI=ih("DropdownMenuContent"),AI=ih("DropdownMenuSubTrigger"),LI=ih("DropdownMenuSubContent");import{jsxs as W_}from"react/jsx-runtime";var ah=({children:e})=>{let t=AI(e),o=LI(e);return W_(G_.Sub,{children:[t,o]})};ah.Trigger=II;ah.Content=wI;ah.displayName="DropdownMenuSub";var Oi=ah;import V_ from"clsx";import{DropdownMenu as Y_}from"radix-ui";import{jsx as K_}from"react/jsx-runtime";var _I=({className:e="",children:t,onToggle:o,title:r,...n})=>{let i=Me(),l=V_(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return K_(Y_.Trigger,{className:l,onClick:o,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:t})},PI=_I;_I.displayName="DropdownMenuTrigger";import{jsx as $_}from"react/jsx-runtime";var X_=e=>$_(bo,{...e,icon:e.checked?zc:$c}),Pr=X_;import{jsx as q_,jsxs as j_}from"react/jsx-runtime";var Dr=({children:e,open:t})=>{let o=kI(e),r=MI(e),n=r&&DI.isValidElement(r)?DI.cloneElement(r,{open:t}):r;return q_(Z_.Root,{open:t,modal:!1,children:j_("div",{className:et.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[o,n]})})};Dr.Trigger=PI;Dr.Content=gI;Dr.Item=bo;Dr.ItemCheckbox=Pr;Dr.ItemLink=us;Dr.ItemCustom=fI;Dr.Group=od;Dr.Separator=EI;Dr.Sub=Oi;var ue=Dr;Dr.displayName="DropdownMenu";import{jsx as Ro,jsxs as lh}from"react/jsx-runtime";var eP=(e,t)=>e.filter(o=>t.includes(o.id)),tP=({setAppState:e,selectedItems:t,library:o,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:l,className:a})=>{let[s]=ne(sn),[c,d]=ne(ps),m=()=>{let P=t.length?h("alerts.removeItemsFromsLibrary",{count:t.length}):h("alerts.resetLibrary"),L=t.length?h("confirmDialog.removeItemsFromLib"):h("confirmDialog.resetLibrary");return Ro(oh,{onConfirm:()=>{t.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:L,children:Ro("p",{children:P})})},[p,u]=G0(!1),b=!!t.length,f=b?s.libraryItems.filter(P=>t.includes(P.id)):s.libraryItems,x=b?h("buttons.remove"):h("buttons.resetLibrary"),[v,y]=G0(!1),[E,w]=G0(null),T=Q_(()=>lh(Mt,{onCloseRequest:()=>w(null),title:h("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Ro("p",{children:Ro(yo,{i18nKey:"publishSuccessDialog.content",authorName:E.authorName,link:P=>Ro("a",{href:E?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),Ro(Q,{type:"button",title:h("buttons.close"),"aria-label":h("buttons.close"),label:h("buttons.close"),onClick:()=>w(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[w,E]),S=(P,L)=>{y(!1),w({url:P.url,authorName:P.authorName});let D=L.slice();D.forEach(U=>{t.includes(U.id)&&(U.status="published")}),o.setLibrary(D)},A=async()=>{try{await o.updateLibrary({libraryItems:ip({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:h("errors.importLibraryError")})}},M=async()=>{let P=b?f:await o.getLatestLibrary();qw(P).catch(Tm).catch(L=>{e({errorMessage:L.message})})},O=()=>lh(ue,{open:c,children:[Ro(ue.Trigger,{onToggle:()=>d(!c),children:yi}),lh(ue.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!b&&Ro(ue.Item,{onSelect:A,icon:Ta,"data-testid":"lib-dropdown--load",children:h("buttons.load")}),!!f.length&&Ro(ue.Item,{onSelect:M,icon:wi,"data-testid":"lib-dropdown--export",children:h("buttons.export")}),b&&Ro(ue.Item,{icon:i1,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:h("buttons.publishLibrary")}),!!f.length&&Ro(ue.Item,{onSelect:()=>u(!0),icon:Kt,children:x})]})]});return lh("div",{className:J_("library-menu-dropdown-container",a),children:[O(),t.length>0&&Ro("div",{className:"library-actions-counter",children:t.length}),p&&m(),v&&Ro(dI,{onClose:()=>y(!1),libraryItems:eP(s.libraryItems,t),appState:l,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>o.setLibrary(s.libraryItems),onRemove:P=>i(t.filter(L=>L!==P))}),E&&T()]})},RI=({selectedItems:e,onSelectItems:t,className:o})=>{let{library:r}=Xe(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=cs(),l=be(),a=Ie(),[s]=ne(sn),c=async m=>{let p=m.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{a({errorMessage:h("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Ro(tP,{appState:l,setAppState:a,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:o})};import{memo as cP,useEffect as dP,useState as mP}from"react";import oP,{useCallback as rP}from"react";function nP(){return[!1,rP(t=>t(),[])]}var NI=oP.useTransition||nP;import OI from"clsx";import{memo as iP,useRef as aP,useState as lP}from"react";import{jsx as sh,jsxs as sP}from"react/jsx-runtime";var FI=iP(({id:e,elements:t,isPending:o,onClick:r,selected:n,onToggle:i,onDrag:l,svgCache:a})=>{let s=aP(null),c=qu(e,t,a,s),[d,m]=lP(!1),p=Me().formFactor==="phone",u=o&&sh("div",{className:"library-unit__adder",children:Xf});return sP("div",{className:OI("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[sh("div",{className:OI("library-unit__dragger",{"library-unit__pulse":!!o}),ref:s,draggable:!!t,onClick:t||o?b=>{e&&b.shiftKey?i(e,b):r(e)}:void 0,onDragStart:b=>{if(!e){b.preventDefault();return}m(!1),l(e,b)}}),u,e&&t&&(d||p||n)&&sh(md,{checked:n,onChange:(b,f)=>i(e,f),className:"library-unit__checkbox"})]})}),BI=()=>sh("div",{className:"library-unit library-unit--skeleton"});import{Fragment as pP,jsx as ch}from"react/jsx-runtime";var dh=({children:e})=>ch("div",{className:"library-menu-items-container__grid",children:e}),Id=cP(({items:e,onItemSelectToggle:t,onItemDrag:o,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:l})=>{let[,a]=NI(),[s,c]=mP(0);return dP(()=>{s<e.length&&a(()=>{c(s+l)})},[s,e.length,a,l]),ch(pP,{children:e.map((d,m)=>m<s?ch(FI,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:n,svgCache:i,id:d?.id,selected:r(d.id),onToggle:t,onDrag:o},d?.id??m):ch(BI,{},m))})});import W0 from"clsx";import{forwardRef as gP,useRef as fP,useImperativeHandle as bP,useLayoutEffect as xP,useState as EP}from"react";import uP from"clsx";import{jsx as hP}from"react/jsx-runtime";var no=({type:e="button",onSelect:t,selected:o,children:r,className:n="",...i})=>hP("button",{onClick:li(i.onClick,l=>{t()}),type:e,className:uP("excalidraw-button",n,{selected:o}),...i,children:r});import{jsx as V0,jsxs as zI}from"react/jsx-runtime";var Fi=gP(({onChange:e,label:t,fullWidth:o,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:l,isRedacted:a=!1,icon:s,className:c,type:d,...m},p)=>{let u=fP(null);bP(p,()=>u.current),xP(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[b,f]=EP(!1);return zI("div",{className:W0("ExcTextField",c,{"ExcTextField--fullWidth":o,"ExcTextField--hasIcon":!!s}),onClick:()=>{u.current?.focus()},children:[s,t&&V0("div",{className:"ExcTextField__label",children:t}),zI("div",{className:W0("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[V0("input",{className:W0({"is-redacted":"value"in m&&m.value&&a&&!b}),readOnly:n,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:r,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:l,type:d}),a&&V0(no,{onSelect:()=>f(!b),style:{border:0,userSelect:"none"},children:b?h1:Sa})]})]})});import{Fragment as GI,jsx as $t,jsxs as cn}from"react/jsx-runtime";var vP=17,wP=64;function X0({isLoading:e,libraryItems:t,onAddToLibrary:o,onInsertLibraryItems:r,pendingElements:n,theme:i,id:l,libraryReturnUrl:a,onSelectItems:s,selectedItems:c}){let d=Me(),m=HI(null),p=iI(m);Y0(()=>{p>0&&m.current?.scrollTo(0,p)},[]);let{svgCache:u}=cs(),[b,f]=UI(null),[x,v]=UI(""),y=!t.length&&!n.length,E=!y&&!!x.trim(),w=K0(()=>{let W=Oa(x.trim().toLowerCase());return W?t.filter(q=>{let oe=q.name||"";return oe.trim()&&Oa(oe.toLowerCase()).includes(W)}):[]},[t,x]),T=K0(()=>t.filter(W=>W.status!=="published"),[t]),S=K0(()=>t.filter(W=>W.status==="published"),[t]),A=hs((W,q)=>{let oe=!c.includes(W),B=[...T,...S];if(oe){if(q.shiftKey&&b){let V=B.findIndex(me=>me.id===b),fe=B.findIndex(me=>me.id===W);if(V===-1||fe===-1){s([...c,W]);return}let Ne=ie(c),Ze=Math.min(V,fe),ye=Math.max(V,fe),Ye=B.reduce((me,je,It)=>((It>=Ze&&It<=ye||Ne.has(je.id))&&me.push(je.id),me),[]);s(Ye)}else s([...c,W]);f(W)}else f(null),s(c.filter(V=>V!==W))},[b,s,S,c,T]);Y0(()=>{c.length||f(null)},[c]);let M=hs(W=>{let q;return c.includes(W)?q=t.filter(oe=>c.includes(oe.id)):q=t.filter(oe=>oe.id===W),q.map(oe=>({...oe,elements:Sn({type:"everything",elements:oe.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements}))},[t,c]),O=hs((W,q)=>{let oe={itemIds:c.includes(W)?c:[W]};q.dataTransfer.setData(pe.excalidrawlibIds,JSON.stringify(oe))},[c]),P=hs(W=>W?c.includes(W):!1,[c]),L=hs(()=>{o(n)},[n,o]),D=hs(W=>{W&&r(M(W))},[M,r]),U=u.size>=(w.length?w:t).length?wP:vP,K=HI(null);Y0(()=>{Dy(()=>{K.current?.focus()})},[]);let F=!E&&cn(GI,{children:[!y&&$t("div",{className:"library-menu-items-container__header",children:h("labels.personalLib")}),!n.length&&!T.length?cn("div",{className:"library-menu-items__no-items",children:[!S.length&&$t("div",{className:"library-menu-items__no-items__label",children:h("library.noItems")}),$t("div",{className:"library-menu-items__no-items__hint",children:S.length>0?h("library.hint_emptyPrivateLibrary"):h("library.hint_emptyLibrary")})]}):cn(dh,{children:[n.length>0&&$t(Id,{itemsRenderedPerBatch:U,items:[{id:null,elements:n}],onItemSelectToggle:A,onItemDrag:O,onClick:L,isItemSelected:P,svgCache:u}),$t(Id,{itemsRenderedPerBatch:U,items:T,onItemSelectToggle:A,onItemDrag:O,onClick:D,isItemSelected:P,svgCache:u})]}),S.length>0&&$t("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:h("labels.excalidrawLib")}),S.length>0&&$t(dh,{children:$t(Id,{itemsRenderedPerBatch:U,items:S,onItemSelectToggle:A,onItemDrag:O,onClick:D,isItemSelected:P,svgCache:u})})]}),$=E&&cn(GI,{children:[cn("div",{className:"library-menu-items-container__header",children:[h("library.search.heading"),!e&&cn("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:W=>W.preventDefault(),onClick:W=>{v("")},children:[$t("kbd",{children:"esc"})," to clear"]})]}),w.length>0?$t(dh,{children:$t(Id,{itemsRenderedPerBatch:U,items:w,onItemSelectToggle:A,onItemDrag:O,onClick:D,isItemSelected:P,svgCache:u})}):cn("div",{className:"library-menu-items__no-items",children:[$t("div",{className:"library-menu-items__no-items__hint",children:h("library.search.noResults")}),$t(no,{onPointerDown:W=>W.preventDefault(),onSelect:()=>{v("")},style:{width:"auto",marginTop:"1rem"},children:h("library.search.clearSearch")})]})]});return cn("div",{className:"library-menu-items-container",style:n.length||T.length||S.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[cn("div",{className:"library-menu-items-header",children:[!y&&$t(Fi,{ref:K,type:"search",className:yP("library-menu-items-container__search",{hideCancelButton:d.formFactor!=="phone"}),placeholder:h("library.search.inputPlaceholder"),value:x,onChange:W=>v(W)}),$t(RI,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),cn(ro.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:S.length>0?1:"0 1 auto",margin:y?"auto":0},ref:m,children:[e&&$t("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:$t(Pt,{})}),F,$,y&&$t(eh,{style:{padding:"16px 0",width:"100%"},id:l,libraryReturnUrl:a,theme:i})]})]})}import{jsx as Bi,jsxs as VI}from"react/jsx-runtime";var ps=Ce(!1),WI=({children:e})=>Bi("div",{className:"layer-ui__library",children:e}),CP=XI(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:o,setAppState:r,libraryReturnUrl:n,library:i,id:l,theme:a,selectedItems:s,onSelectItems:c})=>{let[d]=ne(sn),m=Z0(b=>{(async(x,v)=>{Ee("element","addToLibrary","ui");for(let E of bm)if(x.some(w=>w.type===E))return r({errorMessage:h(`errors.libraryElementTypeError.${E}`)});let y=[{status:"unpublished",elements:x,id:So(),created:Date.now()},...v];o(),i.setLibrary(y).catch(()=>{r({errorMessage:h("alerts.errorAddingToLibrary")})})})(b,d.libraryItems)},[o,i,r,d.libraryItems]),p=KI(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return Bi(WI,{children:Bi("div",{className:"layer-ui__library-message",children:VI("div",{children:[Bi(Pt,{size:"2em"}),Bi("span",{children:h("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return VI(WI,{children:[Bi(X0,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:l,libraryReturnUrl:n,theme:a,onSelectItems:c,selectedItems:s}),u&&Bi(eh,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:l,libraryReturnUrl:n,theme:a})]})}),$0=(e,t)=>({elements:e,pending:ae(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),IP=(e,t)=>{let o=ki(),[r,n]=YI(()=>$0(o,e.selectedElementIds)),i=TP(new Map);return j0(()=>{for(let l of r.pending)i.current.set(l.id,l.version)},[r.pending]),j0(()=>{t.state.cursorButton==="up"&&t.state.activeTool.type==="selection"&&n(l=>{if(!Lt(l.selectedElementIds,e.selectedElementIds))return i.current.clear(),$0(o,e.selectedElementIds);let a=t.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=a.get(s)?.version;if(c&&c!==i.current.get(s))return $0(o,e.selectedElementIds)}return l})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,o]),r.pending},$I=XI(()=>{let e=Xe(),{onInsertElements:t}=e,o=xo(),r=be(),n=Ie(),[i,l]=YI([]),a=KI(()=>e.library,[e.library]),s=IP(r,e);j0(()=>_e(document,"keydown",m=>{if(m.key===I.ESCAPE&&m.target instanceof HTMLElement){let p=m.target;if(p.closest(`.${et.SIDEBAR}`))i.length>0?(m.stopPropagation(),l([])):lo(p)&&p instanceof HTMLInputElement&&!p.value&&(m.stopPropagation(),n({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:b}=e.viewport.lastPosition;document.elementFromPoint(u,b)?.closest(`.${et.SIDEBAR}`)&&(m.stopPropagation(),l([]))}}},{capture:!0}),[i,n,e]);let c=Z0(m=>{t(ms(m)),e.focusContainer()},[t,e]),d=Z0(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return Bi(CP,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:d,setAppState:n,libraryReturnUrl:o.libraryReturnUrl,library:a,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:l})});import SP from"clsx";import{useRef as kP}from"react";import{createPortal as MP}from"react-dom";import{jsx as ZI,jsxs as AP}from"react/jsx-runtime";var jI=e=>{let{closeOnClickOutside:t=!0}=e,o=Qp({className:"excalidraw-modal-container"}),r=kP(document.body.classList.contains("excalidraw-animations-disabled"));if(!o)return null;let n=i=>{i.key===I.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return MP(AP("div",{className:SP("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,children:[ZI("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),ZI("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),o)};import{jsx as Sd,jsxs as RP}from"react/jsx-runtime";function DP(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Mt=e=>{let[t,o]=XC(),[r]=PP(document.activeElement),{id:n}=Je(),i=Me().formFactor==="phone";_P(()=>{if(!t)return;let c=ac(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===I.TAB){let p=ac(t),{activeElement:u}=document,b=p.findIndex(f=>f===u);b===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):b===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let l=Ie(),a=qr(ps),s=()=>{l({openMenu:null}),a(!1),r.focus(),e.onCloseRequest()};return Sd(jI,{className:LP("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:DP(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:RP(yt,{ref:o,children:[e.title&&Sd("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Sd("span",{className:"Dialog__titleContent",children:e.title})}),i&&Sd("button",{className:"Dialog__close",onClick:s,title:h("buttons.close"),"aria-label":h("buttons.close"),type:"button",children:Go}),Sd("div",{className:"Dialog__content",children:e.children})]})})};import Ui from"clsx";import{useRef as NP}from"react";import{Popover as Hi}from"radix-ui";var zi=G({name:"viewMode",label:"labels.viewMode",icon:Sa,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:N.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,o,r)=>typeof o.viewModeEnabled>"u"&&r.isInteractionEnabled(),keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ge.R});var mh=(e,t)=>{let o=t[0]?.type||null;for(let r of t)if(r.type!==o){o=null;break}return hc(e.activeTool.type)&&o!=="image"&&o!=="frame"&&o!=="magicframe"||t.some(r=>hc(r.type))},ph=(e,t)=>mi(e.activeTool.type)||t.some(o=>mi(o.type)),uh=(e,t,o,r)=>{let n=e.activeTool.type,i=d=>d(n)||t.some(m=>d(m.type)),l=t.length===1,a=t.length===2&&(Ht(t[0])||Ht(t[1])),s=!!(e.editingTextElement||e.newElement),c=t.length>0;return{hasSelection:c,showExtraActions:c&&!s,strokeColor:mh(e,t),backgroundColor:ph(e,t),fill:n==="bucketfill"||mi(n)&&!Uo(e.currentItemBackgroundColor)||t.some(d=>mi(d.type)&&!Uo(d.backgroundColor)),strokeWidth:i(yv),freedrawMode:i(vv),strokeStyle:i(pf),sloppiness:i(pf),roundness:i(wv),arrowType:i(Tv),arrowheads:i(gc),text:n==="text"||t.some(ee),textAlign:n==="text"||Ev(t,o),verticalAlign:xv(t,o),opacity:n!=="autoshape"||c,layers:n!=="freedraw"&&n!=="autoshape"&&!t.some(d=>d.type==="freedraw")||ae(o,e).some(d=>d.type==="freedraw"),align:!a&&Do(e,r),distribute:t.length>2,link:l||a,linkSingleOnly:l,cropEditor:!e.croppingElementId&&l&&ot(t[0]),lineEditor:!e.selectedLinearElement?.isEditing&&l&&Se(t[0])&&!Re(t[0])}};import{Fragment as dr,jsx as te,jsxs as $e}from"react/jsx-runtime";var q0=Ui([et.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),qI=({renderAction:e})=>$e("fieldset",{children:[te("legend",{children:h("labels.layers")}),$e("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),JI=({renderAction:e,showDistribute:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return $e("fieldset",{children:[te("legend",{children:h("labels.align")}),$e("div",{className:"buttonList",children:[o?$e(dr,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):$e(dr,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),t&&e("distributeHorizontally"),te("div",{style:{flexBasis:"100%",height:0}}),$e("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),t&&e("distributeVertically")]})]})]})},QI=({appState:e,elementsMap:t,renderAction:o,app:r})=>{let n=pl(t,e),i=uh(e,n,t,r);return e.activeTool.type==="bucketfill"?$e("div",{className:"selected-shape-actions",children:[te("div",{children:o("changeBucketFillBackgroundColor")}),o("changeFillStyle"),o("changeOpacity")]}):$e("div",{className:"selected-shape-actions",children:[te("div",{children:i.strokeColor&&o("changeStrokeColor")}),i.backgroundColor&&te("div",{children:o("changeBackgroundColor")}),i.fill&&o("changeFillStyle"),i.strokeWidth&&o("changeStrokeWidth"),i.strokeStyle&&te(dr,{children:o("changeStrokeStyle")}),i.freedrawMode&&o("changeFreedrawMode"),i.sloppiness&&te(dr,{children:o("changeSloppiness")}),i.roundness&&te(dr,{children:o("changeRoundness")}),i.arrowType&&te(dr,{children:o("changeArrowType")}),i.text&&$e(dr,{children:[te("fieldset",{children:o("changeFontFamily")}),o("changeFontSize"),i.textAlign&&o("changeTextAlign")]}),i.verticalAlign&&o("changeVerticalAlign"),i.arrowheads&&te(dr,{children:o("changeArrowhead")}),i.opacity&&o("changeOpacity"),i.layers&&te(qI,{renderAction:o}),i.align&&te(JI,{renderAction:o,showDistribute:i.distribute}),i.showExtraActions&&$e("fieldset",{children:[te("legend",{children:h("labels.actions")}),$e("div",{className:"buttonList",children:[o("duplicateSelection"),o("deleteSelectedElements"),o("group"),o("ungroup"),i.link&&o("hyperlink"),i.cropEditor&&o("cropEditor"),i.lineEditor&&o("toggleLinearEditor")]})]})]})},eS=({appState:e,renderAction:t,setAppState:o,predicates:r,container:n})=>{let i=r.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return i?te("div",{className:"compact-action-item",children:$e(Hi.Root,{open:l,onOpenChange:a=>{o(a?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[te(Hi.Trigger,{asChild:!0,children:te("button",{type:"button",className:Ui("compact-action-button properties-trigger",{active:l}),title:h("labels.stroke"),onClick:a=>{a.preventDefault(),a.stopPropagation(),o({openPopup:l?null:"compactStrokeStyles"})},children:N1})}),l&&te(Nn,{className:q0,container:n,style:{maxWidth:"13rem"},onClose:()=>{},children:$e("div",{className:"selected-shape-actions",children:[r.fill&&t("changeFillStyle"),r.strokeWidth&&t("changeStrokeWidth"),r.freedrawMode&&t("changeFreedrawMode"),r.strokeStyle&&te(dr,{children:t("changeStrokeStyle")}),r.sloppiness&&te(dr,{children:t("changeSloppiness")}),r.roundness&&t("changeRoundness"),r.opacity&&t("changeOpacity")]})})]})}):null},tS=({appState:e,renderAction:t,setAppState:o,targetElements:r,predicates:n,container:i,app:l})=>{if(!n.arrowType)return null;let a=e.openPopup==="compactArrowProperties";return te("div",{className:"compact-action-item",children:$e(Hi.Root,{open:a,onOpenChange:s=>{o(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[te(Hi.Trigger,{asChild:!0,children:te("button",{type:"button",className:Ui("compact-action-button properties-trigger",{active:a}),title:h("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),o({openPopup:a?null:"compactArrowProperties"})},children:(()=>{let s=Xt(r,l,c=>Te(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>Te(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?Dn:s==="round"?Rn:Pn})()})}),a&&te(Nn,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:t("changeArrowProperties")})]})})},oS=({appState:e,renderAction:t,setAppState:o,predicates:r,container:n})=>{let{saveCaretPosition:i,restoreCaretPosition:l}=_2(),a=e.openPopup==="compactTextProperties";return te("div",{className:"compact-action-item",children:$e(Hi.Root,{open:a,onOpenChange:s=>{s?(e.editingTextElement&&i(),o({openPopup:"compactTextProperties"})):(o({openPopup:null}),e.editingTextElement&&l())},children:[te(Hi.Trigger,{asChild:!0,children:te("button",{type:"button",className:Ui("compact-action-button properties-trigger",{active:a}),title:h("labels.textAlign"),onClick:s=>{s.preventDefault(),s.stopPropagation(),a?o({openPopup:null}):(e.editingTextElement&&i(),o({openPopup:"compactTextProperties"}))},children:rb})}),e.openPopup==="compactTextProperties"&&te(Nn,{className:q0,container:n,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:$e("div",{className:"selected-shape-actions",children:[r.text&&t("changeFontSize"),r.textAlign&&t("changeTextAlign"),r.verticalAlign&&t("changeVerticalAlign")]})})]})})},rS=({appState:e,renderAction:t,predicates:o,setAppState:r,container:n,showDuplicate:i,showDelete:l})=>{let a=e.openPopup==="compactOtherProperties";return o.showExtraActions?te("div",{className:"compact-action-item",children:$e(Hi.Root,{open:a,onOpenChange:s=>{r(s?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[te(Hi.Trigger,{asChild:!0,children:te("button",{type:"button",className:Ui("compact-action-button properties-trigger",{active:a}),title:h("labels.actions"),onClick:s=>{s.preventDefault(),s.stopPropagation(),r({openPopup:a?null:"compactOtherProperties"})},children:$f})}),a&&te(Nn,{className:q0,container:n,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:$e("div",{className:"selected-shape-actions",children:[o.layers&&te(qI,{renderAction:t}),o.align&&te(JI,{renderAction:t,showDistribute:o.distribute}),$e("fieldset",{children:[te("legend",{children:h("labels.actions")}),$e("div",{className:"buttonList",children:[t("group"),t("ungroup"),o.linkSingleOnly&&t("hyperlink"),o.cropEditor&&t("cropEditor"),i&&t("duplicateSelection"),l&&t("deleteSelectedElements")]})]})]})})]})}):null},OP=({renderAction:e,predicates:t})=>t.lineEditor?te("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,nS=({appState:e,elementsMap:t,renderAction:o,app:r,setAppState:n})=>{let i=pl(t,e),l=uh(e,i,t,r),{container:a}=Je();return $e("div",{className:"compact-shape-actions",children:[l.strokeColor&&te("div",{className:Ui("compact-action-item"),children:o("changeStrokeColor")}),l.backgroundColor&&te("div",{className:"compact-action-item",children:o(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),l.freedrawMode&&te("div",{className:"compact-action-item",children:o("changeFreedrawMode",{cycle:!0})}),te(eS,{appState:e,renderAction:o,setAppState:n,predicates:l,container:a}),te(tS,{appState:e,renderAction:o,setAppState:n,targetElements:i,predicates:l,container:a,app:r}),l.lineEditor&&te("div",{className:"compact-action-item",children:o("toggleLinearEditor")}),l.text&&$e(dr,{children:[te("div",{className:"compact-action-item",children:o("changeFontFamily")}),te(oS,{appState:e,renderAction:o,setAppState:n,predicates:l,container:a})]}),l.showExtraActions&&te("div",{className:"compact-action-item",children:o("duplicateSelection")}),l.showExtraActions&&te("div",{className:"compact-action-item",children:o("deleteSelectedElements")}),te(rS,{appState:e,renderAction:o,predicates:l,setAppState:n,container:a})]})},iS=({appState:e,elementsMap:t,renderAction:o,app:r,setAppState:n})=>{let i=pl(t,e),l=uh(e,i,t,r),{container:a}=Je(),s=NP(null),c=s.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,b=p+m,f=c>=u+b,x=c>=u+2*b;return $e(yt,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:s,children:[$e("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[l.strokeColor&&te("div",{className:Ui("compact-action-item"),children:o("changeStrokeColor")}),l.backgroundColor&&te("div",{className:"compact-action-item",children:o(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),te(eS,{appState:e,renderAction:o,setAppState:n,predicates:l,container:a}),te(tS,{appState:e,renderAction:o,setAppState:n,targetElements:i,predicates:l,container:a,app:r}),te(OP,{renderAction:o,predicates:l}),l.text&&$e(dr,{children:[te("div",{className:"compact-action-item",children:o("changeFontFamily")}),te(oS,{appState:e,renderAction:o,setAppState:n,predicates:l,container:a})]}),te(rS,{appState:e,renderAction:o,predicates:l,setAppState:n,container:a,showDuplicate:!x,showDelete:!f})]}),$e("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[te("div",{className:"compact-action-item",children:o("undo")}),te("div",{className:"compact-action-item",children:o("redo")}),x&&te("div",{className:"compact-action-item",children:o("duplicateSelection")}),f&&te("div",{className:"compact-action-item",children:o("deleteSelectedElements")})]})]})},aS=({renderAction:e})=>te(ro.Col,{gap:1,className:et.ZOOM_ACTIONS,children:$e(ro.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),lS=({renderAction:e,className:t})=>$e("div",{className:`undo-redo-buttons ${t}`,children:[te("div",{className:"undo-button-container",children:te(Eo,{label:h("buttons.undo"),children:e("undo")})}),te("div",{className:"redo-button-container",children:$e(Eo,{label:h("buttons.redo"),children:[" ",e("redo")]})})]}),sS=({actionManager:e,showExitZenModeBtn:t})=>te("button",{type:"button",className:Ui("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(zn),children:h("buttons.exitZenMode")}),cS=({actionManager:e})=>te("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(zi),children:F1});import{useRef as FP}from"react";var J0=e=>{let t=FP({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...o)=>t.current.userFn(...o)),t.current.stableFn};import{jsx as zP,jsxs as BP}from"react/jsx-runtime";var Fa=Ce(null),dS=()=>{let[e,t]=ne(Fa),o=Qe();return e&&e==="clearCanvas"?zP(oh,{onConfirm:()=>{o.executeAction(nn),t(null)},onCancel:()=>t(null),title:h("clearCanvasDialog.title"),children:BP("p",{className:"clear-canvas__content",children:[" ",h("alerts.clearReset")]})}):null};var mS={};import{jsx as Zt,jsxs as dn}from"react/jsx-runtime";var GP=Ce(null),xt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},pS=e=>{switch(e){case xt.app:return 1;case xt.export:return 2;case xt.editor:return 3;case xt.tools:return 4;case xt.elements:return 5;case xt.links:return 6;default:return 10}},fh=({shortcut:e,className:t,children:o})=>{let r=e.replace("++","+$").split("+");return dn("div",{className:hS("shortcut",t),children:[r.map((n,i)=>Zt("div",{className:"shortcut-wrapper",children:Zt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Zt("div",{className:"shortcut-desc",children:o})]})},fS=e=>!e.altKey&&e[I.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===I.P||e.key===I.SLASH),WP=Object.assign(e=>{let t=be(),o=Ie();return gh(()=>{let r=n=>{fS(n)&&(n.preventDefault(),n.stopPropagation(),o(i=>{let l=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return l&&Ee("command_palette","open","shortcut"),{openDialog:l}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[o]),t.openDialog?.name!=="commandPalette"?null:Zt(VP,{...e})},{defaultItems:mS});function VP({customCommandPaletteItems:e}){let t=Xe(),o=be(),r=Ie(),n=xo(),i=Qe(),[l,a]=ne(GP),[s,c]=hh(null),d=gS(null),m=Si({uiAppState:o,customCommandPaletteItems:e,appProps:n}),[p]=ne(sn),u=UP(()=>p.libraryItems?.filter(M=>!!M.name).map(M=>({label:M.name,icon:Zt(YP,{id:M.id,elements:M.elements}),category:"Library",order:pS("Library"),haystack:Oa(M.name),perform:()=>{t.onInsertElements(ms([M]))}}))||[],[t,p.libraryItems]);gh(()=>{let{uiAppState:M,customCommandPaletteItems:O,appProps:P}=m,L=F=>{let $="";return F.label&&(typeof F.label=="function"?$=h(F.label(t.scene.getNonDeletedElements(),M,t)):$=h(F.label)),$},D=F=>typeof F.icon=="function"?F.icon(M,t.scene.getNonDeletedElements()):F.icon,U=[],K=(F,$,W)=>{let q={label:L(F),icon:D(F),category:$,shortcut:rt(F.name),keywords:F.keywords,predicate:F.predicate,viewMode:F.viewMode,perform:()=>{i.executeAction(F,"commandPalette")}};return W?W(q,F):q};if(M&&t.scene&&i){let F=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,os,ju,KC].map(B=>K(B,xt.elements,(V,fe)=>({...V,predicate:fe.predicate?fe.predicate:(Ne,Ze,ye,Ye)=>ae(Ne,Ze).length>0}))),$=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(B=>K(B,xt.editor)),W=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(B=>K(B,xt.export));U=[...F,...$,{label:L(nn),icon:D(nn),shortcut:rt(nn.name),category:xt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{bt.set(Fa,"clearCanvas")}},{label:h("buttons.exportImage"),category:xt.export,icon:Hc,shortcut:rt("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...W];let q=[K(Bn,xt.app),{label:h("toolBar.library"),category:xt.app,icon:Rc,viewMode:!1,perform:()=>{M.openSidebar?r({openSidebar:null}):r({openSidebar:{name:ao.name,tab:ao.defaultTab}})}},{label:h("search.title"),category:xt.app,icon:Lo,viewMode:!0,perform:()=>{i.executeAction(gs)}},{label:h("labels.shapeSwitch"),category:xt.elements,icon:Rl,perform:()=>{i.executeAction(YC)}},{label:h("labels.changeStroke"),keywords:["color","outline"],category:xt.elements,icon:fo,viewMode:!1,predicate:(B,V)=>{let fe=ae(B,V);return fe.length>0&&mh(V,fe)},perform:()=>{r(B=>({openPopup:"elementStroke"}))}},{label:h("labels.changeBackground"),keywords:["color","fill"],icon:fo,category:xt.elements,viewMode:!1,predicate:(B,V)=>{let fe=ae(B,V);return fe.length>0&&ph(V,fe)},perform:()=>{r(B=>({openPopup:"elementBackground"}))}},{label:h("labels.canvasBackground"),keywords:["color"],icon:fo,category:xt.editor,viewMode:!1,perform:()=>{r(B=>({openMenu:B.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Object.keys(vt).reduce((B,V)=>{let fe=vt[V];if(P.UIOptions.tools?.[V]===!1)return B;let Ne=Eu(V)||fe.numericKey,Ze={label:h(`toolBar.${V}`),category:xt.tools,shortcut:Ne,icon:fe.icon,keywords:["toolbar"],viewMode:!1,perform:()=>{t.setActiveTool({type:V},{toggle:!1})}};return B.push(Ze),B},[]),{label:h("toolBar.lock"),category:xt.tools,icon:M.activeTool.locked?ya:vi,shortcut:I.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${h("labels.textToDiagram")}...`,category:xt.tools,icon:f1,viewMode:!1,predicate:P.aiEnabled,perform:()=>{r(B=>({...B,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${h("toolBar.mermaidToExcalidraw")}...`,category:xt.tools,icon:Ia,viewMode:!1,predicate:P.aiEnabled,perform:()=>{r(B=>({...B,openDialog:{name:"ttd",tab:"mermaid"}}))}}],oe=[...U,...q,...O||[]].map(B=>({...B,icon:B.icon||Rl,order:B.order??pS(B.category),haystack:`${Oa(B.label.toLocaleLowerCase())} ${B.keywords?.join(" ")||""}`}));c(oe),a([...oe,...u].find(B=>B.label===l?.label)??null)}},[m,t,i,c,l?.label,a,r,u]);let[b,f]=hh(""),[x,v]=hh(null),[y,E]=hh({}),w=M=>{r({openDialog:null},M),f("")},T=(M,O)=>{o.openDialog?.name==="commandPalette"&&(O.stopPropagation(),O.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{M.perform({actionManager:i,event:O}),a(M),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},S=J0(M=>M.viewMode===!1&&o.viewModeEnabled?!1:typeof M.predicate=="function"?M.predicate(t.scene.getNonDeletedElements(),o,n,t):M.predicate===void 0||M.predicate),A=J0(M=>{let O=lo(M.target)||fS(M)||M.key===I.ESCAPE;if(O&&M.key!==I.ARROW_UP&&M.key!==I.ARROW_DOWN&&M.key!==I.ENTER)return;let P=Object.values(y).flat(),L=l&&!b&&S(l);if(M.key===I.ARROW_UP){M.preventDefault();let D=P.findIndex(F=>F.label===x?.label);if(L){if(D===0){v(l);return}if(x===l){let F=P[P.length-1];F&&v(F);return}}let U;D===-1?U=P.length-1:U=D===0?P.length-1:(D-1)%P.length;let K=P[U];K&&v(K);return}if(M.key===I.ARROW_DOWN){M.preventDefault();let D=P.findIndex(F=>F.label===x?.label);if(L){if(!x||D===P.length-1){v(l);return}if(x===l){let F=P[0];F&&v(F);return}}let U=(D+1)%P.length,K=P[U];K&&v(K);return}if(M.key===I.ENTER&&x&&setTimeout(()=>{T(x,M)}),!O){if(M.stopPropagation(),/^[a-zA-Z0-9]$/.test(M.key)){d?.current?.focus();return}M.preventDefault()}});return gh(()=>(window.addEventListener("keydown",A,{capture:!0}),()=>window.removeEventListener("keydown",A,{capture:!0})),[A]),gh(()=>{if(!s)return;let M=D=>{let U={};for(let K of D)U[K.category]?U[K.category].push(K):U[K.category]=[K];return U},O=b?.length>1?[...s.filter(S).sort((D,U)=>D.order-U.order),...u]:s.filter(S).sort((D,U)=>D.order-U.order),P=!b&&l&&S(l);if(!b){E(M(P?O.filter(D=>D.label!==l?.label):O)),v(P?l:O[0]||null);return}let L=Oa(b.toLocaleLowerCase().replace(/[<>_| -]/g,""));O=HP.filter(L,O,{extract:D=>D.haystack??""}).sort((D,U)=>U.score-D.score).map(D=>D.original),E(M(O)),v(O[0]??null)},[b,s,S,l,u]),dn(Mt,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Zt(Fi,{value:b,placeholder:h("commandPalette.search.placeholder"),onChange:M=>{f(M)},selectOnRender:!0,ref:d}),t.editorInterface.formFactor!=="phone"&&dn("div",{className:"shortcuts-wrapper",children:[Zt(fh,{shortcut:"\u2191\u2193",children:h("commandPalette.shortcuts.select")}),Zt(fh,{shortcut:"\u21B5",children:h("commandPalette.shortcuts.confirm")}),Zt(fh,{shortcut:H("Esc"),children:h("commandPalette.shortcuts.close")})]}),dn("div",{className:"commands",children:[l&&!b&&dn("div",{className:"command-category",children:[dn("div",{className:"command-category-title",children:[h("commandPalette.recents"),Zt("div",{className:"icon",style:{marginLeft:"6px"},children:b1})]}),Zt(uS,{command:l,isSelected:l.label===x?.label,onClick:M=>T(l,M),disabled:!S(l),onMouseMove:()=>v(l),showShortcut:t.editorInterface.formFactor!=="phone",appState:o})]}),Object.keys(y).length>0?Object.keys(y).map((M,O)=>dn("div",{className:"command-category",children:[Zt("div",{className:"command-category-title",children:M}),y[M].map(P=>Zt(uS,{command:P,isSelected:P.label===x?.label,onClick:L=>T(P,L),onMouseMove:()=>v(P),showShortcut:t.editorInterface.formFactor!=="phone",appState:o,size:M==="Library"?"large":"small"},P.label))]},M)):s?dn("div",{className:"no-match",children:[Zt("div",{className:"icon",children:Lo})," ",h("commandPalette.search.noMatch")]}):null]})]})}var YP=({id:e,elements:t})=>{let o=gS(null),{svgCache:r}=cs();return qu(e,t,r,o),Zt("div",{className:"library-item-icon",ref:o})},uS=({command:e,isSelected:t,disabled:o,onMouseMove:r,onClick:n,showShortcut:i,appState:l,size:a="small"})=>{let s=()=>{};return dn("div",{className:hS("command-item",{"item-selected":t,"item-disabled":o,"command-item-large":a==="large"}),ref:c=>{t&&!o&&c?.scrollIntoView?.({block:"nearest"})},onClick:o?s:n,onMouseMove:o?s:r,title:o?h("commandPalette.itemNotAvailable"):"",children:[dn("div",{className:"name",children:[e.icon&&Zt(on,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(l,[]):e.icon}),Zt(Ma,{children:e.label})]}),i&&e.shortcut&&Zt(fh,{shortcut:e.shortcut})]})};import{jsx as bS}from"react/jsx-runtime";var Ba=G({name:"toggleLinearEditor",category:xt.elements,label:(e,t,o)=>o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return!!(!t.selectedLinearElement?.isEditing&&n.length===1&&Se(n[0])&&!Re(n[0]))},perform(e,t,o,r){it(t.selectedLinearElement,"No selected linear element found");let n=r.scene.getElement(t.selectedLinearElement.elementId);it(n,"No selected element found");let i={...t.selectedLinearElement,isEditing:!t.selectedLinearElement.isEditing};return{appState:{...t,selectedLinearElement:i},captureUpdate:N.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let r=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let n=h(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return bS(Q,{type:"button",icon:P1,title:n,"aria-label":n,onClick:()=>t(null)})}}),iae=G({name:"togglePolygon",category:xt.elements,icon:fp,keywords:["loop"],label:(e,t,o)=>!o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(i=>!at(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds});return n.length>0&&n.every(i=>at(i)&&i.points.length>=4)},perform(e,t,o,r){let n=r.scene.getSelectedElements(t);if(n.some(s=>!at(s)))return!1;let i=n,l=i.some(s=>!s.polygon),a=ie(i);return{elements:e.map(s=>!a.has(s.id)||!at(s)?s:se(s,{backgroundColor:l?s.backgroundColor:"transparent",...Zm(s,l)})),appState:t,captureUpdate:N.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let r=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(l=>!at(l)||!l.polygon||l.points.length<3))return null;let n=r.every(l=>at(l)&&l.polygon),i=h(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return bS(Q,{type:"toggle",icon:fp,title:i,"aria-label":i,checked:n,onSelect:()=>t(null),style:{marginLeft:"auto"}})}});var gs=G({name:"searchMenu",icon:Lo,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,t,o,r){if(t.openDialog)return!1;if(t.openSidebar?.name===ao.name&&t.openSidebar.tab===gn){let n=r.excalidrawContainerValue.container?.querySelector(`.${et.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...t,openSidebar:{name:ao.name,tab:gn},openDialog:null},captureUpdate:N.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.F});import{jsx as KP}from"react/jsx-runtime";var bh=G({name:"cropEditor",label:"helpDialog.cropStart",icon:Gp,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,t,o,r){let n=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:n.id},captureUpdate:N.IMMEDIATELY}},predicate:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t);return!!(!t.croppingElementId&&n.length===1&&ot(n[0]))},PanelComponent:({appState:e,updateData:t,app:o})=>{let r=h("helpDialog.cropStart");return KP(Q,{type:"button",icon:Gp,title:r,"aria-label":r,onClick:()=>t(null)})}});var ES=(e,t)=>{let o=t.scene.getSelectedElements(e);return o.length===1&&re(o[0])},yS=G({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t).at(0)||null;if(re(n)){let i=er(de(e),n.id).filter(l=>!(l.type==="text"&&l.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((l,a)=>(l[a.id]=!0,l),{})},captureUpdate:N.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:N.EVENTUALLY}},predicate:(e,t,o,r)=>ES(t,r)}),vS=G({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,o,r)=>{let n=r.scene.getSelectedElements(t).at(0)||null;return re(n)?{elements:Vv(e,n),appState:{...t,selectedElementIds:{[n.id]:!0}},captureUpdate:N.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:N.EVENTUALLY}},predicate:(e,t,o,r)=>ES(t,r)}),ple=G({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:N.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),wS=G({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,t,o,r)=>{let n=ae(e,t);return n.length>0&&!n.some(i=>re(i))},perform:(e,t,o,r)=>{let n=ae(e,t),i=r.scene.getNonDeletedElementsMap(),[l,a,s,c]=we(n,i),d=16,m=Qm({x:l-d,y:a-d,width:s-l+d*2,height:c-a+d*2});if(t.editingGroupId){let u=He(n,t.editingGroupId);for(let b of u){let f=b.groupIds.indexOf(t.editingGroupId);co(b,i,{groupIds:b.groupIds.slice(0,f)})}}return{elements:hl([...r.scene.getElementsIncludingDeleted(),m],n,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:N.IMMEDIATELY}}});var fs=class extends Ic{applyTo(t,o,r){let[n,i]=this.elements.applyTo(t,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[l,a]=this.appState.applyTo(o,n);return[n,l,i||a]}static calculate(t,o){return super.calculate(t,o)}static inverse(t){return super.inverse(t)}static applyLatestChanges(t,o,r,n){return super.applyLatestChanges(t,o,r,n)}},za=class{constructor(t=!0,o=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=o}},kd=class e{constructor(t){this.store=t;C(this,"onHistoryChangedEmitter",new Jo);C(this,"undoStack",[]);C(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(t){if(t.isEmpty()||t instanceof fs)return;let o=fs.inverse(t);this.undoStack.push(o),o.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new za(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,o){return this.perform(t,o,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(t,o){return this.perform(t,o,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(t,o,r,n){try{let i=r();if(i===null)return;let l=N.IMMEDIATELY,a=this.store.snapshot,s=t,c=o,d=!1;for(;i;){try{[s,c,d]=i.applyTo(s,c,a);let m=a.elements,p=a.maybeClone(l,s,c),u=fw.create(a,p),b=fs.applyLatestChanges(i,m,s);b.isEmpty()||(this.store.scheduleMicroAction({action:l,change:u,delta:b}),i=b),a=p}finally{n(i)}if(d)break;i=r()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new za(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let o=t.pop();return o!==void 0?o:null}static push(t,o){let r=fs.inverse(o);return t.push(r)}};import{useEffect as XP,useState as $P}from"react";var Q0=(e,t)=>{let[o,r]=$P(t);return XP(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),o};import{jsx as SS}from"react/jsx-runtime";var TS=(e,t,o)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let r=o();if(!r)return{captureUpdate:N.EVENTUALLY};let[n,i]=r,l=Wm(Array.from(n.values()));return{appState:i,elements:l,captureUpdate:N.NEVER}}return{captureUpdate:N.EVENTUALLY}},CS=e=>({name:"undo",label:"buttons.undo",icon:vp,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,r,n)=>TS(n,o,()=>e.undo(ie(t),o)),keyTest:t=>t[I.CTRL_OR_CMD]&&vm(t,I.Z)&&!t.shiftKey,PanelComponent:({appState:t,updateData:o,data:r,app:n})=>{let{isUndoStackEmpty:i}=Q0(e.onHistoryChangedEmitter,new za(e.isUndoStackEmpty,e.isRedoStackEmpty)),l=Ut()==="mobile";return SS(Q,{type:"button",icon:vp,"aria-label":h("buttons.undo"),onClick:o,size:r?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...l?fn:{}}})}}),IS=e=>({name:"redo",label:"buttons.redo",icon:wp,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,r,n)=>TS(n,o,()=>e.redo(ie(t),o)),keyTest:t=>t[I.CTRL_OR_CMD]&&t.shiftKey&&vm(t,I.Z)||t[I.CTRL_OR_CMD]&&!t.shiftKey&&vm(t,I.Y),PanelComponent:({appState:t,updateData:o,data:r,app:n})=>{let{isRedoStackEmpty:i}=Q0(e.onHistoryChangedEmitter,new za(e.isUndoStackEmpty,e.isRedoStackEmpty)),l=Ut()==="mobile";return SS(Q,{type:"button",icon:wp,"aria-label":h("buttons.redo"),onClick:o,size:r?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...l?fn:{}}})}});var ex=G({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,o)=>{let r=ae(e,t);return r.length===1&&ee(r[0])&&!r[0].autoResize},perform:(e,t,o,r)=>{let n=ae(e,t),i=sl(o)&&ee(o)?o:n[0],l=e.find(d=>d.id===i?.id);if(!l||!ee(l))return!1;let a=lt(l.originalText,dt(l),l.lineHeight),s=nw(l),c=se(l,{autoResize:!0,width:a.width,height:a.height,x:l.x+(l.width-a.width)*s.x,y:l.y+(l.height-a.height)*s.y,text:l.originalText});return or(c)&&ko(c,r.scene,{changedElements:new Map([[c.id,c]])}),{appState:t,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:N.IMMEDIATELY}}});import{jsx as ZP}from"react/jsx-runtime";var tx=(e,t,o,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(o,r,i))&&Ee(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(l){console.error("error while logging action:",l)}},xh=class{constructor(t,o,r,n){C(this,"actions",{});C(this,"updater");C(this,"getAppState");C(this,"getElementsIncludingDeleted");C(this,"app");C(this,"isActionBlockedByViewportTransition",t=>t.navigation===!0&&this.app.viewport.isLockedTransitionPending);C(this,"renderAction",(t,o)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in r)||r[t])){let n=this.actions[t],i=n.PanelComponent;i.displayName="PanelComponent";let l=a=>{this.isActionBlockedByViewportTransition(n)||(tx(n,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,a),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),a,this.app)))};return ZP(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:l,appProps:this.app.props,app:this.app,data:o,renderAction:this.renderAction})}return null});C(this,"isActionEnabled",t=>{let o=this.getElementsIncludingDeleted(),r=this.getAppState();return!t.predicate||t.predicate(o,r,this.app.props,this.app)});this.updater=i=>{if(ai(i))i.then(l=>t(l));else return t(i)},this.getAppState=o,this.getElementsIncludingDeleted=r,this.app=n}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(o=>this.registerAction(o))}handleKeyDown(t){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let o=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in o?o[s.name]:!0)&&s.keyTest&&s.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(!this.app.isInteractionEnabled()&&n.navigation!==!0||this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(n))return t.preventDefault(),t.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),l=this.getAppState(),a=null;return tx(n,"keyboard",l,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(r[0].perform(i,l,a,this.app)),!0}executeAction(t,o="api",r=null){if(o!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&t.navigation===!0)||this.isActionBlockedByViewportTransition(t))return;let n=this.getElementsIncludingDeleted(),i=this.getAppState();tx(t,o,i,n,this.app,r),this.updater(t.perform(n,i,r,this.app))}};var ox=e=>{let t=Array.from(e.values());return{x:kS(t,o=>o.x)/t.length,y:kS(t,o=>o.y)/t.length}},rx=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),kS=(e,t)=>e.reduce((o,r)=>o+t(r),0);var jP=8,MS=99999,Eh=e=>jP/e,vo=class vo{};C(vo,"referenceSnapPoints",null),C(vo,"visibleGaps",null),C(vo,"setReferenceSnapPoints",t=>{vo.referenceSnapPoints=t}),C(vo,"getReferenceSnapPoints",()=>vo.referenceSnapPoints),C(vo,"setVisibleGaps",t=>{vo.visibleGaps=t}),C(vo,"getVisibleGaps",()=>vo.visibleGaps),C(vo,"destroy",()=>{vo.referenceSnapPoints=null,vo.visibleGaps=null});var mr=vo,Gi=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Gn=({event:e,app:t,selectedElements:o})=>{if(e){let r=t.state.activeTool.type==="lasso"&&t.state.selectedElementsAreBeingDragged;return(t.state.activeTool.type!=="lasso"||r)&&(t.state.objectsSnapModeEnabled&&!e[I.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[I.CTRL_OR_CMD]&&!Gi(t))}return o.length===1&&o[0].type==="arrow"?!1:t.state.objectsSnapModeEnabled},qP=(e,t,o=.01)=>Math.abs(e-t)<=o,Md=(e,t,{omitCenter:o,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let l=e[0],[a,s,c,d,m,p]=Yt(l,t);n&&(a+=n.x,c+=n.x,m+=n.x,s+=n.y,d+=n.y,p+=n.y);let u=(c-a)/2,b=(d-s)/2;if((l.type==="diamond"||l.type==="ellipse")&&!r){let f=ke(_(a,s+b),_(m,p),l.angle),x=ke(_(a+u,s),_(m,p),l.angle),v=ke(_(c,s+b),_(m,p),l.angle),y=ke(_(a+u,d),_(m,p),l.angle),E=_(m,p);i=o?[f,x,v,y]:[f,x,v,y,E]}else{let f=ke(_(a,s),_(m,p),l.angle),x=ke(_(c,s),_(m,p),l.angle),v=ke(_(a,d),_(m,p),l.angle),y=ke(_(c,d),_(m,p),l.angle),E=_(m,p);i=o?[f,x,v,y]:[f,x,v,y,E]}}else if(e.length>1){let[l,a,s,c]=qm(e,n??{x:0,y:0}),d=s-l,m=c-a,p=_(l,a),u=_(s,a),b=_(l,c),f=_(s,c),x=_(l+d/2,a+m/2);i=o?[p,u,b,f]:[p,u,b,f,x]}return i.map(l=>_(wt(l[0]),wt(l[1])))},_S=(e,t,o,r)=>xf(e,t,o,r),PS=(e,t,o,r)=>{let n=_S(e,t,o,r),i=bf(n,r).filter(m=>!(m.length===1&&mt(m[0]))).map(m=>we(m).map(p=>wt(p))),l=i.sort((m,p)=>m[0]-p[0]),a=[],s=0;e:for(let m=0;m<l.length;m++){let p=l[m];for(let u=m+1;u<l.length;u++){if(++s>MS)break e;let b=l[u],[,f,x,v]=p,[y,E,,w]=b;x<y&&$s(zo(f,v),zo(E,w))&&a.push({startBounds:p,endBounds:b,startSide:[_(x,f),_(x,v)],endSide:[_(y,E),_(y,w)],length:y-x,overlap:Zs(zo(f,v),zo(E,w))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];s=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++s>MS)break e;let b=c[u],[f,,x,v]=p,[y,E,w]=b;v<E&&$s(zo(f,x),zo(y,w))&&d.push({startBounds:p,endBounds:b,startSide:[_(f,v),_(x,v)],endSide:[_(y,E),_(w,E)],length:E-v,overlap:Zs(zo(f,x),zo(y,w))})}}return{horizontalGaps:a,verticalGaps:d}},AS=(e,t,o,r,n,i,l)=>{if(!Gn({app:o,event:r,selectedElements:e}))return[];if(e.length===0)return[];let a=mr.getVisibleGaps();if(a){let{horizontalGaps:s,verticalGaps:c}=a,[d,m,p,u]=qm(e,t).map(x=>wt(x)),b=(d+p)/2,f=(m+u)/2;for(let x of s){if(!$s(zo(m,u),x.overlap))continue;let v=x.startSide[0][0]+x.length/2,y=wt(v-b);if(x.length>p-d&&Math.abs(y)<=l.x){Math.abs(y)<l.x&&(n.length=0),l.x=Math.abs(y);let P={type:"gap",direction:"center_horizontal",gap:x,offset:y};n.push(P);continue}let[,,w]=x.endBounds,T=d-w,S=wt(x.length-T);if(Math.abs(S)<=l.x){Math.abs(S)<l.x&&(n.length=0),l.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[A,,,]=x.startBounds,M=A-p,O=wt(M-x.length);if(Math.abs(O)<=l.x){Math.abs(O)<l.x&&(n.length=0),l.x=Math.abs(O);let P={type:"gap",direction:"side_left",gap:x,offset:O};n.push(P);continue}}for(let x of c){if(!$s(zo(d,p),x.overlap))continue;let v=x.startSide[0][1]+x.length/2,y=wt(v-f);if(x.length>u-m&&Math.abs(y)<=l.y){Math.abs(y)<l.y&&(i.length=0),l.y=Math.abs(y);let P={type:"gap",direction:"center_vertical",gap:x,offset:y};i.push(P);continue}let[,w,,]=x.startBounds,T=w-u,S=wt(T-x.length);if(Math.abs(S)<=l.y){Math.abs(S)<l.y&&(i.length=0),l.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,A]=x.endBounds,M=wt(m-A),O=x.length-M;if(Math.abs(O)<=l.y){Math.abs(O)<l.y&&(i.length=0),l.y=Math.abs(O);let P={type:"gap",direction:"side_bottom",gap:x,offset:O};i.push(P);continue}}}},DS=(e,t,o,r)=>{let n=_S(e,t,o,r);return bf(n,r).filter(i=>!(i.length===1&&mt(i[0]))).flatMap(i=>Md(i,r))},bs=(e,t,o,r,n,i,l)=>{if(!Gn({app:o,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];let a=mr.getReferenceSnapPoints();if(a)for(let s of t)for(let c of a){let d=c[0]-s[0],m=c[1]-s[1];Math.abs(d)<=l.x&&(Math.abs(d)<l.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:d}),l.x=Math.abs(d)),Math.abs(m)<=l.y&&(Math.abs(m)<l.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:m}),l.y=Math.abs(m))}},RS=(e,t,o,r,n)=>{let i=o.state,l=ae(e,i);if(!Gn({app:o,event:r,selectedElements:l})||l.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=wt(t.x),t.y=wt(t.y);let a=[],s=[],c=Eh(i.zoom.value),d={x:c,y:c},m=Md(l,n,{dragOffset:t});bs(l,m,o,r,a,s,d),AS(l,t,o,r,a,s,d);let p={x:a[0]?.offset??0,y:s[0]?.offset??0};d.x=0,d.y=0,a.length=0,s.length=0;let u={x:wt(t.x+p.x),y:wt(t.y+p.y)};bs(l,Md(l,n,{dragOffset:u}),o,r,a,s,d),AS(l,u,o,r,a,s,d);let b=nx(a,s),f=QP(l,u,[...a,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...b,...f]}},wt=e=>Math.round(e*10**6)/10**6,LS=e=>{let t=new Map;for(let o of e){let r=o.join(",");t.has(r)||t.set(r,o)}return Array.from(t.values())},nx=(e,t)=>{let o={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=wt(n.points[0][0]);o[i]||(o[i]=[]),o[i].push(...n.points.map(l=>_(wt(l[0]),wt(l[1]))))}}if(t.length>0){for(let n of t)if(n.type==="point"){let i=wt(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(l=>_(wt(l[0]),wt(l[1]))))}}return Object.entries(o).map(([n,i])=>({type:"points",points:LS(i.map(l=>_(Number(n),l[1])).sort((l,a)=>l[1]-a[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:LS(i.map(l=>_(l[0],Number(n))).sort((l,a)=>l[0]-a[0]))})))},JP=e=>{let t=new Map;for(let o of e){let r=o.points.flat().map(n=>[wt(n)]).join(",");t.has(r)||t.set(r,o)}return Array.from(t.values())},QP=(e,t,o)=>{let[r,n,i,l]=qm(e,t),a=[];for(let s of o){let[c,d,m,p]=s.gap.startBounds,[u,b,f,x]=s.gap.endBounds,v=Zs(zo(n,l),s.gap.overlap),y=Zs(zo(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[_(s.gap.startSide[0][0],E),_(r,E)]},{type:"gap",direction:"horizontal",points:[_(i,E),_(s.gap.endSide[0][0],E)]})}break}case"center_vertical":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[_(E,s.gap.startSide[0][1]),_(E,n)]},{type:"gap",direction:"vertical",points:[_(E,l),_(E,s.gap.endSide[0][1])]})}break}case"side_right":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[_(m,E),_(u,E)]},{type:"gap",direction:"horizontal",points:[_(f,E),_(r,E)]})}break}case"side_left":{if(v){let E=(v[0]+v[1])/2;a.push({type:"gap",direction:"horizontal",points:[_(i,E),_(c,E)]},{type:"gap",direction:"horizontal",points:[_(m,E),_(u,E)]})}break}case"side_top":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[_(E,l),_(E,d)]},{type:"gap",direction:"vertical",points:[_(E,p),_(E,b)]})}break}case"side_bottom":{if(y){let E=(y[0]+y[1])/2;a.push({type:"gap",direction:"vertical",points:[_(E,p),_(E,b)]},{type:"gap",direction:"vertical",points:[_(E,x),_(E,n)]})}break}}}return JP(a.map(s=>({...s,points:s.points.map(c=>_(wt(c[0]),wt(c[1])))})))},ix=(e,t,o,r,n,i)=>{if(!Gn({event:r,selectedElements:e,app:o})||e.length===0||e.length===1&&!qP(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[l,a,s,c]=we(t);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(l+=n.x),i.includes("n")?a+=n.y:i.includes("s")&&(c+=n.y));let d=[];if(i)switch(i){case"e":{d.push(_(s,a),_(s,c));break}case"w":{d.push(_(l,a),_(l,c));break}case"n":{d.push(_(l,a),_(s,a));break}case"s":{d.push(_(l,c),_(s,c));break}case"ne":{d.push(_(s,a));break}case"nw":{d.push(_(l,a));break}case"se":{d.push(_(s,c));break}case"sw":{d.push(_(l,c));break}}let m=Eh(o.state.zoom.value),p={x:m,y:m},u=[],b=[];bs(t,d,o,r,u,b,p);let f={x:u[0]?.offset??0,y:b[0]?.offset??0};p.x=0,p.y=0,u.length=0,b.length=0;let[x,v,y,E]=we(e).map(S=>wt(S)),w=[_(x,v),_(x,E),_(y,v),_(y,E)];bs(e,w,o,r,u,b,p);let T=nx(u,b);return{snapOffset:f,snapLines:T}},NS=(e,t,o,r,n,i)=>{if(!Gn({event:o,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let l=[_(r.x+n.x,r.y+n.y)],a=Eh(t.state.zoom.value),s={x:a,y:a},c=[],d=[];bs([e],l,t,o,c,d,s);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,c.length=0,d.length=0;let p=Md([e],i,{boundingBoxCorners:!0,omitCenter:!0});bs([e],p,t,o,c,d,s);let u=nx(c,d);return{snapOffset:m,snapLines:u}},OS=(e,t,o,r,n)=>{if(!Gn({event:r,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=xf(e,[],t.state,n),l=Eh(t.state.zoom.value),a={x:l,y:l},s=[],c=[];for(let d of i){let m=Md([d],n);for(let p of m){let u=p[0]-o.x;Math.abs(u)<=Math.abs(a.x)&&(Math.abs(u)<Math.abs(a.x)&&(c.length=0),c.push({type:"pointer",points:[p,_(p[0],o.y)],direction:"vertical"}),a.x=u);let b=p[1]-o.y;Math.abs(b)<=Math.abs(a.y)&&(Math.abs(b)<Math.abs(a.y)&&(s.length=0),s.push({type:"pointer",points:[p,_(o.x,p[1])],direction:"horizontal"}),a.y=b)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-o.x:0,y:s.length>0?s[0].points[0][1]-o.y:0},snapLines:[...c,...s]}},FS=e=>e===ht.rectangle||e===ht.ellipse||e===ht.diamond||e===ht.frame||e===ht.magicframe||e===ht.image||e===ht.text;var Ad=class{constructor(t){C(this,"scene");C(this,"_getRenderableElements",Yy(({canvasNonce:t,zoom:o,offsetLeft:r,offsetTop:n,scrollX:i,scrollY:l,height:a,width:s,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),b=this.getVisibleCanvasElements({elementsMap:p,zoom:o,offsetLeft:r,offsetTop:n,scrollX:i,scrollY:l,height:a,width:s});return{elementsMap:p,visibleElements:b,newElementCanvasElement:u,canvasNonce:t}}));C(this,"getRenderableElements",t=>{let{newElement:o}=t,r=`${this.scene.getSceneNonce()}${o?.frameId?`:${o.versionNonce}`:""}`,n=this._getRenderableElements({canvasNonce:r,zoom:t.zoom,offsetLeft:t.offsetLeft,offsetTop:t.offsetTop,scrollX:t.scrollX,scrollY:t.scrollY,height:t.height,width:t.width,editingTextElement:t.editingTextElement,newElement:t.newElement});if(t.frameToHighlight&&t.selectedElementsAreBeingDragged&&Tc(t.selectedElements)!==t.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:n.visibleElements,selectedElements:t.selectedElements,frameToHighlight:t.frameToHighlight});return{...n,visibleElements:i}}return n});this.scene=t}getVisibleCanvasElements({elementsMap:t,zoom:o,offsetLeft:r,offsetTop:n,scrollX:i,scrollY:l,height:a,width:s}){let c=[];for(let d of t.values())Cc(d,s,a,{zoom:o,offsetLeft:r,offsetTop:n,scrollX:i,scrollY:l},t)&&c.push(d);return c}getRenderableElementsMap({elements:t,editingTextElement:o,newElement:r}){let n=new Map,i=r?.frameId?null:r;for(let l of t)i?.id!==l.id&&(!o||o.type!=="text"||l.id!==o.id)&&n.set(l.id,l);return{elementsMap:n,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:t,selectedElements:o,frameToHighlight:r}){if(!o.length)return t;let n=ie(o),i=t.filter(a=>!n.has(a.id)),l=Ym(i,r.id);return l===null?t:[...i.slice(0,l),...o,...i.slice(l)]}destroy(){e2.cancel(),this._getRenderableElements.clear()}};import{jsx as oD}from"react/jsx-runtime";var eD=5,tD=(e,t,o)=>{let[r,n]=Yt(e,o),{x:i,y:l}=Ft({sceneX:r+e.width,sceneY:n},t),a=i-t.offsetLeft+10,s=l-t.offsetTop;return{x:a,y:s}},ax=({children:e,element:t,elementsMap:o})=>{let r=tn();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=tD(t,r,o);return oD("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:eD},children:e})};import{version as rD}from"react";import{unstable_batchedUpdates as BS}from"react-dom";var Tt=e=>t=>{BS(e,t)},yh=e=>rc(t=>{BS(e,t)}),xs=(()=>{let e;try{let o=rD.split(".");e=Number(o[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})();var Pe=class Pe{static start(t,o){if(Pe.animations.has(t))return;let r={animation:o,lastTime:0,state:void 0};Pe.animations.set(t,r);let n;try{n=o({deltaTime:0,state:void 0})}catch(i){throw Pe.animations.get(t)===r&&(Pe.animations.delete(t),Pe.cancelScheduledFrameIfIdle()),i}if(Pe.animations.get(t)===r){if(!n){Pe.animations.delete(t),Pe.cancelScheduledFrameIfIdle();return}r.state=n,Pe.scheduleNextFrame()}}static scheduleNextFrame(){Pe.scheduledFrame||(xs()?Pe.scheduledFrame={id:requestAnimationFrame(Pe.tick),type:"raf"}:Pe.scheduledFrame={id:setTimeout(Pe.tick,0),type:"timeout"})}static cancelScheduledFrame(){Pe.scheduledFrame&&(Pe.scheduledFrame.type==="raf"?cancelAnimationFrame(Pe.scheduledFrame.id):clearTimeout(Pe.scheduledFrame.id),Pe.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return Pe.animations.size>0?!1:(Pe.cancelScheduledFrame(),!0)}static tick(){if(Pe.scheduledFrame=null,Pe.animations.size>0){let t=[...Pe.animations];for(let[o,r]of t){if(Pe.animations.get(o)!==r)continue;let n=performance.now(),i=r.lastTime===0?0:n-r.lastTime,l=r.animation({deltaTime:i,state:r.state});if(Pe.animations.get(o)===r){if(l)r.lastTime=n,r.state=l;else if(Pe.animations.delete(o),Pe.cancelScheduledFrameIfIdle())return}}if(Pe.cancelScheduledFrameIfIdle())return;Pe.scheduleNextFrame()}}static running(t){return Pe.animations.has(t)}static cancel(t){Pe.animations.delete(t),Pe.cancelScheduledFrameIfIdle()}static reset(){Pe.animations.clear(),Pe.cancelScheduledFrame()}};C(Pe,"scheduledFrame",null),C(Pe,"animations",new Map);var Rt=Pe;var vh=class vh{constructor(t,o){this.app=t;this.options=o;C(this,"currentTrail");C(this,"pastTrails",[]);C(this,"container");C(this,"trailElement");C(this,"trailAnimation");C(this,"key");this.key=`animated-trail-${vh.counter++}`,this.trailElement=document.createElementNS($g,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS($g,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,o){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===t&&this.currentTrail.originalPoints[r-1][1]===o}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),Rt.running(this.key)||Rt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){Rt.cancel(this.key),this.cleanup()}startPath(t,o){this.currentTrail=new Zy(this.options),this.currentTrail.addPoint([t,o,performance.now()]),this.update()}addPointToPath(t,o){this.currentTrail&&(this.currentTrail.addPoint([t,o,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())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let t=[];for(let r of this.pastTrails)t.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);t.push(r)}if(this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline(r.options.size/this.app.state.zoom.value).length!==0),t.length===0)return this.trailElement.setAttribute("d",""),!1;let o=t.join(" ").trim();return this.trailElement.setAttribute("d",o),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(t,o){let r=t.getStrokeOutline(t.options.size/o.zoom.value).map(([i,l])=>{let a=Ft({sceneX:i,sceneY:l},o);return[a.x,a.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return Ky(n,!0)}};C(vh,"counter",0);var Rr=vh;var wh=class{constructor(t){this.app=t;C(this,"localTrail");C(this,"collabTrails",new Map);C(this,"container");this.localTrail=new Rr(t,{...this.getTrailOptions(),fill:()=>Gg})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let n=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(jo(i),jo(n))}}}startPath(t,o){this.localTrail.startPath(t,o)}addPointToPath(t,o){this.localTrail.addPointToPath(t,o)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.localTrail.start(t)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(t){for(let[o,r]of this.collabTrails)t?.get(o)||(r.stop(),this.collabTrails.delete(o))}updateCollabTrails(t){if(this.stopCollabTrails(t),!(!this.container||t.size===0))for(let[o,r]of t.entries()){if(r.isCurrentUser)continue;let n=this.collabTrails.get(o);if(n||(n=new Rr(this.app,{...this.getTrailOptions(),fill:()=>r.pointer?.laserColor||Da(o,r)}),n.start(this.container),this.collabTrails.set(o,n)),r.pointer&&r.pointer.tool==="laser"){let i=r.button==="down",l=r.button==="up",a=n.hasCurrentTrail;i&&!a&&n.startPath(r.pointer.x,r.pointer.y);let s=!n.hasLastPoint(r.pointer.x,r.pointer.y);i&&s&&n.addPointToPath(r.pointer.x,r.pointer.y),l&&a&&(n.addPointToPath(r.pointer.x,r.pointer.y),n.endPath())}}}};var nD=12,lx=16,iD=10,aD=lx+2,lD=.8,sx=e=>oa*2/e,cx=(e,t,o)=>{let r=sx(t);if(o!=="desktop"||lx>(e.height+r*2)*t*lD)return null;let n=nD/t,i=lx/t,l=_(e.x+e.width/2,e.y+e.height/2),a=ke(_(l[0]+e.width/2+r+n,l[1]),l,e.angle);return{center:a,start:ke(_(a[0],a[1]-i/2),a,e.angle),end:ke(_(a[0],a[1]+i/2),a,e.angle),hitboxWidth:iD/t,hitboxHeight:aD/t}},zS=(e,t,o,r)=>{let n=cx(t,o,r);if(!n)return!1;let i=ke(_(e.x,e.y),n.center,-t.angle);return Math.abs(i[0]-n.center[0])<=n.hitboxWidth/2&&Math.abs(i[1]-n.center[1])<=n.hitboxHeight/2};var sD=(e,t,o,r,n,i)=>{let{zoom:l}=r,a=180*o/Math.PI,s=e*(l.value-1)/2,c=t*(l.value-1)/2;return e>n&&l.value!==1&&(s=n*(l.value-1)/2),t>i&&l.value!==1&&(c=i*(l.value-1)/2),`translate(${s}px, ${c}px) scale(${l.value}) rotate(${a}deg)`},cD=(e,t)=>{let o=e.lastIndexOf(`
|
|
6
|
+
`,Math.max(0,t-1))+1,r=e.indexOf(`
|
|
7
|
+
`,t),n=e.slice(o,r===-1?e.length:r);return Ny(n)?"rtl":"ltr"},dD=e=>{let t=[0],o=0;for(let r of Array.from(e))o+=r.length,t.push(o);return t},mD=({text:e,font:t,lineHeightPx:o,direction:r,targetX:n})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=dD(e),l=document.createElement("div"),a=document.createTextNode(e),s=document.createRange(),c=[];l.dir=r,Object.assign(l.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:t,lineHeight:`${o}px`}),l.append(a),document.body.append(l);try{for(let u of i){s.setStart(a,u),s.setEnd(a,u);let b=s.getBoundingClientRect();if(!Number.isFinite(b.left))return null;c.push(b.left)}}catch{return null}finally{l.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let b=Math.abs(c[u]-d-n);b<p&&(p=b,m=i[u])}return m},HS=({onChange:e,onSubmit:t,getViewportCoords:o,element:r,canvas:n,excalidrawContainer:i,app:l,autoSelect:a=!0,initialCaretSceneCoords:s=null})=>{let c=null,d=(B,V)=>{if(!V.style.fontFamily||!V.style.fontSize)return!1;let fe=V.style.fontFamily.replace(/"/g,"");return la({fontFamily:B.fontFamily})!==fe||`${B.fontSize}px`!==V.style.fontSize},m=l.state.theme,p=()=>{m=l.state.theme;let B=l.state,V=l.scene.getElement(r.id);if(!V)return;let{textAlign:fe,verticalAlign:Ne}=V,Ze=l.scene.getNonDeletedElementsMap();if(V&&ee(V)){let ye=V.x,Ye=V.y,me=Vr(V,l.scene.getNonDeletedElementsMap()),je=V.width,It=V.height,wr=V.width,Hr=V.height;if(me&&V.containerId){if(Te(me)){let Tr=Z.getBoundTextElementPosition(me,V,Ze);ye=Tr.x,Ye=Tr.y}let Ag=d(V,u),Jn;if(Ag?Jn=sc(me.id,me.height):(Jn=lv[me.id],Jn||(Jn=sc(me.id,me.height))),wr=pc(me,V),Hr=Om(me,V),!Te(me)&&It>Hr){let Tr=dl(It,me.type);l.scene.mutateElement(me,{height:Tr}),ko(me,l.scene);return}else if(!Te(me)&&me.height>Jn.height&&It<Hr){let Tr=dl(It,me.type);l.scene.mutateElement(me,{height:Tr}),ko(me,l.scene)}else{let{x:Tr,y:Lg}=di(me,V,Ze);ye=Tr,Ye=Lg}}let[qn,$a]=o(ye,Ye);me?je+=.5:(wr=(B.width-8-qn)/B.zoom.value,je=Math.min(je,wr)),It*=1.05;let Xs=dt(V),Za=bv(V,me),Qi=(B.height-$a)/B.zoom.value;Object.assign(u.style,{font:Xs,lineHeight:V.lineHeight,width:`${je}px`,height:`${It}px`,left:`${qn}px`,top:`${$a}px`,transform:sD(je,It,Za,B,wr,Qi),textAlign:fe,verticalAlign:Ne,color:Jt(V.strokeColor,B.theme===J.DARK),opacity:V.opacity/100,maxHeight:`${Qi}px`}),c={angle:Za,font:Xs,height:V.height,lineHeightPx:dc(V.fontSize,V.lineHeight),textAlign:fe,width:V.width,x:ye,y:Ye},u.scrollTop=0,Wr()&&(u.style.fontFamily=la(V)),l.scene.mutateElement(V,{x:ye,y:Ye})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let b="pre",f="normal";(mt(r)||!r.autoResize)&&(b="pre-wrap",f="break-word"),Object.assign(u.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:f,whiteSpace:b,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=r.originalText,p();let x=()=>{if(!s||!c)return null;let B=c,V=_(B.x+B.width/2,B.y+B.height/2),[fe,Ne]=ke(_(s.x,s.y),V,-B.angle),Ze=fe-B.x,ye=Ne-B.y,Ye=gv(u.value,B.font,b==="pre-wrap"?B.width:1/0),me=Math.max(0,Math.min(Ye.length-1,Math.floor(ye/B.lineHeightPx))),je=Ye[me],It=cD(u.value,je.start),wr=uv(je.text,B.font),Hr=B.textAlign==="center"?(B.width-wr)/2:B.textAlign==="right"?B.width-wr:0,qn=Ze-Hr;if(!je.text)return je.start;let $a=mD({text:je.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:It,targetX:qn});return je.start+($a||0)},v=(()=>{let B=x();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let V=iC(B),fe=null;if(V.has(pe.excalidrawClipboard)||V.has(pe.excalidraw)){B.preventDefault(),fe=await Kl(B);try{let me=await Lu(fe);if(me.elements){let je=uc(me.elements);if(je){let{selectionStart:It,selectionEnd:wr,value:Hr}=u;u.value=Hr.slice(0,It)+je+Hr.slice(wr);let qn=It+je.length;u.selectionStart=u.selectionEnd=qn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}fe=fe||await Kl(B);let Ne=fe.findByType(pe.text);if(!Ne)return;let Ze=cc(Ne.value);if(!Ze)return;let ye=Vr(r,l.scene.getNonDeletedElementsMap()),Ye=dt({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ye){let me=ve(ye,l.scene.getNonDeletedElementsMap()),je=wn(`${u.value}${Ze}`,Ye,pc(ye,me)),It=hv(je,Ye);u.style.width=`${It}px`}},u.oninput=()=>{let B=cc(u.value);if(u.value!==B){let V=u.selectionStart;u.value=B,u.selectionStart=V,u.selectionEnd=V}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&ld.keyTest(B))B.preventDefault(),l.actionManager.executeAction(ld),p();else if(!B.shiftKey&&sd.keyTest(B))B.preventDefault(),l.actionManager.executeAction(sd),p();else if(!B.shiftKey&&cd.keyTest(B))B.preventDefault(),l.actionManager.executeAction(cd),p();else if(p0.keyTest(B))l.actionManager.executeAction(p0);else if(u0.keyTest(B))l.actionManager.executeAction(u0);else if(B.key===I.ESCAPE)B.preventDefault(),O=!0,P();else if(Di.keyTest(B))B.preventDefault(),P(),l.actionManager.executeAction(Di);else if(B.key===I.ENTER&&B[I.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;O=!0,P()}else if(B.key===I.TAB||B[I.CTRL_OR_CMD]&&(B.code===ge.BRACKET_LEFT||B.code===ge.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===ge.BRACKET_LEFT?S():T(),u.dispatchEvent(new Event("input"))}};let y=4,E=" ".repeat(y),w=new RegExp(`^ {1,${y}}`),T=()=>{let{selectionStart:B,selectionEnd:V}=u,fe=A(),Ne=u.value;fe.forEach(Ze=>{let ye=Ne.slice(0,Ze),Ye=Ne.slice(Ze);Ne=`${ye}${E}${Ye}`}),u.value=Ne,u.selectionStart=B+y,u.selectionEnd=V+y*fe.length},S=()=>{let{selectionStart:B,selectionEnd:V}=u,fe=A(),Ne=[],Ze=u.value;fe.forEach(ye=>{let Ye=Ze.slice(ye,ye+y).match(w);if(Ye){let me=Ze.slice(0,ye),je=Ze.slice(ye+Ye[0].length);Ze=`${me}${je}`,Ne.push(ye)}}),u.value=Ze,Ne.length&&(B>Ne[Ne.length-1]?u.selectionStart=Math.max(B-y,Ne[Ne.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,V-y*Ne.length))},A=()=>{let{selectionStart:B,selectionEnd:V,value:fe}=u,Ne=fe.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-Ne,fe.slice(B,V).split(`
|
|
8
|
+
`).reduce((ye,Ye,me,je)=>ye.concat(me?ye[me-1]+je[me-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},O=!1,P=()=>{if(q)return;q=!0,L();let B=l.scene.getElement(r.id);if(!B)return;let V=Vr(B,l.scene.getNonDeletedElementsMap());if(V){if(u.value.trim()){let fe=mc(V);!fe||fe!==r.id?l.scene.mutateElement(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:r.id})}):Te(V)&&Tn(V)}else l.scene.mutateElement(V,{boundElements:V.boundElements?.filter(fe=>!ee(fe))});St(B,V,l.scene)}t({viaKeyboard:O,nextOriginalText:u.value})},L=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,oe&&oe.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",K),window.removeEventListener("pointerup",D),window.removeEventListener("blur",P),window.removeEventListener("beforeunload",P),$(),F(),W(),u.remove()},D=B=>{window.removeEventListener("pointerup",D);let V=B?.target,fe=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),Ne=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content"),Ze=(V instanceof HTMLElement||V instanceof SVGElement)&&(!!V.closest(`.${et.SHAPE_ACTIONS_MENU}`)||!!V.closest(".compact-shape-actions-island"));setTimeout(()=>{Ze||fe||Ne||(u.onblur=P,u.focus(),v&&(u.setSelectionRange(v.start,v.end),v=null))})},U=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",P)},K=B=>{let V=B?.target;if(B.button===Xo.WHEEL){V instanceof HTMLTextAreaElement&&(B.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(B)),U();return}let fe=V instanceof HTMLElement&&V.classList.contains("properties-trigger"),Ne=(V instanceof HTMLElement||V instanceof SVGElement)&&!!V.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${et.SHAPE_ACTIONS_MENU}, .${et.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!lo(B.target)||fe||Ne?U():B.target instanceof HTMLCanvasElement&&!Wr()&&requestAnimationFrame(()=>{P()})},F=l.onChangeEmitter.on(B=>{l.state.theme!==m&&p()}),$=l.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),W=l.onScrollChangeEmitter.on(()=>{p()}),q=!1;a&&!v&&u.select(),D();let oe=null;return n&&"ResizeObserver"in window?(oe=new window.ResizeObserver(()=>{p()}),oe.observe(n)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",K,{capture:!0})}),window.addEventListener("beforeunload",P),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),P};var Wn=4,pr=6,US="rgba(0,0,0,0.3)",GS=(e,t,o,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,l,a]=we(e),s=t/r.zoom.value,c=o/r.zoom.value,d={top:parseInt(ic("sat"))||0,bottom:parseInt(ic("sab"))||0,left:parseInt(ic("sal"))||0,right:parseInt(ic("sar"))||0},m=Qr().rtl,p=-r.scrollX+d.left,u=-r.scrollY+d.top,b=p+s-d.right,f=u+c-d.bottom,x=Math.min(n,p),v=Math.min(i,u),y=Math.max(l,b),E=Math.max(a,f),w=l-n,T=a-i,S=y-x,A=E-v,M=Math.max(Wn*2,d.left+d.right)+pr*2,O=t*(s/S)-M,P=Math.max(Wn*2,d.top+d.bottom)+pr*2,L=o*(c/A)-P,D=S>w?S*r.zoom.value/(O+M):t/(O+M),U=A>T?A*r.zoom.value/(L+P):o/(L+P);return{horizontal:p===x&&b===y?null:{x:Math.max(d.left,Wn)+pr+(p-x)/S*t,y:o-pr-Math.max(Wn,d.bottom),width:O,height:pr,deltaMultiplier:D},vertical:u===v&&f===E?null:{x:m?Math.max(d.left,Wn):t-pr-Math.max(d.right,Wn),y:Math.max(d.top,Wn)+pr+(u-v)/A*o,width:pr,height:L,deltaMultiplier:U}}},dx=(e,t,o)=>{let[r,n]=[e.horizontal,e.vertical].map(l=>l!=null&&l.x<=t&&t<=l.x+l.width&&l.y<=o&&o<=l.y+l.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var WS=e=>{let t=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${t.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{simplify as pD}from"points-on-curve";var YS=e=>{let{lassoPath:t,elements:o,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:l,simplifyDistance:a,mode:s="contain"}=e,c=t;a&&(c=pD(t,a));let d=o.filter(f=>!f.locked&&!mt(f));l.clear(),i.clear();let m=t.reduce((f,x)=>[Math.min(f[0],x[0]),Math.min(f[1],x[1]),Math.max(f[2],x[0]),Math.max(f[3],x[1])],[1/0,1/0,-1/0,-1/0]),p=ZE(c),u=[m[0]-1e-4,m[1]-1e-4,m[2]+1e-4,m[3]+1e-4];for(let f of d){let x=fi(f,r),v=uD(f,x,r),y=hD(x,v);if(gl(m,y)&&!i.has(f.id)&&!l.has(f.id)){if(s==="contain"&&!Tf(u,y))continue;let E=gD(f,r,n,v),w=xD(p,E,y,s);s==="contain"?w&&!VS(c,f,r,v)&&l.add(f.id):w?l.add(f.id):VS(c,f,r,v)&&i.add(f.id)}}return{selectedElementIds:s==="contain"?bD([...l],r):[...i,...l]}},uD=(e,t,o)=>{let r=Cn(e,o);if(!r)return null;let n=fi(r,o);return Tf(n,t)?null:Vm(e,r,o)?n:null},hD=(e,t)=>t?[Math.max(e[0],t[0]),Math.max(e[1],t[1]),Math.min(e[2],t[2]),Math.min(e[3],t[3])]:e,gD=(e,t,o,r)=>{let n=o.get(e.id)??[],i=ve(e,t),l=i?o.get(i.id):null,a=l?.length?[...n,...l]:n;return r?fD(a,r):a},fD=(e,t)=>{let[o,r,n,i]=t,l=[];for(let[[a,s],[c,d]]of e){let m=c-a,p=d-s,u=0,b=1,f=!0;for(let[x,v]of[[-m,a-o],[m,n-a],[-p,s-r],[p,i-s]]){if(x===0){if(v<0){f=!1;break}continue}let y=v/x;if(x<0){if(y>b){f=!1;break}u=Math.max(u,y)}else{if(y<u){f=!1;break}b=Math.min(b,y)}}f&&l.push(ea(_(a+u*m,s+u*p),_(a+b*m,s+b*p)))}return l},bD=(e,t)=>{if(!e.some(n=>t.get(n)?.groupIds.length))return e;let o=new Map;for(let n of t.values()){let i=n.groupIds.at(-1);if(!i||n.locked||mt(n))continue;let l=o.get(i);l?l.push(n.id):o.set(i,[n.id])}if(!o.size)return e;let r=new Set(e);return e.filter(n=>{let i=t.get(n)?.groupIds.at(-1),l=i?o.get(i):null;return!l||l.every(a=>r.has(a))})},xD=(e,t,o,r)=>{let n=r==="contain"?"every":"some",i=l=>lm(l,e)||r==="contain"&&yD(l,e);return t.length===0?ED(o)[n](i):t[n](l=>l[n](i))},ED=([e,t,o,r])=>[_(e,t),_(o,t),_(o,r),_(e,r)],yD=(e,t)=>t.some((o,r)=>r>0&&jE(e,ea(t[r-1],o))),VS=(e,t,o,r)=>{let n=e.slice(1).map((a,s)=>ea(e[s],a)).concat([ea(e[e.length-1],e[0])]),i=ve(t,o),l=(a,s)=>{let c=fc(a,o,s,0,!r);return r?c.some(d=>ew(d,r)):c.length>0};return n.some(a=>l(t,a)||!!i&&l({...i,...di(t,i,o)},a))};var Ch=class extends Rr{constructor(o){super(o,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),a=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(jo(a),jo(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});C(this,"intersectedElements",new Set);C(this,"enclosedElements",new Set);C(this,"elementsSegments",null);C(this,"canvasTranslate",null);C(this,"keepPreviousSelection",!1);C(this,"selectElementsFromIds",o=>{this.app.setState(r=>{let n=o.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&re(c)){let d=er(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete n[m.id]}}let i=kt({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),l=[...Object.keys(i.selectedElementIds)],a=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:l.length===1&&!a.length&&Se(this.app.scene.getNonDeletedElement(l[0]))?new Z(this.app.scene.getNonDeletedElement(l[0]),this.app.scene.getNonDeletedElementsMap()):null}})});C(this,"addPointToPath",(o,r,n=!1)=>{super.addPointToPath(o,r),this.keepPreviousSelection=n,this.updateSelection()});C(this,"updateSelection",()=>{let o=super.getCurrentTrail()?.originalPoints?.map(n=>_(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!Lt(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=ie(this.app.visibleElements);for(let i of this.app.visibleElements){let l=jm(i,n);this.elementsSegments.set(i.id,l)}}if(o){let{selectedElementIds:n}=YS({lassoPath:o,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(n)}})}startPath(o,r,n=!1){this.endPath(),super.startPath(o,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};var Ih=class extends Rr{constructor(o){super(o,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),a=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(jo(a),jo(l))},fill:()=>o.state.theme===J.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});C(this,"elementsToErase",new Set);C(this,"groupsToErase",new Set)}startPath(o,r){this.endPath(),super.startPath(o,r),this.elementsToErase.clear()}addPointToPath(o,r,n=!1){return super.addPointToPath(o,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(o){let r=super.getCurrentTrail()?.originalPoints?.map(a=>_(a[0],a[1]))||[];if(r.length<2)return[];let n=ea(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(a=>!a.locked),l=ie(i);for(let a of i)if(o&&this.elementsToErase.has(a.id)){if(KS(n,a,l,this.app.state.zoom.value)){let c=a.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=He(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(mt(a)&&this.elementsToErase.delete(a.containerId),Ht(a)){let d=mc(a);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(a.id)}}else if(!o&&!this.elementsToErase.has(a.id)&&KS(n,a,l,this.app.state.zoom.value)){let c=a.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=He(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(Ht(a)){let d=mc(a);d&&this.elementsToErase.add(d)}mt(a)&&this.elementsToErase.add(a.containerId),this.elementsToErase.add(a.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},KS=(e,t,o,r)=>{let n=e[1],i=ll(t)?15:t.strokeWidth/2,l=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],a=fi(t,o),s=[a[0]-i,a[1]-i,a[2]+i,a[3]+i];if(!gl(l,s))return!1;if(Cv(t)&&bc(n,t,o))return!0;if(ll(t)){let d=Qv(t),m=Jv(t,d,o),p=Math.max(2.25,5/r);for(let b of m)if(Hg(b,e)<=p)return!0;let u=$E(...d.map(([b,f])=>_(t.x+b,t.y+f)));return!!lm(e[0],u)}let c=ve(t,o);if(Te(t)||at(t)&&!t.polygon){let d=Math.max(t.strokeWidth,t.strokeWidth*2/r),m=jm(t,o);for(let p of m)if(Hg(p,e)<=d)return!0;return!1}return fc(t,o,e,0,!0).length>0||!!c&&fc({...c,...di(t,c,o)},o,e,0,!0).length>0};var XS=44,$S=22,ZS=66,jS=48,Ld=14,qS=304,JS=320,mx=5.87,QS=28,e3=4,t3=2,px=10,o3=10,r3=8,mn=12,Es=256,Ha=10,ux=4,ys=mn*2,hx=mn*2,n3=100,i3=140,_d=.35,a3=mn/2,Wi=20,Sh=mn*2,gx=mn,st={fillStyle:"hachure",fontFamily:Qa,fontSize:Qn,opacity:100,roughness:1,strokeColor:ra,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Zo.MIDDLE,locked:!1};var Ua=yy(by),vD=e=>e.labels?.length??e.series[0]?.values.length??0,vs=(e,t)=>{if(!e)return!1;let o=vD(e);return o<2?!1:t==="radar"?o>=3:!0},l3=(e,t)=>{let o=t<=1?0:Math.min(ZS,(t-1)*$S);return e+o},kh=(e,t)=>{if(e==="line"){let r=l3(jS,t);return{slotWidth:r,gap:Ld,chartHeight:JS,xLabelMaxWidth:r+Ld*3+px}}let o=l3(XS,t);return{slotWidth:o,gap:Ld,chartHeight:qS,xLabelMaxWidth:o+Ld*3+px}},ws=(e,t)=>{let o=(t.slotWidth+t.gap)*e.series[0].values.length+t.gap,r=t.chartHeight+t.gap*2;return{chartWidth:o,chartHeight:r}},c3=()=>{let e=Es+hx*2,t=Es+hx*2;return{chartWidth:e,chartHeight:t}},wD=(e,t,o)=>{let r=Math.abs(e-t);return Math.min(r,o-r)},Ts=(e,t)=>{if(e<=0||Ua.length===0)return[];let o=Ua.length,r=(t%o+o)%o,n=[r],i=Math.min(e,o),l=new Set(Array.from({length:o},(a,s)=>s).filter(a=>a!==r));for(;n.length<i;){let a=-1,s=-1,c=-1;for(let d of l){let m=n.map(b=>wD(d,b,o)),p=Math.min(...m),u=m.reduce((b,f)=>b+f,0)/m.length;(p>s||p===s&&u>c)&&(a=d,s=p,c=u)}n.push(a),l.delete(a)}return Array.from({length:e},(a,s)=>Ua[n[s%n.length]])},Cs=e=>{if(Ua.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*Ua.length);let t=e.toString(),o=0;for(let r=0;r<t.length;r++)o=o*31+t.charCodeAt(r)|0;return Math.abs(o)%Ua.length},Is=e=>Ua[e],d3=(e,t)=>{let o=e.flatMap(a=>a.values.map(s=>Math.max(0,s))),r=o.filter(a=>a>0),n=Math.max(1,...o),i=r.length>0?Math.min(...r):1,l=e.length===1&&i>0&&n/i>=n3;return{renderSteps:!1,normalize:(a,s)=>{let c=Math.max(0,a);return l?Math.log10(c+1)/Math.log10(n+1):c/n}}},TD=e=>/\s/.test(e.trim()),Mh=(e,t,o)=>TD(e)?wn(e,t,o):e,m3=(e,t,o,r,n,i)=>{let l=ct.Excalifont,a=$o.sm,s=ho(l),c=dt({fontFamily:l,fontSize:a}),d=Math.min(i3,n*(e.length>8?.56:.72)),m=cl(c,s),p=e.map((f,x)=>{let v=t[x],y=Math.max(0,...f.trim().split(/\s+/).filter(Boolean).map(F=>lt(F,c,s).width)),E=Math.max(m,d,y),w=Mh(f,c,E),T=lt(w,c,s),S=Math.cos(v),A=Math.sin(v),M=S>_d?"left":S<-_d?"right":"center",O=M==="center"?T.width/2:0,P=Math.abs(S)*O+Math.abs(A)*(T.height/2),L=ys+P+a3,D=o+S*(n+L),U=r+A*(n+L),K=A>_d?mn/3:A<-_d?-mn/3:0;return eo({backgroundColor:i,...st,text:w,originalText:f,x:D,y:U+K,fontFamily:l,fontSize:a,lineHeight:s,textAlign:M,verticalAlign:"middle"})}),u=Math.min(...p.map(f=>f.y)),b=Math.max(...p.map(f=>f.y+f.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:b}},Ss=(e,t,o,r,n,i)=>{if(e.length<=1)return[];let l=ct["Lilita One"],a=$o.lg,s=ho(l),c=dt({fontFamily:l,fontSize:a}),d=e.map((w,T)=>{let S=w.title?.trim()||`Series ${T+1}`,A=Mh(S,c,Es),M=lt(A,c,s),O=Wi+gx+M.width;return{label:S,displayLabel:A,color:t[T],width:O,height:M.height}}),m=Math.max(Wi/2,...d.map(w=>w.height/2)),p=Math.max(n,r+m+ys),u=Sh,b=Wi*.6,f=d.reduce((w,T)=>w+T.width,0)+Sh*Math.max(0,d.length-1),x=f+u*2,v=m*2+b*2,y=[];y.push(Ao({...st,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:ra,x:o-x/2,y:p-v/2,width:x,height:v,roughness:el.architect,roundness:{type:At.PROPORTIONAL_RADIUS}}));let E=o-f/2;return d.forEach(w=>{y.push(Ao({...st,backgroundColor:w.color,type:"rectangle",x:E,y:p-Wi/2,width:Wi,height:Wi,fillStyle:"solid",strokeColor:w.color,roughness:el.architect,roundness:{type:At.PROPORTIONAL_RADIUS}})),y.push(eo({...st,text:w.displayLabel,originalText:w.label,autoResize:!1,x:E+Wi+gx,y:p,fontFamily:l,fontSize:a,lineHeight:s,textAlign:"left",verticalAlign:"middle"})),E+=w.width+Sh}),y},CD=(e,t,o,r)=>{if(lt(e,o,r).width<=t)return e;let n=e.length;for(;n>1;){let i=`${e.slice(0,n)}...`;if(lt(i,o,r).width<=t)return i;n--}return e[0]?`${e[0]}...`:e},ID=(e,t,o,r)=>{if(lt(e,o,r).width<=t)return{wrapped:!1,text:e};let n=e.trim().split(/\s+/).filter(Boolean);return n.length>1&&!n.some(l=>lt(l,o,r).width>t)&&t>=cl(o,r)?{wrapped:!0,text:wn(e,o,t)}:{wrapped:!1,text:CD(e,t,o,r)}},p3=(e,t,o)=>{let r=Math.abs(Math.cos(o)),n=Math.abs(Math.sin(o));return{width:e*r+t*n,height:e*n+t*r}},s3=e=>e.includes("..."),SD=(e,t,o,r,n)=>{let i=Math.max(QS,Math.ceil(cl(r,n))),l=Math.max(i,Math.floor(t)),a=[];for(let u=l;u>=i;u-=4)a.push(u);a[a.length-1]!==i&&a.push(i);let s=u=>{let b=s3(u.text),f=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,x=u.text.split(`
|
|
9
|
+
`).length;return{ellipsified:b,visibleChars:f,lineCount:x}},c=(u,b)=>{let f=s(u),x=s(b);return f.ellipsified!==x.ellipsified?!f.ellipsified:f.visibleChars!==x.visibleChars?f.visibleChars>x.visibleChars:f.lineCount!==x.lineCount?f.lineCount<x.lineCount:u.rotatedHeight<b.rotatedHeight},d=null,m=null,p=null;for(let u of a){let{wrapped:b,text:f}=ID(e,u,r,n),x=lt(f,r,n),v=p3(x.width,x.height,mx),y={originalText:e,text:f,metrics:x,rotatedWidth:v.width,rotatedHeight:v.height,wrapped:b},E=v.width-o;if(E<=0){(!d||c(y,d))&&(d=y);continue}(!m||E<m.overflow||E===m.overflow&&c(y,m.spec))&&(m={overflow:E,spec:y}),!s3(y.text)&&(!p||E<p.overflow||E===p.overflow&&c(y,p.spec))&&(p={overflow:E,spec:y})}return d||(p&&m&&p.overflow<=m.overflow+r3?p.spec:m.spec)},Ah=e=>{if(e.type!=="text")return e.y+e.height;let t=p3(e.width,e.height,e.angle);return e.y+e.height/2+t.height/2},Pd=(e,t,o,r,n)=>{let i=st.fontFamily,l=$o.sm,a=ho(i),s=dt({fontFamily:i,fontSize:l}),c=Math.max(1,n.slotWidth+n.gap-e3*2+o3),d=o;return e.labels?.map((m,p)=>{let u=SD(m,n.xLabelMaxWidth,c,s,a),b=t+p*(n.slotWidth+n.gap)+n.gap+n.slotWidth/2,f=d+t3+(u.rotatedHeight-u.metrics.height)/2;return eo({backgroundColor:r,...st,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:b,y:f,angle:mx,fontSize:l,lineHeight:a,textAlign:"center",verticalAlign:"top"})})||[]},kD=(e,t,o,r,n,i=Math.max(...e.series[0].values))=>{let l=eo({backgroundColor:r,...st,x:t-n.gap,y:o-n.gap,text:"0",textAlign:"right"}),a=eo({backgroundColor:r,...st,x:t-n.gap,y:o-n.chartHeight-l.height/2,text:i.toLocaleString(),textAlign:"right"});return[l,a]},MD=(e,t,o,r,n)=>{let{chartWidth:i,chartHeight:l}=ws(e,n),a=to({backgroundColor:r,...st,type:"line",x:t,y:o,width:i,points:[_(0,0),_(i,0)]}),s=to({backgroundColor:r,...st,type:"line",x:t,y:o,height:l,points:[_(0,0),_(0,-l)]}),c=to({backgroundColor:r,...st,type:"line",x:t,y:o-n.chartHeight-n.gap,strokeStyle:"dotted",width:i,opacity:Ha,points:[_(0,0),_(i,0)]});return[a,s,c]},Lh=(e,t,o,r,n,i=Math.max(...e.series[0].values),l)=>{let{chartWidth:a,chartHeight:s}=ws(e,n),c=e.title?eo({backgroundColor:r,...st,text:e.title,x:t+a/2,y:o-n.chartHeight-n.gap*2-Qn,roundness:null,textAlign:"center",fontSize:$o.xl,fontFamily:ct["Lilita One"]}):null,d=l?Ao({backgroundColor:r,...st,type:"rectangle",x:t,y:o-s,width:a,height:s,strokeColor:ra,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Pd(e,t,o,r,n),...kD(e,t,o,r,n,i),...MD(e,t,o,r,n)]};var u3=(e,t,o,r)=>{let n=e.series,i=kh("bar",n.length),l=Math.max(1,...n.flatMap(w=>w.values.map(T=>Math.max(0,T)))),a=Cs(r),s=Is(a),c=Ts(n.length,a),d=n.length>1?Math.max(1,Math.floor(i.gap/(n.length+1))):0,m=n.length>1?Math.max(2,(i.slotWidth-d*(n.length-1))/n.length):i.slotWidth,p=n.length*m+d*(n.length-1),u=(i.slotWidth-p)/2,b=n[0].values.flatMap((w,T)=>n.map((S,A)=>{let O=Math.max(0,S.values[T]??0)/l*i.chartHeight,P=n.length>1?c[A]:s;return Ao({backgroundColor:P,...st,type:"rectangle",fillStyle:n.length>1?"solid":st.fillStyle,strokeColor:n.length>1?P:st.strokeColor,x:t+T*(i.slotWidth+i.gap)+i.gap+u+A*(m+d),y:o-O-i.gap,width:m,height:O})})),f=Lh(e,t,o,s,i,l,Bt()),x=Pd(e,t,o,s,i),v=Math.max(o+i.gap/2,...x.map(w=>Ah(w))),{chartWidth:y}=ws(e,i),E=Ss(n,c,t+y/2,v,o+i.gap*5,s);return[...f,...b,...E]};var h3=(e,t,o,r)=>{let n=e.series,i=kh("line",n.length),l=Math.max(1,...n.flatMap(E=>E.values)),a=Cs(r),s=Is(a),c=Ts(n.length,a),d=n.map((E,w)=>{let T=E.values.map((P,L)=>_(L*(i.slotWidth+i.gap),-(P/l)*i.chartHeight)),S=Math.max(...T.map(P=>P[0])),A=Math.max(...T.map(P=>P[1])),M=Math.min(...T.map(P=>P[0])),O=Math.min(...T.map(P=>P[1]));return to({backgroundColor:"transparent",...st,type:"line",x:t+i.gap+i.slotWidth/2,y:o-i.gap,height:A-O,width:S-M,strokeColor:c[w],strokeWidth:2,points:T})}),m=n.flatMap((E,w)=>E.values.map((T,S)=>{let A=S*(i.slotWidth+i.gap)+i.gap/2,M=-(T/l)*i.chartHeight+i.gap/2;return Ao({backgroundColor:c[w],...st,fillStyle:"solid",strokeColor:c[w],strokeWidth:2,type:"ellipse",x:t+A+i.slotWidth/2,y:o+M-i.gap*2,width:i.gap,height:i.gap})})),u=n[0].values.map((E,w)=>Math.max(0,...n.map(T=>T.values[w]??0))).map((E,w)=>{let T=w*(i.slotWidth+i.gap)+i.gap/2,S=E/l*i.chartHeight+i.gap/2+i.gap;return to({backgroundColor:s,...st,type:"line",x:t+T+i.slotWidth/2+i.gap/2,y:o-S,height:S,strokeStyle:"dotted",opacity:Ha,points:[_(0,0),_(0,S)]})}),b=Lh(e,t,o,s,i,l,Bt()),f=Pd(e,t,o,s,i),x=Math.max(o+i.gap/2,...f.map(E=>Ah(E))),{chartWidth:v}=ws(e,i),y=Ss(n,c,t+v/2,x,o+i.gap*5,s);return[...b,...d,...u,...m,...y]};var Nr=e=>{let t=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},AD=(e,t)=>e.slice(1).every(o=>Nr(o[t])!==null),g3=e=>{let t=e[0].length;if(t>2){let l=e[0].every(m=>Nr(m)===null),a=l?e.slice(1):e;if(a.length<1)return{ok:!1,reason:"No data rows"};if(a.some(m=>m.slice(1).some(p=>Nr(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(t-1>a.length){let m=l?e[0].slice(1).map(b=>b.trim()):null,p=a.map(b=>({title:b[0]?.trim()||null,values:b.slice(1).map(f=>Nr(f))}));return{ok:!0,data:{title:p.length===1?p[0].title:l&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,b=`Series ${u}`;return{title:l&&m.trim()||b,values:a.map(f=>Nr(f[u]))}});return{ok:!0,data:{title:l&&e[0][0].trim()||null,labels:a.map(m=>m[0]),series:d}}}if(t===1){if(!AD(e,0))return{ok:!1,reason:"Value is not numeric"};let l=Nr(e[0][0])===null,a=l?e[0][0]:null,s=(l?e.slice(1):e).map(c=>Nr(c[0]));return s.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:a,labels:null,series:[{title:a,values:s}]}}}let o=Nr(e[0][1])===null,r=o?e.slice(1):e;if(r.length<2)return{ok:!1,reason:"Less than 2 rows"};if(r.some(l=>Nr(l[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=o?e[0][1]:null;return{ok:!0,data:{title:i,labels:r.map(l=>l[0]),series:[{title:i,values:r.map(l=>Nr(l[1]))}]}}},_h=e=>{let t=a=>e.replace(/\r\n?/g,`
|
|
10
|
+
`).split(`
|
|
11
|
+
`).filter(s=>s.trim().length>0).map(s=>s.split(a).map(c=>c.trim())),o=[" ",",",";"].map(a=>{let s=t(a),c=s[0]?.length??0,d=s.length>0&&s.every(m=>m.length===c);return{delimiter:a,parsed:s,numCols:c,isConsistent:d}}),n=(o.find(a=>a.isConsistent&&a.numCols>1)??o.find(a=>a.isConsistent)??o[0]).parsed;if(n.length===0)return{ok:!1,reason:"No values"};let i=n[0].length;return n.every(a=>a.length===i)?g3(n):{ok:!1,reason:"All rows don't have same number of columns"}};var f3=(e,t,o,r)=>{if(!vs(e,"radar"))return null;let n=e.labels??e.series[0].values.map((F,$)=>`Value ${$+1}`),i=e.series,{normalize:l,renderSteps:a}=d3(i,n.length),s=Cs(r),c=Is(s),d=Ts(i.length,s),{chartWidth:m,chartHeight:p}=c3(),u=t+m/2,b=o-p/2,f=Es/2,x=n.map((F,$)=>-Math.PI/2+Math.PI*2*$/n.length),{axisLabels:v,axisLabelTopY:y,axisLabelBottomY:E}=m3(n,x,u,b,f,c),w=ct["Lilita One"],T=$o.xl,S=ho(w),A=dt({fontFamily:w,fontSize:T}),M=e.title?Mh(e.title,A,m+ys*2):null,O=M?lt(M,A,S):null,P=M?eo({backgroundColor:c,...st,text:M,originalText:e.title??M,x:t+m/2,y:y-ys-O.height/2,fontFamily:w,fontSize:T,lineHeight:S,textAlign:"center"}):null,L=a?Array.from({length:ux},(F,$)=>{let W=($+1)/ux,q=f*W,oe=x.map(B=>_(Math.cos(B)*q,Math.sin(B)*q));return oe.push(_(oe[0][0],oe[0][1])),to({backgroundColor:"transparent",...st,type:"line",x:u,y:b,width:q*2,height:q*2,strokeStyle:"solid",roughness:el.architect,opacity:Ha,polygon:!0,points:oe})}):[],D=x.map(F=>{let $=Math.cos(F)*f,W=Math.sin(F)*f;return to({backgroundColor:"transparent",...st,type:"line",x:u,y:b,width:Math.abs($),height:Math.abs(W),strokeStyle:"solid",roughness:el.architect,opacity:Ha,points:[_(0,0),_($,W)]})}),U=i.map((F,$)=>{let W=x.map((q,oe)=>{let B=F.values[oe]??0,V=l(B,oe)*f;return _(Math.cos(q)*V,Math.sin(q)*V)});return W.push(_(W[0][0],W[0][1])),to({backgroundColor:"transparent",...st,type:"line",x:u,y:b,width:f*2,height:f*2,strokeColor:d[$],strokeWidth:2,polygon:!0,points:W})}),K=Ss(i,d,u,E,o+mn*5,c);return[...P?[P]:[],...v,...L,...D,...U,...K]};var fx=(e,t,o,r,n)=>e==="line"?h3(t,o,r,n):e==="radar"?f3(t,o,r,n):u3(t,o,r,n);var Ph=class{constructor(t){this.app=t;C(this,"updateHoveredAnchor",t=>{let o=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(t.x,t.y):null,r=this.app.state.hoveredArrowTextAnchor;return(r?.elementId!==o?.elementId||r?.anchor!==o?.anchor)&&this.app.setState({hoveredArrowTextAnchor:o}),o});C(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(t,o){if(!pa(this.app.state))return null;let r=sw(_(t,o),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!r||this.app.getTextElementAtPosition(t,o))return null;let n=this.app.getElementAtPosition(t,o,{includeLockedElements:!0});return n&&n.id!==r.arrow.id&&this.app.scene.getElementIndex(n.id)>this.app.scene.getElementIndex(r.arrow.id)?null:r}getAnchorAtPosition(t,o){let r=this.getBindableEndpointAtPosition(t,o);if(r)return{elementId:r.arrow.id,anchor:r.startOrEnd};let n=this.app.getTextBindableContainerAtPosition(t,o);return!Te(n)||ve(n,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(t,o,this.app.state,n)?{elementId:n.id,anchor:"label"}:null}getTextBinding({arrow:t,startOrEnd:o},r){return cw(t,o,this.app.scene.getNonDeletedElementsMap(),r)}bindText({arrow:t,startOrEnd:o},r,n){Lv(t,r,o,n,this.app.scene)}maybeDragNewText(t,o){return!ee(t)||!dw(t,this.app.scene.getNonDeletedElementsMap())?!1:(vw({newElement:t,...mw(t),pointerX:o.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};var bx=Em.filter(e=>e!==Co.white),Dh=class{constructor(t){this.app=t;C(this,"temporaryEyeDropper",null);C(this,"pending",null);C(this,"handlePointerDown",t=>{this.pending=t});C(this,"handlePointerUp",()=>{let t=this.pending;this.pending=null,t&&this.fill(t)});C(this,"cancel",()=>{this.pending=null});C(this,"cycleBackgroundColor",()=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=bx.indexOf(t),r=bx[(o+1)%bx.length];this.app.actionManager.executeAction(ad,"keyboard",{currentItemBackgroundColor:r})});C(this,"openTemporaryEyeDropper",()=>{if(bt.get(Po))return;let t={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:o=>{this.app.actionManager.executeAction(ad,"ui",{currentItemBackgroundColor:o})}};this.temporaryEyeDropper=t,this.app.updateEditorAtom(Po,t)});C(this,"closeTemporaryEyeDropper",()=>{let t=this.temporaryEyeDropper;this.temporaryEyeDropper=null,t&&bt.get(Po)===t&&this.app.updateEditorAtom(Po,null)});C(this,"restyle",t=>{let o=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);t.backgroundColor===o&&t.fillStyle===this.app.state.currentItemFillStyle&&t.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(t,{backgroundColor:o,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),tr.delete(t),this.app.scheduleCapture())});C(this,"fill",t=>{let o=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),r=this.app.scene.getNonDeletedElements(),n=this.app.scene.getNonDeletedElementsMap(),i=_(t.x,t.y),l=this.app.getElementAtPosition(i[0],i[1]),a=uw({point:i,elements:r,elementsMap:n});if(!a.ok){if(l&&pw(l)){this.restyle(l);return}a.reason==="too_complex"?this.app.setToast({message:h("bucketfill.tooComplex"),duration:3e3}):(a.reason==="open_region"||a.reason==="too_small"||a.reason==="invalid_polygon")&&this.app.setToast({message:h("bucketfill.noRegion"),duration:3e3});return}if(l&&hw({hitElement:l,scenePoints:a.scenePoints,elementsMap:n})){this.restyle(l);return}let{width:s,height:c}=Ly(a.scenePoints),[d,m]=a.scenePoints[0],p=a.scenePoints.map(y=>_(y[0]-d,y[1]-m)),u=a.ownerId?n.get(a.ownerId):null,b=u?re(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(t)?.id??null,f=u?u.groupIds:a.boundaryElementIds.map(y=>n.get(y)?.groupIds).filter(y=>!!y).reduce((y,E)=>y===null?E:y.filter(w=>E.includes(w)),null)??[],x=to({type:"line",x:d,y:m,width:s,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:o,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:b,groupIds:f}),v=this.app.scene.getElementsIncludingDeleted().findIndex(y=>y.id===a.insertion.elementId);this.app.scene.insertElementsAtIndex([x],v<0?null:a.insertion.placement==="above"?v+1:v),this.app.scheduleCapture()});C(this,"getBucketFillBackgroundColor",(t,o)=>Uo(t)?Co.green[xm]:Jt(t,o===J.DARK))}};var b3='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',LD='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',x3='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',_D=`data:${pe.svg},${encodeURIComponent(`${b3}${x3}</svg>`)}`,PD=`data:${pe.svg},${encodeURIComponent(`${b3}${LD}${x3}</svg>`)}`,DD=e=>{let t=yp.map((o,r)=>`<path d="${o}" ${r<2?`fill="${e}"`:""} />`).join("");return`data:${pe.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${t}</g><g stroke="#1b1b1f" stroke-width="1.25">${t}</g></svg>`)}`},Rh=class{constructor(t){this.app=t;C(this,"toolCursorMemo",null);C(this,"eraserCanvasCache",null);C(this,"eraserPreviewDataURL",null);C(this,"set",t=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=t)});C(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Fe.GRAB):this.clear():this.applyForTool()});C(this,"applyForTool",(t=this.app.state.activeTool)=>{let o=this.canvas;if(!o)return;let r=t.type==="eraser"||t.type==="laser"||t.type==="bucketfill"?this.app.state.theme:void 0,n=t.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,r):void 0,i=this.toolCursorMemo;if(!(i?.canvas===o&&i.type===t.type&&i.bucketFillColor===n&&i.theme===r)){if(t.type==="selection")this.clear();else if(kc({activeTool:t}))this.set(Fe.GRAB);else if(rr({activeTool:t}))this.applyEraser();else if(t.type==="autoshape")this.set(Fe.CROSSHAIR);else if(t.type==="bucketfill")this.set(`url(${DD(n)}) 5 18, auto`);else if(t.type==="laser"){let l=this.app.state.theme===J.LIGHT?_D:PD;this.set(`url(${l}), auto`)}else if(t.type==="custom"&&t.customType==="comment"){let l=`data:${pe.svg},${encodeURIComponent(`
|
|
3
12
|
<svg
|
|
4
13
|
width="24"
|
|
5
14
|
height="24"
|
|
@@ -8,107 +17,74 @@ import{$ as ue,$a as ox,$b as Ex,$c as en,$d as Zt,$e as uy,$f as _y,$g as oE,$h
|
|
|
8
17
|
>
|
|
9
18
|
<path
|
|
10
19
|
d="M5.25 18A3.25 3.25 0 0 1 2 14.75v-8.5A3.25 3.25 0 0 1 5.25 3h13.5A3.25 3.25 0 0 1 22 6.25v8.5A3.25 3.25 0 0 1 18.75 18h-5.738L8 21.75a1.25 1.25 0 0 1-1.999-1V18h-.75Zm7.264-1.5h6.236a1.75 1.75 0 0 0 1.75-1.75v-8.5a1.75 1.75 0 0 0-1.75-1.75H5.25A1.75 1.75 0 0 0 3.5 6.25v8.5c0 .966.784 1.75 1.75 1.75h2.249v3.75l5.015-3.75Z"
|
|
11
|
-
fill="${
|
|
20
|
+
fill="${this.app.state.theme===J.LIGHT?"#000":"#fff"}"
|
|
12
21
|
/>
|
|
13
22
|
</svg>
|
|
14
|
-
`)}`;e.style.cursor=`url(${t}) 5 20, auto`}else o.activeTool.type!=="image"&&(e.style.cursor=Pe.AUTO)};var w4=.1,T4=1,C4=.2,I4=.2,mn=null,Pv=(e,o,t)=>{let r=e.viewportZoomFactor?$e(e.viewportZoomFactor,w4,T4):C4,n=e.width,a=e.height,i=o/n,l=t/a,s=vo(Math.min(i,l)*r);return{zoomLevelX:i,zoomLevelY:l,initialZoomLevel:s}},k4=({scrollConstraints:e,width:o,height:t,zoom:r})=>{let{zoomLevelX:n,zoomLevelY:a,initialZoomLevel:i}=Pv(e,o,t),l=e.lockZoom?Math.max(i,r.value):r.value;return{effectiveZoom:vo(l),initialZoomLevel:i,zoomLevelX:n,zoomLevelY:a}},S4=({scrollConstraints:e,width:o,height:t,effectiveZoom:r,zoomLevelX:n,zoomLevelY:a,allowOverscroll:i})=>{let l=e.overscrollAllowance??I4,s=$e(l,0,1),c=x=>{let y=e.x+(e.width-o/x)/-2,w=e.y+(e.height-t/x)/-2;return{centerX:y,centerY:w}},{centerX:m,centerY:p}=c(r),d=Math.min(s*e.width,s*e.height),h=r<=n,b=r<=a,f=(x,y,w,C,S,A)=>{let{pos:M,size:N}=x==="x"?{pos:w.x,size:w.width}:{pos:w.y,size:w.height},R=x==="x"?m:p;return i?y?{min:R-A,max:R+A}:{min:M-N+C/S-A,max:M+A}:y?{min:R,max:R}:{min:M-N+C/S,max:M}},E=f("x",h,e,o,r,d),v=f("y",b,e,t,r,d);return{minScrollX:E.min,maxScrollX:E.max,minScrollY:v.min,maxScrollY:v.max}},Dv=({scrollConstraints:e,width:o,height:t,zoom:r,allowOverscroll:n})=>{let{effectiveZoom:a,initialZoomLevel:i,zoomLevelX:l,zoomLevelY:s}=k4({scrollConstraints:e,width:o,height:t,zoom:r});return{...S4({scrollConstraints:e,width:o,height:t,effectiveZoom:a,zoomLevelX:l,zoomLevelY:s,allowOverscroll:n}),effectiveZoom:{value:a},initialZoomLevel:i}},M4=({scrollX:e,scrollY:o,minScrollX:t,maxScrollX:r,minScrollY:n,maxScrollY:a,constrainedZoom:i})=>{let l=$e(e,t,r),s=$e(o,n,a);return{scrollX:l,scrollY:s,zoom:i}},g1=e=>({...e,x:e.x*-1,y:e.y*-1}),L4=e=>{if(!e.scrollConstraints)return!1;let{scrollX:o,scrollY:t,width:r,height:n,scrollConstraints:a,zoom:i}=e,l=g1(a),s=r/i.value,c=n/i.value;return o>l.x||o-s<l.x-l.width||t>l.y||t-c<l.y-l.height},f1=(e,{scrollX:o,scrollY:t})=>{let{width:r,height:n,scrollConstraints:a}=e;if(!a)return{scrollX:o,scrollY:t,zoom:e.zoom};let i=g1(a),s={value:Pv(i,r,n).initialZoomLevel},c=Dv({scrollConstraints:i,width:r,height:n,zoom:s,allowOverscroll:!1});return{scrollX:c.minScrollX,scrollY:c.minScrollY,zoom:c.effectiveZoom}};var _v={allowOverscroll:!0,disableAnimation:!1},cr=(e,o="elastic")=>{if(!e.scrollConstraints)return e;let{scrollX:t,scrollY:r,width:n,height:a,scrollConstraints:i,zoom:l}=e,s,c;switch(o){case"elastic":({allowOverscroll:s,disableAnimation:c}=_v);break;case"rigid":s=!1,c=!1;break;case"loose":s=!0,c=!0;break;default:({allowOverscroll:s,disableAnimation:c}=_v);break}let m=g1(i),p=mn&&mn.previousState.scrollConstraints&&mn.allowOverscroll===s&&at(e.scrollConstraints,mn.previousState.scrollConstraints)&&at({zoom:l.value,width:n,height:a},{zoom:mn.previousState.zoom.value,width:mn.previousState.width,height:mn.previousState.height}),d=p?mn.constraints:Dv({scrollConstraints:m,width:n,height:a,zoom:l,allowOverscroll:s});p||(mn={previousState:{zoom:e.zoom,width:e.width,height:e.height,scrollConstraints:e.scrollConstraints},constraints:d,allowOverscroll:s});let h=l.value>=d.effectiveZoom.value?M4({scrollX:t,scrollY:r,minScrollX:d.minScrollX,maxScrollX:d.maxScrollX,minScrollY:d.minScrollY,maxScrollY:d.maxScrollY,constrainedZoom:d.effectiveZoom}):f1(e,{scrollX:t,scrollY:r});return{...e,scrollConstraints:{...e.scrollConstraints,animateOnNextUpdate:c?!1:L4(e)},...h}},b1=(e,o)=>Math.abs(e.scrollX-o.scrollX)<.1&&Math.abs(e.scrollY-o.scrollY)<.1&&Math.abs(e.zoom-o.zoom)<.1;var pn=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,a=o-r.offsetTop,i=r.zoom.value,l=r.scrollX+(n-n/i),s=r.scrollY+(a-a/i),c=-(n-n/t),m=-(a-a/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as mp,jsxs as _4}from"react/jsx-runtime";var Rv=H({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?D.IMMEDIATELY:D.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r,data:n})=>mp(Js,{palette:null,topPicks:xd,label:u("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:a=>t({viewBackgroundColor:a}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Dr=H({name:"clearCanvas",label:"labels.clearCanvas",icon:_t,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>re(n,{isDeleted:!0})),appState:{..._a(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:r.state.preferredSelectionTool.type}:o.activeTool},captureUpdate:D.IMMEDIATELY})}),nc=H({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:ym,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:cr({...o,...pn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:vo(o.zoom.value+yi)},o),userToFollow:null}),captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mp(J,{type:"button",className:"zoom-in-button zoom-button",icon:ym,title:`${u("buttons.zoomIn")} \u2014 ${B("CtrlOrCmd++")}`,"aria-label":u("buttons.zoomIn"),disabled:o.zoom.value>=Qu,onClick:()=>{e(null)}}),keyTest:e=>(e.code===he.EQUAL||e.code===he.NUM_ADD)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),ac=H({name:"zoomOut",label:"buttons.zoomOut",icon:Em,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:cr({...o,...pn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:vo(o.zoom.value-yi)},o),userToFollow:null}),captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mp(J,{type:"button",className:"zoom-out-button zoom-button",icon:Em,title:`${u("buttons.zoomOut")} \u2014 ${B("CtrlOrCmd+-")}`,"aria-label":u("buttons.zoomOut"),disabled:o.zoom.value<=Ju,onClick:()=>{e(null)}}),keyTest:e=>(e.code===he.MINUS||e.code===he.NUM_SUBTRACT)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),ic=H({name:"resetZoom",label:"buttons.resetZoom",icon:sg,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...pn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:vo(1)},o),userToFollow:null},captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mp(To,{label:u("buttons.resetZoom"),style:{height:"100%"},children:_4(J,{type:"button",className:"reset-zoom-button zoom-button",title:u("buttons.resetZoom"),"aria-label":u("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===he.ZERO||e.code===he.NUM_ZERO)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),A4=(e,o,t=1)=>{let[r,n,a,i]=e,l=a-r,s=o.width/l,c=i-n,m=o.height/c,d=Math.min(s,m)*$e(t,.1,1);return Math.min(d,1)},Nv=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:a=-1/0,maxZoom:i=1/0})=>{n=$e(n,Ju,Qu);let[l,s,c,m]=e,p=(l+c)/2,d=(s+m)/2,h=t?.left??0,b=t?.top??0,f=t?.right??0,E=t?.bottom??0,v=o.width-h-f,x=o.height-b-E,y;if(r){let S=c-l,A=m-s;y=Math.min(v/S,x/A)*n}else y=A4(e,{width:v,height:x},n);let w=vo($e(L0(y,yi,"floor"),a,i)),C=oE({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:w}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:w}},captureUpdate:D.EVENTUALLY}},lc=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:a,maxZoom:i})=>{let l=_e(ve(o));return Nv({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:a,maxZoom:i})},uF=H({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Ws,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return lc({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===he.TWO&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),hF=H({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Ws,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return lc({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===he.THREE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Ov=H({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Ws,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>lc({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===he.ONE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Xn=H({name:"toggleTheme",label:(e,o)=>o.theme===ne.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===ne.LIGHT?$i:ji,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ne.LIGHT?ne.DARK:ne.LIGHT)},captureUpdate:D.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===he.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),gF=H({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return po(o)?n=Ne(o,{...o.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):n=Ne(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:D.IMMEDIATELY}},keyTest:e=>e.key===T.E}),fF=H({name:"toggleLassoTool",label:"toolBar.lasso",icon:ln,trackEvent:{category:"toolbar"},predicate:(e,o,t,r)=>r.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Ne(o,{type:"lasso",fromSelection:!1}),He(r.interactiveCanvas,Pe.CROSSHAIR)):n=Ne(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:D.NEVER}}}),zv=H({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Us,viewMode:!1,perform:(e,o,t,r)=>{let n;return ir(o)?n=Ne(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Ne(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),He(r.interactiveCanvas,Pe.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:D.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[T.CTRL_OR_CMD]&&e.key===T.H});var Bv=H({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Ne(o,{type:"embeddable"});return Uo(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ne(o,{type:"embeddable"})},captureUpdate:D.EVENTUALLY}}});import{jsx as P4}from"react/jsx-runtime";var $t=H({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let n=e,{interactiveCanvas:a,focusContainer:i,scene:l}=r,s=l.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:h}=t,b=X.getElement(o.selectedLinearElement.elementId,s);je(b,"Arrow element should exist if selectedLinearElement is set"),je(h,"sceneCoords should be defined if actionFinalize is called with event");let f=X.handlePointerUp(d,o.selectedLinearElement,o,r.scene);if(co(b)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let E=!!o.newElement,x=(E||!o.selectedLinearElement.selectedPointsIndices?[b.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((y,w)=>(y.set(w,{point:X.pointFromAbsoluteCoords(b,L(h.x,h.y),s)}),y),new Map)??new Map;Ud(b,x,h.x,h.y,l,o,{newArrow:E,altKey:d.altKey,angleLocked:ds(d)})}else tt(b)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!ph(b.points)&&l.mutateElement(b,{polygon:!1});if(f!==o.selectedLinearElement){b&&vr(b)&&(n=n.map(v=>v.id===b.id?re(v,{isDeleted:!0}):v));let E=o.activeTool?.locked;return{elements:b.points.length<2||vr(b)?e.map(v=>v.id===b.id?re(v,{isDeleted:!0}):v):n,appState:{...o,cursorButton:"up",selectedLinearElement:E?null:{...f,selectedPointsIndices:null,isEditing:!1,initialState:{...f.initialState,lastClickedPoint:-1}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:D.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||co(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:h}=o.selectedLinearElement;(!h||d[d.length-1]!==h)&&l.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&vr(c)&&(n=n.map(d=>d.id===c?.id?re(d,{isDeleted:!0}):d)),ge(c)||Ci(c)){if(hs(c.points,o.zoom.value)&&(tt(c)||Ci(c))){let h=c.points,b=h[0],f=h.map((E,v)=>v===h.length-1?L(b[0],b[1]):E);tt(c)?l.mutateElement(c,{points:f,polygon:!0}):l.mutateElement(c,{points:f})}tt(c)&&!ph(c.points)&&l.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Co(a);let m;o.activeTool.type==="eraser"?m=Ne(o,{...o.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=Ne(o,{type:r.state.preferredSelectionTool.type});let p=c&&ge(c)?new X(c,ie(n)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:n,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:D.IMMEDIATELY}},keyTest:(e,o)=>e.key===T.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===T.ESCAPE||e.key===T.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>P4(J,{type:"button",icon:xg,title:u("buttons.done"),"aria-label":u("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import D4 from"clsx";import{jsx as Fv,jsxs as R4}from"react/jsx-runtime";var sc=({children:e,checked:o,onChange:t,className:r})=>R4("div",{className:D4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Fv("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:ug}),Fv("div",{className:"Checkbox-label",children:e})]});import{jsx as cc}from"react/jsx-runtime";var Uv=e=>{let o=e.title||(e.value===ne.DARK?u("buttons.lightMode"):u("buttons.darkMode"));return cc(J,{type:"icon",icon:e.value===ne.LIGHT?Hv.MOON:Hv.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===ne.DARK?ne.LIGHT:ne.DARK),"data-testid":"toggle-dark-mode"})},Hv={SUN:cc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:cc("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:cc("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:cc("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"})})};import{useState as N4}from"react";import{jsx as Gv,jsxs as O4}from"react/jsx-runtime";var Wv=e=>{let{id:o}=qe(),[t,r]=N4(e.value),n=i=>{e.ignoreFocus||Ex(i.target);let l=i.target.value;l!==e.value&&e.onChange(l)},a=i=>{if(i.key===T.ENTER){if(i.preventDefault(),i.nativeEvent.isComposing||i.keyCode===229)return;i.currentTarget.blur()}};return O4("div",{className:"ProjectName",children:[Gv("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Gv("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:a,id:`${o}-filename`,value:t,onChange:i=>r(i.target.value)})]})};var dr=32,Ze=12,$n=256,Vv=50,$a="NOT_SPREADSHEET",ml="VALID_SPREADSHEET",dc=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},x1=(e,o)=>e.slice(1).every(t=>dc(t[o])!==null),Yv=e=>{let o=e[0].length;if(o>2)return{type:$a,reason:"More than 2 columns"};if(o===1){if(!x1(e,0))return{type:$a,reason:"Value is not numeric"};let s=dc(e[0][0])===null,c=(s?e.slice(1):e).map(m=>dc(m[0]));return c.length<2?{type:$a,reason:"Less than two rows"}:{type:ml,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=x1(e,0),r=x1(e,1);if(!t&&!r)return{type:$a,reason:"Value is not numeric"};let[n,a]=r?[0,1]:[1,0],i=dc(e[0][a])===null,l=i?e.slice(1):e;return l.length<2?{type:$a,reason:"Less than 2 rows"}:{type:ml,spreadsheet:{title:i?e[0][a]:null,labels:l.map(s=>s[n]),values:l.map(s=>dc(s[a]))}}},z4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},Kv=e=>{let o=e.trim().split(`
|
|
15
|
-
`).
|
|
16
|
-
`)
|
|
17
|
-
`).
|
|
18
|
-
|
|
19
|
-
${u("hints.firefox_clipboard_write")}`):new Error(u("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var e2=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:a,fileHandle:i}=o,l=uE(i);if(!i||!hE(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=ja(e,o,!1);return await qa({type:l,data:{elements:s,appState:o,files:t},config:{exportBackground:n,viewBackgroundColor:a,name:r,fileHandle:i,exportingFrame:c}}),{fileHandle:i}};import{Fragment as Q4,jsx as un,jsxs as ek}from"react/jsx-runtime";var fp=H({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>un(Wv,{label:u("labels.fileTitle"),value:n.getName(),onChange:a=>o(a),ignoreFocus:r?.ignoreFocus??!1})}),t2=H({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:D.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=ve(e),a=Be(r,o)?ae(r,o):r,i=(l,s,c)=>{let[,,m,p]=mE(l).map(d=>Math.trunc(d*c));return[m+s*2,p+s*2]};return un(Q4,{children:md.map(l=>{let[s,c]=i(a,Cn,l),m=`${u("imageExportDialog.label.scale")} ${l}x (${s}x${c})`;return un(J,{size:"small",type:"radio",icon:`${l}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:l===o.exportScale,onChange:()=>t(l)},l)})})}}),bp=H({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>un(sc,{checked:e.exportBackground,onChange:t=>o(t),children:u("imageExportDialog.label.withBackground")})}),xp=H({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>ek(sc,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[u("imageExportDialog.label.embedScene"),un(To,{label:u("imageExportDialog.tooltip.embedScene"),long:!0,children:un("div",{className:"excalidraw-tooltip-icon",children:yg})})]})}),jn=H({name:"saveToActiveFile",label:"buttons.save",icon:Fn,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:a}=pm(o.fileHandle)?await e2(e,o,r.files,r.getName()):await lm(e,o,r.files,r.getName());return{captureUpdate:D.EVENTUALLY,appState:{...o,fileHandle:a,toast:n?{message:a?.name?u("toast.fileSavedToFilename").replace("{filename}",`"${a.name}"`):u("toast.fileSaved")}:null}}}catch(a){return a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:D.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e[T.CTRL_OR_CMD]&&!e.shiftKey}),ul=H({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Fn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await lm(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:D.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:u("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:D.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e.shiftKey&&e[T.CTRL_OR_CMD],PanelComponent:({updateData:e})=>un(J,{type:"button",icon:gg,title:u("buttons.saveAs"),"aria-label":u("buttons.saveAs"),showAriaLabel:Te().formFactor==="phone",hidden:!Gi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ja=H({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:a,files:i}=await Kh(o,e);return{elements:n,appState:a,files:i,captureUpdate:D.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:D.EVENTUALLY}}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.O}),o2=H({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:D.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>un("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:un(Uv,{value:e.exportWithDarkMode?ne.DARK:ne.LIGHT,onChange:t=>{o(t===ne.DARK)},title:u("imageExportDialog.label.darkMode")})})});var r2="{}",yp=H({name:"copyStyles",label:"labels.copyStyles",icon:Fm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],a=e.find(i=>o.selectedElementIds[i.id]);if(n.push(a),a&&ft(a)){let i=xe(a,r.scene.getNonDeletedElementsMap());n.push(i)}return a&&(r2=JSON.stringify(n)),{appState:{...o,toast:{message:u("toast.copyStyles")}},captureUpdate:D.EVENTUALLY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.C}),Ep=H({name:"pasteStyles",label:"labels.pasteStyles",icon:Fm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(r2),a=n[0],i=n[1];if(!Px(a))return{elements:e,captureUpdate:D.EVENTUALLY};let l=ae(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=a;if($(c)&&c.containerId&&(m=i),!m)return c;let p=re(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?Rx(m.roundness.type,c)?m.roundness:Nx(c):null});if($(p)){let d=m.fontSize||ha,h=m.fontFamily||xi;p=re(p,{fontSize:d,fontFamily:h,textAlign:m.textAlign||id,lineHeight:m.lineHeight||qr(h)});let b=null;p.containerId&&(b=l.find(f=>$(p)&&f.id===p.containerId)||null),ut(p,b,r.scene)}return p.type==="arrow"&&Me(m)&&(p=re(p,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),le(c)&&(p=re(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:D.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.V});var qn=H({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:dg,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:D.EVENTUALLY}),keyTest:e=>e.key===T.QUESTION_MARK});import{jsx as hl}from"react/jsx-runtime";var tk=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&Ai(n,t),!0))return!0}return!1},n2=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!tk(r)&&!$d(r)},vp=H({name:"group",label:"labels.group",icon:e=>hl(Rm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=dy(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:D.EVENTUALLY};let a=nr(o);if(a.length===1){let E=a[0],v=new Set(Ke(e,E).map(w=>w.id)),x=new Set(n.map(w=>w.id));if(new Set([...Array.from(v),...Array.from(x)]).size===v.size)return{appState:o,elements:e,captureUpdate:D.EVENTUALLY}}let i=[...e];new Set(n.map(E=>E.frameId)).size>1&&sy(n).forEach((v,x)=>{Zd(v,r.scene.getNonDeletedElementsMap())});let s=Ut(),c=ie(n);i=i.map(E=>c.get(E.id)?re(E,{groupIds:ry(E.groupIds,s,o.editingGroupId)}):E);let m=Ke(i,s),p=m[m.length-1],d=i.lastIndexOf(p),h=i.slice(d+1),b=i.slice(0,d).filter(E=>!Ai(E,s)),f=wr([...b,...m,...h],ie(m));return{appState:{...o,...ey(s,{...o,selectedGroupIds:{}},ve(i))},elements:f,captureUpdate:D.IMMEDIATELY}},predicate:(e,o,t,r)=>n2(e,o,r),keyTest:e=>!e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>hl(J,{hidden:!n2(e,o,r),type:"button",icon:hl(Rm,{theme:o.theme}),onClick:()=>t(null),title:`${u("labels.group")} \u2014 ${B("CtrlOrCmd+G")}`,"aria-label":u("labels.group"),visible:Be(ve(e),o)})}),wp=H({name:"ungroup",label:"labels.ungroup",icon:e=>hl(Nm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=nr(o),a=ie(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:D.EVENTUALLY};let i=[...e],l=[];i=i.map(d=>{it(d)&&l.push(d.id);let h=ny(d.groupIds,o.selectedGroupIds);return h.length===d.groupIds.length?d:re(d,{groupIds:h})});let s=bt(o,ve(i),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(d=>d.frameId).map(d=>d.frameId));return cy(e).filter(d=>m.has(d.id)).forEach(d=>{d&&(i=br(i,mo(i,d,o,a),d,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((d,[h,b])=>(b&&!l.includes(h)&&(d[h]=!0),d),{}),{appState:{...o,...s},elements:i,captureUpdate:D.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G.toUpperCase(),predicate:(e,o)=>nr(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>hl(J,{type:"button",hidden:nr(o).length===0,icon:hl(Nm,{theme:o.theme}),onClick:()=>t(null),title:`${u("labels.ungroup")} \u2014 ${B("CtrlOrCmd+Shift+G")}`,"aria-label":u("labels.ungroup"),visible:Be(ve(e),o)})});import ak from"clsx";var Tp=(e,o,t,r,n,a,i)=>{e.beginPath(),e.moveTo(o+a,t),e.lineTo(o+r-a,t),e.quadraticCurveTo(o+r,t,o+r,t+a),e.lineTo(o+r,t+n-a),e.quadraticCurveTo(o+r,t+n,o+r-a,t+n),e.lineTo(o+a,t+n),e.quadraticCurveTo(o,t+n,o,t+n-a),e.lineTo(o,t+a),e.quadraticCurveTo(o,t,o+a,t),e.closePath(),e.fill(),i&&(e.strokeStyle=i),e.stroke()};function ok(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var Qa=(e,o)=>`hsl(${Math.abs(ok(o?.id||e))%37*10}, 100%, 83%)`,a2=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},i2=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[a,i]of o.remotePointerViewportCoords){let{x:l,y:s}=i,c=t.collaborators.get(a);l-=t.offsetLeft,s-=t.offsetTop;let m=11,p=14,d=l<0||l>r-m||s<0||s>n-p;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-p);let h=Qa(a,c);e.save(),e.strokeStyle=h,e.fillStyle=h;let b=o.remotePointerUserStates.get(a),f=d||b==="idle"||b==="away";f&&(e.globalAlpha=.3),o.remotePointerButton.get(a)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=h,e.stroke(),e.closePath());let E=t.theme===ne.DARK?"#2f6330":z0,v=c?.isSpeaking;v&&(e.fillStyle=E,e.strokeStyle=E,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Lo,e.strokeStyle=Lo,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=h,e.strokeStyle=h,e.lineWidth=2,e.lineJoin="round",e.beginPath(),f?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let x=o.remotePointerUsernames.get(a)||"";if(!d&&x){e.font="600 12px sans-serif";let y=(v?l+0:l)+m/2,w=(v?s+0:s)+p+2,C=5,S=3,A=e.measureText(x),M=A.actualBoundingBoxDescent+A.actualBoundingBoxAscent,N=Math.max(M,12),R=y-1,P=w-1,O=A.width+2+C*2+2,Y=N+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(R,P,O,Y,8),e.fillStyle=h,e.fill(),e.strokeStyle=Lo,e.stroke(),v&&(e.beginPath(),e.roundRect(R-2,P-2,O+4,Y+4,8),e.strokeStyle=E,e.stroke())):Tp(e,R,P,O,Y,8,Lo),e.fillStyle=as,e.fillText(x,y+C+1,w+S+A.actualBoundingBoxAscent+Math.floor((N-M)/2)+2),v){e.fillStyle=E;let Q=8,q=8,Z=5;e.fillRect(R+O+q,P+(Y/2-Q/2),2,Q),e.fillRect(R+O+q+Z,P+(Y/2-Q*2/2),2,Q*2),e.fillRect(R+O+q+Z*2,P+(Y/2-Q/2),2,Q)}}e.restore(),e.closePath()}};import rk from"clsx";import{useState as nk}from"react";import{jsx as l2}from"react/jsx-runtime";var y1=({color:e,onClick:o,name:t,src:r,className:n})=>{let a=a2(t),[i,l]=nk(!1),s=!i&&r,c=s?void 0:{background:e};return l2("div",{className:rk("Avatar",n),style:c,onClick:o,children:s?l2("img",{className:"Avatar-img",src:r,alt:a,referrerPolicy:"no-referrer",onError:()=>l(!0)}):a})};import{jsx as Rr,jsxs as Cp}from"react/jsx-runtime";var s2=H({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(je(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:D.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:D.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:a,isBeingFollowed:i}=o,l=Qa(r,n),s=ak({"is-followed":i,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?Cp("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:u("userList.hint.isSpeaking"),children:[Rr("div",{}),Rr("div",{}),Rr("div",{})]}):n.isMuted?Rr("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:u("userList.hint.micMuted"),children:vf}):Rr("div",{title:u("userList.hint.inCall"),children:Ef}):null;return a?Cp("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Rr(y1,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),Rr("div",{className:"UserList__collaborator-name",children:n.username}),Cp("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[i&&Rr("div",{className:"UserList__collaborator-status-icon-is-followed",title:u("userList.hint.followStatus"),children:Ya}),c]})]}):Cp("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Rr(y1,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&Rr("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var Ip=H({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let a of hd)if(n.some(i=>i.type===a))return{captureUpdate:D.EVENTUALLY,appState:{...o,errorMessage:u(`errors.libraryElementTypeError.${a}`)}};return r.library.getLatestLibrary().then(a=>r.library.setLibrary([{id:Ut(),status:"unpublished",elements:n.map(ar),created:Date.now()},...a])).then(()=>({captureUpdate:D.EVENTUALLY,appState:{...o,toast:{message:u("toast.addedToLibrary")}}})).catch(a=>({captureUpdate:D.EVENTUALLY,appState:{...o,errorMessage:a.message}}))},label:"labels.addToLibrary"});import{jsx as fl}from"react/jsx-runtime";var to=(e,o)=>{let t=o.scene.getSelectedElements(e);return Vd(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>le(r))},gl=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),a=Cy(n,r,t.scene,o),i=ie(a);return xr(e.map(l=>i.get(l.id)||l),o,t)},c2=H({name:"alignTop",label:"labels.alignTop",icon:Mm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>to(o,r),perform:(e,o,t,r)=>({appState:o,elements:gl(e,o,r,{position:"start",axis:"y"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fl(J,{hidden:!to(o,r),type:"button",icon:Mm,onClick:()=>t(null),title:`${u("labels.alignTop")} \u2014 ${B("CtrlOrCmd+Shift+Up")}`,"aria-label":u("labels.alignTop"),visible:Be(ve(e),o)})}),d2=H({name:"alignBottom",label:"labels.alignBottom",icon:Lm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>to(o,r),perform:(e,o,t,r)=>({appState:o,elements:gl(e,o,r,{position:"end",axis:"y"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fl(J,{hidden:!to(o,r),type:"button",icon:Lm,onClick:()=>t(null),title:`${u("labels.alignBottom")} \u2014 ${B("CtrlOrCmd+Shift+Down")}`,"aria-label":u("labels.alignBottom"),visible:Be(ve(e),o)})}),m2=H({name:"alignLeft",label:"labels.alignLeft",icon:Am,trackEvent:{category:"element"},predicate:(e,o,t,r)=>to(o,r),perform:(e,o,t,r)=>({appState:o,elements:gl(e,o,r,{position:"start",axis:"x"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fl(J,{hidden:!to(o,r),type:"button",icon:Am,onClick:()=>t(null),title:`${u("labels.alignLeft")} \u2014 ${B("CtrlOrCmd+Shift+Left")}`,"aria-label":u("labels.alignLeft"),visible:Be(ve(e),o)})}),p2=H({name:"alignRight",label:"labels.alignRight",icon:_m,trackEvent:{category:"element"},predicate:(e,o,t,r)=>to(o,r),perform:(e,o,t,r)=>({appState:o,elements:gl(e,o,r,{position:"end",axis:"x"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fl(J,{hidden:!to(o,r),type:"button",icon:_m,onClick:()=>t(null),title:`${u("labels.alignRight")} \u2014 ${B("CtrlOrCmd+Shift+Right")}`,"aria-label":u("labels.alignRight"),visible:Be(ve(e),o)})}),u2=H({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Pm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>to(o,r),perform:(e,o,t,r)=>({appState:o,elements:gl(e,o,r,{position:"center",axis:"y"}),captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fl(J,{hidden:!to(o,r),type:"button",icon:Pm,onClick:()=>t(null),title:u("labels.centerVertically"),"aria-label":u("labels.centerVertically"),visible:Be(ve(e),o)})}),h2=H({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Dm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>to(o,r),perform:(e,o,t,r)=>({appState:o,elements:gl(e,o,r,{position:"center",axis:"x"}),captureUpdate:D.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fl(J,{hidden:!to(o,r),type:"button",icon:Dm,onClick:()=>t(null),title:u("labels.centerHorizontally"),"aria-label":u("labels.centerHorizontally"),visible:Be(ve(e),o)})});import{jsx as y2}from"react/jsx-runtime";var g2=(e,o)=>{let t=o.scene.getSelectedElements(e);return Vd(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>le(r))},f2=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),a=Ly(n,t.scene.getNonDeletedElementsMap(),r,o),i=ie(a);return xr(e.map(l=>i.get(l.id)||l),o,t)},b2=H({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:f2(e,o,r,{space:"between",axis:"x"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>y2(J,{hidden:!g2(o,r),type:"button",icon:vg,onClick:()=>t(null),title:`${u("labels.distributeHorizontally")} \u2014 ${B("Alt+H")}`,"aria-label":u("labels.distributeHorizontally"),visible:Be(ve(e),o)})}),x2=H({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:f2(e,o,r,{space:"between",axis:"y"}),captureUpdate:D.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>y2(J,{hidden:!g2(o,r),type:"button",icon:wg,onClick:()=>t(null),title:`${u("labels.distributeVertically")} \u2014 ${B("Alt+V")}`,"aria-label":u("labels.distributeVertically"),visible:Be(ve(e),o)})});var kp=H({name:"flipHorizontal",label:"labels.flipHorizontal",icon:If,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:xr(E2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:D.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===he.H}),Sp=H({name:"flipVertical",label:"labels.flipVertical",icon:Cf,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:xr(E2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:D.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===he.V&&!e[T.CTRL_OR_CMD]}),E2=(e,o,t,r,n)=>{let a=ae(ve(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),i=ik(a,o,r,n),l=ie(i);return e.map(s=>l.get(s.id)||s)},ik=(e,o,t,r)=>{if(e.every(d=>Me(d)&&(d.startBinding||d.endBinding)))return e.map(d=>{let h=d;return re(h,{startArrowhead:h.endArrowhead,endArrowhead:h.startArrowhead})});let{midX:n,midY:a}=rn(e);Zy(e,o,"nw",r.scene,new Map(Array.from(o.values()).map(d=>[d.id,ar(d)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),ys(e.filter(Me),r.scene,r.state);let{elbowArrows:i,otherElements:l}=e.reduce((d,h)=>Se(h)?{...d,elbowArrows:d.elbowArrows.concat(h)}:{...d,otherElements:d.otherElements.concat(h)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=rn(e),[m,p]=[n-s,a-c];return l.forEach(d=>r.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),i.forEach(d=>r.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),e};var ei=H({name:"copy",label:"labels.copy",icon:Xi,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await hp(n,r.files,t)}catch(a){return{captureUpdate:D.EVENTUALLY,appState:{...o,errorMessage:a.message}}}return{captureUpdate:D.EVENTUALLY}},keyTest:void 0}),E1=H({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await Jv()}catch(a){return a.name==="AbortError"||a.name==="NotAllowedError"?!1:(console.error(`actionPaste ${a.name}: ${a.message}`),Jr?{captureUpdate:D.EVENTUALLY,appState:{...o,errorMessage:u("hints.firefox_clipboard_write")}}:{captureUpdate:D.EVENTUALLY,appState:{...o,errorMessage:u("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(jv({types:n}))}catch(a){return console.error(a),{captureUpdate:D.EVENTUALLY,appState:{...o,errorMessage:u("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:D.EVENTUALLY}},keyTest:void 0}),pc=H({name:"cut",label:"labels.cut",icon:sf,trackEvent:{category:"element"},perform:(e,o,t,r)=>(ei.perform(e,o,t,r),tl.perform(e,o,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),uc=H({name:"copyAsSvg",label:"labels.copyAsSvg",icon:kf,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:D.EVENTUALLY};let{exportedElements:n,exportingFrame:a}=ja(e,o,!0);try{await qa({type:"clipboard-svg",data:{elements:n,appState:o,files:r.files},config:{...o,exportingFrame:a,name:r.getName()}});let i=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:u("toast.copyToClipboardAsSvg",{exportSelection:i.length?u("toast.selection"):u("toast.canvas"),exportColorScheme:o.exportWithDarkMode?u("buttons.darkMode"):u("buttons.lightMode")})}},captureUpdate:D.EVENTUALLY}}catch(i){return console.error(i),{appState:{errorMessage:i.message},captureUpdate:D.EVENTUALLY}}},predicate:e=>up&&e.length>0,keywords:["svg","clipboard","copy"]}),hc=H({name:"copyAsPng",label:"labels.copyAsPng",icon:Sf,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:D.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:a,exportingFrame:i}=ja(e,o,!0);try{return await qa({type:"clipboard",data:{elements:a,appState:o,files:r.files},config:{...o,exportingFrame:i,name:o.name||r.getName()}}),{appState:{...o,toast:{message:u("toast.copyToClipboardAsPng",{exportSelection:n.length?u("toast.selection"):u("toast.canvas"),exportColorScheme:o.exportWithDarkMode?u("buttons.darkMode"):u("buttons.lightMode")})}},captureUpdate:D.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:D.EVENTUALLY}}},predicate:e=>pl&&e.length>0,keyTest:e=>e.code===he.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),gc=H({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{mr(bh(n))}catch{throw new Error(u("errors.copyToSystemClipboardFailed"))}return{captureUpdate:D.EVENTUALLY}},predicate:(e,o,t,r)=>up&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some($),keywords:["text","clipboard","copy"]});var fc=H({name:"gridMode",icon:Pf,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:D.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.code===he.QUOTE});var ti=H({name:"zenMode",label:"buttons.zenMode",icon:Lf,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:D.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,r)=>r.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.Z});var Mp=H({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Mf,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:D.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.S});var oi=H({name:"stats",label:"stats.fullTitle",icon:Tf,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:D.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.SLASH});var Lp=H({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(a=>ft(a)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),a=r.scene.getNonDeletedElementsMap();return n.forEach(i=>{let l=xe(i,a);if(l){let{width:s,height:c}=Kt(l.originalText,yt(l),l.lineHeight),m=Hx(i.id);Fx(i.id);let{x:p,y:d}=Pn(i,l,a);r.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:p,y:d}),r.scene.mutateElement(i,{boundElements:i.boundElements?.filter(h=>h.id!==l.id),height:m||i.height})}}),{elements:e,appState:o,captureUpdate:D.IMMEDIATELY}}}),Ap=H({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let a=$(n[0])||$(n[1]),i;if(en(n[0])?i=n[0]:en(n[1])&&(i=n[1]),a&&i&&xe(i,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),a,i;$(n[0])&&en(n[1])?(a=n[0],i=n[1]):(a=n[1],i=n[0]),r.scene.mutateElement(a,{containerId:i.id,verticalAlign:Ao.MIDDLE,textAlign:nh.CENTER,autoResize:!0,angle:Me(i)?0:i?.angle??0}),r.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:a.id})});let l=i.height;return ut(a,i,r.scene),gs(i.id,l),{elements:lk(e,i,a),appState:{...o,selectedElementIds:{[i.id]:!0}},captureUpdate:D.IMMEDIATELY}}}),lk=(e,o,t)=>{let r=e.slice(),n=r.findIndex(i=>i.id===t.id);r.splice(n,1);let a=r.findIndex(i=>i.id===o.id);return r.splice(a+1,0,t),wr(r,ie([o,t])),r},sk=(e,o,t)=>{let r=e.slice(),n=r.findIndex(i=>i.id===o.id);r.splice(n,1);let a=r.findIndex(i=>i.id===t.id);return r.splice(a,0,o),wr(r,ie([o,t])),r},v2=H({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),a=n.some(i=>$(i)&&!it(i));return n.length>0&&a},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),a=e.slice(),i={};for(let l of n)if($(l)&&!it(l)){let s=Tr({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:_n("rectangle")?Lt.ADAPTIVE_RADIUS:Lt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-rh,y:l.y-rh,width:ki(l.width,"rectangle"),height:ki(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);a.filter(p=>c.includes(p.id)).forEach(p=>{let d=p.startBinding,h=p.endBinding;d?.elementId===l.id&&(d={...d,elementId:s.id}),h?.elementId===l.id&&(h={...h,elementId:s.id}),(d||h)&&r.scene.mutateElement(p,{startBinding:d,endBinding:h})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:Ao.MIDDLE,boundElements:null,textAlign:nh.CENTER,autoResize:!0}),ut(l,s,r.scene),a=sk([...a,s],s,l),i[s.id]=!0}return{elements:a,appState:{...o,selectedElementIds:i},captureUpdate:D.IMMEDIATELY}}});import ck from"clsx";import{useCallback as w2,useEffect as T2,useLayoutEffect as dk,useRef as mk,useState as pk}from"react";import{jsx as bl,jsxs as C2}from"react/jsx-runtime";var T1=380,uk=42,v1=5,I2=85,hk=500,w1=!1,_p=new Map,k2=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:a})=>{let i=o.getNonDeletedElementsMap(),l=Lr(),s=Ar(),c=Te(),m=e.link||"",[p,d]=pk(m),h=mk(null),b=l.showHyperlinkPopup==="editor",f=w2(()=>{if(!h.current)return;let w=rr(h.current.value)||null;if(!e.link&&w&&pe("hyperlink","create"),Vt(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!w){o.mutateElement(e,{link:null}),a(e,!1);return}if(!Bi(w,s.validateEmbeddable))w&&n({message:u("toast.unableToEmbed"),closable:!0}),e.link&&_p.set(e.id,e.link),o.mutateElement(e,{link:w}),a(e,!1);else{let{width:C,height:S}=e,A=La(w);A?.error instanceof URIError&&n({message:u("toast.unrecognizedLinkFormat"),closable:!0});let M=A?A.intrinsicSize.w/A.intrinsicSize.h:1,N=_p.get(e.id)!==e.link;o.mutateElement(e,{...N?{width:A?.type==="video"?C>S?C:S*M:C,height:A?.type==="video"&&C>S?C/M:S}:{},link:w}),a(e,!0),_p.has(e.id)&&_p.delete(e.id)}}else o.mutateElement(e,{link:w})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,a]);dk(()=>()=>{f()},[f]),T2(()=>{b&&h?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&h.current.select()},[b,c.formFactor,c.isTouchScreen]),T2(()=>{let w=null,C=S=>{if(b)return;w&&clearTimeout(w),fk(e,i,l,L(S.clientX,S.clientY))&&(w=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},hk))};return window.addEventListener("pointermove",C,!1),()=>{window.removeEventListener("pointermove",C,!1),w&&clearTimeout(w)}},[l,e,b,t,i]);let E=w2(()=>{pe("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),v=()=>{pe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x,y}=S2(e,l,i);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:C2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${x}px`,width:T1,padding:v1},children:[b?bl("input",{className:ck("excalidraw-hyperlinkContainer-input"),placeholder:u("labels.link.hint"),ref:h,value:p,onChange:w=>d(w.target.value),autoFocus:!0,onKeyDown:w=>{w.stopPropagation(),w[T.CTRL_OR_CMD]&&w.key===T.K&&w.preventDefault(),(w.key===T.ENTER||w.key===T.ESCAPE)&&(f(),t({showHyperlinkPopup:"info"}))}}):e.link?bl("a",{href:rr(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Ld(e.link)?"_self":"_blank",onClick:w=>{if(e.link&&r){let C=kd("excalidraw-link",w.nativeEvent);r({...e,link:rr(e.link)},C),C.defaultPrevented&&w.preventDefault()}},rel:"noopener noreferrer",children:e.link}):bl("div",{className:"excalidraw-hyperlinkContainer-link",children:u("labels.link.empty")}),C2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!b&&bl(J,{type:"button",title:u("buttons.edit"),"aria-label":u("buttons.edit"),label:u("buttons.edit"),onClick:v,className:"excalidraw-hyperlinkContainer--edit",icon:lr}),bl(J,{type:"button",title:u("labels.linkToElement"),"aria-label":u("labels.linkToElement"),label:u("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Vs}),m&&!Vt(e)&&bl(J,{type:"button",title:u("buttons.remove"),"aria-label":u("buttons.remove"),label:u("buttons.remove"),onClick:E,className:"excalidraw-hyperlinkContainer--remove",icon:_t})]})]})},S2=(e,o,t)=>{let[r,n]=At(e,t),{x:a,y:i}=kt({sceneX:r+e.width/2,sceneY:n},o),l=a-o.offsetLeft-T1/2,s=i-o.offsetTop-I2;return{x:l,y:s}},C1=(e,o)=>{let t=ae(e,o);return Vt(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},bc=null,M2=(e,o,t)=>{bc&&clearTimeout(bc),bc=window.setTimeout(()=>gk(e,o,t),Y0)},gk=(e,o,t)=>{if(!e.link)return;let r=dl();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=Ma(e.link)?u("labels.link.goToElement"):e.link;let[n,a,i,l]=At(e,t),[s,c,m,p]=iE([n,a,i,l],e.angle,o),d=kt({sceneX:s,sceneY:c},o);u1(r,{left:d.x,top:d.y,width:m,height:p},"top"),pe("hyperlink","tooltip","link-icon"),w1=!0},I1=()=>{bc&&clearTimeout(bc),w1&&(w1=!1,dl().classList.remove("excalidraw-tooltip--visible"))},fk=(e,o,t,[r,n])=>{let{x:a,y:i}=Ye({clientX:r,clientY:n},t),l=15/t.zoom.value;if(zd(L(a,i),e,o))return!1;let[s,c,m]=At(e,o);if(a>=s&&a<=m&&i>=c-I2&&i<=c)return!1;let{x:p,y:d}=S2(e,t,o);return!(r>=p-l&&r<=p+T1+v1*2+l&&n>=d-l&&n<=d+l+v1*2+uk)};import{jsx as bk}from"react/jsx-runtime";var xl=H({name:"hyperlink",label:(e,o)=>C1(e,o),icon:qi,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:D.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.K,predicate:(e,o)=>ae(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=ae(e,o);return bk(J,{type:"button",icon:qi,"aria-label":u(C1(e,o)),title:`${Vt(e[0])?u("labels.link.labelEmbed"):u("labels.link.label")} - ${B("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var k1=e=>e.every(o=>!o.locked),yl=H({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return k1(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=ae(o,e);return k1(t)?Da:zn},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(a=>a.locked&&a.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let a=k1(n),i=ie(n),l=n.length>1&&Yd(n),c=n.length===1||l?null:Ut(),m={...o.lockedMultiSelections};if(a)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let v=n[0].groupIds.at(-1);delete m[v]}let p=e.map(v=>{if(!i.has(v.id))return v;let x=v.groupIds;return a?c&&(x=[...x,c]):x=x.filter(y=>!o.lockedMultiSelections[y]),re(v,{locked:a,groupIds:x.length!==v.groupIds.length?x:v.groupIds})}),d=ie(p),h=a?{}:Object.fromEntries(n.map(v=>[v.id,!0])),b=n.map(v=>d.get(v.id)||v),f=a?{}:Ia(b,o),E=a?c||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:p,appState:{...o,selectedElementIds:h,selectedGroupIds:f,selectedLinearElement:a?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:E},captureUpdate:D.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===T.L&&e[T.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),L2=H({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:zn,predicate:(e,o)=>ae(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(i=>i.locked),r=e.map(i=>{if(i.locked){let l=i.groupIds.filter(s=>!o.lockedMultiSelections[s]);return re(i,{locked:!1,groupIds:i.groupIds.length!==l.length?l:i.groupIds})}return i}),n=ie(r),a=t.map(i=>n.get(i.id)||i);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(i=>[i.id,!0])),selectedGroupIds:Ia(a,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:D.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import qw from"clsx";import vM from"fuzzy";import{useEffect as Jp,useRef as Jw,useMemo as wM,useState as qp}from"react";import{useEffect as Ec,useMemo as A2,useRef as M1,useState as xk}from"react";import{jsx as _1}from"react/jsx-runtime";var yk=8,Ek=10,xc=["rectangle","diamond","ellipse"],yc=["line","sharpArrow","curvedArrow","elbowArrow"],vk=new Set(xc),wk=new Set(yc),vl=e=>vk.has(e),Dp=e=>e==="arrow"||wk.has(e),pr=we(null),vc=new Map,wc=new Map,Tk=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=M1(null);return Ec(()=>{if(o.length===0){e.updateEditorAtom(pr,null);return}let r=wl(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(pr,null),t.current=null)},[o,e]),Ec(()=>()=>{vc.clear(),wc.clear()},[]),_1(Ck,{app:e,elements:o})},Ck=({app:e,elements:o})=>{let t=wl(o),r=A2(()=>t==="generic"?R2(o):[],[t,o]),n=A2(()=>t==="linear"?A1(o):[],[t,o]),a=t==="generic"?r.every(p=>p.type===r[0].type):t==="linear"?n.every(p=>Ca(p)===Ca(n[0])):!1,[i,l]=xk({x:0,y:0}),s=M1(""),c=M1(null);Ec(()=>{let p=[...r,...n].sort((E,v)=>E.id.localeCompare(v.id)),d=`
|
|
20
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(E=>E.id).join(",")}`;if(d===s.current)return;s.current=d;let h;if(p.length===1){let[E,,,v,x,y]=At(p[0],e.scene.getNonDeletedElementsMap());h=Ge(L(E,v),L(x,y),p[0].angle)}else{let{minX:E,maxY:v}=rn(p);h=L(E,v)}let{x:b,y:f}=kt({sceneX:h[0],sceneY:h[1]},e.state);l({x:b,y:f})},[r,n,e.scene,e.state]),Ec(()=>{for(let p of n){let d=L1(p.id,Lk(p));wc.has(d)||wc.set(d,p)}},[n]),Ec(()=>{for(let p of r)if(!vc.has(p.id)){let d=xe(p,e.scene.getNonDeletedElementsMap());d&&vc.set(p.id,{fontSize:d.fontSize})}},[r,e.scene]);let m=t==="linear"?[["line",za],["sharpArrow",Va],["curvedArrow",Za],["elbowArrow",Ka]]:t==="generic"?[["rectangle",Ra],["diamond",Na],["ellipse",Oa]]:[];return _1("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${i.y+(Ek+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${i.x-e.state.offsetLeft-yk}px`,zIndex:2},className:nt.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([p,d])=>{let h=a&&(t==="generic"&&r[0].type===p||t==="linear"&&Ca(n[0])===p);return _1(J,{className:"Shape",type:"radio",icon:d,checked:h,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&pe("convertElementType",p,"ui"),P1(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},Ik=(e,o,t)=>{let r=xs(e,o),n=Od(e,o),a=Ii(o.text,yt(o),r),i=Kt(a,yt(o),o.lineHeight),l=o.fontSize;for(;(i.width>r||i.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};i=Kt(o.text,yt(s),o.lineHeight)}Zt(o,t.getNonDeletedElementsMap(),{fontSize:l,width:i.width,height:i.height}),ut(o,e,t)},P1=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),a=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),i=r==="right"?1:-1;if(o==="generic"){let l=R2(n),c=l.every(m=>m.type===l[0].type)?xc.indexOf(l[0].type):-1;if(t=t??xc[(c+xc.length+i)%xc.length],t&&vl(t)){let m={};for(let d of l){let h=P2(d,t,e);m[h.id]=h}let p=[];for(let d of e.scene.getElementsIncludingDeleted())m[d.id]?p.push(m[d.id]):p.push(d);e.scene.replaceAllElements(p);for(let d of Object.values(m)){let h=xe(d,e.scene.getNonDeletedElementsMap());h&&(vc.get(d.id)&&Zt(h,e.scene.getNonDeletedElementsMap(),{fontSize:vc.get(d.id)?.fontSize??h.fontSize}),Ik(d,h,e.scene))}e.setState(d=>({selectedElementIds:a,activeTool:Ne(d,{type:"selection"})}))}}if(o==="linear"){let l=A1(n);if(!t){let c=Md(l,Ca),m=c?yc.indexOf(c):-1;t=yc[(m+yc.length+i)%yc.length]}if(Dp(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let p of l){let d=wc.get(L1(p.id,t));if(d&&Ca(d)===t)m.set(d.id,d),c.push(d);else{let h=P2(p,t,e);m.set(h.id,h),c.push(h)}}e.scene.replaceAllElements(m);for(let p of c)if(ge(p))if(Se(p)){let d=kk(p);if(d.length<2)continue;let h=[];for(let f=1;f<d.length-2;f++)h.push({start:d[f],end:d[f+1],index:f+1});let b=Fd(p,e.scene.getNonDeletedElementsMap(),{points:d,fixedSegments:h});Zt(p,e.scene.getNonDeletedElementsMap(),{...b,endArrowhead:"arrow"})}else{let d=bx(["line","sharpArrow","curvedArrow"],h=>wc.get(L1(p.id,h)));if(d){let h=d.points;e.scene.mutateElement(p,{points:h})}}}let s=A1(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:a,selectedLinearElement:s.length===1?new X(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Ne(c,{type:"selection"})}))}return!0},wl=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(vl(t.type))return"generic";D2(t)&&(o=!0)}return o?"linear":null},D2=e=>ge(e)&&(!Me(e)||!Dx(e)&&!ft(e)),L1=(e,o)=>`${e}:${o}`,R2=e=>e.filter(o=>vl(o.type)),A1=e=>e.filter(o=>D2(o)),Pp=20,El=(e,o)=>e[0]===o[0],S1=(e,o)=>e[1]===o[1],_2=(e,o)=>El(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),kk=e=>{let o=[e.points[0]],t=Sk(e.points);for(let a=1;a<t.length;++a){let i=o[o.length-1],l=[...t[a]];Math.abs(l[0]-i[0])<Pp?l[0]=i[0]:Math.abs(l[1]-i[1])<Pp&&(l[1]=i[1]),El(i,l)||S1(i,l)||o.push(L(i[0],l[1])),o.push(l)}let r=[o[0]];for(let a=1;a<o.length-1;++a)El(o[a-1],o[a])&&El(o[a],o[a+1])||S1(o[a-1],o[a])&&S1(o[a],o[a+1])||r.push(o[a]);r.push(o[o.length-1]);let n=[r[0]];for(let a=1;a<r.length-1;++a){let i=n[n.length-1],l=r[a],s=r[a+1],c=El(i,l),m=El(l,s);if(c!==m){let p=_2(i,l),d=_2(l,s);if(p<Pp||d<Pp){if(d<p)c?s[0]=i[0]:s[1]=i[1];else if(m)for(let h=n.length-1;h>=0&&n[h][0]===i[0];--h)n[h][0]=l[0];else for(let h=n.length-1;h>=0&&n[h][1]===i[1];--h)n[h][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},Sk=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[a,i]=e[t];(r!==a||n!==i)&&o.push(e[t])}return o},P2=(e,o,t)=>{if(!Mk(e.type,o)){if(!Id())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(Er.delete(e),vl(o)){let r=tn(Tr({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:_n(o)?Lt.ADAPTIVE_RADIUS:Lt.PROPORTIONAL_RADIUS}:e.roundness}));return Dn(r,t.scene,t.state),r}if(Dp(o))switch(o){case"line":return tn(Ir({...e,type:"line"}));case"sharpArrow":return tn(zi({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return tn(zi({...e,type:"arrow",elbowed:!1,roundness:{type:Lt.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return tn(zi({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return Cx(o,`unhandled conversion type: ${o}`),e},Mk=(e,o)=>!!(vl(e)&&vl(o)||Dp(e)&&Dp(o)),Lk=e=>ge(e)?Ca(e):e.type,N2=Tk;var O2=H({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return Et.set(pr,{type:"panel"}),{captureUpdate:D.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>wl(e)!==null});var Rp=H({name:"copyElementLink",label:"labels.copyElementLink",icon:Ga,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=ae(e,o);try{if(window.location){let a=tm(n,o);return a?(await mr(r.props.generateLinkForSelection?r.props.generateLinkForSelection(a.id,a.type):em(a.id,a.type)),{appState:{toast:{message:u("toast.elementLinkCopied"),closable:!0}},captureUpdate:D.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:D.EVENTUALLY}}}catch(a){console.error(a)}return{appState:o,elements:e,app:r,captureUpdate:D.EVENTUALLY}},predicate:(e,o)=>om(ae(e,o))}),z2=H({name:"linkToElement",label:"labels.linkToElement",icon:Vs,perform:(e,o,t,r)=>{let n=ae(e,o);return n.length!==1||!om(n)?{elements:e,appState:o,app:r,captureUpdate:D.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:ae(e,o)[0].id}},captureUpdate:D.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=ae(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&om(n)},trackEvent:!1});var Ak={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+${u("helpDialog.drag")}`)],sendBackward:[B("CtrlOrCmd+[")],bringForward:[B("CtrlOrCmd+]")],sendToBack:[lo?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")],bringToFront:[lo?B("CtrlOrCmd+Alt+]"):B("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:[]},ht=(e,o=0)=>{let t=Ak[e];return t&&t.length>0?t[o]||t[0]:""};var _k="\\u0300-\\u036f",Pk="\\ufe20-\\ufe2f",Dk="\\u20d0-\\u20ff",Rk=_k+Pk+Dk,Nk=`[${Rk}]`,Ok=RegExp(Nk,"g"),zk=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Bk={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},ri=e=>e.replace(zk,o=>Bk[o]||o).replace(Ok,"");import nM from"clsx";import{useEffect as aM,useState as iM}from"react";import{useCallback as Fk,useState as Hk}from"react";var B2=()=>{let[e,o]=Hk(null),t=Fk(r=>o(r),[]);return[e,t]};import{useState as Sw,useCallback as Z1,useMemo as Mw,useEffect as X1,memo as Lw,useRef as qS}from"react";import{useEffect as G2,useRef as W2}from"react";var Np=async({data:e,config:o})=>On({data:e,config:o}),F2=async({data:e,config:o})=>{let{mimeType:t=ue.png,quality:r}=o||{};t===ue.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${ue.png}" mimeType`),t==="image/jpg"&&(t=ue.jpg),t===ue.jpg&&o?.canvasBackgroundColor&&(console.warn(`Defaulting "exportBackground" to "true" for "${ue.jpg}" mimeType`),o={...o,canvasBackgroundColor:e.appState?.viewBackgroundColor||Lo});let n=await On({data:e,config:o});return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((a,i)=>{n.toBlob(async l=>{if(!l)return i(new Error("couldn't export to blob"));l&&t===ue.png&&e.appState?.exportEmbedScene&&(l=await pE({blob:l,metadata:Ss(e.elements,e.appState,e.files||{},"local")})),a(l)},t,r)})},Tl=async({data:e,config:o})=>{let t=Wi(e.elements,null,{deleteInvisibleElements:!0}),n={...Ls(e.appState,null),exportPadding:o?.padding},a=ve(t),i=e.files||{};return Yi({data:{elements:a,appState:n,files:i},config:{exportingFrame:o?.exportingFrame,renderEmbeddables:o?.renderEmbeddables,skipInliningFonts:o?.skipInliningFonts,reuseImages:o?.reuseImages}})},Uk=async({type:e,data:o,config:t})=>{if(e==="svg"){let r=await Tl({data:o,config:t});await mr(r.outerHTML)}else if(e==="png")await gp(F2({data:o,config:t}));else if(e==="json")await hp(o.elements,o.files);else throw new Error("Invalid export type")};import{useEffect as H2,useState as Gk}from"react";var D1=we(new Map),U2=async e=>await Tl({data:{elements:e,appState:{exportBackground:!1,viewBackgroundColor:$r.white},files:null},config:{renderEmbeddables:!1,skipInliningFonts:!0}}),Op=(e,o,t,r)=>{let[n,a]=Gk();return H2(()=>{if(o)if(e){let i=t.get(e);i?a(i):(async()=>{let l=await U2(o);l.querySelector(".style-fonts")?.remove(),l&&(t.set(e,l),a(l))})()}else(async()=>{let i=await U2(o);a(i)})()},[e,o,t,a]),H2(()=>{let i=r.current;if(i)return n&&(i.innerHTML=n.outerHTML),()=>{i.innerHTML=""}},[n,r]),n},Cl=()=>{let[e]=te(D1);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var Wk=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],V2=new Po,Nr=we({status:"loaded",isInitialized:!1,libraryItems:[]}),Tc=e=>or(e),Yk=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),K2=(e,o)=>{let t=[];for(let r of o)Yk(e,r)&&t.push(r);return[...t,...e]},Z2=(e,o)=>{let t=ie(o),r={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let a of e)t.has(a.id)||r.deletedItems.set(a.id,a);let n=ie(e);for(let a of o){let i=n.get(a.id);i?O1(i)!==O1(a)&&r.updatedItems.set(a.id,a):r.addedItems.set(a.id,a)}return r},R1=class{constructor(o){k(this,"currLibraryItems",[]);k(this,"prevLibraryItems",Tc(this.currLibraryItems));k(this,"app");k(this,"updateQueue",[]);k(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);k(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Et.set(Nr,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Et.set(Nr,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Tc(this.currLibraryItems);let t=Tc(this.currLibraryItems);this.app.props.onLibraryChange?.(t),V2.trigger(Z2(o,t),t)}catch(o){console.error(o)}}});k(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Et.set(D1,new Map)});k(this,"resetLibrary",()=>this.setLibrary([]));k(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Tc(t))}catch{return o(this.currLibraryItems)}}));k(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:a="unpublished"})=>(n&&this.app.setState({openSidebar:{name:Yt.name,tab:ls}}),this.setLibrary(()=>new Promise(async(i,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await $h(s,a):c=As(s,a),!t||window.confirm(u("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),i(r?K2(this.currLibraryItems,c):c)):l(new Ui)}catch(s){l(s)}}))));k(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Tc(await o),r(this.currLibraryItems)}catch(a){n(a)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},z1=R1,kl=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=h=>e.slice(h*t,h*t+t).reduce((f,E)=>{let{height:v}=rn(E.elements);return Math.max(f,v)},0),a=h=>{let b=0,f=0,E=0;for(let v of e){if(b%t===0&&(f=0),f===h){let{width:x}=rn(v.elements);E=Math.max(E,x)}b++,f++}return E},i=0,l=0,s=0,c=0,m=0,p=0,d=0;for(let h of e){m&&m%t===0&&(l+=s+50,i=0,p=0,d++),p===0&&(s=n(d)),c=a(p);let{minX:b,minY:f,width:E,height:v}=rn(h.elements),x=(c-E)/2,y=(s-v)/2;r.push(...h.elements.map(w=>({...w,x:w.x+i+x-b,y:w.y+l+y-f}))),i+=c+50,m++,p++}return r},Vk=(e,o=Wk)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:a}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(a)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},N1=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(dd.addLibrary)||new URLSearchParams(window.location.search).get(cd.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Jn=class Jn{constructor(o){k(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(a,i)=>{try{let l=await o.load({source:t});a(As(l?.libraryItems||[],"published"))}catch(l){i(l)}});return r?Jn.queue.push(n):n()}getLibraryItems(o){return Jn.getLibraryItems(this.adapter,o,!1)}};k(Jn,"queue",new ix),k(Jn,"run",async(o,t)=>{let r=new Jn(o);return Jn.queue.push(()=>t(r))});var Il=Jn,Cc=0,zp=0,O1=e=>`${e.id}:${e.name||""}:${Hh(e.elements)}`,Bp=e=>Uh(e.map(o=>O1(o)).sort().join()),Y2=async(e,o)=>{try{return zp++,await Il.run(e,async t=>{let r=ie(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);if(o.updatedItems)for(let[l,s]of o.updatedItems)r.set(l,s);let a=n.concat(Array.from(r.values())),i=Bp(a);return i!==Cc&&await e.save({libraryItems:a}),Cc=i,a})}finally{zp--}},Kk=e=>{let{excalidrawAPI:o}=e,t=W2(e);t.current=e;let r=W2(!1);G2(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(p,d)=>{try{l=decodeURIComponent(l),l=Ad(l),Vk(l,t.current.validateLibraryUrl);let b=await(await fetch(l)).blob();p(b)}catch(h){d(h)}}),m=s!==o.id;await(m&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(dd.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(dd.addLibrary),window.history.replaceState({},os,`#${p.toString()}`)}else if(window.location.search.includes(cd.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete(cd.addLibrary),window.history.replaceState({},os,`?${p.toString()}`)}}},a=l=>{l.preventDefault();let s=N1();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},i=N1();if(i&&n(i),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=xx();s?c.resolve(dh(s.load).then(async m=>{let p=null;try{if(!m)return Il.getLibraryItems(l,"load");p=As(m.libraryItems||[],"published");let d=await Y2(l,Z2([],p));try{await s.clear()}catch(h){console.error(`couldn't delete legacy library data: ${h.message}`)}return d}catch(d){return console.error(`couldn't migrate legacy library data: ${d.message}`),p}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Il.getLibraryItems(l,"load")))):c.resolve(dh(Il.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let p=m||[];return Cc=Bp(p),p}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",a),()=>{window.removeEventListener("hashchange",a)}},[o]),G2(()=>{let n=V2.on(async(i,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Cc!==Bp(l)&&await Y2(c,i)}catch(m){console.error(`couldn't persist library update: ${m.message}`,i),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:u("errors.saveLibraryError")}})}}),a=i=>{zp&&vx(i)};return window.addEventListener("beforeunload",a),()=>{window.removeEventListener("beforeunload",a),n(),Cc=0,zp=0}},[])};import $k from"clsx";import{jsx as Xk}from"react/jsx-runtime";var Zk=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return Xk("a",{className:"library-menu-browse-button",href:`${I.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${pd.excalidrawLibrary}`,target:"_excalidraw_libraries",children:u("labels.libraries")})},X2=Zk;import{jsx as jk,jsxs as qk}from"react/jsx-runtime";var Fp=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:a})=>qk("div",{className:$k("library-menu-control-buttons",a),style:r,children:[jk(X2,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Ll,useEffect as W1,useMemo as Y1,useRef as ww,useState as Tw}from"react";import XS from"clsx";import Jk from"lodash.throttle";import{useEffect as Qk}from"react";var eS=we(0),$2=e=>{let[o,t]=te(eS);return Qk(()=>{let{current:r}=e;if(!r)return;let n=Jk(()=>{let{scrollTop:a}=r;t(a)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import kS from"clsx";import{useCallback as SS,useState as H1}from"react";import{flushSync as j2}from"react-dom";import tS from"clsx";import{jsx as Hp,jsxs as rS}from"react/jsx-runtime";var oS=({label:e,onClick:o,className:t,children:r,actionType:n,type:a="button",isLoading:i,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return rS("button",{className:tS("Dialog__action-button",s,t),type:a,"aria-label":e,onClick:o,...l,children:[r&&Hp("div",{style:i?{visibility:"hidden"}:{},children:r}),Hp("div",{style:i?{visibility:"hidden"}:{},children:e}),i&&Hp("div",{style:{position:"absolute",inset:0},children:Hp(Wt,{})})]})},hn=oS;import{jsx as q2,jsxs as J2}from"react/jsx-runtime";var nS=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=u("buttons.confirm"),cancelText:a=u("buttons.cancel"),className:i="",...l}=e,s=ye(),c=Sr(Sl),{container:m}=qe();return J2(gt,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${i}`,children:[r,J2("div",{className:"confirm-dialog-buttons",children:[q2(hn,{label:a,onClick:()=>{s({openMenu:null}),c(!1),j2(()=>{t()}),m?.focus()}}),q2(hn,{label:n,onClick:()=>{s({openMenu:null}),c(!1),j2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Up=nS;import{useCallback as mS,useEffect as F1,useRef as Q2,useState as B1}from"react";var Wo=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};k(Wo,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),k(Wo,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Gp from"react";var aS=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,iS=/{{([\w-]+)}}/,lS=/<([\w-]+)>/,sS=/<\/([\w-]+)>/,cS=(e,o)=>{let t=[{name:"",children:[]}];return e.split(aS).filter(Boolean).forEach(r=>{let n=r.match(lS),a=r.match(sS),i=r.match(iS);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(a!==null)if(a[1]===t[t.length-1].name){let s=t.pop(),c=Gp.createElement(Gp.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(i!==null){let l=i[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},dS=({i18nKey:e,children:o,...t})=>{let{t:r}=dt();return Gp.createElement(Gp.Fragment,{},...cS(r(e),t))},oo=dS;import{jsx as Ce,jsxs as jt}from"react/jsx-runtime";var pS=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),a=fx(e,6),i=document.createElement("canvas");i.width=a[0].length*128+(a[0].length+1)*(r*2)-r*2,i.height=a.length*128+(a.length+1)*(r*2)-r*2;let l=i.getContext("2d");l.fillStyle=Lo,l.fillRect(0,0,i.width,i.height);for(let[s,c]of e.entries()){let m=await Np({data:{elements:c.elements,files:null},config:{maxWidthOrHeight:128}}),{width:p,height:d}=m,h=Math.floor(s/6)*(128+r*2),b=s%6*(128+r*2);l.drawImage(m,b+(128-p)/2+r,h+(128-d)/2+r),l.lineWidth=n,l.strokeStyle="#ced4da",l.strokeRect(b+r/2,h+r/2,128+r,128+r)}return await hm(new File([await Pa(i)],"preview",{type:ue.png}),{outputType:ue.jpg,maxWidthOrHeight:5e3})},uS=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let a=Q2(null),i=Q2(null);return F1(()=>{let l=a.current;l&&(async()=>{let s=await Tl({data:{elements:e.elements,appState:{...o,viewBackgroundColor:Lo,exportBackground:!0},files:null},config:{skipInliningFonts:!0}});l.innerHTML=s.outerHTML})()},[e.elements,o]),jt("div",{className:"single-library-item",children:[e.status==="published"&&Ce("span",{className:"single-library-item-status",children:u("labels.statusPublished")}),Ce("div",{ref:a,className:"single-library-item__svg"}),Ce(J,{"aria-label":u("buttons.remove"),type:"button",icon:wo,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:u("buttons.remove")}),jt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[jt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[jt("div",{style:{padding:"0.5em 0"},children:[Ce("span",{style:{fontWeight:500,color:"#868e96"},children:u("publishDialog.itemName")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("input",{type:"text",ref:i,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),Ce("span",{className:"error",children:e.error})]})]})},hS=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:a,onRemove:i})=>{let[l,s]=B1({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=B1(!1);F1(()=>{let y=Wo.get(In.PUBLISH_LIBRARY);y&&s(y)},[]);let[p,d]=B1(o.slice());F1(()=>{d(o.slice())},[o]);let h=y=>{s({...l,[y.target.name]:y.target.value})},b=async y=>{y.preventDefault(),m(!0);let w=[],C=!1;if(p.forEach(P=>{let O="";P.name||(O=u("publishDialog.errors.required"),C=!0),w.push({...P,error:O})}),C){d(w),m(!1);return}let S=await pS(p),A={type:Tn.excalidrawLibrary,version:pd.excalidrawLibrary,source:F0(),libraryItems:p},M=JSON.stringify(A,null,2),N=new Blob([M],{type:"application/json"}),R=new FormData;R.append("excalidrawLib",N),R.append("previewImage",S),R.append("previewImageType",S.type),R.append("title",l.name),R.append("authorName",l.authorName),R.append("githubHandle",l.githubHandle),R.append("name",l.name),R.append("description",l.description),R.append("twitterHandle",l.twitterHandle),R.append("website",l.website),fetch(`${I.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:R}).then(P=>P.ok?P.json().then(({url:O})=>{Wo.delete(In.PUBLISH_LIBRARY),r({url:O,authorName:l.authorName,items:p})}):P.json().catch(()=>{throw new Error(P.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||P.statusText||"something went wrong")}),P=>{console.error(P),n(P),m(!1)}).catch(P=>{console.error(P),n(P),m(!1)})},f=()=>{let y=[];return p.forEach((w,C)=>{y.push(Ce("div",{className:"single-library-item-wrapper",children:Ce(uS,{libItem:w,appState:t,index:C,onChange:(S,A)=>{let M=p.slice();M[A].name=S,d(M)},onRemove:i})},C))}),Ce("div",{className:"selected-library-items",children:y})},E=mS(()=>{a(p),Wo.set(In.PUBLISH_LIBRARY,l),e()},[p,e,a,l]),v=!!o.length,x=o.some(y=>y.status==="published");return Ce(gt,{onCloseRequest:E,title:u("publishDialog.title"),className:"publish-library",children:v?jt("form",{onSubmit:b,children:[Ce("div",{className:"publish-library-note",children:Ce(oo,{i18nKey:"publishDialog.noteDescription",link:y=>Ce("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),Ce("span",{className:"publish-library-note",children:Ce(oo,{i18nKey:"publishDialog.noteGuidelines",link:y=>Ce("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),Ce("div",{className:"publish-library-note",children:u("publishDialog.noteItems")}),x&&Ce("span",{className:"publish-library-note publish-library-warning",children:u("publishDialog.republishWarning")}),f(),jt("div",{className:"publish-library__fields",children:[jt("label",{children:[jt("div",{children:[Ce("span",{children:u("publishDialog.libraryName")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("input",{type:"text",name:"name",required:!0,value:l.name,onChange:h,placeholder:u("publishDialog.placeholder.libraryName")})]}),jt("label",{style:{alignItems:"flex-start"},children:[jt("div",{children:[Ce("span",{children:u("publishDialog.libraryDesc")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:h,placeholder:u("publishDialog.placeholder.libraryDesc")})]}),jt("label",{children:[jt("div",{children:[Ce("span",{children:u("publishDialog.authorName")}),Ce("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Ce("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:h,placeholder:u("publishDialog.placeholder.authorName")})]}),jt("label",{children:[Ce("span",{children:u("publishDialog.githubUsername")}),Ce("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:h,placeholder:u("publishDialog.placeholder.githubHandle")})]}),jt("label",{children:[Ce("span",{children:u("publishDialog.twitterUsername")}),Ce("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:h,placeholder:u("publishDialog.placeholder.twitterHandle")})]}),jt("label",{children:[Ce("span",{children:u("publishDialog.website")}),Ce("input",{type:"text",name:"website",pattern:"https?://.+",title:u("publishDialog.errors.website"),value:l.website,onChange:h,placeholder:u("publishDialog.placeholder.website")})]}),Ce("span",{className:"publish-library-note",children:Ce(oo,{i18nKey:"publishDialog.noteLicense",link:y=>Ce("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),jt("div",{className:"publish-library__buttons",children:[Ce(hn,{label:u("buttons.saveLibNames"),onClick:E,"data-testid":"cancel-clear-canvas-button"}),Ce(hn,{type:"submit",label:u("buttons.submit"),actionType:"primary",isLoading:c})]})]}):Ce("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:u("publishDialog.atleastOneLibItem")})})},ew=hS;import gw from"react";import bS from"clsx";import{useEffect as xS,useRef as yS}from"react";import{forwardRef as tw}from"react";import ow from"clsx";import{jsx as rw}from"react/jsx-runtime";var gS=tw(({children:e,gap:o,align:t,justifyContent:r,className:n,style:a},i)=>rw("div",{className:ow("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...a},ref:i,children:e})),fS=tw(({children:e,gap:o,align:t,justifyContent:r,className:n,style:a},i)=>rw("div",{className:ow("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...a},ref:i,children:e})),go={Row:gS,Col:fS};import{jsx as Wp}from"react/jsx-runtime";var nw=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n,placement:a="bottom"})=>{let i=Te(),l=yS(null),s=Gn({onClickOutside:o});rl(l,m=>{l.current?.closest(".dropdown-menu-container")?.contains(m.target)||s.onClickOutside?.()}),xS(()=>{let m=d=>{d.key===T.ESCAPE&&(d.stopImmediatePropagation(),s.onClickOutside?.())},p={capture:!0};return document.addEventListener("keydown",m,p),()=>{document.removeEventListener("keydown",m,p)}},[s]);let c=bS(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.formFactor==="phone","dropdown-menu--placement-top":a==="top"}).trim();return Wp(e1.Provider,{value:{onSelect:r},children:Wp("div",{ref:l,className:c,style:n,"data-testid":"dropdown-menu",children:i.formFactor==="phone"?Wp(go.Col,{className:"dropdown-menu-container",children:e}):Wp(xt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};nw.displayName="DropdownMenuContent";var aw=nw;import{jsx as vS}from"react/jsx-runtime";var ES=({children:e,className:o="",selected:t,...r})=>vS("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),iw=ES;import{jsx as lw}from"react/jsx-runtime";var sw=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:a="",selected:i,rel:l="noopener",...s})=>{let c=sp(s.onClick,n);return lw("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:lp(a,i),title:s.title??s["aria-label"],onClick:c,children:lw(ip,{icon:e,shortcut:o,children:r})})},Ml=sw;sw.displayName="DropdownMenuItemLink";import{jsx as wS}from"react/jsx-runtime";var cw=()=>wS("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0",flex:"0 0 auto"}}),dw=cw;cw.displayName="DropdownMenuSeparator";import TS from"clsx";import{jsx as CS}from"react/jsx-runtime";var mw=({className:e="",children:o,onToggle:t,title:r,...n})=>{let a=Te(),i=TS(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":a.formFactor==="phone"}).trim();return CS("button",{className:i,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},pw=mw;mw.displayName="DropdownMenuTrigger";import Yp from"react";var uw=e=>{let o=Yp.Children.toArray(e).find(t=>Yp.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},hw=e=>{let o=Yp.Children.toArray(e).find(t=>Yp.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{jsxs as IS}from"react/jsx-runtime";var gn=({children:e,open:o,placement:t})=>{let r=uw(e),n=hw(e),a=n&&gw.isValidElement(n)?gw.cloneElement(n,{placement:t}):n;return IS("div",{className:"dropdown-menu-container",style:{display:"contents"},children:[r,o&&a]})};gn.Trigger=pw;gn.Content=aw;gn.Item=Jt;gn.ItemLink=Ml;gn.ItemCustom=iw;gn.Group=Qs;gn.Separator=dw;var de=gn;gn.displayName="DropdownMenu";import{jsx as fo,jsxs as Vp}from"react/jsx-runtime";var MS=(e,o)=>e.filter(t=>o.includes(t.id)),LS=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:a,appState:i,className:l})=>{let[s]=te(Nr),[c,m]=te(Sl),p=()=>{let R=o.length?u("alerts.removeItemsFromsLibrary",{count:o.length}):u("alerts.resetLibrary"),P=o.length?u("confirmDialog.removeItemsFromLib"):u("confirmDialog.resetLibrary");return fo(Up,{onConfirm:()=>{o.length?r():n(),h(!1)},onCancel:()=>{h(!1)},title:P,children:fo("p",{children:R})})},[d,h]=H1(!1),b=!!o.length,f=b?s.libraryItems.filter(R=>o.includes(R.id)):s.libraryItems,E=b?u("buttons.remove"):u("buttons.resetLibrary"),[v,x]=H1(!1),[y,w]=H1(null),C=SS(()=>Vp(gt,{onCloseRequest:()=>w(null),title:u("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[fo("p",{children:fo(oo,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:R=>fo("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:R})})}),fo(J,{type:"button",title:u("buttons.close"),"aria-label":u("buttons.close"),label:u("buttons.close"),onClick:()=>w(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[w,y]),S=(R,P)=>{x(!1),w({url:R.url,authorName:R.authorName});let O=P.slice();O.forEach(Y=>{o.includes(Y.id)&&(Y.status="published")}),t.setLibrary(O)},A=async()=>{try{await t.updateLibrary({libraryItems:im({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(R){if(R?.name==="AbortError"){console.warn(R);return}e({errorMessage:u("errors.importLibraryError")})}},M=async()=>{let R=b?f:await t.getLatestLibrary();aE(R).catch(Td).catch(P=>{e({errorMessage:P.message})})},N=()=>Vp(de,{open:c,children:[fo(de.Trigger,{onToggle:()=>m(!c),children:Qh}),Vp(de.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!b&&fo(de.Item,{onSelect:A,icon:Ua,"data-testid":"lib-dropdown--load",children:u("buttons.load")}),!!f.length&&fo(de.Item,{onSelect:M,icon:Fn,"data-testid":"lib-dropdown--export",children:u("buttons.export")}),b&&fo(de.Item,{icon:lf,onSelect:()=>x(!0),"data-testid":"lib-dropdown--remove",children:u("buttons.publishLibrary")}),!!f.length&&fo(de.Item,{onSelect:()=>h(!0),icon:_t,children:E})]})]});return Vp("div",{className:kS("library-menu-dropdown-container",l),children:[N(),o.length>0&&fo("div",{className:"library-actions-counter",children:o.length}),d&&p(),v&&fo(ew,{onClose:()=>x(!1),libraryItems:MS(s.libraryItems,o),appState:i,onSuccess:R=>S(R,s.libraryItems),onError:R=>window.alert(R),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:R=>a(o.filter(P=>P!==R))}),y&&C()]})},fw=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=lt(),{clearLibraryCache:n,deleteItemsFromLibraryCache:a}=Cl(),i=Le(),l=ye(),[s]=te(Nr),c=async p=>{let d=p.filter(h=>!e.includes(h.id));r.setLibrary(d).catch(()=>{l({errorMessage:u("alerts.errorRemovingFromLibrary")})}),a(e),o([])};return fo(LS,{appState:i,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as zS,useEffect as BS,useState as FS}from"react";import AS,{useCallback as _S}from"react";function PS(){return[!1,_S(o=>o(),[])]}var bw=AS.useTransition||PS;import xw from"clsx";import{memo as DS,useRef as RS,useState as NS}from"react";import{jsx as Kp,jsxs as OS}from"react/jsx-runtime";var yw=DS(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:a,onDrag:i,svgCache:l})=>{let s=RS(null),c=Op(e,o,l,s),[m,p]=NS(!1),d=Te().formFactor==="phone",h=t&&Kp("div",{className:"library-unit__adder",children:Jh});return OS("div",{className:xw("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[Kp("div",{className:xw("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?b=>{e&&b.shiftKey?a(e,b):r(e)}:void 0,onDragStart:b=>{if(!e){b.preventDefault();return}p(!1),i(e,b)}}),h,e&&o&&(m||d||n)&&Kp(sc,{checked:n,onChange:(b,f)=>a(e,f),className:"library-unit__checkbox"})]})}),Ew=()=>Kp("div",{className:"library-unit library-unit--skeleton"});import{Fragment as HS,jsx as Zp}from"react/jsx-runtime";var Xp=({children:e})=>Zp("div",{className:"library-menu-items-container__grid",children:e}),Ic=zS(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:a,itemsRenderedPerBatch:i})=>{let[,l]=bw(),[s,c]=FS(0);return BS(()=>{s<e.length&&l(()=>{c(s+i)})},[s,e.length,l,i]),Zp(HS,{children:e.map((m,p)=>p<s?Zp(yw,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:a,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??p):Zp(Ew,{},p))})});import U1 from"clsx";import{forwardRef as WS,useRef as YS,useImperativeHandle as VS,useLayoutEffect as KS,useState as ZS}from"react";import US from"clsx";import{jsx as GS}from"react/jsx-runtime";var ro=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...a})=>GS("button",{onClick:Ln(a.onClick,i=>{o()}),type:e,className:US("excalidraw-button",n,{selected:t}),...a,children:r});import{jsx as G1,jsxs as vw}from"react/jsx-runtime";var Qn=WS(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:a,onKeyDown:i,isRedacted:l=!1,icon:s,className:c,type:m,...p},d)=>{let h=YS(null);VS(d,()=>h.current),KS(()=>{a&&(h.current?.focus(),h.current?.select())},[a]);let[b,f]=ZS(!1);return vw("div",{className:U1("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{h.current?.focus()},children:[s,o&&G1("div",{className:"ExcTextField__label",children:o}),vw("div",{className:U1("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[G1("input",{className:U1({"is-redacted":"value"in p&&p.value&&l&&!b}),readOnly:n,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:r,ref:h,onChange:E=>e?.(E.target.value),onKeyDown:i,type:m}),l&&G1(ro,{onSelect:()=>f(!b),style:{border:0,userSelect:"none"},children:b?gf:Ya})]})]})});import{Fragment as Cw,jsx as Dt,jsxs as Or}from"react/jsx-runtime";var $S=17,jS=64;function V1({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:a,id:i,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=Te(),p=ww(null),d=$2(p);W1(()=>{d>0&&p.current?.scrollTo(0,d)},[]);let{svgCache:h}=Cl(),[b,f]=Tw(null),[E,v]=Tw(""),x=!o.length&&!n.length,y=!x&&!!E.trim(),w=Y1(()=>{let z=ri(E.trim().toLowerCase());return z?o.filter(U=>{let ee=U.name||"";return ee.trim()&&ri(ee.toLowerCase()).includes(z)}):[]},[o,E]),C=Y1(()=>o.filter(z=>z.status!=="published"),[o]),S=Y1(()=>o.filter(z=>z.status==="published"),[o]),A=Ll((z,U)=>{let ee=!c.includes(z),Ie=[...C,...S];if(ee){if(U.shiftKey&&b){let V=Ie.findIndex(ao=>ao.id===b),fe=Ie.findIndex(ao=>ao.id===z);if(V===-1||fe===-1){s([...c,z]);return}let Ee=ie(c),ke=Math.min(V,fe),et=Math.max(V,fe),Bt=Ie.reduce((ao,So,er)=>((er>=ke&&er<=et||Ee.has(So.id))&&ao.push(So.id),ao),[]);s(Bt)}else s([...c,z]);f(z)}else f(null),s(c.filter(V=>V!==z))},[b,s,S,c,C]);W1(()=>{c.length||f(null)},[c]);let M=Ll(z=>{let U;return c.includes(z)?U=o.filter(ee=>c.includes(ee.id)):U=o.filter(ee=>ee.id===z),U.map(ee=>({...ee,elements:nn({type:"everything",elements:ee.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),N=Ll((z,U)=>{let ee={itemIds:c.includes(z)?c:[z]};U.dataTransfer.setData(ue.excalidrawlibIds,JSON.stringify(ee))},[c]),R=Ll(z=>z?c.includes(z):!1,[c]),P=Ll(()=>{t(n)},[n,t]),O=Ll(z=>{z&&r(M(z))},[M,r]),Y=h.size>=(w.length?w:o).length?jS:$S,Q=ww(null);W1(()=>{hx(()=>{Q.current?.focus()})},[]);let q=!y&&Or(Cw,{children:[!x&&Dt("div",{className:"library-menu-items-container__header",children:u("labels.personalLib")}),!n.length&&!C.length?Or("div",{className:"library-menu-items__no-items",children:[!S.length&&Dt("div",{className:"library-menu-items__no-items__label",children:u("library.noItems")}),Dt("div",{className:"library-menu-items__no-items__hint",children:S.length>0?u("library.hint_emptyPrivateLibrary"):u("library.hint_emptyLibrary")})]}):Or(Xp,{children:[n.length>0&&Dt(Ic,{itemsRenderedPerBatch:Y,items:[{id:null,elements:n}],onItemSelectToggle:A,onItemDrag:N,onClick:P,isItemSelected:R,svgCache:h}),Dt(Ic,{itemsRenderedPerBatch:Y,items:C,onItemSelectToggle:A,onItemDrag:N,onClick:O,isItemSelected:R,svgCache:h})]}),S.length>0&&Dt("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:u("labels.excalidrawLib")}),S.length>0&&Dt(Xp,{children:Dt(Ic,{itemsRenderedPerBatch:Y,items:S,onItemSelectToggle:A,onItemDrag:N,onClick:O,isItemSelected:R,svgCache:h})})]}),Z=y&&Or(Cw,{children:[Or("div",{className:"library-menu-items-container__header",children:[u("library.search.heading"),!e&&Or("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:z=>z.preventDefault(),onClick:z=>{v("")},children:[Dt("kbd",{children:"esc"})," to clear"]})]}),w.length>0?Dt(Xp,{children:Dt(Ic,{itemsRenderedPerBatch:Y,items:w,onItemSelectToggle:A,onItemDrag:N,onClick:O,isItemSelected:R,svgCache:h})}):Or("div",{className:"library-menu-items__no-items",children:[Dt("div",{className:"library-menu-items__no-items__hint",children:u("library.search.noResults")}),Dt(ro,{onPointerDown:z=>z.preventDefault(),onSelect:()=>{v("")},style:{width:"auto",marginTop:"1rem"},children:u("library.search.clearSearch")})]})]});return Or("div",{className:"library-menu-items-container",style:n.length||C.length||S.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[Or("div",{className:"library-menu-items-header",children:[!x&&Dt(Qn,{ref:Q,type:"search",className:XS("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:u("library.search.inputPlaceholder"),value:E,onChange:z=>v(z)}),Dt(fw,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),Or(go.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:S.length>0?1:"0 1 auto",margin:x?"auto":0},ref:p,children:[e&&Dt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Dt(Wt,{})}),q,Z,x&&Dt(Fp,{style:{padding:"16px 0",width:"100%"},id:i,libraryReturnUrl:l,theme:a})]})]})}import{jsx as ea,jsxs as kw}from"react/jsx-runtime";var Sl=we(!1),Iw=({children:e})=>ea("div",{className:"layer-ui__library",children:e}),JS=Lw(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:a,id:i,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=te(Nr),p=Z1(b=>{(async(E,v)=>{pe("element","addToLibrary","ui");for(let y of hd)if(E.some(w=>w.type===y))return r({errorMessage:u(`errors.libraryElementTypeError.${y}`)});let x=[{status:"unpublished",elements:E,id:Ut(),created:Date.now()},...v];t(),a.setLibrary(x).catch(()=>{r({errorMessage:u("alerts.errorAddingToLibrary")})})})(b,m.libraryItems)},[t,a,r,m.libraryItems]),d=Mw(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return ea(Iw,{children:ea("div",{className:"layer-ui__library-message",children:kw("div",{children:[ea(Wt,{size:"2em"}),ea("span",{children:u("labels.libraryLoadingMessage")})]})})});let h=m.libraryItems.length>0||o.length>0;return kw(Iw,{children:[ea(V1,{isLoading:m.status==="loading",libraryItems:d,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:i,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),h&&ea(Fp,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:i,libraryReturnUrl:n,theme:l})]})}),K1=(e,o)=>({elements:e,pending:ae(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),QS=(e,o)=>{let t=Yn(),[r,n]=Sw(()=>K1(t,e.selectedElementIds)),a=qS(new Map);return X1(()=>{for(let i of r.pending)a.current.set(i.id,i.version)},[r.pending]),X1(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(i=>{if(!at(i.selectedElementIds,e.selectedElementIds))return a.current.clear(),K1(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==a.current.get(s))return K1(t,e.selectedElementIds)}return i})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Aw=Lw(()=>{let e=lt(),{onInsertElements:o}=e,t=Ar(),r=Le(),n=ye(),[a,i]=Sw([]),l=Mw(()=>e.library,[e.library]),s=QS(r,e);X1(()=>Ve(document,"keydown",p=>{if(p.key===T.ESCAPE&&p.target instanceof HTMLElement){let d=p.target;if(d.closest(`.${nt.SIDEBAR}`))a.length>0?(p.stopPropagation(),i([])):so(d)&&d instanceof HTMLInputElement&&!d.value&&(p.stopPropagation(),n({openSidebar:null}),e.focusContainer());else if(a.length>0){let{x:h,y:b}=e.lastViewportPosition;document.elementFromPoint(h,b)?.closest(`.${nt.SIDEBAR}`)&&(p.stopPropagation(),i([]))}}},{capture:!0}),[a,n,e]);let c=Z1(p=>{o(kl(p)),e.focusContainer()},[o,e]),m=Z1(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return ea(JS,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:i})});import eM from"clsx";import{useRef as tM}from"react";import{createPortal as oM}from"react-dom";import{jsx as _w,jsxs as rM}from"react/jsx-runtime";var Pw=e=>{let{closeOnClickOutside:o=!0}=e,t=jm({className:"excalidraw-modal-container"}),r=tM(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=a=>{a.key===T.ESCAPE&&(a.nativeEvent.stopImmediatePropagation(),a.stopPropagation(),e.onCloseRequest())};return oM(rM("div",{className:eM("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,children:[_w("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),_w("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as kc,jsxs as sM}from"react/jsx-runtime";function lM(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var gt=e=>{let[o,t]=B2(),[r]=iM(document.activeElement),{id:n}=qe(),a=Te().formFactor==="phone";aM(()=>{if(!o)return;let c=us(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=p=>{if(p.key===T.TAB){let d=us(o),{activeElement:h}=document,b=d.findIndex(f=>f===h);b===0&&p.shiftKey?(d[d.length-1].focus(),p.preventDefault()):b===d.length-1&&!p.shiftKey&&(d[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let i=ye(),l=Sr(Sl),s=()=>{i({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return kc(Pw,{className:nM("Dialog",e.className,{"Dialog--fullscreen":a}),labelledBy:"dialog-title",maxWidth:lM(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:sM(xt,{ref:t,children:[e.title&&kc("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:kc("span",{className:"Dialog__titleContent",children:e.title})}),a&&kc("button",{className:"Dialog__close",onClick:s,title:u("buttons.close"),"aria-label":u("buttons.close"),type:"button",children:wo}),kc("div",{className:"Dialog__content",children:e.children})]})})};var $p=[{icon:Bn,value:"selection",key:T.V,numericKey:T[1],fillable:!0},{icon:Ra,value:"rectangle",key:T.R,numericKey:T[2],fillable:!0},{icon:Na,value:"diamond",key:T.D,numericKey:T[3],fillable:!0},{icon:Oa,value:"ellipse",key:T.O,numericKey:T[4],fillable:!0},{icon:Ds,value:"arrow",key:T.A,numericKey:T[5],fillable:!0},{icon:za,value:"line",key:T.L,numericKey:T[6],fillable:!0},{icon:lr,value:"freedraw",key:[T.P,T.X],numericKey:T[7],fillable:!1},{icon:sr,value:"text",key:T.T,numericKey:T[8],fillable:!1},{icon:Ba,value:"image",key:null,numericKey:T[9],fillable:!1},{icon:Rs,value:"eraser",key:T.E,numericKey:T[0],fillable:!1}],$1=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:Bn,key:T.V,numericKey:T[1],fillable:!0},...$p.slice(1)]:$p,Dw=(e,o)=>$1(o).find((r,n)=>r.numericKey!=null&&e===r.numericKey.toString()||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;import Br from"clsx";import{useRef as hM,useState as gM}from"react";import*as Fr from"@radix-ui/react-popover";import{createIsolation as cM}from"jotai-scope";import j1 from"react";import zr from"tunnel-rat";var q1=j1.createContext(null),Xe=()=>j1.useContext(q1),dM=cM(),Rw=()=>j1.useMemo(()=>({MainMenuTunnel:zr(),WelcomeScreenMenuHintTunnel:zr(),WelcomeScreenToolbarHintTunnel:zr(),WelcomeScreenHelpHintTunnel:zr(),WelcomeScreenCenterTunnel:zr(),FooterCenterTunnel:zr(),DefaultSidebarTriggerTunnel:zr(),DefaultSidebarTabTriggersTunnel:zr(),OverwriteConfirmDialogTunnel:zr(),TTDDialogTriggerTunnel:zr(),tunnelsJotai:dM}),[]);var Sc=H({name:"viewMode",label:"labels.viewMode",icon:Ya,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:D.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===he.R});import{useEffect as mM,useState as pM}from"react";import Nw from"clsx";import*as Al from"@radix-ui/react-popover";import{jsx as jp,jsxs as uM}from"react/jsx-runtime";var _l=({app:e,options:o,activeTool:t,defaultOption:r,className:n="Shape",namePrefix:a,title:i,"data-testid":l,onToolChange:s,displayedOption:c,fillable:m=!1})=>{let[p,d]=pM(!1),h=t.type,b=c.type===h,f=32/2+10,{container:E}=qe();return!o.some(v=>v.type===h)&&p&&d(!1),mM(()=>{let v=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>v?.()},[e]),uM(Al.Root,{open:p,children:[jp(Al.Trigger,{asChild:!0,children:jp(J,{className:Nw(n,{fillable:m,active:o.some(v=>v.type===t.type)}),type:"radio",icon:c.icon,checked:b,name:"editor-current-shape",title:i,"aria-label":i,"data-testid":l,onPointerDown:()=>{d(v=>!v),s(r)}})}),jp(Al.Content,{className:"tool-popover-content",sideOffset:f,collisionBoundary:E??void 0,children:o.map(({type:v,icon:x,title:y})=>jp(J,{className:Nw(n,{active:h===v}),type:"radio",icon:x,checked:h===v,name:`${a}-option`,title:y||Ae(v),keyBindingLabel:"","aria-label":y||Ae(v),"data-testid":`toolbar-${v}`,onChange:()=>{e.state.activeTool.type!==v&&pe("toolbar",v,"ui"),e.setActiveTool({type:v}),s?.(v)}},v))})]})};import{Fragment as Io,jsx as j,jsxs as be}from"react/jsx-runtime";var J1=Br([nt.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),Mc=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return Es(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>Es(r.type))},Lc=(e,o)=>yr(e.activeTool.type)||o.some(t=>yr(t.type)),Ow=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=_i(o,e),a=!1;n.length===2&&(ft(n[0])||ft(n[1]))&&(a=!0);let i=!!(e.editingTextElement||e.newElement),l=Te(),s=document.documentElement.getAttribute("dir")==="rtl",c=yr(e.activeTool.type)&&!jr(e.currentItemBackgroundColor)||n.some(b=>yr(b.type)&&!jr(b.backgroundColor)),m=n.length===1||a,p=!e.selectedLinearElement?.isEditing&&n.length===1&&ge(n[0])&&!Se(n[0]),d=!e.croppingElementId&&n.length===1&&Ue(n[0]),h=!a&&to(e,r);return be("div",{className:"selected-shape-actions",children:[j("div",{children:Mc(e,n)&&t("changeStrokeColor")}),Lc(e,n)&&j("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(vs(e.activeTool.type)||n.some(b=>vs(b.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(b=>b.type==="freedraw"))&&t("changeStrokeShape"),(ws(e.activeTool.type)||n.some(b=>ws(b.type)))&&be(Io,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Ts(e.activeTool.type)||n.some(b=>Ts(b.type)))&&j(Io,{children:t("changeRoundness")}),(Cs(e.activeTool.type)||n.some(b=>Cs(b.type)))&&j(Io,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some($))&&be(Io,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||fh(n,o))&&t("changeTextAlign")]}),gh(n,o)&&t("changeVerticalAlign"),(Di(e.activeTool.type)||n.some(b=>Di(b.type)))&&j(Io,{children:t("changeArrowhead")}),t("changeOpacity"),be("fieldset",{children:[j("legend",{children:u("labels.layers")}),be("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),h&&!a&&be("fieldset",{children:[j("legend",{children:u("labels.align")}),be("div",{className:"buttonList",children:[s?be(Io,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):be(Io,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),be("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!i&&n.length>0&&be("fieldset",{children:[j("legend",{children:u("labels.actions")}),be("div",{className:"buttonList",children:[l.formFactor!=="phone"&&t("duplicateSelection"),l.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),p&&t("toggleLinearEditor")]})]})]})},zw=({appState:e,renderAction:o,setAppState:t,targetElements:r,container:n})=>{let a=yr(e.activeTool.type)&&!jr(e.currentItemBackgroundColor)||r.some(s=>yr(s.type)&&!jr(s.backgroundColor)),i=r.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return i?j("div",{className:"compact-action-item",children:be(Fr.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(Fr.Trigger,{asChild:!0,children:j("button",{type:"button",className:Br("compact-action-button properties-trigger",{active:l}),title:u("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactStrokeStyles"})},children:Of})}),l&&j(dn,{className:J1,container:n,style:{maxWidth:"13rem"},onClose:()=>{},children:be("div",{className:"selected-shape-actions",children:[a&&o("changeFillStyle"),(vs(e.activeTool.type)||r.some(s=>vs(s.type)))&&o("changeStrokeWidth"),(ws(e.activeTool.type)||r.some(s=>ws(s.type)))&&be(Io,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(Ts(e.activeTool.type)||r.some(s=>Ts(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},Bw=({appState:e,renderAction:o,setAppState:t,targetElements:r,container:n,app:a})=>{let i=Cs(e.activeTool.type)||r.some(s=>Cs(s.type)),l=e.openPopup==="compactArrowProperties";return i?j("div",{className:"compact-action-item",children:be(Fr.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(Fr.Trigger,{asChild:!0,children:j("button",{type:"button",className:Br("compact-action-button properties-trigger",{active:l}),title:u("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=Xt(r,a,c=>Me(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>Me(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?Ka:s==="round"?Za:Va})()})}),l&&j(dn,{container:n,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},Fw=({appState:e,renderAction:o,setAppState:t,targetElements:r,container:n,elementsMap:a})=>{let{saveCaretPosition:i,restoreCaretPosition:l}=zE(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:be(Fr.Root,{open:s,onOpenChange:c=>{c?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&l())},children:[j(Fr.Trigger,{asChild:!0,children:j("button",{type:"button",className:Br("compact-action-button properties-trigger",{active:s}),title:u("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:lg})}),e.openPopup==="compactTextProperties"&&j(dn,{className:J1,container:n,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:be("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||r.some($))&&o("changeFontSize"),(e.activeTool.type==="text"||fh(r,a))&&o("changeTextAlign"),gh(r,a)&&o("changeVerticalAlign")]})})]})})},Hw=({appState:e,renderAction:o,targetElements:t,setAppState:r,container:n,app:a,showDuplicate:i,showDelete:l})=>{let s=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&Ue(t[0]),m=t.length===1,p=to(e,a),d=!1;t.length===2&&(ft(t[0])||ft(t[1]))&&(d=!0);let h=document.documentElement.getAttribute("dir")==="rtl",b=e.openPopup==="compactOtherProperties";return s||t.length===0?null:j("div",{className:"compact-action-item",children:be(Fr.Root,{open:b,onOpenChange:f=>{r(f?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(Fr.Trigger,{asChild:!0,children:j("button",{type:"button",className:Br("compact-action-button properties-trigger",{active:b}),title:u("labels.actions"),onClick:f=>{f.preventDefault(),f.stopPropagation(),r({openPopup:b?null:"compactOtherProperties"})},children:eg})}),b&&j(dn,{className:J1,container:n,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:be("div",{className:"selected-shape-actions",children:[be("fieldset",{children:[j("legend",{children:u("labels.layers")}),be("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!d&&be("fieldset",{children:[j("legend",{children:u("labels.align")}),be("div",{className:"buttonList",children:[h?be(Io,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):be(Io,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),be("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically")]})]})]}),be("fieldset",{children:[j("legend",{children:u("labels.actions")}),be("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),c&&o("cropEditor"),i&&o("duplicateSelection"),l&&o("deleteSelectedElements")]})]})]})})]})})},fM=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&ge(t[0])&&!Se(t[0])?j("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,Uw=({appState:e,elementsMap:o,renderAction:t,app:r,setAppState:n})=>{let a=_i(o,e),{container:i}=qe(),l=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&a.length===1&&ge(a[0])&&!Se(a[0]);return be("div",{className:"compact-shape-actions",children:[Mc(e,a)&&j("div",{className:Br("compact-action-item"),children:t("changeStrokeColor")}),Lc(e,a)&&j("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),j(zw,{appState:e,renderAction:t,setAppState:n,targetElements:a,container:i}),j(Bw,{appState:e,renderAction:t,setAppState:n,targetElements:a,container:i,app:r}),s&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||a.some($))&&be(Io,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(Fw,{appState:e,renderAction:t,setAppState:n,targetElements:a,container:i,elementsMap:o})]}),!l&&a.length>0&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),!l&&a.length>0&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(Hw,{appState:e,renderAction:t,targetElements:a,setAppState:n,container:i,app:r})]})},Gw=({appState:e,elementsMap:o,renderAction:t,app:r,setAppState:n})=>{let a=_i(o,e),{container:i}=qe(),l=hM(null),s=l.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,d=c*p+(c-1)*m,h=p+m,b=s>=d+h,f=s>=d+2*h;return be(xt,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[be("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[Mc(e,a)&&j("div",{className:Br("compact-action-item"),children:t("changeStrokeColor")}),Lc(e,a)&&j("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),j(zw,{appState:e,renderAction:t,setAppState:n,targetElements:a,container:i}),j(Bw,{appState:e,renderAction:t,setAppState:n,targetElements:a,container:i,app:r}),j(fM,{appState:e,renderAction:t,targetElements:a}),(e.activeTool.type==="text"||a.some($))&&be(Io,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(Fw,{appState:e,renderAction:t,setAppState:n,targetElements:a,container:i,elementsMap:o})]}),j(Hw,{appState:e,renderAction:t,targetElements:a,setAppState:n,container:i,app:r,showDuplicate:!f,showDelete:!b})]}),be("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),f&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),b&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},Ww=({activeTool:e,setAppState:o,app:t,UIOptions:r})=>{let[n,a]=gM(!1),i=Pt(),l=i==="full",s=i==="compact",c=[{type:"selection",icon:Bn,title:Ae(u("toolBar.selection"))},{type:"lasso",icon:ln,title:Ae(u("toolBar.lasso"))}],m=e.type==="frame",p=e.type==="laser",d=l&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",h=e.type==="embeddable",{TTDDialogTriggerTunnel:b}=Xe();return be(Io,{children:[$1(t).map(({value:f,icon:E,key:v,numericKey:x,fillable:y},w)=>{if(r.tools?.[f]===!1)return null;let C=u(`toolBar.${f}`),S=v&&Ae(typeof v=="string"?v:v[0]),A=S?`${S} ${u("helpDialog.or")} ${x}`:`${x}`;return(f==="selection"||f==="lasso")&&s?j(_l,{app:t,options:c,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Ae(u("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:M=>{(M==="selection"||M==="lasso")&&(t.setActiveTool({type:M}),o({preferredSelectionTool:{type:M,initialized:!0}}))},displayedOption:c.find(M=>M.type===t.state.preferredSelectionTool.type)||c[0],fillable:e.type==="selection"},"selection-popover"):j(J,{className:Br("Shape",{fillable:y}),type:"radio",icon:E,checked:e.type===f,name:"editor-current-shape",title:`${Ae(C)} \u2014 ${A}`,keyBindingLabel:x||S,"aria-label":Ae(C),"aria-keyshortcuts":A,"data-testid":`toolbar-${f}`,onPointerDown:({pointerType:M})=>{!t.state.penDetected&&M==="pen"&&t.togglePenMode(!0),f==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:M})=>{t.state.activeTool.type!==f&&pe("toolbar",f,"ui"),f==="image"?t.setActiveTool({type:f}):t.setActiveTool({type:f})}},f)}),j("div",{className:"App-toolbar__divider"}),be(de,{open:n,children:[j(de.Trigger,{className:Br("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":m||h||d||p&&!t.props.isCollaborating}),onToggle:()=>{a(!n),o({openMenu:null,openPopup:null})},title:u("toolBar.extraTools"),children:m?zo:h?Fa:p&&!t.props.isCollaborating?cn:d?ln:Qi}),be(de.Content,{onClickOutside:()=>a(!1),onSelect:()=>a(!1),className:"App-toolbar__extra-tools-dropdown",children:[j(de.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:zo,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:m,children:u("toolBar.frame")}),j(de.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Fa,"data-testid":"toolbar-embeddable",selected:h,children:u("toolBar.embeddable")}),j(de.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:cn,"data-testid":"toolbar-laser",selected:p,shortcut:T.K.toLocaleUpperCase(),children:u("toolBar.laser")}),l&&j(de.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:ln,"data-testid":"toolbar-lasso",selected:d,children:u("toolBar.lasso")}),j("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&j(b.Out,{}),j(de.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Wa,"data-testid":"toolbar-embeddable",children:u("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&be(de.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Un,"data-testid":"toolbar-magicframe",children:[u("toolBar.magicframe"),j(de.Item.Badge,{children:"AI"})]})]})]})]})},Yw=({renderAction:e,zoom:o})=>j(go.Col,{gap:1,className:nt.ZOOM_ACTIONS,children:be(go.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),Vw=({renderAction:e,className:o})=>be("div",{className:`undo-redo-buttons ${o}`,children:[j("div",{className:"undo-button-container",children:j(To,{label:u("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:be(To,{label:u("buttons.redo"),children:[" ",e("redo")]})})]}),Kw=({actionManager:e,showExitZenModeBtn:o})=>j("button",{type:"button",className:Br("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ti),children:u("buttons.exitZenMode")}),Zw=({actionManager:e})=>j("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(Sc),children:Bf});import{useRef as bM}from"react";var Q1=e=>{let o=bM({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as yM,jsxs as xM}from"react/jsx-runtime";var ni=we(null),Xw=()=>{let[e,o]=te(ni),t=vt();return e&&e==="clearCanvas"?yM(Up,{onConfirm:()=>{t.executeAction(Dr),o(null)},onCancel:()=>o(null),title:u("clearCanvasDialog.title"),children:xM("p",{className:"clear-canvas__content",children:[" ",u("alerts.clearReset")]})}):null};var eb={};td(eb,{toggleTheme:()=>EM});var EM={...Xn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Xn,"commandPalette")}};import{jsx as Rt,jsxs as Hr}from"react/jsx-runtime";var TM=we(null),ot={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},$w=e=>{switch(e){case ot.app:return 1;case ot.export:return 2;case ot.editor:return 3;case ot.tools:return 4;case ot.elements:return 5;case ot.links:return 6;default:return 10}},Qp=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return Hr("div",{className:qw("shortcut",o),children:[r.map((n,a)=>Rt("div",{className:"shortcut-wrapper",children:Rt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Rt("div",{className:"shortcut-desc",children:t})]})},Qw=e=>!e.altKey&&e[T.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===T.P||e.key===T.SLASH),CM=Object.assign(e=>{let o=Le(),t=ye();return Jp(()=>{let r=n=>{Qw(n)&&(n.preventDefault(),n.stopPropagation(),t(a=>{let i=a.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return i&&pe("command_palette","open","shortcut"),{openDialog:i}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Rt(IM,{...e})},{defaultItems:eb});function IM({customCommandPaletteItems:e}){let o=lt(),t=Le(),r=ye(),n=Ar(),a=vt(),[i,l]=te(TM),[s,c]=qp(null),m=Jw(null),p=Gn({uiAppState:t,customCommandPaletteItems:e,appProps:n}),[d]=te(Nr),h=wM(()=>d.libraryItems?.filter(M=>!!M.name).map(M=>({label:M.name,icon:Rt(kM,{id:M.id,elements:M.elements}),category:"Library",order:$w("Library"),haystack:ri(M.name),perform:()=>{o.onInsertElements(kl([M]))}}))||[],[o,d.libraryItems]);Jp(()=>{let{uiAppState:M,customCommandPaletteItems:N,appProps:R}=p,P=q=>{let Z="";return q.label&&(typeof q.label=="function"?Z=u(q.label(o.scene.getNonDeletedElements(),M,o)):Z=u(q.label)),Z},O=q=>typeof q.icon=="function"?q.icon(M,o.scene.getNonDeletedElements()):q.icon,Y=[],Q=(q,Z,z)=>{let U={label:P(q),icon:O(q),category:Z,shortcut:ht(q.name),keywords:q.keywords,predicate:q.predicate,viewMode:q.viewMode,perform:()=>{a.executeAction(q,"commandPalette")}};return z?z(U,q):U};if(M&&o.scene&&a){let q=[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,a.actions.togglePolygon,xl,Rp,z2].map(V=>Q(V,ot.elements,(fe,Ee)=>({...fe,predicate:Ee.predicate?Ee.predicate:(ke,et,Bt,ao)=>ae(ke,et).length>0}))),Z=[a.actions.toggleHandTool,a.actions.setFrameAsActiveTool,a.actions.toggleLassoTool].map(V=>Q(V,ot.tools)),z=[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(V=>Q(V,ot.editor)),U=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(V=>Q(V,ot.export));Y=[...q,...z,{label:P(Dr),icon:O(Dr),shortcut:ht(Dr.name),category:ot.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Et.set(ni,"clearCanvas")}},{label:u("buttons.exportImage"),category:ot.export,icon:zs,shortcut:ht("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...U];let ee=[{label:u("toolBar.library"),category:ot.app,icon:Ps,viewMode:!1,perform:()=>{M.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Yt.name,tab:Yt.defaultTab}})}},{label:u("search.title"),category:ot.app,icon:uo,viewMode:!0,perform:()=>{a.executeAction(Pl)}},{label:u("labels.shapeSwitch"),category:ot.elements,icon:el,perform:()=>{a.executeAction(O2)}},{label:u("labels.changeStroke"),keywords:["color","outline"],category:ot.elements,icon:Os,viewMode:!1,predicate:(V,fe)=>{let Ee=ae(V,fe);return Ee.length>0&&Mc(fe,Ee)},perform:()=>{r(V=>({openPopup:"elementStroke"}))}},{label:u("labels.changeBackground"),keywords:["color","fill"],icon:Os,category:ot.elements,viewMode:!1,predicate:(V,fe)=>{let Ee=ae(V,fe);return Ee.length>0&&Lc(fe,Ee)},perform:()=>{r(V=>({openPopup:"elementBackground"}))}},{label:u("labels.canvasBackground"),keywords:["color"],icon:Os,category:ot.editor,viewMode:!1,perform:()=>{r(V=>({openMenu:V.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...$p.reduce((V,fe)=>{let{value:Ee,icon:ke,key:et,numericKey:Bt}=fe;if(R.UIOptions.tools?.[Ee]===!1)return V;let So=et&&Ae(typeof et=="string"?et:et[0])||Bt,er={label:u(`toolBar.${Ee}`),category:ot.tools,shortcut:So,icon:ke,keywords:["toolbar"],viewMode:!1,perform:({event:Hu})=>{Ee==="image"?o.setActiveTool({type:Ee}):o.setActiveTool({type:Ee})}};return V.push(er),V},[]),...Z,{label:u("toolBar.lock"),category:ot.tools,icon:M.activeTool.locked?Da:zn,shortcut:T.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${u("labels.textToDiagram")}...`,category:ot.tools,icon:bf,viewMode:!1,predicate:R.aiEnabled,perform:()=>{r(V=>({...V,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${u("toolBar.mermaidToExcalidraw")}...`,category:ot.tools,icon:Wa,viewMode:!1,predicate:R.aiEnabled,perform:()=>{r(V=>({...V,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Ie=[...Y,...ee,...N||[]].map(V=>({...V,icon:V.icon||el,order:V.order??$w(V.category),haystack:`${ri(V.label.toLocaleLowerCase())} ${V.keywords?.join(" ")||""}`}));c(Ie),l([...Ie,...h].find(V=>V.label===i?.label)??null)}},[p,o,a,c,i?.label,l,r,h]);let[b,f]=qp(""),[E,v]=qp(null),[x,y]=qp({}),w=M=>{r({openDialog:null},M),f("")},C=(M,N)=>{t.openDialog?.name==="commandPalette"&&(N.stopPropagation(),N.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{M.perform({actionManager:a,event:N}),l(M),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},S=Q1(M=>M.viewMode===!1&&t.viewModeEnabled?!1:typeof M.predicate=="function"?M.predicate(o.scene.getNonDeletedElements(),t,n,o):M.predicate===void 0||M.predicate),A=Q1(M=>{let N=so(M.target)||Qw(M)||M.key===T.ESCAPE;if(N&&M.key!==T.ARROW_UP&&M.key!==T.ARROW_DOWN&&M.key!==T.ENTER)return;let R=Object.values(x).flat(),P=i&&!b&&S(i);if(M.key===T.ARROW_UP){M.preventDefault();let O=R.findIndex(q=>q.label===E?.label);if(P){if(O===0){v(i);return}if(E===i){let q=R[R.length-1];q&&v(q);return}}let Y;O===-1?Y=R.length-1:Y=O===0?R.length-1:(O-1)%R.length;let Q=R[Y];Q&&v(Q);return}if(M.key===T.ARROW_DOWN){M.preventDefault();let O=R.findIndex(q=>q.label===E?.label);if(P){if(!E||O===R.length-1){v(i);return}if(E===i){let q=R[0];q&&v(q);return}}let Y=(O+1)%R.length,Q=R[Y];Q&&v(Q);return}if(M.key===T.ENTER&&E&&setTimeout(()=>{C(E,M)}),!N){if(M.stopPropagation(),/^[a-zA-Z0-9]$/.test(M.key)){m?.current?.focus();return}M.preventDefault()}});return Jp(()=>(window.addEventListener("keydown",A,{capture:!0}),()=>window.removeEventListener("keydown",A,{capture:!0})),[A]),Jp(()=>{if(!s)return;let M=O=>{let Y={};for(let Q of O)Y[Q.category]?Y[Q.category].push(Q):Y[Q.category]=[Q];return Y},N=b?.length>1?[...s.filter(S).sort((O,Y)=>O.order-Y.order),...h]:s.filter(S).sort((O,Y)=>O.order-Y.order),R=!b&&i&&S(i);if(!b){y(M(R?N.filter(O=>O.label!==i?.label):N)),v(R?i:N[0]||null);return}let P=ri(b.toLocaleLowerCase().replace(/[<>_| -]/g,""));N=vM.filter(P,N,{extract:O=>O.haystack??""}).sort((O,Y)=>Y.score-O.score).map(O=>O.original),y(M(N)),v(N[0]??null)},[b,s,S,i,h]),Hr(gt,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Rt(Qn,{value:b,placeholder:u("commandPalette.search.placeholder"),onChange:M=>{f(M)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&Hr("div",{className:"shortcuts-wrapper",children:[Rt(Qp,{shortcut:"\u2191\u2193",children:u("commandPalette.shortcuts.select")}),Rt(Qp,{shortcut:"\u21B5",children:u("commandPalette.shortcuts.confirm")}),Rt(Qp,{shortcut:B("Esc"),children:u("commandPalette.shortcuts.close")})]}),Hr("div",{className:"commands",children:[i&&!b&&Hr("div",{className:"command-category",children:[Hr("div",{className:"command-category-title",children:[u("commandPalette.recents"),Rt("div",{className:"icon",style:{marginLeft:"6px"},children:xf})]}),Rt(jw,{command:i,isSelected:i.label===E?.label,onClick:M=>C(i,M),disabled:!S(i),onMouseMove:()=>v(i),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((M,N)=>Hr("div",{className:"command-category",children:[Rt("div",{className:"command-category-title",children:M}),x[M].map(R=>Rt(jw,{command:R,isSelected:R.label===E?.label,onClick:P=>C(R,P),onMouseMove:()=>v(R),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:M==="Library"?"large":"small"},R.label))]},M)):s?Hr("div",{className:"no-match",children:[Rt("div",{className:"icon",children:uo})," ",u("commandPalette.search.noMatch")]}):null]})]})}var kM=({id:e,elements:o})=>{let t=Jw(null),{svgCache:r}=Cl();return Op(e,o,r,t),Rt("div",{className:"library-item-icon",ref:t})},jw=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:a,appState:i,size:l="small"})=>{let s=()=>{};return Hr("div",{className:qw("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":l==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?s:n,onMouseMove:t?s:r,title:t?u("commandPalette.itemNotAvailable"):"",children:[Hr("div",{className:"name",children:[e.icon&&Rt(_r,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(i,[]):e.icon}),Rt(ec,{children:e.label})]}),a&&e.shortcut&&Rt(Qp,{shortcut:e.shortcut})]})};import{jsx as e3}from"react/jsx-runtime";var ai=H({name:"toggleLinearEditor",category:ot.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&ge(n[0])&&!Se(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];je(n,"No selected element found"),je(o.selectedLinearElement,"No selected linear element found"),je(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let a={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:a},captureUpdate:D.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let n=u(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return e3(J,{type:"button",icon:Df,title:n,"aria-label":n,onClick:()=>o(null)})}}),yQ=H({name:"togglePolygon",category:ot.elements,icon:xm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(a=>!tt(a)||!a.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(a=>tt(a)&&a.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!tt(s)))return!1;let a=n,i=a.some(s=>!s.polygon),l=ie(a);return{elements:e.map(s=>!l.has(s.id)||!tt(s)?s:re(s,{backgroundColor:i?s.backgroundColor:"transparent",...jd(s,i)})),appState:o,captureUpdate:D.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(i=>!tt(i)||!i.polygon||i.points.length<3))return null;let n=r.every(i=>tt(i)&&i.polygon),a=u(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return e3(ol,{icon:xm,title:a,"aria-label":a,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});var Pl=H({name:"searchMenu",icon:uo,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===Yt.name&&o.openSidebar.tab===Zr){let n=r.excalidrawContainerValue.container?.querySelector(`.${nt.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:Yt.name,tab:Zr},openDialog:null},captureUpdate:D.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.F});import{jsx as SM}from"react/jsx-runtime";var eu=H({name:"cropEditor",label:"helpDialog.cropStart",icon:Hm,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:D.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&Ue(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=u("helpDialog.cropStart");return SM(J,{type:"button",icon:Hm,title:r,"aria-label":r,onClick:()=>o(null)})}});var o3=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&le(t[0])},r3=H({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(le(n)){let a=No(ve(e),n.id).filter(i=>!(i.type==="text"&&i.containerId));return{elements:e,appState:{...o,selectedElementIds:a.reduce((i,l)=>(i[l.id]=!0,i),{})},captureUpdate:D.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:D.EVENTUALLY}},predicate:(e,o,t,r)=>o3(o,r)}),n3=H({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return le(n)?{elements:uy(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:D.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:D.EVENTUALLY}},predicate:(e,o,t,r)=>o3(o,r)}),See=H({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:D.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Mee=H({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:zo,viewMode:!1,perform:(e,o,t,r)=>{let n=Ne(o,{type:"frame"});return Uo(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ne(o,{type:"frame"})},captureUpdate:D.EVENTUALLY}},keyTest:e=>!e[T.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===T.F}),a3=H({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=ae(e,o);return n.length>0&&!n.some(a=>le(a))},perform:(e,o,t,r)=>{let n=ae(e,o),a=r.scene.getNonDeletedElementsMap(),[i,l,s,c]=_e(n,a),m=16,p=rm({x:i-m,y:l-m,width:s-i+m*2,height:c-l+m*2});if(o.editingGroupId){let h=Ke(n,o.editingGroupId);for(let b of h){let f=b.groupIds.indexOf(o.editingGroupId);Zt(b,a,{groupIds:b.groupIds.slice(0,f)})}}return{elements:Pi([...r.scene.getElementsIncludingDeleted(),p],n,p,o),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:D.IMMEDIATELY}}});var Dl=class extends ks{applyTo(o,t,r){let[n,a]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[i,l]=this.appState.applyTo(t,n);return[n,i,a||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},ii=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Rl=class e{constructor(o){this.store=o;k(this,"onHistoryChangedEmitter",new Po);k(this,"undoStack",[]);k(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(o){if(o.isEmpty()||o instanceof Dl)return;let t=Dl.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ii(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let a=r();if(a===null)return;let i=D.IMMEDIATELY,l=this.store.snapshot,s=o,c=t,m=!1;for(;a;){try{[s,c,m]=a.applyTo(s,c,l);let p=l.elements,d=l.maybeClone(i,s,c),h=ky.create(l,d),b=Dl.applyLatestChanges(a,p,s);b.isEmpty()||(this.store.scheduleMicroAction({action:i,change:h,delta:b}),a=b),l=d}finally{n(a)}if(m)break;a=r()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new ii(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=Dl.inverse(t);return o.push(r)}};import{useEffect as MM,useState as LM}from"react";var tb=(e,o)=>{let[t,r]=LM(o);return MM(()=>{let n=e.on(a=>{r(a)});return()=>{n()}},[e]),t};import{jsx as c3}from"react/jsx-runtime";var i3=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:D.EVENTUALLY};let[n,a]=r,i=Qd(Array.from(n.values()));return{appState:a,elements:i,captureUpdate:D.NEVER}}return{captureUpdate:D.EVENTUALLY}},l3=e=>({name:"undo",label:"buttons.undo",icon:wm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>i3(n,t,()=>e.undo(ie(o),t)),keyTest:o=>o[T.CTRL_OR_CMD]&&Ed(o,T.Z)&&!o.shiftKey,PanelComponent:({appState:o,updateData:t,data:r,app:n})=>{let{isUndoStackEmpty:a}=tb(e.onHistoryChangedEmitter,new ii(e.isUndoStackEmpty,e.isRedoStackEmpty)),i=Pt()==="mobile";return c3(J,{type:"button",icon:wm,"aria-label":u("buttons.undo"),onClick:t,size:r?.size||"medium",disabled:a,"data-testid":"button-undo",style:{...i?Xr:{}}})}}),s3=e=>({name:"redo",label:"buttons.redo",icon:Tm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>i3(n,t,()=>e.redo(ie(o),t)),keyTest:o=>o[T.CTRL_OR_CMD]&&o.shiftKey&&Ed(o,T.Z)||yd&&o.ctrlKey&&!o.shiftKey&&Ed(o,T.Y),PanelComponent:({appState:o,updateData:t,data:r,app:n})=>{let{isRedoStackEmpty:a}=tb(e.onHistoryChangedEmitter,new ii(e.isUndoStackEmpty,e.isRedoStackEmpty)),i=Pt()==="mobile";return c3(J,{type:"button",icon:Tm,"aria-label":u("buttons.redo"),onClick:t,size:r?.size||"medium",disabled:a,"data-testid":"button-redo",style:{...i?Xr:{}}})}});var d3=H({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=ae(e,o);return n.length===1&&$(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=ae(e,o);return{appState:o,elements:e.map(a=>{if(a.id===n[0].id&&$(a)){let i=Kt(a.originalText,yt(a),a.lineHeight);return re(a,{autoResize:!0,width:i.width,height:i.height,text:a.originalText})}return a}),captureUpdate:D.IMMEDIATELY}}});import{jsx as AM}from"react/jsx-runtime";var ob=(e,o,t,r,n,a)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,a))&&pe(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(i){console.error("error while logging action:",i)}},Ac=class{constructor(o,t,r,n){k(this,"actions",{});k(this,"updater");k(this,"getAppState");k(this,"getElementsIncludingDeleted");k(this,"app");k(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],a=n.PanelComponent;a.displayName="PanelComponent";let i=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{ob(n,"ui",l,i,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return AM(a,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});k(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=a=>{if(Mn(a))a.then(i=>o(i));else return o(a)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let a=this.getElementsIncludingDeleted(),i=this.getAppState(),l=null;return ob(n,"keyboard",i,a,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(a,i,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),a=this.getAppState();ob(o,t,a,n,this.app,r),this.updater(o.perform(n,a,r,this.app))}};var tu=class{constructor(){k(this,"targets",new WeakMap);k(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var rb=e=>{let o=Array.from(e.values());return{x:m3(o,t=>t.x)/o.length,y:m3(o,t=>t.y)/o.length}},nb=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),m3=(e,o)=>e.reduce((t,r)=>t+o(r),0);var _M=8,p3=99999,ou=e=>_M/e,no=class no{};k(no,"referenceSnapPoints",null),k(no,"visibleGaps",null),k(no,"setReferenceSnapPoints",o=>{no.referenceSnapPoints=o}),k(no,"getReferenceSnapPoints",()=>no.referenceSnapPoints),k(no,"setVisibleGaps",o=>{no.visibleGaps=o}),k(no,"getVisibleGaps",()=>no.visibleGaps),k(no,"destroy",()=>{no.referenceSnapPoints=null,no.visibleGaps=null});var Yo=no,ta=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,fn=({event:e,app:o,selectedElements:t})=>{if(e){let r=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||r)&&(o.state.objectsSnapModeEnabled&&!e[T.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[T.CTRL_OR_CMD]&&!ta(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},PM=(e,o,t=.01)=>Math.abs(e-o)<=t,_c=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let a=[];if(e.length===1){let i=e[0],[l,s,c,m,p,d]=At(i,o);n&&(l+=n.x,c+=n.x,p+=n.x,s+=n.y,m+=n.y,d+=n.y);let h=(c-l)/2,b=(m-s)/2;if((i.type==="diamond"||i.type==="ellipse")&&!r){let f=Ge(L(l,s+b),L(p,d),i.angle),E=Ge(L(l+h,s),L(p,d),i.angle),v=Ge(L(c,s+b),L(p,d),i.angle),x=Ge(L(l+h,m),L(p,d),i.angle),y=L(p,d);a=t?[f,E,v,x]:[f,E,v,x,y]}else{let f=Ge(L(l,s),L(p,d),i.angle),E=Ge(L(c,s),L(p,d),i.angle),v=Ge(L(l,m),L(p,d),i.angle),x=Ge(L(c,m),L(p,d),i.angle),y=L(p,d);a=t?[f,E,v,x]:[f,E,v,x,y]}}else if(e.length>1){let[i,l,s,c]=Jd(e,n??{x:0,y:0}),m=s-i,p=c-l,d=L(i,l),h=L(s,l),b=L(i,c),f=L(s,c),E=L(i+m/2,l+p/2);a=t?[d,h,b,f]:[d,h,b,f,E]}return a.map(i=>L(st(i[0]),st(i[1])))},g3=(e,o,t,r)=>Th(e,o,t,r),f3=(e,o,t,r)=>{let n=g3(e,o,t,r),a=wh(n,r).filter(p=>!(p.length===1&&it(p[0]))).map(p=>_e(p).map(d=>st(d))),i=a.sort((p,d)=>p[0]-d[0]),l=[],s=0;e:for(let p=0;p<i.length;p++){let d=i[p];for(let h=p+1;h<i.length;h++){if(++s>p3)break e;let b=i[h],[,f,E,v]=d,[x,y,,w]=b;E<x&&es(Eo(f,v),Eo(y,w))&&l.push({startBounds:d,endBounds:b,startSide:[L(E,f),L(E,v)],endSide:[L(x,y),L(x,w)],length:x-E,overlap:ts(Eo(f,v),Eo(y,w))})}}let c=a.sort((p,d)=>p[1]-d[1]),m=[];s=0;e:for(let p=0;p<c.length;p++){let d=c[p];for(let h=p+1;h<c.length;h++){if(++s>p3)break e;let b=c[h],[f,,E,v]=d,[x,y,w]=b;v<y&&es(Eo(f,E),Eo(x,w))&&m.push({startBounds:d,endBounds:b,startSide:[L(f,v),L(E,v)],endSide:[L(x,y),L(w,y)],length:y-v,overlap:ts(Eo(f,E),Eo(x,w))})}}return{horizontalGaps:l,verticalGaps:m}},u3=(e,o,t,r,n,a,i)=>{if(!fn({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Yo.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,p,d,h]=Jd(e,o).map(E=>st(E)),b=(m+d)/2,f=(p+h)/2;for(let E of s){if(!es(Eo(p,h),E.overlap))continue;let v=E.startSide[0][0]+E.length/2,x=st(v-b);if(E.length>d-m&&Math.abs(x)<=i.x){Math.abs(x)<i.x&&(n.length=0),i.x=Math.abs(x);let R={type:"gap",direction:"center_horizontal",gap:E,offset:x};n.push(R);continue}let[,,w]=E.endBounds,C=m-w,S=st(E.length-C);if(Math.abs(S)<=i.x){Math.abs(S)<i.x&&(n.length=0),i.x=Math.abs(S);let R={type:"gap",direction:"side_right",gap:E,offset:S};n.push(R);continue}let[A,,,]=E.startBounds,M=A-d,N=st(M-E.length);if(Math.abs(N)<=i.x){Math.abs(N)<i.x&&(n.length=0),i.x=Math.abs(N);let R={type:"gap",direction:"side_left",gap:E,offset:N};n.push(R);continue}}for(let E of c){if(!es(Eo(m,d),E.overlap))continue;let v=E.startSide[0][1]+E.length/2,x=st(v-f);if(E.length>h-p&&Math.abs(x)<=i.y){Math.abs(x)<i.y&&(a.length=0),i.y=Math.abs(x);let R={type:"gap",direction:"center_vertical",gap:E,offset:x};a.push(R);continue}let[,w,,]=E.startBounds,C=w-h,S=st(C-E.length);if(Math.abs(S)<=i.y){Math.abs(S)<i.y&&(a.length=0),i.y=Math.abs(S);let R={type:"gap",direction:"side_top",gap:E,offset:S};a.push(R);continue}let[,,,A]=E.endBounds,M=st(p-A),N=E.length-M;if(Math.abs(N)<=i.y){Math.abs(N)<i.y&&(a.length=0),i.y=Math.abs(N);let R={type:"gap",direction:"side_bottom",gap:E,offset:N};a.push(R);continue}}}},b3=(e,o,t,r)=>{let n=g3(e,o,t,r);return wh(n,r).filter(a=>!(a.length===1&&it(a[0]))).flatMap(a=>_c(a,r))},Nl=(e,o,t,r,n,a,i)=>{if(!fn({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Yo.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],p=c[1]-s[1];Math.abs(m)<=i.x&&(Math.abs(m)<i.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:m}),i.x=Math.abs(m)),Math.abs(p)<=i.y&&(Math.abs(p)<i.y&&(a.length=0),a.push({type:"point",points:[s,c],offset:p}),i.y=Math.abs(p))}},x3=(e,o,t,r,n)=>{let a=t.state,i=ae(e,a);if(!fn({app:t,event:r,selectedElements:i})||i.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=st(o.x),o.y=st(o.y);let l=[],s=[],c=ou(a.zoom.value),m={x:c,y:c},p=_c(i,n,{dragOffset:o});Nl(i,p,t,r,l,s,m),u3(i,o,t,r,l,s,m);let d={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let h={x:st(o.x+d.x),y:st(o.y+d.y)};Nl(i,_c(i,n,{dragOffset:h}),t,r,l,s,m),u3(i,h,t,r,l,s,m);let b=ab(l,s),f=RM(i,h,[...l,...s].filter(E=>E.type==="gap"));return{snapOffset:d,snapLines:[...b,...f]}},st=e=>Math.round(e*10**6)/10**6,h3=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},ab=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let a=st(n.points[0][0]);t[a]||(t[a]=[]),t[a].push(...n.points.map(i=>L(st(i[0]),st(i[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let a=st(n.points[0][1]);r[a]||(r[a]=[]),r[a].push(...n.points.map(i=>L(st(i[0]),st(i[1]))))}}return Object.entries(t).map(([n,a])=>({type:"points",points:h3(a.map(i=>L(Number(n),i[1])).sort((i,l)=>i[1]-l[1]))})).concat(Object.entries(r).map(([n,a])=>({type:"points",points:h3(a.map(i=>L(i[0],Number(n))).sort((i,l)=>i[0]-l[0]))})))},DM=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[st(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},RM=(e,o,t)=>{let[r,n,a,i]=Jd(e,o),l=[];for(let s of t){let[c,m,p,d]=s.gap.startBounds,[h,b,f,E]=s.gap.endBounds,v=ts(Eo(n,i),s.gap.overlap),x=ts(Eo(r,a),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(s.gap.startSide[0][0],y),L(r,y)]},{type:"gap",direction:"horizontal",points:[L(a,y),L(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(x){let y=(x[0]+x[1])/2;l.push({type:"gap",direction:"vertical",points:[L(y,s.gap.startSide[0][1]),L(y,n)]},{type:"gap",direction:"vertical",points:[L(y,i),L(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(p,y),L(h,y)]},{type:"gap",direction:"horizontal",points:[L(f,y),L(r,y)]})}break}case"side_left":{if(v){let y=(v[0]+v[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(a,y),L(c,y)]},{type:"gap",direction:"horizontal",points:[L(p,y),L(h,y)]})}break}case"side_top":{if(x){let y=(x[0]+x[1])/2;l.push({type:"gap",direction:"vertical",points:[L(y,i),L(y,m)]},{type:"gap",direction:"vertical",points:[L(y,d),L(y,b)]})}break}case"side_bottom":{if(x){let y=(x[0]+x[1])/2;l.push({type:"gap",direction:"vertical",points:[L(y,d),L(y,b)]},{type:"gap",direction:"vertical",points:[L(y,E),L(y,n)]})}break}}}return DM(l.map(s=>({...s,points:s.points.map(c=>L(st(c[0]),st(c[1])))})))},ib=(e,o,t,r,n,a)=>{if(!fn({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!PM(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[i,l,s,c]=_e(o);a&&(a.includes("e")?s+=n.x:a.includes("w")&&(i+=n.x),a.includes("n")?l+=n.y:a.includes("s")&&(c+=n.y));let m=[];if(a)switch(a){case"e":{m.push(L(s,l),L(s,c));break}case"w":{m.push(L(i,l),L(i,c));break}case"n":{m.push(L(i,l),L(s,l));break}case"s":{m.push(L(i,c),L(s,c));break}case"ne":{m.push(L(s,l));break}case"nw":{m.push(L(i,l));break}case"se":{m.push(L(s,c));break}case"sw":{m.push(L(i,c));break}}let p=ou(t.state.zoom.value),d={x:p,y:p},h=[],b=[];Nl(o,m,t,r,h,b,d);let f={x:h[0]?.offset??0,y:b[0]?.offset??0};d.x=0,d.y=0,h.length=0,b.length=0;let[E,v,x,y]=_e(e).map(S=>st(S)),w=[L(E,v),L(E,y),L(x,v),L(x,y)];Nl(e,w,t,r,h,b,d);let C=ab(h,b);return{snapOffset:f,snapLines:C}},y3=(e,o,t,r,n,a)=>{if(!fn({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let i=[L(r.x+n.x,r.y+n.y)],l=ou(o.state.zoom.value),s={x:l,y:l},c=[],m=[];Nl([e],i,o,t,c,m,s);let p={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let d=_c([e],a,{boundingBoxCorners:!0,omitCenter:!0});Nl([e],d,o,t,c,m,s);let h=ab(c,m);return{snapOffset:p,snapLines:h}},E3=(e,o,t,r,n)=>{if(!fn({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let a=Th(e,[],o.state,n),i=ou(o.state.zoom.value),l={x:i,y:i},s=[],c=[];for(let m of a){let p=_c([m],n);for(let d of p){let h=d[0]-t.x;Math.abs(h)<=Math.abs(l.x)&&(Math.abs(h)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[d,L(d[0],t.y)],direction:"vertical"}),l.x=h);let b=d[1]-t.y;Math.abs(b)<=Math.abs(l.y)&&(Math.abs(b)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[d,L(t.x,d[1])],direction:"horizontal"}),l.y=b)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},v3=e=>e===mt.rectangle||e===mt.ellipse||e===mt.diamond||e===mt.frame||e===mt.magicframe||e===mt.image||e===mt.text;var Pc=class{constructor(o){k(this,"scene");k(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:a,offsetTop:i,scrollX:l,scrollY:s,height:c,width:m})=>{let p=[];for(let d of r.values())Is(d,m,c,{zoom:n,offsetLeft:a,offsetTop:i,scrollX:l,scrollY:s},r)&&p.push(d);return p},t=({elements:r,editingTextElement:n,newElementId:a})=>{let i=new Map;for(let l of r)a!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&i.set(l.id,l);return i};return Ix(({zoom:r,offsetLeft:n,offsetTop:a,scrollX:i,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:p,sceneNonce:d})=>{let h=this.scene.getNonDeletedElements(),b=t({elements:h,editingTextElement:m,newElementId:p}),f=o({elementsMap:b,zoom:r,offsetLeft:n,offsetTop:a,scrollX:i,scrollY:l,height:s,width:c});return{elementsMap:b,visibleElements:f}})})());this.scene=o}destroy(){cE.cancel(),this.getRenderableElements.clear()}};import{jsx as zM}from"react/jsx-runtime";var NM=5,OM=(e,o,t)=>{let[r,n]=At(e,t),{x:a,y:i}=kt({sceneX:r+e.width,sceneY:n},o),l=a-o.offsetLeft+10,s=i-o.offsetTop;return{x:l,y:s}},lb=({children:e,element:o,elementsMap:t})=>{let r=Lr();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:a}=OM(o,r,t);return zM("div",{className:"excalidraw-canvas-buttons",style:{top:`${a}px`,left:`${n}px`,padding:NM},children:e})};import{LaserPointer as BM}from"@excalidraw/laser-pointer";var bn=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;k(this,"currentTrail");k(this,"pastTrails",[]);k(this,"container");k(this,"trailElement");k(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(oh,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(oh,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),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(o,t){this.currentTrail=new BM(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,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())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([a,i])=>{let l=kt({sceneX:a,sceneY:i},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return kx(n,!0)}};var ru=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;k(this,"localTrail");k(this,"collabTrails",new Map);k(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new bn(o,t,{...this.getTrailOptions(),fill:()=>Xu})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),a=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(tr(a),tr(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new bn(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||Qa(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as FM}from"react";import{unstable_batchedUpdates as w3}from"react-dom";var ct=e=>o=>{w3(e,o)},nu=e=>vd(o=>{w3(e,o)}),li=(()=>{let e;try{let t=FM.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var HM=(e,o,t,r,n,a)=>{let{zoom:i}=r,l=180*t/Math.PI,s=e*(i.value-1)/2,c=o*(i.value-1)/2;return e>n&&i.value!==1&&(s=n*(i.value-1)/2),o>a&&i.value!==1&&(c=a*(i.value-1)/2),`translate(${s}px, ${c}px) scale(${i.value}) rotate(${l}deg)`},T3=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:a,excalidrawContainer:i,app:l,autoSelect:s=!0})=>{let c=(z,U)=>{if(!U.style.fontFamily||!U.style.fontSize)return!1;let ee=U.style.fontFamily.replace(/"/g,"");return ya({fontFamily:z.fontFamily})!==ee||`${z.fontSize}px`!==U.style.fontSize},m=l.state.theme,p=()=>{m=l.state.theme;let z=l.state,U=l.scene.getElement(e);if(!U)return;let{textAlign:ee,verticalAlign:Ie}=U,V=l.scene.getNonDeletedElementsMap();if(U&&$(U)){let fe=U.x,Ee=U.y,ke=Do(U,l.scene.getNonDeletedElementsMap()),et=U.width,Bt=U.height,ao=U.width,So=U.height;if(ke&&U.containerId){if(Me(ke)){let vn=X.getBoundTextElementPosition(ke,U,V);fe=vn.x,Ee=vn.y}let GC=c(U,d),Jl;if(GC?Jl=gs(ke.id,ke.height):(Jl=Bx[ke.id],Jl||(Jl=gs(ke.id,ke.height))),ao=xs(ke,U),So=Od(ke,U),!Me(ke)&&Bt>So){let vn=ki(Bt,ke.type);l.scene.mutateElement(ke,{height:vn});return}else if(!Me(ke)&&ke.height>Jl.height&&Bt<So){let vn=ki(Bt,ke.type);l.scene.mutateElement(ke,{height:vn})}else{let{x:vn,y:WC}=Pn(ke,U,V);fe=vn,Ee=WC}}let[er,Hu]=r(fe,Ee);ke?et+=.5:(ao=(z.width-8-er)/z.zoom.value,et=Math.min(et,ao)),Bt*=1.05;let UC=yt(U),S0=(z.height-Hu)/z.zoom.value;Object.assign(d.style,{font:UC,lineHeight:U.lineHeight,width:`${et}px`,height:`${Bt}px`,left:`${er}px`,top:`${Hu}px`,transform:HM(et,Bt,Xx(U,ke),z,ao,S0),textAlign:ee,verticalAlign:Ie,color:z.theme===ne.DARK?gd(U.strokeColor):U.strokeColor,opacity:U.opacity/100,maxHeight:`${S0}px`}),d.scrollTop=0,Qr()&&(d.style.fontFamily=ya(U)),l.scene.mutateElement(U,{x:fe,y:Ee})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let h="pre",b="normal";(it(n)||!n.autoResize)&&(h="pre-wrap",b="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:b,whiteSpace:h,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,p(),o&&(d.onpaste=async z=>{let U=(await mc(z)).findByType(ue.text);if(!U)return;let ee=fs(U.value);if(!ee)return;let Ie=Do(n,l.scene.getNonDeletedElementsMap()),V=yt({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Ie){let fe=xe(Ie,l.scene.getNonDeletedElementsMap()),Ee=Ii(`${d.value}${ee}`,V,xs(Ie,fe)),ke=Kx(Ee,V);d.style.width=`${ke}px`}},d.oninput=()=>{let z=fs(d.value);if(d.value!==z){let U=d.selectionStart;d.value=z,d.selectionStart=U,d.selectionEnd=U}o(d.value)}),d.onkeydown=z=>{if(!z.shiftKey&&nc.keyTest(z))z.preventDefault(),l.actionManager.executeAction(nc),p();else if(!z.shiftKey&&ac.keyTest(z))z.preventDefault(),l.actionManager.executeAction(ac),p();else if(!z.shiftKey&&ic.keyTest(z))z.preventDefault(),l.actionManager.executeAction(ic),p();else if(d1.keyTest(z))l.actionManager.executeAction(d1);else if(m1.keyTest(z))l.actionManager.executeAction(m1);else if(z.key===T.ESCAPE)z.preventDefault(),S=!0,A();else if(jn.keyTest(z))z.preventDefault(),A(),l.actionManager.executeAction(jn);else if(z.key===T.ENTER&&z[T.CTRL_OR_CMD]){if(z.preventDefault(),z.isComposing||z.keyCode===229)return;S=!0,A()}else if(z.key===T.TAB||z[T.CTRL_OR_CMD]&&(z.code===he.BRACKET_LEFT||z.code===he.BRACKET_RIGHT)){if(z.preventDefault(),z.isComposing)return;z.shiftKey||z.code===he.BRACKET_LEFT?y():x(),d.dispatchEvent(new Event("input"))}};let f=4,E=" ".repeat(f),v=new RegExp(`^ {1,${f}}`),x=()=>{let{selectionStart:z,selectionEnd:U}=d,ee=w(),Ie=d.value;ee.forEach(V=>{let fe=Ie.slice(0,V),Ee=Ie.slice(V);Ie=`${fe}${E}${Ee}`}),d.value=Ie,d.selectionStart=z+f,d.selectionEnd=U+f*ee.length},y=()=>{let{selectionStart:z,selectionEnd:U}=d,ee=w(),Ie=[],V=d.value;ee.forEach(fe=>{let Ee=V.slice(fe,fe+f).match(v);if(Ee){let ke=V.slice(0,fe),et=V.slice(fe+Ee[0].length);V=`${ke}${et}`,Ie.push(fe)}}),d.value=V,Ie.length&&(z>Ie[Ie.length-1]?d.selectionStart=Math.max(z-f,Ie[Ie.length-1]):d.selectionStart=z,d.selectionEnd=Math.max(d.selectionStart,U-f*Ie.length))},w=()=>{let{selectionStart:z,selectionEnd:U,value:ee}=d,Ie=ee.slice(0,z).match(/[^\n]*$/)[0].length;return z=z-Ie,ee.slice(z,U).split(`
|
|
21
|
-
`).reduce((fe,Ee,ke,et)=>fe.concat(ke?fe[ke-1]+et[ke-1].length+1:z),[]).reverse()},C=z=>{z.target instanceof HTMLCanvasElement&&(z.preventDefault(),z.stopPropagation())},S=!1,A=()=>{if(q)return;q=!0,M();let z=l.scene.getElement(n.id);if(!z)return;let U=Do(z,l.scene.getNonDeletedElementsMap());if(U){if(d.value.trim()){let ee=bs(U);!ee||ee!==n.id?l.scene.mutateElement(U,{boundElements:(U.boundElements||[]).concat({type:"text",id:n.id})}):Me(U)&&tn(U)}else l.scene.mutateElement(U,{boundElements:U.boundElements?.filter(ee=>!$(ee))});ut(z,U,l.scene)}t({viaKeyboard:S,nextOriginalText:d.value})},M=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,Z&&Z.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",C,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",N),window.removeEventListener("blur",A),window.removeEventListener("beforeunload",A),Y(),O(),Q(),d.remove()},N=z=>{window.removeEventListener("pointerup",N);let U=z?.target,ee=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),Ie=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content"),V=(U instanceof HTMLElement||U instanceof SVGElement)&&(!!U.closest(`.${nt.SHAPE_ACTIONS_MENU}`)||!!U.closest(".compact-shape-actions-island"));setTimeout(()=>{V||ee||Ie||(d.onblur=A,d.focus())})},R=()=>{d.onblur=null,window.addEventListener("pointerup",N),window.addEventListener("blur",A)},P=z=>{let U=z?.target;if(z.button===fr.WHEEL){U instanceof HTMLTextAreaElement&&(z.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(z)),R();return}let ee=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),Ie=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content");(z.target instanceof HTMLElement||z.target instanceof SVGElement)&&(z.target.closest(`.${nt.SHAPE_ACTIONS_MENU}, .${nt.ZOOM_ACTIONS}`)||z.target.closest(".compact-shape-actions-island"))&&!so(z.target)||ee||Ie?R():z.target instanceof HTMLCanvasElement&&!Qr()&&requestAnimationFrame(()=>{A()})},O=l.onChangeEmitter.on(z=>{l.state.theme!==m&&p()}),Y=l.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||d.focus()}),Q=l.onScrollChangeEmitter.on(()=>{p()}),q=!1;s&&d.select(),N();let Z=null;return a&&"ResizeObserver"in window?(Z=new window.ResizeObserver(()=>{p()}),Z.observe(a)):window.addEventListener("resize",p),d.onpointerdown=z=>z.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",A),i?.querySelector(".excalidraw-textEditorContainer").appendChild(d),A};var xn=4,Vo=6,C3="rgba(0,0,0,0.3)",I3=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,a,i,l]=_e(e),s=o/r.zoom.value,c=t/r.zoom.value,m={top:parseInt(ps("sat"))||0,bottom:parseInt(ps("sab"))||0,left:parseInt(ps("sal"))||0,right:parseInt(ps("sar"))||0},p=an().rtl,d=-r.scrollX+m.left,h=-r.scrollY+m.top,b=d+s-m.right,f=h+c-m.bottom,E=Math.min(n,d),v=Math.min(a,h),x=Math.max(i,b),y=Math.max(l,f),w=i-n,C=l-a,S=x-E,A=y-v,M=Math.max(xn*2,m.left+m.right)+Vo*2,N=o*(s/S)-M,R=Math.max(xn*2,m.top+m.bottom)+Vo*2,P=t*(c/A)-R,O=S>w?S*r.zoom.value/(N+M):o/(N+M),Y=A>C?A*r.zoom.value/(P+R):t/(P+R);return{horizontal:d===E&&b===x?null:{x:Math.max(m.left,xn)+Vo+(d-E)/S*o,y:t-Vo-Math.max(xn,m.bottom),width:N,height:Vo,deltaMultiplier:O},vertical:h===v&&f===y?null:{x:p?Math.max(m.left,xn):o-Vo-Math.max(m.right,xn),y:Math.max(m.top,xn)+Vo+(h-v)/A*t,width:Vo,height:P,deltaMultiplier:Y}}},sb=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(i=>i!=null&&i.x<=o&&o<=i.x+i.width&&i.y<=t&&t<=i.y+i.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var k3=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{simplify as UM}from"points-on-curve";var S3=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:a,enclosedElements:i,simplifyDistance:l}=e,s=o;l&&(s=UM(o,l));let c=t.filter(d=>!d.locked);i.clear(),a.clear();let m=o.reduce((d,h)=>[Math.min(d[0],h[0]),Math.min(d[1],h[1]),Math.max(d[2],h[0]),Math.max(d[3],h[1])],[1/0,1/0,-1/0,-1/0]);for(let d of c){let h=Sa(d,r);Ri(m,h)&&!a.has(d.id)&&!i.has(d.id)&&(GM(s,d,n)?i.add(d.id):WM(s,d,r)&&a.add(d.id))}return{selectedElementIds:[...a,...i]}},GM=(e,o,t)=>{let r=D0(e),n=t.get(o.id);return n?n.some(a=>a.some(i=>rd(i,r))):!1},WM=(e,o,t)=>{let r=e.slice(1).map((a,i)=>Ql(e[i],a)).concat([Ql(e[e.length-1],e[0])]),n=xe(o,t);return r.some(a=>Mi(o,t,a,0,!0).length>0||!!n&&Mi({...n,...Pn(o,n,t)},t,a,0,!0).length>0)};var au=class extends bn{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(tr(s),tr(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});k(this,"intersectedElements",new Set);k(this,"enclosedElements",new Set);k(this,"elementsSegments",null);k(this,"canvasTranslate",null);k(this,"keepPreviousSelection",!1);k(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&$(c)){let m=Do(c,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&le(c)){let m=No(this.app.scene.getNonDeletedElementsMap(),c.id);for(let p of m)delete n[p.id]}}let a=bt({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),i=[...Object.keys(a.selectedElementIds)],l=[...Object.keys(a.selectedGroupIds)];return{selectedElementIds:a.selectedElementIds,selectedGroupIds:a.selectedGroupIds,selectedLinearElement:i.length===1&&!l.length&&ge(this.app.scene.getNonDeletedElement(i[0]))?new X(this.app.scene.getNonDeletedElement(i[0]),this.app.scene.getNonDeletedElementsMap()):null}})});k(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});k(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>L(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!at(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=ie(this.app.visibleElements);for(let a of this.app.visibleElements){let i=qd(a,n);this.elementsSegments.set(a.id,i)}}if(t){let{selectedElementIds:n}=S3({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};var iu=class extends bn{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(tr(s),tr(l))},fill:()=>r.state.theme===ne.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});k(this,"elementsToErase",new Set);k(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>L(l[0],l[1]))||[];if(r.length<2)return[];let n=Ql(r[r.length-1],r[r.length-2]),a=this.app.visibleElements.filter(l=>!l.locked),i=ie(a);for(let l of a)if(t&&this.elementsToErase.has(l.id)){if(M3(n,l,i,this.app.state.zoom.value)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=Ke(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.delete(p.id);this.groupsToErase.delete(c)}if(it(l)&&this.elementsToErase.delete(l.containerId),ft(l)){let m=bs(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&M3(n,l,i,this.app.state.zoom.value)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=Ke(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.add(p.id);this.groupsToErase.add(c)}if(ft(l)){let m=bs(l);m&&this.elementsToErase.add(m)}it(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},M3=(e,o,t,r)=>{let n=e[1],a=Ci(o)?15:o.strokeWidth/2,i=[Math.min(e[0][0],e[1][0])-a,Math.min(e[0][1],e[1][1])-a,Math.max(e[0][0],e[1][0])+a,Math.max(e[0][1],e[1][1])+a],l=Sa(o,t),s=[l[0]-a,l[1]-a,l[2]+a,l[3]+a];if(!Ri(i,s))return!1;if(jx(o)&&Bd(n,o,t))return!0;if(Ci(o)){let m=wy(o),p=vy(o,m,t),d=Math.max(2.25,5/r);for(let b of p)if(Ku(b,e)<=d)return!0;let h=P0(...m.map(([b,f])=>L(o.x+b,o.y+f)));return!!rd(e[0],h)}let c=xe(o,t);if(Me(o)||tt(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/r),p=qd(o,t);for(let d of p)if(Ku(d,e)<=m)return!0;return!1}return Mi(o,t,e,0,!0).length>0||!!c&&Mi({...c,...Pn(o,c,t)},t,e,0,!0).length>0};import{jsx as Ko,jsxs as L3}from"react/jsx-runtime";var YM=()=>L3("div",{"data-testid":"brave-measure-text-error",children:[Ko("p",{children:Ko(oo,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Ko("span",{style:{fontWeight:600},children:e})})}),Ko("p",{children:Ko(oo,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Ko("span",{style:{fontWeight:600},children:e})})}),Ko("p",{children:Ko(oo,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Ko("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Ko("p",{children:Ko(oo,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Ko("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>L3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),A3=YM;import $M from"clsx";import jM from"react";import{useLayoutEffect as VM,useRef as _3,useEffect as P3}from"react";import{unstable_batchedUpdates as KM}from"react-dom";import ZM from"clsx";import{jsx as XM}from"react/jsx-runtime";var D3=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:a=0,offsetTop:i=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight,className:c})=>{let m=_3(null);P3(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let h=b=>{if(b.key===T.TAB){let f=us(d),{activeElement:E}=document,v=f.findIndex(x=>x===E);E===d?(b.shiftKey?f[f.length-1]?.focus():f[0].focus(),b.preventDefault(),b.stopImmediatePropagation()):v===0&&b.shiftKey?(f[f.length-1]?.focus(),b.preventDefault(),b.stopImmediatePropagation()):v===f.length-1&&!b.shiftKey&&(f[0]?.focus(),b.preventDefault(),b.stopImmediatePropagation())}};return d.addEventListener("keydown",h),()=>d.removeEventListener("keydown",h)},[]);let p=_3(null);return VM(()=>{if(n&&m.current&&t!=null&&o!=null){let d=m.current,{width:h,height:b}=d.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},h>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+h-a>l?d.style.left=`${l-h-10}px`:d.style.left=`${o}px`,b>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+b-i>s?d.style.top=`${s-b}px`:d.style.top=`${t}px`}},[t,o,n,l,s,a,i]),P3(()=>{if(r){let d=h=>{m.current?.contains(h.target)||KM(()=>r(h))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),XM("div",{className:ZM("popover",c),ref:m,tabIndex:-1,children:e})};import{jsx as Ol,jsxs as qM}from"react/jsx-runtime";var wt="separator",R3=jM.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let a=Lr(),i=Yn(),l=o.reduce((s,c)=>(c&&(c===wt||!c.predicate||c.predicate(i,a,e.app.props,e.app))&&s.push(c),s),[]);return Ol(D3,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:a.offsetLeft,offsetTop:a.offsetTop,viewportWidth:a.width,viewportHeight:a.height,className:"context-menu-popover",children:Ol("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===wt)return!l[c-1]||l[c-1]===wt?null:Ol("hr",{className:"context-menu-item-separator"},c);let m=s.name,p="";return s.label&&(typeof s.label=="function"?p=u(s.label(i,a,e.app)):p=u(s.label)),Ol("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:qM("button",{type:"button",className:$M("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(a)}),children:[Ol("div",{className:"context-menu-item__label",children:p}),Ol("kbd",{className:"context-menu-item__shortcut",children:m?ht(m):""})]})},c)})})})});import{jsx as cb,jsxs as N3}from"react/jsx-runtime";var JM=({height:e,width:o,userToFollow:t,onDisconnect:r})=>cb("div",{className:"follow-mode",style:{width:o,height:e},children:N3("div",{className:"follow-mode__badge",children:[N3("div",{className:"follow-mode__badge__label",children:["Following"," ",cb("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),cb("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:wo})]})}),O3=JM;import gi from"clsx";import C8 from"react";import QM from"clsx";import{useState as eL,useEffect as tL}from"react";import{jsx as db,jsxs as oL}from"react/jsx-runtime";var lu=({delay:e,theme:o})=>{let[t,r]=eL(!!e);return tL(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:oL("div",{className:QM("LoadingMessage",{"LoadingMessage--dark":o===ne.DARK}),children:[db("div",{children:db(Wt,{})}),db("div",{className:"LoadingMessage-text",children:u("labels.loadingScene")})]})};import rL from"clsx";import{jsx as B3,jsxs as aL}from"react/jsx-runtime";var nL="medium",z3={CHECKED:Da,UNCHECKED:zn},F3=e=>aL("label",{className:rL("ToolIcon ToolIcon__lock",`ToolIcon_size_${nL}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[B3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),B3("div",{className:"ToolIcon__icon",children:e.checked?z3.CHECKED:z3.UNCHECKED})]});import{useState as cu,useEffect as H3}from"react";import zl from"clsx";import iL from"clsx";import{jsx as lL}from"react/jsx-runtime";var su=e=>lL(J,{className:iL("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:Us,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:T.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":T.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{Fragment as sL,jsx as Tt,jsxs as du}from"react/jsx-runtime";var mb=[{type:"rectangle",icon:Ra,title:Ae(u("toolBar.rectangle"))},{type:"diamond",icon:Na,title:Ae(u("toolBar.diamond"))},{type:"ellipse",icon:Oa,title:Ae(u("toolBar.ellipse"))}],pb=[{type:"selection",icon:Bn,title:Ae(u("toolBar.selection"))},{type:"lasso",icon:ln,title:Ae(u("toolBar.lasso"))}],ub=[{type:"arrow",icon:Ds,title:Ae(u("toolBar.arrow"))},{type:"line",icon:za,title:Ae(u("toolBar.line"))}],U3=({app:e,onHandToolToggle:o,setAppState:t})=>{let r=e.state.activeTool,[n,a]=cu(!1),[i,l]=cu("rectangle"),[s,c]=cu("arrow");H3(()=>{(r.type==="rectangle"||r.type==="diamond"||r.type==="ellipse")&&l(r.type)},[r.type]),H3(()=>{(r.type==="arrow"||r.type==="line")&&c(r.type)},[r.type]);let m=r.type==="frame",p=r.type==="laser",d=r.type==="embeddable",{TTDDialogTriggerTunnel:h}=Xe(),b=(O,Y)=>{e.state.activeTool.type!==O&&pe("toolbar",O,"ui"),O==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:O})},[f,E]=cu(0),v=36,x=4,y=7,w=y*v+(y-1)*x,C=v+x,S=f>=w+1*C,A=f>=w+2*C,M=f>=w+3*C,R=["text","frame","embeddable","laser","magicframe"].filter(O=>!(S&&O==="text"||A&&O==="image"||M&&O==="frame")).includes(r.type),P=R?r.type==="text"?sr:r.type==="image"?Ba:r.type==="frame"?zo:r.type==="embeddable"?Fa:r.type==="laser"?cn:r.type==="magicframe"?Un:Qi:Qi;return du("div",{className:"mobile-toolbar",ref:O=>{O&&E(O.getBoundingClientRect().width)},children:[Tt(su,{checked:ir(e.state),onChange:o,title:u("toolBar.hand"),isMobile:!0}),Tt(_l,{app:e,options:pb,activeTool:r,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Ae(u("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:O=>{(O==="selection"||O==="lasso")&&(e.setActiveTool({type:O}),t({preferredSelectionTool:{type:O,initialized:!0}}))},displayedOption:pb.find(O=>O.type===e.state.preferredSelectionTool.type)||pb[0]}),Tt(J,{className:zl({active:r.type==="freedraw"}),type:"radio",icon:lr,checked:r.type==="freedraw",name:"editor-current-shape",title:`${Ae(u("toolBar.freedraw"))}`,"aria-label":Ae(u("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>b("freedraw")}),Tt(J,{className:zl({active:r.type==="eraser"}),type:"radio",icon:Rs,checked:r.type==="eraser",name:"editor-current-shape",title:`${Ae(u("toolBar.eraser"))}`,"aria-label":Ae(u("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>b("eraser")}),Tt(_l,{app:e,options:mb,activeTool:r,defaultOption:i,namePrefix:"shapeType",title:Ae(u(i==="rectangle"?"toolBar.rectangle":i==="diamond"?"toolBar.diamond":i==="ellipse"?"toolBar.ellipse":"toolBar.rectangle")),"data-testid":"toolbar-rectangle",onToolChange:O=>{(O==="rectangle"||O==="diamond"||O==="ellipse")&&(l(O),e.setActiveTool({type:O}))},displayedOption:mb.find(O=>O.type===i)||mb[0]}),Tt(_l,{app:e,options:ub,activeTool:r,defaultOption:s,namePrefix:"linearElementType",title:Ae(u(s==="arrow"?"toolBar.arrow":"toolBar.line")),"data-testid":"toolbar-arrow",fillable:!0,onToolChange:O=>{(O==="arrow"||O==="line")&&(c(O),e.setActiveTool({type:O}))},displayedOption:ub.find(O=>O.type===s)||ub[0]}),S&&Tt(J,{className:zl({active:r.type==="text"}),type:"radio",icon:sr,checked:r.type==="text",name:"editor-current-shape",title:`${Ae(u("toolBar.text"))}`,"aria-label":Ae(u("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>b("text")}),A&&Tt(J,{className:zl({active:r.type==="image"}),type:"radio",icon:Ba,checked:r.type==="image",name:"editor-current-shape",title:`${Ae(u("toolBar.image"))}`,"aria-label":Ae(u("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>b("image")}),M&&Tt(J,{className:zl({active:m}),type:"radio",icon:zo,checked:m,name:"editor-current-shape",title:`${Ae(u("toolBar.frame"))}`,"aria-label":Ae(u("toolBar.frame")),"data-testid":"toolbar-frame",onChange:()=>b("frame")}),du(de,{open:n,placement:"top",children:[Tt(de.Trigger,{className:zl("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":R||n}),onToggle:()=>{a(!n),t({openMenu:null,openPopup:null})},title:u("toolBar.extraTools"),style:{width:v,height:v,display:"flex",alignItems:"center",justifyContent:"center"},children:P}),du(de.Content,{onClickOutside:()=>a(!1),onSelect:()=>a(!1),className:"App-toolbar__extra-tools-dropdown",children:[!S&&Tt(de.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:sr,shortcut:T.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:r.type==="text",children:u("toolBar.text")}),!A&&Tt(de.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Ba,"data-testid":"toolbar-image",selected:r.type==="image",children:u("toolBar.image")}),!M&&Tt(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:zo,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:m,children:u("toolBar.frame")}),Tt(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Fa,"data-testid":"toolbar-embeddable",selected:d,children:u("toolBar.embeddable")}),Tt(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:cn,"data-testid":"toolbar-laser",selected:p,shortcut:T.K.toLocaleUpperCase(),children:u("toolBar.laser")}),Tt("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Tt(h.Out,{}),Tt(de.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Wa,"data-testid":"toolbar-embeddable",children:u("toolBar.mermaidToExcalidraw")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Tt(sL,{children:du(de.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:Un,"data-testid":"toolbar-magicframe",children:[u("toolBar.magicframe"),Tt(de.Item.Badge,{children:"AI"})]})})]})]})]})};import cL from"clsx";import{jsx as dL}from"react/jsx-runtime";var mu=({children:e,side:o,className:t})=>dL("div",{className:cL("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import mL from"clsx";import{jsx as G3,jsxs as uL}from"react/jsx-runtime";var pL="medium",pu=e=>e.penDetected?uL("label",{className:mL("ToolIcon ToolIcon__penMode",`ToolIcon_size_${pL}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[G3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),G3("div",{className:"ToolIcon__icon",children:ig})]}):null;import{Fragment as W3,jsx as Ur,jsxs as si}from"react/jsx-runtime";var Y3=({appState:e,elements:o,actionManager:t,setAppState:r,onHandToolToggle:n,renderTopLeftUI:a,renderTopRightUI:i,renderSidebars:l,renderWelcomeScreen:s,UIOptions:c,app:m,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:d,MainMenuTunnel:h,DefaultSidebarTriggerTunnel:b}=Xe(),f=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let v=si("div",{className:"excalidraw-ui-top-right",children:[i?.(!0,e),!e.viewModeEnabled&&si(W3,{children:[Ur(pu,{checked:e.penMode,onChange:()=>p(null),title:u("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Ur(b.Out,{})]}),e.viewModeEnabled&&Ur(Zw,{actionManager:t})]}),x=si("div",{className:"excalidraw-ui-top-left",children:[a?.(!0,e),Ur(h.Out,{})]});return si("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[x,v]})},E=()=>Ur(U3,{app:m,onHandToolToggle:n,setAppState:r});return si(W3,{children:[l(),Ur("div",{className:"App-welcome-screen",children:s&&Ur(d.Out,{})}),!e.viewModeEnabled&&si("div",{className:"App-bottom-bar",style:{marginBottom:Vo+xn},children:[Ur(Gw,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:r}),si(xt,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&!e.scrollConstraints&&Ur("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(v=>({...Aa(o,v)}))},children:u("buttons.scrollBackToContent")})]})]}),Ur(mu,{side:"top",className:"App-top-bar",children:f()})]})};import hL,{useLayoutEffect as gL,useRef as fL,useState as bL}from"react";import{jsx as Dc,jsxs as xL}from"react/jsx-runtime";var V3=e=>{let o=fL(null),[t,r]=bL(null);return gL(()=>{if(!e.spreadsheet)return;let n=$v(e.chartType,e.spreadsheet,0,0);r(n);let a,i=o.current;return(async()=>(a=await Yi({data:{elements:n,appState:{exportBackground:!1,viewBackgroundColor:Lo},files:null},config:{skipInliningFonts:!0}}),a.querySelector(".style-fonts")?.remove(),i.replaceChildren(),i.appendChild(a),e.selected&&i.parentNode.focus()))(),()=>{i.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Dc("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Dc("div",{ref:o})})},K3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=lt(),n=hL.useCallback(()=>{t&&t()},[t]),a=(i,l)=>{r(l),pe("paste","chart",i),e({currentChartType:i,pasteDialog:{shown:!1,data:null}})};return Dc(gt,{size:"small",onCloseRequest:n,title:u("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:xL("div",{className:"container",children:[Dc(V3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:a}),Dc(V3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:a})]})})};import{Fragment as yL,jsx as Z3,jsxs as EL}from"react/jsx-runtime";var Rc=({heading:e,children:o,...t})=>{let{id:r}=qe(),n=Z3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:u(`headings.${e}`)});return Z3("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):EL(yL,{children:[n,o]})})};import*as oa from"@radix-ui/react-popover";import X3 from"clsx";import uu,{useLayoutEffect as vL}from"react";import{Fragment as kL,jsx as Gr,jsxs as hu}from"react/jsx-runtime";var wL=4,TL=8,CL=({shouldWrap:e,children:o,username:t})=>e?Gr(To,{label:t||"Unknown user",children:o}):Gr(kL,{children:o}),hb=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:a})=>{let i={socketId:t,collaborator:o,withName:r,isBeingFollowed:a},l=e.renderAction("goToCollaborator",i);return Gr(CL,{username:o.username,shouldWrap:n,children:l},t)},IL=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],gu=uu.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=vt(),a=new Map;t.forEach((f,E)=>{let v=f.id||E;a.set(v,{...f,socketId:E})});let i=Array.from(a.values()).filter(f=>f.username?.trim()),[l,s]=uu.useState(""),c=i.filter(f=>f.username?.toLowerCase().includes(l)),m=uu.useRef(null);vL(()=>{if(m.current){let f=v=>{let x=Math.max(1,Math.min(8,Math.floor(v/38)));d(x)};if(f(m.current.clientWidth),!nd)return;let E=new ResizeObserver(v=>{for(let x of v){let{width:y}=x.contentRect;f(y)}});return E.observe(m.current),()=>{E.disconnect()}}},[]);let[p,d]=uu.useState(wL),b=i.slice(0,p-1).map(f=>hb({actionManager:n,collaborator:f,socketId:f.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:f.socketId===r}));return o?Gr("div",{className:X3("UserList UserList_mobile",e),children:i.map(f=>hb({actionManager:n,collaborator:f,socketId:f.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:f.socketId===r}))}):Gr("div",{className:"UserList__wrapper",ref:m,children:hu("div",{className:X3("UserList",e),style:{"--max-avatars":p},children:[b,i.length>p-1&&hu(oa.Root,{children:[hu(oa.Trigger,{className:"UserList__more",children:["+",i.length-p+1]}),Gr(oa.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:hu(xt,{padding:2,children:[i.length>=TL&&Gr(rp,{placeholder:u("quickSearch.placeholder"),onChange:s}),Gr(np,{className:"dropdown-menu UserList__collaborators",placeholder:u("userList.empty"),children:c.length>0?[Gr("div",{className:"hint",children:u("userList.hint.text")}),c.map(f=>hb({actionManager:n,collaborator:f,socketId:f.socketId,withName:!0,isBeingFollowed:f.socketId===r}))]:[]}),Gr(oa.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let a=o.collaborators.get(r);if(!a||r!==t.next().value||!at(n,a,IL))return!1}return!0});import gb from"clsx";import{jsx as SL}from"react/jsx-runtime";var $3=e=>SL("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${u("helpDialog.title")} \u2014 ?`,"aria-label":u("helpDialog.title"),children:Ha});import{jsx as yn,jsxs as fb}from"react/jsx-runtime";var j3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:a}=Xe();return fb("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[yn("div",{className:gb("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:yn(go.Col,{gap:2,children:fb(Rc,{heading:"canvasActions",children:[yn(Yw,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&yn(Vw,{renderAction:o.renderAction,className:gb("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),yn(n.Out,{}),yn("div",{className:gb("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:fb("div",{style:{position:"relative"},children:[r&&yn(a.Out,{}),yn($3,{onClick:()=>o.executeAction(qn)})]})}),yn(Kw,{actionManager:o,showExitZenModeBtn:t})]})},q3=j3;j3.displayName="Footer";import NL from"clsx";import{useEffect as lT,useLayoutEffect as sT,useRef as Ib,useState as OL,forwardRef as cT,useImperativeHandle as zL,useCallback as aT}from"react";import LL from"clsx";import{useContext as AL}from"react";import ML from"react";var fu=ML.createContext({});import{jsx as bb,jsxs as J3}from"react/jsx-runtime";var xb=({children:e,className:o})=>{let t=Te(),r=AL(fu),n=!!(t.canFitSidebar&&r.shouldRenderDockButton);return J3("div",{className:LL("sidebar__header",o),"data-testid":"sidebar-header",children:[e,J3("div",{className:"sidebar__header__buttons",children:[n&&bb(To,{label:u("labels.sidebarLock"),children:bb(ro,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":u("labels.sidebarLock"),children:tg})}),bb(ro,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":u("buttons.close"),children:wo})]})]})};xb.displayName="SidebarHeader";import*as eT from"@radix-ui/react-tabs";import{jsx as Q3}from"react/jsx-runtime";var yb=({children:e,tab:o,onSelect:t,...r})=>Q3(eT.Trigger,{value:o,asChild:!0,onSelect:t,children:Q3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});yb.displayName="SidebarTabTrigger";import*as tT from"@radix-ui/react-tabs";import{jsx as _L}from"react/jsx-runtime";var Eb=({children:e,...o})=>_L(tT.List,{className:"sidebar-triggers",...o,children:e});Eb.displayName="SidebarTabTriggers";import PL from"clsx";import{jsx as vb,jsxs as oT}from"react/jsx-runtime";var wb=({name:e,tab:o,icon:t,title:r,children:n,onToggle:a,className:i,style:l})=>{let s=ye(),c=Le();return oT("label",{title:r,className:"sidebar-trigger__label-element",children:[vb("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=m.target.checked;s({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),a?.(p)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),oT("div",{className:PL("sidebar-trigger",i),style:l,children:[t&&vb("div",{children:t}),n&&vb("div",{className:"sidebar-trigger__label",children:n})]})]})};wb.displayName="SidebarTrigger";import*as rT from"@radix-ui/react-tabs";import{jsx as DL}from"react/jsx-runtime";var Tb=({children:e,...o})=>{let t=Le(),r=ye();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return DL(rT.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:a=>r(i=>({...i,openSidebar:{...i.openSidebar,name:n,tab:a}})),...o,children:e})};Tb.displayName="SidebarTabs";import*as nT from"@radix-ui/react-tabs";import{jsx as RL}from"react/jsx-runtime";var Cb=({tab:e,children:o,...t})=>RL(nT.Content,{...t,value:e,"data-testid":e,children:o});Cb.displayName="SidebarTab";import{jsx as iT}from"react/jsx-runtime";import{createElement as BL}from"react";var Nc=we(!1),dT=cT(({name:e,children:o,onDock:t,docked:r,className:n,...a},i)=>{Ht()&&t&&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 l=ye(),s=Sr(Nc);sT(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=Ib({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=h=>t?.(h),c.current=vi(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=Ib(null);zL(i,()=>m.current);let p=Te(),d=aT(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return rl(m,aT(h=>{h.target.closest(".sidebar-trigger")||(!r||!p.canFitSidebar)&&d()},[d,r,p.canFitSidebar])),lT(()=>{let h=b=>{b.key===T.ESCAPE&&(!r||!p.canFitSidebar)&&d()};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[d,r,p.canFitSidebar]),iT(xt,{...a,className:NL(nt.SIDEBAR,{"sidebar--docked":r},n),ref:m,children:iT(fu.Provider,{value:c.current,children:o})})});dT.displayName="SidebarInner";var Zo=Object.assign(cT((e,o)=>{let t=Le(),{onStateChange:r}=e,n=Ib(t.openSidebar);lT(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[a,i]=OL(!1);return sT(()=>(i(!0),()=>i(!1)),[]),a&&t.openSidebar?.name===e.name?BL(dT,{...e,ref:o,key:e.name}):null}),{Header:xb,TabTriggers:Eb,TabTrigger:yb,Tabs:Tb,Tab:Cb,Trigger:wb});Zo.displayName="Sidebar";import{useLayoutEffect as FL,useRef as HL}from"react";import{jsx as UL}from"react/jsx-runtime";var En=(e,o)=>{let t=we(0),r=n=>{let{tunnelsJotai:{useAtom:a}}=Xe(),[,i]=a(t),l=HL({preferHost:!1,counter:0});return FL(()=>{let s=l.current;return i(c=>{let m=c+1;return s.counter=m,m}),()=>{i(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[i]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:UL(o,{...n})};return r.displayName=e,r};var Mb={};td(Mb,{ChangeCanvasBackground:()=>CT,ClearCanvas:()=>wT,CommandPalette:()=>yT,Export:()=>IT,Help:()=>vT,LiveCollaborationTrigger:()=>ST,LoadScene:()=>fT,SaveAsImage:()=>xT,SaveToActiveFile:()=>bT,SearchMenu:()=>ET,Socials:()=>kT,ToggleTheme:()=>TT});import VL from"clsx";var kb=we({active:!1});async function mT({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{Et.set(kb,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import GL from"clsx";import{jsx as pT,jsxs as WL}from"react/jsx-runtime";var bu=function({onChange:e,value:o,choices:t,name:r}){return pT("div",{className:"RadioGroup",children:t.map(n=>WL("div",{className:GL("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[pT("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as YL,jsx as Sb,jsxs as uT}from"react/jsx-runtime";var hT=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:a})=>{let i=Te();return uT(YL,{children:[uT("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Sb("label",{className:"dropdown-menu-item__text",htmlFor:a,children:n}),Sb(bu,{name:a,value:e,onChange:t,choices:r})]}),o&&i.formFactor!=="phone"&&Sb("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};hT.displayName="DropdownMenuItemContentRadio";var gT=hT;import{Fragment as KL,jsx as St,jsxs as MT}from"react/jsx-runtime";var fT=()=>{let{t:e}=dt(),o=vt(),t=Yn();return o.isActionEnabled(Ja)?St(Jt,{icon:Ua,onSelect:async()=>{(!t.length||await mT({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:St(oo,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>St("strong",{children:n}),br:()=>St("br",{})})}))&&o.executeAction(Ja)},"data-testid":"load-button",shortcut:ht("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};fT.displayName="LoadScene";var bT=()=>{let{t:e}=dt(),o=vt();return o.isActionEnabled(jn)?St(Jt,{shortcut:ht("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(jn),icon:hg,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};bT.displayName="SaveToActiveFile";var xT=()=>{let e=ye(),{t:o}=dt();return St(Jt,{icon:zs,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:ht("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};xT.displayName="SaveAsImage";var yT=e=>{let o=ye(),{t}=dt();return St(Jt,{icon:el,"data-testid":"command-palette-button",onSelect:()=>{pe("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:ht("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};yT.displayName="CommandPalette";var ET=e=>{let{t:o}=dt(),t=vt();return St(Jt,{icon:uo,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Pl)},shortcut:ht("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};ET.displayName="SearchMenu";var vT=()=>{let{t:e}=dt(),o=vt();return St(Jt,{"data-testid":"help-menu-item",icon:Ha,onSelect:()=>o.executeAction(qn),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};vT.displayName="Help";var wT=()=>{let{t:e}=dt(),o=Sr(ni);return vt().isActionEnabled(Dr)?St(Jt,{icon:_t,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};wT.displayName="ClearCanvas";var TT=e=>{let{t:o}=dt(),t=Le(),r=vt(),n=ht("toggleTheme");return r.isActionEnabled(Xn)?e?.allowSystemTheme?St(gT,{name:"theme",value:e.theme,onChange:a=>e.onSelect(a),choices:[{value:ne.LIGHT,label:ji,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:ne.DARK,label:$i,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:Af,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):St(Jt,{onSelect:a=>{if(a.preventDefault(),e?.onSelect)e.onSelect(t.theme===ne.DARK?ne.LIGHT:ne.DARK);else return r.executeAction(Xn)},icon:t.theme===ne.DARK?ji:$i,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===ne.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===ne.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};TT.displayName="ToggleTheme";var CT=()=>{let{t:e}=dt(),o=Le(),t=vt(),r=Ar();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:MT("div",{style:{marginTop:"0.5rem"},children:[St("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),St("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};CT.displayName="ChangeCanvasBackground";var IT=()=>{let{t:e}=dt(),o=ye();return St(Jt,{icon:Fn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};IT.displayName="Export";var kT=()=>{let{t:e}=dt();return MT(KL,{children:[St(Ml,{icon:Ns,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),St(Ml,{icon:pg,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),St(Ml,{icon:mg,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};kT.displayName="Socials";var ST=({onSelect:e,isCollaborating:o})=>{let{t}=dt();return St(Jt,{"data-testid":"collab-button",icon:Bs,className:VL({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};ST.displayName="LiveCollaborationTrigger";import{jsx as xu,jsxs as Lb}from"react/jsx-runtime";var ZL=Object.assign(En("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Xe(),r=Te(),n=Le(),a=ye();return xu(t.In,{children:Lb(de,{open:n.openMenu==="canvas",children:[xu(de.Trigger,{onToggle:()=>{a({openMenu:n.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:cg}),Lb(de.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:Ln(o,()=>{a({openMenu:null})}),placement:"bottom",className:r.formFactor==="phone"?"main-menu-dropdown":"",children:[e,r.formFactor==="phone"&&n.collaborators.size>0&&Lb("fieldset",{className:"UserList-Wrapper",children:[xu("legend",{children:u("labels.collaborators")}),xu(gu,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:de.Trigger,Item:de.Item,ItemLink:de.ItemLink,ItemCustom:de.ItemCustom,Group:de.Group,Separator:de.Separator,DefaultItems:Mb}),qt=ZL;import XL from"clsx";import{forwardRef as $L,useState as jL}from"react";import{jsx as yu,jsxs as qL}from"react/jsx-runtime";var Xo=$L(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:a="primary",size:i="medium",fullWidth:l,className:s,status:c,disabled:m},p)=>{let[d,h]=jL(!1),b=async E=>{let v=t?.(E);if(Mn(v)){let x=window.setTimeout(()=>{h(!0)},50);try{await v}catch(y){if(y instanceof Ui)console.warn(y);else throw y}finally{clearTimeout(x),h(!1)}}},f=d?"loading":c;return a=f==="success"?"success":a,yu("button",{className:XL("ExcButton",`ExcButton--color-${a}`,`ExcButton--variant-${n}`,`ExcButton--size-${i}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:b,type:"button","aria-label":r,ref:p,disabled:m||f==="loading"||f==="success",children:qL("div",{className:"ExcButton__contents",children:[f==="loading"?yu(Wt,{className:"ExcButton__statusIcon"}):f==="success"&&yu("div",{className:"ExcButton__statusIcon",children:df}),o&&yu("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Bl,jsxs as eA}from"react/jsx-runtime";var Eu=({title:e,children:o,actionLabel:t,onClick:r})=>eA("div",{className:"OverwriteConfirm__Actions__Action",children:[Bl("h4",{children:e}),Bl("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Bl(Xo,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),JL=()=>{let{t:e}=dt(),o=vt(),t=ye();return Bl(Eu,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(xp,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},QL=()=>{let{t:e}=dt(),o=vt();return Bl(Eu,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ul,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Ab=Object.assign(({children:e})=>Bl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:JL,SaveToDisk:QL});import{jsx as ra,jsxs as LT}from"react/jsx-runtime";var vu=Object.assign(En("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Xe(),[t,r]=te(kb);if(!t.active)return null;let n=()=>{t.onClose(),r(i=>({...i,active:!1}))},a=()=>{t.onConfirm(),r(i=>({...i,active:!1}))};return ra(o.In,{children:ra(gt,{onCloseRequest:n,title:!1,size:916,children:LT("div",{className:"OverwriteConfirm",children:[ra("h3",{children:t.title}),LT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[ra("div",{className:"OverwriteConfirm__Description__icon",children:Gs}),ra("div",{children:t.description}),ra("div",{className:"OverwriteConfirm__Description__spacer"}),ra(Xo,{color:t.color,size:"large",label:t.actionLabel,onClick:a})]}),ra(Ab,{children:e})]})})})}),{Actions:Ab,Action:Eu});import gA from"clsx";import tA from"clsx";import oA from"lodash.debounce";import{Fragment as rA,memo as nA,useEffect as Oc,useMemo as AT,useRef as _b,useState as _T}from"react";import{Fragment as hA,jsx as Nt,jsxs as Wr}from"react/jsx-runtime";var aA=we(""),Pb=we(null),iA=350,NT=()=>{let e=lt(),o=ye(),t=_b(null),[r,n]=te(aA),a=r.trim(),[i,l]=_T(!1),[s,c]=_T({nonce:null,items:[]}),m=_b(null),p=_b(void 0),[d,h]=te(Pb),b=e.scene.getNonDeletedElementsMap();Oc(()=>{i||(a!==m.current||e.scene.getSceneNonce()!==p.current)&&(m.current=null,RT(a,e,(y,w)=>{c({nonce:va(),items:y}),m.current=a,p.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[i,a,b,e,o,h,p]);let f=()=>{s.items.length>0&&h(y=>y===null?0:(y+1)%s.items.length)},E=()=>{s.items.length>0&&h(y=>y===null?0:y-1<0?s.items.length-1:y-1)};Oc(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:d!==null&&y.searchMatches?.matches[d]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===d?{...C,focus:!0}:{...C,focus:!1})}}:null)},[d,o]),Oc(()=>{if(s.items.length>0&&d!==null){let y=s.items[d];if(y){let w=e.state.zoom.value,C=Cr({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:le(y.element)?We.nameFontSize:y.element.fontSize,fontFamily:le(y.element)?It.Assistant:y.element.fontFamily}),S=14,A=C.fontSize,M=A*w<S;if(!Ni([C],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())||M){let N;M?A>=S?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:Mo(S/A,1)}:N={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[d,s,e]),Oc(()=>()=>{h(null),m.current=null,p.current=void 0,o({searchMatches:null}),l(!1)},[o,h]);let v=Gn({goToNextItem:f,goToPreviousItem:E,searchMatches:s});Oc(()=>{let y=w=>{if(w.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){w.preventDefault(),w.stopPropagation(),o({openSidebar:null});return}if(w[T.CTRL_OR_CMD]&&w.key===T.F){if(w.preventDefault(),w.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}w.target instanceof HTMLElement&&w.target.closest(".layer-ui__search")&&v.searchMatches.items.length&&(w.key===T.ENTER&&(w.stopPropagation(),v.goToNextItem()),w.key===T.ARROW_UP?(w.stopPropagation(),v.goToPreviousItem()):w.key===T.ARROW_DOWN&&(w.stopPropagation(),v.goToNextItem()))};return Ve(window,"keydown",y,{capture:!0,passive:!1})},[o,v,e]);let x=`${s.items.length} ${s.items.length===1?u("search.singleResult"):u("search.multipleResults")}`;return Wr("div",{className:"layer-ui__search",children:[Nt("div",{className:"layer-ui__search-header",children:Nt(Qn,{className:nt.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:u("search.placeholder"),icon:uo,onChange:y=>{n(y),l(!0);let w=y.trim();RT(w,e,(C,S)=>{c({nonce:va(),items:C}),h(S),m.current=w,p.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(A=>({id:A.element.id,focus:!1,matchedLines:A.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Wr("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Wr(hA,{children:[d!==null&&d>-1?Wr("div",{children:[d+1," / ",x]}):Nt("div",{children:x}),Wr("div",{className:"result-nav",children:[Nt(ro,{onSelect:()=>{f()},className:"result-nav-btn",children:Ys}),Nt(ro,{onSelect:()=>{E()},className:"result-nav-btn",children:Nf})]})]}),s.items.length===0&&a&&m.current&&Nt("div",{style:{margin:"1rem auto"},children:u("search.noMatch")})]}),Nt(cA,{matches:s,onItemClick:h,focusIndex:d,searchQuery:a})]})},PT=e=>{let o=[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 Nt("div",{tabIndex:-1,className:tA("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Nt("div",{className:"preview-text",children:o.flatMap((t,r)=>Nt(rA,{children:r===2?Nt("b",{children:t}):t},r))})})},lA=e=>{let o=AT(()=>e.matches.items.filter(r=>le(r.element)),[e.matches]),t=AT(()=>e.matches.items.filter(r=>$(r.element)),[e.matches]);return Wr("div",{children:[o.length>0&&Wr("div",{className:"layer-ui__search-result-container",children:[Wr("div",{className:"layer-ui__search-result-title",children:[Nt("div",{className:"title-icon",children:zo}),Nt("div",{children:u("search.frames")})]}),o.map((r,n)=>Nt(PT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&Nt("div",{className:"layer-ui__divider"})]}),t.length>0&&Wr("div",{className:"layer-ui__search-result-container",children:[Wr("div",{className:"layer-ui__search-result-title",children:[Nt("div",{className:"title-icon",children:sr}),Nt("div",{children:u("search.texts")})]}),t.map((r,n)=>Nt(PT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},sA=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,cA=nA(lA,sA),DT=(e,o,t)=>{let a=e.slice(0,o),i=a.split(/\s+/),l=a.endsWith(" "),s=i.length-2-1-(l?0:1),c=i.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let p=e.slice(o+t.length),d=p.split(/\s+/),h=!p.startsWith(" "),b=h?6:5,f=(h?"":" ")+d.slice(0,b).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+f,moreBefore:s>0,moreAfter:d.length>b}},dA=(e,o)=>{let t=e.split(`
|
|
22
|
-
`)
|
|
23
|
-
`)},
|
|
24
|
-
`),a=[],i=0,l=0;for(let p of n){let d=i,h=d+p.length-1;a.push({line:p,startIndex:d,endIndex:h,lineNumber:l}),i=h+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of a){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,h=p.line.slice(0,s-p.startIndex),b=c.slice(0,d);c=c.slice(d);let f=Kt(h,yt(e),e.lineHeight);if(h===""&&(f.width=0),e.textAlign!=="left"&&p.line.length>0){let w=Kt(p.line,yt(e),e.lineHeight),C=e.textAlign==="center"?(e.width-w.width)/2:e.width-w.width;f.width+=C}let{width:E,height:v}=Kt(b,yt(e),e.lineHeight),x=f.width,y=p.lineNumber*f.height;m.push({offsetX:x,offsetY:y,width:E,height:v,showOnCanvas:!0}),s+=d}}return m},pA=(e,o,t,r)=>{let n=e.name??kh(e),a=n.slice(t,t+o.length),i=n.slice(0,t),l=yt({fontSize:We.nameFontSize,fontFamily:It.Assistant}),s=qr(It.Assistant),c=Kt(i,l,s);i===""&&(c.width=0);let m=Kt(a,l,s),p=c.width,d=-c.height-We.strokeWidth,h=m.width;return[{offsetX:p,offsetY:d,width:h,height:m.height,showOnCanvas:p+h<=e.width*r}]},uA=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),RT=oA((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(d=>$(d)),a=r.filter(d=>le(d));n.sort((d,h)=>d.y-h.y),a.sort((d,h)=>d.y-h.y);let i=[],l=new RegExp(uA(e),"gi");for(let d of n){let h=null,b=d.originalText;for(;(h=l.exec(b))!==null;){let f=DT(b,h.index,e),E=mA(d,e,h.index);E.length>0&&i.push({element:d,searchQuery:e,preview:f,index:h.index,matchedLines:E})}}let s=[];for(let d of a){let h=null,b=d.name??kh(d);for(;(h=l.exec(b))!==null;){let f=DT(b,h.index,e),E=pA(d,e,h.index,o.state.zoom.value);E.length>0&&s.push({element:d,searchQuery:e,preview:f,index:h.index,matchedLines:E})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...i],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},iA);import{jsx as ur,jsxs as OT}from"react/jsx-runtime";import{createElement as fA}from"react";var zT=En("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Xe();return ur(o.In,{children:ur(Zo.Trigger,{...e,className:"default-sidebar-trigger",name:Yt.name})})});zT.displayName="DefaultSidebarTrigger";var BT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Xe();return ur(o.In,{children:e})};BT.displayName="DefaultTabTriggers";var wu=Object.assign(En("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let a=Le(),i=ye(),{DefaultSidebarTabTriggersTunnel:l}=Xe(),s=a.openSidebar?.tab===Zr;return fA(Zo,{...n,name:"default",key:"default",className:gA("default-sidebar",o),docked:s||(r??a.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:Ln(t,c=>{i({defaultSidebarDockedPreference:c})})},OT(Zo.Tabs,{children:[ur(Zo.Header,{children:OT(Zo.TabTriggers,{children:[ur(Zo.TabTrigger,{tab:Zr,children:uo}),ur(Zo.TabTrigger,{tab:ls,children:Ps}),ur(l.Out,{})]})}),ur(Zo.Tab,{tab:ls,children:ur(Aw,{})}),ur(Zo.Tab,{tab:Zr,children:ur(NT,{})}),e]}))}),{Trigger:zT,TabTriggers:BT});import{useEffect as JA,useState as QA}from"react";import{useState as VT,useRef as KT,useEffect as ZT,useDeferredValue as TA}from"react";import{useEffect as bA,useRef as FT}from"react";import{jsx as xA}from"react/jsx-runtime";var HT=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=FT(null),a=FT(r);return a.current=r,bA(()=>{if(!a.current)return;let i=n.current;if(i){let l=s=>{s[T.CTRL_OR_CMD]&&s.key===T.ENTER&&(s.preventDefault(),a.current?.())};return i.focus(),i.addEventListener("keydown",l),()=>{i.removeEventListener("keydown",l)}}},[]),xA("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import yA from"clsx";import{jsx as ci,jsxs as UT}from"react/jsx-runtime";var Tu=({error:e,canvasRef:o,loaded:t,hideErrorDetails:r})=>UT("div",{className:`ttd-dialog-output-wrapper ${e?"ttd-dialog-output-wrapper--error":""}`,children:[e&&ci("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:UT("div",{className:"ttd-dialog-output-error-content",children:[ci("div",{className:"ttd-dialog-output-error-icon",children:Gs}),ci("div",{className:"ttd-dialog-output-error-title",children:u("ttd.error")}),ci("div",{className:"ttd-dialog-output-error-message",children:r?u("ttd.errorMermaidSyntax"):e.message})]})},"error"),t?ci("div",{className:yA("ttd-dialog-output-canvas-container",{invisible:!!e}),children:ci("div",{ref:o,className:"ttd-dialog-output-canvas-content"})},"canvas"):ci(Wt,{size:"2rem"})]});import Fl from"clsx";import{Fragment as EA}from"react";import{jsx as Hl,jsxs as Ul}from"react/jsx-runtime";var di=({label:e,children:o,panelActions:t=[],onTextSubmitInProgess:r,renderTopRight:n,renderSubmitShortcut:a,className:i,panelActionJustifyContent:l="flex-start"})=>{let s=c=>{if(c?.variant==="link")return Ul("button",{className:Fl("ttd-dialog-panel-action-link",c.className),onClick:c.action,disabled:c?.disabled||r,type:"button",children:[c.label,c.icon&&Hl("span",{className:"ttd-dialog-panel-action-link__icon",children:c.icon})]});if(c?.variant==="button")return Ul(ro,{className:Fl("ttd-dialog-panel-button",c.className),onSelect:c.action?c.action:()=>{},disabled:c?.disabled||r,children:[Ul("div",{className:Fl({invisible:r}),children:[c?.label,c?.icon&&Hl("span",{children:c.icon})]}),r&&Hl(Wt,{})]});if(c?.variant==="rateLimit")return Hl("div",{className:Fl("ttd-dialog-panel__rate-limit",c.className),children:c.label})};return Ul("div",{className:Fl("ttd-dialog-panel",i),children:[(e||n)&&Ul("div",{className:"ttd-dialog-panel__header",children:[typeof e=="string"?Hl("label",{children:e}):e,n?.()]}),o,Ul("div",{className:Fl("ttd-dialog-panel-button-container",{invisible:!t.length}),style:{justifyContent:l},children:[t.filter(Boolean).map(c=>Hl(EA,{children:s(c)},c.label)),!r&&a?.()]})]})};import{jsx as vA}from"react/jsx-runtime";var GT=({children:e})=>vA("div",{className:"ttd-dialog-panels",children:e});import{jsx as WT,jsxs as wA}from"react/jsx-runtime";var YT=()=>wA("div",{className:"ttd-dialog-submit-shortcut",children:[WT("div",{className:"ttd-dialog-submit-shortcut__key",children:B("CtrlOrCmd")}),WT("div",{className:"ttd-dialog-submit-shortcut__key",children:B("Enter")})]});var Db=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Gl=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n,theme:a})=>{let i=e.current,l=i?.parentElement;if(!i||!l)return{success:!1};if(!t)return Db({canvasRef:e,setError:r}),{success:!1};let s;try{let c=await o.api;try{try{s=await c.parseMermaidToExcalidraw(t)}catch{s=await c.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}}catch(h){return{success:!1,error:h}}let{elements:m,files:p}=s;r(null),n.current={elements:Hi(m,{regenerateIds:!0}),files:p};let d=await On({data:{elements:n.current.elements,files:n.current.files},config:{theme:a,padding:Cn,maxWidthOrHeight:Math.max(l.offsetWidth,l.offsetHeight)*window.devicePixelRatio}});return l.style.background="var(--default-bg-color)",i.replaceChildren(d),{success:!0}}catch(c){return l.style.background="var(--default-bg-color)",t&&r(c),{success:!1,error:c}}},Wl=e=>{Wo.set(In.MERMAID_TO_EXCALIDRAW,e)},zc=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:a}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:a,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&Wl(t))};import{Fragment as kA,jsx as Yr,jsxs as $T}from"react/jsx-runtime";var CA=`flowchart TD
|
|
23
|
+
`)}`;this.set(`url(${l}) 5 20, auto`)}else["image","custom"].includes(t.type)?t.type!=="image"&&this.set(Fe.AUTO):this.set(Fe.CROSSHAIR);this.toolCursorMemo={canvas:o,type:t.type,bucketFillColor:n,theme:r}}});C(this,"clear",()=>{this.set("")});C(this,"applyEraser",()=>{let o=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==o){let r=o===J.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=o,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let n=this.eraserCanvasCache.getContext("2d");n.lineWidth=1,n.beginPath(),n.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),n.fillStyle=r?"#000":"#fff",n.fill(),n.strokeStyle=r?"#fff":"#000",n.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(pe.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};var Nh=class{constructor(t){this.app=t;C(this,"trail");this.trail=new Rr(this.app,{...this.getTrailOptions(),fill:()=>t.state.theme===J.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>qe(Gr("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(t,o){this.trail.startPath(t,o)}addPointToPath(t,o){this.trail.addPointToPath(t,o)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let t=this.trail.getCurrentTrail();return t?t.originalPoints.map(([o,r])=>_(o,r)):[]}start(t){this.trail.start(t)}stop(){this.trail.stop()}};var Oh=class{constructor(t){this.app=t;C(this,"trail");C(this,"gestureInProgress",!1);C(this,"stop",()=>{this.trail.stop()});C(this,"hasPendingGesture",()=>this.gestureInProgress);C(this,"handlePointerDown",t=>{this.gestureInProgress&&this.app.actionManager.executeAction(Gt),this.gestureInProgress=!0,this.trail.startPath(t.lastCoords.x,t.lastCoords.y)});C(this,"handlePointerMove",t=>Xw(this.app,t));C(this,"bindRecognizedArrow",t=>{let{app:o}=this,r=o.scene.getNonDeletedElementsMap(),n=o.scene.getNonDeletedElements(),i=ui(o.state.zoom),l=["start","end"].map(d=>{let m=Z.getPointAtIndexGlobalCoordinates(t,d==="start"?0:-1,r);return{startOrEnd:d,globalPoint:m,target:Qo(m,n,r,i)}}),a=!!l[0].target&&l[0].target===l[1].target,s=o.state.isMidpointSnappingEnabled&&!o.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of l)p&&yc(t,p,a?"inside":"orbit",d,o.scene,m,o.state.isBindingEnabled,s);if(a)return;let c=new Map;for(let{startOrEnd:d,target:m}of l){if(!m)continue;let p=Av(t,d==="start"?"startBinding":"endBinding",d==="start"?t.startBinding:t.endBinding,m,r);p&&c.set(d==="start"?0:t.points.length-1,{point:p})}c.size&&Z.movePoints(t,o.scene,c)});C(this,"maybeUpgradeLineToArrow",t=>{let{app:o}=this,r=o.scene.getNonDeletedElementsMap(),n=o.scene.getNonDeletedElements(),i=ui(o.state.zoom),[l,a]=[0,-1].map(s=>Qo(Z.getPointAtIndexGlobalCoordinates(t,s,r),n,r,i));return!l&&!a||l===a?null:bi({type:"arrow",x:t.x,y:t.y,width:t.width,height:t.height,startArrowhead:null,endArrowhead:o.state.currentItemEndArrowhead,points:t.points,groupIds:t.groupIds,frameId:t.frameId,locked:!1,angle:t.angle,strokeColor:t.strokeColor,backgroundColor:t.backgroundColor,fillStyle:t.fillStyle,roughness:t.roughness,opacity:t.opacity,strokeStyle:t.strokeStyle,strokeWidth:t.strokeWidth})});C(this,"finalize",()=>{let{app:t}=this,o=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),o.length>=3){let r=t.state.newElement||Kw(o,t.state,t.scene.getNonDeletedElementsMap(),t.state.newElement,t.scene.getNonDeletedFramesLikes());if(r){let n={...r,seed:En(),opacity:t.state.currentItemOpacity};t.state.isBindingEnabled&&at(n)&&(n=this.maybeUpgradeLineToArrow(n)??n),t.insertNewElement(n),t.state.isBindingEnabled&&zt(n)&&this.bindRecognizedArrow(n)}}this.trail.clearTrails()});this.trail=new Nh(t)}};var Fh=class e{constructor(t){this.app=t;C(this,"creator",new Iw);C(this,"navigator",new Cw);C(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});C(this,"handleKeyEvent",t=>{let o=this.resolveKeyboardEventToOperation(t);switch(o.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return t.preventDefault(),o.pending.length&&this.app.revealIfHidden(o.pending),!0;case"navigating":{t.preventDefault();let r=o.nodeId&&this.app.scene.getNonDeletedElementsMap().get(o.nodeId);return r&&this.selectAndReveal(r),!0}case"committed":{o.nodes.length&&this.app.insertNewElements(o.nodes);let r=o.nodes[0];return r&&this.selectAndReveal(r),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(t){let{creator:o,navigator:r,app:n}=this;if(t.type==="keydown"){if(t.key===I.ESCAPE&&o.isCreatingChart)return o.clear(),{type:"canceled"};if(!ni(t.key))return{type:"none"};if(t[I.CTRL_OR_CMD]&&!t.shiftKey){let l=ae(n.scene.getNonDeletedElementsMap(),n.state);return l.length===1&&Pm(l[0])&&o.createNodes(l[0],n.state,e.getLinkDirectionFromKey(t.key),n.scene),{type:"creating",pending:o.pendingNodes??[]}}if(t.altKey){let l=n.scene.getNonDeletedElementsMap(),a=ae(l,n.state);if(a.length===1)return{type:"navigating",nodeId:r.exploreByDirection(a[0],l,e.getLinkDirectionFromKey(t.key))}}return{type:"none"}}let i=!t.altKey&&r.isExploring;if(i&&r.clear(),!t[I.CTRL_OR_CMD]&&o.isCreatingChart){let l=o.pendingNodes??[];return o.clear(),{type:"committed",nodes:l}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(t){this.app.setState(o=>({selectedElementIds:Be({[t.id]:!0},o)})),this.app.revealIfHidden([t])}captureUpdate(){this.app.syncActionResult({captureUpdate:N.IMMEDIATELY})}static getLinkDirectionFromKey(t){switch(t){case I.ARROW_UP:return"up";case I.ARROW_DOWN:return"down";case I.ARROW_RIGHT:return"right";case I.ARROW_LEFT:return"left";default:return"right"}}};var Bh="animateScrollToContent",ks="animateScrollConstraintsSnapBack",E3=500,RD=250,ND=200,xx=302,y3={full:216,compact:64},OD=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&(t.width==null||typeof t.width=="number")&&(t.height==null||typeof t.height=="number")},FD=(e,t)=>{let o=t.get(e);return o?[o]:He(t,e)},v3=(e,t,o)=>{if(typeof e=="string"){let l=ga(e),a=l?"link":"element",s=l?ww(e):e,c=s?FD(s,t):[];return c.length?{bounds:we(c,t),type:a}:{bounds:null,type:a}}if(KE(e))return{bounds:e,type:"area"};if(OD(e)&&!sl(e)){let l=e.width??o.width,a=e.height??o.height;return{bounds:[e.x,e.y,e.x+l,e.y+a],type:"area"}}let r=Array.isArray(e)?e:[e],n=r.reduce((l,a)=>{if(a&&!a.isDeleted){let s=t.get(a.id);s&&l.push(s)}return l},[]),i=!n.length;return(n.length!==r.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:we(n,t),type:"element"}},BD=e=>e===!1?0:e===!0||e==null?Bf:Math.max(e,0),zD=(e,t,o="scale-down",r)=>{let{appState:n}=ba({bounds:t,appState:e,fit:o,canvasOffsets:r,steppedZoom:!1});return{scrollX:n.scrollX,scrollY:n.scrollY,zoom:n.zoom}},w3=(e,t,{fit:o,offsets:r,lock:n})=>{let i=zD(e,t,o,r);if(!n?.scroll&&!n?.zoom)return{...i,scrollConstraints:null};let[l,a,s,c]=t,d={x:l,y:a,width:s-l,height:c-a,lockScroll:!!n.scroll,lockZoom:!!n.zoom,zoom:i.zoom.value,overscroll:BD(n.overscroll),offsets:r};return{...Zr({...e,...i,scrollConstraints:d}),scrollConstraints:d}},HD=({from:e,target:t,factor:o})=>{if(o>=1)return{...t};let r=e.zoom.value*Math.pow(t.zoom.value/e.zoom.value,o),n=t.zoom.value===e.zoom.value?o:(r-e.zoom.value)/(t.zoom.value-e.zoom.value);return{scrollX:((1-n)*e.scrollX*e.zoom.value+n*t.scrollX*t.zoom.value)/r,scrollY:((1-n)*e.scrollY*e.zoom.value+n*t.scrollY*t.zoom.value)/r,zoom:{value:r}}},UD=e=>e===!1?null:e===!0||e==null?E3:e.duration??E3,GD=(e,t,o,r,n)=>{Rt.start(Bh,({deltaTime:i,state:l})=>{let a=(l?.elapsed??0)+i,s=Math.min(a/o,1),c=jo(qe(s,0,1));return s<1?(r({...HD({from:e,target:t,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:a}):(n(),null)})},WD=(e,t,o=RD)=>{let r=Zr(e);if(r.scrollX===e.scrollX&&r.scrollY===e.scrollY&&r.zoom.value===e.zoom.value||Rt.running(Bh))return;let n=(e.scrollX-r.scrollX)*e.zoom.value,i=(e.scrollY-r.scrollY)*e.zoom.value;Rt.start(ks,({deltaTime:l,state:a})=>{let s=(a?.elapsed??0)+l,c=Math.min(s/o,1),d=1-jo(qe(c,0,1));return t(m=>{if(!m.scrollConstraints)return null;let p=Zr(m),u=p.zoom.value;return{scrollX:p.scrollX+n*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:s}:null})},zh=class{constructor(t,o){this.app=t;this.dependencies=o;C(this,"lastPosition",{x:0,y:0});C(this,"activeTransition",null);C(this,"uiLastMeasured",new Map);C(this,"invalidateUIOffset",t=>{this.uiLastMeasured.delete(t)});C(this,"resolveOffsets",t=>{if(!t)return t;let{ui:o,...r}=t;if(!o)return r;let n=this.getOffsets(o===!0?void 0:o);return{top:r.top??n.top,right:r.right??n.right,bottom:r.bottom??n.bottom,left:r.left??n.left}});C(this,"getOffsets",t=>{let o=this.dependencies.getContainer(),r=o?.getBoundingClientRect(),n=Qr().rtl,i={top:0,right:0,bottom:0,left:0},l=new Set;if(o&&r)for(let u of o.querySelectorAll("[data-viewport-ui]")){let b=u.getBoundingClientRect(),f={top:b.top-r.top,right:b.right-r.left,bottom:b.bottom-r.top,left:b.left-r.left,width:b.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,f.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-f.top);break;case"side":{let[x,v]=f.left+f.width/2<this.app.state.width/2?["left",f.right]:["right",this.app.state.width-f.left];i[x]=Math.max(i[x],v);let y=u.dataset.viewportUiName;y&&(l.add(y),v>0&&this.uiLastMeasured.set(y,{side:x,offset:v}));break}}}if(t?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(b,f)=>{if(l.has(b))return;let{side:x,offset:v}=this.uiLastMeasured.get(b)??f;i[x]=Math.max(i[x],v)};t.reserve.stylesPanel&&u("stylesPanel",{side:n?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?y3.compact:y3.full}),t.reserve.sidebar&&u("sidebar",{side:n?"left":"right",offset:xx})}let a=t?.padding??24,s=t?.paddingTop??a,c=(n?t?.paddingLeft:t?.paddingRight)??a,d=t?.paddingBottom??a,m=(n?t?.paddingRight:t?.paddingLeft)??a,p={top:i.top+s,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:t?.top??p.top,right:(n?t?.left:t?.right)??p.right,bottom:t?.bottom??p.bottom,left:(n?t?.right:t?.left)??p.left}});C(this,"resolveInitialViewport",(t,o,r)=>{let{bounds:n}=v3(t.target,o,r);return n?w3(r,n,{...t,offsets:this.resolveOffsets(t.offsets)}):null});C(this,"setViewport",t=>{if(t===null){this.cancelTransition(),Rt.cancel(ks),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:o,fit:r,lock:n,animation:i}=t,l=this.resolveOffsets(t.offsets),{bounds:a,type:s}=v3(o,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!a){s==="link"&&this.app.setState({toast:{message:h("elementLink.notFound"),duration:3e3,closable:!0}});return}let c=w3(this.app.state,a,{fit:r,offsets:l,lock:n}),d=UD(i),m={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),Rt.cancel(ks),this.snapBackDebounced.cancel(),d===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let p={target:c};this.activeTransition=p,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),GD(m,c,d,u=>{this.activeTransition===p&&this.app.setState(u)},()=>{this.activeTransition===p&&(this.activeTransition=null,this.app.setState({...p.target,shouldCacheIgnoreZoom:!1}))})});C(this,"translate",(t,o)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),o?.preserveScrollConstraintsSnapBack||Rt.cancel(ks),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let r=this.app.state.zoom.value;return this.app.setState(t),this.app.setState(n=>{if(!n.scrollConstraints)return null;let l=!o?.zoomPreConstrained&&n.zoom.value!==r?0:n.scrollConstraints.overscroll;return l>0&&this.snapBackDebounced(),Zr(n,l)}),!0});C(this,"constrain",(t=0)=>{this.app.setState(o=>o.scrollConstraints?Zr(o,t):null)});C(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});C(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||WD(this.app.state,t=>this.app.setState(o=>t(o)))});C(this,"snapBackDebounced",xn(this.snapBack,ND));C(this,"cancelTransition",()=>{this.activeTransition=null,Rt.cancel(Bh)});C(this,"destroy",()=>{this.cancelTransition(),Rt.cancel(ks),this.snapBackDebounced.cancel()})}get isAnimating(){return Rt.running(Bh)||Rt.running(ks)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import{jsx as ur,jsxs as T3}from"react/jsx-runtime";var VD=()=>T3("div",{"data-testid":"brave-measure-text-error",children:[ur("p",{children:ur(yo,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>ur("span",{style:{fontWeight:600},children:e})})}),ur("p",{children:ur(yo,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>ur("span",{style:{fontWeight:600},children:e})})}),ur("p",{children:ur(yo,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>ur("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),ur("p",{children:ur(yo,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>ur("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>T3("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),C3=VD;import ZD from"clsx";import jD from"react";import{useLayoutEffect as YD,useRef as I3,useEffect as S3}from"react";import{unstable_batchedUpdates as KD}from"react-dom";import XD from"clsx";import{jsx as $D}from"react/jsx-runtime";var Vi=10,k3=({children:e,left:t,top:o,onCloseRequest:r,fitInViewport:n=!1,viewportWidth:i=window.innerWidth,viewportHeight:l=window.innerHeight,className:a})=>{let s=I3(null);S3(()=>{let d=s.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===I.TAB){let u=ac(d),{activeElement:b}=document,f=u.findIndex(x=>x===b);b===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):f===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):f===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=I3(null);return YD(()=>{if(n&&s.current&&o!=null&&t!=null){let d=s.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===o&&c.current?.left===t)return;c.current={top:o,left:t};let u=Math.max(0,i-Vi*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${Vi}px`,d.style.overflowX="scroll"):d.style.left=`${qe(t,Vi,i-Vi-m)}px`;let b=Math.max(0,l-Vi*2);p>=b?(d.style.height=`${b}px`,d.style.top=`${Vi}px`,d.style.overflowY="scroll"):d.style.top=`${qe(o,Vi,l-Vi-p)}px`}},[o,t,n,i,l]),S3(()=>{if(r){let d=m=>{s.current?.contains(m.target)||KD(()=>r(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),$D("div",{className:XD("popover",a),ref:s,tabIndex:-1,children:e})};import{jsx as Ms,jsxs as qD}from"react/jsx-runtime";var Nt="separator",M3=jD.memo(({actionManager:e,items:t,top:o,left:r,onClose:n})=>{let i=tn(),l=ki(),a=t.reduce((s,c)=>(c&&(c===Nt||!c.predicate||c.predicate(l,i,e.app.props,e.app))&&s.push(c),s),[]);return Ms(k3,{onCloseRequest:()=>{n()},top:o,left:r,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Ms("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:a.map((s,c)=>{if(s===Nt)return!a[c-1]||a[c-1]===Nt?null:Ms("hr",{className:"context-menu-item-separator"},c);let d=s.name,m="";return s.label&&(typeof s.label=="function"?m=h(s.label(l,i,e.app)):m=h(s.label)),Ms("li",{"data-testid":d,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:qD("button",{type:"button",className:ZD("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ms("div",{className:"context-menu-item__label",children:m}),Ms("kbd",{className:"context-menu-item__shortcut",children:d?rt(d):""})]})},c)})})})});import{useId as JD}from"react";import QD from"clsx";import{Fragment as e8,jsx as Dd,jsxs as A3}from"react/jsx-runtime";var Hh=({border:e,style:t})=>Dd("div",{className:"viewport-status-frame__border",style:{borderColor:e,...t}}),Uh=({label:e,border:t})=>{let o=JD(),r=A3(e8,{children:[e.icon&&Dd("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return A3("div",{className:QD("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||t||"var(--color-primary)",color:e.color},children:[e.onClick&&Dd("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":o,onClick:e.onClick}),Dd("div",{className:"viewport-status-frame__badge-label",id:e.onClick?o:void 0,children:r}),e.onClose&&Dd("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":h("buttons.close"),onClick:e.onClose,children:Go})]})};import Ws from"clsx";import WN from"react";import{createIsolation as t8}from"jotai-scope";import Ex from"react";import pn from"tunnel-rat";var yx=Ex.createContext(null),nt=()=>Ex.useContext(yx),o8=t8(),L3=()=>Ex.useMemo(()=>({MainMenuTunnel:pn(),WelcomeScreenMenuHintTunnel:pn(),WelcomeScreenToolbarHintTunnel:pn(),WelcomeScreenHelpHintTunnel:pn(),WelcomeScreenCenterTunnel:pn(),FooterCenterTunnel:pn(),DefaultSidebarTriggerTunnel:pn(),DefaultSidebarTabTriggersTunnel:pn(),OverwriteConfirmDialogTunnel:pn(),TTDDialogTriggerTunnel:pn(),tunnelsJotai:o8}),[]);import r8 from"clsx";import{useState as n8,useEffect as i8}from"react";import{jsx as vx,jsxs as a8}from"react/jsx-runtime";var Gh=({delay:e,theme:t})=>{let[o,r]=n8(!!e);return i8(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),o?null:a8("div",{className:r8("LoadingMessage",{"LoadingMessage--dark":t===J.DARK}),children:[vx("div",{children:vx(Pt,{})}),vx("div",{className:"LoadingMessage-text",children:h("labels.loadingScene")})]})};import{useState as Wh,useEffect as _3}from"react";import l8 from"clsx";import{Fragment as s8,jsx as Ct,jsxs as wx}from"react/jsx-runtime";var P3=({app:e,setAppState:t})=>{let o=e.state.activeTool,[r,n]=Wh(!1),[i,l]=Wh("rectangle"),[a,s]=Wh("arrow");_3(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&l(o.type)},[o.type]),_3(()=>{(o.type==="arrow"||o.type==="line")&&s(o.type)},[o.type]);let c=o.type==="frame",d=o.type==="autoshape",m=o.type==="laser",p=o.type==="embeddable",u=o.type==="bucketfill",{TTDDialogTriggerTunnel:b}=nt(),f=["rectangle","diamond","ellipse"].map(F=>({type:F,icon:vt[F].icon,title:Vt(h(`toolBar.${F}`)),fillable:vt[F].fillable})),x=["arrow","line"].map(F=>({type:F,icon:vt[F].icon,title:Vt(h(`toolBar.${F}`)),fillable:vt[F].fillable})),[v,y]=Wh(0),E=36,w=4,T=7,S=T*E+(T-1)*w,A=E+w,M=v>=S+1*A,O=v>=S+2*A,P=v>=S+3*A,D=["text","frame","embeddable","laser","bucketfill","magicframe"].filter(F=>!(M&&F==="text"||P&&F==="frame")).includes(o.type),U=D?o.type==="text"?en:o.type==="image"?Ml:o.type==="frame"?Ar:o.type==="embeddable"?Ln:o.type==="laser"?Lr:o.type==="bucketfill"?fo:o.type==="magicframe"?Ii:yi:yi,K={app:e,activeTool:o};return wx("div",{className:"mobile-toolbar",ref:F=>{F&&y(F.getBoundingClientRect().width)},children:[Ct(yu,{...K,hideKeyBinding:!0}),Ct(Cu,{...K,setAppState:t}),Ct(Iu,{...K}),Ct(Tu,{...K,hideShortcut:!0}),Ct(Wl,{app:e,options:f,activeTool:o,defaultOption:i,"data-testid":"toolbar-rectangle",onToolChange:F=>{(F==="rectangle"||F==="diamond"||F==="ellipse")&&(l(F),e.setActiveTool({type:F}))},displayedOption:f.find(F=>F.type===i)||f[0]}),Ct(Wl,{app:e,options:x,activeTool:o,defaultOption:a,"data-testid":"toolbar-arrow",onToolChange:F=>{(F==="arrow"||F==="line")&&(s(F),e.setActiveTool({type:F}))},displayedOption:x.find(F=>F.type===a)||x[0]}),M&&Ct(vu,{...K,hideShortcut:!0}),O&&Ct(wu,{...K,hideShortcut:!0}),P&&Ct(XT,{...K,hideShortcut:!0}),wx(ue,{open:r,children:[Ct(ue.Trigger,{className:l8("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":D||r}),onToggle:()=>{n(!r),t({openMenu:null,openPopup:null})},title:h("toolBar.extraTools"),style:{width:E,height:E,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),wx(ue.Content,{onClickOutside:()=>n(!1),onSelect:()=>n(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[!M&&Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:en,shortcut:I.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Dt(e,"text"),children:h("toolBar.text")}),!O&&Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Ml,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Dt(e,"image"),children:h("toolBar.image")}),!P&&Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Ar,shortcut:I.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Dt(e,"frame"),children:h("toolBar.frame")}),Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Ln,"data-testid":"toolbar-embeddable",selected:p,disabled:Dt(e,"embeddable"),children:h("toolBar.embeddable")}),Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Ci,shortcut:dd("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Dt(e,"autoshape"),children:h("toolBar.autoshape")}),Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Lr,"data-testid":"toolbar-laser",selected:m,shortcut:I.K.toLocaleUpperCase(),disabled:Dt(e,"laser"),children:h("toolBar.laser")}),Ct(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:fo,"data-testid":"toolbar-bucketfill",selected:u,shortcut:I.B.toLocaleUpperCase(),disabled:Dt(e,"bucketfill"),children:h("toolBar.bucketfill")}),Ct("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Ct(b.Out,{}),Ct(ue.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Ia,"data-testid":"toolbar-embeddable",children:h("toolBar.mermaidToExcalidraw")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Ct(s8,{children:Ct(ue.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:Ii,"data-testid":"toolbar-magicframe",badge:Ct(ue.Item.Badge,{children:"AI"}),disabled:Dt(e,"magicframe"),children:h("toolBar.magicframe")})})]})]})]})};import c8 from"clsx";import{jsx as d8}from"react/jsx-runtime";var Vh=({children:e,side:t,className:o})=>d8("div",{className:c8("FixedSideContainer",`FixedSideContainer_side_${t}`,o),children:e});import m8 from"clsx";import{jsx as p8}from"react/jsx-runtime";var As=e=>e.penDetected?p8(Q,{className:m8("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:ob,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as D3,jsx as wo,jsxs as Ls}from"react/jsx-runtime";var R3=({appState:e,elements:t,actionManager:o,setAppState:r,renderTopLeftUI:n,renderTopRightUI:i,renderSidebars:l,renderWelcomeScreen:a,defaultUIEnabled:s,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:b}=nt(),f=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let S=Ls("div",{className:"excalidraw-ui-top-right",children:[i?.(!0,e),!e.viewModeEnabled&&Ls(D3,{children:[s&&wo(As,{checked:e.penMode,onChange:()=>m(null),title:h("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wo(b.Out,{})]}),s&&e.viewModeEnabled&&d.isInteractionEnabled()&&wo(cS,{actionManager:o})]}),A=Ls("div",{className:"excalidraw-ui-top-left",children:[n?.(!0,e),wo(u.Out,{})]});return Ls("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,S]})},x=()=>wo(P3,{app:d,setAppState:r}),v=c&&e.scrolledOutside,y=s&&!e.viewModeEnabled,E=v&&!e.openMenu&&!e.openSidebar?wo("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(S=>({...El(t,S)}))},children:h("buttons.scrollBackToContent")}):null,w=d.props.viewportStatusFrame?.label,T=w?wo(Uh,{label:w,border:d.props.viewportStatusFrame?.border}):null;return Ls(D3,{children:[l(),wo("div",{className:"App-welcome-screen",children:a&&wo(p.Out,{})}),y&&Ls("div",{className:"App-bottom-bar",style:{marginBottom:pr+Wn},"data-viewport-ui":"bottom",children:[E&&wo("div",{className:"floating-status-stack",children:E}),wo(iS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:o.renderAction,app:d,setAppState:r}),wo(yt,{className:"App-toolbar",children:e.openDialog?.name!=="elementLinkSelector"&&x()})]}),!y&&E&&wo("div",{className:"floating-status-stack",children:E}),T&&wo("div",{className:"viewport-status-frame__badge-row",children:T}),wo(Vh,{side:"top",className:"App-top-bar",children:f()})]})};import N3,{useLayoutEffect as O3,useRef as F3,useState as B3}from"react";import{jsx as Vn,jsxs as Yh}from"react/jsx-runtime";var u8=e=>{switch(e){case"bar":return h("labels.chartType_bar");case"line":return h("labels.chartType_line");case"radar":return h("labels.chartType_radar");default:return e}},h8=e=>{let t=F3(null),[o,r]=B3(null),{theme:n}=be();O3(()=>{if(!e.spreadsheet){r(null);return}let l=fx(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!l){r(null),t.current?.replaceChildren();return}r(l);let a,s=t.current;return(async()=>(a=await xa({data:{elements:l,appState:{exportBackground:!1,viewBackgroundColor:Ho,exportWithDarkMode:n==="dark"},files:null},config:{skipInliningFonts:!0}}),a.querySelector(".style-fonts")?.remove(),s.replaceChildren(),s.appendChild(a)))(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,n]);let i=u8(e.chartType);return Yh("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{o&&e.onClick(e.chartType,o)},children:[Vn("div",{className:"ChartPreview__canvas",ref:t}),Vn("div",{className:"ChartPreview__label",children:i})]})},g8=e=>{let t=F3(null),{theme:o}=be();return O3(()=>{if(!e.rawText)return;let r=eo({text:e.rawText,x:0,y:0}),n=t.current;return(async()=>{let i=await xa({data:{elements:[r],appState:{exportBackground:!1,viewBackgroundColor:Ho,exportWithDarkMode:o==="dark"},files:null},config:{skipInliningFonts:!0}});i.querySelector(".style-fonts")?.remove(),n.replaceChildren(),n.appendChild(i)})(),()=>{n.replaceChildren()}},[e.rawText,o]),Yh("button",{type:"button",className:"ChartPreview","aria-label":h("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Vn("div",{className:"ChartPreview__canvas",ref:t}),Vn("div",{className:"ChartPreview__label",children:h("labels.chartType_plaintext")})]})},z3=({data:e,rawText:t,onClose:o})=>{let{onInsertElements:r,focusContainer:n}=Xe(),[i,l]=B3(Math.random()),a=N3.useCallback(()=>{l(Math.random())},[]),s=N3.useCallback(()=>{o&&o()},[o]),c=(m,p)=>{r(p),Ee("paste","chart",m),o(),n()},d=m=>{let p=eo({text:m,x:0,y:0});r([p]),Ee("paste","chart","plaintext"),o(),n()};return Vn(Mt,{size:"regular",onCloseRequest:s,title:Yh("div",{className:"PasteChartDialog__title",children:[Vn("div",{className:"PasteChartDialog__titleText",children:h("labels.pasteCharts")}),Vn("div",{className:"PasteChartDialog__reshuffleBtn",onClick:a,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a())},children:fo})]}),className:"PasteChartDialog",autofocus:!1,children:Yh("div",{className:"container",children:[["bar","line","radar"].map(m=>vs(e,m)?Vn(h8,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),t&&Vn(g8,{rawText:t,onClick:d})]})})};import{Fragment as f8,jsx as H3,jsxs as b8}from"react/jsx-runtime";var Rd=({heading:e,children:t,...o})=>{let{id:r}=Je(),n=H3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:h(`headings.${e}`)});return H3("section",{...o,"aria-labelledby":`${r}-${e}-title`,children:typeof t=="function"?t(n):b8(f8,{children:[n,t]})})};import{Popover as Nd}from"radix-ui";import U3 from"clsx";import Kh,{useLayoutEffect as x8}from"react";import{Fragment as Ix,jsx as io,jsxs as _s}from"react/jsx-runtime";var E8=4,y8=8,Tx=38,G3=21,v8=({shouldWrap:e,children:t,username:o})=>e?io(Eo,{label:o||"Unknown user",children:t}):io(Ix,{children:t}),Cx=({actionManager:e,collaborator:t,socketId:o,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let l={socketId:o,collaborator:t,withName:r,isBeingFollowed:i},a=e.renderAction("goToCollaborator",l);return io(v8,{username:t.username,shouldWrap:n,children:a},o)},w8=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Xh=Kh.memo(({className:e,mobile:t,collaborators:o,userToFollow:r,currentUserControls:n})=>{let i=Qe(),l=typeof n=="function"?n(!!t):n,a=Array.from(o,([S,A])=>({...A,socketId:S})).filter(S=>S.username?.trim()),s=a.find(S=>S.isCurrentUser),c=a.filter(S=>!S.isCurrentUser),[d,m]=Kh.useState(""),p=a.filter(S=>S.username?.toLowerCase().includes(d)),u=Kh.useRef(null);x8(()=>{if(u.current){let S=M=>{f(M)};if(S(u.current.clientWidth),!sm)return;let A=new ResizeObserver(M=>{for(let O of M){let{width:P}=O.contentRect;S(P)}});return A.observe(u.current),()=>{A.disconnect()}}},[]);let[b,f]=Kh.useState(E8*Tx),x=s?b-G3:b,v=Math.max(1,Math.min(8,Math.floor(x/Tx))),y=s?Math.max(0,v-1):v,E=c.slice(0,y),w=s?[...E,s]:E,T=w.map(S=>{let A=Cx({actionManager:i,collaborator:S,socketId:S.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:S.socketId===r});return S.isCurrentUser?_s(Nd.Root,{children:[io(Nd.Trigger,{asChild:!0,children:_s("div",{className:"UserList__pill",children:[A,io("div",{className:"UserList__pill-chevron",children:z1})]})}),io(Nd.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:_s(yt,{padding:2,children:[a.length>=y8&&io(lu,{placeholder:h("quickSearch.placeholder"),onChange:m}),io(su,{className:"dropdown-menu UserList__collaborators",placeholder:h("userList.empty"),children:p.length>0?[io("div",{className:"hint",children:h("userList.hint.text")},"hint"),p.map(M=>Cx({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===r}))]:[]}),l&&_s(Ix,{children:[io("div",{className:"UserList__menu-divider"}),io(Nd.Close,{asChild:!0,children:io("div",{className:"dropdown-menu",children:l})})]}),io(Nd.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},S.socketId):A});return t?_s("div",{className:U3("UserList UserList_mobile",e),children:[io("div",{className:"UserList_mobile__avatars",children:a.map(S=>Cx({actionManager:i,collaborator:S,socketId:S.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:S.socketId===r}))}),l&&_s(Ix,{children:[io("div",{className:"UserList__menu-divider"}),l]})]}):io("div",{className:"UserList__wrapper",ref:u,children:io("div",{className:U3("UserList",e),style:{"--max-avatars":w.length+(s?G3/Tx:0)},children:T})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow||e.currentUserControls!==t.currentUserControls)return!1;let o=t.collaborators.keys();for(let[r,n]of e.collaborators){let i=t.collaborators.get(r);if(!i||r!==o.next().value||!Lt(n,i,w8))return!1}return!0});import Sx from"clsx";import{jsx as W3}from"react/jsx-runtime";var V3=e=>W3(Eo,{label:`${h("helpDialog.title")} \u2014 ?`,children:W3("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":h("helpDialog.title"),children:wa})});import{jsx as Yn,jsxs as kx}from"react/jsx-runtime";var Y3=({appState:e,actionManager:t,showExitZenModeBtn:o,renderWelcomeScreen:r,defaultUIEnabled:n,zoomUIEnabled:i})=>{let{FooterCenterTunnel:l,WelcomeScreenHelpHintTunnel:a}=nt(),s=Xe();return kx("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(n||i&&s.isNavigationEnabled())&&Yn("div",{className:Sx("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Yn(ro.Col,{gap:2,children:kx(Rd,{heading:"canvasActions",children:[i&&s.isNavigationEnabled()&&Yn(aS,{renderAction:t.renderAction}),n&&!e.viewModeEnabled&&Yn(lS,{renderAction:t.renderAction,className:Sx("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Yn(l.Out,{}),(n||r)&&Yn("div",{className:Sx("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:kx("div",{style:{position:"relative"},children:[r&&Yn(a.Out,{}),n&&Yn(V3,{onClick:()=>t.executeAction(Ri)})]})}),n&&Yn(sS,{actionManager:t,showExitZenModeBtn:o})]})},K3=Y3;Y3.displayName="Footer";import N8 from"clsx";import{useEffect as q3,useLayoutEffect as J3,useRef as Ox,useState as O8,forwardRef as Q3,useImperativeHandle as F8,useCallback as Z3}from"react";import C8 from"clsx";import{useContext as I8}from"react";import T8 from"react";var $h=T8.createContext({});import{jsx as Mx,jsxs as X3}from"react/jsx-runtime";var Ax=({children:e,className:t})=>{let o=Me(),r=I8($h),n=!!(o.canFitSidebar&&r.shouldRenderDockButton);return X3("div",{className:C8("sidebar__header",t),"data-testid":"sidebar-header",children:[e,X3("div",{className:"sidebar__header__buttons",children:[n&&Mx(Eo,{label:h("labels.sidebarLock"),children:Mx(no,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":h("labels.sidebarLock"),children:Zf})}),Mx(no,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":h("buttons.close"),children:Go})]})]})};Ax.displayName="SidebarHeader";import{Tabs as S8}from"radix-ui";import{jsx as $3}from"react/jsx-runtime";var Lx=({children:e,tab:t,onSelect:o,...r})=>$3(S8.Trigger,{value:t,asChild:!0,onSelect:o,children:$3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});Lx.displayName="SidebarTabTrigger";import{Tabs as k8}from"radix-ui";import{jsx as M8}from"react/jsx-runtime";var _x=({children:e,...t})=>M8(k8.List,{className:"sidebar-triggers",...t,children:e});_x.displayName="SidebarTabTriggers";import A8 from"clsx";import{jsx as Px,jsxs as L8}from"react/jsx-runtime";var Dx=({name:e,tab:t,icon:o,title:r,children:n,onToggle:i,className:l,style:a})=>{let s=Ie(),d=be().openSidebar?.name===e;return Px("button",{type:"button",title:r,className:"sidebar-trigger__label-element","aria-label":r,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;s({openSidebar:m?{name:e,tab:t}:null,openMenu:null,openPopup:null}),i?.(m)},children:L8("div",{className:A8("sidebar-trigger",l),style:a,children:[o&&Px("div",{children:o}),n&&Px("div",{className:"sidebar-trigger__label",children:n})]})})};Dx.displayName="SidebarTrigger";import{Tabs as _8}from"radix-ui";import{jsx as P8}from"react/jsx-runtime";var Rx=({children:e,...t})=>{let o=be(),r=Ie();if(!o.openSidebar)return null;let{name:n}=o.openSidebar;return P8(_8.Root,{className:"sidebar-tabs-root",value:o.openSidebar.tab,onValueChange:i=>r(l=>({...l,openSidebar:{...l.openSidebar,name:n,tab:i}})),...t,children:e})};Rx.displayName="SidebarTabs";import{Tabs as D8}from"radix-ui";import{jsx as R8}from"react/jsx-runtime";var Nx=({tab:e,children:t,...o})=>R8(D8.Content,{...o,value:e,"data-testid":e,children:t});Nx.displayName="SidebarTab";import{jsx as j3}from"react/jsx-runtime";import{createElement as B8}from"react";var Od=Ce(!1),ek=Q3(({name:e,children:t,onDock:o,docked:r,className:n,...i},l)=>{Bt()&&o&&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 a=Ie(),s=qr(Od);J3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=Ox({});c.current.onCloseRequest=()=>{a({openSidebar:null})},c.current.onDock=u=>o?.(u),c.current=nl(c.current,{docked:r,shouldRenderDockButton:!!o&&r!=null});let d=Ox(null);F8(l,()=>d.current);let m=Me(),p=Z3(()=>{document.querySelector(".Dialog")||a({openSidebar:null})},[a]);return Ol(d,Z3(u=>{u.target.closest(".sidebar-trigger")||(!r||!m.canFitSidebar)&&p()},[p,r,m.canFitSidebar])),q3(()=>{let u=b=>{b.key===I.ESCAPE&&(!r||!m.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,m.canFitSidebar]),j3(yt,{...i,className:N8(et.SIDEBAR,{"sidebar--docked":r},n),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:j3($h.Provider,{value:c.current,children:t})})});ek.displayName="SidebarInner";var hr=Object.assign(Q3((e,t)=>{let o=be(),{onStateChange:r}=e,n=Ox(o.openSidebar);q3(()=>{(!o.openSidebar&&n?.current?.name===e.name||o.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&o.openSidebar!==n.current&&r?.(o.openSidebar?.name!==e.name?null:o.openSidebar),n.current=o.openSidebar},[o.openSidebar,r,e.name]);let[i,l]=O8(!1);return J3(()=>(l(!0),()=>l(!1)),[]),i&&o.openSidebar?.name===e.name?B8(ek,{...e,ref:t,key:e.name}):null}),{Header:Ax,TabTriggers:_x,TabTrigger:Lx,Tabs:Rx,Tab:Nx,Trigger:Dx});hr.displayName="Sidebar";import{useLayoutEffect as z8,useRef as H8}from"react";import{jsx as U8}from"react/jsx-runtime";var Kn=(e,t)=>{let o=Ce(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=nt(),[,l]=i(o),a=H8({preferHost:!1,counter:0});return z8(()=>{let s=a.current;return l(c=>{let d=c+1;return s.counter=d,d}),()=>{l(c=>{let d=c-1;return s.counter=d,d||(s.preferHost=!1),d})}},[l]),n.__fallback||(a.current.preferHost=!0),!a.current.counter&&n.__fallback&&a.current.preferHost||a.current.counter>1&&n.__fallback?null:U8(t,{...n})};return r.displayName=e,r};var Ux={};Dg(Ux,{ChangeCanvasBackground:()=>uk,ClearCanvas:()=>mk,CommandPalette:()=>sk,Export:()=>hk,Help:()=>dk,LiveCollaborationTrigger:()=>fk,LoadScene:()=>ik,Preferences:()=>Or,PreferencesToggleGridModeItem:()=>zx,PreferencesToggleZenModeItem:()=>Hx,SaveAsImage:()=>lk,SaveToActiveFile:()=>ak,SearchMenu:()=>ck,Socials:()=>gk,ToggleTheme:()=>pk});import Y8 from"clsx";var Fx=Ce({active:!1});async function tk({title:e,description:t,actionLabel:o,color:r}){return new Promise(n=>{bt.set(Fx,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:t,actionLabel:o,color:r})})}import G8 from"clsx";import{jsx as ok,jsxs as W8}from"react/jsx-runtime";var Zh=function({onChange:e,value:t,choices:o,name:r}){return ok("div",{className:"RadioGroup",children:o.map(n=>W8("div",{className:G8("RadioGroup__choice",{active:n.value===t}),title:n.ariaLabel,children:[ok("input",{name:r,type:"radio",checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as V8,jsx as Fd,jsxs as rk}from"react/jsx-runtime";var nk=({value:e,shortcut:t,onChange:o,choices:r,children:n,name:i,icon:l})=>{let a=Me();return rk(V8,{children:[rk("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[l&&Fd("div",{className:"dropdown-menu-item__icon",children:l}),Fd("label",{className:"dropdown-menu-item__text",children:Fd(Ma,{children:n})}),Fd(Zh,{name:i,value:e,onChange:o,choices:r})]}),t&&a.formFactor!=="phone"&&Fd("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};nk.displayName="DropdownMenuItemContentRadio";var Bx=nk;import{Fragment as Ck,jsx as De,jsxs as Bd}from"react/jsx-runtime";var ik=()=>{let{t:e}=Ue(),t=Qe(),o=ki();return t.isActionEnabled(Pa)?De(bo,{icon:Ta,onSelect:async()=>{(!o.length||await tk({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:De(yo,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>De("strong",{children:n}),br:()=>De("br",{})})}))&&t.executeAction(Pa)},"data-testid":"load-button",shortcut:rt("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};ik.displayName="LoadScene";var ak=()=>{let{t:e}=Ue(),t=Qe();return t.isActionEnabled(Di)?De(bo,{shortcut:rt("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(Di),icon:db,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};ak.displayName="SaveToActiveFile";var lk=()=>{let e=Ie(),{t}=Ue();return De(bo,{icon:Hc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:rt("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};lk.displayName="SaveAsImage";var sk=e=>{let t=Ie(),{t:o}=Ue();return De(bo,{icon:Rl,"data-testid":"command-palette-button",onSelect:()=>{Ee("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:rt("commandPalette"),"aria-label":o("commandPalette.title"),className:e?.className,children:o("commandPalette.title")})};sk.displayName="CommandPalette";var ck=e=>{let{t}=Ue(),o=Qe();return De(bo,{icon:Lo,"data-testid":"search-menu-button",onSelect:()=>{o.executeAction(gs)},shortcut:rt("searchMenu"),"aria-label":t("search.title"),className:e?.className,children:t("search.title")})};ck.displayName="SearchMenu";var dk=()=>{let{t:e}=Ue(),t=Qe();return De(bo,{"data-testid":"help-menu-item",icon:wa,onSelect:()=>t.executeAction(Ri),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};dk.displayName="Help";var mk=()=>{let{t:e}=Ue(),t=qr(Fa);return Qe().isActionEnabled(nn)?De(bo,{icon:Kt,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};mk.displayName="ClearCanvas";var pk=e=>{let{t}=Ue(),o=be(),r=Qe(),n=rt("toggleTheme"),i=xo();return r.isActionEnabled(Bn)?e?.allowSystemTheme?De(Bx,{name:"theme",value:e.theme,onChange:l=>{if(i.onThemeChange){i.onThemeChange(l);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:J.LIGHT,label:_l,ariaLabel:`${t("buttons.lightMode")} - ${n}`},{value:J.DARK,label:Ll,ariaLabel:`${t("buttons.darkMode")} - ${n}`},{value:"system",label:A1,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):De(bo,{onSelect:l=>{l.preventDefault(),r.executeAction(Bn)},icon:o.theme===J.DARK?_l:Ll,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":o.theme===J.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:o.theme===J.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};pk.displayName="ToggleTheme";var uk=()=>{let{t:e}=Ue(),t=be(),o=Qe(),r=xo();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:Bd("div",{style:{marginTop:"0.75rem"},children:[De("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),De("div",{style:{padding:"0 0.625rem"},children:o.renderAction("changeViewBackgroundColor")})]})};uk.displayName="ChangeCanvasBackground";var hk=()=>{let{t:e}=Ue(),t=Ie();return De(bo,{icon:wi,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};hk.displayName="Export";var gk=()=>{let{t:e}=Ue();return Bd(Ck,{children:[De(us,{icon:Bc,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),De(us,{icon:cb,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),De(us,{icon:sb,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};gk.displayName="Socials";var fk=({onSelect:e,isCollaborating:t})=>{let{t:o}=Ue();return De(bo,{"data-testid":"collab-button",icon:Uc,className:Y8({"active-collab":t}),onSelect:e,children:o("labels.liveCollaboration")})};fk.displayName="LiveCollaborationTrigger";var bk=()=>{let{t:e}=Ue(),t=Xe(),o=be();return De(Pr,{checked:o.activeTool.locked,shortcut:rt("toolLock"),onSelect:r=>{t.toggleLock(),r.preventDefault()},children:e("labels.preferences_toolLock")})},xk=()=>{let{t:e}=Ue(),t=be(),o=Ie();return De(Bx,{name:"boxSelectionMode",icon:$c,value:t.boxSelectionMode,onChange:r=>{o({boxSelectionMode:r})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},Ek=()=>{let{t:e}=Ue(),t=Qe(),o=be();return De(Pr,{checked:o.objectsSnapModeEnabled,shortcut:rt("objectsSnapMode"),onSelect:r=>{t.executeAction(Jl),r.preventDefault()},children:e("buttons.objectsSnapMode")})},yk=()=>{let{t:e}=Ue(),t=Qe(),o=be();return De(Pr,{checked:o.bindingPreference==="enabled",onSelect:r=>{t.executeAction(Ql),r.preventDefault()},children:e("labels.arrowBinding")})},vk=()=>{let{t:e}=Ue(),t=Qe(),o=be();return De(Pr,{checked:o.isMidpointSnappingEnabled,onSelect:r=>{t.executeAction(es),r.preventDefault()},children:e("labels.midpointSnapping")})},zx=()=>{let{t:e}=Ue(),t=Qe(),o=be();return De(Pr,{checked:o.gridModeEnabled,shortcut:rt("gridMode"),onSelect:r=>{t.executeAction(Na),r.preventDefault()},children:e("labels.toggleGrid")})},Hx=()=>{let{t:e}=Ue(),t=Qe(),o=be();return De(Pr,{checked:o.zenModeEnabled,shortcut:rt("zenMode"),onSelect:r=>{t.executeAction(zn),r.preventDefault()},children:e("buttons.zenMode")})},wk=()=>{let{t:e}=Ue(),t=Qe(),o=be();return t.isActionEnabled(zi)?De(Pr,{checked:o.viewModeEnabled,shortcut:rt("viewMode"),onSelect:r=>{t.executeAction(zi),r.preventDefault()},children:e("labels.viewMode")}):null},Tk=()=>{let{t:e}=Ue(),t=Qe(),o=be();return De(Pr,{checked:o.stats.open,shortcut:rt("stats"),onSelect:r=>{t.executeAction(Hn),r.preventDefault()},children:e("stats.fullTitle")})},Or=({children:e,additionalItems:t})=>{let{t:o}=Ue();return Bd(Oi,{children:[De(Oi.Trigger,{icon:U1,children:o("labels.preferences")}),Bd(Oi.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Bd(Ck,{children:[De(xk,{}),De(bk,{}),De(Ek,{}),De(zx,{}),De(Hx,{}),De(wk,{}),De(Tk,{}),De(yk,{}),De(vk,{})]}),t]})]})};Or.ToggleToolLock=bk;Or.BoxSelectionMode=xk;Or.ToggleSnapMode=Ek;Or.ToggleArrowBinding=yk;Or.ToggleMidpointSnapping=vk;Or.ToggleGridMode=zx;Or.ToggleZenMode=Hx;Or.ToggleViewMode=wk;Or.ToggleElementProperties=Tk;Or.displayName="Preferences";import{jsx as jh,jsxs as Gx}from"react/jsx-runtime";var K8=Object.assign(Kn("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:o}=nt(),r=Me(),n=be(),i=xo(),l=Ie();return jh(o.In,{children:Gx(ue,{open:n.openMenu==="canvas",children:[jh(ue.Trigger,{onToggle:()=>{l({openMenu:n.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:ab}),Gx(ue.Content,{onClickOutside:()=>l({openMenu:null}),onSelect:li(t,()=>{l({openMenu:null})}),className:"main-menu",align:"start",children:[e,r.formFactor==="phone"&&n.collaborators.size>0&&Gx("fieldset",{className:"UserList-Wrapper",children:[jh("legend",{children:h("labels.collaborators")}),jh(Xh,{mobile:!0,collaborators:n.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ue.Trigger,Item:ue.Item,ItemLink:ue.ItemLink,ItemCustom:ue.ItemCustom,Group:ue.Group,Separator:ue.Separator,Sub:Oi,DefaultItems:Ux}),uo=K8;import X8 from"clsx";import{forwardRef as $8,useState as Z8}from"react";import{jsx as qh,jsxs as j8}from"react/jsx-runtime";var gr=$8(({children:e,icon:t,onClick:o,label:r,variant:n="filled",color:i="primary",size:l="medium",fullWidth:a,className:s,status:c,disabled:d},m)=>{let[p,u]=Z8(!1),b=async x=>{let v=o?.(x);if(ai(v)){let y=window.setTimeout(()=>{u(!0)},50);try{await v}catch(E){if(E instanceof yl)console.warn(E);else throw E}finally{clearTimeout(y),u(!1)}}},f=p?"loading":c;return i=f==="success"?"success":i,qh("button",{className:X8("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${l}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":a},s),onClick:b,type:"button","aria-label":r,ref:m,disabled:d||f==="loading"||f==="success",children:j8("div",{className:"ExcButton__contents",children:[f==="loading"?qh(Pt,{className:"ExcButton__statusIcon"}):f==="success"&&qh("div",{className:"ExcButton__statusIcon",children:c1}),t&&qh("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),n!=="icon"&&(e??r)]})})});import{jsx as Ps,jsxs as Q8}from"react/jsx-runtime";var Jh=({title:e,children:t,actionLabel:o,onClick:r})=>Q8("div",{className:"OverwriteConfirm__Actions__Action",children:[Ps("h4",{children:e}),Ps("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),Ps(gr,{variant:"outlined",color:"muted",label:o,size:"large",fullWidth:!0,onClick:r})]}),q8=()=>{let{t:e}=Ue(),t=Qe(),o=Ie();return Ps(Jh,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(Ru,"ui",!0),o({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},J8=()=>{let{t:e}=Ue(),t=Qe();return Ps(Jh,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction($l,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Wx=Object.assign(({children:e})=>Ps("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:q8,SaveToDisk:J8});import{jsx as Yi,jsxs as Ik}from"react/jsx-runtime";var Qh=Object.assign(Kn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=nt(),[o,r]=ne(Fx);if(!o.active)return null;let n=()=>{o.onClose(),r(l=>({...l,active:!1}))},i=()=>{o.onConfirm(),r(l=>({...l,active:!1}))};return Yi(t.In,{children:Yi(Mt,{onCloseRequest:n,title:!1,size:916,children:Ik("div",{className:"OverwriteConfirm",children:[Yi("h3",{children:o.title}),Ik("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${o.color}`,children:[Yi("div",{className:"OverwriteConfirm__Description__icon",children:Vc}),Yi("div",{children:o.description}),Yi("div",{className:"OverwriteConfirm__Description__spacer"}),Yi(gr,{color:o.color,size:"large",label:o.actionLabel,onClick:i})]}),Yi(Wx,{children:e})]})})})}),{Actions:Wx,Action:Jh});import h7 from"clsx";import e7 from"clsx";import t7 from"lodash.debounce";import{Fragment as o7,memo as r7,useEffect as zd,useMemo as Sk,useRef as Vx,useState as kk}from"react";import{Fragment as u7,jsx as jt,jsxs as un}from"react/jsx-runtime";var n7=Ce(""),Yx=Ce(null),i7=350,_k=()=>{let e=Xe(),t=Ie(),o=Vx(null),[r,n]=ne(n7),i=r.trim(),[l,a]=kk(!1),[s,c]=kk({nonce:null,items:[]}),d=Vx(null),m=Vx(void 0),[p,u]=ne(Yx),b=e.scene.getNonDeletedElementsMap();zd(()=>{l||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,Lk(i,e,(E,w)=>{c({nonce:En(),items:E}),d.current=i,m.current=e.scene.getSceneNonce(),t({searchMatches:E.length?{focusedId:null,matches:E.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[l,i,b,e,t,u,m]);let f=()=>{s.items.length>0&&u(E=>E===null?0:(E+1)%s.items.length)},x=()=>{s.items.length>0&&u(E=>E===null?0:E-1<0?s.items.length-1:E-1)};zd(()=>{t(E=>E.searchMatches?{searchMatches:{focusedId:p!==null&&E.searchMatches?.matches[p]?.id||null,matches:E.searchMatches.matches.map((T,S)=>S===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,t]),zd(()=>{if(s.items.length>0&&p!==null){let E=s.items[p];if(E){let w=e.state.zoom.value,T=eo({text:E.searchQuery,x:E.element.x+(E.matchedLines[0]?.offsetX??0),y:E.element.y+(E.matchedLines[0]?.offsetY??0),width:E.matchedLines[0]?.width,height:E.matchedLines[0]?.height,fontSize:re(E.element)?tt.nameFontSize:E.element.fontSize,fontFamily:re(E.element)?ct.Assistant:E.element.fontFamily}),S=14,A=T.fontSize,M=A*w<S;if(!Jm([T],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.viewport.getOffsets())||M){let O=M&&A<S?"contain":"scale-down";e.viewport.setViewport({target:we([T]),fit:O,animation:{duration:300},offsets:{ui:!0}})}}}},[p,s,e]),zd(()=>()=>{u(null),d.current=null,m.current=void 0,t({searchMatches:null}),a(!1)},[t,u]);let v=Si({goToNextItem:f,goToPreviousItem:x,searchMatches:s});zd(()=>{let E=w=>{if(w.key===I.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){w.preventDefault(),w.stopPropagation(),t({openSidebar:null});return}if(w[I.CTRL_OR_CMD]&&w.key===I.F){if(w.preventDefault(),w.stopPropagation(),e.state.openDialog)return;o.current?.matches(":focus")||(e.state.openDialog&&t({openDialog:null}),o.current?.focus(),o.current?.select())}w.target instanceof HTMLElement&&w.target.closest(".layer-ui__search")&&v.searchMatches.items.length&&(w.key===I.ENTER&&(w.stopPropagation(),v.goToNextItem()),w.key===I.ARROW_UP?(w.stopPropagation(),v.goToPreviousItem()):w.key===I.ARROW_DOWN&&(w.stopPropagation(),v.goToNextItem()))};return _e(window,"keydown",E,{capture:!0,passive:!1})},[t,v,e]);let y=`${s.items.length} ${s.items.length===1?h("search.singleResult"):h("search.multipleResults")}`;return un("div",{className:"layer-ui__search",children:[jt("div",{className:"layer-ui__search-header",children:jt(Fi,{className:et.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:o,placeholder:h("search.placeholder"),icon:Lo,onChange:E=>{n(E),a(!0);let w=E.trim();Lk(w,e,(T,S)=>{c({nonce:En(),items:T}),u(S),d.current=w,m.current=e.scene.getSceneNonce(),t({searchMatches:T.length?{focusedId:null,matches:T.map(A=>({id:A.element.id,focus:!1,matchedLines:A.matchedLines}))}:null}),a(!1)})},selectOnRender:!0})}),un("div",{className:"layer-ui__search-count",children:[s.items.length>0&&un(u7,{children:[p!==null&&p>-1?un("div",{children:[p+1," / ",y]}):jt("div",{children:y}),un("div",{className:"result-nav",children:[jt(no,{onSelect:()=>{f()},className:"result-nav-btn",children:Kc}),jt(no,{onSelect:()=>{x()},className:"result-nav-btn",children:R1})]})]}),s.items.length===0&&i&&d.current&&jt("div",{style:{margin:"1rem auto"},children:h("search.noMatch")})]}),jt(s7,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},Mk=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 jt("div",{tabIndex:-1,className:e7("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:o=>{e.highlighted&&o?.scrollIntoView({behavior:"auto",block:"nearest"})},children:jt("div",{className:"preview-text",children:t.flatMap((o,r)=>jt(o7,{children:r===2?jt("b",{children:o}):o},r))})})},a7=e=>{let t=Sk(()=>e.matches.items.filter(r=>re(r.element)),[e.matches]),o=Sk(()=>e.matches.items.filter(r=>ee(r.element)),[e.matches]);return un("div",{children:[t.length>0&&un("div",{className:"layer-ui__search-result-container",children:[un("div",{className:"layer-ui__search-result-title",children:[jt("div",{className:"title-icon",children:Ar}),jt("div",{children:h("search.frames")})]}),t.map((r,n)=>jt(Mk,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),o.length>0&&jt("div",{className:"layer-ui__divider"})]}),o.length>0&&un("div",{className:"layer-ui__search-result-container",children:[un("div",{className:"layer-ui__search-result-title",children:[jt("div",{className:"title-icon",children:en}),jt("div",{children:h("search.texts")})]}),o.map((r,n)=>jt(Mk,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+t.length===e.focusIndex,onClick:()=>e.onItemClick(n+t.length)},r.element.id+r.index))]})]})},l7=(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex,s7=r7(a7,l7),Ak=(e,t,o)=>{let i=e.slice(0,t),l=i.split(/\s+/),a=i.endsWith(" "),s=l.length-2-1-(a?0:1),c=l.slice(s<=0?0:s).join(" ")+(a?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(t+o.length),p=m.split(/\s+/),u=!m.startsWith(" "),b=u?6:5,f=(u?"":" ")+p.slice(0,b).join(" ");return{indexInSearchQuery:c.length,previewText:c+o+f,moreBefore:s>0,moreAfter:p.length>b}},c7=(e,t)=>{let o=e.split(`
|
|
24
|
+
`),r=[],n=0;for(let i=0;i<o.length;i++){let l=o[i],a=o[i+1];if(a){let s=t.indexOf(a,n);if(s>l.length+n){let c=s-(l.length+n);for(;c>0;)l+=" ",c--}}r.push(l),n=n+l.length}return r.join(`
|
|
25
|
+
`)},d7=(e,t,o)=>{let n=c7(e.text,e.originalText).split(`
|
|
26
|
+
`),i=[],l=0,a=0;for(let m of n){let p=l,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:a}),l=u+1,a++}let s=o,c=e.originalText.slice(o,o+t.length),d=[];for(let m of i){if(c==="")break;if(s>=m.startIndex&&s<=m.endIndex){let p=m.endIndex+1-s,u=m.line.slice(0,s-m.startIndex),b=c.slice(0,p);c=c.slice(p);let f=lt(u,dt(e),e.lineHeight);if(u===""&&(f.width=0),e.textAlign!=="left"&&m.line.length>0){let w=lt(m.line,dt(e),e.lineHeight),T=e.textAlign==="center"?(e.width-w.width)/2:e.width-w.width;f.width+=T}let{width:x,height:v}=lt(b,dt(e),e.lineHeight),y=f.width,E=m.lineNumber*f.height;d.push({offsetX:y,offsetY:E,width:x,height:v,showOnCanvas:!0}),s+=p}}return d},m7=(e,t,o,r)=>{let n=e.name??vf(e),i=n.slice(o,o+t.length),l=n.slice(0,o),a=dt({fontSize:tt.nameFontSize,fontFamily:ct.Assistant}),s=ho(ct.Assistant),c=lt(l,a,s);l===""&&(c.width=0);let d=lt(i,a,s),m=c.width,p=-c.height-tt.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*r}]},p7=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),Lk=t7((e,t,o)=>{if(!e||e===""){o([],null);return}let r=t.scene.getNonDeletedElements(),n=r.filter(p=>ee(p)),i=r.filter(p=>re(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let l=[],a=new RegExp(p7(e),"gi");for(let p of n){let u=null,b=p.originalText;for(;(u=a.exec(b))!==null;){let f=Ak(b,u.index,e),x=d7(p,e,u.index);x.length>0&&l.push({element:p,searchQuery:e,preview:f,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,b=p.name??vf(p);for(;(u=a.exec(b))!==null;){let f=Ak(b,u.index,e),x=m7(p,e,u.index,t.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:f,index:u.index,matchedLines:x})}}let c=new Set(t.visibleElements.map(p=>p.id)),d=[...s,...l],m=d.findIndex(p=>c.has(p.element.id))??null;o(d,m)},i7);import{jsx as Fr,jsxs as Pk}from"react/jsx-runtime";import{createElement as g7}from"react";var Dk=Kn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=nt();return Fr(t.In,{children:Fr(hr.Trigger,{...e,className:"default-sidebar-trigger",name:ao.name})})});Dk.displayName="DefaultSidebarTrigger";var Rk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=nt();return Fr(t.In,{children:e})};Rk.displayName="DefaultTabTriggers";var eg=Object.assign(Kn("DefaultSidebar",({children:e,className:t,onDock:o,docked:r,...n})=>{let i=be(),l=Ie(),{DefaultSidebarTabTriggersTunnel:a}=nt(),s=i.openSidebar?.tab===gn;return g7(hr,{...n,name:"default",key:"default",className:h7("default-sidebar",t),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||o===!1||!o&&r!=null?void 0:li(o,c=>{l({defaultSidebarDockedPreference:c})})},Pk(hr.Tabs,{children:[Fr(hr.Header,{children:Pk(hr.TabTriggers,{children:[Fr(hr.TabTrigger,{tab:gn,children:Lo}),Fr(hr.TabTrigger,{tab:ec,children:Rc}),Fr(a.Out,{})]})}),Fr(hr.Tab,{tab:ec,children:Fr($I,{})}),Fr(hr.Tab,{tab:gn,children:Fr(_k,{})}),e]}))}),{Trigger:Dk,TabTriggers:Rk});import{useEffect as hR,useState as gR}from"react";import{useState as Zx,useRef as jk,useEffect as jx,useDeferredValue as L7}from"react";import{useEffect as Nk,useRef as Ok,useState as Fk}from"react";import{jsx as tg}from"react/jsx-runtime";var f7=300,Bk=({input:e,placeholder:t,onChange:o,onKeyboardSubmit:r,errorLine:n})=>{let i=Ok(null),l=Ok(r);l.current=r;let[a,s]=Fk({type:"loading"}),[c,d]=Fk(!1),{theme:m}=be();if(Nk(()=>{let p=!1,u=setTimeout(()=>{p||d(!0)},f7);return import("./components/TTDDialog/CodeMirrorEditor-T6RKT6RA.js").then(b=>{p||s({type:"ready",component:b.default})}).catch(()=>{p||s({type:"fallback"})}).finally(()=>{clearTimeout(u)}),()=>{p=!0,clearTimeout(u)}},[]),Nk(()=>{if(a.type!=="fallback"||!l.current)return;let p=i.current;if(p){let u=b=>{b[I.CTRL_OR_CMD]&&b.key===I.ENTER&&(b.preventDefault(),l.current?.())};return p.focus(),p.addEventListener("keydown",u),()=>{p.removeEventListener("keydown",u)}}},[a.type]),a.type==="ready"){let p=a.component;return tg(p,{value:e,onChange:o,onKeyboardSubmit:r,placeholder:t,theme:m,errorLine:n})}return a.type==="fallback"?tg("textarea",{className:"ttd-dialog-input",onChange:p=>o(p.target.value),value:e,placeholder:t,ref:i}):c?tg("div",{className:"ttd-dialog-input ttd-dialog-input--loading",children:tg(Pt,{})}):null};import y7 from"clsx";var zk=/(?:Parse|Lexical) error on line (\d+)[.:]/i,Hk=/Trying to inactivate an inactive participant \((.+)\)/i,b7=/^\s*-+\^\s*$/,Hd=e=>zk.test(e),og=e=>Hd(e)||Hk.test(e),Uk=e=>b7.test(e),Kx=e=>{let t=e.match(Hk);return t?.[1]?t[1].trim():null},x7=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E7=(e,t)=>{let o=Kx(e);if(!o)return null;let r=new RegExp(`^\\s*deactivate\\s+${x7(o)}(?:\\s+%%.*)?\\s*$`),n=t.split(/\r?\n/);for(let i=n.length-1;i>=0;i--)if(r.test(n[i]))return i+1;return null},Ud=(e,t)=>{let o=e.match(zk);return o?Number.parseInt(o[1],10):t?E7(e,t):null},Ki=(e,t)=>(e.match(t)||[]).length,Gk=(e,t)=>{if(!Hd(e))return null;let o=Ud(e,t),r=o?`Syntax error near line ${o}.`:"Syntax error in Mermaid diagram.",n=[];if(t){let i=Ki(t,/\[/g),l=Ki(t,/\]/g);i!==l&&n.push("Unbalanced square brackets in a node label.");let a=Ki(t,/\(/g),s=Ki(t,/\)/g);a!==s&&n.push("Unbalanced parentheses in a node shape.");let c=Ki(t,/\{/g),d=Ki(t,/\}/g);c!==d&&n.push("Unbalanced braces in a decision node.");let m=Ki(t,/^\s*subgraph\b/gm),p=Ki(t,/^\s*end\s*$/gm);m>p&&n.push("A block is missing an `end` statement.")}return(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&n.push("An extra character/token may appear after a node or label definition."),n.length===0&&(n.push("A node or edge line is malformed (missing/extra delimiters)."),n.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:r,likelyCauses:[...new Set(n)]}},Wk=e=>Hd(e)?e.replace(/\n\s*Expecting[\s\S]*$/,"").trimEnd():e;import{jsx as fr,jsxs as rg}from"react/jsx-runtime";var ng=({error:e,canvasRef:t,loaded:o,hideErrorDetails:r,sourceText:n,autoFixAvailable:i,onApplyAutoFix:l})=>{let a=e?r?h("chat.errors.mermaidParseError"):Wk(e.message):null,s=e&&!r?Gk(e.message,n):null,c=!!i&&!!l&&!r,d=a?.split(/\r?\n/)??[];return rg("div",{className:`ttd-dialog-output-wrapper ${e?"ttd-dialog-output-wrapper--error":""}`,children:[e&&fr("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:rg("div",{className:"ttd-dialog-output-error-content",children:[fr("div",{className:"ttd-dialog-output-error-icon",children:Vc}),s&&rg("div",{className:"ttd-dialog-output-error-summary",children:[fr("div",{className:"ttd-dialog-output-error-summary__headline",children:s.summary}),fr("div",{className:"ttd-dialog-output-error-summary__label",children:"Likely causes:"}),fr("ul",{className:"ttd-dialog-output-error-summary__causes",children:s.likelyCauses.map(m=>fr("li",{children:m},m))})]}),fr("div",{className:"ttd-dialog-output-error-message",children:d.map((m,p)=>rg("span",{className:Uk(m)?"ttd-dialog-output-error-message__caret":void 0,children:[m,p<d.length-1?`
|
|
27
|
+
`:""]},`error-line-${p}`))}),!r&&fr("div",{className:"ttd-dialog-output-error-autofix-slot",children:c?fr(no,{className:"ttd-dialog-panel-button ttd-dialog-output-error-autofix",onSelect:l,children:h("mermaid.autoFixAvailable")}):null})]})},"error"),o?fr("div",{className:y7("ttd-dialog-output-canvas-container",{invisible:!!e}),children:fr("div",{ref:t,className:"ttd-dialog-output-canvas-content"})},"canvas"):fr(Pt,{size:"2rem"})]})};import Ds from"clsx";import{Fragment as v7}from"react";import{jsx as Rs,jsxs as Ns}from"react/jsx-runtime";var Ga=({label:e,children:t,panelActions:o=[],onTextSubmitInProgess:r,renderTopRight:n,renderSubmitShortcut:i,className:l,panelActionJustifyContent:a="flex-start"})=>{let s=c=>{if(c?.variant==="link")return Ns("button",{className:Ds("ttd-dialog-panel-action-link",c.className),onClick:c.action,disabled:c?.disabled||r,type:"button",children:[c.label,c.icon&&Rs("span",{className:"ttd-dialog-panel-action-link__icon",children:c.icon})]});if(c?.variant==="button")return Ns(no,{className:Ds("ttd-dialog-panel-button",c.className),onSelect:c.action?c.action:()=>{},disabled:c?.disabled||r,children:[Ns("div",{className:Ds({invisible:r}),children:[c?.label,c?.icon&&Rs("span",{children:c.icon})]}),r&&Rs(Pt,{})]});if(c?.variant==="rateLimit")return Rs("div",{className:Ds("ttd-dialog-panel__rate-limit",c.className),children:c.label})};return Ns("div",{className:Ds("ttd-dialog-panel",l),children:[(e||n)&&Ns("div",{className:"ttd-dialog-panel__header",children:[typeof e=="string"?Rs("label",{children:e}):e,n?.()]}),t,Ns("div",{className:Ds("ttd-dialog-panel-button-container",{invisible:!o.length}),style:{justifyContent:a},children:[o.filter(Boolean).map(c=>Rs(v7,{children:s(c)},c.label)),!r&&i?.()]})]})};import{jsx as w7}from"react/jsx-runtime";var Vk=({children:e})=>w7("div",{className:"ttd-dialog-panels",children:e});import{jsx as Yk,jsxs as T7}from"react/jsx-runtime";var Kk=()=>T7("div",{className:"ttd-dialog-submit-shortcut",children:[Yk("div",{className:"ttd-dialog-submit-shortcut__key",children:H("CtrlOrCmd")}),Yk("div",{className:"ttd-dialog-submit-shortcut__key",children:H("Enter")})]});var C7=(e,t)=>{let o=Ud(e,t);return o==null?null:o-1},Xk=(e,t,o)=>{if(t<0||t>=e.length)return null;let r=o(e[t]);if(r===e[t])return null;let n=[...e];return n[t]=r,n.join(`
|
|
28
|
+
`)},I7=e=>{let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(t)return t[1];let o=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return o?o[1]:e},$k=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,"$1 "),Zk=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S7=(e,t)=>{let o=new RegExp(`^\\s*deactivate\\s+${Zk(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/);for(let n=r.length-1;n>=0;n--)if(o.test(r[n]))return r.filter((i,l)=>l!==n).join(`
|
|
29
|
+
`);return null},k7=(e,t)=>{let o=new RegExp(`^\\s*deactivate\\s+${Zk(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/),n=!1,i=r.filter(l=>o.test(l)?(n=!0,!1):!0);return n?i.join(`
|
|
30
|
+
`):null},M7=e=>{let t=(e.match(/^\s*subgraph\b/gm)||[]).length,o=(e.match(/^\s*end\s*$/gm)||[]).length,r=t-o;if(r<=0)return null;let n=Array.from({length:r},()=>"end").join(`
|
|
31
|
+
`);return`${e.trimEnd()}
|
|
32
|
+
${n}`},A7=e=>e.replace(/[“”]/g,'"').replace(/[‘’]/g,"'"),Xx=(e,t)=>{if(!og(t)||!e.trim())return[];let o=[],r=new Set,n=l=>{!l||l===e||r.has(l)||(r.add(l),o.push(l))},i=Kx(t);if(i&&(n(S7(e,i)),n(k7(e,i))),Hd(t)){let l=e.split(/\r?\n/),a=C7(t,e),s=a==null?[]:[a,a-1,a+1];for(let d of s)n(Xk(l,d,m=>I7(m))),n(Xk(l,d,m=>$k(m)));n($k(e)),n(M7(e));let c=A7(e);n(c===e?null:c)}return o};var $x=({canvasRef:e,setError:t})=>{let o=e.current;if(!o)return;let r=o.parentElement;r&&(r.style.background="",t(null),o.replaceChildren())},Os=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:o,setError:r,data:n,theme:i})=>{let l=e.current,a=l?.parentElement;if(!l||!a)return{success:!1};if(!o)return $x({canvasRef:e,setError:r}),{success:!1};let s;try{let c=await t.api;try{s=await c.parseMermaidToExcalidraw(o)}catch(u){let b=u;if(!o.includes('"'))return{success:!1,error:b};try{s=await c.parseMermaidToExcalidraw(o.replace(/"/g,"'"))}catch{return{success:!1,error:b}}}let{elements:d,files:m={}}=s;r(null),n.current={elements:xl(d,{regenerateIds:!0}),files:m};let p=await ls({data:{elements:n.current.elements,files:n.current.files},config:{theme:i,padding:ti,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio}});return a.style.background="var(--default-bg-color)",l.replaceChildren(p),{success:!0}}catch(c){return a.style.background="var(--default-bg-color)",o&&r(c),{success:!1,error:c}}},Fs=e=>{cr.set(oi.MERMAID_TO_EXCALIDRAW,e)},Gd=({app:e,data:t,text:o,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=t.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fit:"scale-down"}),e.setOpenDialog(null),r&&o&&Fs(o))};import{Fragment as F7,jsx as Br,jsxs as Jk}from"react/jsx-runtime";var _7=`flowchart TD
|
|
25
33
|
A[Christmas] -->|Get money| B(Go shopping)
|
|
26
34
|
B --> C{Let me think}
|
|
27
35
|
C -->|One| D[Laptop]
|
|
28
36
|
C -->|Two| E[iPhone]
|
|
29
|
-
C -->|Three| F[Car]`,XT=Sn(Wl,300),IA=({mermaidToExcalidrawLib:e,isActive:o})=>{let[t,r]=VT(()=>Wo.get(In.MERMAID_TO_EXCALIDRAW)||CA),n=TA(t.trim()),[a,i]=VT(null),l=KT(null),s=KT({elements:[],files:null}),c=lt(),{theme:m}=Le();ZT(()=>{o&&((async()=>{try{if(!n){Db({canvasRef:l,setError:i});return}let h=await Gl({canvasRef:l,data:s,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n,theme:m});if(!h.success){let b=h.error??new Error("Invalid mermaid definition");i(b)}}catch(h){Ht()&&console.error("Failed to parse mermaid definition",h)}})(),XT(n))},[n,e,o,m]),ZT(()=>()=>{XT.flush()},[]);let p=()=>{zc({app:c,data:s,text:t,shouldSaveMermaidDataToStorage:!0})};return $T(kA,{children:[Yr("div",{className:"ttd-dialog-desc",children:Yr(oo,{i18nKey:"mermaid.description",flowchartLink:d=>Yr("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>Yr("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>Yr("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),$T(GT,{children:[Yr(di,{children:Yr(HT,{input:t,placeholder:u("mermaid.inputPlaceholder"),onChange:d=>r(d.target.value),onKeyboardSubmit:()=>{p()}})}),Yr(di,{panelActions:[{action:()=>{p()},label:u("mermaid.button"),icon:sn,variant:"button"}],renderSubmitShortcut:()=>Yr(YT,{}),children:Yr(Tu,{canvasRef:l,loaded:e.loaded,error:a})})]})]})},jT=IA;import{useRef as VA}from"react";import{useRef as JT,useEffect as AA,useLayoutEffect as _A}from"react";import SA from"clsx";import{useState as MA,useEffect as LA}from"react";import{Fragment as qT,jsx as Mt,jsxs as $o}from"react/jsx-runtime";var Rb=({message:e,onMermaidTabClick:o,onAiRepairClick:t,onDeleteMessage:r,onInsertMessage:n,onRetry:a,rateLimitRemaining:i,isLastMessage:l,renderWarning:s,allowFixingParseError:c})=>{let[m,p]=MA(!1);LA(()=>{if(!e.error||!l)return;if(e.error&&!e.lastAttemptAt){p(!0);return}let h=Date.now()-e.lastAttemptAt,b=Math.max(0,5e3-h);if(b===0){p(!0);return}p(!1);let f=setTimeout(()=>{p(!0)},b);return()=>clearTimeout(f)},[e.error,e.lastAttemptAt,l]);let d=h=>h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(e.type==="warning"){let h=s?.(e);return Mt("div",{className:"chat-message chat-message--system",children:$o("div",{className:"chat-message__content",children:[$o("div",{className:"chat-message__header",children:[Mt("span",{className:"chat-message__role",children:u("chat.role.system")}),Mt("span",{className:"chat-message__timestamp",children:d(e.timestamp)})]}),Mt("div",{className:"chat-message__body",children:Mt("div",{className:"chat-message__text",children:h||(e.warningType==="messageLimitExceeded"?$o(qT,{children:[u("chat.rateLimit.messageLimit"),Mt("div",{style:{marginTop:"10px"},children:Mt(Xo,{onClick:()=>{window.open(`${I.VITE_APP_PLUS_LP}/plus?utm_source=excalidraw&utm_medium=app&utm_content=ttdChatBanner#excalidraw-redirect`,"_blank","noopener")},children:u("chat.upsellBtnLabel")})})]}):u("chat.rateLimit.generalRateLimit"))})})]})})}return $o("div",{className:`chat-message chat-message--${e.type}`,children:[$o("div",{className:"chat-message__content",children:[$o("div",{className:"chat-message__header",children:[Mt("span",{className:"chat-message__role",children:e.type==="user"?u("chat.role.user"):u("chat.role.assistant")}),Mt("span",{className:"chat-message__timestamp",children:d(e.timestamp)})]}),Mt("div",{className:"chat-message__body",children:e.error?$o(qT,{children:[Mt("div",{className:"chat-message__error",children:e.content}),e.errorType!=="parse"&&$o("div",{className:"chat-message__error_message",children:["Error: ",e.error||u("chat.errors.generationFailed")]}),e.errorType==="parse"&&c&&$o("div",{className:"chat-message__error_message",children:[Mt("p",{children:u("chat.errors.invalidDiagram")}),$o("div",{className:"chat-message__error-actions",children:[o&&Mt("button",{className:"chat-message__error-link",onClick:()=>o(e),type:"button",children:u("chat.errors.fixInMermaid")}),t&&Mt("button",{className:"chat-message__error-link",onClick:()=>t(e),disabled:i===0,type:"button",children:u("chat.errors.aiRepair")})]})]})]}):$o("div",{className:"chat-message__text",children:[e.content,e.isGenerating&&Mt("span",{className:"chat-message__cursor",children:"\u258B"})]})})]}),e.type==="assistant"&&!e.isGenerating&&$o("div",{className:"chat-message__actions",children:[!e.error&&n&&Mt("button",{className:"chat-message__action",onClick:()=>n(e),type:"button","aria-label":u("chat.insert"),title:u("chat.insert"),children:uf}),o&&e.content&&Mt("button",{className:"chat-message__action",onClick:()=>o(e),type:"button","aria-label":u("chat.viewAsMermaid"),title:u("chat.viewAsMermaid"),children:zm}),r&&e.errorType!=="network"&&Mt("button",{className:"chat-message__action chat-message__action--danger",onClick:()=>r(e.id),type:"button","aria-label":u("chat.deleteMessage"),title:u("chat.deleteMessage"),children:_t}),e.errorType==="network"&&a&&l&&Mt("button",{className:SA("chat-message__action",{invisible:!m}),onClick:()=>a(e),type:"button","aria-label":u("chat.retry"),title:u("chat.retry"),children:pf})]})]})};import{jsx as hr,jsxs as Cu}from"react/jsx-runtime";var Nb=({chatId:e,messages:o,currentPrompt:t,onPromptChange:r,onGenerate:n,isGenerating:a,rateLimits:i,placeholder:l,onAbort:s,onMermaidTabClick:c,onAiRepairClick:m,onDeleteMessage:p,onInsertMessage:d,onRetry:h,renderWarning:b})=>{let f=JT(null),E=JT(null);_A(()=>{f.current?.scrollIntoView()},[o]),AA(()=>{E.current&&E.current.focus()},[e]);let v=A=>{let M=A.target.value;r(M)},x=()=>{if(a&&s){s();return}let A=t.trim();A&&(n({prompt:A}),r(""))},y=A=>{A.key===T.ENTER&&!A.shiftKey&&(A.preventDefault(),x())},w=t.trim().length>3&&!a&&(i?.rateLimitRemaining??1)>0,C=a&&!!s,S=A=>{let M=A.target;M.style.height="auto",M.style.height=`${Math.min(M.scrollHeight,120)}px`};return Cu("div",{className:"chat-interface",children:[Cu("div",{className:"chat-interface__messages",children:[o.length===0?hr("div",{className:"chat-interface__empty-state",children:Cu("div",{className:"chat-interface__empty-state-content",children:[hr("h3",{children:l.title}),hr("p",{children:l.description}),hr("p",{children:l.hint})]})}):o.map((A,M)=>hr(Rb,{message:A,onMermaidTabClick:c,onAiRepairClick:m,onDeleteMessage:p,onInsertMessage:d,onRetry:h,rateLimitRemaining:i?.rateLimitRemaining,isLastMessage:M===o.length-1,renderWarning:b,allowFixingParseError:A.errorType==="parse"&&M===o.length-1},A.id)),hr("div",{ref:f,id:"messages-end"})]}),hr("div",{className:"chat-interface__input-container",children:hr("div",{className:"chat-interface__input-outer",children:Cu("div",{className:"chat-interface__input-wrapper",children:[hr("textarea",{ref:E,autoFocus:!0,className:"chat-interface__input",value:t,onChange:v,onKeyDown:y,placeholder:i?.rateLimitRemaining===0?u("chat.rateLimit.messageLimitInputPlaceholder"):o.length>0?u("chat.inputPlaceholderWithMessages"):u("chat.inputPlaceholder",{shortcut:"Shift + Enter"}),disabled:a||i?.rateLimitRemaining===0,rows:1,cols:30,onInput:S}),hr("button",{className:"chat-interface__send-button",onClick:x,disabled:!w&&!C,type:"button",children:hr(_r,{size:"1.5em",icon:a?Tg:sn})})]})})})]})};var Iu=we(null),ku=we(!1),na=we(null),jo=we({id:Ut(),messages:[],currentPrompt:""});var aa=(e,o)=>{let{messages:t}=e,r=Cd(t,i=>i.type==="assistant");if(r===-1)return e;let n=t[r],a=t.slice();return a[r]={...n,...o},{...e,messages:a}},ia=e=>{let{messages:o}=e,t=Cd(o,r=>r.type==="assistant");return o[t]},Yl=(e,o)=>{let t=o.map(r=>({...r,id:Ut(),timestamp:new Date}));return{...e,messages:[...e.messages,...t]}},QT=e=>{let o=Cd(e.messages??[],t=>t.type==="assistant");return o!==-1?{...e,messages:e.messages.filter((t,r)=>r!==o)}:e},e5=e=>{let o=[];for(let t of e.messages)t.content&&(t.type==="user"||t.type==="assistant")&&o.push({role:t.type,content:t.content});return o};var Bc=()=>{let[e,o]=te(jo);return{addUserMessage:i=>{o(l=>Yl(l,[{type:"user",content:i}]))},addAssistantMessage:()=>{o(i=>Yl(i,[{type:"assistant",content:"",isGenerating:!0}]))},setAssistantError:(i,l="other",s)=>{let c=s?JSON.stringify({name:s instanceof Error?s.name:"Error",message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0}):void 0;o(m=>aa(m,{isGenerating:!1,error:i,errorType:l,errorDetails:c}))},chatHistory:e,setChatHistory:o,setLastRetryAttempt:()=>{o(i=>aa(i,{lastAttemptAt:Date.now()}))}}};import{useCallback as Fc,useEffect as t5,useRef as PA}from"react";var DA=e=>{let o=e.trim();return o.length<=50?o:`${o.substring(0,47)}...`},RA=we([]),NA=we(!1),OA=we(!1),Su=({persistenceAdapter:e})=>{let[o]=te(jo),[t,r]=te(RA),[n,a]=te(NA),[i,l]=te(OA),s=PA(t);s.current=t;let c=o?.messages[o?.messages.length-1],m=Fc(async()=>{if(!(i||n)){a(!0);try{let f=await e.loadChats();r(f),l(!0)}catch(f){console.warn("Failed to load chats:",f),r([]),l(!0)}finally{a(!1)}}},[i,n,r,a,l,e]);t5(()=>{m()},[]);let p=Fc(async()=>{if(o.messages.length===0)return;let f=o.messages.find(S=>S.type==="user");if(!f||typeof f.content!="string")return;let E=DA(f.content),v=s.current,x=v.find(S=>S.id===o.id),y=!x||x.messages.length!==o.messages.length||x.messages.some((S,A)=>S.id!==o.messages[A]?.id||S.content!==o.messages[A]?.content),w={id:o.id,title:E,messages:o.messages.filter(S=>S.type==="user"||S.type==="assistant").map(S=>({...S,timestamp:S.timestamp instanceof Date?S.timestamp:new Date(S.timestamp)})),currentPrompt:o.currentPrompt,timestamp:y?Date.now():x?.timestamp??Date.now()},C=[...v.filter(S=>S.id!==o.id),w].sort((S,A)=>A.timestamp-S.timestamp).slice(0,10);r(C);try{await e.saveChats(C)}catch(S){console.warn("Failed to save chats:",S)}},[o,r,e]);t5(()=>{c?.isGenerating||p()},[o.messages?.length,c?.id,c?.isGenerating]);let d=Fc(async f=>{let E=s.current.filter(v=>v.id!==f);r(E);try{await e.saveChats(E)}catch(v){console.warn("Failed to save after delete:",v)}return E},[r,e]),h=Fc(f=>f,[]),b=Fc(async()=>(await p(),Ut()),[p]);return{savedChats:t,saveCurrentChat:p,deleteChat:d,restoreChat:h,createNewChatId:b}};import{useCallback as r5,useEffect as Hc,useMemo as n5,useRef as mi}from"react";var o5=e=>{let o=e.trim();if(!o)return!1;let t=(o.match(/\[/g)||[]).length,r=(o.match(/\]/g)||[]).length,n=(o.match(/\{/g)||[]).length,a=(o.match(/\}/g)||[]).length,i=(o.match(/\(/g)||[]).length,l=(o.match(/\)/g)||[]).length;if(t!==r||n!==a||i!==l)return!1;let s=o.split(`
|
|
30
|
-
`).pop()?.trim()||"";return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(
|
|
31
|
-
`)}catch{return f}},d=(f,E)=>{E==="parse"&&pe("ai","mermaid parse failed","ttd");let v=p(f.message);s(v,E),o(f)};return{onGenerate:async({prompt:f,isRepairFlow:E=!1})=>{if(!m(f))return;c.current&&c.current.abort(),o(null);let v=new AbortController;c.current=v,E?a(x=>aa(x,{isGenerating:!0,content:"",error:void 0,errorType:void 0,errorDetails:void 0})):(i(f),l());try{pe("ai","generate","ttd");let y=[...e5(n).slice(-3),{role:"user",content:f}],{generatedResponse:w,error:C,rateLimit:S,rateLimitRemaining:A}=await e({messages:y,onStreamCreated:()=>{E&&a(M=>aa(M,{content:"",error:"",isGenerating:!0}))},onChunk:M=>{a(N=>{let R=ia(N);return aa(N,{content:R.content+M})})},signal:v.signal});if(a(M=>aa(M,{isGenerating:!1})),Uu(S)&&Uu(A)&&r({rateLimit:S,rateLimitRemaining:A}),C){if(C.name==="AbortError"||C.message==="Aborted"||v.signal.aborted)return;if(C.status===429){a(N=>{let R=QT(N);return{...R,messages:R.messages.filter(P=>P.type!=="warning"||P.warningType==="rateLimitExceeded"||P.warningType==="messageLimitExceeded")}}),a(N=>Yl(N,[{type:"warning",warningType:A===0?"messageLimitExceeded":"rateLimitExceeded"}]));return}else A===0&&a(N=>(N={...N,messages:N.messages.filter(R=>R.type!=="warning"||R.warningType==="rateLimitExceeded"||R.warningType==="messageLimitExceeded")},Yl(N,[{type:"warning",warningType:"messageLimitExceeded"}])));d(C,"network");return}await HA(w??""),pe("ai","mermaid parse success","ttd")}catch(x){d(x,"parse")}finally{c.current=null}},handleAbort:()=>{c.current&&c.current.abort()}}};import{useCallback as pi,useState as UA}from"react";var s5=({persistenceAdapter:e})=>{let o=Sr(na),[t,r]=te(jo),[n,a]=UA(!1),{restoreChat:i,deleteChat:l,createNewChatId:s}=Su({persistenceAdapter:e}),c=pi(E=>{let v=E.messages.map(w=>({...w,timestamp:w.timestamp instanceof Date?w.timestamp:new Date(w.timestamp)})),x={id:E.id,messages:v,currentPrompt:""},y=ia(x);o(y?.error?new Error(y?.error):null),r(x)},[o,r]),m=pi(async()=>{let E=await s();r({id:E,messages:[],currentPrompt:""}),o(null)},[s,r,o]),p=pi(E=>{let v=i(E);c(v),a(!1)},[i,c]),d=pi(async(E,v)=>{v.stopPropagation();let x=E===t.id,y=await l(E);if(x)if(y.length>0){let w=y[0];c(w)}else await m()},[t.id,l,c,m]),h=pi(async()=>{await m(),a(!1)},[m]),b=pi(()=>{a(E=>!E)},[]),f=pi(()=>{a(!1)},[]);return{isMenuOpen:n,onRestoreChat:p,handleDeleteChat:d,handleNewChat:h,handleMenuToggle:b,handleMenuClose:f}};import GA from"clsx";import{Fragment as WA,jsx as ui,jsxs as Fb}from"react/jsx-runtime";var c5=({isOpen:e,onToggle:o,onClose:t,onNewChat:r,onRestoreChat:n,onDeleteChat:a,isNewChatBtnVisible:i,savedChats:l,activeSessionId:s,disabled:c})=>Fb("div",{className:"ttd-chat-history-menu",children:[i&&ui(Xo,{onClick:r,disabled:c,children:u("chat.newChat")}),l.length>0&&ui("div",{className:"ttd-dialog-panel__menu-wrapper",children:Fb(de,{open:e,children:[ui(de.Trigger,{onToggle:o,className:"ttd-dialog-menu-trigger",disabled:c,title:u("chat.menu"),"aria-label":u("chat.menu"),children:yf}),ui(de.Content,{onClickOutside:t,onSelect:t,placement:"bottom",children:ui(WA,{children:l.map(m=>Fb(de.ItemCustom,{className:GA("ttd-chat-menu-item",{"ttd-chat-menu-item--active":m.id===s}),onClick:()=>{n(m)},children:[ui("span",{className:"ttd-chat-menu-item__title",children:m.title}),ui("button",{className:"ttd-chat-menu-item__delete",onClick:p=>a(m.id,p),title:u("chat.deleteChat"),"aria-label":u("chat.deleteChat"),type:"button",children:_t})]},m.id))})})]})})]});import{jsx as Vl,jsxs as YA}from"react/jsx-runtime";var d5=({chatId:e,messages:o,currentPrompt:t,onPromptChange:r,onGenerate:n,isGenerating:a,generatedResponse:i,isMenuOpen:l,onMenuToggle:s,onMenuClose:c,onNewChat:m,onRestoreChat:p,onDeleteChat:d,savedChats:h,activeSessionId:b,onAbort:f,onMermaidTabClick:E,onAiRepairClick:v,onDeleteMessage:x,onInsertMessage:y,onRetry:w,onViewAsMermaid:C,renderWarning:S})=>{let[A]=te(Iu),N=(()=>{let P=[];return A&&P.push({label:u("chat.rateLimitRemaining",{count:A.rateLimitRemaining}),variant:"rateLimit",className:A.rateLimitRemaining<5?"ttd-dialog-panel__rate-limit--danger":""}),i&&P.push({action:C,label:u("chat.viewAsMermaid"),icon:Vl(_r,{icon:sn}),variant:"link"}),P})(),R=()=>N.length===2?"space-between":N.length===1&&N[0].variant==="rateLimit"?"flex-start":"flex-end";return Vl(di,{label:YA("div",{className:"ttd-dialog-panel__label-wrapper",children:[Vl("div",{className:"ttd-dialog-panel__label-group"}),Vl("div",{className:"ttd-dialog-panel__header-right",children:Vl(c5,{isNewChatBtnVisible:!!o.length,isOpen:l,onToggle:s,onClose:c,onNewChat:m,onRestoreChat:p,onDeleteChat:d,savedChats:h,activeSessionId:b,disabled:a})})]}),className:"ttd-dialog-chat-panel",panelActionJustifyContent:R(),panelActions:N,children:Vl(Nb,{chatId:e,messages:o,currentPrompt:t,onPromptChange:r,onGenerate:n,isGenerating:a,generatedResponse:i,onAbort:f,onMermaidTabClick:E,onAiRepairClick:v,onDeleteMessage:x,onInsertMessage:y,onRetry:w,rateLimits:A,placeholder:{title:u("chat.placeholder.title"),description:u("chat.placeholder.description"),hint:u("chat.placeholder.hint")},renderWarning:S})})};import{jsx as m5}from"react/jsx-runtime";var p5=({canvasRef:e,error:o,loaded:t,onInsert:r,hideErrorDetails:n})=>{let a=[{action:r,label:u("chat.insert"),icon:sn,variant:"button"}];return m5(di,{panelActionJustifyContent:"flex-end",panelActions:a,className:"ttd-dialog-preview-panel",children:m5(Tu,{canvasRef:e,error:o,loaded:t,hideErrorDetails:n})})};import{jsx as Hb,jsxs as XA}from"react/jsx-runtime";var KA=({mermaidToExcalidrawLib:e,onTextSubmit:o,renderWarning:t,persistenceAdapter:r})=>{let n=lt(),a=ye(),i=VA(null),[l,s]=te(na),[c,m]=te(jo),p=Vi(ku),{savedChats:d}=Su({persistenceAdapter:r}),h=ia(c),{setLastRetryAttempt:b}=Bc(),{data:f}=i5({canvasRef:i,mermaidToExcalidrawLib:e}),{onGenerate:E,handleAbort:v}=l5({onTextSubmit:o}),{isMenuOpen:x,onRestoreChat:y,handleDeleteChat:w,handleNewChat:C,handleMenuToggle:S,handleMenuClose:A}=s5({persistenceAdapter:r}),M=()=>{typeof h?.content=="string"&&(Wl(h.content),a({openDialog:{name:"ttd",tab:"mermaid"}}))},N=Z=>{let z=Z.content||"";z&&(Wl(z),a({openDialog:{name:"ttd",tab:"mermaid"}}))},R=async Z=>{let z=Z.content||"";if(!z.trim()||!e.loaded)return;let U={current:{elements:[],files:null}};(await Gl({canvasRef:i,data:U,mermaidToExcalidrawLib:e,setError:s,mermaidDefinition:z,theme:n.state.theme})).success&&zc({app:n,data:U,text:z,shouldSaveMermaidDataToStorage:!0})},P=async Z=>{let z=Z.content||"",U=Z.error||"";if(!z)return;let ee=`Fix the error in this Mermaid diagram. The diagram is:
|
|
37
|
+
C -->|Three| F[Car]`,qk=xn(Fs,300),P7=500,D7=4,R7=30,N7=e=>e instanceof Error?e.message:typeof e=="string"?e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:"",O7=({mermaidToExcalidrawLib:e,isActive:t})=>{let[o,r]=Zx(()=>cr.get(oi.MERMAID_TO_EXCALIDRAW)||_7),n=L7(o),[i,l]=Zx(null),[a,s]=Zx(null),c=i?.message?Ud(i.message,n):null,d=jk(null),m=jk({elements:[],files:null}),p=Xe(),{theme:u}=be();jx(()=>{t&&((async()=>{try{if(!n.trim()){$x({canvasRef:d,setError:l});return}let v=await Os({canvasRef:d,data:m,mermaidToExcalidrawLib:e,setError:l,mermaidDefinition:n,theme:u});if(!v.success){let y=v.error??new Error("Invalid mermaid definition");l(y)}}catch(v){Bt()&&console.error("Failed to parse mermaid definition",v)}})(),qk(n))},[n,e,t,u]),jx(()=>()=>{qk.flush()},[]),jx(()=>{let x=i?.message??"",v=n;if(!(t&&og(x)&&!!v.trim()&&e.loaded)){s(null);return}let E=Xx(v,x);if(!E.length){s(null);return}let w=!1,T=setTimeout(async()=>{try{let S=await e.api,A=new Set([v]),M=E.map(P=>({text:P,depth:1})),O=0;for(;M.length>0&&O<R7;){let P=M.shift();if(!(!P||A.has(P.text))){A.add(P.text),O+=1;try{await S.parseMermaidToExcalidraw(P.text),w||s(P.text);return}catch(L){if(P.depth>=D7)continue;let D=N7(L);if(!D)continue;let U=Xx(P.text,D);for(let K of U)A.has(K)||M.push({text:K,depth:P.depth+1})}}}}catch{}w||s(null)},P7);return()=>{w=!0,clearTimeout(T)}},[n,i?.message,t,e]);let b=()=>{Gd({app:p,data:m,text:o,shouldSaveMermaidDataToStorage:!0})},f=()=>{a&&r(a)};return Jk(F7,{children:[Br("div",{className:"ttd-dialog-desc",children:Br(yo,{i18nKey:"mermaid.description",flowchartLink:x=>Br("a",{href:"https://mermaid.js.org/syntax/flowchart.html",target:"_blank",rel:"noreferrer",children:x}),sequenceLink:x=>Br("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",target:"_blank",rel:"noreferrer",children:x}),classLink:x=>Br("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",target:"_blank",rel:"noreferrer",children:x}),erdLink:x=>Br("a",{href:"https://mermaid.js.org/syntax/entityRelationshipDiagram.html",target:"_blank",rel:"noreferrer",children:x})})}),Jk(Vk,{children:[Br(Ga,{children:Br(Bk,{input:o,placeholder:h("mermaid.inputPlaceholder"),onChange:x=>r(x),errorLine:c,onKeyboardSubmit:()=>{b()}})}),Br(Ga,{panelActions:[{action:()=>{b()},label:h("mermaid.button"),icon:_n,variant:"button"}],renderSubmitShortcut:()=>Br(Kk,{}),children:Br(ng,{canvasRef:d,loaded:e.loaded,error:i,sourceText:o,autoFixAvailable:!!a,onApplyAutoFix:f})})]})]})},Qk=O7;import{useRef as rR}from"react";import{useRef as t5,useEffect as G7,useLayoutEffect as W7}from"react";import{jsx as qx,jsxs as B7}from"react/jsx-runtime";var ig=()=>B7("div",{className:"chat-interface__welcome-screen__welcome-message",children:[qx("h3",{children:h("chat.placeholder.title")}),qx("p",{children:h("chat.placeholder.description")}),qx("p",{children:h("chat.placeholder.hint")})]});import z7 from"clsx";import{useState as H7,useEffect as U7}from"react";import{Fragment as e5,jsx as Wt,jsxs as br}from"react/jsx-runtime";var Jx=({message:e,onMermaidTabClick:t,onAiRepairClick:o,onDeleteMessage:r,onInsertMessage:n,onRetry:i,rateLimitRemaining:l,isLastMessage:a,renderWarning:s,allowFixingParseError:c})=>{let[d,m]=H7(!1);U7(()=>{if(!e.error||!a)return;if(e.error&&!e.lastAttemptAt){m(!0);return}let u=Date.now()-e.lastAttemptAt,b=Math.max(0,5e3-u);if(b===0){m(!0);return}m(!1);let f=setTimeout(()=>{m(!0)},b);return()=>clearTimeout(f)},[e.error,e.lastAttemptAt,a]);let p=u=>u.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(e.type==="warning"){let u=s?.(e);return Wt("div",{className:"chat-message chat-message--system",children:br("div",{className:"chat-message__content",children:[br("div",{className:"chat-message__header",children:[Wt("span",{className:"chat-message__role",children:h("chat.role.system")}),Wt("span",{className:"chat-message__timestamp",children:p(e.timestamp)})]}),Wt("div",{className:"chat-message__body",children:Wt("div",{className:"chat-message__text",children:u||(e.warningType==="messageLimitExceeded"?br(e5,{children:[h("chat.rateLimit.messageLimit"),Wt("div",{style:{marginTop:"10px"},children:Wt(gr,{onClick:()=>{window.open(`${k.VITE_APP_PLUS_LP}/plus?utm_source=excalidraw&utm_medium=app&utm_content=ttdChatBanner#excalidraw-redirect`,"_blank","noopener")},children:h("chat.upsellBtnLabel")})})]}):h("chat.rateLimit.generalRateLimit"))})})]})})}return br("div",{className:`chat-message chat-message--${e.type}`,children:[br("div",{className:"chat-message__content",children:[br("div",{className:"chat-message__header",children:[Wt("span",{className:"chat-message__role",children:e.type==="user"?h("chat.role.user"):h("chat.role.assistant")}),Wt("span",{className:"chat-message__timestamp",children:p(e.timestamp)})]}),Wt("div",{className:"chat-message__body",children:e.error?br(e5,{children:[Wt("div",{className:"chat-message__error",children:e.content}),e.errorType!=="parse"&&br("div",{className:"chat-message__error_message",children:["Error: ",e.error||h("chat.errors.generationFailed")]}),e.errorType==="parse"&&c&&br("div",{className:"chat-message__error_message",children:[Wt("p",{children:h("chat.errors.invalidDiagram")}),br("div",{className:"chat-message__error-actions",children:[t&&Wt("button",{className:"chat-message__error-link",onClick:()=>t(e),type:"button",children:h("chat.errors.fixInMermaid")}),o&&Wt("button",{className:"chat-message__error-link",onClick:()=>o(e),disabled:l===0,type:"button",children:h("chat.errors.aiRepair")})]})]})]}):br("div",{className:"chat-message__text",children:[e.content,e.isGenerating&&Wt("span",{className:"chat-message__cursor",children:"\u258B"})]})})]}),e.type==="assistant"&&!e.isGenerating&&br("div",{className:"chat-message__actions",children:[!e.error&&n&&Wt("button",{className:"chat-message__action",onClick:()=>n(e),type:"button","aria-label":h("chat.insert"),title:h("chat.insert"),children:p1}),t&&e.content&&Wt("button",{className:"chat-message__action",onClick:()=>t(e),type:"button","aria-label":h("chat.viewAsMermaid"),title:h("chat.viewAsMermaid"),children:Bp}),r&&e.errorType!=="network"&&Wt("button",{className:"chat-message__action chat-message__action--danger",onClick:()=>r(e.id),type:"button","aria-label":h("chat.deleteMessage"),title:h("chat.deleteMessage"),children:Kt}),e.errorType==="network"&&i&&a&&Wt("button",{className:z7("chat-message__action",{invisible:!d}),onClick:()=>i(e),type:"button","aria-label":h("chat.retry"),title:h("chat.retry"),children:m1})]})]})};import{jsx as Xn,jsxs as Qx}from"react/jsx-runtime";var eE=({chatId:e,messages:t,currentPrompt:o,onPromptChange:r,onGenerate:n,isGenerating:i,rateLimits:l,onAbort:a,onMermaidTabClick:s,onAiRepairClick:c,onDeleteMessage:d,onInsertMessage:m,onRetry:p,renderWelcomeScreen:u,renderWarning:b})=>{let f=t5(null),x=t5(null);W7(()=>{f.current?.scrollIntoView()},[t]),G7(()=>{x.current&&x.current.focus()},[e]);let v=A=>{let M=A.target.value;r(M)},y=()=>{if(i&&a){a();return}let A=o.trim();A&&(n({prompt:A}),r(""))},E=A=>{A.key===I.ENTER&&!A.shiftKey&&(A.preventDefault(),i||y())},w=o.trim().length>3&&!i&&(l?.rateLimitRemaining??1)>0,T=i&&!!a,S=A=>{let M=A.target;M.style.height="auto",M.style.height=`${Math.min(M.scrollHeight,120)}px`};return Qx("div",{className:"chat-interface",children:[Qx("div",{className:"chat-interface__messages",children:[t.length===0?Xn("div",{className:"chat-interface__welcome-screen",children:u?u({rateLimits:l??null}):Xn(ig,{})}):t.map((A,M)=>Xn(Jx,{message:A,onMermaidTabClick:s,onAiRepairClick:c,onDeleteMessage:d,onInsertMessage:m,onRetry:p,rateLimitRemaining:l?.rateLimitRemaining,isLastMessage:M===t.length-1,renderWarning:b,allowFixingParseError:A.errorType==="parse"&&M===t.length-1},A.id)),Xn("div",{ref:f,id:"messages-end"})]}),Xn("div",{className:"chat-interface__input-container",children:Xn("div",{className:"chat-interface__input-outer",children:Qx("div",{className:"chat-interface__input-wrapper",style:{borderColor:i?"var(--dialog-border-color)":void 0},children:[Xn("textarea",{ref:x,autoFocus:!0,className:"chat-interface__input",value:o,onChange:v,onKeyDown:E,placeholder:i?h("chat.generating"):l?.rateLimitRemaining===0?h("chat.rateLimit.messageLimitInputPlaceholder"):t.length>0?h("chat.inputPlaceholderWithMessages"):h("chat.inputPlaceholder",{shortcut:"Shift + Enter"}),disabled:l?.rateLimitRemaining===0,rows:1,cols:30,onInput:S}),Xn("button",{className:"chat-interface__send-button",onClick:y,disabled:!w&&!T,type:"button",children:Xn(on,{size:"1.5em",icon:i?Eb:_n})})]})})})]})};var ag=Ce(null),lg=Ce(!1),Xi=Ce(null),xr=Ce({id:So(),messages:[],currentPrompt:""});var $i=(e,t)=>{let{messages:o}=e,r=Cm(o,l=>l.type==="assistant");if(r===-1)return e;let n=o[r],i=o.slice();return i[r]={...n,...t},{...e,messages:i}},Zi=e=>{let{messages:t}=e,o=Cm(t,r=>r.type==="assistant");return t[o]},Wd=(e,t)=>{let o=t.map(r=>({...r,id:So(),timestamp:new Date}));return{...e,messages:[...e.messages,...o]}},o5=e=>{let t=Cm(e.messages??[],o=>o.type==="assistant");return t!==-1?{...e,messages:e.messages.filter((o,r)=>r!==t)}:e},r5=e=>{let t=[];for(let o of e.messages)o.content&&(o.type==="user"||o.type==="assistant")&&t.push({role:o.type,content:o.content});return t};var Vd=()=>{let[e,t]=ne(xr);return{addUserMessage:l=>{t(a=>Wd(a,[{type:"user",content:l}]))},addAssistantMessage:()=>{t(l=>Wd(l,[{type:"assistant",content:"",isGenerating:!0}]))},setAssistantError:(l,a="other",s)=>{let c=s?JSON.stringify({name:s instanceof Error?s.name:"Error",message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0}):void 0;t(d=>$i(d,{isGenerating:!1,error:l,errorType:a,errorDetails:c}))},chatHistory:e,setChatHistory:t,setLastRetryAttempt:()=>{t(l=>$i(l,{lastAttemptAt:Date.now()}))}}};import{useCallback as Yd,useEffect as n5,useRef as V7}from"react";var Y7=e=>{let t=e.trim();return t.length<=50?t:`${t.substring(0,47)}...`},K7=Ce([]),X7=Ce(!1),$7=Ce(!1),sg=({persistenceAdapter:e})=>{let[t]=ne(xr),[o,r]=ne(K7),[n,i]=ne(X7),[l,a]=ne($7),s=V7(o);s.current=o;let c=t?.messages[t?.messages.length-1],d=Yd(async()=>{if(!(l||n)){i(!0);try{let f=await e.loadChats();r(f),a(!0)}catch(f){console.warn("Failed to load chats:",f),r([]),a(!0)}finally{i(!1)}}},[l,n,r,i,a,e]);n5(()=>{d()},[]);let m=Yd(async()=>{if(t.messages.length===0)return;let f=t.messages.find(S=>S.type==="user");if(!f||typeof f.content!="string")return;let x=Y7(f.content),v=s.current,y=v.find(S=>S.id===t.id),E=!y||y.messages.length!==t.messages.length||y.messages.some((S,A)=>S.id!==t.messages[A]?.id||S.content!==t.messages[A]?.content),w={id:t.id,title:x,messages:t.messages.filter(S=>S.type==="user"||S.type==="assistant").map(S=>({...S,timestamp:S.timestamp instanceof Date?S.timestamp:new Date(S.timestamp)})),currentPrompt:t.currentPrompt,timestamp:E?Date.now():y?.timestamp??Date.now()},T=[...v.filter(S=>S.id!==t.id),w].sort((S,A)=>A.timestamp-S.timestamp).slice(0,10);r(T);try{await e.saveChats(T)}catch(S){console.warn("Failed to save chats:",S)}},[t,r,e]);n5(()=>{c?.isGenerating||m()},[t.messages?.length,c?.id,c?.isGenerating]);let p=Yd(async f=>{let x=s.current.filter(v=>v.id!==f);r(x);try{await e.saveChats(x)}catch(v){console.warn("Failed to save after delete:",v)}return x},[r,e]),u=Yd(f=>f,[]),b=Yd(async()=>(await m(),So()),[m]);return{savedChats:o,saveCurrentChat:m,deleteChat:p,restoreChat:u,createNewChatId:b}};import{useCallback as a5,useEffect as cg,useMemo as l5,useRef as Wa}from"react";var i5=e=>{let t=e.trim();if(!t)return!1;let o=(t.match(/\[/g)||[]).length,r=(t.match(/\]/g)||[]).length,n=(t.match(/\{/g)||[]).length,i=(t.match(/\}/g)||[]).length,l=(t.match(/\(/g)||[]).length,a=(t.match(/\)/g)||[]).length;if(o!==r||n!==i||l!==a)return!1;let s=t.split(`
|
|
38
|
+
`).pop()?.trim()||"";return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(d=>d.test(s))};var tE=300,Z7=3e3,j7=100,s5=100,c5=({mermaidToExcalidrawLib:e,canvasRef:t})=>{let[o]=ne(xr),[,r]=ne(Xi),[n,i]=ne(lg),l=Wa(!1),a=l5(()=>Zi(o),[o]),s=Wa(a);cg(()=>{s.current=a},[a]);let c=Wa({elements:[],files:null}),d=Wa(0),m=Wa(null),p=Wa(!1),u=Wa(tE),{theme:b}=be(),f=a5(async y=>{if(!y.trim()||!e.loaded||l.current)return!1;l.current=!0;let E=performance.now(),w=await Os({canvasRef:t,data:c,mermaidToExcalidrawLib:e,setError:r,mermaidDefinition:y,theme:b});return performance.now()-E<j7?u.current=tE:u.current=Z7,l.current=!1,w.success},[t,e,r,b]),x=l5(()=>{let y=async E=>{let w=Date.now(),T=w-d.current,S=u.current;if(!i5(E)){p.current||(d.current=Math.max(d.current,w-S+s5),p.current=!0),m.current=E;return}if(p.current=!1,T<S){m.current=E;return}m.current=null;let A=await f(E);d.current=Date.now(),A||(d.current=d.current-S+s5,p.current=!0)};return y.flush=async()=>{if(m.current){let E=m.current;m.current=null,await f(E),d.current=Date.now()}},y.cancel=()=>{m.current=null},y},[f]),v=a5(()=>{d.current=0,m.current=null,p.current=!1,u.current=tE},[]);return cg(()=>{a?.content&&a?.isGenerating?x(a.content):a?.isGenerating||(x.flush(),v(),a?.content&&x(a.content))},[v,x,a?.isGenerating,a?.content]),cg(()=>{let y=s.current;!y?.content||y.error||n&&f(y.content)},[o?.id,f,n]),cg(()=>{if(o.messages?.filter(y=>y.type==="assistant").length)n||i(!0);else{let y=t.current;if(y){let E=y.parentElement;E&&(E.style.background="",y.replaceChildren())}i(!1)}},[o.messages,i,t,n]),{data:c}};import{useRef as q7}from"react";import{parseMermaidToExcalidraw as J7}from"@excalidraw/mermaid-to-excalidraw";var oE=3,rE=1e4,d5=({onTextSubmit:e})=>{let[,t]=ne(Xi),[o,r]=ne(ag),[n,i]=ne(xr),{addUserMessage:l,addAssistantMessage:a,setAssistantError:s}=Vd(),c=q7(null),d=u=>u.length>rE||u.length<oE||o?.rateLimitRemaining===0?(u.length<oE&&t(new Error(h("chat.errors.promptTooShort",{min:oE}))),u.length>rE&&t(new Error(h("chat.errors.promptTooLong",{max:rE}))),!1):!0;return{onGenerate:async({prompt:u,isRepairFlow:b=!1})=>{if(!d(u))return;c.current&&c.current.abort(),t(null);let f=new AbortController;c.current=f,b?i(x=>$i(x,{isGenerating:!0,content:"",error:void 0,errorType:void 0,errorDetails:void 0})):(l(u),a());try{Ee("ai","generate","ttd");let v=[...r5(n).slice(-3),{role:"user",content:u}],{generatedResponse:y,error:E,rateLimit:w,rateLimitRemaining:T}=await e({messages:v,onStreamCreated:()=>{b&&i(S=>$i(S,{content:"",error:"",isGenerating:!0}))},onChunk:S=>{i(A=>{let M=Zi(A);return $i(A,{content:M.content+S})})},signal:f.signal});if(i(S=>$i(S,{isGenerating:!1})),Rg(w)&&Rg(T)&&r({rateLimit:w,rateLimitRemaining:T}),(E?.status===429||T===0)&&i(S=>(E?.status===429&&(S=o5(S)),S={...S,messages:S.messages.filter(M=>M.type!=="warning"||M.warningType==="rateLimitExceeded"||M.warningType==="messageLimitExceeded")},Wd(S,[{type:"warning",warningType:T===0?"messageLimitExceeded":"rateLimitExceeded"}]))),E){if(E.name==="AbortError"||E.message==="Aborted"||f.signal.aborted)return;let A=new Error(E.message||h("chat.errors.requestFailed"));E.status!==429&&s(A.message,"network"),t(A);return}try{await J7(y??""),Ee("ai","mermaid parse success","ttd")}catch(S){Ee("ai","mermaid parse failed","ttd");let A=new Error(S.message||h("chat.errors.mermaidParseError"));s(A.message,"parse"),t(A)}}catch(x){let v=new Error(x.message||h("chat.errors.generationFailed"));s(v.message,"other"),t(v)}finally{c.current=null}},handleAbort:()=>{c.current&&c.current.abort()}}};import{useCallback as Va,useState as Q7}from"react";var m5=({persistenceAdapter:e})=>{let t=qr(Xi),[o,r]=ne(xr),[n,i]=Q7(!1),{restoreChat:l,deleteChat:a,createNewChatId:s}=sg({persistenceAdapter:e}),c=Va(x=>{let v=x.messages.map(w=>({...w,timestamp:w.timestamp instanceof Date?w.timestamp:new Date(w.timestamp)})),y={id:x.id,messages:v,currentPrompt:""},E=Zi(y);t(E?.error?new Error(E?.error):null),r(y)},[t,r]),d=Va(async()=>{let x=await s();r({id:x,messages:[],currentPrompt:""}),t(null)},[s,r,t]),m=Va(x=>{let v=l(x);c(v),i(!1)},[l,c]),p=Va(async(x,v)=>{v.stopPropagation();let y=x===o.id,E=await a(x);if(y)if(E.length>0){let w=E[0];c(w)}else await d()},[o.id,a,c,d]),u=Va(async()=>{await d(),i(!1)},[d]),b=Va(()=>{i(x=>!x)},[]),f=Va(()=>{i(!1)},[]);return{isMenuOpen:n,onRestoreChat:m,handleDeleteChat:p,handleNewChat:u,handleMenuToggle:b,handleMenuClose:f}};import eR from"clsx";import{Fragment as tR,jsx as Ya,jsxs as nE}from"react/jsx-runtime";var p5=({isOpen:e,onToggle:t,onClose:o,onNewChat:r,onRestoreChat:n,onDeleteChat:i,isNewChatBtnVisible:l,savedChats:a,activeSessionId:s,disabled:c})=>nE("div",{className:"ttd-chat-history-menu",children:[l&&Ya(gr,{onClick:r,disabled:c,children:h("chat.newChat")}),a.length>0&&Ya("div",{className:"ttd-dialog-panel__menu-wrapper",children:nE(ue,{open:e,children:[Ya(ue.Trigger,{onToggle:t,className:"ttd-dialog-menu-trigger",disabled:c,title:h("chat.menu"),"aria-label":h("chat.menu"),children:x1}),Ya(ue.Content,{onClickOutside:o,onSelect:o,children:Ya(tR,{children:a.map(d=>nE(ue.ItemCustom,{className:eR("ttd-chat-menu-item",{"ttd-chat-menu-item--active":d.id===s}),onClick:()=>{n(d)},children:[Ya("span",{className:"ttd-chat-menu-item__title",children:d.title}),Ya("button",{className:"ttd-chat-menu-item__delete",onClick:m=>i(d.id,m),title:h("chat.deleteChat"),"aria-label":h("chat.deleteChat"),type:"button",children:Kt})]},d.id))})})]})})]});import{jsx as Bs,jsxs as oR}from"react/jsx-runtime";var u5=({chatId:e,messages:t,currentPrompt:o,onPromptChange:r,onGenerate:n,isGenerating:i,generatedResponse:l,isMenuOpen:a,onMenuToggle:s,onMenuClose:c,onNewChat:d,onRestoreChat:m,onDeleteChat:p,savedChats:u,activeSessionId:b,onAbort:f,onMermaidTabClick:x,onAiRepairClick:v,onDeleteMessage:y,onInsertMessage:E,onRetry:w,onViewAsMermaid:T,renderWelcomeScreen:S,renderWarning:A})=>{let[M]=ne(ag),P=(()=>{let D=[];return M&&D.push({label:h("chat.rateLimitRemaining",{count:M.rateLimitRemaining}),variant:"rateLimit",className:M.rateLimitRemaining<5?"ttd-dialog-panel__rate-limit--danger":""}),l&&D.push({action:T,label:h("chat.viewAsMermaid"),icon:Bs(on,{icon:_n}),variant:"link"}),D})(),L=()=>P.length===2?"space-between":P.length===1&&P[0].variant==="rateLimit"?"flex-start":"flex-end";return Bs(Ga,{label:oR("div",{className:"ttd-dialog-panel__label-wrapper",children:[Bs("div",{className:"ttd-dialog-panel__label-group"}),Bs("div",{className:"ttd-dialog-panel__header-right",children:Bs(p5,{isNewChatBtnVisible:!!t.length,isOpen:a,onToggle:s,onClose:c,onNewChat:d,onRestoreChat:m,onDeleteChat:p,savedChats:u,activeSessionId:b,disabled:i})})]}),className:"ttd-dialog-chat-panel",panelActionJustifyContent:L(),panelActions:P,children:Bs(eE,{chatId:e,messages:t,currentPrompt:o,onPromptChange:r,onGenerate:n,isGenerating:i,generatedResponse:l,onAbort:f,onMermaidTabClick:x,onAiRepairClick:v,onDeleteMessage:y,onInsertMessage:E,onRetry:w,rateLimits:M,renderWelcomeScreen:S,renderWarning:A})})};import{jsx as h5}from"react/jsx-runtime";var g5=({canvasRef:e,error:t,loaded:o,onInsert:r,hideErrorDetails:n})=>{let i=[{action:r,label:h("chat.insert"),icon:_n,variant:"button"}];return h5(Ga,{panelActionJustifyContent:"flex-end",panelActions:i,className:"ttd-dialog-preview-panel",children:h5(ng,{canvasRef:e,error:t,loaded:o,hideErrorDetails:n})})};import{jsx as iE,jsxs as aR}from"react/jsx-runtime";var nR=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:o,renderWarning:r,persistenceAdapter:n})=>{let i=Xe(),l=Ie(),a=rR(null),[s,c]=ne(Xi),[d,m]=ne(xr),p=Cl(lg),{savedChats:u}=sg({persistenceAdapter:n}),b=Zi(d),{setLastRetryAttempt:f}=Vd(),{data:x}=c5({canvasRef:a,mermaidToExcalidrawLib:e}),{onGenerate:v,handleAbort:y}=d5({onTextSubmit:t}),{isMenuOpen:E,onRestoreChat:w,handleDeleteChat:T,handleNewChat:S,handleMenuToggle:A,handleMenuClose:M}=m5({persistenceAdapter:n}),O=()=>{typeof b?.content=="string"&&(Fs(b.content),l({openDialog:{name:"ttd",tab:"mermaid"}}))},P=W=>{let q=W.content||"";q&&(Fs(q),l({openDialog:{name:"ttd",tab:"mermaid"}}))},L=async W=>{let q=W.content||"";if(!q.trim()||!e.loaded)return;let oe={current:{elements:[],files:null}};(await Os({canvasRef:a,data:oe,mermaidToExcalidrawLib:e,setError:c,mermaidDefinition:q,theme:i.state.theme})).success&&Gd({app:i,data:oe,text:q,shouldSaveMermaidDataToStorage:!0})},D=async W=>{let q=W.content||"",oe=W.error||"";if(!q)return;let B=`Fix the error in this Mermaid diagram. The diagram is:
|
|
32
39
|
|
|
33
40
|
\`\`\`mermaid
|
|
34
|
-
${
|
|
41
|
+
${q}
|
|
35
42
|
\`\`\`
|
|
36
43
|
|
|
37
|
-
The exception/error is: ${
|
|
44
|
+
The exception/error is: ${oe}
|
|
38
45
|
|
|
39
|
-
Please fix the Mermaid syntax and regenerate a valid diagram.`;await E({prompt:ee,isRepairFlow:!0})},O=async Z=>{let z=c.messages.findIndex(U=>U.id===Z.id);if(z>0){let U=c.messages[z-1];U.type==="user"&&typeof U.content=="string"&&(b(),await E({prompt:U.content,isRepairFlow:!0}))}},Y=()=>{zc({app:n,data:f})},Q=Z=>{let z=c.messages.findIndex(ee=>ee.id===Z&&ee.type==="assistant"),U=c.messages.slice(0,z-1);m({...c,messages:U})},q=Z=>{m(z=>({...z,currentPrompt:Z}))};return XA("div",{className:`ttd-dialog-layout ${p?"ttd-dialog-layout--split":"ttd-dialog-layout--chat-only"}`,children:[Hb(d5,{chatId:c.id,messages:c.messages,currentPrompt:c.currentPrompt,onPromptChange:q,onGenerate:E,isGenerating:h?.isGenerating??!1,generatedResponse:h?.content,isMenuOpen:x,onMenuToggle:S,onMenuClose:A,onNewChat:C,onRestoreChat:y,onDeleteChat:w,savedChats:d,activeSessionId:c.id,onAbort:v,onMermaidTabClick:N,onAiRepairClick:P,onDeleteMessage:Q,onInsertMessage:R,onRetry:O,onViewAsMermaid:M,renderWarning:t}),p&&Hb(p5,{canvasRef:i,hideErrorDetails:h?.errorType==="parse",error:l,loaded:e.loaded,onInsert:Y})]})},ZA=({mermaidToExcalidrawLib:e,onTextSubmit:o,renderWarning:t,persistenceAdapter:r})=>Hb(KA,{mermaidToExcalidrawLib:e,onTextSubmit:o,renderWarning:t,persistenceAdapter:r}),u5=ZA;import*as g5 from"@radix-ui/react-tabs";import{useRef as h5}from"react";import{jsx as $A}from"react/jsx-runtime";var f5=e=>{let o=ye(),t=h5(null),r=h5(0);return $A(g5.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let a=t.current?.closest(".Modal__content");if(a){let i=a.offsetHeight||0;i>r.current&&(r.current=i,a.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&Sd(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};f5.displayName="TTDDialogTabs";var b5=f5;import*as x5 from"@radix-ui/react-tabs";import{jsx as jA}from"react/jsx-runtime";var Ub=({children:e,...o})=>jA(x5.List,{className:"ttd-dialog-triggers",...o,children:e});Ub.displayName="TTDDialogTabTriggers";import*as E5 from"@radix-ui/react-tabs";import{jsx as y5}from"react/jsx-runtime";var Mu=({children:e,tab:o,onSelect:t,...r})=>y5(E5.Trigger,{value:o,asChild:!0,onSelect:t,children:y5("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Mu.displayName="TTDDialogTabTrigger";import*as v5 from"@radix-ui/react-tabs";import{jsx as qA}from"react/jsx-runtime";var Lu=({tab:e,children:o,...t})=>qA(v5.Content,{...t,value:e,children:o});Lu.displayName="TTDDialogTab";import{jsx as Vr,jsxs as Gb}from"react/jsx-runtime";var Wb=e=>{let o=Le();return o.openDialog?.name!=="ttd"?null:Vr(e_,{...e,tab:o.openDialog.tab})},e_=En("TTDDialogBase",({tab:e,...o})=>{let t=lt(),[r,n]=QA({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});return JA(()=>{(async()=>{await r.api,n(i=>({...i,loaded:!0}))})()},[r.api]),Vr(gt,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1520,title:!1,...o,autofocus:!1,children:Gb(b5,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?Vr("p",{className:"dialog-mermaid-title",children:u("mermaid.title")}):Gb(Ub,{children:[Vr(Mu,{tab:"text-to-diagram",children:Gb("div",{className:"ttd-dialog-tab-trigger__content",children:[u("labels.textToDiagram"),Vr("div",{className:"ttd-dialog-tab-trigger__badge",children:u("chat.aiBeta")})]})}),Vr(Mu,{tab:"mermaid",children:u("mermaid.label")})]}),!("__fallback"in o)&&Vr(Lu,{className:"ttd-dialog-content",tab:"text-to-diagram",children:Vr(u5,{mermaidToExcalidrawLib:r,onTextSubmit:o.onTextSubmit,renderWarning:o.renderWarning,persistenceAdapter:o.persistenceAdapter})}),Vr(Lu,{className:"ttd-dialog-content",tab:"mermaid",children:Vr(jT,{mermaidToExcalidrawLib:r,isActive:e==="mermaid"})})]})})});import V_ from"clsx";import K_ from"lodash.throttle";import{useEffect as R5,useMemo as $b,useState as Z_,memo as X_}from"react";import t_ from"clsx";import{useEffect as T5,useRef as Au,useState as o_}from"react";var w5=.01,Uc=10,bo=(e,o)=>!(o==="angle"&&le(e)),rt=(e,o)=>{let t=e+o/2;return t-t%o},Kl=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var hi=(e,o,t,r,n,a,i=!0)=>{if(co(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<rs&&Math.abs(o-t.y)<rs)return;yh(t,"start",r),yh(t,"end",r)}let l=r.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=Ge(L(t.x,t.y),L(c,m),t.angle),h=e-p,b=o-d,[f,E]=Ge(L(e,o),L(c+h,m+b),-t.angle);r.mutateElement(s,{x:f,y:E},{informMutation:i,isDragging:!1}),Dn(s,r,n);let v=xe(t,a);if(v){let x=l.get(v.id);x&&r.mutateElement(x,{x:v.x+h,y:v.y+b},{informMutation:i,isDragging:!1})}if(le(t)){let x=No(a,t.id);x.forEach(y=>{let w=l.get(y.id);if(!w)return;let[C,S]=[y.x+y.width/2,y.y+y.height/2],[A,M]=Ge(L(y.x,y.y),L(C,S),y.angle),N=Math.round(A+h),R=Math.round(M+b),[P,O]=Ge(L(N,R),L(C+h,S+b),-y.angle);r.mutateElement(w,{x:P,y:O},{informMutation:i,isDragging:!1}),Dn(w,r,n,{simultaneouslyUpdated:x})})}},Zl=(e,o)=>{let r=nr(o).map(n=>Ke(e,n).reduce((a,i)=>(a[i.id]=!0,a),{}));return e.filter(n=>!Rn(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Yb,jsxs as n_}from"react/jsx-runtime";var r_=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:a=!0,shouldKeepAspectRatio:i,property:l,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=lt(),h=ye(),b=Au(null),f=Au(null),[E,v]=o_(r.toString()),x=Au(null);x.current||(x.current={originalAppState:or(c),originalElements:n,lastUpdatedValue:E,updatePending:!1}),T5(()=>{let C=r.toString();v(C),x.current.lastUpdatedValue=C},[r]);let y=(C,S,A)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let M=Number(C);if(isNaN(M)){v(r.toString());return}let N=Number(M.toFixed(2)),R=Number(r);(isNaN(R)||Math.abs(N-R)>=w5)&&(x.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:i,shouldChangeByStepSize:!1,scene:s,nextValue:N,property:l,originalAppState:A,setInputValue:P=>v(String(P)),app:d,setAppState:h}),d.syncActionResult({captureUpdate:D.IMMEDIATELY}))},w=Au({});return w.current.handleInputValue=y,T5(()=>{let C=b.current,S=w.current;return()=>{let A=C?.value;A&&S.handleInputValue?.(A,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",S.onPointerMove,!1),window.removeEventListener("pointerup",S.onPointerUp,!1)}},[a]),a?n_("div",{className:t_("drag-input-container",!a&&"disabled"),"data-testid":e,children:[Yb("div",{className:"drag-input-label",ref:f,onPointerDown:C=>{if(b.current&&a){document.body.classList.add("excalidraw-cursor-resize");let S=Number(b.current.value);isNaN(S)&&(S=0);let A=null,M=d.scene.getNonDeletedElements().reduce((q,Z)=>(q.set(Z.id,ar(Z)),q),new Map),N=n.map(q=>M.get(q.id)),R=or(c),P=0,O=0,Y=q=>{if(A&&M!==null&&N!==null){let Z=q.clientX-A.x;Z!==0&&(O+=Z,Math.abs(O)>=m&&(O=Math.sign(O)*Math.floor(Math.abs(O)/m),P+=O,t({accumulatedChange:P,instantChange:O,originalElements:N,originalElementsMap:M,shouldKeepAspectRatio:i,shouldChangeByStepSize:q.shiftKey,property:l,scene:s,originalAppState:R,setInputValue:z=>v(String(z)),app:d,setAppState:h}),O=0))}A={x:q.clientX,y:q.clientY}},Q=()=>{window.removeEventListener("pointermove",Y,!1),d.syncActionResult({captureUpdate:D.IMMEDIATELY}),p?.({app:d,setAppState:h,originalElements:N,originalAppState:R}),A=null,P=0,O=0,N=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",Q,!1)};w.current.onPointerMove=Y,w.current.onPointerUp=Q,window.addEventListener("pointermove",Y,!1),window.addEventListener("pointerup",Q,!1)}},onPointerEnter:()=>{f.current&&(f.current.style.cursor="ew-resize")},children:o?Yb(_r,{icon:o}):e}),Yb("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(a){let S=C.target;S instanceof HTMLInputElement&&C.key===T.ENTER&&(y(S.value,n,c),d.focusContainer())}},ref:b,value:E,onChange:C=>{x.current.updatePending=!0,v(C.target.value)},onFocus:C=>{C.target.select(),x.current.originalElements=n,x.current.originalAppState=or(c)},onBlur:C=>{E?a&&y(C.target.value,x.current.originalElements,x.current.originalAppState):v(r.toString())},disabled:!a})]}):null},Ot=r_;import{jsx as s_}from"react/jsx-runtime";var a_=15,i_=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n,app:a})=>{let i=n.getNonDeletedElementsMap(),l=o[0];if(l&&!Se(l)){let s=i.get(l.id);if(!s)return;if(r!==void 0){let b=fi(r);n.mutateElement(s,{angle:b}),Dn(s,n,a.state);let f=xe(s,i);f&&!Me(s)&&n.mutateElement(f,{angle:b});return}let c=Math.round(bi(l.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=rt(p,a_)),p=p<0?p+360:p;let d=fi(p);n.mutateElement(s,{angle:d}),Dn(s,n,a.state);let h=xe(s,i);h&&!Me(s)&&n.mutateElement(h,{angle:d})}},l_=({element:e,scene:o,appState:t,property:r})=>s_(Ot,{label:"A",icon:Hs,value:Math.round(bi(e.angle)%360*100)/100,elements:[e],dragInputCallback:i_,editable:bo(e,"angle"),scene:o,appState:t,property:r}),C5=l_;import{jsx as d_}from"react/jsx-runtime";var I5=5,c_=({property:e,scene:o,appState:t,setAppState:r})=>d_(Ot,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:a,shouldChangeByStepSize:i,setInputValue:l})=>{r(s=>{let c;return n?c=n:a&&(c=i?rt(s.gridStep+I5*Math.sign(a),I5):s.gridStep+a),c?(c=rE(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),k5=c_;import{jsx as g_}from"react/jsx-runtime";var S5=10,m_=e=>e.type==="image",p_=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:a,property:i,originalAppState:l,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),h=o[0],b=d.get(h.id);if(h&&b){let f=r||m_(h),E=h.width/h.height;if(l.croppingElementId===h.id){let v=d.get(h.id);if(!v||!Ue(v)||!v.crop)return;let x=v.crop,y={...x},w=v.scale[0]===-1,C=v.scale[1]===-1,{width:S,height:A}=wa(v),M=x.naturalWidth/S,N=x.naturalHeight/A,R=w?x.width+x.x:x.naturalWidth-x.x,P=C?x.height+x.y:x.naturalHeight-x.y,O=mh*M,Y=mh*N;if(a!==void 0){if(i==="width"){let U=a*M,ee=$e(U,O,R);y={...y,width:ee,x:w?x.x+x.width-ee:x.x}}else if(i==="height"){let U=a*N,ee=$e(U,Y,P);y={...y,height:ee,y:C?x.y+x.height-ee:x.y}}c.mutateElement(v,{crop:y,width:y.width/(x.naturalWidth/S),height:y.height/(x.naturalHeight/A)});return}let Q=i==="width"?s:0,q=i==="height"?s:0,Z=$e(x.width+Q,O,R),z=$e(x.height+q,O,P);y={...x,x:w?x.x+x.width-Z:x.x,y:C?x.y+x.height-z:x.y,width:Z,height:z},c.mutateElement(v,{crop:y,width:y.width/(x.naturalWidth/S),height:y.height/(x.naturalHeight/A)});return}if(a!==void 0){let v=Math.max(i==="width"?a:f?a*E:h.width,io),x=Math.max(i==="height"?a:f?a/E:h.height,io);if(Fi(v,x,b,h,t,c,i==="width"?"e":"s",{shouldMaintainAspectRatio:f}),le(b)){let y=mo(c.getElementsIncludingDeleted(),b,l,c.getNonDeletedElementsMap()),w=br(c.getElementsIncludingDeleted(),y,b,m);c.replaceAllElements(w)}return}{let v=i==="width"?e:0,x=i==="height"?e:0,y=Math.max(0,h.width+v);i==="width"&&(n?y=rt(y,S5):y=Math.round(y));let w=Math.max(0,h.height+x);if(i==="height"&&(n?w=rt(w,S5):w=Math.round(w)),f&&(i==="width"?w=Math.round(y/E*100)/100:y=Math.round(w*E*100)/100),w=Math.max(io,w),y=Math.max(io,y),Fi(y,w,b,h,t,c,i==="width"?"e":"s",{shouldMaintainAspectRatio:f}),le(b)){let C=mo(c.getElementsIncludingDeleted(),b,l,c.getNonDeletedElementsMap());p({elementsToHighlight:C})}}}},u_=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),a=t?.[0],i=a&&n.get(a.id);if(i&&le(i)){let l=mo(o.scene.getElementsIncludingDeleted(),i,r,o.scene.getNonDeletedElementsMap()),s=br(o.scene.getElementsIncludingDeleted(),l,i,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},h_=({property:e,element:o,scene:t,appState:r})=>{let n=Mo(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&Ue(o)&&o.crop){let{width:a,height:i}=wa(o);if(e==="width"){let l=a/o.crop.naturalWidth;n=Mo(o.crop.width*l,2)}if(e==="height"){let l=i/o.crop.naturalHeight;n=Mo(o.crop.height*l,2)}}return g_(Ot,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:p_,value:n,editable:bo(o,e),scene:t,appState:r,property:e,dragFinishedCallback:u_})},Vb=h_;import{jsx as y_}from"react/jsx-runtime";var M5=4,f_=4,b_=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let a=n.getNonDeletedElementsMap(),i=o[0];if(i){let l=a.get(i.id);if(!l||!$(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),M5);else if(i.type==="text"){let c=Math.round(i.fontSize),m=Math.round(e);s=Math.max(c+m,M5),t&&(s=rt(s,f_))}s&&(n.mutateElement(l,{fontSize:s}),ut(l,n.getContainerElement(l),n))}},x_=({element:e,scene:o,appState:t,property:r})=>{let n=$(e)?e:ft(e)?xe(e,o.getNonDeletedElementsMap()):null;return n?y_(Ot,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:b_,icon:Hn,appState:t,scene:o,property:r}):null},L5=x_;import{jsx as T_}from"react/jsx-runtime";var E_=15,v_=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:a})=>{let i=a.getNonDeletedElementsMap(),l=o.map(c=>i.get(c.id)).filter(c=>c&&!Rn(c)&&bo(c,n)),s=o.filter(c=>!Rn(c)&&bo(c,n));if(r!==void 0){let c=fi(r);for(let m of l){if(!m)continue;a.mutateElement(m,{angle:c});let p=xe(m,i);p&&!Me(m)&&a.mutateElement(p,{angle:c})}a.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let p=s[c],d=Math.round(bi(p.angle)*100)/100,h=Math.round(e),b=(d+h)%360;t&&(b=rt(b,E_)),b=b<0?b+360:b;let f=fi(b);a.mutateElement(m,{angle:f});let E=xe(m,i);E&&!Me(m)&&a.mutateElement(E,{angle:f})}a.triggerUpdate()},w_=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!Rn(s)&&bo(s,"angle")),a=n.map(s=>Math.round(bi(s.angle)%360*100)/100),i=new Set(a).size===1?a[0]:"Mixed",l=n.some(s=>bo(s,"angle"));return T_(Ot,{label:"A",icon:Hs,value:i,elements:e,dragInputCallback:v_,editable:l,appState:t,scene:o,property:r})},A5=w_;import{useMemo as C_}from"react";import{jsx as A_}from"react/jsx-runtime";var Xl=10,I_=(e,o,t,r)=>{let n=r.x-e,a=r.y-o,i=r.width*t,l=r.height*t,s=e+n*t,c=o+a*t;return{width:i,height:l,x:s,y:c,...Yy(r,i,l,!1),...$(r)?{fontSize:r.fontSize*t}:{}}},k_=(e,o,t,r,n,a,i,l)=>{let s=l.getNonDeletedElementsMap(),c=I_(e,o,r,a);l.mutateElement(n,c);let m=xe(a,i);if(m){let p=m.fontSize*r;on(n,l);let d=s.get(m.id);d&&$(d)&&(l.mutateElement(d,{fontSize:p}),Zx(n,l,t==="width"?"e":"s",!0))}},_5=(e,o,t,r,n,a,i,l,s,c)=>{a==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let p=0;p<l.length;p++){let d=l[p],h=i[p];k_(n[0],n[1],a,m,h,d,s,c)}},S_=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:a,scene:i,property:l,setAppState:s,app:c})=>{let m=i.getNonDeletedElementsMap(),p=Zl(o,r);if(a!==void 0){for(let f of p){let E=Kl(f,m,t);if(E.length>1){let v=E.map(O=>O.latest),x=E.map(O=>O.original),[y,w,C,S]=_e(x),A=C-y,M=S-w,N=A/M,R=Math.max(io,l==="width"?Math.max(0,a):A),P=Math.max(io,l==="height"?Math.max(0,a):M);_5(R,P,M,N,L(y,w),l,v,x,t,i)}else{let[v]=E,x=v?.latest,y=v?.original;if(x&&y&&bo(x,l)){let w=l==="width"?Math.max(0,a):x.width;l==="width"&&(n?w=rt(w,Xl):w=Math.round(w));let C=l==="height"?Math.max(0,a):x.height;if(l==="height"&&(n?C=rt(C,Xl):C=Math.round(C)),w=Math.max(io,w),C=Math.max(io,C),Fi(w,C,x,y,t,i,l==="width"?"e":"s",{shouldInformMutation:!1}),le(x)){let S=mo(i.getElementsIncludingDeleted(),x,r,i.getNonDeletedElementsMap()),A=br(i.getElementsIncludingDeleted(),S,x,c);i.replaceAllElements(A)}}}}i.triggerUpdate();return}let d=l==="width"?e:0,h=l==="height"?e:0,b=[];for(let f of p){let E=Kl(f,m,t);if(E.length>1){let v=E.map(O=>O.latest),x=E.map(O=>O.original),[y,w,C,S]=_e(x),A=C-y,M=S-w,N=A/M,R=Math.max(0,A+d);l==="width"&&(n?R=rt(R,Xl):R=Math.round(R));let P=Math.max(0,M+h);l==="height"&&(n?P=rt(P,Xl):P=Math.round(P)),R=Math.max(io,R),P=Math.max(io,P),_5(R,P,M,N,L(y,w),l,v,x,t,i)}else{let[v]=E,x=v?.latest,y=v?.original;if(x&&y&&bo(x,l)){let w=Math.max(0,y.width+d);l==="width"&&(n?w=rt(w,Xl):w=Math.round(w));let C=Math.max(0,y.height+h);if(l==="height"&&(n?C=rt(C,Xl):C=Math.round(C)),w=Math.max(io,w),C=Math.max(io,C),Fi(w,C,x,y,t,i,l==="width"?"e":"s",{shouldInformMutation:!1}),le(x)){let S=mo(i.getElementsIncludingDeleted(),x,r,i.getNonDeletedElementsMap());b.push(...S)}}}}s({elementsToHighlight:b}),i.triggerUpdate()},M_=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),a=t?.[0],i=a&&n.get(a.id);if(i&&le(i)){let l=mo(o.scene.getElementsIncludingDeleted(),i,r,o.scene.getNonDeletedElementsMap()),s=br(o.scene.getElementsIncludingDeleted(),l,i,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},L_=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:a})=>{let i=C_(()=>r.map(c=>{let m=Kl(c,t);if(m.length>1){let[d,h,b,f]=_e(m.map(E=>E.latest));return Math.round((e==="width"?b-d:f-h)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,r,e]),l=new Set(i).size===1?Math.round(i[0]*100)/100:"Mixed",s=i.length>0;return A_(Ot,{label:e==="width"?"W":"H",elements:o,dragInputCallback:S_,value:l,editable:s,appState:a,property:e,scene:n,dragFinishedCallback:M_})},Kb=L_;import{jsx as N_}from"react/jsx-runtime";var P5=4,__=4,P_=(e,o)=>e.reduce((t,r)=>{if(!r||Rn(r))return t;if($(r))return t.push(r),t;if(ft(r)){let n=xe(r,o);if(n)return t.push(n),t}return t},[]),D_=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let a=n.getNonDeletedElementsMap(),i=o.map(s=>a.get(s.id)),l;if(r){l=Math.max(Math.round(r),P5);for(let s of i)n.mutateElement(s,{fontSize:l}),ut(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let c=0;c<i.length;c++){let m=i[c],p=s[c],d=Math.round(p.fontSize),h=Math.round(e),b=Math.max(d+h,P5);t&&(b=rt(b,__)),n.mutateElement(m,{fontSize:b}),ut(m,n.getContainerElement(m),n)}n.triggerUpdate()}},R_=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let a=P_(e,n);if(!a.length)return null;let i=a.map(c=>Math.round(c.fontSize*10)/10),l=new Set(i).size===1?i[0]:"Mixed",s=i.length>0;return N_(Ot,{label:"F",icon:Hn,elements:a,dragInputCallback:D_,value:l,editable:s,scene:o,property:r,appState:t})},D5=R_;import{useMemo as O_}from"react";import{jsx as U_}from"react/jsx-runtime";var z_=(e,o,t,r,n,a,i)=>{for(let l=0;l<r.length;l++){let s=r[l],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=Ge(L(s.x,s.y),L(c,m),s.angle),h=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(d+t):d;hi(h,b,s,a,i,n,!1)}},B_=(e,o,t,r,n,a)=>{let i=n.getNonDeletedElementsMap(),[l,s,,]=_e(t),c=e-l,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],h=i.get(d.id);if(h&&(!$(h)||!h.containerId)){let[b,f]=[h.x+h.width/2,h.y+h.height/2],[E,v]=Ge(L(h.x,h.y),L(b,f),h.angle);hi(E+c,v+m,d,n,a,r,!1)}}},F_=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:a,scene:i,originalAppState:l,app:s})=>{let c=i.getNonDeletedElementsMap();if(n!==void 0){for(let h of Zl(o,l)){let b=Kl(h,c,t);if(b.length>1){let[f,E,,]=_e(b.map(y=>y.latest));B_(a==="x"?n:f,a==="y"?n:E,b.map(y=>y.original),t,i,s.state)}else{let f=b[0]?.original,E=b[0]?.latest;if(f&&E&&bo(E,a)){let[v,x]=[f.x+f.width/2,f.y+f.height/2],[y,w]=Ge(L(f.x,f.y),L(v,x),f.angle);hi(a==="x"?n:y,a==="y"?n:w,f,i,s.state,t,!1)}}}i.triggerUpdate();return}let m=r?rt(e,Uc):e;z_(a,a==="x"?m:0,a==="y"?m:0,o,t,i,s.state),i.triggerUpdate()},H_=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:a})=>{let i=O_(()=>r.map(s=>{let c=Object.keys(s).map(f=>t.get(f)).filter(f=>f!==void 0);if(c.length>1){let[f,E]=_e(c);return Math.round((e==="x"?f:E)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[h,b]=Ge(L(m.x,m.y),L(p,d),m.angle);return Math.round((e==="x"?h:b)*100)/100}),[r,t,e]),l=new Set(i).size===1?i[0]:"Mixed";return U_(Ot,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:F_,value:l,property:e,scene:n,appState:a})},Zb=H_;import{jsx as Y_}from"react/jsx-runtime";var G_=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:a,property:i,scene:l,originalAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=t[0],[d,h]=[p.x+p.width/2,p.y+p.height/2],[b,f]=Ge(L(p.x,p.y),L(d,h),p.angle);if(s.croppingElementId===p.id){let w=m.get(p.id);if(!w||!Ue(w)||!w.crop)return;let C=w.crop,S=C,A=w.scale[0]===-1,M=w.scale[1]===-1,{width:N,height:R}=wa(w);if(a!==void 0){if(i==="x"){let Y=a*(C.naturalWidth/N);A?S={...C,x:$e(C.naturalWidth-Y-C.width,0,C.naturalWidth-C.width)}:S={...C,x:$e(a*(C.naturalWidth/N),0,C.naturalWidth-C.width)}}i==="y"&&(S={...C,y:$e(a*(C.naturalHeight/R),0,C.naturalHeight-C.height)}),l.mutateElement(w,{crop:S});return}let P=(i==="x"?o:0)*(A?-1:1),O=(i==="y"?o:0)*(M?-1:1);S={...C,x:$e(C.x+P,0,C.naturalWidth-C.width),y:$e(C.y+O,0,C.naturalHeight-C.height)},l.mutateElement(w,{crop:S});return}if(a!==void 0){hi(i==="x"?a:b,i==="y"?a:f,p,l,c.state,r);return}let E=i==="x"?e:0,v=i==="y"?e:0,x=i==="x"?Math.round(n?rt(p.x+E,Uc):b+E):b,y=i==="y"?Math.round(n?rt(p.y+v,Uc):f+v):f;hi(x,y,p,l,c.state,r)},W_=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[a,i]=Ge(L(o.x,o.y),L(o.x+o.width/2,o.y+o.height/2),o.angle),l=Mo(e==="x"?a:i,2);if(n.croppingElementId===o.id&&Ue(o)&&o.crop){let s=Lx(o);s&&(l=Mo(e==="x"?s.x:s.y,2))}return Y_(Ot,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:G_,scene:r,value:l,property:e,appState:n})},Xb=W_;import{Fragment as jb,jsx as se,jsxs as xo}from"react/jsx-runtime";var $_=50,Gc=e=>{let o=Lr(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=ta(e.app);return se(j_,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Je=({children:e,columns:o=1,heading:t,style:r,...n})=>se("div",{className:V_("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Je.displayName="StatsRow";var _u=({children:e,order:o,style:t,...r})=>se("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});_u.displayName="StatsRows";Gc.StatsRow=Je;Gc.StatsRows=_u;var j_=X_(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:a,gridModeEnabled:i})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=ye(),p=r.length===1?r[0]:null,d=r.length>1?r:null,h=n.croppingElementId&&Ue(p),b=h?wa(p):null,[f,E]=Z_({width:0,height:0}),v=$b(()=>K_(w=>{let C=_e(w);E({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},$_),[]);R5(()=>{v(s)},[a,s,v]),R5(()=>()=>v.cancel(),[v]);let x=$b(()=>Zl(r,n),[r,n]),y=$b(()=>$d(r),[r]);return se("div",{className:"exc-stats",children:xo(xt,{padding:3,children:[xo("div",{className:"title",children:[se("h2",{children:u("stats.title")}),se("div",{className:"close",onClick:o,children:wo})]}),xo(rc,{label:se("h3",{children:u("stats.generalStats")}),open:!!(n.stats.panels&ss.generalStats),openTrigger:()=>m(w=>({stats:{open:!0,panels:w.stats.panels^ss.generalStats}})),children:[xo(_u,{children:[se(Je,{heading:!0,children:u("stats.scene")}),xo(Je,{columns:2,children:[se("div",{children:u("stats.shapes")}),se("div",{children:s.length})]}),xo(Je,{columns:2,children:[se("div",{children:u("stats.width")}),se("div",{children:f.width})]}),xo(Je,{columns:2,children:[se("div",{children:u("stats.height")}),se("div",{children:f.height})]}),i&&xo(jb,{children:[se(Je,{heading:!0,children:"Canvas"}),se(Je,{children:se(k5,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&se("div",{id:"elementStats",style:{marginTop:12},children:se(rc,{label:se("h3",{children:u("stats.elementProperties")}),open:!!(n.stats.panels&ss.elementProperties),openTrigger:()=>m(w=>({stats:{open:!0,panels:w.stats.panels^ss.elementProperties}})),children:xo(_u,{children:[p&&xo(jb,{children:[h&&se(Je,{heading:!0,children:u("labels.unCroppedDimension")}),n.croppingElementId&&Ue(p)&&b&&xo(Je,{columns:2,children:[se("div",{children:u("stats.width")}),se("div",{children:Mo(b.width,2)})]}),n.croppingElementId&&Ue(p)&&b&&xo(Je,{columns:2,children:[se("div",{children:u("stats.height")}),se("div",{children:Mo(b.height,2)})]}),se(Je,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?u("labels.imageCropping"):u(`element.${p.type}`)}),se(Je,{children:se(Xb,{element:p,property:"x",elementsMap:c,scene:l,appState:n})}),se(Je,{children:se(Xb,{element:p,property:"y",elementsMap:c,scene:l,appState:n})}),se(Je,{children:se(Vb,{property:"width",element:p,scene:l,appState:n})}),se(Je,{children:se(Vb,{property:"height",element:p,scene:l,appState:n})}),se(Je,{children:se(C5,{property:"angle",element:p,scene:l,appState:n})}),se(Je,{children:se(L5,{property:"fontSize",element:p,scene:l,appState:n})})]}),d&&xo(jb,{children:[Yd(d)&&se(Je,{heading:!0,children:u("element.group")}),xo(Je,{columns:2,style:{margin:"0.3125rem 0"},children:[se("div",{children:u("stats.shapes")}),se("div",{children:r.length})]}),se(Je,{children:se(Zb,{property:"x",elements:d,elementsMap:c,atomicUnits:x,scene:l,appState:n})}),se(Je,{children:se(Zb,{property:"y",elements:d,elementsMap:c,atomicUnits:x,scene:l,appState:n})}),se(Je,{children:se(Kb,{property:"width",elements:d,elementsMap:c,atomicUnits:x,scene:l,appState:n})}),se(Je,{children:se(Kb,{property:"height",elements:d,elementsMap:c,atomicUnits:x,scene:l,appState:n})}),se(Je,{children:se(A5,{property:"angle",elements:d,scene:l,appState:n})}),se(Je,{children:se(D5,{property:"fontSize",elements:d,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as q_,useEffect as N5,useState as O5}from"react";import{jsx as $l,jsxs as Pu}from"react/jsx-runtime";var J_=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=em})=>{let a=r.getNonDeletedElementsMap(),i=a.get(e)?.link??null,[l,s]=O5(i),[c,m]=O5(!1);N5(()=>{let d=ae(a,t),h=i;if(d.length>0&&n){let b=tm(d,t);b&&(h=rr(n(b.id,b.type)))}s(h)},[a,t,t.selectedElementIds,i,n]);let p=q_(()=>{if(l&&l!==a.get(e)?.link){let d=a.get(e);d&&r.mutateElement(d,{link:l})}if(!l&&c&&e){let d=a.get(e);d&&r.mutateElement(d,{link:null})}o?.()},[e,l,a,c,r,o]);return N5(()=>{let d=h=>{t.openDialog?.name==="elementLinkSelector"&&h.key===T.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&h.key===T.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),Pu("div",{className:"ElementLinkDialog",children:[Pu("div",{className:"ElementLinkDialog__header",children:[$l("h2",{children:u("elementLink.title")}),$l("p",{children:u("elementLink.desc")})]}),Pu("div",{className:"ElementLinkDialog__input",children:[$l(Qn,{value:l??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===T.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),i&&l&&$l(J,{type:"button",title:u("buttons.remove"),"aria-label":u("buttons.remove"),label:u("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:_t})]}),Pu("div",{className:"ElementLinkDialog__actions",children:[$l(hn,{label:u("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),$l(hn,{label:u("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},z5=J_;import Q_,{useState as e8}from"react";import{Fragment as t8,jsx as qb}from"react/jsx-runtime";var B5=({children:e,onClose:o})=>{let[t,r]=e8(!!e),{container:n}=qe(),a=Q_.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return qb(t8,{children:t&&qb(gt,{size:"small",onCloseRequest:a,title:u("errorDialog.title"),children:qb("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import o8 from"react";import{Fragment as H5,jsx as W,jsxs as ko}from"react/jsx-runtime";var r8=()=>ko("div",{className:"HelpDialog__header",children:[ko("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[W("div",{className:"HelpDialog__link-icon",children:vm}),u("helpDialog.documentation")]}),ko("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[W("div",{className:"HelpDialog__link-icon",children:vm}),u("helpDialog.blog")]}),ko("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:Ns}),u("helpDialog.github")]}),ko("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[W("div",{className:"HelpDialog__link-icon",children:_f}),"YouTube"]})]}),n8=e=>ko(H5,{children:[W("h3",{children:e.title}),W("div",{className:"HelpDialog__islands-container",children:e.children})]}),Jb=e=>ko("div",{className:`HelpDialog__island ${e.className}`,children:[W("h4",{className:"HelpDialog__island-title",children:e.caption}),W("div",{className:"HelpDialog__island-content",children:e.children})]});function*a8(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var i8=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),K=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(i=>W(l8,{children:i8(i)},i)));return ko("div",{className:"HelpDialog__shortcut",children:[W("div",{children:e}),W("div",{className:"HelpDialog__key-container",children:[...a8(r,t?u("helpDialog.or"):null)]})]})},l8=e=>W("kbd",{className:"HelpDialog__key",...e}),F5=({onClose:e})=>{let o=o8.useCallback(()=>{e&&e()},[e]);return W(H5,{children:ko(gt,{onCloseRequest:o,title:u("helpDialog.title"),className:"HelpDialog",children:[W(r8,{}),ko(n8,{title:u("helpDialog.shortcuts"),children:[ko(Jb,{className:"HelpDialog__island--tools",caption:u("helpDialog.tools"),children:[W(K,{label:u("toolBar.hand"),shortcuts:[T.H]}),W(K,{label:u("toolBar.selection"),shortcuts:[T.V,T[1]]}),W(K,{label:u("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),W(K,{label:u("toolBar.diamond"),shortcuts:[T.D,T[3]]}),W(K,{label:u("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),W(K,{label:u("toolBar.arrow"),shortcuts:[T.A,T[5]]}),W(K,{label:u("toolBar.line"),shortcuts:[T.L,T[6]]}),W(K,{label:u("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),W(K,{label:u("toolBar.text"),shortcuts:[T.T,T[8]]}),W(K,{label:u("toolBar.image"),shortcuts:[T[9]]}),W(K,{label:u("toolBar.eraser"),shortcuts:[T.E,T[0]]}),W(K,{label:u("toolBar.frame"),shortcuts:[T.F]}),W(K,{label:u("toolBar.laser"),shortcuts:[T.K]}),W(K,{label:u("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),W(K,{label:u("helpDialog.editLineArrowPoints"),shortcuts:[B("CtrlOrCmd+Enter")]}),W(K,{label:u("helpDialog.editText"),shortcuts:[B("Enter")]}),W(K,{label:u("helpDialog.textNewLine"),shortcuts:[B("Enter"),B("Shift+Enter")]}),W(K,{label:u("helpDialog.textFinish"),shortcuts:[B("Esc"),B("CtrlOrCmd+Enter")]}),W(K,{label:u("helpDialog.curvedArrow"),shortcuts:["A",u("helpDialog.click"),u("helpDialog.click"),u("helpDialog.click")],isOr:!1}),W(K,{label:u("helpDialog.curvedLine"),shortcuts:["L",u("helpDialog.click"),u("helpDialog.click"),u("helpDialog.click")],isOr:!1}),W(K,{label:u("helpDialog.cropStart"),shortcuts:[u("helpDialog.doubleClick"),B("Enter")],isOr:!0}),W(K,{label:u("helpDialog.cropFinish"),shortcuts:[B("Enter"),B("Escape")],isOr:!0}),W(K,{label:u("toolBar.lock"),shortcuts:[T.Q]}),W(K,{label:u("helpDialog.preventBinding"),shortcuts:[B("CtrlOrCmd")]}),W(K,{label:u("toolBar.link"),shortcuts:[B("CtrlOrCmd+K")]}),W(K,{label:u("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ko(Jb,{className:"HelpDialog__island--view",caption:u("helpDialog.view"),children:[W(K,{label:u("buttons.zoomIn"),shortcuts:[B("CtrlOrCmd++")]}),W(K,{label:u("buttons.zoomOut"),shortcuts:[B("CtrlOrCmd+-")]}),W(K,{label:u("buttons.resetZoom"),shortcuts:[B("CtrlOrCmd+0")]}),W(K,{label:u("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),W(K,{label:u("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),W(K,{label:u("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),W(K,{label:u("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),W(K,{label:u("buttons.zenMode"),shortcuts:[B("Alt+Z")]}),W(K,{label:u("buttons.objectsSnapMode"),shortcuts:[B("Alt+S")]}),W(K,{label:u("labels.toggleGrid"),shortcuts:[B("CtrlOrCmd+'")]}),W(K,{label:u("labels.viewMode"),shortcuts:[B("Alt+R")]}),W(K,{label:u("labels.toggleTheme"),shortcuts:[B("Alt+Shift+D")]}),W(K,{label:u("stats.fullTitle"),shortcuts:[B("Alt+/")]}),W(K,{label:u("search.title"),shortcuts:[ht("searchMenu")]}),W(K,{label:u("commandPalette.title"),shortcuts:Jr?[ht("commandPalette")]:[ht("commandPalette"),ht("commandPalette",1)]})]}),ko(Jb,{className:"HelpDialog__island--editor",caption:u("helpDialog.editor"),children:[W(K,{label:u("helpDialog.createFlowchart"),shortcuts:[B("CtrlOrCmd+Arrow Key")],isOr:!0}),W(K,{label:u("helpDialog.navigateFlowchart"),shortcuts:[B("Alt+Arrow Key")],isOr:!0}),W(K,{label:u("labels.moveCanvas"),shortcuts:[B(`Space+${u("helpDialog.drag")}`),B(`Wheel+${u("helpDialog.drag")}`)],isOr:!0}),W(K,{label:u("buttons.clearReset"),shortcuts:[B("CtrlOrCmd+Delete")]}),W(K,{label:u("labels.delete"),shortcuts:[B("Delete")]}),W(K,{label:u("labels.cut"),shortcuts:[B("CtrlOrCmd+X")]}),W(K,{label:u("labels.copy"),shortcuts:[B("CtrlOrCmd+C")]}),W(K,{label:u("labels.paste"),shortcuts:[B("CtrlOrCmd+V")]}),W(K,{label:u("labels.pasteAsPlaintext"),shortcuts:[B("CtrlOrCmd+Shift+V")]}),W(K,{label:u("labels.selectAll"),shortcuts:[B("CtrlOrCmd+A")]}),W(K,{label:u("labels.multiSelect"),shortcuts:[B(`Shift+${u("helpDialog.click")}`)]}),W(K,{label:u("helpDialog.deepSelect"),shortcuts:[B(`CtrlOrCmd+${u("helpDialog.click")}`)]}),W(K,{label:u("helpDialog.deepBoxSelect"),shortcuts:[B(`CtrlOrCmd+${u("helpDialog.drag")}`)]}),(pl||Jr)&&W(K,{label:u("labels.copyAsPng"),shortcuts:[B("Shift+Alt+C")]}),W(K,{label:u("labels.copyStyles"),shortcuts:[B("CtrlOrCmd+Alt+C")]}),W(K,{label:u("labels.pasteStyles"),shortcuts:[B("CtrlOrCmd+Alt+V")]}),W(K,{label:u("labels.sendToBack"),shortcuts:[lo?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")]}),W(K,{label:u("labels.bringToFront"),shortcuts:[lo?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")]}),W(K,{label:u("labels.sendBackward"),shortcuts:[B("CtrlOrCmd+[")]}),W(K,{label:u("labels.bringForward"),shortcuts:[B("CtrlOrCmd+]")]}),W(K,{label:u("labels.alignTop"),shortcuts:[B("CtrlOrCmd+Shift+Up")]}),W(K,{label:u("labels.alignBottom"),shortcuts:[B("CtrlOrCmd+Shift+Down")]}),W(K,{label:u("labels.alignLeft"),shortcuts:[B("CtrlOrCmd+Shift+Left")]}),W(K,{label:u("labels.alignRight"),shortcuts:[B("CtrlOrCmd+Shift+Right")]}),W(K,{label:u("labels.duplicateSelection"),shortcuts:[B("CtrlOrCmd+D"),B(`Alt+${u("helpDialog.drag")}`)]}),W(K,{label:u("helpDialog.toggleElementLock"),shortcuts:[B("CtrlOrCmd+Shift+L")]}),W(K,{label:u("buttons.undo"),shortcuts:[B("CtrlOrCmd+Z")]}),W(K,{label:u("buttons.redo"),shortcuts:yd?[B("CtrlOrCmd+Y"),B("CtrlOrCmd+Shift+Z")]:[B("CtrlOrCmd+Shift+Z")]}),W(K,{label:u("labels.group"),shortcuts:[B("CtrlOrCmd+G")]}),W(K,{label:u("labels.ungroup"),shortcuts:[B("CtrlOrCmd+Shift+G")]}),W(K,{label:u("labels.flipHorizontal"),shortcuts:[B("Shift+H")]}),W(K,{label:u("labels.flipVertical"),shortcuts:[B("Shift+V")]}),W(K,{label:u("labels.showStroke"),shortcuts:[B("S")]}),W(K,{label:u("labels.showBackground"),shortcuts:[B("G")]}),W(K,{label:u("labels.showFonts"),shortcuts:[B("Shift+F")]}),W(K,{label:u("labels.decreaseFontSize"),shortcuts:[B("CtrlOrCmd+Shift+<")]}),W(K,{label:u("labels.increaseFontSize"),shortcuts:[B("CtrlOrCmd+Shift+>")]})]})]})]})})};import{jsx as Qb}from"react/jsx-runtime";var ze=e=>Array.isArray(e)?`<kbd>${e.map(B).join(" + ")}</kbd>`:`<kbd>${B(e)}</kbd>`,s8=({appState:e,isMobile:o,editorInterface:t,app:r})=>{let{activeTool:n,isResizing:a,isRotating:i,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===Yt.name&&e.openSidebar.tab===Zr&&e.searchMatches?.matches.length)return u("hints.dismissSearch",{shortcut:ze("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(po(e))return u("hints.eraserRevert",{shortcut:ze("Alt")});let c=r.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return u("hints.arrowBindModifiers",{shortcut_1:ze("Ctrl"),shortcut_2:ze("Alt")});if(n.type==="arrow"||n.type==="line")return s?u("hints.linearElementMulti",{shortcut_1:ze("Escape"),shortcut_2:ze("Enter")}):n.type==="arrow"?u("hints.arrowTool",{shortcut:ze("A")}):u("hints.linearElement");if(n.type==="freedraw")return u("hints.freeDraw");if(n.type==="text")return u("hints.text");if(n.type==="embeddable")return u("hints.embeddable");if(a&&l==="mouse"&&c.length===1){let m=c[0];return ge(m)&&m.points.length===2?u("hints.lockAngle",{shortcut:ze("Shift")}):Ue(m)?u("hints.resizeImage",{shortcut_1:ze("Shift"),shortcut_2:ze("Alt")}):u("hints.resize",{shortcut_1:ze("Shift"),shortcut_2:ze("Alt")})}if(i&&l==="mouse")return u("hints.rotate",{shortcut:ze("Shift")});if(c.length===1&&$(c[0]))return u("hints.text_selected",{shortcut:ze("Enter")});if(e.editingTextElement)return u("hints.text_editing",{shortcut_1:ze("Escape"),shortcut_2:ze(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return u("hints.leaveCropEditor",{shortcut_1:ze("Enter"),shortcut_2:ze("Escape")});if(c.length===1&&Ue(c[0]))return u("hints.enterCropEditor",{shortcut:ze("Enter")});if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return u("hints.deepBoxSelect",{shortcut:ze("CtrlOrCmd")});if(ta(r)&&e.selectedElementsAreBeingDragged)return u("hints.disableSnapping",{shortcut:ze("CtrlOrCmd")});if(!c.length&&!o)return u("hints.canvasPanning",{shortcut_1:ze(u("keys.mmb")),shortcut_2:ze("Space")});if(c.length===1){if(ge(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?u("hints.lineEditor_pointSelected",{shortcut_1:ze("Delete"),shortcut_2:ze(["CtrlOrCmd","D"])}):u("hints.lineEditor_nothingSelected",{shortcut_1:ze("Shift"),shortcut_2:ze("Alt")}):tt(c[0])?u("hints.lineEditor_line_info",{shortcut:ze("Enter")}):u("hints.lineEditor_info",{shortcut_1:ze("CtrlOrCmd"),shortcut_2:ze(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&en(c[0])){let m=u("hints.bindTextToElement",{shortcut:ze("Enter")}),p=u("hints.createFlowchart",{shortcut:ze(["CtrlOrCmd","\u2191\u2193"])});return Rd(c[0])?Hy(c[0],r.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},U5=({appState:e,isMobile:o,editorInterface:t,app:r})=>{let n=s8({appState:e,isMobile:o,editorInterface:t,app:r});if(!n)return null;let i=(Array.isArray(n)?n.map(l=>l.replace(/\. ?$/,"")).join(", "):n).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,s)=>{if(s%2===1){let c=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return Qb("kbd",{children:c?c[1]:l},s)}return l});return Qb("div",{className:"HintViewer",children:Qb("span",{children:i})})};import{useEffect as Y5,useRef as h8,useState as la}from"react";import{useCallback as c8,useRef as d8,useState as m8}from"react";var p8=2e3,G5=()=>{let[e,o]=m8(null),t=d8(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},p8)},n=c8(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import u8 from"clsx";import{jsx as W5}from"react/jsx-runtime";var Wc=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>W5("div",{className:u8("Switch",{toggled:t,disabled:n}),children:W5("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:a=>{a.key===" "&&r(!t)}})});import{jsx as Qe,jsxs as sa}from"react/jsx-runtime";var g8=()=>sa("div",{children:[Qe("h3",{children:u("canvasError.cannotShowPreview")}),Qe("p",{children:Qe("span",{children:u("canvasError.canvasTooBig")})}),sa("em",{children:["(",u("canvasError.canvasTooBigTip"),")"]})]}),f8=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:a})=>{let i=Be(o,e),[l,s]=la(a),[c,m]=la(i),[p,d]=la(e.exportBackground),[h,b]=la(e.exportWithDarkMode),[f,E]=la(e.exportEmbedScene),[v,x]=la(e.exportScale),y=h8(null),[w,C]=la(null),{onCopy:S,copyStatus:A,resetCopyStatus:M}=G5();Y5(()=>{M()},[l,p,h,v,f,M]);let{exportedElements:N,exportingFrame:R}=ja(o,e,c);return Y5(()=>{let P=y.current;if(!P)return;let O=P.offsetWidth,Y=P.offsetHeight;O&&Np({data:{elements:N,appState:{...e,name:l,exportEmbedScene:f},files:t},config:{canvasBackgroundColor:p?e.viewBackgroundColor:!1,padding:Cn,theme:h?"dark":"light",scale:v,maxWidthOrHeight:Math.max(O,Y),exportingFrame:R}}).then(Q=>(C(null),Pa(Q).then(()=>{P.replaceChildren(Q)}).catch(q=>{throw q.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(u("canvasError.canvasTooBig")):q}))).catch(Q=>{console.error(Q),C(Q)})},[e,t,N,R,l,p,h,v,f]),sa("div",{className:"ImageExportModal",children:[Qe("h3",{children:u("imageExportDialog.header")}),sa("div",{className:"ImageExportModal__preview",children:[Qe("div",{className:"ImageExportModal__preview__canvas",ref:y,children:w&&Qe(g8,{})}),Qe("div",{className:"ImageExportModal__preview__filename",children:!Gi&&Qe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:P=>{s(P.target.value),r.executeAction(fp,"ui",P.target.value)}})})]}),sa("div",{className:"ImageExportModal__settings",children:[Qe("h3",{children:u("imageExportDialog.header")}),i&&Qe(Yc,{label:u("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Qe(Wc,{name:"exportOnlySelected",checked:c,onChange:P=>{m(P)}})}),Qe(Yc,{label:u("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Qe(Wc,{name:"exportBackgroundSwitch",checked:p,onChange:P=>{d(P),r.executeAction(bp,"ui",P)}})}),Qe(Yc,{label:u("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Qe(Wc,{name:"exportDarkModeSwitch",checked:h,onChange:P=>{b(P),r.executeAction(o2,"ui",P)}})}),Qe(Yc,{label:u("imageExportDialog.label.embedScene"),tooltip:u("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Qe(Wc,{name:"exportEmbedSwitch",checked:f,onChange:P=>{E(P),r.executeAction(xp,"ui",P)}})}),Qe(Yc,{label:u("imageExportDialog.label.scale"),name:"exportScale",children:Qe(bu,{name:"exportScale",value:v,onChange:P=>{x(P),r.executeAction(t2,"ui",P)},choices:md.map(P=>({value:P,label:`${P}\xD7`}))})}),sa("div",{className:"ImageExportModal__settings__buttons",children:[Qe(Xo,{className:"ImageExportModal__settings__buttons__button",label:u("imageExportDialog.title.exportToPng"),onClick:()=>n(sd.png,N,{exportingFrame:R}),icon:Bm,children:u("imageExportDialog.button.exportToPng")}),Qe(Xo,{className:"ImageExportModal__settings__buttons__button",label:u("imageExportDialog.title.exportToSvg"),onClick:()=>n(sd.svg,N,{exportingFrame:R}),icon:Bm,children:u("imageExportDialog.button.exportToSvg")}),(pl||Jr)&&Qe(Xo,{className:"ImageExportModal__settings__buttons__button",label:u("imageExportDialog.title.copyPngToClipboard"),status:A,onClick:async()=>{await n(sd.clipboard,N,{exportingFrame:R}),S()},icon:Ga,children:u("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Yc=({label:e,children:o,tooltip:t,name:r})=>sa("div",{className:"ImageExportModal__settings__setting",title:e,children:[sa("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Qe(To,{label:t,long:!0,children:cf})]}),Qe("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),V5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:a,name:i})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=la(()=>({appStateSnapshot:or(o),elementsSnapshot:or(e)}));return Qe(gt,{onCloseRequest:a,size:"wide",title:!1,children:Qe(f8,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:i})})};import x8 from"react";import{jsx as b8}from"react/jsx-runtime";var e0={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},t0=({children:e,color:o})=>b8("div",{className:"Card",style:{"--card-color":e0[o].base,"--card-color-darker":e0[o].darker,"--card-color-darkest":e0[o].darkest},children:e});import{Fragment as E8,jsx as gr,jsxs as Du}from"react/jsx-runtime";var y8=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:a,canvas:i,onCloseRequest:l})=>{let{onExportToBackend:s}=a;return gr("div",{className:"ExportDialog ExportDialog--json",children:Du("div",{className:"ExportDialog-cards",children:[a.saveFileToDisk&&Du(t0,{color:"lime",children:[gr("div",{className:"Card-icon",children:bg}),gr("h2",{children:u("exportDialog.disk_title")}),Du("div",{className:"Card-details",children:[u("exportDialog.disk_details"),!Gi&&n.renderAction("changeProjectName")]}),gr(J,{className:"Card-button",type:"button",title:u("exportDialog.disk_button"),"aria-label":u("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(ul,"ui")}})]}),s&&Du(t0,{color:"pink",children:[gr("div",{className:"Card-icon",children:qi}),gr("h2",{children:u("exportDialog.link_title")}),gr("div",{className:"Card-details",children:u("exportDialog.link_details")}),gr(J,{className:"Card-button",type:"button",title:u("exportDialog.link_button"),"aria-label":u("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{pe("export","link",`ui (${Tx()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,o,r,i)]})})},K5=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:a,setAppState:i})=>{let l=x8.useCallback(()=>{i({openDialog:null})},[i]);return gr(E8,{children:o.openDialog?.name==="jsonExport"&&gr(gt,{onCloseRequest:l,title:u("buttons.export"),children:gr(y8,{elements:e,appState:o,setAppState:i,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:a})})})};import v8 from"clsx";import{jsx as Z5,jsxs as T8}from"react/jsx-runtime";var w8="small",X5=e=>T8("label",{className:v8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${w8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Z5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),Z5("div",{className:"ToolIcon__icon",children:cn})]});import{Fragment as j5,jsx as oe,jsxs as yo}from"react/jsx-runtime";var I8=({UIOptions:e})=>yo(qt,{__fallback:!0,children:[oe(qt.DefaultItems.LoadScene,{}),oe(qt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&oe(qt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&oe(qt.DefaultItems.SaveAsImage,{}),oe(qt.DefaultItems.SearchMenu,{}),oe(qt.DefaultItems.Help,{}),oe(qt.DefaultItems.ClearCanvas,{}),oe(qt.Separator,{}),oe(qt.Group,{title:"Excalidraw links",children:oe(qt.DefaultItems.Socials,{})}),oe(qt.Separator,{}),oe(qt.DefaultItems.ToggleTheme,{}),oe(qt.DefaultItems.ChangeCanvasBackground,{})]}),k8=()=>yo(vu,{__fallback:!0,children:[oe(vu.Actions.SaveToDisk,{}),oe(vu.Actions.ExportToImage,{})]}),S8=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:a,onLockToggle:i,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:h,onExportImage:b,renderWelcomeScreen:f,children:E,app:v,isCollaborating:x,generateLinkForSelection:y,uiDisabled:w})=>{let C=Te(),A=Pt()==="compact",M=Rw(),N=A?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},R=M.tunnelsJotai.Provider,[P,O]=te(Wn),Y=()=>h.canvasActions.export?oe(K5,{elements:n,appState:o,files:t,actionManager:e,exportOpts:h.canvasActions.export,canvas:a,setAppState:r}):null,Q=()=>!h.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:oe(V5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:b,onCloseRequest:()=>r({openDialog:null}),name:v.getName()}),q=()=>yo("div",{style:{position:"relative"},children:[yo("div",{className:"excalidraw-ui-top-left",children:[m?.(!1,o),oe(M.MainMenuTunnel.Out,{})]}),f&&oe(M.WelcomeScreenMenuHintTunnel.Out,{})]}),Z=()=>{let V=A;return oe(Rc,{heading:"selectedShapeActions",className:gi("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:V?oe(xt,{className:gi("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:oe(Uw,{appState:o,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v,setAppState:r})}):oe(xt,{className:nt.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:oe(Ow,{appState:o,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:v})})})},z=()=>{let V=jy(o,n),fe=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return oe(mu,{side:"top",children:yo("div",{className:"App-menu App-menu_top",children:[yo(go.Col,{gap:N.menuTopGap,className:gi("App-menu_top__left"),children:[q(),oe("div",{className:gi("selected-shape-actions-container",{"selected-shape-actions-container--compact":A}),children:V&&Z()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&oe(Rc,{heading:"shapes",className:"shapes-section",children:Ee=>yo("div",{style:{position:"relative"},children:[f&&oe(M.WelcomeScreenToolbarHintTunnel.Out,{}),oe(go.Col,{gap:N.toolbarColGap,align:"start",children:yo(go.Row,{gap:N.toolbarRowGap,className:gi("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[yo(xt,{padding:N.islandPadding,className:gi("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":A}),children:[oe(U5,{appState:o,isMobile:C.formFactor==="phone",editorInterface:C,app:v}),Ee,yo(go.Row,{gap:N.toolbarInnerRowGap,children:[oe(pu,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:u("toolBar.penMode"),penDetected:o.penDetected}),oe(F3,{checked:o.activeTool.locked,onChange:i,title:u("toolBar.lock")}),oe("div",{className:"App-toolbar__divider"}),oe(su,{checked:ir(o),onChange:()=>l(),title:u("toolBar.hand"),isMobile:!0}),oe(Ww,{setAppState:r,activeTool:o.activeTool,UIOptions:h,app:v})]})]}),x&&oe(xt,{style:{marginLeft:N.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:oe(X5,{title:u("toolBar.laser"),checked:o.activeTool.type===mt.laser,onChange:()=>v.setActiveTool({type:mt.laser}),isMobile:!0})})]})})]})}),yo("div",{className:gi("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":A}),children:[o.collaborators.size>0&&oe(gu,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(C.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!ee||o.openSidebar?.name!==Yt.name)&&oe(M.DefaultSidebarTriggerTunnel.Out,{}),fe&&oe(Gc,{app:v,onClose:()=>{e.executeAction(oi)},renderCustomStats:d})]})]})})},U=()=>oe(wu,{__fallback:!0,onDock:V=>{pe("sidebar",`toggleDock (${V?"dock":"undock"})`,`(${C.formFactor==="phone"?"mobile":"desktop"})`)}}),ee=Vi(Nc);if(w)return null;let Ie=yo(j5,{children:[E,oe(I8,{UIOptions:h}),oe(wu.Trigger,{__fallback:!0,icon:Ff,title:Ae(u("toolBar.library")),onToggle:V=>{V&&pe("sidebar",`${Yt.name} (open)`,`button (${C.formFactor==="phone"?"mobile":"desktop"})`)},tab:Yt.defaultTab}),oe(k8,{}),o.openDialog?.name==="ttd"&&oe(Wb,{__fallback:!0}),o.isLoading&&oe(lu,{delay:250}),o.errorMessage&&oe(B5,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),P&&C.formFactor!=="phone"&&oe(OE,{colorPickerType:P.colorPickerType,onCancel:()=>{O(null)},onChange:(V,fe,Ee,{altKey:ke})=>{if(!(V!=="elementBackground"&&V!=="elementStroke"))if(Ee.length){for(let et of Ee)Zt(et,ie(n),{[ke&&P.swapPreviewOnAlt?V==="elementBackground"?"strokeColor":"backgroundColor":V==="elementBackground"?"backgroundColor":"strokeColor"]:fe}),Er.delete(et);v.scene.triggerUpdate()}else r(V==="elementBackground"?{currentItemBackgroundColor:fe}:{currentItemStrokeColor:fe})},onSelect:(V,fe)=>{O(Ee=>Ee?.keepOpenOnAlt&&fe.altKey?Ee:null),P?.onSelect?.(V,fe)}}),o.openDialog?.name==="help"&&oe(F5,{onClose:()=>{r({openDialog:null})}}),oe(Xw,{}),o.openDialog?.name==="elementLinkSelector"&&oe(z5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:v.scene,appState:o,generateLinkForSelection:y}),oe(M.OverwriteConfirmDialogTunnel.Out,{}),Q(),Y(),o.pasteDialog.shown&&oe(K3,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),C.formFactor==="phone"&&oe(Y3,{app:v,appState:o,elements:n,actionManager:e,renderJSONExportDialog:Y,renderImageExportDialog:Q,setAppState:r,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:U,renderWelcomeScreen:f,UIOptions:h}),C.formFactor!=="phone"&&yo(j5,{children:[yo("div",{className:"layer-ui__wrapper",style:o.openSidebar&&ee&&C.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&oe(M.WelcomeScreenCenterTunnel.Out,{}),z(),oe(q3,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:f}),o.scrolledOutside&&!o.scrollConstraints&&oe("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(V=>({...Aa(n,V)}))},children:u("buttons.scrollBackToContent")})]}),U()]})]});return oe(Wf.Provider,{value:o,children:oe(R,{children:oe(q1.Provider,{value:M,children:Ie})})})},$5=e=>{let{startBoundElement:o,cursorButton:t,scrollX:r,scrollY:n,...a}=e;return a},M8=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:a,appState:i,...l}=o;return at($5(r),$5(i),{selectedElementIds:at,selectedGroupIds:at})&&at(n,l)},q5=C8.memo(S8,M8);import L8 from"clsx";import{jsx as J5,jsxs as _8}from"react/jsx-runtime";var A8="small",Ru=e=>_8("label",{className:L8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${A8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[J5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),J5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as P8,useRef as D8}from"react";import{jsx as Q5}from"react/jsx-runtime";var eC=({trails:e})=>{let o=D8(null);return P8(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),Q5("div",{className:"SVGLayer",children:Q5("svg",{ref:o})})};import X8,{useEffect as $8,useRef as dC}from"react";var zt=class zt{static start(o,t){let r=t({deltaTime:0,state:void 0});r&&(zt.animations.set(o,{animation:t,lastTime:0,state:r}),zt.isRunning||(zt.isRunning=!0,li()?requestAnimationFrame(zt.tick):setTimeout(zt.tick,0)))}static tick(){if(zt.animations.size>0){for(let[o,t]of zt.animations){let r=performance.now(),n=t.lastTime===0?0:r-t.lastTime,a=t.animation({deltaTime:n,state:t.state});if(a)t.lastTime=r,t.state=a;else if(zt.animations.delete(o),zt.animations.size===0){zt.isRunning=!1;return}}li()?requestAnimationFrame(zt.tick):setTimeout(zt.tick,0)}}static running(o){return zt.animations.has(o)}static cancel(o){zt.animations.delete(o)}};k(zt,"isRunning",!1),k(zt,"animations",new Map);var Vc=zt;var R8="#ff6b6b",N8="#ff0000",tC=1,oC=2,rC=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===ne.LIGHT||o.zenModeEnabled?R8:N8,r=(o.zenModeEnabled?tC*1.5:tC)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,z8(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,B8(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,O8(n,e,o));e.restore()},O8=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];qo(r,n,o)}for(let r of e.points)nC(r,t,o)},z8=(e,o,t)=>{nC(e.points[0],t,o),t.zenModeEnabled||qo(e.points[0],e.points[1],o)},nC=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?oC*1.5:oC)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},qo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},B8=(e,o,t,r,n)=>{let a=8/r.zoom.value,i=a/2,l=a/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||qo(L(e[0],e[1]-a),L(e[0],e[1]+a),n),qo(L(s[0]-l,s[1]-i),L(s[0]-l,s[1]+i),n),qo(L(s[0]+l,s[1]-i),L(s[0]+l,s[1]+i),n),r.zenModeEnabled||(qo(L(o[0],o[1]-a),L(o[0],o[1]+a),n),qo(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||qo(L(e[0]-a,e[1]),L(e[0]+a,e[1]),n),qo(L(s[0]-i,s[1]-l),L(s[0]+i,s[1]-l),n),qo(L(s[0]-i,s[1]+l),L(s[0]+i,s[1]+l),n),r.zenModeEnabled||(qo(L(o[0]-a,o[1]),L(o[0]+a,o[1]),n),qo(e,o,n))}};var F8=(e,o)=>{je(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;je(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),lC(t,e,o),e.restore()},H8=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let a=X.getElement(r,t);if(!a)return;let i=X.getPointAtIndexGlobalCoordinates(a,n,t);e.save(),e.translate(o.scrollX,o.scrollY),lC(i,e,o),e.restore()},lC=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",cm(o,e[0],e[1],X.POINT_HANDLE_SIZE/t.zoom.value,!1)},o0=(e,o,t,r,n,a,i)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":a&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),cm(e,t[0],t[1],(i?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!a,!i||n)},U8=(e,o,t,r)=>{let n=o.frameId&&t.get(o.frameId);switch(n&&le(n)&&(e.translate(n.x,n.y),e.beginPath(),We.radius&&e.roundRect?e.roundRect(-1,-1,n.width+1,n.height+1,We.radius/r.zoom.value):e.rect(-1,-1,n.width+1,n.height+1),e.clip(),e.translate(-n.x,-n.y)),o.type){case"magicframe":case"frame":e.save(),e.translate(o.x,o.y),e.lineWidth=We.strokeWidth/r.zoom.value,e.strokeStyle=r.theme===ne.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",We.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.width,o.height,We.radius/r.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.width,o.height),e.restore();break;default:e.save();let a=Mh(o,t);switch(e.translate(a[0],a[1]),e.rotate(o.angle),e.translate(-a[0],-a[1]),e.translate(o.x,o.y),e.lineWidth=$e(1.75,o.strokeWidth,4)/Math.max(.25,r.zoom.value),e.strokeStyle=r.theme===ne.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.type){case"ellipse":e.beginPath(),e.ellipse(o.width/2,o.height/2,o.width/2,o.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[i,l]=hh(o);i.forEach(s=>{e.beginPath(),e.moveTo(s[0][0]-o.x,s[0][1]-o.y),e.lineTo(s[1][0]-o.x,s[1][1]-o.y),e.stroke()}),l.forEach(s=>{let[c,m,p,d]=s;e.beginPath(),e.moveTo(c[0]-o.x,c[1]-o.y),e.bezierCurveTo(m[0]-o.x,m[1]-o.y,p[0]-o.x,p[1]-o.y,d[0]-o.x,d[1]-o.y),e.stroke()})}break;default:{let[i,l]=uh(o);i.forEach(s=>{e.beginPath(),e.moveTo(s[0][0]-o.x,s[0][1]-o.y),e.lineTo(s[1][0]-o.x,s[1][1]-o.y),e.stroke()}),l.forEach(s=>{let[c,m,p,d]=s;e.beginPath(),e.moveTo(c[0]-o.x,c[1]-o.y),e.bezierCurveTo(m[0]-o.x,m[1]-o.y,p[0]-o.x,p[1]-o.y,d[0]-o.x,d[1]-o.y),e.stroke()})}break}e.restore();break}},G8=(e,o,t,r,n,a,i)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=kn-(i?.runtime??(l?0:kn)),c=$e(1/kn*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&r.get(t.frameId);switch(p&&le(p)&&(o.translate(p.x,p.y),o.beginPath(),We.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,We.radius/n.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=We.strokeWidth/n.zoom.value,o.strokeStyle=n.theme===ne.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,We.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,We.radius/n.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let h=Mh(t,r),b=h[0]+n.scrollX,f=h[1]+n.scrollY;switch(o.translate(b,f),o.rotate(t.angle),o.translate(-b,-f),o.translate(t.x+n.scrollX-m,t.y+n.scrollY-m),o.lineWidth=$e(2.5,t.strokeWidth*1.75,4)/Math.max(.25,n.zoom.value),o.strokeStyle=n.theme===ne.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[E,v]=hh(t,m);E.forEach(x=>{o.beginPath(),o.moveTo(x[0][0]-t.x+m,x[0][1]-t.y+m),o.lineTo(x[1][0]-t.x+m,x[1][1]-t.y+m),o.stroke()}),v.forEach(x=>{let[y,w,C,S]=x;o.beginPath(),o.moveTo(y[0]-t.x+m,y[1]-t.y+m),o.bezierCurveTo(w[0]-t.x+m,w[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m,S[0]-t.x+m,S[1]-t.y+m),o.stroke()})}break;default:{let[E,v]=uh(t,m);E.forEach(x=>{o.beginPath(),o.moveTo(x[0][0]-t.x+m,x[0][1]-t.y+m),o.lineTo(x[1][0]-t.x+m,x[1][1]-t.y+m),o.stroke()}),v.forEach(x=>{let[y,w,C,S]=x;o.beginPath(),o.moveTo(y[0]-t.x+m,y[1]-t.y+m),o.bezierCurveTo(w[0]-t.x+m,w[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m,S[0]-t.x+m,S[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!l||(i?.runtime??0)>kn)return;let d=.5*(Math.min(t.width,t.height)/2);if(!le(t)){o.save(),o.translate(t.x+n.scrollX,t.y+n.scrollY);let h=1/kn*s;o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/n.zoom.value,o.setLineDash([4/n.zoom.value,4/n.zoom.value]),o.lineDashOffset=-h*10/n.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore()}return{runtime:(i?.runtime??0)+a}},W8=(e,o,t,r,n,a,i)=>{if(_o("COMPLEX_BINDINGS"))return G8(e,o,t,r,n,a,i);o.save(),o.translate(n.scrollX,n.scrollY),U8(o,t,r,n),o.restore()},sC=(e,o,t)=>{let{angle:r,x1:n,y1:a,x2:i,y2:l,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,h=i-n,b=l-a,E=(t.padding??ld*2)/o.zoom.value,v=8/o.zoom.value,x=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let y=s.length;for(let w=0;w<y;++w)e.strokeStyle=s[w],p&&e.setLineDash([v,x+(v+x)*(y-1)]),e.lineDashOffset=(v+x)*w,Ms(e,n-E,a-E,h+E*2,b+E*2,c,m,r);e.restore()},Y8=(e,o,t,r)=>{let[n,a,i,l]=At(t,r),s=i-n,c=l-a;e.strokeStyle="rgb(0,118,255)",e.lineWidth=We.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Ms(e,n,a,s,c,n+s/2,a+c/2,t.angle,!1,We.radius/o.zoom.value),e.restore()},aC=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:a=!1}=r||{},i=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,h,b]=_e(m);return{angle:0,x1:p,x2:h,y1:d,y2:b,selectionColors:n,dashed:a,cx:p+(h-p)/2,cy:d+(b-d)/2,activeEmbeddable:!1}},c=m=>{let p=Ke(t,m);return s(p)};Object.entries(Ia(l,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(i.map(m=>s([m]))).forEach(m=>sC(e,o,m))},r0=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=X.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:a}=X,i=o.selectedLinearElement?.isEditing?a:a/2,l=Se(t),s=tt(t);if(n.forEach((c,m)=>{if(l&&m!==0&&m!==n.length-1)return;let p=m>0&&(m!==n.length-1||!s||!t.polygon)&&_0(c,m===n.length-1?n[0]:n[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),o0(e,o,c,i,d,!1,p)}),Se(t)){let c=t.fixedSegments?.map(m=>m.index)||[];n.slice(0,-1).forEach((m,p)=>{X.isSegmentTooShort(t,n[p+1],n[p],p,o.zoom)||o0(e,o,L((m[0]+n[p+1][0])/2,(m[1]+n[p+1][1])/2),a/2,!1,!c.includes(p+1),!1)})}else X.getEditorMidPoints(t,r,o).filter((m,p,d)=>m!==null&&!(Se(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||n.length===2)&&o0(e,o,m,a/2,!1,!0,!1)});e.restore()},iC=(e,o,t,r,n)=>{Object.keys(r).forEach(a=>{let i=r[a];if(i!==void 0){let[l,s,c,m]=i;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),a==="rotation"?cm(e,l+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):Ms(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},V8=(e,o,t,r,n)=>{let[a,i,,,l,s]=At(r,n),c=3,m=20,p=c/t.zoom.value,d=p/2,h=l-a+p,b=s-i+p,f=Math.min(m/t.zoom.value,h),E=Math.min(m/t.zoom.value,b);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-h,-b],[0,d],[f,d],[d,0],[d,E]],[[h-d,-b],[d,d],[-f+d,d],[0,0],[0,E]],[[-h,b],[0,-d],[f,-d],[d,0],[d,-E]],[[h-d,b],[d,-d],[-f+d,-d],[0,0],[0,-E]]].forEach(x=>{let[[y,w],[C,S],[A,M],[N,R],[P,O]]=x;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,w+S),e.lineTo(y+A,w+M),e.stroke(),e.beginPath(),e.moveTo(y+N,w+R),e.lineTo(y+P,w+O),e.stroke(),e.restore()}),e.restore()},K8=(e,o,t,r)=>{o.save();let n=ld*2/t.zoom.value,a=e.width+n*2,i=e.height+n*2,l=e.x+a/2,s=e.y+i/2,c=-(a/2+n),m=-(i/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(c,m,a,i),o.restore()},Z8=({app:e,canvas:o,elementsMap:t,visibleElements:r,selectedElements:n,allElementsMap:a,scale:i,appState:l,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,h]=dm(o,i),b=m,f=mm({canvas:o,scale:i,normalizedWidth:d,normalizedHeight:h});f.save(),f.scale(l.zoom.value,l.zoom.value);let E;if(r.forEach(y=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===y.id&&y&&(E=y)}),E&&r0(f,l,E,t),l.selectionElement&&!l.isCropping)try{yy(l.selectionElement,f,l,s.selectionColor)}catch(y){console.error(y)}if(l.editingTextElement&&$(l.editingTextElement)){let y=a.get(l.editingTextElement.id);y&&!y.autoResize&&K8(y,f,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?b={...m,bindingHighlight:W8(e,f,l.suggestedBinding,a,l,p,m?.bindingHighlight)}:b={...m,bindingHighlight:void 0},l.frameToHighlight&&Y8(f,l,l.frameToHighlight,t),l.elementsToHighlight&&aC(f,l,l.elementsToHighlight),l.activeLockedId){let y=a.get(l.activeLockedId),w=y?[y]:Ke(a,l.activeLockedId);aC(f,l,w,{colors:["#ced4da"],dashed:!0})}let v=n.some(y=>le(y));if(n.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===n[0].id&&r0(f,l,n[0],t),l.selectedLinearElement){let y=l.selectedLinearElement,w=n.find(C=>C.id===y.elementId);l.selectedLinearElement.isDragging||(y.segmentMidPointHoveredCoords?F8(f,l):(Se(w)?y.hoverPointIndex===0||y.hoverPointIndex===w.points.length-1:y.hoverPointIndex>=0)&&H8(f,l,t))}if(!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let y=am(n,l,c),w=n.length===1&&ge(n[0]);w&&l.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&r0(f,l,n[0],t);let C=s.selectionColor||"#000";if(y){let S=ie(n),A=[];for(let N of t.values()){let R=[],P=s.remoteSelectedElementIds.get(N.id);if(w&&Se(N)&&(N.startBinding||N.endBinding)||(S.has(N.id)&&!Wd(l,N)&&R.push(C),P&&R.push(...P.map(O=>Qa(O,l.collaborators.get(O))))),R.length){let[O,Y,Q,q,Z,z]=At(N,t,!0);A.push({angle:N.angle,x1:O,y1:Y,x2:Q,y2:q,selectionColors:N.locked?["#ced4da"]:R,dashed:!!P||N.locked,cx:Z,cy:z,activeEmbeddable:l.activeEmbeddable?.element===N&&l.activeEmbeddable.state==="active",padding:N.id===l.croppingElementId||Ue(N)?0:void 0})}}let M=N=>{let R=Ke(t,N),[P,O,Y,Q]=_e(R);A.push({angle:0,x1:P,x2:Y,y1:O,y2:Q,selectionColors:R.some(q=>q.locked)?["#ced4da"]:["#000"],dashed:!0,cx:P+(Y-P)/2,cy:O+(Q-O)/2,activeEmbeddable:!1})};for(let N of nr(l))M(N);l.editingGroupId&&M(l.editingGroupId),A.forEach(N=>sC(f,l,N))}if(f.save(),f.translate(l.scrollX,l.scrollY),n.length===1){f.fillStyle="#fff";let S=$y(n[0],l.zoom,t,"mouse",nm(c));if(!l.viewModeEnabled&&y&&!$(l.editingTextElement)&&!l.croppingElementId&&iC(f,s,l,S,n[0].angle),l.croppingElementId&&!l.isCropping){let A=t.get(l.croppingElementId);A&&Ue(A)&&V8(f,s,l,A,t)}}else if(n.length>1&&!l.isRotating&&!n.some(S=>S.locked)){let S=ld*2/l.zoom.value;f.fillStyle="#fff";let[A,M,N,R]=_e(n,t),P=f.getLineDash();f.setLineDash([2/l.zoom.value]);let O=f.lineWidth;f.lineWidth=1/l.zoom.value,f.strokeStyle=C,Ms(f,A-S,M-S,N-A+S*2,R-M+S*2,(A+N)/2,(M+R)/2,0),f.lineWidth=O,f.setLineDash(P);let Y=Xy([A,M,N,R,(A+N)/2,(M+R)/2],0,l.zoom,"mouse",v?{...nm(c),rotation:!0}:nm(c));n.some(Q=>!Q.locked)&&iC(f,s,l,Y,0)}f.restore()}l.searchMatches?.matches.forEach(({id:y,focus:w,matchedLines:C})=>{let S=t.get(y);if(S){let[A,M,,,N,R]=At(S,t,!0);f.save(),l.theme===ne.LIGHT?w?f.fillStyle="rgba(255, 124, 0, 0.4)":f.fillStyle="rgba(255, 226, 0, 0.4)":w?f.fillStyle="rgba(229, 82, 0, 0.4)":f.fillStyle="rgba(99, 52, 0, 0.4)";let P=le(S)?l.zoom.value:1;f.translate(l.scrollX,l.scrollY),f.translate(N,R),f.rotate(S.angle),C.forEach(O=>{(O.showOnCanvas||w)&&f.fillRect(A+O.offsetX/P-N,M+O.offsetY/P-R,O.width/P,O.height/P)}),f.restore()}}),rC(f,l),f.restore(),i2({context:f,renderConfig:s,appState:l,normalizedWidth:d,normalizedHeight:h});let x;return s.renderScrollbars&&(x=I3(t,d,h,l),f.save(),f.fillStyle=C3,f.strokeStyle="rgba(255,255,255,0.8)",[x.horizontal,x.vertical].forEach(y=>{y&&Tp(f,y.x,y.y,y.width,y.height,Vo/2)}),f.restore()),{scrollBars:x,atLeastOneVisibleElement:r.length>0,elementsMap:t,animationState:b}},cC=e=>{let o=Z8(e);return e.callback(o),o};import{jsx as J8}from"react/jsx-runtime";var mC="animateInteractiveScene",j8=e=>{let o=dC(!1),t=dC(null);return $8(()=>{if(!o.current){o.current=!0;return}let r=new Map,n=new Map,a=new Map,i=new Map,l=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))a.has(p)||a.set(p,[]),a.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&i.set(m,c.username),c.userState&&l.set(m,c.userState),n.set(m,kt({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),r.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:n,remotePointerButton:r,remoteSelectedElementIds:a,remotePointerUsernames:i,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},Vc.running(mC)||Vc.start(mC,({deltaTime:c,state:m})=>{let p=cC({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),J8("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Pe.GRAB:Pe.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:u("labels.drawingCanvas")})},pC=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,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,suggestedBinding:e.suggestedBinding,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,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale}),q8=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:at(pC(e.appState),pC(o.appState)),n0=X8.memo(j8,q8);import Q8,{useEffect as uC,useRef as hC}from"react";import{jsx as o7}from"react/jsx-runtime";var e7=e=>{let o=hC(null),t=hC(!1);return uC(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),uC(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),dE({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},li())}),o7("div",{className:"excalidraw__canvas-wrapper",ref:o})},gC=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,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,suggestedBinding:e.suggestedBinding}),t7=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:at(gC(e.appState),gC(o.appState))&&at(e.renderConfig,o.renderConfig),a0=Q8.memo(e7,t7);import{useEffect as n7,useRef as a7}from"react";var fC=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:a,appState:i,renderConfig:l})=>{if(e){let[s,c]=dm(e,a),m=mm({canvas:e,scale:a,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(i.zoom.value,i.zoom.value),t&&t.type!=="selection"){if(vr(t))return;if((t.frameId||i.frameToHighlight?.id)&&i.frameRendering.enabled&&i.frameRendering.clip){let d=hy(t,r,i);d&&gy(t,d,i,r)&&sE(d,m,l,i)}Ey(t,r,n,o,m,l,i)}else m.clearRect(0,0,s,c);m.restore()}},r7=vd(e=>{fC(e)},{trailing:!0}),bC=(e,o)=>{if(o){r7(e);return}fC(e)};import{jsx as l7}from"react/jsx-runtime";var i7=e=>{let o=a7(null);return n7(()=>{o.current&&bC({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},li())}),l7("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:o})},xC=i7;import{useCallback as s7,useEffect as c7,useRef as d7}from"react";import{jsx as yC,jsxs as p7}from"react/jsx-runtime";var m7=5e3,EC=({message:e,onClose:o,closable:t=!1,duration:r=m7,style:n})=>{let a=d7(0),i=r!==1/0,l=s7(()=>{i&&(a.current=window.setTimeout(()=>o(),r))},[o,r,i]);return c7(()=>{if(i)return l(),()=>clearTimeout(a.current)},[l,e,r,i]),p7("div",{className:"Toast",onMouseEnter:i?()=>clearTimeout(a?.current):void 0,onMouseLeave:i?l:void 0,style:n,children:[yC("p",{className:"Toast__message",children:e}),t&&yC(J,{icon:wo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{flushSync as u7}from"react-dom";import{jsx as g7}from"react/jsx-runtime";var h7=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:Ke(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,a]=_e(r),{x:i,y:l}=kt({sceneX:n,sceneY:a},e.state);return g7("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${i-e.state.offsetLeft}px`},onClick:()=>{u7(()=>{let s=Ia(r,e.state);e.setState({selectedElementIds:r.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(yl)},title:u("labels.elementLock.unlock"),children:og})},vC=h7;import{Fragment as v7,jsx as Re,jsxs as Nu}from"react/jsx-runtime";var IC=Kr.createContext(null),kC=Kr.createContext(null),d0={formFactor:"desktop",desktopUIMode:"full",userAgent:ih(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},p0=Kr.createContext(d0);p0.displayName="EditorInterfaceContext";var u0=Kr.createContext({container:null,id:null});u0.displayName="ExcalidrawContainerContext";var h0=Kr.createContext([]);h0.displayName="ExcalidrawElementsContext";var g0=Kr.createContext({..._a(),width:0,height:0,offsetLeft:0,offsetTop:0,scrollConstraints:null});g0.displayName="ExcalidrawAppStateContext";var f0=Kr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});f0.displayName="ExcalidrawSetAppStateContext";var b0=Kr.createContext(null);b0.displayName="ExcalidrawActionManagerContext";var lt=()=>da(IC),Ar=()=>da(kC),Te=()=>da(p0),Pt=()=>ba(Te()),qe=()=>da(u0),Yn=()=>da(h0),Lr=()=>da(g0),ye=()=>da(f0),vt=()=>da(b0),Kc=!1,i0=0,Zc=null,jl=!1,Xc=!1,l0=!1,$c={horizontal:null,vertical:null},ca=0,jc=!1,qc=null,s0=new Map,c0=!1,TC=0,CC=!1,Jc=null,De={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},m0=class e extends Kr.Component{constructor(t){super(t);k(this,"canvas");k(this,"interactiveCanvas",null);k(this,"rc");k(this,"unmounted",!1);k(this,"actionManager");k(this,"editorInterface",d0);k(this,"stylesPanelMode",ba(d0));k(this,"excalidrawContainerRef",Kr.createRef());k(this,"scene");k(this,"fonts");k(this,"renderer");k(this,"visibleElements");k(this,"resizeObserver");k(this,"library");k(this,"libraryItemsFromStorage");k(this,"id");k(this,"store");k(this,"history");k(this,"excalidrawContainerValue");k(this,"files",{});k(this,"imageCache",new Map);k(this,"iFrameRefs",new Map);k(this,"embedsValidationStatus",new Map);k(this,"initializedEmbeds",new Set);k(this,"handleToastClose",()=>{this.setToast(null)});k(this,"elementsPendingErasure",new Set);k(this,"flowChartCreator",new Fy);k(this,"flowChartNavigator",new By);k(this,"bindModeHandler",null);k(this,"hitLinkElement");k(this,"lastPointerDownEvent",null);k(this,"lastPointerUpEvent",null);k(this,"lastPointerMoveEvent",null);k(this,"lastPointerMoveCoords",null);k(this,"lastViewportPosition",{x:0,y:0});k(this,"animationFrameHandler",new tu);k(this,"laserTrails",new ru(this.animationFrameHandler,this));k(this,"eraserTrail",new iu(this.animationFrameHandler,this));k(this,"lassoTrail",new au(this.animationFrameHandler,this));k(this,"onChangeEmitter",new Po);k(this,"onPointerDownEmitter",new Po);k(this,"onPointerUpEmitter",new Po);k(this,"onUserFollowEmitter",new Po);k(this,"onScrollChangeEmitter",new Po);k(this,"missingPointerEventCleanupEmitter",new Po);k(this,"onRemoveEventListenersEmitter",new Po);k(this,"updateEditorAtom",(t,...r)=>{let n=Et.set(t,...r);return this.triggerRender(),n});k(this,"previousHoveredBindableElement",null);k(this,"getEffectiveGridSize",()=>ta(this)?this.state.gridSize:null);k(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),Er.delete(t)});k(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Vt(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let a=Bi(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,a)}}else Ta(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,a)=>{t.has(a)||this.iFrameRefs.delete(a)})});k(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);k(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let a=n.getBoundingClientRect(),i=Ye({clientX:a.x,clientY:a.y},this.state),l=Ye({clientX:a.right,clientY:a.bottom},this.state);return r={x:i.x,y:i.y,width:l.x-i.x,height:l.y-i.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});k(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});k(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ne.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&le(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(a=>a.focus):null;return r.map(a=>{if(!Is(a,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===a.id&&this.resetEditingFrame(a),null;let{x:i,y:l}=kt({sceneX:a.x,sceneY:a.y},this.state),s=6,c,m=fy(a);if(a.id===this.state.editingFrame){let p=m;c=Re("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(a,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(a),onKeyDown:d=>{(d.key===T.ESCAPE||d.key===T.ENTER)&&this.resetEditingFrame(a)},style:{background:t?gd(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${We.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?We.nameColorDarkTheme:We.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-i-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return Re("div",{id:this.getFrameNameDOMId(a),className:nt.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+We.nameOffsetY-l+this.state.offsetTop}px`,left:`${i-this.state.offsetLeft}px`,zIndex:2,fontSize:We.nameFontSize,color:t?We.nameColorDarkTheme:We.nameColorLightTheme,lineHeight:We.nameLineHeight,width:"max-content",maxWidth:n?.id===a.id&&n?.focus?"none":`${a.width*this.state.zoom.value}px`,overflow:a.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Pe.MOVE,pointerEvents:this.state.viewModeEnabled?pa.disabled:pa.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:a.id})},children:c},a.id)})});k(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});k(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());k(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());k(this,"getSceneElements",()=>this.scene.getNonDeletedElements());k(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});k(this,"onExportImage",async(t,r,n)=>{pe("export",t,"ui");let a=await qa({type:t,data:{elements:r,appState:this.state,files:this.files},config:{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}}).catch(Td).catch(i=>{console.error(i),this.setState({errorMessage:i.message})});this.state.exportEmbedScene&&a&&pm(a)&&this.setState({fileHandle:a})});k(this,"magicGenerations",new Map);k(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});k(this,"plugins",{});k(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:mt.magicframe}),pe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&_d(t[0])&&t[0];if(!r&&t.some(a=>le(a)||a.frameId)){this.setActiveTool({type:mt.magicframe});return}pe("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[a,i,l,s]=_e(t),c=50;n=Ph({...We,x:a-c,y:i-c,width:l-a+c*2,height:s-i+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)this.scene.mutateElement(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});k(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Wn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let a=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:D.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:D.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?re(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:D.IMMEDIATELY})},keepOpenOnAlt:!1})});k(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});k(this,"syncActionResult",ct(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let a=t?.appState?.viewModeEnabled||!1,i=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||ne.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(a=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(i=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&Gh(m)&&$(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:n,viewModeEnabled:a,zenModeEnabled:i,theme:l,name:s,errorMessage:c}}),r=!0}r||this.scene.triggerUpdate()}));k(this,"onBlur",ct(()=>{jl=!1,this.setState({isBindingEnabled:!0})}));k(this,"onUnload",()=>{this.onBlur()});k(this,"disableEvent",t=>{t.preventDefault()});k(this,"resetHistory",()=>{this.history.clear()});k(this,"resetStore",()=>{this.store.clear()});k(this,"resetScene",ct(t=>{this.scene.replaceAllElements([]),this.setState(r=>({..._a(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));k(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let l=i.files[0],s=await l.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),l)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let r=Wi(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=Ls(t?.appState,null),a=n.activeTool;n.preferredSelectionTool.initialized||(n.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),n={...n,theme:this.props.theme||n.theme,openSidebar:n?.openSidebar||this.state.openSidebar,activeTool:a.type==="image"||a.type==="lasso"||a.type==="selection"?{...a,type:n.preferredSelectionTool.type}:n.activeTool,isLoading:!1,toast:this.state.toast},this.props.scrollConstraints?n={...n,...f1(this.state,n)}:t?.scrollToContent&&(n={...n,...Aa(r,{...n,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft,scrollConstraints:this.state.scrollConstraints})}),this.resetStore(),t?.scrollX!=null&&(n.scrollX=t.scrollX),t?.scrollY!=null&&(n.scrollY=t.scrollY),this.resetHistory(),this.syncActionResult({elements:r,appState:n,files:t?.files,captureUpdate:D.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),Ma(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});k(this,"getFormFactor",(t,r)=>this.props.UIOptions.getFormFactor?.(t,r)??ah(t,r));k(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),a=dx(),i=ih(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:1229,s=vi(this.editorInterface,{desktopUIMode:a??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(r,n),userAgent:i,canFitSidebar:r>l,isLandscape:r>n});this.editorInterface=s,this.reconcileStylesPanelMode(s)});k(this,"reconcileStylesPanelMode",t=>{let r=ba(t);if(r===this.stylesPanelMode)return;let n=this.stylesPanelMode;this.stylesPanelMode=r,n!=="full"&&r==="full"&&this.setState(a=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});k(this,"setDesktopUIMode",t=>{let r=mx(t);this.editorInterface=vi(this.editorInterface,{desktopUIMode:r}),this.reconcileStylesPanelMode(this.editorInterface)});k(this,"onResize",ct(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Er.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.state.scrollConstraints?this.setState(t=>cr(t)):this.setState({})}));k(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});k(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&($c=r);let a=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==a&&this.setState({scrolledOutside:a}),this.scheduleImageRefresh()});k(this,"onScroll",Sn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},W0));k(this,"onCut",ct(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||so(t.target)||(this.actionManager.executeAction(pc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onCopy",ct(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||so(t.target)||(this.actionManager.executeAction(ei,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onTouchStart",t=>{if(sx&&t.preventDefault(),this.props.interactive!==!1){if(!Kc){Kc=!0,t.touches.length===1&&(Zc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(i0),i0=window.setTimeout(e.resetTapTwice,U0);return}if(Kc&&t.touches.length===1&&Zc){let r=t.touches[0];wn(L(r.clientX,r.clientY),L(Zc.x,Zc.y))<=j0&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY})),Kc=!1,clearTimeout(i0)}t.touches.length===2&&this.setState({selectedElementIds:Oe({},this.state),activeEmbeddable:null})}});k(this,"onTouchEnd",t=>{this.props.interactive!==!1&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Oe(this.state.previousSelectedElementIds,this.state)}):De.pointers.clear())});k(this,"pasteFromClipboard",ct(async t=>{if(this.props.interactive===!1)return;let r=!!c0,n=document.activeElement,a=this.excalidrawContainerRef.current?.contains(n);if(t&&!a)return;let i=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(i instanceof HTMLCanvasElement)||so(n)))return;let l=await mc(t),s=l.getFiles(),c=await Qv(l,r);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,r),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));k(this,"addElementsFromPasteOrLibrary",t=>{let r=Wi(t.elements,null,{deleteInvisibleElements:!0}),[n,a,i,l]=_e(r),s=Ea(n,i)/2,c=Ea(a,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:h}=Ye({clientX:m,clientY:p},this.state),b=d-s,f=h-c,[E,v]=Ft(b,f,this.getEffectiveGridSize()),{duplicatedElements:x}=nn({type:"everything",elements:r.map(M=>re(M,{x:M.x+E-n,y:M.y+v-a})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),w=[...y,...x];w=this.props.onDuplicate?.(w,y)||w,wr(w,ie(x));let S=this.getTopLayerFrameAtSceneCoords({x:d,y:h});if(S){let M=py(x,S);Pi(w,M,S,this.state)}this.scene.replaceAllElements(w),x.forEach(M=>{if($(M)&&it(M)){let N=Do(M,this.scene.getElementsMapIncludingDeleted());ut(M,N,this.scene)}}),lx&&Nn.loadElementsFonts(x).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let A=ay(x);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Et.get(Nc)?this.state.openSidebar:null,...bt({editingGroupId:null,selectedElementIds:A.reduce((M,N)=>(it(N)||(M[N.id]=!0),M),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(x,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});k(this,"setAppState",(t,r)=>{this.setState(t,r)});k(this,"removePointer",t=>{ca&&this.resetContextMenuTimer(),De.pointers.delete(t.pointerId)});k(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||pe("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Ne(this.state,r.activeTool.locked?{type:this.state.preferredSelectionTool.type}:r.activeTool),locked:!r.activeTool.locked}}))});k(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});k(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});k(this,"onHandToolToggle",()=>{this.actionManager.executeAction(zv)});k(this,"zoomCanvas",t=>{this.setState(pn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:vo(t)},this.state))});k(this,"cancelInProgressAnimation",null);k(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(Ma(t)?s=Py(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):Ma(t)&&this.setState({toast:{message:u("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],a=this.state.zoom,i=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=lc({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});a=s.zoom,i=s.scrollX,l=s.scrollY}else{let s=Aa(n,this.state);i=s.scrollX,l=s.scrollY}if(r?.animate){let s={scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom.value},c={scrollX:i,scrollY:l,zoom:a.value};this.animateTranslateCanvas({fromValues:s,toValues:c,duration:r?.duration??500,onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})}})}else this.setState({scrollX:i,scrollY:l,zoom:a})});k(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});k(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),qc&&clearTimeout(qc);let r=typeof t=="function"?t(this.state,this.props):t,n={...this.state,...r,...this.state.scrollConstraints&&{shouldCacheIgnoreZoom:!1}},a=n.scrollConstraints&&n.scrollConstraints.lockZoom?cr(n,"elastic"):n;if(a.zoom.value>n.zoom.value){n.zoom=a.zoom,n.scrollX=a.scrollX,n.scrollY=a.scrollY,this.debounceConstrainScrollState(n);return}this.setState(n),this.state.scrollConstraints&&(n.zoom.value!==this.state.zoom.value?this.debounceConstrainScrollState(n):this.setState(cr(n)))});k(this,"debounceConstrainScrollState",Sn(t=>{let r=cr(t,"rigid"),n={scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom.value},a={scrollX:r.scrollX,scrollY:r.scrollY,zoom:r.zoom.value};b1(n,a)||(this.cancelInProgressAnimation?.(),this.animateToConstrainedArea(n,a))},200));k(this,"animateToConstrainedArea",(t,r)=>{let n=()=>{this.setState(a=>({shouldCacheIgnoreZoom:!1,scrollConstraints:{...a.scrollConstraints,animateOnNextUpdate:!1}}))};this.animateTranslateCanvas({fromValues:t,toValues:r,duration:200,onStart:()=>{this.setState(a=>({shouldCacheIgnoreZoom:!0,scrollConstraints:{...a.scrollConstraints,animateOnNextUpdate:!1}}))},onEnd:n,onCancel:n})});k(this,"animateTranslateCanvas",({fromValues:t,toValues:r,duration:n,onStart:a,onEnd:i,onCancel:l})=>{let s=gx({fromValues:t,toValues:r,interpolateValue:(c,m,p,d)=>{if(d==="zoom")return c*Math.pow(m/c,tr(p))},onStep:({scrollX:c,scrollY:m,zoom:p})=>{this.setState({scrollX:c,scrollY:m,zoom:{value:p}})},onStart:a,onEnd:i,onCancel:l,duration:n});this.cancelInProgressAnimation=()=>{s(),this.cancelInProgressAnimation=null}});k(this,"setToast",t=>{this.setState({toast:t})});k(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),a=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(a,null),await t.delete("shared-file"),window.history.replaceState(null,os,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});k(this,"addFiles",ct(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));k(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},a={},i=Array.isArray(t)?t:Object.values(t);for(let l of i)if(!n[l.id]&&(a[l.id]=l,n[l.id]=l,l.mimeType===ue.svg))try{let s=xE(Nh(yE(l.dataURL)),ue.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:a}});k(this,"updateScene",ct(t=>{let{elements:r,appState:n,collaborators:a,captureUpdate:i}=t;if(i){let l=r||void 0,s=n?Sy({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:i,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),a&&this.setState({collaborators:a})}));k(this,"applyDeltas",(t,r)=>{let n=ks.squash(...t),a={...this.state},i=new Map(this.scene.getElementsMapIncludingDeleted());return ks.applyTo(n,i,a,r)});k(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));k(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});k(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let a;n===void 0?a=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:a=n?t:null;let i=a?{name:a}:null;return i&&r&&(i.tab=r),this.setState({openSidebar:i}),!!a});k(this,"updateCurrentCursorPosition",ct(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));k(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),a=16;return an().rtl?{top:t+a,right:Math.max(this.state.width-(n?.left??this.state.width),0)+a,bottom:a,left:Math.max(r?.right??0,0)+a}:{top:t+a,right:Math.max(this.state.width-(r?.left??this.state.width)+a,0),bottom:a,left:Math.max(n?.right??0,0)+a}});k(this,"onKeyDown",ct(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(i,l){let s=i[l];return typeof s=="function"?s.bind(i):l==="key"?t.shiftKey?i.key.toUpperCase():i.key.toLowerCase():s}})),!ch(t.target)){if((t.key===T.ESCAPE||t.key===T.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let i=ae(this.scene.getNonDeletedElementsMap(),this.state);if(i.length===1&&Ue(i[0])&&t.key===T.ENTER){this.startImageCropping(i[0]);return}if(t.key===T.ESCAPE)this.updateEditorAtom(pr,null);else if(t.key===T.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(nt.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=wl(i);Et.get(pr)?.type==="panel"&&P1(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(pr,{type:"panel"})}if(t.key===T.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=xa(t.key);if(t[T.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=ae(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&Rd(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,Rh(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Ni(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(t.altKey){let s=ae(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),Rh(t.key));if(c){this.setState(p=>({selectedElementIds:Oe({[c]:!0},p)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Ni([m],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(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[T.CTRL_OR_CMD]&&t.key===T.P&&!t.shiftKey&&!t.altKey){this.setToast({message:u("commandPalette.shortcutHint",{shortcut:ht("commandPalette")})}),t.preventDefault();return}if(t[T.CTRL_OR_CMD]&&t.key.toLowerCase()===T.V&&(c0=t.shiftKey,clearTimeout(TC),TC=window.setTimeout(()=>{c0=!1},100)),t[T.CTRL_OR_CMD]&&so(t.target)&&(t.code===he.MINUS||t.code===he.EQUAL)){t.preventDefault();return}if(so(t.target)&&t.key!==T.ESCAPE||xa(t.key)&&ch(t.target))return;if(t.key===T.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===T.E&&t.shiftKey&&t[T.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===T.PAGE_UP||t.key===T.PAGE_DOWN){let i=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===T.PAGE_DOWN&&(i=-i),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+i})):this.translateCanvas(l=>({scrollY:l.scrollY+i}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===T.ALT&&_o("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),this.actionManager.handleKeyDown(t))||this.state.viewModeEnabled)return;if(t[T.CTRL_OR_CMD]&&this.state.isBindingEnabled&&(_o("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({isBindingEnabled:!1})),xa(t.key)){let i=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=new Set;i.filter(p=>co(p)).filter(p=>{let d=p.startBinding&&!i.some(b=>b.id===p.startBinding?.elementId),h=p.endBinding&&!i.some(b=>b.id===p.endBinding?.elementId);return d||h}).forEach(p=>l.add(p.id)),i=i.filter(p=>!l.has(p.id));let s=this.getEffectiveGridSize()&&(t.shiftKey?Zu:this.getEffectiveGridSize())||(t.shiftKey?N0:Zu),c=0,m=0;t.key===T.ARROW_LEFT?c=-s:t.key===T.ARROW_RIGHT?c=s:t.key===T.ARROW_UP?m=-s:t.key===T.ARROW_DOWN&&(m=s),i.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+m},{informMutation:!1,isDragging:!1}),on(p,this.scene,{simultaneouslyUpdated:i})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===T.ENTER){let i=this.scene.getSelectedElements(this.state);if(i.length===1){let l=i[0];if(t[T.CTRL_OR_CMD]||tt(l))ge(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Se(l)||this.actionManager.executeAction(ai));else if($(l)||$x(l)){let s;$(l)||(s=l);let c=Nd(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,p=c.y;this.startTextEditing({sceneX:m,sceneY:p,container:s}),t.preventDefault();return}else le(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let i=Dw(t.key,this);i?(this.state.activeTool.type!==i&&pe("toolbar",i,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),i==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===pt.sharp?pt.round:l.currentItemArrowType===pt.round?pt.elbow:pt.sharp})),this.setActiveTool({type:i}),t.stopPropagation()):t.key===T.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===T.SPACE&&De.pointers.size===0&&(jl=!0,He(this.interactiveCanvas,Pe.GRAB),t.preventDefault()),(t.key===T.G||t.key===T.S)&&!t.altKey&&!t[T.CTRL_OR_CMD]){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;t.key===T.G&&(yr(this.state.activeTool.type)||i.some(l=>yr(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===T.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[T.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===T.F){let i=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!i.length)return;(this.state.activeTool.type==="text"||i.find(l=>$(l)||xe(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===T.K&&!t.altKey&&!t[T.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:"laser"});return}t[T.CTRL_OR_CMD]&&(t.key===T.BACKSPACE||t.key===T.DELETE)&&this.updateEditorAtom(ni,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===T.S&&t.shiftKey,a=t.key===T.I||r===T.G&&t.shiftKey;(n||a)&&this.openEyeDropper({type:n?"stroke":"background"})}));k(this,"onKeyUp",ct(t=>{if(t.key===T.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?He(this.interactiveCanvas,Pe.GRAB):ms(this.state.activeTool.type)?Co(this.interactiveCanvas):(Uo(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Oe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),jl=!1),(t.key===T.ALT&&this.state.bindMode==="skip"||!t[T.CTRL_OR_CMD]&&!Li(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent)){let r=Ye({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),n=Ro(L(r.x,r.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let a=X.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());co(a)&&_o("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(a,n)}}if(!t[T.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),xa(t.key)){ys(this.scene.getSelectedElements(this.state).filter(Me),this.scene,this.state);let r=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Pd).forEach(n=>{n.startBinding&&this.scene.mutateElement(n,{startBinding:{...n.startBinding,...vh(n,r.get(n.startBinding.elementId),"start",r)}}),n.endBinding&&this.scene.mutateElement(n,{endBinding:{...n.endBinding,...vh(n,r.get(n.endBinding.elementId),"end",r)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:D.IMMEDIATELY})),!t[T.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:Oe({[r.id]:!0},n)})),Ni([r],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(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:D.IMMEDIATELY})}}));k(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);k(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=Ne(this.state,t);px(document.activeElement)&&this.focusContainer(),Ax(n.type)||this.setState({suggestedBinding:null}),n.type==="image"&&this.onImageToolbarButtonClick(),this.setState(a=>{let i={snapLines:a.snapLines.length?[]:a.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:ms(n.type)?a.selectedLinearElement:null};n.type==="freedraw"&&this.store.scheduleCapture();let l;return n.type==="lasso"?l={...a,...i,activeTool:n,...r?{}:{selectedElementIds:Oe({},a),selectedGroupIds:Oe({},a),editingGroupId:null,multiElement:null}}:n.type!=="selection"?l={...a,...i,activeTool:n,selectedElementIds:Oe({},a),selectedGroupIds:Oe({},a),editingGroupId:null,multiElement:null}:l={...a,...i,activeTool:n},l})});k(this,"setOpenDialog",t=>{this.setState({openDialog:t})});k(this,"setCursor",t=>{He(this.interactiveCanvas,t)});k(this,"resetCursor",()=>{Co(this.interactiveCanvas)});k(this,"isTouchScreenMultiTouchGesture",()=>De.pointers.size>=2);k(this,"getName",()=>this.state.name||this.props.name||`${u("labels.untitled")}-${sh()}`);k(this,"onGestureStart",ct(t=>{if(t.preventDefault(),this.props.interactive===!1)return!1;this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Oe({},this.state),activeEmbeddable:null}),De.initialScale=this.state.zoom.value}));k(this,"onGestureChange",ct(t=>{if(t.preventDefault(),this.props.interactive===!1)return!1;if(this.isTouchScreenMultiTouchGesture())return;let r=De.initialScale;r&&this.setState(n=>cr({...n,...pn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:vo(r*t.scale)},n)},"loose"))}));k(this,"onGestureEnd",ct(t=>{if(t.preventDefault(),this.props.interactive===!1)return!1;this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Oe(this.state.previousSelectedElementIds,this.state)}),De.initialScale=null}));k(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:a,autoEdit:i=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,a);a&&s&&(xe(a,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?$(m[0])?c=m[0]:a?c=xe(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,r):c=this.getTextElementAtPosition(t,r);let p=c?.fontFamily||this.state.currentItemFontFamily,d=c?.lineHeight||qr(p),h=this.state.currentItemFontSize;if(!c&&l&&a&&!Me(a)){let v=Ux(yt({fontSize:h,fontFamily:p}),d),x=Vx(h,d),y=Math.max(a.height,x),w=Math.max(a.width,v);this.scene.mutateElement(a,{height:y,width:w}),t=a.x+w/2,r=a.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,a))}let b=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),f=c||Cr({x:s?s.elementCenterX:t,y:s?s.elementCenterY: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,text:"",fontSize:h,fontFamily:p,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Ao.MIDDLE:$u,containerId:l?a?.id:void 0,groupIds:a?.groupIds??[],lineHeight:d,angle:a?Me(a)?0:a.angle:0,frameId:b?b.id:null});if(!c&&l&&a&&this.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:f.id})}),this.setState({editingTextElement:f}),!c)if(a&&l){let E=this.scene.getElementIndex(a.id);this.scene.insertElementAtIndex(f,E+1)}else this.scene.insertElement(f);i||c||a?this.handleTextWysiwyg(f,{isExistingElement:!!c}):this.setState({newElement:f,multiElement:null})});k(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});k(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});k(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let r=this.scene.getSelectedElements(this.state),{x:n,y:a}=Ye(t,this.state);if(r.length===1&&ge(r[0])){let l=r[0];if((t[T.CTRL_OR_CMD]&&Pd(l)||tt(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(ai);return}else if(this.state.selectedLinearElement&&Se(r[0])){let s=X.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:a},this.state,this.scene.getNonDeletedElementsMap()),c=s?X.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),X.deleteFixedSegment(r[0],this.scene,c);let m=X.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:a},this.state,this.scene.getNonDeletedElementsMap()),p=m?X.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&tt(l))return}if(r.length===1&&Ue(r[0])){this.startImageCropping(r[0]);return}if(Co(this.interactiveCanvas),nr(this.state).length>0){let l=this.getElementAtPosition(n,a),s=l&&oy(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...bt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Co(this.interactiveCanvas),!t[T.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,a);if(Ti(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,a);if(s&&(ft(s)||!jr(s.backgroundColor)||Si({point:L(n,a),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Nd(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,a=c.y}this.startTextEditing({sceneX:n,sceneY:a,insertAtParentCenter:!t.altKey,container:s})}}});k(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),a=-1;for(let i=n.length-1;i>=0;i--){let l=n[i];if(r&&l.id===r.id&&(a=i),l.link&&i>=a&&sm(l,this.scene.getNonDeletedElementsMap(),this.state,L(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});k(this,"redirectToLink",(t,r)=>{let n=wn(L(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),L(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>rs)return;let a=Ye(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),l=sm(this.hitLinkElement,i,this.state,L(a.x,a.y),this.editorInterface.formFactor==="phone"),s=Ye(this.lastPointerUpEvent,this.state),c=sm(this.hitLinkElement,i,this.state,L(s.x,s.y),this.editorInterface.formFactor==="phone");if(l&&c){I1();let m=this.hitLinkElement.link;if(m){m=rr(m);let p;if(this.props.onLinkOpen&&(p=kd("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},p)),!p?.defaultPrevented){let d=Ld(m)?"_self":"_blank",h=window.open(void 0,d);h&&(h.opener=null,h.location=m)}}}});k(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(a=>!a.locked&&Ch(t,a,r));return n.length?n[n.length-1]:null});k(this,"handleCanvasPointerMove",t=>{if(this.props.interactive===!1)return!1;this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let r=Ye(t,this.state),{x:n,y:a}=r;this.lastPointerMoveCoords={x:n,y:a},De.pointers.has(t.pointerId)&&De.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let i=De.initialScale;if(De.pointers.size===2&&De.lastCenter&&i&&De.initialDistance){let b=rb(De.pointers),f=b.x-De.lastCenter.x,E=b.y-De.lastCenter.y;De.lastCenter=b;let v=nb(Array.from(De.pointers.values())),x=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:v/De.initialDistance,y=x?vo(i*x):this.state.zoom.value;this.setState(w=>{let C=pn({viewportX:b.x,viewportY:b.y,nextZoom:y},w);return this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(f/y),scrollY:C.scrollY+2*(E/y),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else De.lastCenter=De.initialDistance=De.initialScale=null;if(jl||Xc||l0||ir(this.state))return;let s=sb($c,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?Co(this.interactiveCanvas):Uo(this.interactiveCanvas,this.state)),!this.state.newElement&&v3(this.state.activeTool.type)){let{originOffset:b,snapLines:f}=E3(this.scene.getNonDeletedElements(),this,{x:n,y:a},t,this.scene.getNonDeletedElementsMap());this.setState(E=>{let v=wi(E.snapLines,f),x=E.originSnapOffset?wi(E.originSnapOffset,b):b;return E.snapLines===v&&E.originSnapOffset===x?null:{snapLines:v,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(b=>b.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let b=this.state.newElement?null:X.handlePointerMoveInEditMode(t,n,a,this);b&&b!==this.state.selectedLinearElement&&Jo(()=>{this.setState({selectedLinearElement:b})})}if(_x(this.state.activeTool.type)){let{newElement:b}=this.state;if(!b&&Li(this.state)){let f=Ro(L(n,a),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),E=>Hd(this.state.zoom));f?this.setState({suggestedBinding:f}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:b,selectedLinearElement:f}=this.state,{x:E,y:v,points:x}=b,y=x[x.length-1],{lastCommittedPoint:w}=f;if(Uo(this.interactiveCanvas,this.state),y===w)Me(this.state.newElement)&&Li(this.state)&&Ro(L(n,a),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),S=>Hd(this.state.zoom))?(this.actionManager.executeAction($t,"ui",{event:t.nativeEvent,sceneCoords:{x:n,y:a}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Co(this.interactiveCanvas),this.setState(S=>({newElement:null,activeTool:Ne(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Oe({...S.selectedElementIds,[b.id]:!0},S),selectedLinearElement:new X(b,this.scene.getNonDeletedElementsMap())})))):wn(L(n-E,a-v),y)>=ad?(this.scene.mutateElement(b,{points:[...x,L(n-E,a-v)]},{informMutation:!1,isDragging:!1}),je(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[b.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:b.points.length-1}}})):He(this.interactiveCanvas,Pe.POINTER);else if(x.length>2&&w&&wn(L(n-E,a-v),w)<ad)He(this.interactiveCanvas,Pe.POINTER),this.scene.mutateElement(b,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1}),this.setState({selectedLinearElement:{...f,selectedPointsIndices:f.selectedPointsIndices?.includes(b.points.length)?[...f.selectedPointsIndices.filter(C=>C!==b.points.length&&C!==b.points.length-1),b.points.length-1]:f.selectedPointsIndices,lastCommittedPoint:b.points[b.points.length-1],initialState:{...f.initialState,lastClickedPoint:b.points.length-1}}});else{hs(x,this.state.zoom.value)&&He(this.interactiveCanvas,Pe.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Pd(b)){let A=Ro(L(n,a),this.scene.getNonDeletedElements(),C);_o("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(b,A)}je(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let S=X.handlePointerMove(t.nativeEvent,this,n,a,this.state.selectedLinearElement);S&&this.setState(S)}return}if(this.state.activeTool.type==="arrow"){let b=Ro(L(n,a),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),f=>Hd(this.state.zoom));b&&!Bd(L(n,a),b,this.scene.getNonDeletedElementsMap())&&this.setState({suggestedBinding:b})}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),p=this.scene.getSelectedElements(this.state);if(p.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,a),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(p.length===1&&Se(p[0]))&&!(ge(p[0])&&(this.editorInterface.userAgent.isMobileDevice||p[0].points.length===2))){let b=zh(m,this.state,n,a,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(b&&b.transformHandleType){He(this.interactiveCanvas,Fh(b));return}}}else if(p.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let b=Bh(_e(p),n,a,this.state.zoom,t.pointerType,this.editorInterface);if(b){He(this.interactiveCanvas,Fh({transformHandleType:b}));return}}let d=this.getElementAtPosition(n,a,{preferSelected:!0,includeLockedElements:!0}),h=null;d&&d.locked?h=null:h=d,this.hitLinkElement=this.getElementLinkAtPosition(r,d),!po(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(He(this.interactiveCanvas,Pe.POINTER),M2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(I1(),h&&(h.link||Vt(h))&&this.state.selectedElementIds[h.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?He(this.interactiveCanvas,$(h)?Pe.TEXT:Pe.CROSSHAIR):this.state.viewModeEnabled?He(this.interactiveCanvas,Pe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?He(this.interactiveCanvas,Pe.AUTO):s?He(this.interactiveCanvas,Pe.AUTO):t[T.CTRL_OR_CMD]?He(this.interactiveCanvas,Pe.AUTO):(h||this.isHittingCommonBoundingBoxOfSelectedElements(r,p))&&!h?.locked&&(h&&Ti(h)&&this.isIframeLikeElementCenter(h,t,n,a)?(He(this.interactiveCanvas,Pe.POINTER),this.setState({activeEmbeddable:{element:h,state:"hover"}})):(!h||!Se(h)||!(h.startBinding||h.endBinding))&&((this.state.activeTool.type!=="lasso"||p.length>0)&&He(this.interactiveCanvas,Pe.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,a)),this.state.openDialog?.name==="elementLinkSelector"&&h?this.setState(b=>({hoveredElementIds:wi(b.hoveredElementIds,bt({editingGroupId:b.editingGroupId,selectedElementIds:{[h.id]:!0}},this.scene.getNonDeletedElements(),b,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!h&&this.setState(b=>({hoveredElementIds:wi(b.hoveredElementIds,{})})))});k(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});k(this,"handleTouchMove",t=>{jc=!0});k(this,"handleCanvasPointerDown",t=>{let r=Ye(t,this.state),{x:n,y:a}=r;this.lastPointerMoveCoords={x:n,y:a};let i=t.target;if(i.setPointerCapture&&i.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(b=>({searchMatches:b.searchMatches&&{focusedId:null,matches:b.searchMatches.matches.map(f=>({...f,focus:!1}))}})),this.updateEditorAtom(Pb,null)),Et.get(pr)&&this.updateEditorAtom(pr,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let b=this.state.newElement;this.updateScene({...b.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(f=>f.id!==b.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:Oe(Object.keys(this.state.selectedElementIds).filter(f=>f!==b.id).reduce((f,E)=>(f[E]=this.state.selectedElementIds[E],f),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?D.EVENTUALLY:D.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(b=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=vi(this.editorInterface,{isTouchScreen:!0})),Xc||(this.lastPointerDownEvent=t,this.props.interactive!==!1&&this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===fr.ERASER&&this.state.activeTool.type!==mt.eraser){this.setState({activeTool:Ne(this.state,{type:mt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let b=()=>{f(),E?.(),po(this.state)&&this.setState({activeTool:Ne(this.state,{...this.state.activeTool.lastActiveTool||{type:mt.selection},lastActiveToolBeforeEraser:null})})},f=Ve(window,"pointerup",b,{once:!0}),E;requestAnimationFrame(()=>{E=this.missingPointerEventCleanupEmitter.once(b)})});return}if(t.button!==fr.MAIN&&t.button!==fr.TOUCH&&t.button!==fr.ERASER||De.pointers.size>1)return;let s=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.props.interactive!==!1&&this.handleDraggingScrollBar(t,s)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.props.interactive!==!1&&this.handleSelectionOnPointerDown(t,s))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let b=s.hit.element&&this.isASelectedElement(s.hit.element);!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!b&&(this.lassoTrail.startPath(s.origin.x,s.origin.y,t.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&s.hit.element&&!b&&(this.setState(f=>{let E={...f.selectedElementIds,[s.hit.element.id]:!0},v=[];Object.keys(f.selectedElementIds).forEach(y=>{let w=this.scene.getElement(y);w&&v.push(w)});let x=s.hit.element;if(le(x))No(v,x.id).forEach(y=>{delete E[y.id]});else if(x.frameId)E[x.frameId]&&delete E[x.id];else{let y=x.groupIds,w=new Set(y.flatMap(C=>Ke(this.scene.getNonDeletedElements(),C)).filter(C=>le(C)).map(C=>C.id));w.size>0&&v.forEach(C=>{C.frameId&&w.has(C.frameId)&&(delete E[C.id],C.groupIds.flatMap(S=>Ke(this.scene.getNonDeletedElements(),S)).forEach(S=>{delete E[S.id]}))})}return{...bt({editingGroupId:f.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),f,this),showHyperlinkPopup:x.link||Vt(x)?"info":!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,s):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="custom"?Uo(this.interactiveCanvas,this.state):this.state.activeTool.type===mt.frame||this.state.activeTool.type===mt.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(s),p=this.onPointerUpFromPointerDownHandler(s),d=this.onKeyDownFromPointerDownHandler(s),h=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(b=>p(b||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",m),window.addEventListener("pointerup",p),window.addEventListener("keydown",d),window.addEventListener("keyup",h),s.eventListeners.onMove=m,s.eventListeners.onUp=p,s.eventListeners.onKeyUp=h,s.eventListeners.onKeyDown=d)});k(this,"handleCanvasPointerUp",t=>{_o("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpEvent=t;let r=Ye({clientX:t.clientX,clientY:t.clientY},this.state),{x:n,y:a}=r;this.lastPointerMoveCoords={x:n,y:a};let i=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.editorInterface.formFactor==="phone"&&i<300){let l=this.getElementAtPosition(r.x,r.y);if(Ti(l)&&this.isIframeLikeElementCenter(l,t,r.x,r.y)){this.handleEmbeddableCenterClick(l);return}}if(this.editorInterface.isTouchScreen){let l=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,l)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?i<300&&Ti(this.hitLinkElement)&&!lE(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,L(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.editorInterface.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});k(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(jc=!1,ca?jc=!0:ca=window.setTimeout(()=>{ca=0,jc||this.handleCanvasContextMenu(t)},G0))});k(this,"resetContextMenuTimer",()=>{clearTimeout(ca),ca=0,jc=!1});k(this,"maybeCleanupAfterMissingPointerUp",t=>{Jc?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});k(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(De.pointers.size<=1&&(t.button===fr.WHEEL||t.button===fr.MAIN&&jl||ir(this.state)||this.state.viewModeEnabled)))return!1;Xc=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);He(this.interactiveCanvas,Pe.GRABBING);let{clientX:a,clientY:i}=t,l=nu(c=>{let m=a-c.clientX,p=i-c.clientY;if(a=c.clientX,i=c.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(p)>1)){r=!0;let d=b=>{document.body.removeEventListener("paste",d),b.stopPropagation()},h=()=>{setTimeout(()=>{document.body.removeEventListener("paste",d),window.removeEventListener("pointerup",h)},100)};document.body.addEventListener("paste",d),window.addEventListener("pointerup",h)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=ct(Jc=()=>{Jc=null,Xc=!1,jl||(this.state.viewModeEnabled?He(this.interactiveCanvas,Pe.GRAB):Uo(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),l.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerup",s),!0});k(this,"clearSelectionIfNotUsingSelection",()=>{ms(this.state.activeTool.type)||this.setState({selectedElementIds:Oe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});k(this,"handleSelectionOnPointerDown",(t,r)=>{if(ms(this.state.activeTool.type)){let n=this.scene.getNonDeletedElements(),a=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.selectedLinearElement?.isEditing&&!Se(i[0])&&!(ge(i[0])&&(this.editorInterface.userAgent.isMobileDevice||i[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=zh(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else i.length>1&&(r.resize.handleType=Bh(_e(i),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=wd(Vy(r.resize.handleType,i,a,r.origin.x,r.origin.y)),i.length===1&&ge(i[0])&&i[0].points.length===2&&(r.resize.arrowDirection=Ky(r.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,h=X.handlePointerDown(t,this,this.store,r.origin,d,this.scene);if(h.hitElement&&(r.hit.element=h.hitElement),h.linearElementEditor&&this.setState({selectedLinearElement:h.linearElementEditor}),h.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(d=>!d.locked),c=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let m=r.hit.element,p=r.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?Oe({[d.selectedLinearElement.elementId]:!0},this.state):Oe({},d)}));else if(m!=null){if(t[T.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(r.origin.x,r.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(r.hit.wasAddedToSelection=!0),this.setState(d=>({...ty(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!Ai(m,this.state.editingGroupId)&&this.setState({selectedElementIds:Oe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let h={...d.selectedElementIds,[m.id]:!0},b=[];if(Object.keys(d.selectedElementIds).forEach(f=>{let E=this.scene.getElement(f);E&&b.push(E)}),le(m))No(b,m.id).forEach(f=>{delete h[f.id]});else if(m.frameId)h[m.frameId]&&delete h[m.id];else{let f=m.groupIds,E=new Set(f.flatMap(v=>Ke(this.scene.getNonDeletedElements(),v)).filter(v=>le(v)).map(v=>v.id));E.size>0&&b.forEach(v=>{v.frameId&&E.has(v.frameId)&&(delete h[v.id],v.groupIds.flatMap(x=>Ke(this.scene.getNonDeletedElements(),x)).forEach(x=>{delete h[x.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(f=>d.selectedGroupIds[f])||(h={[m.id]:!0})),{...bt({editingGroupId:d.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||Vt(m)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});k(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,a=r.origin.y,i=this.getElementAtPosition(n,a,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,a);ft(i)&&(l=i,n=i.x+i.width/2,a=i.y+i.height/2),this.startTextEditing({sceneX:n,sceneY:a,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Co(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Ne(this.state,{type:this.state.preferredSelectionTool.type})})});k(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[a,i]=Ft(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:a,y:i}),s=t.pressure===.5,c=Ny({type:r,x:a,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:s,locked:!1,frameId:l?l.id:null,points:[L(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let d={...p.selectedElementIds};return delete d[c.id],{selectedElementIds:Oe(d,p)}});let m=Ro(L(n.origin.x,n.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:m,suggestedBinding:null})});k(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:a})=>{let[i,l]=Ft(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Dy({type:"iframe",x:i,y:l,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:a});return this.scene.insertElement(s),s});k(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[a,i]=Ft(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=La(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:u("toast.unrecognizedLinkFormat"),closable:!0});let s=_h({type:"embeddable",x:a,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:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});k(this,"newImagePlaceholder",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[a,i]=Ft(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:a,y:i}):null,s=100/this.state.zoom.value;return Oy({type:"image",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:l?l.id:null,x:a-s/2,y:i-s/2,width:s,height:s})});k(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(t.ctrlKey&&Jo(()=>{this.setState({isBindingEnabled:!1})}),this.state.multiElement){let{multiElement:a,selectedLinearElement:i}=this.state;if(je(i,"selectedLinearElement is expected to be set"),a.type==="line"&&hs(a.points,this.state.zoom.value)){Jo(()=>{this.setState({selectedLinearElement:{...i,lastCommittedPoint:a.points[a.points.length-1],initialState:{...i.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction($t);return}if(Se(a)&&a.points.length>1){this.actionManager.executeAction($t,"ui",{event:t.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}let{x:l,y:s}=a,{lastCommittedPoint:c}=i,m=Li(this.state)&&Ro(L(this.lastPointerMoveCoords?.x??l+a.points[a.points.length-1][0],this.lastPointerMoveCoords?.y??s+a.points[a.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(co(a)&&m||a.points.length>1&&c&&wn(L(n.origin.x-l,n.origin.y-s),c)<ad){this.actionManager.executeAction($t,"ui",{event:t.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}this.setState(p=>({selectedElementIds:Oe({...p.selectedElementIds,[a.id]:!0},p)})),He(this.interactiveCanvas,Pe.POINTER)}else{let[a,i]=Ft(n.origin.x,n.origin.y,t[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:a,y:i}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=r==="arrow"?[s,c]:[null,null],d=r==="arrow"?zi({type:r,x:a,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===pt.round?{type:Lt.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===pt.elbow,fixedSegments:this.state.currentItemArrowType===pt.elbow?[]:null}):Ir({type:r,x:a,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:Lt.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),h=L(n.origin.x,n.origin.y),b=this.scene.getNonDeletedElementsMap(),f=Li(this.state)?Ro(h,this.scene.getNonDeletedElements(),b):null;this.scene.mutateElement(d,{points:[L(0,0),L(0,0)]}),this.scene.insertElement(d),co(d)&&Ud(d,new Map([[0,{point:L(0,0),isDragging:!1}]]),h[0],h[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:ds(t.nativeEvent)}),Jo(()=>{this.setState(E=>{let v=null,x=E.selectedElementIds;if(ge(d)){v=new X(d,this.scene.getNonDeletedElementsMap());let y=d.points.length-1;v={...v,selectedPointsIndices:[y],initialState:{...v.initialState,lastClickedPoint:y,origin:L(n.origin.x,n.origin.y)}}}return x=this.state.activeTool.locked?E.selectedElementIds:Oe({[d.id]:!0},E),{...E,bindMode:"orbit",newElement:d,startBoundElement:f,suggestedBinding:f||null,selectedElementIds:x,selectedLinearElement:v}})}),co(d)&&_o("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,f)}});k(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,a]=Ft(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.getTopLayerFrameAtSceneCoords({x:n,y:a}),l={x:n,y:a,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(t),locked:!1,frameId:i?i.id:null},s;t==="embeddable"?s=_h({type:"embeddable",...l}):s=Tr({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});k(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,a]=Ft(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:a,opacity:this.state.currentItemOpacity,locked:!1,...We},l=r===mt.magicframe?Ph(i):rm(i);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});k(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});k(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(n=>{let a=this.scene.getElement(n);if(co(a)){if(a.startBinding){let i=this.scene.getElement(a.startBinding.elementId);Zt(i,this.scene.getElementsMapIncludingDeleted(),{boundElements:i.boundElements.filter(l=>l.id!==a.id)})}if(a.endBinding){let i=this.scene.getElement(a.endBinding.elementId);Zt(i,this.scene.getElementsMapIncludingDeleted(),{boundElements:i.boundElements.filter(l=>l.id!==a.id)})}}else Dd(a)&&a.boundElements?.forEach(i=>{if(i.type==="arrow"){let l=this.scene.getElement(i.id);l?.startBinding?.elementId===a.id&&Zt(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===a.id&&Zt(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||it(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,re(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});k(this,"initializeImage",async(t,r)=>{if(!Zh(r))throw new Error(u("errors.unsupportedFileType"));let n=r.type;if(He(this.interactiveCanvas,"wait"),n===ue.svg)try{r=qh(Nh(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(u("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(r)||bE(r));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(u("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{r=await hm(r,{maxWidthOrHeight:V0})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>th)throw new Error(u("errors.fileTooBig",{maxSize:`${Math.trunc(th/1024/1024)}MB`}))}let l=this.files[a]?.dataURL||await jh(r);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,a);if(this.addMissingFiles([{mimeType:n,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(a)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(a)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,a);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(u("errors.imageInsertError")))}})});k(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return re(n,{fileId:r})});k(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:a}=Ye({clientX:t,clientY:r},this.state),i=await im({description:"Image",extensions:Object.keys(is),multiple:!0});this.insertImages(i,n,a)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Ne(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction($t)})}});k(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),a=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),i=Math.min(r.naturalHeight,a),l=i*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-i/2;return{x:s,y:c,width:l,height:i,crop:null}});k(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:a}=await Uy({imageCache:this.imageCache,fileIds:t.map(i=>i.fileId),files:r});return a.size&&(this.store.scheduleAction(D.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(i=>An(i)&&a.has(i.fileId)?re(i,{status:"error"}):i))),{updatedFiles:n,erroredFiles:a}});k(this,"addNewImagesToImageCache",async(t=Gy(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(a=>!a.isDeleted&&!this.imageCache.has(a.fileId));if(n.length){let{updatedFiles:a}=await this.updateImageCache(n,r);if(a.size)for(let i of n)a.has(i.fileId)&&Er.delete(i);a.size&&this.scene.triggerUpdate()}});k(this,"scheduleImageRefresh",b7(()=>{this.addNewImagesToImageCache()},H0));k(this,"updateBindingEnabledOnPointerMove",t=>{let r=Qx(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});k(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});k(this,"insertImages",async(t,r,n)=>{let a=50/this.state.zoom.value,i=Oh(t.map(()=>this.newImagePlaceholder({sceneX:r,sceneY:n})),r,n,a);i.forEach(d=>this.scene.insertElement(d));let l=await Promise.all(i.map(async(d,h)=>{try{return await this.initializeImage(d,await _s(t[h]))}catch(b){return this.setState({errorMessage:b.message||u("errors.imageInsertError")}),re(d,{isDeleted:!0})}})),s=ie(l),c=Oh(l.filter(d=>!d.isDeleted),r,n,a),m=ie(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:Oe(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:D.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction($t)})});k(this,"handleAppOnDrop",async t=>{let{x:r,y:n}=Ye(t,this.state),a=await mc(t),i=a.getFiles();if(i.length===1){let{file:p,fileHandle:d}=i[0];if(p&&(p.type===ue.png||p.type===ue.svg))try{let h=await um(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...h,appState:{...h.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:D.IMMEDIATELY});return}catch(h){if(h.name!=="EncodingError")throw new Error(u("alerts.couldNotLoadInvalidFile"))}}let l=i.map(p=>p.file).filter(p=>Zh(p));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,r,n);let s=a.getData(ue.excalidrawlibIds),c=a.getData(ue.excalidrawlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(b=>d.includes(b.id))}else c&&(p=fE(c));p?.length&&(p=p.map(d=>({...d,elements:nn({type:"everything",elements:d.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:kl(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(i.length>0){let{file:p,fileHandle:d}=i[0];p&&await this.loadFileToCanvas(p,d)}let m=a.findByType(ue.text);if(m){let p=m.value;if(p&&Bi(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||La(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:r,sceneY:n,link:rr(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});k(this,"loadFileToCanvas",async(t,r)=>{t=await _s(t);try{let n=this.scene.getElementsIncludingDeleted(),a;try{a=await Xh(t,this.state,n,r)}catch(i){let l=i instanceof nE;if(l&&i.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:u("errors.imageToolNotSupported")});return}let s=l?u("alerts.cannotRestoreFromImage"):u("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!a)return;a.type===ue.excalidraw?(Oi(n.concat(a.data.elements)),this.store.scheduleMicroAction({action:D.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...a.data,appState:{...a.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:D.IMMEDIATELY})):a.type===ue.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(i=>{console.error(i),this.setState({errorMessage:u("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});k(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),this.props.interactive===!1||("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==fr.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:r,y:n}=Ye(t,this.state),a=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},i),s=a||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,h=t.clientY-m;pe("contextMenu","openContextMenu",s),this.setState({...a&&!this.state.selectedElementIds[a.id]?{...this.state,...bt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ge(a)?new X(a,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:h,left:d,items:this.getContextMenuItems(s)}})})});k(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let a=this.state.selectionElement,i=t.lastCoords;if(a&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){Ah({newElement:a,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:i.x,y:i.y,width:Ea(t.origin.x,i.x),height:Ea(t.origin.y,i.y),shouldMaintainAspectRatio:Ei(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=Ft(i.x,i.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=An(l)&&this.imageCache.get(l.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:d,snapLines:h}=y3(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:h}),co(l)||Ah({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Ea(t.originInGrid.x,s),height:Ea(t.originInGrid.y,c),shouldMaintainAspectRatio:Ue(l)?!Ei(r):Ei(r),shouldResizeFromCenter:lh(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===mt.frame||this.state.activeTool.type===mt.magicframe)&&this.setState({elementsToHighlight:mo(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});k(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,a=t.lastCoords,[i,l]=Ft(a.x-t.resize.offset.x,a.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&Ue(s)){let c=t.originalElements.get(s.id),m=An(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Ue(c)&&m&&!(m instanceof Promise)){let[p,d]=Ft(a.x,a.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:b,snapLines:f}=ib([s],[c],this,r,h,n);this.scene.mutateElement(s,Mx(s,this.scene.getNonDeletedElementsMap(),n,m.naturalWidth,m.naturalHeight,i+b.x,l+b.y,r.shiftKey?c.width/c.height:void 0)),on(s,this.scene),this.setState({isCropping:n&&n!=="rotation",snapLines:f})}return!0}return!1});k(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),a=n.filter(p=>le(p)),i=t.resize.handleType;if(a.length>0&&i==="rotation"||n.length===1&&Se(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:i&&i!=="rotation",isRotating:i==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=Ft(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(a.forEach(p=>{No(this.scene.getNonDeletedElements(),p.id).forEach(h=>{m.set(p.id+h.id,{x:h.x-p.x,y:h.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=Ft(l.x,l.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h={x:p-t.originInGrid.x,y:d-t.originInGrid.y},b=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:f,snapLines:E}=ib(n,ae(b,this.state),this,r,h,i);s+=f.x,c+=f.y,this.setState({snapLines:E})}if(Wy(t.originalElements,i,n,this.scene,ds(r),lh(r),n.some(p=>Ue(p))?!Ei(r):Ei(r),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return a.forEach(d=>{mo(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(h=>p.add(h))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});k(this,"getContextMenuItems",t=>{let r=[];if(r.push(hc,uc),t==="canvas")return this.state.viewModeEnabled?[...r,fc,ti,Sc,oi]:[E1,wt,hc,uc,gc,wt,Zm,L2,wt,fc,Mp,ti,Sc,oi];if(r.push(gc),this.state.viewModeEnabled)return[ei,...r];let n=this.editorInterface.formFactor==="desktop"?[wt,Gm,Wm,Ym,Vm]:[];return[wt,pc,ei,E1,wt,r3,n3,a3,wt,eu,wt,...r,wt,yp,Ep,wt,vp,d3,Lp,Ap,v2,wp,wt,Ip,...n,wt,kp,Sp,wt,ai,wt,xl,Rp,wt,Xm,yl,wt,tl]});k(this,"handleWheel",ct(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(nt.FRAME_NAME))){t[T.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Xc||this.props.interactive===!1)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let a=Math.sign(n),i=yi*100,l=Math.abs(n),s=n;l>i&&(s=i*a);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-a*Math.min(1,l/20),this.translateCanvas(m=>({...pn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:vo(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:a,scrollX:i})=>({scrollX:i-(n||r)/a.value}));return}this.translateCanvas(({zoom:a,scrollX:i,scrollY:l})=>({scrollX:i-r/a.value,scrollY:l-n/a.value}))}));k(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:a,y:i}=Ye({clientX:t,clientY:r},this.state);isNaN(a)||isNaN(i);let l={x:a,y:i,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:De.pointers})});k(this,"resetShouldCacheIgnoreZoomDebounced",Sn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));k(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:a,left:i,top:l}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:p}=this.state;if(n===s&&a===c&&i===p&&l===m){t&&t();return}this.setState({width:n,height:a,offsetLeft:i,offsetTop:l},()=>{t&&t()})}});k(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});k(this,"watchState",()=>{});k(this,"setScrollConstraints",t=>{t?this.setState({scrollConstraints:t,viewModeEnabled:!0},()=>{let r=cr({...this.state,scrollConstraints:t},"rigid");this.animateToConstrainedArea({scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom.value},{scrollX:r.scrollX,scrollY:r.scrollY,zoom:r.zoom.value})}):this.setState({scrollConstraints:null,viewModeEnabled:!1})});let r=_a(),{excalidrawAPI:n,viewModeEnabled:a=!1,zenModeEnabled:i=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${u("labels.untitled")}-${sh()}`,scrollConstraints:p}=t;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:a,zenModeEnabled:i,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight,scrollConstraints:p??null},this.refreshEditorInterface(),this.stylesPanelMode=ba(this.editorInterface),this.id=y7(),this.library=new z1(this),this.actionManager=new Ac(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Lh,this.canvas=document.createElement("canvas"),this.rc=x7.canvas(this.canvas),this.renderer=new Pc(this.scene),this.visibleElements=[],this.store=new Iy(this),this.history=new Rl(this.store),n){let d={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:h=>{this.actionManager.registerAction(h)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,app:this,setScrollConstraints:this.setScrollConstraints,onChange:h=>this.onChangeEmitter.on(h),onIncrement:h=>this.store.onStoreIncrementEmitter.on(h),onPointerDown:h=>this.onPointerDownEmitter.on(h),onPointerUp:h=>this.onPointerUpEmitter.on(h),onScrollChange:h=>this.onScrollChangeEmitter.on(h),onUserFollow:h=>this.onUserFollowEmitter.on(h)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Nn(this.scene),this.history=new Rl(this.store),this.actionManager.registerAll(Um),this.actionManager.registerAction(l3(this.history)),this.actionManager.registerAction(s3(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,a=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!a)break;for(let i of a)i.contentWindow===t.source&&(n=i.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,a=r.info.playerState;Object.values(ns).includes(a)&&s0.set(n,a)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){je(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),r=Ro(L(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),n=X.getElement(this.state.selectedLinearElement.elementId,t);n?.startBinding&&r?.id===n.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Jo(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:r}=this.lastPointerMoveCoords,n=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;je(n,"Last event must exist");let a=t-this.state.selectedLinearElement.pointerOffset.x,i=r-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?X.handlePointerMove(n,this,a,i,this.state.selectedLinearElement):X.handlePointDragging(n,this,a,i,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,r){if(t.isDeleted||Se(t))return;let n=()=>{if(this.bindModeHandler=null,je(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let b=this.state.selectedLinearElement.selectedPointsIndices.includes(0),f=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!b&&!f||b&&f)return}let{x:p,y:d}=this.lastPointerMoveCoords,h=Ro(L(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(h&&this.state.bindMode!=="skip"){je(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let b=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===h.id;Jo(()=>{je(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:b}}})});let f=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;je(f,"Last event must exist");let E=p-this.state.selectedLinearElement.pointerOffset.x,v=d-this.state.selectedLinearElement.pointerOffset.y,x=this.state.multiElement?X.handlePointerMove(f,this,E,v,this.state.selectedLinearElement):X.handlePointDragging(f,this,E,v,this.state.selectedLinearElement);x&&this.setState(x)}},a=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),h=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),b=d?r:t.startBinding&&p.get(t.startBinding.elementId),f=h?r:t.endBinding&&p.get(t.endBinding.elementId),E=b&&Sa(b,p),v=f&&Sa(f,p);a=!!(E&&v&&b.id!==f.id&&Ri(E,v))}let i=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=i?"startBinding":l?"endBinding":null,c=i?"endBinding":l?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===r?.id||s&&t[s]?.mode==="inside"&&r?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&r?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!r||this.previousHoveredBindableElement&&r.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Jo(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||a)&&!m&&(this.bindModeHandler=setTimeout(n,kn)),this.previousHoveredBindableElement=r}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Ta(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=s0.get(t.id);switch(n||(s0.set(t.id,ns.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case ns.PLAYING:case ns.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,a){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=t.x+2*t.width/3&&a>=t.y+t.height/3&&a<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,r=this.state.width,n=this.state.height,a=this.scene.getNonDeletedElements().filter(i=>Vt(i)&&this.embedsValidationStatus.get(i.id)===!0||Ta(i));return Re(v7,{children:a.map(i=>{let{x:l,y:s}=kt({sceneX:i.x,sceneY:i.y},this.state),c=Is(i,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(i.id);if(c&&!m&&this.initializedEmbeds.add(i.id),!(c||m))return null;let d;if(Ta(i)){d=null;let f=(i.customData?.generationData??this.magicGenerations.get(i.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(f.status==="done"){let E=f.html;d={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>E}}else if(f.status==="pending")d={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>Dh(`
|
|
46
|
+
Please fix the Mermaid syntax and regenerate a valid diagram.`;await v({prompt:B,isRepairFlow:!0})},U=async W=>{let q=d.messages.findIndex(oe=>oe.id===W.id);if(q>0){let oe=d.messages[q-1];oe.type==="user"&&typeof oe.content=="string"&&(f(),await v({prompt:oe.content,isRepairFlow:!0}))}},K=()=>{Gd({app:i,data:x})},F=W=>{let q=d.messages.findIndex(B=>B.id===W&&B.type==="assistant"),oe=d.messages.slice(0,q-1);m({...d,messages:oe})},$=W=>{m(q=>({...q,currentPrompt:W}))};return aR("div",{className:`ttd-dialog-layout ${p?"ttd-dialog-layout--split":"ttd-dialog-layout--chat-only"}`,children:[iE(u5,{chatId:d.id,messages:d.messages,currentPrompt:d.currentPrompt,onPromptChange:$,onGenerate:v,isGenerating:b?.isGenerating??!1,generatedResponse:b?.content,isMenuOpen:E,onMenuToggle:A,onMenuClose:M,onNewChat:S,onRestoreChat:w,onDeleteChat:T,savedChats:u,activeSessionId:d.id,onAbort:y,onMermaidTabClick:P,onAiRepairClick:D,onDeleteMessage:F,onInsertMessage:L,onRetry:U,onViewAsMermaid:O,renderWarning:r,renderWelcomeScreen:o}),p&&iE(g5,{canvasRef:a,hideErrorDetails:b?.errorType==="parse",error:s,loaded:e.loaded,onInsert:K})]})},iR=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:o,renderWarning:r,persistenceAdapter:n})=>iE(nR,{mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:o,renderWarning:r,persistenceAdapter:n}),f5=iR;import{Tabs as lR}from"radix-ui";import{useRef as b5}from"react";import{jsx as sR}from"react/jsx-runtime";var x5=e=>{let t=Ie(),o=b5(null),r=b5(0);return sR(lR.Root,{ref:o,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=o.current?.closest(".Modal__content");if(i){let l=i.offsetHeight||0;l>r.current&&(r.current=l,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&Sm(["text-to-diagram","mermaid"],n)&&t({openDialog:{name:e.dialog,tab:n}})},children:e.children})};x5.displayName="TTDDialogTabs";var E5=x5;import{Tabs as cR}from"radix-ui";import{jsx as dR}from"react/jsx-runtime";var aE=({children:e,...t})=>dR(cR.List,{className:"ttd-dialog-triggers",...t,children:e});aE.displayName="TTDDialogTabTriggers";import{Tabs as mR}from"radix-ui";import{jsx as y5}from"react/jsx-runtime";var dg=({children:e,tab:t,onSelect:o,...r})=>y5(mR.Trigger,{value:t,asChild:!0,onSelect:o,children:y5("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});dg.displayName="TTDDialogTabTrigger";import{Tabs as pR}from"radix-ui";import{jsx as uR}from"react/jsx-runtime";var mg=({tab:e,children:t,...o})=>uR(pR.Content,{...o,value:e,children:t});mg.displayName="TTDDialogTab";import{jsx as hn,jsxs as lE}from"react/jsx-runtime";var pg=e=>{let t=be();return t.openDialog?.name!=="ttd"?null:hn(fR,{...e,tab:t.openDialog.tab})};pg.WelcomeMessage=ig;var fR=Kn("TTDDialogBase",({tab:e,...t})=>{let o=Xe(),[r,n]=gR({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});return hR(()=>{(async()=>{await r.api,n(l=>({...l,loaded:!0}))})()},[r.api]),hn(Mt,{className:"ttd-dialog",onCloseRequest:()=>{o.setOpenDialog(null)},size:1520,title:!1,...t,autofocus:!1,children:lE(E5,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?hn("p",{className:"dialog-mermaid-title",children:h("mermaid.title")}):lE(aE,{children:[hn(dg,{tab:"text-to-diagram",children:lE("div",{className:"ttd-dialog-tab-trigger__content",children:[h("labels.textToDiagram"),hn("div",{className:"ttd-dialog-tab-trigger__badge",children:h("chat.aiBeta")})]})}),hn(dg,{tab:"mermaid",children:h("mermaid.label")})]}),!("__fallback"in t)&&hn(mg,{className:"ttd-dialog-content",tab:"text-to-diagram",children:hn(f5,{mermaidToExcalidrawLib:r,onTextSubmit:t.onTextSubmit,renderWelcomeScreen:t.renderWelcomeScreen,renderWarning:t.renderWarning,persistenceAdapter:t.persistenceAdapter})}),hn(mg,{className:"ttd-dialog-content",tab:"mermaid",children:hn(Qk,{mermaidToExcalidrawLib:r,isActive:e==="mermaid"})})]})})});import lN from"clsx";import sN from"lodash.throttle";import{useEffect as D5,useMemo as uE,useState as cN,memo as dN}from"react";import bR from"clsx";import{useEffect as w5,useRef as ug,useState as xR}from"react";var v5=.01,Kd=10,No=(e,t)=>!(t==="angle"&&re(e)),Et=(e,t)=>{let o=e+t/2;return o-o%t},zs=(e,t,o)=>Object.keys(e).map(r=>({original:(o??t).get(r),latest:t.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var Ka=(e,t,o,r,n,i,l=!0)=>{if(zt(o)&&(o.startBinding||o.endBinding)){if(Math.abs(e-o.x)<Ja&&Math.abs(t-o.y)<Ja)return;uf(o,"start",r),uf(o,"end",r)}let a=r.getNonDeletedElementsMap(),s=a.get(o.id);if(!s)return;let[c,d]=[o.x+o.width/2,o.y+o.height/2],[m,p]=ke(_(o.x,o.y),_(c,d),o.angle),u=e-m,b=t-p,[f,x]=ke(_(e,t),_(c+u,d+b),-o.angle);r.mutateElement(s,{x:f,y:x},{informMutation:l,isDragging:!1}),hi(s,r,n);let v=ve(o,i);if(v){let y=a.get(v.id);y&&r.mutateElement(y,{x:v.x+u,y:v.y+b},{informMutation:l,isDragging:!1})}if(re(o)){let y=er(i,o.id);y.forEach(E=>{let w=a.get(E.id);if(!w)return;let[T,S]=[E.x+E.width/2,E.y+E.height/2],[A,M]=ke(_(E.x,E.y),_(T,S),E.angle),O=Math.round(A+u),P=Math.round(M+b),[L,D]=ke(_(O,P),_(T+u,S+b),-E.angle);r.mutateElement(w,{x:L,y:D},{informMutation:l,isDragging:!1}),hi(w,r,n,{simultaneouslyUpdated:de(y)})})}},Hs=(e,t)=>{let r=kr(t).map(n=>He(e,n).reduce((i,l)=>(i[l.id]=!0,i),{}));return e.filter(n=>!gi(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as sE,jsxs as yR}from"react/jsx-runtime";var ER=({label:e,icon:t,dragInputCallback:o,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:l,property:a,scene:s,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=Xe(),u=Ie(),b=ug(null),f=ug(null),[x,v]=xR(r.toString()),y=ug(null);y.current||(y.current={originalAppState:Ir(c),originalElements:n,lastUpdatedValue:x,updatePending:!1}),w5(()=>{let T=r.toString();v(T),y.current.lastUpdatedValue=T},[r]);let E=(T,S,A)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let M=Number(T);if(isNaN(M)){v(r.toString());return}let O=Number(M.toFixed(2)),P=Number(r);(isNaN(P)||Math.abs(O-P)>=v5)&&(y.current.lastUpdatedValue=T,o({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:l,shouldChangeByStepSize:!1,scene:s,nextValue:O,property:a,originalAppState:A,setInputValue:L=>v(String(L)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:N.IMMEDIATELY}))},w=ug({});return w.current.handleInputValue=E,w5(()=>{let T=b.current,S=w.current;return()=>{let A=T?.value;A&&S.handleInputValue?.(A,y.current.originalElements,y.current.originalAppState),window.removeEventListener("pointermove",S.onPointerMove,!1),window.removeEventListener("pointerup",S.onPointerUp,!1)}},[i]),i?yR("div",{className:bR("drag-input-container",!i&&"disabled"),"data-testid":e,children:[sE("div",{className:"drag-input-label",ref:f,onPointerDown:T=>{if(b.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(b.current.value);isNaN(S)&&(S=0);let A=null,M=p.scene.getNonDeletedElements().reduce((F,$)=>(F.set($.id,Mr($)),F),new Map),O=n.map(F=>M.get(F.id)),P=Ir(c),L=0,D=0,U=F=>{if(A&&M!==null&&O!==null){let $=F.clientX-A.x;$!==0&&(D+=$,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),L+=D,o({accumulatedChange:L,instantChange:D,originalElements:O,originalElementsMap:M,shouldKeepAspectRatio:l,shouldChangeByStepSize:F.shiftKey,property:a,scene:s,originalAppState:P,setInputValue:W=>v(String(W)),app:p,setAppState:u}),D=0))}A={x:F.clientX,y:F.clientY}},K=()=>{window.removeEventListener("pointermove",U,!1),p.syncActionResult({captureUpdate:N.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:O,originalAppState:P}),A=null,L=0,D=0,O=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",K,!1)};w.current.onPointerMove=U,w.current.onPointerUp=K,window.addEventListener("pointermove",U,!1),window.addEventListener("pointerup",K,!1)}},onPointerEnter:()=>{f.current&&(f.current.style.cursor="ew-resize")},children:t?sE(on,{icon:t}):e}),sE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let S=T.target;S instanceof HTMLInputElement&&T.key===I.ENTER&&(E(S.value,n,c),p.focusContainer())}},ref:b,value:x,onChange:T=>{y.current.updatePending=!0,v(T.target.value)},onFocus:T=>{T.target.select(),y.current.originalElements=n,y.current.originalAppState=Ir(c)},onBlur:T=>{x?i&&E(T.target.value,y.current.originalElements,y.current.originalAppState):v(r.toString())},disabled:!i})]}):null},qt=ER;import{jsx as CR}from"react/jsx-runtime";var vR=15,wR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,scene:n,app:i})=>{let l=n.getNonDeletedElementsMap(),a=t[0];if(a&&!Re(a)){let s=l.get(a.id);if(!s)return;if(r!==void 0){let b=ja(r);n.mutateElement(s,{angle:b}),hi(s,n,i.state);let f=ve(s,l);f&&!Te(s)&&n.mutateElement(f,{angle:b});return}let c=Math.round(qa(a.angle)*100)/100,d=Math.round(e),m=(c+d)%360;o&&(m=Et(m,vR)),m=m<0?m+360:m;let p=ja(m);n.mutateElement(s,{angle:p}),hi(s,n,i.state);let u=ve(s,l);u&&!Te(s)&&n.mutateElement(u,{angle:p})}},TR=({element:e,scene:t,appState:o,property:r})=>CR(qt,{label:"A",icon:Wc,value:Math.round(qa(e.angle)%360*100)/100,elements:[e],dragInputCallback:wR,editable:No(e,"angle"),scene:t,appState:o,property:r}),T5=TR;import{jsx as SR}from"react/jsx-runtime";var C5=5,IR=({property:e,scene:t,appState:o,setAppState:r})=>SR(qt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:l,setInputValue:a})=>{r(s=>{let c;return n?c=n:i&&(c=l?Et(s.gridStep+C5*Math.sign(i),C5):s.gridStep+i),c?(c=Zw(c),a(c),{gridStep:c}):(a(s.gridStep),null)})},scene:t,value:o.gridStep,property:e,appState:o}),I5=IR;import{jsx as _R}from"react/jsx-runtime";var S5=10,kR=e=>e.type==="image",MR=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:l,originalAppState:a,instantChange:s,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=t[0],b=p.get(u.id);if(u&&b){let f=r||kR(u),x=u.width/u.height;if(a.croppingElementId===u.id){let v=p.get(u.id);if(!v||!ot(v)||!v.crop)return;let y=v.crop,E={...y},w=v.scale[0]===-1,T=v.scale[1]===-1,{width:S,height:A}=yn(v),M=y.naturalWidth/S,O=y.naturalHeight/A,P=w?y.width+y.x:y.naturalWidth-y.x,L=T?y.height+y.y:y.naturalHeight-y.y,D=sf*M,U=sf*O;if(i!==void 0){if(l==="width"){let q=i*M,oe=qe(q,D,P);E={...E,width:oe,x:w?y.x+y.width-oe:y.x}}else if(l==="height"){let q=i*O,oe=qe(q,U,L);E={...E,height:oe,y:T?y.y+y.height-oe:y.y}}c.mutateElement(v,{crop:E,width:E.width/(y.naturalWidth/S),height:E.height/(y.naturalHeight/A)});return}let K=l==="width"?s:0,F=l==="height"?s:0,$=qe(y.width+K,D,P),W=qe(y.height+F,D,L);E={...y,x:w?y.x+y.width-$:y.x,y:T?y.y+y.height-W:y.y,width:$,height:W},c.mutateElement(v,{crop:E,width:E.width/(y.naturalWidth/S),height:E.height/(y.naturalHeight/A)});return}if(i!==void 0){let v=Math.max(l==="width"?i:f?i*x:u.width,To),y=Math.max(l==="height"?i:f?i/x:u.height,To);if(bl(v,y,b,u,o,c,l==="width"?"e":"s",{shouldMaintainAspectRatio:f}),re(b)){let E=Mo(c.getElementsIncludingDeleted(),b,a,c.getNonDeletedElementsMap()),w=Kr(c.getElementsIncludingDeleted(),E,b);c.replaceAllElements(w)}return}{let v=l==="width"?e:0,y=l==="height"?e:0,E=Math.max(0,u.width+v);l==="width"&&(n?E=Et(E,S5):E=Math.round(E));let w=Math.max(0,u.height+y);if(l==="height"&&(n?w=Et(w,S5):w=Math.round(w)),f&&(l==="width"?w=Math.round(E/x*100)/100:E=Math.round(w*x*100)/100),w=Math.max(To,w),E=Math.max(To,E),bl(E,w,b,u,o,c,l==="width"?"e":"s",{shouldMaintainAspectRatio:f}),re(b)){let T=de(Mo(c.getElementsIncludingDeleted(),b,a,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},AR=({setAppState:e,app:t,originalElements:o,originalAppState:r})=>{let n=t.scene.getNonDeletedElementsMap(),i=o?.[0],l=i&&n.get(i.id);if(l&&re(l)){let a=Mo(t.scene.getElementsIncludingDeleted(),l,r,t.scene.getNonDeletedElementsMap()),s=Kr(t.scene.getElementsIncludingDeleted(),a,l);t.scene.replaceAllElements(s),e({elementsToHighlight:null})}},LR=({property:e,element:t,scene:o,appState:r})=>{let n=Ur(e==="width"?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&ot(t)&&t.crop){let{width:i,height:l}=yn(t);if(e==="width"){let a=i/t.crop.naturalWidth;n=Ur(t.crop.width*a,2)}if(e==="height"){let a=l/t.crop.naturalHeight;n=Ur(t.crop.height*a,2)}}return _R(qt,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:MR,value:n,editable:No(t,e),scene:o,appState:r,property:e,dragFinishedCallback:AR})},cE=LR;import{jsx as NR}from"react/jsx-runtime";var k5=4,PR=4,DR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),l=t[0];if(l){let a=i.get(l.id);if(!a||!ee(a))return;let s;if(r!==void 0)s=Math.max(Math.round(r),k5);else if(l.type==="text"){let c=Math.round(l.fontSize),d=Math.round(e);s=Math.max(c+d,k5),o&&(s=Et(s,PR))}s&&(n.mutateElement(a,{fontSize:s}),St(a,n.getContainerElement(a),n))}},RR=({element:e,scene:t,appState:o,property:r})=>{let n=ee(e)?e:Ht(e)?ve(e,t.getNonDeletedElementsMap()):null;return n?NR(qt,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:DR,icon:Ti,appState:o,scene:t,property:r}):null},M5=RR;import{jsx as zR}from"react/jsx-runtime";var OR=15,FR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,property:n,scene:i})=>{let l=i.getNonDeletedElementsMap(),a=t.map(c=>l.get(c.id)).filter(c=>c&&!gi(c)&&No(c,n)),s=t.filter(c=>!gi(c)&&No(c,n));if(r!==void 0){let c=ja(r);for(let d of a){if(!d)continue;i.mutateElement(d,{angle:c});let m=ve(d,l);m&&!Te(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<a.length;c++){let d=a[c];if(!d)continue;let m=s[c],p=Math.round(qa(m.angle)*100)/100,u=Math.round(e),b=(p+u)%360;o&&(b=Et(b,OR)),b=b<0?b+360:b;let f=ja(b);i.mutateElement(d,{angle:f});let x=ve(d,l);x&&!Te(d)&&i.mutateElement(x,{angle:f})}i.triggerUpdate()},BR=({elements:e,scene:t,appState:o,property:r})=>{let n=e.filter(s=>!gi(s)&&No(s,"angle")),i=n.map(s=>Math.round(qa(s.angle)%360*100)/100),l=new Set(i).size===1?i[0]:"Mixed",a=n.some(s=>No(s,"angle"));return zR(qt,{label:"A",icon:Wc,value:l,elements:e,dragInputCallback:FR,editable:a,appState:o,scene:t,property:r})},A5=BR;import{useMemo as HR}from"react";import{jsx as KR}from"react/jsx-runtime";var Us=10,UR=(e,t,o,r)=>{let n=r.x-e,i=r.y-t,l=r.width*o,a=r.height*o,s=e+n*o,c=t+i*o;return{width:l,height:a,x:s,y:c,...zw(r,l,a,!1),...ee(r)?{fontSize:r.fontSize*o}:{}}},GR=(e,t,o,r,n,i,l,a)=>{let s=a.getNonDeletedElementsMap(),c=UR(e,t,r,i);a.mutateElement(n,c);let d=ve(i,l);if(d){let m=d.fontSize*r;ko(n,a);let p=s.get(d.id);p&&ee(p)&&(a.mutateElement(p,{fontSize:m}),fv(n,a,o==="width"?"e":"s",!0))}},L5=(e,t,o,r,n,i,l,a,s,c)=>{i==="width"?t=Math.round(e/r*100)/100:e=Math.round(t*r*100)/100;let d=t/o;for(let m=0;m<a.length;m++){let p=a[m],u=l[m];GR(n[0],n[1],i,d,u,p,s,c)}},WR=({accumulatedChange:e,originalElements:t,originalElementsMap:o,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:l,property:a,setAppState:s,app:c})=>{let d=l.getNonDeletedElementsMap(),m=Hs(t,r);if(i!==void 0){for(let f of m){let x=zs(f,d,o);if(x.length>1){let v=x.map(D=>D.latest),y=x.map(D=>D.original),[E,w,T,S]=we(y),A=T-E,M=S-w,O=A/M,P=Math.max(To,a==="width"?Math.max(0,i):A),L=Math.max(To,a==="height"?Math.max(0,i):M);L5(P,L,M,O,_(E,w),a,v,y,o,l)}else{let[v]=x,y=v?.latest,E=v?.original;if(y&&E&&No(y,a)){let w=a==="width"?Math.max(0,i):y.width;a==="width"&&(n?w=Et(w,Us):w=Math.round(w));let T=a==="height"?Math.max(0,i):y.height;if(a==="height"&&(n?T=Et(T,Us):T=Math.round(T)),w=Math.max(To,w),T=Math.max(To,T),bl(w,T,y,E,o,l,a==="width"?"e":"s",{shouldInformMutation:!1}),re(y)){let S=Mo(l.getElementsIncludingDeleted(),y,r,l.getNonDeletedElementsMap()),A=Kr(l.getElementsIncludingDeleted(),S,y);l.replaceAllElements(A)}}}}l.triggerUpdate();return}let p=a==="width"?e:0,u=a==="height"?e:0,b=[];for(let f of m){let x=zs(f,d,o);if(x.length>1){let v=x.map(D=>D.latest),y=x.map(D=>D.original),[E,w,T,S]=we(y),A=T-E,M=S-w,O=A/M,P=Math.max(0,A+p);a==="width"&&(n?P=Et(P,Us):P=Math.round(P));let L=Math.max(0,M+u);a==="height"&&(n?L=Et(L,Us):L=Math.round(L)),P=Math.max(To,P),L=Math.max(To,L),L5(P,L,M,O,_(E,w),a,v,y,o,l)}else{let[v]=x,y=v?.latest,E=v?.original;if(y&&E&&No(y,a)){let w=Math.max(0,E.width+p);a==="width"&&(n?w=Et(w,Us):w=Math.round(w));let T=Math.max(0,E.height+u);if(a==="height"&&(n?T=Et(T,Us):T=Math.round(T)),w=Math.max(To,w),T=Math.max(To,T),bl(w,T,y,E,o,l,a==="width"?"e":"s",{shouldInformMutation:!1}),re(y)){let S=de(Mo(l.getElementsIncludingDeleted(),y,r,l.getNonDeletedElementsMap()));b.push(...S)}}}}s({elementsToHighlight:b}),l.triggerUpdate()},VR=({setAppState:e,app:t,originalElements:o,originalAppState:r})=>{let n=t.scene.getNonDeletedElementsMap(),i=o?.[0],l=i&&n.get(i.id);if(l&&re(l)){let a=Mo(t.scene.getElementsIncludingDeleted(),l,r,t.scene.getNonDeletedElementsMap()),s=Kr(t.scene.getElementsIncludingDeleted(),a,l);t.scene.replaceAllElements(s),e({elementsToHighlight:null})}},YR=({property:e,elements:t,elementsMap:o,atomicUnits:r,scene:n,appState:i})=>{let l=HR(()=>r.map(c=>{let d=zs(c,o);if(d.length>1){let[p,u,b,f]=we(d.map(x=>x.latest));return Math.round((e==="width"?b-p:f-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[o,r,e]),a=new Set(l).size===1?Math.round(l[0]*100)/100:"Mixed",s=l.length>0;return KR(qt,{label:e==="width"?"W":"H",elements:t,dragInputCallback:WR,value:a,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:VR})},dE=YR;import{jsx as qR}from"react/jsx-runtime";var _5=4,XR=4,$R=(e,t)=>e.reduce((o,r)=>{if(!r||gi(r))return o;if(ee(r))return o.push(r),o;if(Ht(r)){let n=ve(r,t);if(n)return o.push(n),o}return o},[]),ZR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),l=t.map(s=>i.get(s.id)),a;if(r){a=Math.max(Math.round(r),_5);for(let s of l)n.mutateElement(s,{fontSize:a}),St(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=t;for(let c=0;c<l.length;c++){let d=l[c],m=s[c],p=Math.round(m.fontSize),u=Math.round(e),b=Math.max(p+u,_5);o&&(b=Et(b,XR)),n.mutateElement(d,{fontSize:b}),St(d,n.getContainerElement(d),n)}n.triggerUpdate()}},jR=({elements:e,scene:t,appState:o,property:r,elementsMap:n})=>{let i=$R(e,n);if(!i.length)return null;let l=i.map(c=>Math.round(c.fontSize*10)/10),a=new Set(l).size===1?l[0]:"Mixed",s=l.length>0;return qR(qt,{label:"F",icon:Ti,elements:i,dragInputCallback:ZR,value:a,editable:s,scene:t,property:r,appState:o})},P5=jR;import{useMemo as JR}from"react";import{jsx as rN}from"react/jsx-runtime";var QR=(e,t,o,r,n,i,l)=>{for(let a=0;a<r.length;a++){let s=r[a],[c,d]=[s.x+s.width/2,s.y+s.height/2],[m,p]=ke(_(s.x,s.y),_(c,d),s.angle),u=e==="x"?Math.round(m+t):m,b=e==="y"?Math.round(p+o):p;Ka(u,b,s,i,l,n,!1)}},eN=(e,t,o,r,n,i)=>{let l=n.getNonDeletedElementsMap(),[a,s,,]=we(o),c=e-a,d=t-s;for(let m=0;m<o.length;m++){let p=o[m],u=l.get(p.id);if(u&&(!ee(u)||!u.containerId)){let[b,f]=[u.x+u.width/2,u.y+u.height/2],[x,v]=ke(_(u.x,u.y),_(b,f),u.angle);Ka(x+c,v+d,p,n,i,r,!1)}}},tN=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:n,property:i,scene:l,originalAppState:a,app:s})=>{let c=l.getNonDeletedElementsMap();if(n!==void 0){for(let u of Hs(t,a)){let b=zs(u,c,o);if(b.length>1){let[f,x,,]=we(b.map(E=>E.latest));eN(i==="x"?n:f,i==="y"?n:x,b.map(E=>E.original),o,l,s.state)}else{let f=b[0]?.original,x=b[0]?.latest;if(f&&x&&No(x,i)){let[v,y]=[f.x+f.width/2,f.y+f.height/2],[E,w]=ke(_(f.x,f.y),_(v,y),f.angle);Ka(i==="x"?n:E,i==="y"?n:w,f,l,s.state,o,!1)}}}l.triggerUpdate();return}let d=r?Et(e,Kd):e;QR(i,i==="x"?d:0,i==="y"?d:0,t,o,l,s.state),l.triggerUpdate()},oN=({property:e,elements:t,elementsMap:o,atomicUnits:r,scene:n,appState:i})=>{let l=JR(()=>r.map(s=>{let c=Object.keys(s).map(f=>o.get(f)).filter(f=>f!==void 0);if(c.length>1){let[f,x]=we(c);return Math.round((e==="x"?f:x)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,b]=ke(_(d.x,d.y),_(m,p),d.angle);return Math.round((e==="x"?u:b)*100)/100}),[r,o,e]),a=new Set(l).size===1?l[0]:"Mixed";return rN(qt,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:tN,value:a,property:e,scene:n,appState:i})},mE=oN;import{jsx as aN}from"react/jsx-runtime";var nN=({accumulatedChange:e,instantChange:t,originalElements:o,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:l,scene:a,originalAppState:s,app:c})=>{let d=a.getNonDeletedElementsMap(),m=o[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[b,f]=ke(_(m.x,m.y),_(p,u),m.angle);if(s.croppingElementId===m.id){let w=d.get(m.id);if(!w||!ot(w)||!w.crop)return;let T=w.crop,S=T,A=w.scale[0]===-1,M=w.scale[1]===-1,{width:O,height:P}=yn(w);if(i!==void 0){if(l==="x"){let U=i*(T.naturalWidth/O);A?S={...T,x:qe(T.naturalWidth-U-T.width,0,T.naturalWidth-T.width)}:S={...T,x:qe(i*(T.naturalWidth/O),0,T.naturalWidth-T.width)}}l==="y"&&(S={...T,y:qe(i*(T.naturalHeight/P),0,T.naturalHeight-T.height)}),a.mutateElement(w,{crop:S});return}let L=(l==="x"?t:0)*(A?-1:1),D=(l==="y"?t:0)*(M?-1:1);S={...T,x:qe(T.x+L,0,T.naturalWidth-T.width),y:qe(T.y+D,0,T.naturalHeight-T.height)},a.mutateElement(w,{crop:S});return}if(i!==void 0){Ka(l==="x"?i:b,l==="y"?i:f,m,a,c.state,r);return}let x=l==="x"?e:0,v=l==="y"?e:0,y=l==="x"?Math.round(n?Et(m.x+x,Kd):b+x):b,E=l==="y"?Math.round(n?Et(m.y+v,Kd):f+v):f;Ka(y,E,m,a,c.state,r)},iN=({property:e,element:t,scene:o,appState:r})=>{let[n,i]=ke(_(t.x,t.y),_(t.x+t.width/2,t.y+t.height/2),t.angle),l=Ur(e==="x"?n:i,2);if(r.croppingElementId===t.id&&ot(t)&&t.crop){let a=qy(t);a&&(l=Ur(e==="x"?a.x:a.y,2))}return aN(qt,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:nN,scene:o,value:l,property:e,appState:r})},pE=iN;import{Fragment as hE,jsx as he,jsxs as Oo}from"react/jsx-runtime";var mN=50,Xd=e=>{let t=tn(),o=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),n=Gi(e.app);return he(pN,{...e,appState:t,sceneNonce:o,selectedElements:r,gridModeEnabled:n})},pt=({children:e,columns:t=1,heading:o,style:r,...n})=>he("div",{className:lN("exc-stats__row",{"exc-stats__row--heading":o}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...n,children:e});pt.displayName="StatsRow";var hg=({children:e,order:t,style:o,...r})=>he("div",{className:"exc-stats__rows",style:{order:t,...o},...r,children:e});hg.displayName="StatsRows";Xd.StatsRow=pt;Xd.StatsRows=hg;var pN=dN(({app:e,onClose:t,renderCustomStats:o,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:l})=>{let a=e.scene,s=a.getNonDeletedElements(),c=a.getNonDeletedElementsMap(),d=Ie(),m=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&ot(m),b=u?yn(m):null,[f,x]=cN({width:0,height:0}),v=uE(()=>sN(w=>{let T=we(w);x({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},mN),[]);D5(()=>{v(s)},[i,s,v]),D5(()=>()=>v.cancel(),[v]);let y=uE(()=>Hs(r,n),[r,n]),E=uE(()=>$m(r),[r]);return he("div",{className:"exc-stats",children:Oo(yt,{padding:3,children:[Oo("div",{className:"title",children:[he("h2",{children:h("stats.title")}),he("div",{className:"close",onClick:t,children:Go})]}),Oo(id,{label:he("h3",{children:h("stats.generalStats")}),open:!!(n.stats.panels&tc.generalStats),openTrigger:()=>d(w=>({stats:{open:!0,panels:w.stats.panels^tc.generalStats}})),children:[Oo(hg,{children:[he(pt,{heading:!0,children:h("stats.scene")}),Oo(pt,{columns:2,children:[he("div",{children:h("stats.shapes")}),he("div",{children:s.length})]}),Oo(pt,{columns:2,children:[he("div",{children:h("stats.width")}),he("div",{children:f.width})]}),Oo(pt,{columns:2,children:[he("div",{children:h("stats.height")}),he("div",{children:f.height})]}),l&&Oo(hE,{children:[he(pt,{heading:!0,children:"Canvas"}),he(pt,{children:he(I5,{property:"gridStep",scene:a,appState:n,setAppState:d})})]})]}),o?.(s,n)]}),!E&&r.length>0&&he("div",{id:"elementStats",style:{marginTop:12},children:he(id,{label:he("h3",{children:h("stats.elementProperties")}),open:!!(n.stats.panels&tc.elementProperties),openTrigger:()=>d(w=>({stats:{open:!0,panels:w.stats.panels^tc.elementProperties}})),children:Oo(hg,{children:[m&&Oo(hE,{children:[u&&he(pt,{heading:!0,children:h("labels.unCroppedDimension")}),n.croppingElementId&&ot(m)&&b&&Oo(pt,{columns:2,children:[he("div",{children:h("stats.width")}),he("div",{children:Ur(b.width,2)})]}),n.croppingElementId&&ot(m)&&b&&Oo(pt,{columns:2,children:[he("div",{children:h("stats.height")}),he("div",{children:Ur(b.height,2)})]}),he(pt,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?h("labels.imageCropping"):h(`element.${m.type}`)}),he(pt,{children:he(pE,{element:m,property:"x",elementsMap:c,scene:a,appState:n})}),he(pt,{children:he(pE,{element:m,property:"y",elementsMap:c,scene:a,appState:n})}),he(pt,{children:he(cE,{property:"width",element:m,scene:a,appState:n})}),he(pt,{children:he(cE,{property:"height",element:m,scene:a,appState:n})}),he(pt,{children:he(T5,{property:"angle",element:m,scene:a,appState:n})}),he(pt,{children:he(M5,{property:"fontSize",element:m,scene:a,appState:n})})]}),p&&Oo(hE,{children:[Um(p)&&he(pt,{heading:!0,children:h("element.group")}),Oo(pt,{columns:2,style:{margin:"0.3125rem 0"},children:[he("div",{children:h("stats.shapes")}),he("div",{children:r.length})]}),he(pt,{children:he(mE,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:a,appState:n})}),he(pt,{children:he(mE,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:a,appState:n})}),he(pt,{children:he(dE,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:a,appState:n})}),he(pt,{children:he(dE,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:a,appState:n})}),he(pt,{children:he(A5,{property:"angle",elements:p,scene:a,appState:n})}),he(pt,{children:he(P5,{property:"fontSize",elements:p,scene:a,appState:n,elementsMap:c})})]})]})})})]})})},(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);import{useCallback as uN,useEffect as R5,useState as N5}from"react";import{jsx as Gs,jsxs as gg}from"react/jsx-runtime";var hN=({sourceElementId:e,onClose:t,appState:o,scene:r,generateLinkForSelection:n=ep})=>{let i=r.getNonDeletedElementsMap(),l=i.get(e)?.link??null,[a,s]=N5(l),[c,d]=N5(!1);R5(()=>{let p=ae(i,o),u=l;if(p.length>0&&n){let b=tp(p,o);b&&(u=Sr(n(b.id,b.type)))}s(u)},[i,o,o.selectedElementIds,l,n]);let m=uN(()=>{if(a&&a!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:a})}if(!a&&c&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}t?.()},[e,a,i,c,r,t]);return R5(()=>{let p=u=>{o.openDialog?.name==="elementLinkSelector"&&u.key===I.ENTER&&m(),o.openDialog?.name==="elementLinkSelector"&&u.key===I.ESCAPE&&t?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[o,t,m]),gg("div",{className:"ElementLinkDialog",children:[gg("div",{className:"ElementLinkDialog__header",children:[Gs("h2",{children:h("elementLink.title")}),Gs("p",{children:h("elementLink.desc")})]}),gg("div",{className:"ElementLinkDialog__input",children:[Gs(Fi,{value:a??"",onChange:p=>{c||d(!0),s(p)},onKeyDown:p=>{p.key===I.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),l&&a&&Gs(Q,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:()=>{s(null),d(!0)},className:"ElementLinkDialog__remove",icon:Kt})]}),gg("div",{className:"ElementLinkDialog__actions",children:[Gs(Un,{label:h("buttons.cancel"),onClick:()=>{t?.()},style:{marginRight:10}}),Gs(Un,{label:h("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},O5=hN;import gN,{useState as fN}from"react";import{Fragment as bN,jsx as gE}from"react/jsx-runtime";var F5=({children:e,onClose:t})=>{let[o,r]=fN(!!e),{container:n}=Je(),i=gN.useCallback(()=>{r(!1),t&&t(),n?.focus()},[t,n]);return gE(bN,{children:o&&gE(Mt,{size:"small",onCloseRequest:i,title:h("errorDialog.title"),children:gE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import xN from"react";import{Fragment as z5,jsx as X,jsxs as Yo}from"react/jsx-runtime";var EN=()=>Yo("div",{className:"HelpDialog__header",children:[Yo("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[X("div",{className:"HelpDialog__link-icon",children:Ep}),h("helpDialog.documentation")]}),Yo("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[X("div",{className:"HelpDialog__link-icon",children:Ep}),h("helpDialog.blog")]}),Yo("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[X("div",{className:"HelpDialog__link-icon",children:Bc}),h("helpDialog.github")]}),Yo("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[X("div",{className:"HelpDialog__link-icon",children:L1}),"YouTube"]})]}),yN=e=>Yo(z5,{children:[X("h3",{children:e.title}),X("div",{className:"HelpDialog__islands-container",children:e.children})]}),fE=e=>Yo("div",{className:`HelpDialog__island ${e.className}`,children:[X("h4",{className:"HelpDialog__island-title",children:e.caption}),X("div",{className:"HelpDialog__island-content",children:e.children})]});function*vN(e,t){let o=!0;for(let r of e)o||(yield t),o=!1,yield r}var wN=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),j=({label:e,shortcuts:t,isOr:o=!0})=>{let r=t.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(l=>X(TN,{children:wN(l)},l)));return Yo("div",{className:"HelpDialog__shortcut",children:[X("div",{children:e}),X("div",{className:"HelpDialog__key-container",children:[...vN(r,o?h("helpDialog.or"):"")]})]})},TN=e=>X("kbd",{className:"HelpDialog__key",...e}),B5=({onClose:e})=>{let t=Qe(),o=xN.useCallback(()=>{e&&e()},[e]);return X(z5,{children:Yo(Mt,{onCloseRequest:o,title:h("helpDialog.title"),className:"HelpDialog",children:[X(EN,{}),Yo(yN,{title:h("helpDialog.shortcuts"),children:[Yo(fE,{className:"HelpDialog__island--tools",caption:h("helpDialog.tools"),children:[X(j,{label:h("toolBar.hand"),shortcuts:[I.H]}),X(j,{label:h("toolBar.selection"),shortcuts:[I.V,I[1]]}),X(j,{label:h("toolBar.rectangle"),shortcuts:[I.R,I[2]]}),X(j,{label:h("toolBar.diamond"),shortcuts:[I.D,I[3]]}),X(j,{label:h("toolBar.ellipse"),shortcuts:[I.O,I[4]]}),X(j,{label:h("toolBar.arrow"),shortcuts:[I.A,I[5]]}),X(j,{label:h("toolBar.line"),shortcuts:[I.L,I[6]]}),X(j,{label:h("toolBar.freedraw"),shortcuts:[I.P,I[7]]}),X(j,{label:h("toolBar.text"),shortcuts:[I.T,I[8]]}),X(j,{label:h("toolBar.image"),shortcuts:[I[9]]}),X(j,{label:h("toolBar.eraser"),shortcuts:[I.E,I[0]]}),X(j,{label:h("toolBar.frame"),shortcuts:[I.F]}),X(j,{label:h("toolBar.laser"),shortcuts:[I.K]}),X(j,{label:h("toolBar.bucketfill"),shortcuts:[I.B]}),X(j,{label:h("labels.eyeDropper"),shortcuts:[I.I,"Shift+S","Shift+G"]}),X(j,{label:h("helpDialog.editLineArrowPoints"),shortcuts:[H("CtrlOrCmd+Enter")]}),X(j,{label:h("helpDialog.editText"),shortcuts:[H("Enter")]}),X(j,{label:h("helpDialog.textNewLine"),shortcuts:[H("Enter"),H("Shift+Enter")]}),X(j,{label:h("helpDialog.textFinish"),shortcuts:[H("Esc"),H("CtrlOrCmd+Enter")]}),X(j,{label:h("helpDialog.curvedArrow"),shortcuts:["A",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),X(j,{label:h("helpDialog.curvedLine"),shortcuts:["L",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),X(j,{label:h("helpDialog.cropStart"),shortcuts:[h("helpDialog.doubleClick"),H("Enter")],isOr:!0}),X(j,{label:h("helpDialog.cropFinish"),shortcuts:[H("Enter"),H("Escape")],isOr:!0}),X(j,{label:h("toolBar.lock"),shortcuts:[I.Q]}),X(j,{label:h("helpDialog.preventBinding"),shortcuts:[H("CtrlOrCmd")]}),X(j,{label:h("toolBar.link"),shortcuts:[H("CtrlOrCmd+K")]}),X(j,{label:h("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Yo(fE,{className:"HelpDialog__island--view",caption:h("helpDialog.view"),children:[X(j,{label:h("buttons.zoomIn"),shortcuts:[H("CtrlOrCmd++")]}),X(j,{label:h("buttons.zoomOut"),shortcuts:[H("CtrlOrCmd+-")]}),X(j,{label:h("buttons.resetZoom"),shortcuts:[H("CtrlOrCmd+0")]}),X(j,{label:h("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),X(j,{label:h("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),X(j,{label:h("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),X(j,{label:h("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),X(j,{label:h("buttons.zenMode"),shortcuts:[H("Alt+Z")]}),X(j,{label:h("buttons.objectsSnapMode"),shortcuts:[H("Alt+S")]}),X(j,{label:h("labels.toggleGrid"),shortcuts:[H("CtrlOrCmd+'")]}),X(j,{label:h("labels.viewMode"),shortcuts:[H("Alt+R")]}),t.isActionEnabled(Bn)&&X(j,{label:h("labels.toggleTheme"),shortcuts:[H("Alt+Shift+D")]}),X(j,{label:h("stats.fullTitle"),shortcuts:[H("Alt+/")]}),X(j,{label:h("search.title"),shortcuts:[rt("searchMenu")]}),X(j,{label:h("commandPalette.title"),shortcuts:bn?[rt("commandPalette")]:[rt("commandPalette"),rt("commandPalette",1)]})]}),Yo(fE,{className:"HelpDialog__island--editor",caption:h("helpDialog.editor"),children:[X(j,{label:h("helpDialog.createFlowchart"),shortcuts:[H("CtrlOrCmd+Arrow Key")],isOr:!0}),X(j,{label:h("helpDialog.navigateFlowchart"),shortcuts:[H("Alt+Arrow Key")],isOr:!0}),X(j,{label:h("labels.moveCanvas"),shortcuts:[H(`Space+${h("helpDialog.drag")}`),H(`Wheel+${h("helpDialog.drag")}`)],isOr:!0}),X(j,{label:h("buttons.clearReset"),shortcuts:[H("CtrlOrCmd+Delete")]}),X(j,{label:h("labels.delete"),shortcuts:[H("Delete")]}),X(j,{label:h("labels.cut"),shortcuts:[H("CtrlOrCmd+X")]}),X(j,{label:h("labels.copy"),shortcuts:[H("CtrlOrCmd+C")]}),X(j,{label:h("labels.paste"),shortcuts:[H("CtrlOrCmd+V")]}),X(j,{label:h("labels.pasteAsPlaintext"),shortcuts:[H("CtrlOrCmd+Shift+V")]}),X(j,{label:h("labels.selectAll"),shortcuts:[H("CtrlOrCmd+A")]}),X(j,{label:h("labels.multiSelect"),shortcuts:[H(`Shift+${h("helpDialog.click")}`)]}),X(j,{label:h("helpDialog.deepSelect"),shortcuts:[H(`CtrlOrCmd+${h("helpDialog.click")}`)]}),X(j,{label:h("helpDialog.deepBoxSelect"),shortcuts:[H(`CtrlOrCmd+${h("helpDialog.drag")}`)]}),(Yl||bn)&&X(j,{label:h("labels.copyAsPng"),shortcuts:[H("Shift+Alt+C")]}),X(j,{label:h("labels.copyStyles"),shortcuts:[H("CtrlOrCmd+Alt+C")]}),X(j,{label:h("labels.pasteStyles"),shortcuts:[H("CtrlOrCmd+Alt+V")]}),X(j,{label:h("labels.sendToBack"),shortcuts:[Io?H("CtrlOrCmd+Alt+["):H("CtrlOrCmd+Shift+[")]}),X(j,{label:h("labels.bringToFront"),shortcuts:[Io?H("CtrlOrCmd+Alt+]"):H("CtrlOrCmd+Shift+]")]}),X(j,{label:h("labels.sendBackward"),shortcuts:[H("CtrlOrCmd+[")]}),X(j,{label:h("labels.bringForward"),shortcuts:[H("CtrlOrCmd+]")]}),X(j,{label:h("labels.alignTop"),shortcuts:[H("CtrlOrCmd+Shift+Up")]}),X(j,{label:h("labels.alignBottom"),shortcuts:[H("CtrlOrCmd+Shift+Down")]}),X(j,{label:h("labels.alignLeft"),shortcuts:[H("CtrlOrCmd+Shift+Left")]}),X(j,{label:h("labels.alignRight"),shortcuts:[H("CtrlOrCmd+Shift+Right")]}),X(j,{label:h("labels.duplicateSelection"),shortcuts:[H("CtrlOrCmd+D"),H(`Alt+${h("helpDialog.drag")}`)]}),X(j,{label:h("helpDialog.toggleElementLock"),shortcuts:[H("CtrlOrCmd+Shift+L")]}),X(j,{label:h("buttons.undo"),shortcuts:[H("CtrlOrCmd+Z")]}),X(j,{label:h("buttons.redo"),shortcuts:Cy?[H("CtrlOrCmd+Y"),H("CtrlOrCmd+Shift+Z")]:[H("CtrlOrCmd+Shift+Z")]}),X(j,{label:h("labels.group"),shortcuts:[H("CtrlOrCmd+G")]}),X(j,{label:h("labels.ungroup"),shortcuts:[H("CtrlOrCmd+Shift+G")]}),X(j,{label:h("labels.flipHorizontal"),shortcuts:[H("Shift+H")]}),X(j,{label:h("labels.flipVertical"),shortcuts:[H("Shift+V")]}),X(j,{label:h("labels.showStroke"),shortcuts:[H("S")]}),X(j,{label:h("labels.showBackground"),shortcuts:[H("G")]}),X(j,{label:h("labels.showFonts"),shortcuts:[H("Shift+F")]}),X(j,{label:h("labels.decreaseFontSize"),shortcuts:[H("CtrlOrCmd+Shift+<")]}),X(j,{label:h("labels.increaseFontSize"),shortcuts:[H("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as G5,useRef as W5,useState as Xa}from"react";import{useCallback as CN,useRef as IN,useState as SN}from"react";var kN=2e3,H5=()=>{let[e,t]=SN(null),o=IN(0),r=()=>{clearTimeout(o.current),t("success"),o.current=window.setTimeout(()=>{t(null)},kN)},n=CN(()=>{t(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import MN from"clsx";import{jsx as U5}from"react/jsx-runtime";var $d=({title:e,name:t,checked:o,onChange:r,disabled:n=!1})=>U5("div",{className:MN("Switch",{toggled:o,disabled:n}),children:U5("input",{name:t,id:t,title:e,type:"checkbox",checked:o,disabled:n,onChange:()=>r(!o),onKeyDown:i=>{i.key===" "&&r(!o)}})});import{jsx as ut,jsxs as ji}from"react/jsx-runtime";var AN=()=>ji("div",{children:[ut("h3",{children:h("canvasError.cannotShowPreview")}),ut("p",{children:ut("span",{children:h("canvasError.canvasTooBig")})}),ji("em",{children:["(",h("canvasError.canvasTooBigTip"),")"]})]}),LN=({appStateSnapshot:e,elementsSnapshot:t,files:o,actionManager:r,onExportImage:n,name:i,exportWithDarkMode:l})=>{let a=Ge(t,e),[s,c]=Xa(i),[d,m]=Xa(a),[p,u]=Xa(e.exportBackground),[b,f]=Xa(e.exportEmbedScene),[x,v]=Xa(e.exportScale),y=W5(null),E=W5(0),[w,T]=Xa(null),{onCopy:S,copyStatus:A,resetCopyStatus:M}=H5();G5(()=>{M()},[s,p,l,x,b,M]);let{exportedElements:O,exportingFrame:P}=La(t,e,d);return G5(()=>{let L=y.current;if(!L)return;let D=L.offsetWidth,U=L.offsetHeight;if(!D)return;let K=++E.current,F=()=>K!==E.current;return ls({data:{elements:O,appState:{...e,name:s,exportEmbedScene:b},files:o},config:{canvasBackgroundColor:p?e.viewBackgroundColor:!1,padding:ti,theme:l?"dark":"light",scale:x,maxWidthOrHeight:Math.max(D,U),exportingFrame:P}}).then(async $=>{if(!F()){try{await Ea($)}catch(W){throw W.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):W}F()||(T(null),L.replaceChildren($))}}).catch($=>{F()||(console.error($),T($))}),()=>{E.current+=1}},[e,o,O,P,s,p,l,x,b]),ji("div",{className:"ImageExportModal",children:[ut("h3",{children:h("imageExportDialog.header")}),ji("div",{className:"ImageExportModal__preview",children:[ut("div",{className:"ImageExportModal__preview__canvas",ref:y,children:w&&ut(AN,{})}),ut("div",{className:"ImageExportModal__preview__filename",children:!vl&&ut("input",{type:"text",className:"TextInput",value:s,style:{width:"30ch"},onChange:L=>{c(L.target.value),r.executeAction(Pu,"ui",L.target.value)}})})]}),ji("div",{className:"ImageExportModal__settings",children:[ut("h3",{children:h("imageExportDialog.header")}),a&&ut(Zd,{label:h("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:ut($d,{name:"exportOnlySelected",checked:d,onChange:L=>{m(L)}})}),ut(Zd,{label:h("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:ut($d,{name:"exportBackgroundSwitch",checked:p,onChange:L=>{u(L),r.executeAction(Du,"ui",L)}})}),ut(Zd,{label:h("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:ut($d,{name:"exportDarkModeSwitch",checked:l,onChange:L=>{r.executeAction(dC,"ui",L)}})}),ut(Zd,{label:h("imageExportDialog.label.embedScene"),tooltip:h("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:ut($d,{name:"exportEmbedSwitch",checked:b,onChange:L=>{f(L),r.executeAction(Ru,"ui",L)}})}),ut(Zd,{label:h("imageExportDialog.label.scale"),name:"exportScale",children:ut(Zh,{name:"exportScale",value:x,onChange:L=>{v(L),r.executeAction(sC,"ui",L)},choices:gm.map(L=>({value:L,label:`${L}\xD7`}))})}),ji("div",{className:"ImageExportModal__settings__buttons",children:[ut(gr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToPng"),onClick:()=>n(mm.png,O,{exportingFrame:P}),icon:zp,children:h("imageExportDialog.button.exportToPng")}),ut(gr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToSvg"),onClick:()=>n(mm.svg,O,{exportingFrame:P}),icon:zp,children:h("imageExportDialog.button.exportToSvg")}),(Yl||bn)&&ut(gr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.copyPngToClipboard"),status:A,onClick:async()=>{await n(mm.clipboard,O,{exportingFrame:P}),S()},icon:Ca,children:h("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Zd=({label:e,children:t,tooltip:o,name:r})=>ji("div",{className:"ImageExportModal__settings__setting",title:e,children:[ji("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,o&&ut(Eo,{label:o,long:!0,children:s1})]}),ut("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),V5=({elements:e,appState:t,files:o,actionManager:r,onExportImage:n,onCloseRequest:i,name:l})=>{let[{appStateSnapshot:a,elementsSnapshot:s}]=Xa(()=>({appStateSnapshot:Ir(t),elementsSnapshot:Ir(e)}));return ut(Mt,{onCloseRequest:i,size:"wide",title:!1,children:ut(LN,{elementsSnapshot:s,appStateSnapshot:a,files:o,actionManager:r,onExportImage:n,name:l,exportWithDarkMode:t.exportWithDarkMode})})};import PN from"react";import{jsx as _N}from"react/jsx-runtime";var bE={primary:{base:"var(--color-primary)",darker:"var(--color-primary-darker)",darkest:"var(--color-primary-darkest)"},lime:{base:"#74b816",darker:"#66a80f",darkest:"#5c940d"},pink:{base:"#d6336c",darker:"#c2255c",darkest:"#a61e4d"}},xE=({children:e,color:t})=>_N("div",{className:"Card",style:{"--card-color":bE[t].base,"--card-color-darker":bE[t].darker,"--card-color-darkest":bE[t].darkest},children:e});import{Fragment as RN,jsx as zr,jsxs as fg}from"react/jsx-runtime";var DN=({elements:e,appState:t,setAppState:o,files:r,actionManager:n,exportOpts:i,canvas:l,onCloseRequest:a})=>{let{onExportToBackend:s}=i;return zr("div",{className:"ExportDialog ExportDialog--json",children:fg("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&fg(xE,{color:"lime",children:[zr("div",{className:"Card-icon",children:ub}),zr("h2",{children:h("exportDialog.disk_title")}),fg("div",{className:"Card-details",children:[h("exportDialog.disk_details"),!vl&&n.renderAction("changeProjectName")]}),zr(Q,{className:"Card-button",type:"button",title:h("exportDialog.disk_button"),"aria-label":h("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction($l,"ui")}})]}),s&&fg(xE,{color:"pink",children:[zr("div",{className:"Card-icon",children:Pl}),zr("h2",{children:h("exportDialog.link_title")}),zr("div",{className:"Card-details",children:h("exportDialog.link_details")}),zr(Q,{className:"Card-button",type:"button",title:h("exportDialog.link_button"),"aria-label":h("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ee("export","link",`ui (${Wy()})`),await s(e,t,r),a()}catch(c){o({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,r,l)]})})},Y5=({elements:e,appState:t,files:o,actionManager:r,exportOpts:n,canvas:i,setAppState:l})=>{let a=PN.useCallback(()=>{l({openDialog:null})},[l]);return zr(RN,{children:t.openDialog?.name==="jsonExport"&&zr(Mt,{onCloseRequest:a,title:h("buttons.export"),children:zr(DN,{elements:e,appState:t,setAppState:l,files:o,actionManager:r,onCloseRequest:a,exportOpts:n,canvas:i})})})};import NN from"clsx";import{jsx as ON}from"react/jsx-runtime";var K5=e=>ON(Q,{className:NN("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:Lr,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Z5 from"clsx";import{useState as HN}from"react";import{jsx as EE}from"react/jsx-runtime";var We=e=>Array.isArray(e)?`<kbd>${e.map(H).join(" + ")}</kbd>`:`<kbd>${H(e)}</kbd>`,FN=({appState:e,isMobile:t,editorInterface:o,app:r})=>{let{activeTool:n,isResizing:i,isRotating:l,lastPointerDownWith:a}=e,s=e.multiElement!==null;if(e.openSidebar?.name===ao.name&&e.openSidebar.tab===gn&&e.searchMatches?.matches.length)return h("hints.dismissSearch",{shortcut:We("Escape")});if(e.openSidebar&&!o.canFitSidebar)return null;if(rr(e))return h("hints.eraserRevert",{shortcut:We("Alt")});let c=r.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return h("hints.arrowBindModifiers",{shortcut_1:We("Ctrl"),shortcut_2:We("Alt")});if(n.type==="arrow"||n.type==="line")return s?h("hints.linearElementMulti",{shortcut_1:We("Escape"),shortcut_2:We("Enter")}):n.type==="arrow"?h("hints.arrowTool",{shortcut:We("A")}):h("hints.linearElement");if(n.type==="freedraw")return h("hints.freeDraw");if(n.type==="text")return h("hints.text");if(n.type==="embeddable")return h("hints.embeddable");if(n.type==="autoshape")return h("hints.autoshape");if(i&&a==="mouse"&&c.length===1){let d=c[0];return Se(d)&&d.points.length===2?h("hints.lockAngle",{shortcut:We("Shift")}):ot(d)?h("hints.resizeImage",{shortcut_1:We("Shift"),shortcut_2:We("Alt")}):h("hints.resize",{shortcut_1:We("Shift"),shortcut_2:We("Alt")})}if(l&&a==="mouse")return h("hints.rotate",{shortcut:We("Shift")});if(c.length===1&&ee(c[0]))return h("hints.text_selected",{shortcut:We("Enter")});if(e.editingTextElement)return h("hints.text_editing",{shortcut_1:We("Escape"),shortcut_2:We(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return h("hints.leaveCropEditor",{shortcut_1:We("Enter"),shortcut_2:We("Escape")});if(c.length===1&&ot(c[0]))return h("hints.enterCropEditor",{shortcut:We("Enter")});if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return h("hints.deepBoxSelect",{shortcut:We("CtrlOrCmd")});if(Gi(r)&&e.selectedElementsAreBeingDragged)return h("hints.disableSnapping",{shortcut:We("CtrlOrCmd")});if(!c.length&&!t)return h("hints.canvasPanning",{shortcut_1:We(h("keys.mmb")),shortcut_2:We("Space")});if(c.length===1){if(Se(c[0]))return Te(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?h("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?h("hints.lineEditor_pointSelected",{shortcut_1:We("Delete"),shortcut_2:We(["CtrlOrCmd","D"])}):h("hints.lineEditor_nothingSelected",{shortcut_1:We("Shift"),shortcut_2:We("Alt")}):at(c[0])?h("hints.lineEditor_line_info",{shortcut:We("Enter")}):h("hints.lineEditor_info",{shortcut_1:We("CtrlOrCmd"),shortcut_2:We(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&vn(c[0])){let d=h("hints.bindTextToElement",{shortcut:We("Enter")}),m=h("hints.createFlowchart",{shortcut:We(["CtrlOrCmd","\u2191\u2193"])});return Pm(c[0])?Sw(c[0],r.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},X5=({appState:e,isMobile:t,editorInterface:o,app:r})=>{let n=FN({appState:e,isMobile:t,editorInterface:o,app:r});if(!n)return null;let l=(Array.isArray(n)?n.map(a=>a.replace(/\. ?$/,"")).join(", "):n).split(/(<kbd>[^<]+<\/kbd>)/g).map((a,s)=>{if(s%2===1){let c=a[0]==="<"&&a.match(/^<kbd>([^<]+)<\/kbd>$/);return EE("kbd",{children:c?c[1]:a},s)}return a});return EE("div",{className:"HintViewer",children:EE("span",{children:l})})};import BN from"clsx";import{jsx as zN}from"react/jsx-runtime";var $5=e=>zN(Q,{className:BN("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?ya:vi,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as GN,jsx as Ve,jsxs as jd}from"react/jsx-runtime";var UN=({app:e,activeTool:t,setAppState:o})=>{let[r,n]=HN(!1),i=Ut()==="full",{TTDDialogTriggerTunnel:l}=nt(),a=t.type==="frame",s=t.type==="autoshape",c=t.type==="laser",d=t.type==="bucketfill",m=i&&t.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",p=t.type==="embeddable";return jd(ue,{open:r,children:[Ve(ue.Trigger,{className:Z5("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||p||i&&s||m||d||c&&!e.props.isCollaborating}),onToggle:()=>{n(!r),o({openMenu:null,openPopup:null})},title:h("toolBar.extraTools"),children:a?Ar:p?Ln:i&&s?Ci:c&&!e.props.isCollaborating?Lr:m?kl:d?fo:yi}),jd(ue.Content,{onClickOutside:()=>n(!1),onSelect:()=>n(!1),className:"App-toolbar__extra-tools-dropdown",children:[Ve(ue.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Ar,shortcut:I.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,disabled:Dt(e,"frame"),children:h("toolBar.frame")}),Ve(ue.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Ln,"data-testid":"toolbar-embeddable",selected:p,disabled:Dt(e,"embeddable"),children:h("toolBar.embeddable")}),Ve(ue.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Ci,shortcut:dd("autoshape"),"data-testid":"toolbar-autoshape",selected:s,disabled:Dt(e,"autoshape"),children:h("toolBar.autoshape")}),Ve(ue.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Lr,"data-testid":"toolbar-laser",selected:c,shortcut:I.K.toLocaleUpperCase(),disabled:Dt(e,"laser"),children:h("toolBar.laser")}),Ve(ue.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:fo,"data-testid":"toolbar-bucketfill",selected:d,shortcut:I.B.toLocaleUpperCase(),disabled:Dt(e,"bucketfill"),children:h("toolBar.bucketfill")}),i&&Ve(ue.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:kl,"data-testid":"toolbar-lasso",selected:m,disabled:Dt(e,"lasso"),children:h("toolBar.lasso")}),Ve("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&Ve(l.Out,{}),Ve(ue.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Ia,"data-testid":"toolbar-embeddable",children:h("toolBar.mermaidToExcalidraw")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&Ve(ue.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:Ii,"data-testid":"toolbar-magicframe",badge:Ve(ue.Item.Badge,{children:"AI"}),disabled:Dt(e,"magicframe"),children:h("toolBar.magicframe")})]})]})},j5=({app:e,appState:t,setAppState:o,UIOptions:r,onPenModeToggle:n,onLockToggle:i,heading:l})=>{let a=Me(),s=Ut()==="compact",c=t.activeTool,d={app:e,activeTool:c};return jd(yt,{padding:1,className:Z5("App-toolbar",{"zen-mode":t.zenModeEnabled,"App-toolbar--compact":s}),"data-viewport-ui":"top",children:[Ve(X5,{appState:t,isMobile:a.formFactor==="phone",editorInterface:a,app:e}),l,jd(ro.Row,{gap:s?.5:1,children:[!s&&Ve(As,{checked:t.penMode,onChange:()=>n(null),title:h("toolBar.penMode"),penDetected:t.penDetected}),e.props.activeTool==null&&jd(GN,{children:[Ve($5,{checked:t.activeTool.locked,onChange:i,title:h("toolBar.lock"),disabled:e.props.activeTool!=null}),Ve("div",{className:"App-toolbar__divider",style:{marginRight:"0.25rem"}})]}),Ve(yu,{...d,hideKeyBinding:!0}),s?Ve(Cu,{...d,setAppState:o}):t.preferredSelectionTool.type==="lasso"?Ve(ZT,{...d}):Ve($T,{...d}),Ve(UT,{...d}),Ve(GT,{...d}),Ve(WT,{...d}),Ve(VT,{...d}),Ve(YT,{...d}),s?Ve(Iu,{...d}):Ve(KT,{...d}),Ve(vu,{...d}),r.tools?.image!==!1&&Ve(wu,{...d}),Ve(Tu,{...d}),Ve("div",{className:"App-toolbar__divider",style:{marginLeft:"0.25rem"}}),Ve(UN,{app:e,activeTool:c,setAppState:o})]})]})};import{Fragment as yE,jsx as ce,jsxs as Fo}from"react/jsx-runtime";var VN=({UIOptions:e})=>Fo(uo,{__fallback:!0,children:[ce(uo.DefaultItems.LoadScene,{}),ce(uo.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ce(uo.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ce(uo.DefaultItems.SaveAsImage,{}),ce(uo.DefaultItems.SearchMenu,{}),ce(uo.DefaultItems.Help,{}),ce(uo.DefaultItems.ClearCanvas,{}),ce(uo.Separator,{}),ce(uo.Group,{title:"Excalidraw links",children:ce(uo.DefaultItems.Socials,{})}),ce(uo.Separator,{}),ce(uo.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ce(uo.DefaultItems.ChangeCanvasBackground,{})]}),YN=()=>Fo(Qh,{__fallback:!0,children:[ce(Qh.Actions.SaveToDisk,{}),ce(Qh.Actions.ExportToImage,{})]}),KN=({actionManager:e,appState:t,files:o,setAppState:r,elements:n,canvas:i,onLockToggle:l,onPenModeToggle:a,showExitZenModeBtn:s,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:b,children:f,app:x,defaultUIEnabled:v,zoomUIEnabled:y,scrollBackToContentUIEnabled:E,isCollaborating:w,generateLinkForSelection:T,currentUserControls:S})=>{let A=Me(),M=xo(),P=Ut()==="compact",L=L3(),D=P?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},U=L.tunnelsJotai.Provider,[K,F]=ne(Po),$=()=>p.canvasActions.export?ce(Y5,{elements:n,appState:t,files:o,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,W=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:ce(V5,{elements:n,appState:t,files:o,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),q=()=>Fo("div",{style:{position:"relative"},children:[Fo("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,t),ce(L.MainMenuTunnel.Out,{})]}),b&&ce(L.WelcomeScreenMenuHintTunnel.Out,{})]}),oe=()=>ce(Rd,{heading:"selectedShapeActions",className:Ws("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:P?ce(yt,{className:Ws("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${t.height-166}px`},children:ce(nS,{appState:t,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x,setAppState:r})}):ce(yt,{className:et.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ce(QI,{appState:t,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),B=()=>{let ye=v&&Yw(t,n),Ye=v&&t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector";return ce(Vh,{side:"top",children:Fo("div",{className:"App-menu App-menu_top",children:[Fo(ro.Col,{gap:D.menuTopGap,className:Ws("App-menu_top__left"),children:[q(),v&&ce("div",{className:Ws("selected-shape-actions-container",{"selected-shape-actions-container--compact":P}),children:ye&&oe()}),v&&P&&!t.viewModeEnabled&&ye&&ce(As,{checked:t.penMode,onChange:()=>a(null),title:h("toolBar.penMode"),isMobile:!0,penDetected:t.penDetected})]}),v&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&ce(Rd,{heading:"shapes",className:"shapes-section",children:me=>Fo("div",{style:{position:"relative"},children:[b&&ce(L.WelcomeScreenToolbarHintTunnel.Out,{}),ce(ro.Col,{gap:D.toolbarColGap,align:"start",children:Fo(ro.Row,{gap:D.toolbarRowGap,className:Ws("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[ce(j5,{app:x,appState:t,setAppState:r,UIOptions:p,onPenModeToggle:a,onLockToggle:l,heading:me}),w&&ce(yt,{style:{marginLeft:D.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ce(K5,{title:h("toolBar.laser"),checked:t.activeTool.type===ht.laser,onChange:()=>x.setActiveTool({type:ht.laser}),isMobile:!0})})]})})]})}),Fo("div",{className:Ws("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled,"layer-ui__wrapper__top-right--compact":P}),children:[v&&t.collaborators.size>0&&ce(Xh,{collaborators:t.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:S}),d?.(A.formFactor==="phone",t),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&(!fe||t.openSidebar?.name!==ao.name)&&ce(L.DefaultSidebarTriggerTunnel.Out,{}),Ye&&ce(Xd,{app:x,onClose:()=>{e.executeAction(Hn)},renderCustomStats:m})]})]})})},V=()=>v?ce(eg,{__fallback:!0,onDock:ye=>{Ee("sidebar",`toggleDock (${ye?"dock":"undock"})`,`(${A.formFactor==="phone"?"mobile":"desktop"})`)}}):null,fe=Cl(Od),Ne=!!(t.openSidebar&&fe&&A.canFitSidebar),Ze=Fo(yE,{children:[f,v&&Fo(yE,{children:[ce(VN,{UIOptions:p}),ce(eg.Trigger,{__fallback:!0,icon:B1,title:Vt(h("toolBar.library")),onToggle:ye=>{ye&&Ee("sidebar",`${ao.name} (open)`,`button (${A.formFactor==="phone"?"mobile":"desktop"})`)},tab:ao.defaultTab})]}),ce(YN,{}),t.openDialog?.name==="ttd"&&ce(pg,{__fallback:!0}),v&&t.isLoading&&ce(Gh,{delay:250}),v&&t.errorMessage&&ce(F5,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),v&&K&&A.formFactor!=="phone"&&ce(L2,{colorPickerType:K.colorPickerType,onCancel:()=>{F(null)},onChange:(ye,Ye,me,{altKey:je})=>{if(!(ye!=="elementBackground"&&ye!=="elementStroke"))if(me.length){for(let It of me)co(It,ie(n),{[je&&K.swapPreviewOnAlt?ye==="elementBackground"?"strokeColor":"backgroundColor":ye==="elementBackground"?"backgroundColor":"strokeColor"]:Ye}),tr.delete(It);x.scene.triggerUpdate()}else r(ye==="elementBackground"?{currentItemBackgroundColor:Ye}:{currentItemStrokeColor:Ye})},onSelect:(ye,Ye)=>{F(me=>me?.keepOpenOnAlt&&Ye.altKey?me:null),K?.onSelect?.(ye,Ye)}}),t.openDialog?.name==="help"&&ce(B5,{onClose:()=>{r({openDialog:null})}}),ce(dS,{}),v&&t.openDialog?.name==="elementLinkSelector"&&ce(O5,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:t,generateLinkForSelection:T}),ce(L.OverwriteConfirmDialogTunnel.Out,{}),W(),$(),v&&t.openDialog?.name==="charts"&&ce(z3,{data:t.openDialog.data,rawText:t.openDialog.rawText,onClose:()=>r({openDialog:null})}),A.formFactor==="phone"&&ce(R3,{app:x,appState:t,elements:n,actionManager:e,renderJSONExportDialog:$,renderImageExportDialog:W,setAppState:r,onPenModeToggle:a,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:V,renderWelcomeScreen:b,defaultUIEnabled:v,scrollBackToContentUIEnabled:E}),A.formFactor!=="phone"&&Fo(yE,{children:[M.viewportStatusFrame?.border&&ce(Hh,{border:M.viewportStatusFrame.border,style:Ne?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),Fo("div",{className:"layer-ui__wrapper",style:Ne?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[b&&ce(L.WelcomeScreenCenterTunnel.Out,{}),B(),ce(K3,{appState:t,actionManager:e,showExitZenModeBtn:s,renderWelcomeScreen:b,defaultUIEnabled:v,zoomUIEnabled:y}),(t.toast||E&&t.scrolledOutside||M.viewportStatusFrame?.label)&&Fo("div",{className:"floating-status-stack",children:[t.toast&&ce(ku,{message:t.toast.message,onClose:()=>r({toast:null}),duration:t.toast.duration,closable:t.toast.closable}),!t.toast&&E&&t.scrolledOutside&&ce("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(ye=>({...El(n,ye)}))},children:h("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&ce(Uh,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]}),V()]})]});return ce(Y1.Provider,{value:t,children:ce(U,{children:ce(yx.Provider,{value:L,children:Ze})})})},q5=e=>{let{cursorButton:t,scrollX:o,scrollY:r,zoom:n,shouldCacheIgnoreZoom:i,snapLines:l,originSnapOffset:a,suggestedBinding:s,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},XN=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:o,appState:r,...n}=e,{canvas:i,appState:l,...a}=t;return Lt(q5(r),q5(l),{selectedElementIds:Lt,selectedGroupIds:Lt})&&Lt(n,a)},J5=WN.memo(KN,XN);import $N from"clsx";import{jsx as ZN}from"react/jsx-runtime";var bg=e=>ZN(Q,{className:$N("ToolIcon__MagicButton",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:e.icon,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()});import{useEffect as jN,useRef as qN}from"react";import{jsx as Q5}from"react/jsx-runtime";var eM=({trails:e})=>{let t=qN(null);return jN(()=>{if(t.current)for(let o of e)o.start(t.current);return()=>{for(let o of e)o.stop()}},e),Q5("div",{className:"SVGLayer",children:Q5("svg",{ref:t})})};import f9,{useEffect as b9,useRef as dM}from"react";var JN="#ff6b6b",QN="#ff0000",tM=1,oM=2,rM=(e,t)=>{if(!t.snapLines.length)return;let o=t.theme===J.LIGHT||t.zenModeEnabled?JN:QN,r=(t.zenModeEnabled?tM*1.5:tM)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let n of t.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=o,t9(n,e,t)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=o,o9(n.points[0],n.points[1],n.direction,t,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=o,e9(n,e,t));e.restore()},e9=(e,t,o)=>{if(!o.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Er(r,n,t)}for(let r of e.points)nM(r,o,t)},t9=(e,t,o)=>{nM(e.points[0],o,t),o.zenModeEnabled||Er(e.points[0],e.points[1],t)},nM=([e,t],o,r)=>{r.save();let n=(o.zenModeEnabled?oM*1.5:oM)/o.zoom.value;r.beginPath(),r.moveTo(e-n,t-n),r.lineTo(e+n,t+n),r.moveTo(e+n,t-n),r.lineTo(e-n,t+n),r.stroke(),r.restore()},Er=(e,t,o)=>{o.beginPath(),o.lineTo(e[0],e[1]),o.lineTo(t[0],t[1]),o.stroke()},o9=(e,t,o,r,n)=>{let i=8/r.zoom.value,l=i/2,a=i/4;if(o==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||Er(_(e[0],e[1]-i),_(e[0],e[1]+i),n),Er(_(s[0]-a,s[1]-l),_(s[0]-a,s[1]+l),n),Er(_(s[0]+a,s[1]-l),_(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Er(_(t[0],t[1]-i),_(t[0],t[1]+i),n),Er(e,t,n))}else{let s=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||Er(_(e[0]-i,e[1]),_(e[0]+i,e[1]),n),Er(_(s[0]-l,s[1]-a),_(s[0]+l,s[1]-a),n),Er(_(s[0]-l,s[1]+a),_(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Er(_(t[0]-i,t[1]),_(t[0]+i,t[1]),n),Er(e,t,n))}};var r9=(e,t)=>{it(t.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:o}=t.selectedLinearElement;it(o,"midPointCoords is null"),xg(o,e,t)},n9=(e,t,o)=>{let{elementId:r,hoverPointIndex:n}=t.selectedLinearElement;if(t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(n)||t.selectedLinearElement?.isDragging)return;let i=Z.getElement(r,o);if(!i)return;let l=Z.getPointAtIndexGlobalCoordinates(i,n,o);xg(l,e,t)},xg=(e,t,o)=>{t.save(),t.translate(o.scrollX,o.scrollY),t.fillStyle="rgba(105, 101, 219, 0.4)",Ac(t,e[0],e[1],Z.POINT_HANDLE_SIZE/o.zoom.value,!1),t.restore()},i9=(e,t,o)=>{let{elementId:r,anchor:n}=t.hoveredArrowTextAnchor,i=o.get(r);if(!i||!Te(i)||i.isDeleted)return;let l=n==="label"?Z.getBoundTextElementCenter(i,o):Z.getPointAtIndexGlobalCoordinates(i,n==="start"?0:-1,o);xg(l,e,t)},vE=(e,t,o,r,n,i,l)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Ac(e,o[0],o[1],(l?r*(t.selectedLinearElement?.isEditing?1.5:2):r)/t.zoom.value,!i,!l||n)},a9=(e,t,o,r,n,i=!1)=>{let l=t.element.frameId&&o.get(t.element.frameId);switch(l&&re(l)&&(e.translate(l.x,l.y),e.beginPath(),tt.radius&&e.roundRect?e.roundRect(-1,-1,l.width+1,l.height+1,tt.radius/r.zoom.value):e.rect(-1,-1,l.width+1,l.height+1),e.clip(),e.translate(-l.x,-l.y)),t.element.type){case"magicframe":case"frame":e.save(),e.translate(t.element.x,t.element.y),e.lineWidth=tt.strokeWidth/r.zoom.value,e.strokeStyle=r.theme===J.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",tt.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,t.element.width,t.element.height,tt.radius/r.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,t.element.width,t.element.height),e.restore();break;default:e.save();let a=ha(t.element,o);switch(e.translate(a[0],a[1]),e.rotate(t.element.angle),e.translate(-a[0],-a[1]),e.translate(t.element.x,t.element.y),e.lineWidth=qe(1.75,t.element.strokeWidth,4)/Math.max(.25,r.zoom.value),e.strokeStyle=r.theme===J.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",t.element.type){case"ellipse":e.beginPath(),e.ellipse(t.element.width/2,t.element.height/2,t.element.width/2,t.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[s,c]=Dm(t.element);s.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-t.element.x,d[0][1]-t.element.y),e.lineTo(d[1][0]-t.element.x,d[1][1]-t.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,b]=d;e.beginPath(),e.moveTo(m[0]-t.element.x,m[1]-t.element.y),e.bezierCurveTo(p[0]-t.element.x,p[1]-t.element.y,u[0]-t.element.x,u[1]-t.element.y,b[0]-t.element.x,b[1]-t.element.y),e.stroke()})}break;default:{let[s,c]=df(t.element);s.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-t.element.x,d[0][1]-t.element.y),e.lineTo(d[1][0]-t.element.x,d[1][1]-t.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,b]=d;e.beginPath(),e.moveTo(m[0]-t.element.x,m[1]-t.element.y),e.bezierCurveTo(p[0]-t.element.x,p[1]-t.element.y,u[0]-t.element.x,u[1]-t.element.y,b[0]-t.element.x,b[1]-t.element.y),e.stroke()})}break}e.restore();break}if(r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&!i&&(re(t.element)||da(t.element))){let a=r.selectedLinearElement,s=a?.elementId&&Z.getElement(a?.elementId,o),c=n&&pi({point:n,element:t.element,elementsMap:o,threshold:0,overrideShouldTestInside:!0}),d=s&&Re(s)||r.activeTool.type==="arrow"&&r.currentItemArrowType==="elbow";if(!c||d){e.save();let m=ha(t.element,o),p;if(t.element.type==="diamond"){let x=ha(t.element,o);p=iv(t.element).map(v=>{let y=zg(v,.5),E=ke(y,x,t.element.angle);return _(E[0],E[1])})}else p=[{x:t.element.width,y:t.element.height/2},{x:t.element.width/2,y:t.element.height},{x:0,y:t.element.height/2},{x:t.element.width/2,y:0}].map(v=>{let y=_(v.x+t.element.x,v.y+t.element.y),E=ke(y,m,t.element.angle);return _(E[0],E[1])});let u=n&&p.reduce((x,v,y)=>{let E=Ko(v,n);return y===-1||E<x.distance?{idx:y,distance:E}:x},{idx:-1,distance:1/0}),b=4/r.zoom.value,f=ui(r.zoom)+t.element.strokeWidth/2;p.forEach((x,v)=>{let y=(!c||d)&&u?.idx===v&&u.distance<=f,E=!y&&(d||v===u?.idx&&u.distance<=f*2);y?(e.fillStyle=r.theme===J.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(x[0],x[1],b,0,2*Math.PI),e.fill()):E&&(e.fillStyle=r.theme===J.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(x[0],x[1],b,0,2*Math.PI),e.fill())}),e.restore()}}},l9=(e,t,o,r,n,i,l)=>{let a=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=ri-(l?.runtime??(a?0:ri)),c=qe(1/ri*s,1e-4,1),d=o.strokeWidth/2,m=o.frameId&&r.get(o.frameId);switch(m&&re(m)&&(t.translate(m.x,m.y),t.beginPath(),tt.radius&&t.roundRect?t.roundRect(-1,-1,m.width+1,m.height+1,tt.radius/n.zoom.value):t.rect(-1,-1,m.width+1,m.height+1),t.clip(),t.translate(-m.x,-m.y)),o.type){case"magicframe":case"frame":t.save(),t.translate(o.x,o.y),t.lineWidth=tt.strokeWidth/n.zoom.value,t.strokeStyle=n.theme===J.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,tt.radius&&t.roundRect?(t.beginPath(),t.roundRect(0,0,o.width,o.height,tt.radius/n.zoom.value),t.stroke(),t.closePath()):t.strokeRect(0,0,o.width,o.height),t.restore();break;default:t.save();let u=ha(o,r),b=u[0]+n.scrollX,f=u[1]+n.scrollY;switch(t.translate(b,f),t.rotate(o.angle),t.translate(-b,-f),t.translate(o.x+n.scrollX-d,o.y+n.scrollY-d),t.lineWidth=qe(2.5,o.strokeWidth*1.75,4)/Math.max(.25,n.zoom.value),t.strokeStyle=n.theme===J.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,o.type){case"ellipse":t.beginPath(),t.ellipse((o.width+d*2)/2,(o.height+d*2)/2,(o.width+d*2)/2,(o.height+d*2)/2,0,0,2*Math.PI),t.closePath(),t.stroke();break;case"diamond":{let[x,v]=Dm(o,d);x.forEach(y=>{t.beginPath(),t.moveTo(y[0][0]-o.x+d,y[0][1]-o.y+d),t.lineTo(y[1][0]-o.x+d,y[1][1]-o.y+d),t.stroke()}),v.forEach(y=>{let[E,w,T,S]=y;t.beginPath(),t.moveTo(E[0]-o.x+d,E[1]-o.y+d),t.bezierCurveTo(w[0]-o.x+d,w[1]-o.y+d,T[0]-o.x+d,T[1]-o.y+d,S[0]-o.x+d,S[1]-o.y+d),t.stroke()})}break;default:{let[x,v]=df(o,d);x.forEach(y=>{t.beginPath(),t.moveTo(y[0][0]-o.x+d,y[0][1]-o.y+d),t.lineTo(y[1][0]-o.x+d,y[1][1]-o.y+d),t.stroke()}),v.forEach(y=>{let[E,w,T,S]=y;t.beginPath(),t.moveTo(E[0]-o.x+d,E[1]-o.y+d),t.bezierCurveTo(w[0]-o.x+d,w[1]-o.y+d,T[0]-o.x+d,T[1]-o.y+d,S[0]-o.x+d,S[1]-o.y+d),t.stroke()})}break}t.restore();break}if(!a||(l?.runtime??0)>ri)return;let p=.5*(Math.min(o.width,o.height)/2);if(!re(o)){t.save(),t.translate(o.x+n.scrollX,o.y+n.scrollY);let u=1/ri*s;if(t.strokeStyle="rgba(0, 0, 0, 0.2)",t.lineWidth=1/n.zoom.value,t.setLineDash([4/n.zoom.value,4/n.zoom.value]),t.lineDashOffset=-u*10/n.zoom.value,t.beginPath(),t.ellipse(o.width/2,o.height/2,p,p,0,0,2*Math.PI),t.stroke(),t.fillStyle="rgba(0, 0, 0, 0.04)",t.beginPath(),t.ellipse(o.width/2,o.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),t.fill(),t.restore(),n.isMidpointSnappingEnabled&&!n.gridModeEnabled&&(!e.lastPointerMoveEvent||!ii(e.lastPointerMoveEvent))){t.save(),t.translate(o.x+n.scrollX,o.y+n.scrollY);let b=5/n.zoom.value,f=5/n.zoom.value,x=b+f,v;if(o.type==="diamond"){let[,y]=Dm(o),E=ha(o,r);v=y.map(w=>{let T=zg(w,.5),S=ke(T,E,o.angle);return{x:S[0]-o.x,y:S[1]-o.y}})}else{let y=ha(o,r);v=[{x:o.width/2,y:0},{x:o.width,y:o.height/2},{x:o.width/2,y:o.height},{x:0,y:o.height/2}].map(w=>{let T=_(w.x+o.x,w.y+o.y),S=ke(T,y,o.angle);return{x:S[0]-o.x,y:S[1]-o.y}})}v.forEach(y=>{t.clearRect(y.x-x,y.y-x,x*2,x*2)}),t.fillStyle=n.theme===J.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,v.forEach(y=>{t.beginPath(),t.arc(y.x,y.y,b,0,2*Math.PI),t.fill()}),t.restore()}}return{runtime:(l?.runtime??0)+i}},s9=(e,t,o,r,n,i,l)=>{if(o===null)return;if(qo("COMPLEX_BINDINGS"))return l9(e,t,o.element,r,n,i,l);t.save(),t.translate(n.scrollX,n.scrollY);let a=e.lastPointerMoveCoords?_(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,s=!!e.lastPointerMoveEvent&&ii(e.lastPointerMoveEvent);a9(t,o,r,n,a,s),t.restore()},sM=(e,t,o)=>{let{angle:r,x1:n,y1:i,x2:l,y2:a,selectionColors:s,cx:c,cy:d,dashed:m,activeEmbeddable:p}=o,u=l-n,b=a-i,x=(o.padding??oa*2)/t.zoom.value,v=8/t.zoom.value,y=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let E=s.length;for(let w=0;w<E;++w)e.strokeStyle=s[w],m&&e.setLineDash([v,y+(v+y)*(E-1)]),e.lineDashOffset=(v+y)*w,Lc(e,n-x,i-x,u+x*2,b+x*2,c,d,r);e.restore()},c9=(e,t,o,r)=>{let[n,i,l,a]=Yt(o,r),s=l-n,c=a-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=tt.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Lc(e,n,i,s,c,n+s/2,i+c/2,o.angle,!1,tt.radius/t.zoom.value),e.restore()},iM=(e,t,o,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},l=o.filter(d=>d.groupIds.length===0),a=o.filter(d=>d.groupIds.length>0),s=d=>{let[m,p,u,b]=we(d);return{angle:0,x1:m,x2:u,y1:p,y2:b,selectionColors:n,dashed:i,cx:m+(u-m)/2,cy:p+(b-p)/2,activeEmbeddable:!1}},c=d=>{let m=He(o,d);return s(m)};Object.entries(ua(a,t)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(l.map(d=>s([d]))).forEach(d=>sM(e,t,d))},wE=(e,t,o,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let n=Z.getPointsGlobalCoordinates(o,r),{POINT_HANDLE_SIZE:i}=Z,l=t.selectedLinearElement?.isEditing?i:i/2,a=Re(o),s=at(o);if(n.forEach((c,d)=>{if(a&&d!==0&&d!==n.length-1)return;let m=d>0&&(d!==n.length-1||!s||!o.polygon)&&XE(c,d===n.length-1?n[0]:n[d-1],2/t.zoom.value),p=!!t.selectedLinearElement?.isEditing&&!!t.selectedLinearElement?.selectedPointsIndices?.includes(d);s&&o.polygon&&!p&&d===o.points.length-1&&t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),vE(e,t,c,l,p,!1,m)}),Re(o)){let c=o.fixedSegments?.map(d=>d.index)||[];n.slice(0,-1).forEach((d,m)=>{Z.isSegmentTooShort(o,n[m+1],n[m],m,t.zoom,r)||vE(e,t,_((d[0]+n[m+1][0])/2,(d[1]+n[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else Z.getEditorMidPoints(o,r,t).filter((d,m,p)=>d!==null&&!(Re(o)&&(m===0||m===p.length-1))).forEach(d=>{(t.selectedLinearElement?.isEditing||n.length===2)&&vE(e,t,d,i/2,!1,!0,!1)});e.restore()},d9=(e,t,o,r)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/t.zoom.value,e.setLineDash([4/t.zoom.value,4/t.zoom.value]),e.beginPath(),e.moveTo(o[0],o[1]),e.lineTo(r[0],r[1]),e.stroke(),e.restore()},m9=(e,t,o,r,n)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/t.zoom.value,e.setLineDash([]),e.fillStyle=n?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Ac(e,o[0],o[1],r/t.zoom.value,!0,!0),e.restore()},aM=({arrow:e,appState:t,type:o,context:r,elementsMap:n})=>{let i=o==="start"?e.startBinding:e.endBinding,l=i?.elementId&&n.get(i.elementId);if(!l||!da(l)||l.isDeleted)return;let a=ff(i.fixedPoint,l,n);if(!_w(a,e,l,n,t,o))return;let s=t.selectedLinearElement,c=!!s?.isDragging,d=o==="start"?0:e.points.length-1,m=!!s?.selectedPointsIndices?.includes(d);if(s?.hoveredFocusPointBinding===o&&!s.draggedFocusPointBinding&&xg(a,r,t),!(m&&c)){let p=ff(i.fixedPoint,l,n),u=s?.hoveredFocusPointBinding===o,b=Z.getPointAtIndexGlobalCoordinates(e,d,n);d9(r,t,b,p),m9(r,t,p,kv/1.5,u)}},lM=(e,t,o,r,n)=>{Object.keys(r).forEach(i=>{let l=r[i];if(l!==void 0){let[a,s,c,d]=l;e.save(),e.lineWidth=1/o.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?Ac(e,a+c/2,s+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(a,s,c,d,2/o.zoom.value),e.fill(),e.stroke()):Lc(e,a,s,c,d,a+c/2,s+d/2,n,!0),e.restore()}})},p9=(e,t,o,r,n)=>{let[i,l,,,a,s]=Yt(r,n),c=3,d=20,m=c/o.zoom.value,p=m/2,u=a-i+m,b=s-l+m,f=Math.min(d/o.zoom.value,u),x=Math.min(d/o.zoom.value,b);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=m,[[[-u,-b],[0,p],[f,p],[p,0],[p,x]],[[u-p,-b],[p,p],[-f+p,p],[0,0],[0,x]],[[-u,b],[0,-p],[f,-p],[p,0],[p,-x]],[[u-p,b],[p,-p],[-f+p,-p],[0,0],[0,-x]]].forEach(y=>{let[[E,w],[T,S],[A,M],[O,P],[L,D]]=y;e.save(),e.translate(a,s),e.rotate(r.angle),e.beginPath(),e.moveTo(E+T,w+S),e.lineTo(E+A,w+M),e.stroke(),e.beginPath(),e.moveTo(E+O,w+P),e.lineTo(E+L,w+D),e.stroke(),e.restore()}),e.restore()},u9=(e,t,o,r)=>{t.save();let n=sx(o.zoom.value),i=e.width+n*2,l=e.height+n*2,a=e.x+e.width/2,s=e.y+e.height/2,c=-(e.width/2+n),d=-(e.height/2+n);t.translate(a+o.scrollX,s+o.scrollY),t.rotate(e.angle),t.lineWidth=1/o.zoom.value,t.strokeStyle=r,t.globalAlpha=.5,t.setLineDash([6/o.zoom.value,4/o.zoom.value]),t.strokeRect(c,d,i,l),t.restore()},h9=(e,t,o,r,n)=>{let i=cx(e,o.zoom.value,n);i&&(t.save(),t.globalAlpha=.5,t.lineWidth=1.5/o.zoom.value,t.lineCap="round",t.strokeStyle=r,t.beginPath(),t.moveTo(i.start[0]+o.scrollX,i.start[1]+o.scrollY),t.lineTo(i.end[0]+o.scrollX,i.end[1]+o.scrollY),t.stroke(),t.restore())},g9=({app:e,canvas:t,elementsMap:o,visibleElements:r,selectedElements:n,allElementsMap:i,scale:l,appState:a,renderConfig:s,editorInterface:c,animationState:d,deltaTime:m})=>{if(t===null)return{};let[p,u]=sp(t,l),b=d,f=cp({canvas:t,scale:l,normalizedWidth:p,normalizedHeight:u});f.save(),f.scale(a.zoom.value,a.zoom.value);let x;if(r.forEach(S=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===S.id&&S&&(x=S)}),x&&wE(f,a,x,o),a.selectionElement&&!a.isCropping)try{jv(a.selectionElement,f,a,s.selectionColor)}catch(S){console.error(S)}let v=wc(n,a);if(v&&!v.autoResize&&h9(v,f,a,s.selectionColor,c.formFactor),a.editingTextElement){let S=i.get(a.editingTextElement.id);S&&!S.autoResize&&u9(S,f,a,s.selectionColor)}if(a.isBindingEnabled&&a.suggestedBinding?b={...d,bindingHighlight:s9(e,f,a.suggestedBinding,i,a,m,d?.bindingHighlight)}:b={...d,bindingHighlight:void 0},a.hoveredArrowTextAnchor&&i9(f,a,i),a.frameToHighlight&&c9(f,a,a.frameToHighlight,o),a.elementsToHighlight&&iM(f,a,a.elementsToHighlight),a.activeLockedId){let S=i.get(a.activeLockedId),A=S?[S]:He(i,a.activeLockedId);iM(f,a,A,{colors:["#ced4da"],dashed:!0})}let y=n.some(S=>re(S));n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&wE(f,a,n[0],o);let E=a.selectedLinearElement,w=E&&Z.getElement(E.elementId,i);if(w&&(a.selectedLinearElement.isDragging||(E.segmentMidPointHoveredCoords?r9(f,a):(Re(w)?E.hoverPointIndex===0||E.hoverPointIndex===w.points.length-1:E.hoverPointIndex>=0)&&n9(f,a,o)),Te(w)&&(aM({arrow:w,elementsMap:i,appState:a,context:f,type:"start"}),aM({arrow:w,elementsMap:i,appState:a,context:f,type:"end"}))),!a.multiElement&&!a.newElement&&!a.selectedLinearElement?.isEditing){let S=np(n,a,c),A=n.length===1&&Se(n[0]);A&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&wE(f,a,n[0],o);let M=s.selectionColor||"#000";if(S){let O=ie(n),P=[];for(let D of o.values()){let U=[],K=s.remoteSelectedElementIds.get(D.id);if(A&&Re(D)&&(D.startBinding||D.endBinding)||(O.has(D.id)&&!Hm(a,D)&&U.push(M),K&&U.push(...K.map(F=>Da(F,a.collaborators.get(F))))),U.length){let[F,$,W,q,oe,B]=Yt(D,o,!0);P.push({angle:D.angle,x1:F,y1:$,x2:W,y2:q,selectionColors:D.locked?["#ced4da"]:U,dashed:!!K||D.locked,cx:oe,cy:B,activeEmbeddable:a.activeEmbeddable?.element===D&&a.activeEmbeddable.state==="active",padding:D.id===a.croppingElementId||ot(D)?0:void 0})}}let L=D=>{let U=He(o,D),[K,F,$,W]=we(U);P.push({angle:0,x1:K,x2:$,y1:F,y2:W,selectionColors:U.some(q=>q.locked)?["#ced4da"]:["#000"],dashed:!0,cx:K+($-K)/2,cy:F+(W-F)/2,activeEmbeddable:!1})};for(let D of kr(a))L(D);a.editingGroupId&&L(a.editingGroupId),P.forEach(D=>sM(f,a,D))}if(f.save(),f.translate(a.scrollX,a.scrollY),n.length===1){f.fillStyle="#fff";let O=Vw(n[0],a.zoom,o,"mouse",rp(c));if(!a.viewModeEnabled&&S&&!ee(a.editingTextElement)&&!a.croppingElementId&&lM(f,s,a,O,n[0].angle),a.croppingElementId&&!a.isCropping){let P=o.get(a.croppingElementId);P&&ot(P)&&p9(f,s,a,P,o)}}else if(n.length>1&&!a.isRotating&&!n.some(O=>O.locked)){let O=oa*2/a.zoom.value;f.fillStyle="#fff";let[P,L,D,U]=we(n,o),K=f.getLineDash();f.setLineDash([2/a.zoom.value]);let F=f.lineWidth;f.lineWidth=1/a.zoom.value,f.strokeStyle=M,Lc(f,P-O,L-O,D-P+O*2,U-L+O*2,(P+D)/2,(L+U)/2,0),f.lineWidth=F,f.setLineDash(K);let $=Ww([P,L,D,U,(P+D)/2,(L+U)/2],0,a.zoom,"mouse",y?{...rp(c),rotation:!0}:rp(c));n.some(W=>!W.locked)&&lM(f,s,a,$,0)}f.restore()}a.searchMatches?.matches.forEach(({id:S,focus:A,matchedLines:M})=>{let O=o.get(S);if(O){let[P,L,,,D,U]=Yt(O,o,!0);f.save(),a.theme===J.LIGHT?A?f.fillStyle="rgba(255, 124, 0, 0.4)":f.fillStyle="rgba(255, 226, 0, 0.4)":A?f.fillStyle="rgba(229, 82, 0, 0.4)":f.fillStyle="rgba(99, 52, 0, 0.4)";let K=re(O)?a.zoom.value:1;f.translate(a.scrollX,a.scrollY),f.translate(D,U),f.rotate(O.angle),M.forEach(F=>{(F.showOnCanvas||A)&&f.fillRect(P+F.offsetX/K-D,L+F.offsetY/K-U,F.width/K,F.height/K)}),f.restore()}}),rM(f,a),f.restore(),gC({context:f,renderConfig:s,appState:a,normalizedWidth:p,normalizedHeight:u});let T;return s.renderScrollbars&&(T=GS(o,p,u,a),f.save(),f.fillStyle=US,f.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(S=>{S&&zu(f,S.x,S.y,S.width,S.height,pr/2)}),f.restore()),{scrollBars:T,animationState:b}},cM=e=>{let t=g9(e);return e.callback(t),t};import{jsx as y9}from"react/jsx-runtime";var mM="animateInteractiveScene",x9=e=>{let t=dM(!1),o=dM(null);return b9(()=>{if(!t.current){t.current=!0;return}let r=new Map,n=new Map,i=new Map,l=new Map,a=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&l.set(d,c.username),c.userState&&a.set(d,c.userState),n.set(d,Ft({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),r.set(d,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";o.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:n,remotePointerButton:r,remoteSelectedElementIds:i,remotePointerUsernames:l,remotePointerUserStates:a,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},Rt.running(mM)||Rt.start(mM,({deltaTime:c,state:d})=>{let m=cM({...o.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),y9("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:h("labels.drawingCanvas")})},pM=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,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,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),E9=(e,t)=>e.selectionNonce!==t.selectionNonce||e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements||e.renderScrollbars!==t.renderScrollbars||e.interactionEnabled!==t.interactionEnabled||e.navigationEnabled!==t.navigationEnabled?!1:Lt(pM(e.appState),pM(t.appState)),TE=f9.memo(x9,E9);import v9,{useEffect as uM,useRef as hM}from"react";import{jsx as C9}from"react/jsx-runtime";var w9=e=>{let t=hM(null),o=hM(!1);return uM(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),uM(()=>{let r=t.current;if(!r)return;let n=e.canvas;o.current||(o.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),t2({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},xs())}),C9("div",{className:"excalidraw__canvas-wrapper",ref:t})},gM=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,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,suggestedBinding:e.suggestedBinding}),T9=(e,t)=>e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Lt(gM(e.appState),gM(t.appState))&&Lt(e.renderConfig,t.renderConfig),CE=v9.memo(w9,T9);import{useEffect as S9,useRef as k9}from"react";var fM=({canvas:e,rc:t,newElement:o,elementsMap:r,allElementsMap:n,scale:i,appState:l,renderConfig:a})=>{if(e){let[s,c]=sp(e,i),d=cp({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(d.save(),d.scale(l.zoom.value,l.zoom.value),o&&o.type!=="selection"){if($r(o))return;if((o.frameId||l.frameToHighlight?.id)&&l.frameRendering.enabled&&l.frameRendering.clip){let u=Yv(o,r,l);u&&Kv(o,u,l,r)&&Qw(u,d,a,l)}qv(o,r,n,t,d,a,l)}else d.clearRect(0,0,s,c);d.restore()}},I9=rc(e=>{fM(e)}),bM=(e,t)=>{if(t){I9(e);return}fM(e)};import{jsx as A9}from"react/jsx-runtime";var M9=e=>{let t=k9(null);return S9(()=>{t.current&&bM({canvas:t.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},xs())}),A9("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})},xM=M9;import L9 from"clsx";import{useLayoutEffect as _9,useEffect as EM,useRef as P9,useState as D9}from"react";import{jsx as F9}from"react/jsx-runtime";var yM=700,R9=100,N9=16,O9=5*60*1e3,wM=Ce(null),vM=e=>e===gt.elbow?Dn:e===gt.round?Rn:Pn,Eg=class{constructor(t){C(this,"app");C(this,"lastShownAt",0);C(this,"show",t=>{let{x:o,y:r}=this.app.viewport.lastPosition;o===0&&r===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(wM,{content:t,nonce:Math.random()}))});C(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<O9);C(this,"onArrowTypeCycled",t=>{this.show(vM(t))});C(this,"onToolShortcut",(t,o)=>{(o==="digit"||!this.isOnCooldown())&&this.show(t==="line"?va:vM(this.app.state.currentItemArrowType))});this.app=t}},TM=()=>{let[e,t]=ne(wM),o=Xe(),{container:r}=Je(),n=P9(null),[i,l]=D9(!1),a=e?.nonce;return _9(()=>{if(a==null||!r)return;let s=(d,m)=>{let p=n.current;if(!p)return;let{left:u,top:b}=eu({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:N9});p.style.transform=`translate(${u}px, ${b}px)`};s(o.viewport.lastPosition.x,o.viewport.lastPosition.y);let c=d=>{s(d.clientX,d.clientY)};return window.addEventListener("pointermove",c),()=>{window.removeEventListener("pointermove",c)}},[a,r,o]),EM(()=>()=>{t(null)},[t]),EM(()=>{if(a==null)return;l(!1);let s=window.setTimeout(()=>{l(!0)},yM),c=window.setTimeout(()=>{t(null)},yM+R9),d=()=>{t(null)};return window.addEventListener("pointerdown",d,{capture:!0}),()=>{window.clearTimeout(s),window.clearTimeout(c),window.removeEventListener("pointerdown",d,{capture:!0})}},[a,t]),e?F9("div",{ref:n,className:L9("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var yg=class{constructor(t){this.getState=t;C(this,"listeners",[]);C(this,"onStateChange",(t,o,r)=>{let{predicate:n,getValue:i,callback:l,once:a,matchesImmediately:s}=this.normalize(t,o,r);return l?s&&(queueMicrotask(()=>{let c=this.getState();l(i(c),c)}),a)?()=>{}:this.subscribe({predicate:n,getValue:i,callback:l,once:a}):s?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:n,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(t){return typeof t=="object"&&!Array.isArray(t)&&"predicate"in t}subscribe(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(o=>o!==t)}}normalize(t,o,r){let n,i,l=o,a=r?.once??!1,s=!1;if(this.isStateChangePredicateOptions(t)){let{predicate:c,callback:d,once:m}=t;n=c,i=p=>p,l=d?(p,u)=>d(u):void 0,a=m??!1,s=c(this.getState())}else if(typeof t=="function"){let c=t;n=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(t)){let c=t;n=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=t;n=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:n,getValue:i,callback:l,once:a,matchesImmediately:s}}flush(t){if(!this.listeners.length)return;let o=this.getState(),r=[];for(let n of this.listeners)n.predicate(o,t)?(n.callback(n.getValue(o),o),n.once||r.push(n)):r.push(n);this.listeners=r}clear(){this.listeners=[]}};import{flushSync as B9}from"react-dom";import{jsx as H9}from"react/jsx-runtime";var z9=({app:e,activeLockedId:t})=>{let o=e.scene.getElement(t);o&&!or(o)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let r=o&&or(o)?o:null,n=r?[r]:He(e.scene.getNonDeletedElementsMap(),t);if(n.length===0)return null;let[i,l]=we(n),{x:a,y:s}=Ft({sceneX:i,sceneY:l},e.state);return H9("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-s+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{B9(()=>{let c=ua(n,e.state);e.setState({selectedElementIds:n.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(rs)},title:h("labels.elementLock.unlock"),children:jf})},CM=z9;import{Fragment as $9,jsx as Oe,jsxs as om}from"react/jsx-runtime";var MM=yr.createContext(null),AM=yr.createContext(null),SE={formFactor:"desktop",desktopUIMode:"full",userAgent:tf(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},ME=yr.createContext(SE);ME.displayName="EditorInterfaceContext";var Y9={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},AE=yr.createContext({container:null,id:null});AE.displayName="ExcalidrawContainerContext";var LE=yr.createContext([]);LE.displayName="ExcalidrawElementsContext";var _E=yr.createContext({...Mn(),width:0,height:0,offsetLeft:0,offsetTop:0});_E.displayName="ExcalidrawAppStateContext";var PE=yr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});PE.displayName="ExcalidrawSetAppStateContext";var DE=yr.createContext(null);DE.displayName="ExcalidrawActionManagerContext";var Ys=yr.createContext(null);Ys.displayName="ExcalidrawAPIContext";var Cg=yr.createContext(null);Cg.displayName="ExcalidrawAPISetContext";var Xe=()=>jn(MM),xo=()=>jn(AM),Me=()=>jn(ME),Ut=()=>aa(Me()),Je=()=>jn(AE),ki=()=>jn(LE),tn=()=>jn(_E),Ie=()=>jn(PE),Qe=()=>jn(DE),fu=()=>jn(Ys),qd=!1,Jd=0,Qd=null,$n=!1,Zn=!1,vg=!1,em={horizontal:null,vertical:null},qi=0,tm=!1,IE=new Map,K9=4,wg=!1,Tg=0,SM=!1,Vs=null,Le={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},kM,kE=class e extends yr.Component{constructor(o){super(o);C(this,"canvas");C(this,"interactiveCanvas",null);C(this,"rc");C(this,"unmounted",!1);C(this,"actionManager");C(this,"editorInterface",SE);C(this,"stylesPanelMode",aa(SE));C(this,"excalidrawContainerRef",yr.createRef());C(this,"scene");C(this,"fonts");C(this,"renderer");C(this,"visibleElements");C(this,"hasRenderableElements",!1);C(this,"resizeObserver");C(this,"library");C(this,"libraryItemsFromStorage");C(this,"id");C(this,"store");C(this,"history");C(this,"excalidrawContainerValue");C(this,"files",{});C(this,"imageCache",new Map);C(this,"iFrameRefs",new Map);C(this,"embedsValidationStatus",new Map);C(this,"initializedEmbeds",new Set);C(this,"elementsPendingErasure",new Set);C(this,"_initialized",!1);C(this,"editorLifecycleEvents",new $y(Y9));C(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));C(this,"appStateObserver",new yg(()=>this.state));C(this,"onStateChange",this.appStateObserver.onStateChange);C(this,"bucketFill",new Dh(this));C(this,"flowchart",new Fh(this));C(this,"cursor",new Rh(this));C(this,"arrowText",new Ph(this));C(this,"viewport",new zh(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>Le.pointers.size>=2||Zn}));C(this,"bindModeHandler",null);C(this,"textWysiwygSubmitHandler",null);C(this,"hitLinkElement");C(this,"lastPointerDownEvent",null);C(this,"lastPointerUpEvent",null);C(this,"lastPointerUpIsDoubleClick",!1);C(this,"lastPointerMoveEvent",null);C(this,"lastPointerMoveCoords",null);C(this,"lastCompletedCanvasClicks",[]);C(this,"previousPointerMoveCoords",null);C(this,"drawShape",new Oh(this));C(this,"laserTrails",new wh(this));C(this,"eraserTrail",new Ih(this));C(this,"lassoTrail",new Ch(this));C(this,"cursorHints",new Eg(this));C(this,"onChangeEmitter",new Jo);C(this,"onPointerDownEmitter",new Jo);C(this,"onPointerUpEmitter",new Jo);C(this,"onUserFollowEmitter",new Jo);C(this,"onScrollChangeEmitter",new Jo);C(this,"missingPointerEventCleanupEmitter",new Jo);C(this,"onRemoveEventListenersEmitter",new Jo);C(this,"api");C(this,"isToolSupported",(o,r=this.props)=>{if(r.UIOptions.tools?.[o]===!1)return!1;if(this.isInteractionEnabled(r))return!0;let n=typeof r.interaction=="object"&&r.interaction!==null?r.interaction.enabled?.tools:void 0;return o==="laser"?n?.laser===!0:o==="custom"?n?.custom===!0:!1});C(this,"updateEditorAtom",(o,...r)=>{let n=bt.set(o,...r);return this.triggerRender(),n});C(this,"previousHoveredBindableElement",null);C(this,"getEffectiveGridSize",()=>Gi(this)?this.state.gridSize:null);C(this,"getTextCreationGridPoint",(o,r)=>{let n=this.getEffectiveGridSize();if(n===null)return null;let i=l=>Math.floor(l/n)*n;return{x:i(o),y:i(r)}});C(this,"handleIframeLikeElementHover",({hitElement:o,scenePointer:r,moveEvent:n})=>o&&al(o)&&this.isIframeLikeInteractive(o)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(o,n,r.x,r.y))?(this.cursor.set(Fe.POINTER),this.setState({activeEmbeddable:{element:o,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));C(this,"isDoubleClick",(o,r)=>o!=null&&r.timeStamp-o.timeStamp<=Kg);C(this,"updateEmbedValidationStatus",(o,r)=>{this.embedsValidationStatus.set(o.id,r),tr.delete(o)});C(this,"updateEmbeddables",()=>{let o=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(so(n)){if(o.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=fl(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else ca(n)&&o.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{o.has(i)||this.iFrameRefs.delete(i)})});C(this,"getFrameNameDOMId",o=>`${this.id}-frame-name-${o.id}`);C(this,"frameNameBoundsCache",{get:o=>{let r=this.frameNameBoundsCache._cache.get(o.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==o.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(o));if(n){let i=n.getBoundingClientRect(),l=ze({clientX:i.x,clientY:i.y},this.state),a=ze({clientX:i.right,clientY:i.bottom},this.state);return r={x:l.x,y:l.y,width:a.x-l.x,height:a.y-l.y,zoom:this.state.zoom.value,versionNonce:o.versionNonce},this.frameNameBoundsCache._cache.set(o.id,r),r}return null}return r},_cache:new Map});C(this,"resetEditingFrame",o=>{o&&this.scene.mutateElement(o,{name:o.name?.trim()||null}),this.setState({editingFrame:null})});C(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let o=this.state.theme===J.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&re(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!Cc(i,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===i.id&&this.resetEditingFrame(i),null;let{x:l,y:a}=Ft({sceneX:i.x,sceneY:i.y},this.state),s=6,c,d=Xv(i);if(i.id===this.state.editingFrame){let m=d;c=Oe("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===I.ESCAPE||p.key===I.ENTER)&&this.resetEditingFrame(i)},style:{background:Jt(this.state.viewBackgroundColor,o),zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${tt.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:o?tt.nameColorDarkTheme:tt.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-l-s}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Oe("div",{id:this.getFrameNameDOMId(i),className:et.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+tt.nameOffsetY-a+this.state.offsetTop}px`,left:`${l-this.state.offsetLeft}px`,zIndex:2,fontSize:tt.nameFontSize,color:o?tt.nameColorDarkTheme:tt.nameColorLightTheme,lineHeight:tt.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Fe.MOVE,pointerEvents:this.state.viewModeEnabled?ta.disabled:ta.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});C(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});C(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());C(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());C(this,"getSceneElements",()=>this.scene.getNonDeletedElements());C(this,"onInsertElements",o=>{this.addElementsFromPasteOrLibrary({elements:o,position:"center",files:null})});C(this,"onExportImage",async(o,r,n)=>{Ee("export",o,"ui");let i=await _a({type:o,data:{elements:r,appState:this.state,files:this.files},config:{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}}).catch(Tm).catch(l=>{console.error(l),this.setState({errorMessage:l.message})});this.state.exportEmbedScene&&i&&dp(i)&&this.setState({fileHandle:i})});C(this,"magicGenerations",new Map);C(this,"updateMagicGeneration",({frameElement:o,data:r})=>{r.status==="pending"?this.scene.mutateElement(o,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(o,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(o.id,r),this.triggerRender()});C(this,"plugins",{});C(this,"onMagicframeToolSelect",()=>{let o=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(o.length===0)this.setActiveTool({type:ht.magicframe}),Ee("ai","tool-select (empty-selection)","d2c");else{let r=o.length===1&&Lm(o[0])&&o[0];if(!r&&o.some(i=>re(i)||i.frameId)){this.setActiveTool({type:ht.magicframe});return}Ee("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,l,a,s]=we(o),c=50;n=If({...tt,x:i-c,y:l-c,width:a-i+c*2,height:s-l+c*2,opacity:100,locked:!1}),this.insertNewElement(n);for(let d of o)this.scene.mutateElement(d,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});C(this,"openEyeDropper",({type:o})=>{this.updateEditorAtom(Po,{swapPreviewOnAlt:!0,colorPickerType:o==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=o==="background"&&n.altKey||o==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:N.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:N.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?se(a,{[i?"strokeColor":"backgroundColor"]:r}):a),captureUpdate:N.IMMEDIATELY})},keepOpenOnAlt:!1})});C(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});C(this,"syncActionResult",Tt(o=>{if(this.unmounted||o===!1)return;this.store.scheduleAction(o.captureUpdate);let r=!1,n=null;if(o.elements&&(this.scene.replaceAllElements(o.elements),r=!0),o.files&&(this.addMissingFiles(o.files,o.replaceFiles),this.addNewImagesToImageCache()),o.appState||n||this.state.contextMenu){let i=o?.appState?.viewModeEnabled||!1,l=o?.appState?.zenModeEnabled||!1,a=o?.appState?.theme||this.props.theme||J.LIGHT,s=o?.appState?.name??this.state.name,c=o?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),typeof this.props.zenModeEnabled<"u"&&(l=this.props.zenModeEnabled),n=o.appState?.editingTextElement||null,o.elements&&n){let d=n.id,m=o.elements.find(p=>p.id===d);n=m&&or(m)&&ee(m)?m:null}this.setState(d=>{let m=o.appState||{};return{...d,...m,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:l,theme:a,name:s,errorMessage:c}}),r=!0}r||this.scene.triggerUpdate()}));C(this,"scheduleCapture",()=>this.store.scheduleCapture());C(this,"onBlur",Tt(()=>{$n=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));C(this,"onUnload",()=>{this.onBlur()});C(this,"disableEvent",o=>{o.preventDefault()});C(this,"preventBrowserZoomWheel",o=>{o[I.CTRL_OR_CMD]&&o.preventDefault()});C(this,"handleNavigationModeKeyDown",o=>{if(this.maybeHandlePageScrollKeyDown(o)){o.preventDefault();return}this.actionManager.handleKeyDown(o)});C(this,"maybeHandlePageScrollKeyDown",o=>{if(o.key!==I.PAGE_UP&&o.key!==I.PAGE_DOWN)return!1;let r=(o.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return o.key===I.PAGE_DOWN&&(r=-r),o.shiftKey?this.viewport.translate(n=>({scrollX:n.scrollX+r})):this.viewport.translate(n=>({scrollY:n.scrollY+r})),!0});C(this,"preventBrowserZoomKeyDown",o=>{o[I.CTRL_OR_CMD]&&(o.code===ge.EQUAL||o.code===ge.MINUS||o.code===ge.ZERO||o.code===ge.NUM_ADD||o.code===ge.NUM_SUBTRACT||o.code===ge.NUM_ZERO)&&o.preventDefault()});C(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),$n=!1,Zn=!1,vg=!1,Vs=null,Le.pointers.clear(),Le.lastCenter=null,Le.initialDistance=null,Le.initialScale=null,clearTimeout(Jd),Jd=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(Tg),Tg=0,wg=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),bt.set(Po,null),bt.set(sr,null),this.state.editingFrame){let o=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(o&&re(o)?o:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});C(this,"handleInteractionStateChange",(o,r)=>{let n=this.isInteractionEnabled(o),i=n!==this.isInteractionEnabled(),l=o.viewModeEnabled!==this.props.viewModeEnabled,a=this.state.viewModeEnabled;this.isInteractionEnabled()?(l||i)&&(a=!!this.props.viewModeEnabled):a=!0,a!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:a});let s=n&&!r.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||s&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(o)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,Xu(),this.cursor.reset())),this.isEmbedsEnabled(o)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(r.activeTool.type,o)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:ft(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(o)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(o)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});C(this,"isSameForcedTool",(o,r)=>o?.type===r?.type&&(o?.type==="custom"?o.customType??null:null)===(r?.type==="custom"?r.customType??null:null));C(this,"handleForcedToolChange",(o,r)=>{let n=this.props.activeTool;if(!n)return;let i=!this.isSameForcedTool(o.activeTool,n);if(n.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(n,this.state.activeTool)||(i||r.activeTool!==this.state.activeTool||this.isToolSupported(n.type,o)!==this.isToolSupported(n.type,this.props))&&this.setActiveTool(n)});C(this,"resetHistory",()=>{this.history.clear()});C(this,"resetStore",()=>{this.store.clear()});C(this,"resetScene",Tt(o=>{this.scene.replaceAllElements([]),this.setState(r=>({...Mn(),isLoading:o?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));C(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async s=>{if(!s.files.length)return;let c=s.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let o=null;try{typeof this.props.initialData=="function"?o=await this.props.initialData()||null:o=await this.props.initialData||null,o?.libraryItems&&this.library.updateLibrary({libraryItems:o.libraryItems,merge:!0}).catch(s=>{console.error(s)})}catch(s){console.error(s),o={appState:{errorMessage:s.message||"Encountered an error during importing or restoring scene data"}}}let r=wl(o?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=_c(o?.appState,null),i=n.activeTool;n.preferredSelectionTool.initialized||(n.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),n={...n,theme:this.props.theme||n.theme,openSidebar:n?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:n.preferredSelectionTool.type}:n.activeTool,isLoading:!1,toast:this.state.toast};let l={...n,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},a=this.props.initialState?.viewport;if(a){let s=r.filter(m=>!m.isDeleted),c=ie(s),d=this.viewport.resolveInitialViewport(a,c,l);d&&(n={...n,...d})}else o?.scrollToContent&&(n={...n,...El(r,l)});this.resetStore(),o?.scrollX!=null&&(n.scrollX=o.scrollX),o?.scrollY!=null&&(n.scrollY=o.scrollY),this.resetHistory(),this.syncActionResult({elements:r,appState:n,files:o?.files,captureUpdate:N.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(s=>{this.fonts.onLoaded(s)}),ga(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});C(this,"getFormFactor",(o,r)=>this.props.UIOptions.getFormFactor?.(o,r)??ef(o,r));C(this,"refreshEditorInterface",()=>{let o=this.excalidrawContainerRef.current;if(!o)return;let{width:r,height:n}=o.getBoundingClientRect(),i=My(),l=tf(typeof navigator<"u"?navigator.userAgent:""),a=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:1229,s=nl(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(r,n),userAgent:l,canFitSidebar:r>a,isLandscape:r>n});this.editorInterface=s,this.reconcileStylesPanelMode(s)});C(this,"reconcileStylesPanelMode",o=>{let r=aa(o);if(r===this.stylesPanelMode)return;let n=this.stylesPanelMode;this.stylesPanelMode=r,this.viewport.invalidateUIOffset("stylesPanel"),n!=="full"&&r==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});C(this,"setDesktopUIMode",o=>{let r=Ay(o);this.editorInterface=nl(this.editorInterface,{desktopUIMode:r}),this.reconcileStylesPanelMode(this.editorInterface)});C(this,"onResize",Tt(()=>{this.scene.getElementsIncludingDeleted().forEach(o=>tr.delete(o)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));C(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});C(this,"renderInteractiveSceneCallback",({scrollBars:o})=>{o&&(em=o),this.scheduleImageRefresh()});C(this,"onScroll",xn(()=>{let{offsetTop:o,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===o?null:{offsetTop:o,offsetLeft:r})},iy));C(this,"onCut",Tt(o=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||lo(o.target)||(this.actionManager.executeAction(ud,"keyboard",o),o.preventDefault(),o.stopPropagation())}));C(this,"onCopy",Tt(o=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||lo(o.target)||(this.actionManager.executeAction(Ra,"keyboard",o),o.preventDefault(),o.stopPropagation())}));C(this,"onTouchStart",o=>{if(this.isInteractionEnabled()){if(Sy&&o.preventDefault(),!qd){qd=!0,o.touches.length===1&&(Qd={x:o.touches[0].clientX,y:o.touches[0].clientY}),clearTimeout(Jd),Jd=window.setTimeout(e.resetTapTwice,Kg);return}if(qd&&o.touches.length===1&&Qd){let r=o.touches[0];Ko(_(r.clientX,r.clientY),_(Qd.x,Qd.y))<=qg&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),qd=!1,clearTimeout(Jd)}o.touches.length===2&&this.setState({selectedElementIds:Be({},this.state),activeEmbeddable:null})}});C(this,"onTouchEnd",o=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),o.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Be(this.state.previousSelectedElementIds,this.state)}):Le.pointers.clear())});C(this,"pasteFromClipboard",Tt(async o=>{if(!this.isInteractionEnabled())return;let r=!!wg,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(o&&!i)return;let l=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(o&&(!(l instanceof HTMLCanvasElement)||lo(n)))return;let a=await Kl(o),s=a.getFiles(),c=await Lu(a,r);if(this.props.onPaste)try{if(await this.props.onPaste(c,o)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,s,r),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),o?.preventDefault()}));C(this,"addElementsFromPasteOrLibrary",o=>{let r=wl(o.elements,null,{deleteInvisibleElements:!0}),[n,i,l,a]=we(r),s=sa(n,l)/2,c=sa(i,a)/2,d=typeof o.position=="object"?o.position.clientX:o.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof o.position=="object"?o.position.clientY:o.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=ze({clientX:d,clientY:m},this.state),b=p-s,f=u-c,[x,v]=Qt(b,f,this.getEffectiveGridSize()),{duplicatedElements:y}=Sn({type:"everything",elements:r.map(M=>se(M,{x:M.x+x-n,y:M.y+v-i})),randomizeSeed:!o.retainSeed,preserveFrameChildrenOrder:o.preserveFrameChildrenOrder}),E=this.scene.getElementsIncludingDeleted(),w=[...E,...y];w=this.props.onDuplicate?.(w,E)||w,Yr(w,ie(y));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let M=Wv(y,S);w=hl(w,M,S)}this.scene.replaceAllElements(w),y.forEach(M=>{if(ee(M)&&mt(M)){let O=Vr(M,this.scene.getElementsMapIncludingDeleted());St(M,O,this.scene)}}),Iy&&kn.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),o.files&&this.addMissingFiles(o.files);let A=Ov(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&bt.get(Od)?this.state.openSidebar:null,...vc(A,this.scene.getNonDeletedElements(),this.state)},()=>{o.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),o.fit&&this.viewport.setViewport({target:y,fit:o.fit,animation:!1,offsets:{ui:!0}})});C(this,"setAppState",(o,r)=>{this.setState(o,r)});C(this,"removePointer",o=>{qi&&this.resetContextMenuTimer(),o.type==="pointercancel"&&this.bucketFill.cancel();let r=Le.pointers.size>=2;Le.pointers.delete(o.pointerId),r&&Le.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});C(this,"toggleLock",(o="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ee("toolbar","toggleLock",`${o} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...ft(this.state,r.activeTool.locked?{type:this.state.preferredSelectionTool.type}:r.activeTool),locked:!r.activeTool.locked}})))});C(this,"updateFrameRendering",o=>{this.setState(r=>{let n=typeof o=="function"?o(r.frameRendering):o;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});C(this,"togglePenMode",o=>{this.setState(r=>({penMode:o??!r.penMode,penDetected:!0,currentItemStrokeVariability:r.penDetected?r.currentItemStrokeVariability:"variable"}))});C(this,"revealIfHidden",o=>{!o.length||Jm(o,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.viewport.getOffsets())||this.viewport.setViewport({target:we(o),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});C(this,"emitUserFollowIntent",o=>{this.onUserFollowEmitter.trigger(o),this.props.onUserFollow?.(o)});C(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});C(this,"setToast",o=>{this.setState({toast:o})});C(this,"restoreFileFromShare",async()=>{try{let o=await caches.open("web-share-target"),r=await o.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await o.delete("shared-file"),window.history.replaceState(null,js,window.location.pathname)}}catch(o){this.setState({errorMessage:o.message})}});C(this,"addFiles",Tt(o=>{let{addedFiles:r}=this.addMissingFiles(o);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));C(this,"addMissingFiles",(o,r=!1)=>{let n=r?{}:{...this.files},i={},l=Array.isArray(o)?o:Object.values(o);for(let a of l)if(!n[a.id]&&(i[a.id]=a,n[a.id]=a,a.mimeType===pe.svg))try{let s=c2(Af(d2(a.dataURL)),pe.svg);a.dataURL!==s&&(a.version=(a.version??1)+1,a.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});C(this,"updateScene",Tt(o=>{let{elements:r,appState:n,collaborators:i,captureUpdate:l}=o;if(l){let a=r||void 0,s=n?bw({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:l,elements:a,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));C(this,"applyDeltas",(o,r)=>{let n=Ic.squash(...o),i={...this.state},l=new Map(this.scene.getElementsMapIncludingDeleted());return Ic.applyTo(n,l,i,r)});C(this,"mutateElement",(o,r,n=!0)=>this.scene.mutateElement(o,r,{informMutation:n,isDragging:!1}));C(this,"triggerRender",o=>{o===!0?this.scene.triggerUpdate():this.setState({})});C(this,"toggleSidebar",({name:o,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===o&&this.state.openSidebar?.tab===r?null:o:i=n?o:null;let l=i?{name:i}:null;return l&&r&&(l.tab=r),this.setState({openSidebar:l}),!!i});C(this,"updateCurrentCursorPosition",Tt(o=>{this.viewport.lastPosition.x=o.clientX,this.viewport.lastPosition.y=o.clientY}));C(this,"onKeyDown",Tt(o=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!o.shiftKey&&/^[A-Z]$/.test(o.key)||o.shiftKey&&/^[a-z]$/.test(o.key))&&(o=new Proxy(o,{get(a,s){let c=a[s];return typeof c=="function"?c.bind(a):s==="key"?o.shiftKey?a.key.toUpperCase():a.key.toLowerCase():c}})),!nf(o.target)){if((o.key===I.ESCAPE||o.key===I.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=ae(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&ot(a[0])&&o.key===I.ENTER){this.startImageCropping(a[0]);return}if(o.key===I.ESCAPE)this.updateEditorAtom(sr,null);else if(o.key===I.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(et.CONVERT_ELEMENT_TYPE_POPUP))){o.preventDefault();let s=as(a);bt.get(sr)?.type==="panel"&&P0(this,{conversionType:s,direction:o.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(sr,{type:"panel"})}if(this.flowchart.handleKeyEvent(o))return}if(o[I.CTRL_OR_CMD]&&o.key===I.P&&!o.shiftKey&&!o.altKey){this.setToast({message:h("commandPalette.shortcutHint",{shortcut:rt("commandPalette")})}),o.preventDefault();return}if(o[I.CTRL_OR_CMD]&&o.key.toLowerCase()===I.V&&(wg=o.shiftKey,clearTimeout(Tg),Tg=window.setTimeout(()=>{wg=!1},100)),o[I.CTRL_OR_CMD]&&lo(o.target)&&(o.code===ge.MINUS||o.code===ge.EQUAL)){o.preventDefault();return}if(lo(o.target)&&o.key!==I.ESCAPE||ni(o.key)&&nf(o.target))return;if(o.key===I.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(o.key.toLowerCase()===I.E&&o.shiftKey&&o[I.CTRL_OR_CMD]){o.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(o)){o.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(o.key===I.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),o.preventDefault();return}else qo("COMPLEX_BINDINGS")?this.handleSkipBindMode():Sc({app:this,event:o});if(this.actionManager.handleKeyDown(o))return;let r=this.props.viewModeEnabled===!0;if(!r&&this.state.viewModeEnabled&&o.key===I.ESCAPE){this.setActiveTool({type:"selection"});return}if(!r&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=HT(o.key,this,o.shiftKey);if(this.state.viewModeEnabled&&!lf(a,["laser","hand"]))return;if(a){if(this.state.activeTool.type!==a&&Ee("toolbar",a,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"){let s=this.state.currentItemArrowType===gt.sharp?gt.round:this.state.currentItemArrowType===gt.round?gt.elbow:gt.sharp;this.setState({currentItemArrowType:s}),this.cursorHints.onArrowTypeCycled(s)}else(a==="arrow"||a==="line")&&this.cursorHints.onToolShortcut(a,/^\d$/.test(o.key)?"digit":"letter");a==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():a==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:a},{toggle:!0}),o.stopPropagation();return}else if(o.key===I.Q){this.toggleLock("keyboard"),o.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(o[I.CTRL_OR_CMD]&&!o.repeat&&(qo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Bo(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Sc({app:this,event:o})),ni(o.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),s=new Set;a.filter(p=>zt(p)).filter(p=>{let u=p.startBinding&&!a.some(f=>f.id===p.startBinding?.elementId),b=p.endBinding&&!a.some(f=>f.id===p.endBinding?.elementId);return u||b}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(o.shiftKey?Ug:this.getEffectiveGridSize())||(o.shiftKey?JE:Ug),d=0,m=0;o.key===I.ARROW_LEFT?d=-c:o.key===I.ARROW_RIGHT?d=c:o.key===I.ARROW_UP?m=-c:o.key===I.ARROW_DOWN&&(m=c),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+d,y:p.y+m},{informMutation:!1,isDragging:!1}),ko(p,this.scene,{simultaneouslyUpdated:a})}),this.scene.triggerUpdate(),o.preventDefault()}else if(o.key===I.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let s=a[0];if(o[I.CTRL_OR_CMD]||at(s))Se(s)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)&&(this.store.scheduleCapture(),Re(s)||this.actionManager.executeAction(Ba));else if(ee(s)||mf(s)){let c;ee(s)||(c=s);let d=Nm(s,this.scene.getNonDeletedElementsMap()),m=d.x,p=d.y;this.startTextEditing({sceneX:m,sceneY:p,container:c}),o.preventDefault();return}else re(s)&&this.setState({editingFrame:s.id})}}if(o.key===I.SPACE&&Le.pointers.size===0&&($n=!0,this.cursor.set(Fe.GRAB),o.preventDefault()),(o.key===I.G||o.key===I.S)&&!o.altKey&&!o[I.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;o.key===I.G&&(mi(this.state.activeTool.type)||a.some(s=>mi(s.type)))&&(this.setState({openPopup:"elementBackground"}),o.stopPropagation()),o.key===I.S&&(this.setState({openPopup:"elementStroke"}),o.stopPropagation())}if(!o[I.CTRL_OR_CMD]&&o.shiftKey&&o.key.toLowerCase()===I.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(s=>ee(s)||ve(s,this.scene.getNonDeletedElementsMap())))&&(o.preventDefault(),this.setState({openPopup:"fontFamily"}))}o[I.CTRL_OR_CMD]&&(o.key===I.BACKSPACE||o.key===I.DELETE)&&this.updateEditorAtom(Fa,"clearCanvas");let n=o.key.toLocaleLowerCase(),i=n===I.S&&o.shiftKey&&!o[I.CTRL_OR_CMD],l=o.key===I.I||n===I.G&&o.shiftKey;(i||l)&&this.openEyeDropper({type:i?"stroke":"background"})}));C(this,"onKeyUp",Tt(o=>{if(this.isInteractionEnabled()){if(o.key===I.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Fe.GRAB):nc(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Be({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),$n=!1),o.key===I.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Sc({app:this,event:o})),(o.key===I.ALT&&this.state.bindMode==="skip"||!o[I.CTRL_OR_CMD]&&!pa(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&qo("COMPLEX_BINDINGS"))){let r=ze({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),n=Qo(_(r.x,r.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=Z.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());zt(i)&&this.handleDelayedBindModeChange(i,n)}}if(!o[I.CTRL_OR_CMD]){let r=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==r&&(Bo(()=>{this.setState({isBindingEnabled:r})}),this.arrowText.refresh()),Sc({app:this,event:o})}if(ni(o.key)){Ec(this.scene.getSelectedElements(this.state).filter(Te),this.scene,this.state);let r=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(_m).forEach(n=>{n.startBinding&&this.scene.mutateElement(n,{startBinding:{...n.startBinding,...gf(n,r.get(n.startBinding.elementId),"start",r)}}),n.endBinding&&this.scene.mutateElement(n,{endBinding:{...n.endBinding,...gf(n,r.get(n.endBinding.elementId),"end",r)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(o)}}));C(this,"setActiveTool",(o,r={})=>{let{keepSelection:n=!1}=r;if(!this.isToolSupported(o.type)){console.warn(this.isInteractionEnabled()?`"${o.type}" tool is disabled via "UIOptions.canvasActions.tools.${o.type}"`:`"${o.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,o)){console.warn(`"${o.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(Gt);let i=Vl.includes(o.type),a=r.toggle===!0&&i&&this.state.activeTool.type===o.type?ft(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==o.type?ft(this.state,{...o,lastActiveTool:this.state.activeTool}):ft(this.state,o);a.type==="hand"?this.cursor.set(Fe.GRAB):$n||this.cursor.applyForTool(a),_y(document.activeElement)&&this.focusContainer(),Jy(a.type)||this.setState({suggestedBinding:null}),a.type==="image"&&this.onImageToolbarButtonClick(),this.setState(s=>{let c={snapLines:s.snapLines.length?[]:s.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:nc(a.type)?s.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return a.type==="freedraw"&&this.store.scheduleCapture(),a.type==="lasso"?{...s,...c,activeTool:a,...n?{}:{selectedElementIds:Be({},s),selectedGroupIds:Be({},s),editingGroupId:null,multiElement:null}}:a.type!=="selection"?{...s,...c,activeTool:a,selectedElementIds:Be({},s),selectedGroupIds:Be({},s),editingGroupId:null,multiElement:null}:{...s,...c,activeTool:a}})});C(this,"setOpenDialog",o=>{this.setState({openDialog:o})});C(this,"isTouchScreenMultiTouchGesture",()=>Le.pointers.size>=2);C(this,"getName",()=>this.state.name||this.props.name||`${h("labels.untitled")}-${rf()}`);C(this,"onGestureStart",Tt(o=>{this.isNavigationEnabled()&&(o.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Be({},this.state),activeEmbeddable:null}),Le.initialScale=this.state.zoom.value)}));C(this,"onGestureChange",Tt(o=>{if(!this.isNavigationEnabled()||(o.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let r=Le.initialScale;r&&this.viewport.translate(n=>({...xi({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Ei(r*o.scale)},n)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));C(this,"onGestureEnd",Tt(o=>{this.isNavigationEnabled()&&(o.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Be(this.state.previousSelectedElementIds,this.state)}),Le.initialScale=null)}));C(this,"isHittingTextAutoResizeHandle",(o,r)=>{let n=wc(o,this.state);return!!(n&&!n.isDeleted&&!n.autoResize&&zS(r,n,this.state.zoom.value,this.editorInterface.formFactor))});C(this,"handleTextAutoResizeHandlePointerDown",(o,r)=>{let n=wc(o,this.state);return!n||!this.isHittingTextAutoResizeHandle(o,r)?!1:(this.actionManager.executeAction(ex,"ui",n),this.cursor.reset(),!0)});C(this,"startTextEditing",({sceneX:o,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:l=!0,initialCaretSceneCoords:a,arrowEndpoint:s})=>{let c=!1,d=s&&this.arrowText.getTextBinding(s,this.getCurrentItemStrokeWidth("text"));d&&(i=null,n=!1,o=d.anchor[0],r=d.anchor[1]);let m=n&&this.getTextWysiwygSnappedToCenterPosition(o,r,this.state,i);i&&m&&(ve(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(o,r),u=p?.fontFamily||this.state.currentItemFontFamily,b=p?.lineHeight||ho(u),f=this.state.currentItemFontSize;if(!p&&c&&i&&!Te(i)){let S=cl(dt({fontSize:f,fontFamily:u}),b),A=pv(f,b),M=Math.max(i.height,A),O=Math.max(i.width,S);this.scene.mutateElement(i,{height:M,width:O}),o=i.x+O/2,r=i.y+M/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(o,r,this.state,i))}let x=this.getTextCreationGridPoint(o,r),v=d?{x:o,y:r}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:o,y:r}:{x:x?.x??o,y:x===null?r-dc(f,b)/2:x.y},y=this.getTopLayerFrameAtSceneCoords({x:v.x,y:v.y}),E=y&&(!c||!i||i.frameId===y.id)?y.id:null,w=p||eo({x:v.x,y:v.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:f,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?Zo.MIDDLE:Wg),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:b,angle:i?Te(i)?0:i.angle:0,frameId:E});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:w.id})}),this.setState({editingTextElement:w}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([w],T+1)}else this.insertNewElement(w);s&&d&&this.arrowText.bindText(s,w,d.fixedPoint),l||p||i?this.handleTextWysiwyg(w,{isExistingElement:!!p,initialCaretSceneCoords:p?a:null}):this.setState({newElement:w,multiElement:null})});C(this,"startImageCropping",o=>{this.store.scheduleCapture(),this.setState({croppingElementId:o.id})});C(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});C(this,"shouldHandleBrowserCanvasDoubleClick",o=>{if(o==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[r,n]=this.lastCompletedCanvasClicks;return Ko(_(r.x,r.y),_(n.x,n.y))<=qg});C(this,"handleCanvasDoubleClick",o=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(o.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=ze(o,this.state);if(r.length===1&&Se(r[0])){let a=r[0];if((o[I.CTRL_OR_CMD]&&_m(a)||at(a))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==a.id)){this.actionManager.executeAction(Ba);return}else if(this.state.selectedLinearElement&&Re(r[0])){let s=Z.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?Z.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),Z.deleteFixedSegment(r[0],this.scene,c);let d=Z.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?Z.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:s,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===a.id&&at(a))return}if(r.length===1&&ot(r[0])){this.startImageCropping(r[0]);return}if(this.cursor.reset(),kr(this.state).length>0){let a=this.getElementAtPosition(n,i),s=a&&Dv(a,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...kt({editingGroupId:s,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let a=this.getElementAtPosition(n,i);if(al(a)){this.isIframeLikeInteractive(a)&&this.setState({activeEmbeddable:{element:a,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=!o[I.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(n,i);if(s&&(this.state.activeTool.type==="autoshape"||Ht(s)||!Uo(s.backgroundColor)||pi({point:_(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Nm(s,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!o.altKey,container:s||null})}}});C(this,"handleCanvasClick",o=>{if(this.isInteractionEnabled()){if(o.button!==Xo.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:o.clientX,y:o.clientY}]}});C(this,"getElementLinkAtPosition",(o,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let l=n.length-1;l>=0;l--){let a=n[l];if(r&&a.id===r.id&&(i=l),a.link&&l>=i&&lp(a,this.scene.getNonDeletedElementsMap(),this.state,_(o.x,o.y),this.editorInterface.formFactor==="phone"))return a}});C(this,"handleElementLinkClick",o=>{let r=Ko(_(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),_(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>Ja)return;let n=ze(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),l=lp(this.hitLinkElement,i,this.state,_(n.x,n.y),this.editorInterface.formFactor==="phone"),a=ze(this.lastPointerUpEvent,this.state),s=lp(this.hitLinkElement,i,this.state,_(a.x,a.y),this.editorInterface.formFactor==="phone");if(l&&s){Xu();let c=this.hitLinkElement.link;if(c){c=Sr(c);let d;if(this.props.onLinkOpen&&(d=Im("excalidraw-link",o.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=Mm(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}});C(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Fe.POINTER),FC(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(Xu(),!1));C(this,"maybeHandleElementLinkClick",(o,r)=>{if(this.editorInterface.isTouchScreen){let n=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,n)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(o),!0):!1});C(this,"handleInteractiveContentPointerMove",o=>{let r=ze(o,this.state),n=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=n?.locked?null:n;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:r,moveEvent:o}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(r,n):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});C(this,"handleInteractiveContentPointerUp",o=>{if(this.lastPointerUpEvent=o,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let r=ze(o,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(o,r)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});C(this,"getTopLayerFrameAtSceneCoords",(o,r)=>{let n=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(s=>!s.locked&&Ef(o,s,n));if(!i.length)return null;let l=i.at(-1),a=this.getElementsAtPosition(o.x,o.y,{includeLockedElements:!0}).findLast(s=>!r?.excludeElementIds?.[s.id]);if(a){if(re(a)&&!a.locked)return l;let s=this.scene.getElementIndex(a.id),c=this.scene.getElementIndex(l.id);if(s!==-1&&c!==-1&&s<=c)return l;let d=r?.currentFrameId?i.find(m=>m.id===r.currentFrameId)??null:null;return d||(a.frameId?i.find(m=>m.id===a.frameId)??null:null)}return l});C(this,"updateFrameToHighlight",o=>{this.state.frameToHighlight!==o&&this.setState({frameToHighlight:o})});C(this,"maybeUpdateFrameToHighlightOnPointerMove",(o,r)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!r&&nv(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(o):null)});C(this,"insertNewElements",o=>{if(!o.length)return;let r=[];for(let n of o){let i=r[r.length-1];i?.[0].frameId===n.frameId?i.push(n):r.push([n])}for(let n of r){let i=n[0].frameId,l=i?Ym(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(n,l)}});C(this,"insertNewElement",o=>{this.insertNewElements([o]);let r=o.frameId?this.scene.getNonDeletedElement(o.frameId):null;this.updateFrameToHighlight(r&&re(r)?r:null)});C(this,"handleCanvasPointerMove",o=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(o.clientX,o.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(o),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!Zn&&this.handleInteractiveContentPointerMove(o);return}this.savePointer(o.clientX,o.clientY,this.state.cursorButton),this.lastPointerMoveEvent=o.nativeEvent;let r=ze(o,this.state),{x:n,y:i}=r;if(this.lastPointerMoveCoords={x:n,y:i},this.updateMultiTouchGesture(o),$n||Zn||vg||kc(this.state))return;let a=dx(em,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(a?this.cursor.set(Fe.AUTO):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:n,y:i},a),!this.state.newElement&&FS(this.state.activeTool.type)){let{originOffset:f,snapLines:x}=OS(this.scene.getNonDeletedElements(),this,{x:n,y:i},o,this.scene.getNonDeletedElementsMap());this.setState(v=>{let y=il(v.snapLines,x),E=v.originSnapOffset?il(v.originSnapOffset,f):f;return v.snapLines===y&&v.originSnapOffset===E?null:{snapLines:y,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=this.state.newElement?null:Z.handlePointerMoveInEditMode(o,n,i,this);f&&f!==this.state.selectedLinearElement&&Bo(()=>{this.setState({selectedLinearElement:f})})}if(Qy(this.state.activeTool.type)){let{newElement:f}=this.state;if(!f&&pa(this.state)){let x=_(n,i),v=this.scene.getNonDeletedElementsMap(),y=Qo(x,this.scene.getNonDeletedElements(),v,ui(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:Rm(x,y,v,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:f,selectedLinearElement:x}=this.state,{x:v,y,points:E}=f,w=E[E.length-1],{lastCommittedPoint:T}=x;if(this.cursor.applyForTool(),w===T)Ko(_(n-v,i-y),w)>=cm?(this.store.scheduleCapture(),Bo(()=>{it(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:E[E.length-1],selectedPointsIndices:[f.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:f.points.length}}})}),this.scene.mutateElement(f,{points:[...E,_(n-v,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Fe.POINTER);else if(E.length>2&&T&&Ko(_(n-v,i-y),T)<cm){this.cursor.set(Fe.POINTER),this.scene.mutateElement(f,{points:E.slice(0,-1)},{informMutation:!1,isDragging:!1});let S=f.points.length-1;this.setState({selectedLinearElement:{...x,selectedPointsIndices:x.selectedPointsIndices?[...new Set(x.selectedPointsIndices.map(A=>Math.min(A,S)))]:x.selectedPointsIndices,lastCommittedPoint:f.points[S],initialState:{...x.initialState,lastClickedPoint:S}}})}else{lc(E,this.state.zoom.value)&&this.cursor.set(Fe.POINTER);let S=this.scene.getNonDeletedElementsMap();if(_m(f)){let M=Qo(_(n,i),this.scene.getNonDeletedElements(),S);qo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(f,M)}it(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let A=Z.handlePointerMove(o.nativeEvent,this,n,i,this.state.selectedLinearElement);A&&this.setState(A)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let f=_(n,i),x=Qo(f,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),ui(this.state.zoom)),v=this.scene.getNonDeletedElementsMap();x&&!bc(f,x,v)&&this.setState({suggestedBinding:{element:x,midPoint:Rm(f,x,v,this.state.zoom)}})}let s=!!o.buttons,c=this.state.activeTool.type==="laser";if(s||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,r)){this.cursor.set(Fe.POINTER);return}if(m.length===1&&!a&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Re(m[0]))&&!(Se(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let f=_f(d,this.state,n,i,this.state.zoom,o.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(f&&f.transformHandleType){this.cursor.set(Df(f));return}}}else if(m.length>1&&!a&&this.state.openDialog?.name!=="elementLinkSelector"){let f=Pf(we(m),n,i,this.state.zoom,o.pointerType,this.editorInterface);if(f){this.cursor.set(Df({transformHandleType:f}));return}}if(rr(this.state))return;let p=this.getElementAtPosition(n,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let b=this.arrowText.updateHoveredAnchor(r);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:r,moveEvent:o})||(this.hitLinkElement=this.getElementLinkAtPosition(r,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||so(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(b?Fe.POINTER:ee(u)?Fe.TEXT:Fe.CROSSHAIR):!o[I.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(r,m)?this.cursor.set(Fe.MOVE):this.state.viewModeEnabled?this.cursor.set(Fe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Fe.AUTO):a?this.cursor.set(Fe.AUTO):!o[I.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(r,m))&&!u?.locked&&(!u||!Re(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Fe.MOVE):this.cursor.set(Fe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:il(f.hoveredElementIds,kt({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:il(f.hoveredElementIds,{})}))});C(this,"handleEraser",(o,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,o.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});C(this,"handleTouchMove",o=>{this.isInteractionEnabled()&&(tm=!0)});C(this,"handleCanvasPointerDown",o=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=o),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(o),Zn||this.handleCanvasPanUsingWheelOrSpaceDrag(o));return}let r=this.scene.getSelectedElements(this.state);if(!o.ctrlKey){let f=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==f&&this.setState({isBindingEnabled:f})}let n=ze(o,this.state),{x:i,y:l}=n;this.lastPointerMoveCoords={x:i,y:l};let a=o.target;if(a.setPointerCapture&&a.setPointerCapture(o.pointerId),this.maybeCleanupAfterMissingPointerUp(o.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(f=>({searchMatches:f.searchMatches&&{focusedId:null,matches:f.searchMatches.matches.map(x=>({...x,focus:!1}))}})),this.updateEditorAtom(Yx,null)),bt.get(sr)&&this.updateEditorAtom(sr,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(o),o.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let f=this.state.newElement;this.updateScene({...f.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==f.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Be(Object.keys(this.state.selectedElementIds).filter(x=>x!==f.id).reduce((x,v)=>(x[v]=this.state.selectedElementIds[v],x),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?N.EVENTUALLY:N.NEVER});return}let s=document.getSelection();if(s?.anchorNode&&s.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(o),!this.state.penDetected&&o.pointerType==="pen"&&this.setState(f=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(o.pointerType)&&(this.editorInterface=nl(this.editorInterface,{isTouchScreen:!0})),Zn||(this.lastPointerDownEvent=o,this.handleCanvasPanUsingWheelOrSpaceDrag(o)))return;if(this.setState({lastPointerDownWith:o.pointerType,cursorButton:"down"}),this.savePointer(o.clientX,o.clientY,"down"),o.button===Xo.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==ht.eraser){this.setState({activeTool:ft(this.state,{type:ht.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(o);let f=()=>{x(),v?.(),rr(this.state)&&this.setState({activeTool:ft(this.state,{...this.state.activeTool.lastActiveTool||{type:ht.selection},lastActiveTool:null})})},x=_e(window,"pointerup",f,{once:!0}),v;requestAnimationFrame(()=>{v=this.missingPointerEventCleanupEmitter.once(f)})});return}if(o.button!==Xo.MAIN&&o.button!==Xo.TOUCH&&o.button!==Xo.ERASER||Le.pointers.size>1)return;let c=this.initialPointerDownState(o);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(r,c.origin)||this.handleDraggingScrollBar(o,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(o,c))||!(!this.state.penMode||o.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let f=c.hit.element&&this.isASelectedElement(c.hit.element);(o.altKey&&o[I.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!f)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,o.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!f&&(this.setState(y=>{let E={...y.selectedElementIds,[c.hit.element.id]:!0},w=[];Object.keys(y.selectedElementIds).forEach(S=>{let A=this.scene.getElement(S);A&&w.push(A)});let T=c.hit.element;if(re(T))er(w,T.id).forEach(S=>{delete E[S.id]});else if(T.frameId)E[T.frameId]&&delete E[T.id];else{let S=T.groupIds,A=new Set(S.flatMap(M=>He(this.scene.getNonDeletedElements(),M)).filter(M=>re(M)).map(M=>M.id));A.size>0&&w.forEach(M=>{M.frameId&&A.has(M.frameId)&&(delete E[M.id],M.groupIds.flatMap(O=>He(this.scene.getNonDeletedElements(),O)).forEach(O=>{delete E[O.id]}))})}return{...kt({editingGroupId:y.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||so(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(o,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(o,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(o,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===ht.frame||this.state.activeTool.type===ht.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===ht.bucketfill?this.bucketFill.handlePointerDown(n):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,o),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),b=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(f=>p(f||o.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener("pointermove",m),window.addEventListener("pointerup",p),window.addEventListener("keydown",u),window.addEventListener("keyup",b),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=b,c.eventListeners.onKeyDown=u)});C(this,"handleCanvasPointerUp",o=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(o);return}if(qo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(o),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,o),this.lastPointerUpEvent=o,!o.ctrlKey){let l=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==l&&this.setState({isBindingEnabled:l})}let r=ze({clientX:o.clientX,clientY:o.clientY},this.state),{x:n,y:i}=r;this.lastPointerMoveCoords={x:n,y:i},!this.handleIframeLikeCenterClick()&&!this.maybeHandleElementLinkClick(o,r)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});C(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",o=>{o.pointerType==="touch"&&(tm=!1,qi?tm=!0:qi=window.setTimeout(()=>{qi=0,tm||this.handleCanvasContextMenu(o)},ny))});C(this,"resetContextMenuTimer",()=>{clearTimeout(qi),qi=0,tm=!1});C(this,"maybeCleanupAfterMissingPointerUp",o=>{Vs?.(),this.missingPointerEventCleanupEmitter.trigger(o).clear()});C(this,"handleCanvasPanUsingWheelOrSpaceDrag",o=>{if(!(Le.pointers.size<=1&&((o.button===Xo.WHEEL||o.button===Xo.MAIN&&$n||kc(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Zn=!0,this.focusContainer(),this.state.editingTextElement||o.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Fe.GRABBING);let{clientX:i,clientY:l}=o,a=yh(c=>{let d=i-c.clientX,m=l-c.clientY;if(i=c.clientX,l=c.clientY,n&&!r&&(Math.abs(d)>1||Math.abs(m)>1)){r=!0;let p=b=>{document.body.removeEventListener("paste",p),b.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener("paste",p),window.removeEventListener("pointerup",u)},100)};document.body.addEventListener("paste",p),window.addEventListener("pointerup",u)}this.viewport.translate({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),s=Tt(Vs=()=>{Vs=null,Zn=!1,$n||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(o.clientX,o.clientY,"up"),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),a.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",a,{passive:!0}),window.addEventListener("pointerup",s),!0});C(this,"updateMultiTouchGesture",o=>{Le.pointers.has(o.pointerId)&&Le.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY});let r=Le.initialScale;if(Le.pointers.size===2&&Le.lastCenter&&r&&Le.initialDistance){let n=ox(Le.pointers),i=n.x-Le.lastCenter.x,l=n.y-Le.lastCenter.y;Le.lastCenter=n;let a=rx(Array.from(Le.pointers.values())),s=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:a/Le.initialDistance,c=s?Ei(r*s):this.state.zoom.value;this.setState(d=>{let m=xi({viewportX:n.x,viewportY:n.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i/p,scrollY:m.scrollY+2*l/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else Le.lastCenter=Le.initialDistance=Le.initialScale=null});C(this,"clearSelectionIfNotUsingSelection",()=>{nc(this.state.activeTool.type)||this.setState({selectedElementIds:Be({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});C(this,"handleSelectionOnPointerDown",(o,r)=>{if(nc(this.state.activeTool.type)){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),l=this.scene.getSelectedElements(this.state);if(l.length===1&&!this.state.selectedLinearElement?.isEditing&&!Re(l[0])&&!(Se(l[0])&&(this.editorInterface.userAgent.isMobileDevice||l[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let a=_f(n,this.state,r.origin.x,r.origin.y,this.state.zoom,o.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);a!=null&&(a.transformHandleType==="rotation"?(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType))}else l.length>1&&(r.resize.handleType=Pf(we(l),r.origin.x,r.origin.y,this.state.zoom,o.pointerType,this.editorInterface));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=wm(Hw(r.resize.handleType,l,i,r.origin.x,r.origin.y)),l.length===1&&Se(l[0])&&l[0].points.length===2&&(r.resize.arrowDirection=Uw(r.resize.handleType,l[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Z.handlePointerDown(o,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let b=this.scene.getNonDeletedElementsMap(),f=Z.getElement(p.elementId,b);if(f&&zt(f)){let{hitFocusPoint:x,pointerOffset:v,arrowOtherEndpointInitialBinding:y}=Dw(f,r,b,this.state);if(x)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:x,draggedFocusPointBinding:x,pointerOffset:v,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:y}}}),!1}}let a=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=a.filter(p=>!p.locked),c=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:a});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let d=r.hit.element,m=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!o.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Be({[p.selectedLinearElement.elementId]:!0},this.state):Be({},p)}));else if(d!=null){if(o[I.CTRL_OR_CMD])return o.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(r.origin.x,r.origin.y,o.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...Pv(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!ml(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Be({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},b=[];if(Object.keys(p.selectedElementIds).forEach(f=>{let x=this.scene.getElement(f);x&&b.push(x)}),re(d))er(b,d.id).forEach(f=>{delete u[f.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let f=d.groupIds,x=new Set(f.flatMap(v=>He(this.scene.getNonDeletedElements(),v)).filter(v=>re(v)).map(v=>v.id));x.size>0&&b.forEach(v=>{v.frameId&&x.has(v.frameId)&&(delete u[v.id],v.groupIds.flatMap(y=>He(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(f=>p.selectedGroupIds[f])||(u={[d.id]:!0})),{...kt({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||so(d)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});C(this,"handleTextOnPointerDown",(o,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y;this.setState({hoveredArrowTextAnchor:null});let l=this.arrowText.getBindableEndpointAtPosition(n,i);if(l)this.startTextEditing({sceneX:n,sceneY:i,autoEdit:!1,arrowEndpoint:l});else{let a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),s=this.getTextBindableContainerAtPosition(n,i);Ht(a)&&(s=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!o.altKey,container:s,autoEdit:!1,initialCaretSceneCoords:{x:n,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:ft(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});C(this,"handleFreeDrawElementOnPointerDown",(o,r,n)=>{let[i,l]=Qt(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),s=o.pressure===.5,c=this.state.currentItemStrokeVariability,d=aw({type:r,x:i,y:l,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,strokeOptions:{variability:c,streamline:o.pointerType!=="mouse"?hy:uy},locked:!1,frameId:a?a.id:null,points:[_(0,0)],pressures:s?[]:[o.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:Be(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});C(this,"insertIframeElement",({sceneX:o,sceneY:r,width:n,height:i})=>{let[l,a]=Qt(o,r,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=rw({type:"iframe",x:l,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.insertNewElement(s),s});C(this,"insertEmbeddableElement",({sceneX:o,sceneY:r,link:n})=>{let[i,l]=Qt(o,r,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=fa(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:h("toast.unrecognizedLinkFormat"),closable:!0});let s=Cf({type:"embeddable",x:i,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),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.insertNewElement(s),s});C(this,"newImagePlaceholder",({sceneX:o,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,l]=Qt(o,r,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=n?this.getTopLayerFrameAtSceneCoords({x:i,y:l}):null,s=100/this.state.zoom.value;return lw({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null,x:i-s/2,y:l-s/2,width:s,height:s})});C(this,"handleLinearElementOnPointerDown",(o,r,n)=>{if(o.ctrlKey&&Bo(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:l}=this.state;if(it(l,"selectedLinearElement is expected to be set"),i.type==="line"&&lc(i.points,this.state.zoom.value)){Bo(()=>{this.setState({selectedLinearElement:{...l,lastCommittedPoint:i.points[i.points.length-1],initialState:{...l.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(Gt);return}if(Re(i)&&i.points.length>1){this.actionManager.executeAction(Gt,"ui",{event:o.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}let{x:a,y:s}=i,{lastCommittedPoint:c}=l,d=ze(o,this.state),{start:m,end:p}=zt(i)&&pa(this.state)?Mv(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),b=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!bc(p.focusPoint,p.element,u),f=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,x=c&&Ko(_(n.origin.x-a,n.origin.y-s),c)<cm;if(f||b||i.points.length>1&&x){this.actionManager.executeAction(Gt,"ui",{event:o.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}this.setState(v=>({selectedElementIds:Be({...v.selectedElementIds,[i.id]:!0},v)})),this.cursor.set(Fe.POINTER)}else{let[i,l]=Qt(n.origin.x,n.origin.y,o[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[d,m]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?bi({type:r,x:i,y:l,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(r),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===gt.round?{type:At.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===gt.elbow,fixedSegments:this.state.currentItemArrowType===gt.elbow?[]:null}):to({type:r,x:i,y:l,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(r),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:At.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),u=_(n.origin.x,n.origin.y),b=this.scene.getNonDeletedElementsMap(),f=pa(this.state)?Qo(u,this.scene.getNonDeletedElements(),b):null;this.scene.mutateElement(p,{points:[_(0,0),_(0,0)]}),this.insertNewElement(p),zt(p)&&xc(p,new Map([[0,{point:_(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:o.altKey,initialBinding:!0,angleLocked:ii(o.nativeEvent)}),Bo(()=>{this.setState(x=>{let v=null,y=x.selectedElementIds;if(Se(p)){v=new Z(p,this.scene.getNonDeletedElementsMap());let E=p.points.length-1;v={...v,selectedPointsIndices:[E],initialState:{...v.initialState,arrowStartIsInside:o.altKey,lastClickedPoint:E,origin:_(n.origin.x,n.origin.y)}}}return y=this.isToolLocked()?x.selectedElementIds:Be({[p.id]:!0},x),{...x,bindMode:"orbit",newElement:p,suggestedBinding:f&&zt(p)?{element:f,midPoint:Rm(u,f,b,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:v}})}),zt(p)&&qo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,f)}});C(this,"createGenericElementOnPointerDown",(o,r)=>{let[n,i]=Qt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(o),locked:!1,frameId:l?l.id:null},s;o==="embeddable"?s=Cf({type:"embeddable",...a}):s=Ao({type:o,...a}),s.type==="selection"?this.setState({selectionElement:s}):(this.insertNewElement(s),this.setState({multiElement:null,newElement:s}))});C(this,"createFrameElementOnPointerDown",(o,r)=>{let[n,i]=Qt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...tt},a=r===ht.magicframe?If(l):Qm(l);this.insertNewElement(a),this.setState({multiElement:null,newElement:a})});C(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});C(this,"eraseElements",()=>{let o=!1;this.elementsPendingErasure.forEach(n=>{let i=this.scene.getElement(n);if(zt(i)){if(i.startBinding){let l=this.scene.getElement(i.startBinding.elementId);co(l,this.scene.getElementsMapIncludingDeleted(),{boundElements:l.boundElements.filter(a=>a.id!==i.id)})}if(i.endBinding){let l=this.scene.getElement(i.endBinding.elementId);co(l,this.scene.getElementsMapIncludingDeleted(),{boundElements:l.boundElements.filter(a=>a.id!==i.id)})}}else da(i)&&i.boundElements?.forEach(l=>{if(l.type==="arrow"){let a=this.scene.getElement(l.id);a?.startBinding?.elementId===i.id&&co(a,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),a?.endBinding?.elementId===i.id&&co(a,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||mt(n)&&this.elementsPendingErasure.has(n.containerId)?(o=!0,se(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,o&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});C(this,"initializeImage",async(o,r)=>{if(!Gf(r))throw new Error(h("errors.unsupportedFileType"));let n=r.type;if(this.cursor.set("wait"),n===pe.svg)try{r=Kf(Af(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(h("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||s2(r));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(h("errors.imageInsertError"));if(!this.files[i]?.dataURL){let{maxWidthOrHeight:s,maxFileSizeBytes:c}=this.props.imageOptions;try{r=await pp(r,{maxWidthOrHeight:s})}catch(d){console.error("Error trying to resizing image file on insertion",d)}if(r.size>c)throw new Error(h("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let a=this.files[i]?.dataURL||await Yf(r);return new Promise(async(s,c)=>{try{let d=this.getLatestInitializedImageElement(o,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:a,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([d]);if(p.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(i)?.image;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(o,i);let p=this.getImageNaturalDimensions(d,m);Object.assign(d,p)}s(d)}catch(d){console.error(d),c(new Error(h("errors.imageInsertError")))}})});C(this,"getLatestInitializedImageElement",(o,r)=>{let n=this.scene.getElement(o.id)??o;return se(n,{fileId:r})});C(this,"onImageToolbarButtonClick",async()=>{try{let o=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=ze({clientX:o,clientY:r},this.state),l=await ip({description:"Image",extensions:Object.keys(Js),multiple:!0});this.insertImages(l,n,i)}catch(o){o.name!=="AbortError"?console.error(o):console.warn(o),this.setState({newElement:null,activeTool:ft(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(Gt)})}});C(this,"getImageNaturalDimensions",(o,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(r.naturalHeight,i),a=l*(r.naturalWidth/r.naturalHeight),s=o.x+o.width/2-a/2,c=o.y+o.height/2-l/2;return{x:s,y:c,width:a,height:l,crop:null}});C(this,"updateImageCache",async(o,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await Ow({imageCache:this.imageCache,fileIds:o.map(l=>l.fileId),files:r});return i.size&&(this.store.scheduleAction(N.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(l=>si(l)&&i.has(l.fileId)?se(l,{status:"error"}):l))),{updatedFiles:n,erroredFiles:i}});C(this,"addNewImagesToImageCache",async(o=Fw(this.scene.getNonDeletedElements()),r=this.files)=>{let n=o.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let l of n)i.has(l.fileId)&&tr.delete(l);i.size&&this.scene.triggerUpdate()}});C(this,"scheduleImageRefresh",G9(()=>{this.addNewImagesToImageCache()},ry));C(this,"handleInteractiveCanvasRef",o=>{o!==null?(this.interactiveCanvas=o,this.cursor.reset(),this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});C(this,"insertImages",async(o,r,n)=>{let i=50/this.state.zoom.value,l=Lf(o.map(()=>this.newImagePlaceholder({sceneX:r,sceneY:n})),r,n,i);this.insertNewElements(l);let a=await Promise.all(l.map(async(p,u)=>{try{return await this.initializeImage(p,await Dc(o[u]))}catch(b){return this.setState({errorMessage:b.message||h("errors.imageInsertError")}),se(p,{isDeleted:!0})}})),s=ie(a),c=Lf(a.filter(p=>!p.isDeleted),r,n,i),d=ie(c),m=this.scene.getElementsIncludingDeleted().map(p=>d.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:Be(Object.fromEntries(c.map(p=>[p.id,!0])),this.state)},elements:m,captureUpdate:N.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(Gt)})});C(this,"handleAppOnDrop",async o=>{if(!this.isInteractionEnabled())return;let{x:r,y:n}=ze(o,this.state),i=await Kl(o),l=i.getFiles();if(l.length===1){let{file:m,fileHandle:p}=l[0];if(m&&(m.type===pe.png||m.type===pe.svg))try{let u=await mp(m,this.state,this.scene.getElementsIncludingDeleted(),p);this.syncActionResult({...u,appState:{...u.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:N.IMMEDIATELY});return}catch(u){if(u.name!=="EncodingError")throw new Error(h("alerts.couldNotLoadInvalidFile"))}}let a=l.map(m=>m.file).filter(m=>Gf(m));if(a.length>0&&this.isToolSupported("image"))return this.insertImages(a,r,n);let s=i.getData(pe.excalidrawlibIds),c=i.getData(pe.excalidrawlib);if(s||c){try{let m=null;if(s){let{itemIds:p}=JSON.parse(s);m=(await this.library.getLatestLibrary()).filter(b=>p.includes(b.id))}else c&&(m=l2(c));m?.length&&(m=m.map(p=>({...p,elements:Sn({type:"everything",elements:p.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:ms(m),position:o,files:null}))}catch(m){this.setState({errorMessage:m.message})}return}if(l.length>0){let{file:m,fileHandle:p}=l[0];m&&await this.loadFileToCanvas(m,p)}let d=i.findByType(pe.text);if(d){let m=d.value;if(m&&fl(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||fa(m)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:r,sceneY:n,link:Sr(m)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});C(this,"loadFileToCanvas",async(o,r)=>{o=await Dc(o);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Wf(o,this.state,n,r)}catch(l){let a=l instanceof jw;if(a&&l.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:h("errors.imageToolNotSupported")});return}let s=a?h("alerts.cannotRestoreFromImage"):h("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===pe.excalidraw?(ul(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:N.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:N.IMMEDIATELY})):i.type===pe.excalidrawlib&&await this.library.updateLibrary({libraryItems:o,merge:!0,openLibraryMenu:!0}).catch(l=>{console.error(l),this.setState({errorMessage:h("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});C(this,"handleCanvasContextMenu",o=>{if(o.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="touch"||"pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="pen"&&o.button!==Xo.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:r,y:n}=ze(o,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),l=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},l),s=i||a?"element":"canvas",c=this.excalidrawContainerRef.current,{top:d,left:m}=c.getBoundingClientRect(),p=o.clientX-m,u=o.clientY-d;Ee("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...kt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Se(i)?new Z(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});C(this,"maybeDragNewGenericElement",(o,r,n=!0)=>{let i=this.state.selectionElement,l=o.lastCoords;if(i&&o.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){kf({newElement:i,elementType:this.state.activeTool.type,originX:o.origin.x,originY:o.origin.y,x:l.x,y:l.y,width:sa(o.origin.x,l.x),height:sa(o.origin.y,l.y),shouldMaintainAspectRatio:rl(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let a=this.state.newElement;if(!a||this.arrowText.maybeDragNewText(a,l))return;let[s,c]=Qt(l.x,l.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=si(a)&&this.imageCache.get(a.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(r,[a]);let{snapOffset:p,snapLines:u}=NS(a,this,r,{x:o.originInGrid.x+(this.state.originSnapOffset?.x??0),y:o.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-o.originInGrid.x,y:c-o.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),zt(a)||kf({newElement:a,elementType:this.state.activeTool.type,originX:o.originInGrid.x,originY:o.originInGrid.y,x:s,y:c,width:sa(o.originInGrid.x,s),height:sa(o.originInGrid.y,c),shouldMaintainAspectRatio:ot(a)?!rl(r):rl(r),shouldResizeFromCenter:of(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:a}),(this.state.activeTool.type===ht.frame||this.state.activeTool.type===ht.magicframe)&&this.setState({elementsToHighlight:Mo(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})});C(this,"maybeHandleCrop",(o,r)=>{if(!this.state.croppingElementId)return!1;let n=o.resize.handleType,i=o.lastCoords,[l,a]=Qt(i.x-o.resize.offset.x,i.y-o.resize.offset.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&ot(s)){let c=o.originalElements.get(s.id),d=si(s)&&this.imageCache.get(s.fileId)?.image;if(c&&ot(c)&&d&&!(d instanceof Promise)){let[m,p]=Qt(i.x,i.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-o.originInGrid.x,y:p-o.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:b,snapLines:f}=ix([s],[c],this,r,u,n);this.scene.mutateElement(s,jy(s,this.scene.getNonDeletedElementsMap(),n,d.naturalWidth,d.naturalHeight,l+b.x,a+b.y,r.shiftKey?c.width/c.height:void 0)),ko(s,this.scene),this.setState({isCropping:n&&n!=="rotation",snapLines:f})}return!0}return!1});C(this,"maybeHandleResize",(o,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(re),l=o.resize.handleType;if(i.length>0&&l==="rotation"||n.length===1&&Re(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:l&&l!=="rotation",isRotating:l==="rotation",activeEmbeddable:null});let a=o.lastCoords,[s,c]=Qt(a.x-o.resize.offset.x,a.y-o.resize.offset.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{er(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Qt(a.x,a.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-o.originInGrid.x,y:p-o.originInGrid.y},b=[...o.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:f,snapLines:x}=ix(n,ae(b,this.state),this,r,u,l);s+=f.x,c+=f.y,this.setState({snapLines:x})}if(Bw(o.originalElements,l,n,this.scene,ii(r),of(r),n.some(m=>ot(m))?!rl(r):rl(r),s,c,o.resize.center.x,o.resize.center.y)){let m=new Set;return i.forEach(p=>{Mo(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{or(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});C(this,"getContextMenuItems",o=>{let r=[];if(r.push(gd,hd),o==="canvas")return this.state.viewModeEnabled?[...r,Na,zn,zi,Hn]:[v0,Nt,gd,hd,fd,Nt,jp,BC,Nt,Na,Jl,Ql,es,zn,zi,Hn];if(r.push(fd),this.state.viewModeEnabled)return[Ra,...r];let n=this.editorInterface.formFactor==="desktop"?[Nt,Yp,Kp,Xp,$p]:[];return[Nt,ud,Ra,v0,Nt,yS,vS,wS,Nt,bh,Nt,...r,Nt,Nu,Ou,Nt,Fu,ex,Vu,Yu,LC,Bu,Nt,Uu,...n,Nt,Gu,Wu,Nt,Ba,Nt,os,ju,Nt,qp,rs,Nt,Nl]});C(this,"handleWheel",Tt(o=>{if(!this.isNavigationEnabled())return;if(!(o.target instanceof HTMLCanvasElement||o.target instanceof HTMLTextAreaElement||o.target instanceof HTMLIFrameElement||o.target instanceof HTMLElement&&o.target.classList.contains(et.FRAME_NAME))){o[I.CTRL_OR_CMD]&&o.preventDefault();return}if(o.preventDefault(),Zn)return;let{deltaX:r,deltaY:n}=o;if(o.metaKey||o.ctrlKey){let i=Math.sign(n),l=Qs*100,a=Math.abs(n),s=n;a>l&&(s=l*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,a/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:pm;c=Math.max(c,d),this.viewport.translate(p=>({...xi({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Ei(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(o.shiftKey){this.viewport.translate(({zoom:i,scrollX:l})=>({scrollX:l-(n||r)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:l,scrollY:a})=>({scrollX:l-r/i.value,scrollY:a-n/i.value}))}));C(this,"savePointer",(o,r,n)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!o||!r)return;let{x:i,y:l}=ze({clientX:o,clientY:r},this.state);isNaN(i)||isNaN(l);let a={x:i,y:l,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:a,button:n,pointersMap:Le.pointers})});C(this,"resetShouldCacheIgnoreZoomDebounced",xn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));C(this,"updateDOMRect",o=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:l,top:a}=r.getBoundingClientRect(),{width:s,height:c,offsetTop:d,offsetLeft:m}=this.state;if(n===s&&i===c&&l===m&&a===d){o&&o();return}this.setState({width:n,height:i,offsetLeft:l,offsetTop:a},()=>{o&&o()}),this.viewport.constrain()}});C(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});C(this,"watchState",()=>{});let r=Mn(),{viewModeEnabled:n=!1,zenModeEnabled:i=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:a=!1,theme:s=r.theme,name:c=`${h("labels.untitled")}-${rf()}`}=o,d=null;o.activeTool&&(o.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(o.activeTool.type,o)?d=ft(r,o.activeTool):console.warn(`"${o.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...r,theme:s,exportWithDarkMode:s===J.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(o)?n:!0,activeTool:d??r.activeTool,zenModeEnabled:i,objectsSnapModeEnabled:a,gridModeEnabled:l??r.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=aa(this.editorInterface),this.id=V9(),this.library=new rI(this),this.actionManager=new xh(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Sf,this.canvas=document.createElement("canvas"),this.rc=W9.canvas(this.canvas),this.renderer=new Ad(this.scene),this.visibleElements=[],this.store=new gw(this),this.history=new kd(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new kn(this.scene),this.history=new kd(this.store),this.actionManager.registerAll(Vp),this.actionManager.registerAction(CS(this.history)),this.actionManager.registerAction(IS(this.history)),this.api=this.createExcalidrawAPI()}createExcalidrawAPI(){return{app:this,isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:r=>{this.actionManager.registerAction(r)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:r=>this.onChangeEmitter.on(r),onIncrement:r=>this.store.onStoreIncrementEmitter.on(r),onPointerDown:r=>this.onPointerDownEmitter.on(r),onPointerUp:r=>this.onPointerUpEmitter.on(r),onScrollChange:r=>this.onScrollChangeEmitter.on(r),onUserFollow:r=>this.onUserFollowEmitter.on(r),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(o=this.props){return o.interaction!==!1&&typeof o.interaction!="object"}isLinksEnabled(o=this.props){return typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.links===!0||o.interaction.enabled?.interactiveContent===!0:o.interaction!==!1}isNavigationEnabled(o=this.props){return typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.navigation===!0:o.interaction!==!1}isEmbedsEnabled(o=this.props){return typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.embeds===!0||o.interaction.enabled?.interactiveContent===!0:o.interaction!==!1}isBrowserZoomEnabled(o=this.props){return typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(o=this.props){return o.ui!==!1&&(typeof o.ui!="object"||o.ui===null)}isUIControlEnabled(o,r=this.props){return typeof r.ui=="object"&&r.ui!==null?r.ui.enabled?.[o]===!0:r.ui!==!1}setSessionExportThemeOverride(o){kM=o}onWindowMessage(o){if(o.origin!=="https://player.vimeo.com"&&o.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(o.data)}catch{}if(r)switch(o.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let l of i)l.contentWindow===o.source&&(n=l.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(qs).includes(i)&&IE.set(n,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){it(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let o=this.scene.getNonDeletedElementsMap(),r=Qo(_(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),o),n=Z.getElement(this.state.selectedLinearElement.elementId,o);n?.startBinding&&r?.id===n.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Bo(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:o,y:r}=this.lastPointerMoveCoords,n=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;it(n,"Last event must exist");let i=o-this.state.selectedLinearElement.pointerOffset.x,l=r-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?Z.handlePointerMove(n,this,i,l,this.state.selectedLinearElement):Z.handlePointDragging(n,this,i,l,this.state.selectedLinearElement);a&&this.setState(a)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(o,r){if(o.isDeleted||Re(o))return;let n=()=>{if(this.bindModeHandler=null,it(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let b=this.state.selectedLinearElement.selectedPointsIndices.includes(0),f=this.state.selectedLinearElement.selectedPointsIndices.includes(o.points.length-1);if(!b&&!f||b&&f)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Qo(_(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){it(this.state.selectedLinearElement?.elementId===o.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let b=this.state.selectedLinearElement.initialState.arrowStartIsInside||o.startBinding?.elementId===u.id;Bo(()=>{it(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:b}}})});let f=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;it(f,"Last event must exist");let x=m-this.state.selectedLinearElement.pointerOffset.x,v=p-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?Z.handlePointerMove(f,this,x,v,this.state.selectedLinearElement):Z.handlePointDragging(f,this,x,v,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(o.points.length-1),b=p?r:o.startBinding&&m.get(o.startBinding.elementId),f=u?r:o.endBinding&&m.get(o.endBinding.elementId),x=b&&fi(b,m),v=f&&fi(f,m);i=!!(x&&v&&b.id!==f.id&&gl(x,v))}let l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(o.points.length-1),s=l?"startBinding":a?"endBinding":null,c=l?"endBinding":a?"startBinding":null,d=c&&o[c]?.mode==="inside"&&o[c]?.elementId===r?.id||s&&o[s]?.mode==="inside"&&r?.id===o[s]?.elementId;s&&c&&o[s]?.mode==="inside"&&r?.id!==o[s]?.elementId&&o[c]?.elementId!==o[s]?.elementId&&this.scene.mutateElement(o,{[s]:{...o[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!r||this.previousHoveredBindableElement&&r.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Bo(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!o.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(n,ri)),this.previousHoveredBindableElement=r}cacheEmbeddableRef(o,r){r&&this.iFrameRefs.set(o.id,r)}getHTMLIFrameElement(o){return this.iFrameRefs.get(o.id)}isIframeLikeInteractive(o){return ca(o)?(o.customData?.generationData??this.magicGenerations.get(o.id))?.status!=="pending":!0}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Xo.MAIN||$n||!lf(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let o=_(ze({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),r=_(ze({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Ko(o,r)>Ja)return!1;let i=this.getElementAtPosition(o[0],o[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&Le.pointers.size<2&&al(i)&&this.isIframeLikeInteractive(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,r[0],r[1]))))return!1;let a=i;if(this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:a,state:"active"},selectedElementIds:{[a.id]:!0},newElement:null,selectionElement:null})},100),ca(a)))return!0;let s=this.getHTMLIFrameElement(a);if(!s?.contentWindow)return!0;if(s.src.includes("youtube")){let c=IE.get(a.id);switch(c||(IE.set(a.id,qs.UNSTARTED),s.contentWindow.postMessage(JSON.stringify({event:"listening",id:a.id}),"*")),c){case qs.PLAYING:case qs.BUFFERING:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:s.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return s.src.includes("player.vimeo.com")&&s.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(o,r,n,i){return o&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==o||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=o.x+o.width/3&&n<=o.x+2*o.width/3&&i>=o.y+o.height/3&&i<=o.y+2*o.height/3}renderEmbeddables(){let o=this.state.zoom.value,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(l=>so(l)&&this.embedsValidationStatus.get(l.id)===!0||ca(l));return Oe($9,{children:i.map(l=>{let{x:a,y:s}=Ft({sceneX:l.x,sceneY:l.y},this.state),c=Cc(l,r,n,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(l.id);if(c&&!d&&this.initializedEmbeds.add(l.id),!(c||d))return null;let p,u=!1;if(ca(l)){p=null;let y=(l.customData?.generationData??this.magicGenerations.get(l.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(y.status==="done"){let E=y.html;p={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>E}}else if(y.status==="pending")p={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>Mf(`
|
|
40
47
|
<style>
|
|
41
48
|
html, body {
|
|
42
49
|
width: 100%;
|
|
43
50
|
height: 100%;
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
body {
|
|
47
|
-
display: flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
justify-content: center;
|
|
50
|
-
flex-direction: column;
|
|
51
|
-
gap: 1rem;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.Spinner {
|
|
55
|
-
display: flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
margin-left: auto;
|
|
59
|
-
margin-right: auto;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.Spinner svg {
|
|
63
|
-
animation: rotate 1.6s linear infinite;
|
|
64
|
-
transform-origin: center center;
|
|
65
|
-
width: 40px;
|
|
66
|
-
height: 40px;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.Spinner circle {
|
|
70
|
-
stroke: currentColor;
|
|
71
|
-
animation: dash 1.6s linear 0s infinite;
|
|
72
|
-
stroke-linecap: round;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@keyframes rotate {
|
|
76
|
-
100% {
|
|
77
|
-
transform: rotate(360deg);
|
|
78
|
-
}
|
|
51
|
+
margin: 0;
|
|
79
52
|
}
|
|
53
|
+
</style>
|
|
54
|
+
<script>
|
|
55
|
+
// progressively renders the partial HTML snapshots the
|
|
56
|
+
// editor streams in during generation by document.write-
|
|
57
|
+
// ing them into this very document \u2014 feeding the
|
|
58
|
+
// browser's incremental HTML parser, so incomplete
|
|
59
|
+
// markup renders progressively
|
|
60
|
+
// (see App.onMagicFrameGenerate)
|
|
61
|
+
let writtenLength = 0;
|
|
62
|
+
let opened = false;
|
|
80
63
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
const onPartialMessage = (event) => {
|
|
65
|
+
const data = event.data;
|
|
66
|
+
if (
|
|
67
|
+
!data ||
|
|
68
|
+
data.type !== "excalidraw:diagramToCode:partial" ||
|
|
69
|
+
typeof data.html !== "string" ||
|
|
70
|
+
data.html.length <= writtenLength
|
|
71
|
+
) {
|
|
72
|
+
return;
|
|
89
73
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
74
|
+
if (!opened) {
|
|
75
|
+
opened = true;
|
|
76
|
+
document.open();
|
|
77
|
+
// document.open() wipes all listeners from both the
|
|
78
|
+
// document and the window, so re-register
|
|
79
|
+
window.addEventListener("message", onPartialMessage);
|
|
93
80
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
cx="50"
|
|
102
|
-
cy="50"
|
|
103
|
-
r="46"
|
|
104
|
-
stroke-width="8"
|
|
105
|
-
fill="none"
|
|
106
|
-
stroke-miter-limit="10"
|
|
107
|
-
/>
|
|
108
|
-
</svg>
|
|
109
|
-
</div>
|
|
110
|
-
<div>Generating...</div>
|
|
111
|
-
`)};else{let E;f.code==="ERR_GENERATION_INTERRUPTED"?E="Generation was interrupted...":E=f.message||"Generation failed",d={intrinsicSize:{w:i.width,h:i.height},type:"document",srcdoc:()=>Dh(`
|
|
81
|
+
document.write(data.html.slice(writtenLength));
|
|
82
|
+
writtenLength = data.html.length;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
window.addEventListener("message", onPartialMessage);
|
|
86
|
+
<\/script>
|
|
87
|
+
`)},u=!0;else{let E;y.code==="ERR_GENERATION_INTERRUPTED"?E="Generation was interrupted...":E=y.message||"Generation failed",p={intrinsicSize:{w:l.width,h:l.height},type:"document",srcdoc:()=>Mf(`
|
|
112
88
|
<style>
|
|
113
89
|
html, body {
|
|
114
90
|
height: 100%;
|
|
@@ -118,7 +94,7 @@ Please fix the Mermaid syntax and regenerate a valid diagram.`;await E({prompt:e
|
|
|
118
94
|
flex-direction: column;
|
|
119
95
|
align-items: center;
|
|
120
96
|
justify-content: center;
|
|
121
|
-
color: ${
|
|
97
|
+
color: ${Co.red[3]};
|
|
122
98
|
}
|
|
123
99
|
h1, h3 {
|
|
124
100
|
margin-top: 0;
|
|
@@ -127,8 +103,8 @@ Please fix the Mermaid syntax and regenerate a valid diagram.`;await E({prompt:e
|
|
|
127
103
|
</style>
|
|
128
104
|
<h1>Error!</h1>
|
|
129
105
|
<h3>${E}</h3>
|
|
130
|
-
`)}}}else d=La(Ad(i.link||""));let h=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="active",b=this.state.activeEmbeddable?.element===i&&this.state.activeEmbeddable?.state==="hover";return Re("div",{className:wC("excalidraw__embeddable-container",{"is-hovered":b}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:by(i,ka(i,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?X0:1),"--embeddable-radius":`${zx(Math.min(i.width,i.height),i)}px`},children:Nu("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${i.width}px`:0,height:c?`${i.height}px`:0,transform:c?`rotate(${i.angle}rad)`:"none",pointerEvents:h?pa.enabled:pa.disabled},children:[b&&Re("div",{className:"excalidraw__embeddable-hint",children:u("buttons.embeddableInteractionButton")}),Re("div",{className:"excalidraw__embeddable__outer",style:{padding:`${i.strokeWidth}px`},children:(Vt(i)?this.props.renderEmbeddable?.(i,this.state):null)??Re("iframe",{ref:f=>this.cacheEmbeddableRef(i,f),className:"excalidraw__embeddable",srcDoc:d?.type==="document"?d.srcdoc(this.state.theme):void 0,src:d?.type!=="document"?d?.link??"":void 0,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:`${d?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},i.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderTopLeftUI:n,renderCustomStats:a}=this.props,i=this.scene.getSceneNonce(),{elementsMap:l,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:i,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});this.visibleElements=s;let c=this.scene.getNonDeletedElementsMap(),m="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",p=t[0],d=Et.get(pr)?.type==="panel";return Re("div",{translate:"no",className:wC("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?pa.disabled:pa.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:Re(IC.Provider,{value:this,children:Re(kC.Provider,{value:this.props,children:Re(u0.Provider,{value:this.excalidrawContainerValue,children:Re(p0.Provider,{value:this.editorInterface,children:Re(f0.Provider,{value:this.setAppState,children:Re(g0.Provider,{value:this.state,children:Nu(h0.Provider,{value:this.scene.getNonDeletedElements(),children:[Nu(b0.Provider,{value:this.actionManager,children:[Re(q5,{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:an().code,renderTopLeftUI:n,renderTopRightUI:r,renderCustomStats:a,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===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,uiDisabled:this.props.ui===!1,children:this.props.children}),Re("div",{className:"excalidraw-textEditorContainer"}),Re("div",{className:"excalidraw-contextMenuContainer"}),Re("div",{className:"excalidraw-eye-dropper-container"}),Re(eC,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Re(k2,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.props.aiEnabled!==!1&&t.length===1&&_d(p)&&Re(lb,{element:p,elementsMap:l,children:Re(Ru,{title:u("labels.convertToCode"),icon:Un,checked:!1,onChange:()=>this.onMagicFrameGenerate(p,"button")})}),t.length===1&&Ta(p)&&p.customData?.generationData?.status==="done"&&Nu(lb,{element:p,elementsMap:l,children:[Re(Ru,{title:u("labels.copySource"),icon:Ga,checked:!1,onChange:()=>this.onIframeSrcCopy(p)}),Re(Ru,{title:"Enter fullscreen",icon:hf,checked:!1,onChange:()=>{let h=this.getHTMLIFrameElement(p);if(h)try{h.requestFullscreen(),this.setState({activeEmbeddable:{element:p,state:"active"},selectedElementIds:{[p.id]:!0},newElement:null,selectionElement:null})}catch(b){console.warn(b),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Re(EC,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&this.props.interactive!==!1&&this.props.ui!==!1&&Re(R3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:h=>{this.setState({contextMenu:null},()=>{this.focusContainer(),h?.()})}}),Re(a0,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:c,visibleElements:s,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:ta(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes,theme:this.state.theme}}),this.state.newElement&&Re(xC,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Re(n0,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:s,allElementsMap:c,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,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&&Re(O3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&Re(vC,{app:this,activeLockedId:this.state.activeLockedId}),d&&Re(N2,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let a=Xd(this.scene.getNonDeletedElements(),t).filter(l=>!_d(l));if(!a.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),pe("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let i=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(i){this.updateMagicGeneration({frameElement:i,data:{status:"pending"}}),this.setState({selectedElementIds:{[i.id]:!0}}),pe("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:a});if(pe("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:i,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:i,data:{status:"done",html:s}})}catch(l){pe("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:i,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(mr(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{An(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),Er.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Qr()||Ht()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...a)=>this.setState(...a)},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.onDurableIncrementEmitter.on(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),nd&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),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),cx()&&!Wx()&&this.setState({errorMessage:Re(A3,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new Lh,this.fonts=new Nn(this.scene),this.renderer=new Pc(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(),this.store.onDurableIncrementEmitter.clear(),Er.destroy(),Yo.destroy(),xy(),this.onChangeEmitter.clear(),Id()&&(this.history=new Rl(this.store),this.library=new z1(this),this.actionManager=new Ac(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.canvas=null,this.interactiveCanvas=null,this.rc=null,this.excalidrawContainerRef.current=void 0,this.excalidrawContainerValue={container:null,id:"unmounted"}),clearTimeout(ca),Be.clearCache(),bt.clearCache(),ca=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ve(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ve(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ve(window,"message",this.onWindowMessage,!1),Ve(document,"pointerup",this.removePointer,{passive:!1}),Ve(document,"copy",this.onCopy,{passive:!1}),Ve(document,"keyup",this.onKeyUp,{passive:!0}),Ve(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),Ve(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Ve(document,"gesturestart",this.onGestureStart,!1),Ve(document,"gesturechange",this.onGestureChange,!1),Ve(document,"gestureend",this.onGestureEnd,!1),Ve(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ve(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),Ve(document,"paste",this.pasteFromClipboard,{passive:!1}),Ve(document,"cut",this.onCut,{passive:!1}),Ve(window,"resize",this.onResize,!1),Ve(window,"unload",this.onUnload,!1),Ve(window,"blur",this.onBlur,!1),Ve(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ve(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),Ve(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ve(yx(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),a=this.scene.getElementsMapIncludingDeleted();if(!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),this.props.activeTool&&this.props.activeTool.type!==this.state.activeTool.type&&this.setActiveTool(this.props.activeTool),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.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)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&po(this.state)&&this.setState({activeTool:Ne(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&h1(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),po(r)&&!po(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),!this.props.UIOptions.canvasActions&&this.state.openMenu==="canvas"&&this.setState({openMenu:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ne.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction($t)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.store.commit(a,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files,this.props.id),this.onChangeEmitter.trigger(n,this.state,this.files)),this.state.scrollConstraints?.animateOnNextUpdate){let l=cr(this.state,"rigid"),s={scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom.value},c={scrollX:l.scrollX,scrollY:l.scrollY,zoom:l.zoom.value};if(b1(s,c))return;qc&&clearTimeout(qc),qc=setTimeout(()=>{this.cancelInProgressAnimation?.(),this.animateToConstrainedArea(s,c)},200)}}static resetTapTwice(){Kc=!1,Zc=null}async insertClipboardContent(t,r,n){let{x:a,y:i}=Ye({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(r.length===0&&!n&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:n,sceneX:a,sceneY:i});return}if(t.spreadsheet&&!n){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=r.map(m=>m.file);if(l.length===0&&t.text&&!n){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&l.push(qh(m))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,a,i):this.setState({errorMessage:u("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?Hi(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:n});return}if(!t.text)return;if(!n&&k3(t.text)){let m=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:p,files:d}=await m.parseMermaidToExcalidraw(t.text),h=Hi(p,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:h,files:d,position:this.editorInterface.formFactor==="desktop"?"cursor":"center"});return}catch(p){console.warn(`parsing pasted text as mermaid definition failed: ${p.message}`)}}let s=Sx(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),c=s.map(m=>zy(m)).filter(m=>Bi(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||La(m)?.type==="video"));if(!n&&c.length>0&&c.length===s.length){let m=[];for(let p of c){let d=m[m.length-1],h=this.insertEmbeddableElement({sceneX:d?d.x+d.width+20:a,sceneY:i,link:rr(p)});h&&m.push(h)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,n)}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:a}){if(!r&&t.some(i=>i.type==="imageUrl")&&this.isToolSupported("image")){let i=t.filter(m=>m.type==="imageUrl").map(m=>m.value),l=await Promise.all(i.map(async m=>{try{return{file:await EE(m)}}catch(p){let d=p.message;return p.cause==="FETCH_ERROR"?d=u("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(d=u("errors.unsupportedFileType")),{errorMessage:d}}})),s=l.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,n,a);let c=l.find(m=>!!m.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let i=t.filter(l=>l.type==="text");i.length&&this.addTextFromPaste(i.map(l=>l.value).join(`
|
|
106
|
+
`)}}}else p=fa(Am(l.link||""));let b=this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===l&&this.state.activeEmbeddable?.state==="hover",x=p?.type==="video",v=qe(x?o:1,.75,K9);return Oe("div",{className:IM("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:c?`translate(${a-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${o})`:"none",display:c?"block":"none",opacity:$v(l,Cn(l,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?my:1),"--embeddable-radius":`${av(Math.min(l.width,l.height),l)}px`},children:om("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${l.width}px`:0,height:c?`${l.height}px`:0,transform:c?`rotate(${l.angle}rad)`:"none",pointerEvents:b?ta.enabled:ta.disabled},children:[f&&Oe("div",{className:"excalidraw__embeddable-hint",children:h("buttons.embeddableInteractionButton")}),Oe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${l.strokeWidth}px`},children:Oe("div",{className:"excalidraw__embeddable__content",style:{width:`${v*100}%`,height:`${v*100}%`,transform:`scale(${1/v})`},children:(so(l)?this.props.renderEmbeddable?.(l,this.state):null)??Oe("iframe",{ref:y=>this.cacheEmbeddableRef(l,y),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,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:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})}),u&&om("div",{className:"excalidraw__embeddable__generating",children:[Oe(Pt,{size:"1em"}),"Generating\u2026"]})]})},l.id)})})}toggleOverscrollBehavior(o){document.documentElement.style.overscrollBehaviorX=o.type==="pointerenter"?"none":"auto"}render(){let o=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderTopLeftUI:n,renderCustomStats:i}=this.props,{elementsMap:l,visibleElements:a,canvasNonce:s,newElementCanvasElement:c}=this.renderer.getRenderableElements({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,newElement:this.state.newElement,selectedElements:o,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=a,this.hasRenderableElements=l.size>0;let d=this.scene.getNonDeletedElementsMap(),m="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",p=o[0],u=bt.get(sr)?.type==="panel";return Oe("div",{translate:"no",className:IM("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?ta.disabled:ta.enabled,"--right-sidebar-width":`${xx}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Oe(Ys.Provider,{value:this.api,children:Oe(MM.Provider,{value:this,children:Oe(AM.Provider,{value:this.props,children:Oe(AE.Provider,{value:this.excalidrawContainerValue,children:Oe(ME.Provider,{value:this.editorInterface,children:Oe(PE.Provider,{value:this.setAppState,children:Oe(_E.Provider,{value:this.state,children:om(LE.Provider,{value:this.scene.getNonDeletedElements(),children:[om(DE.Provider,{value:this.actionManager,children:[Oe(J5,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Qr().code,renderTopLeftUI:n,renderTopRightUI:r,renderCustomStats:i,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===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),Oe("div",{className:"excalidraw-textEditorContainer"}),Oe("div",{className:"excalidraw-contextMenuContainer"}),Oe("div",{className:"excalidraw-eye-dropper-container"}),Oe(eM,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Oe(TM,{}),this.isDefaultUIEnabled()&&o.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Oe(NC,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.props.aiEnabled!==!1&&o.length===1&&Lm(p)&&Oe(ax,{element:p,elementsMap:l,children:Oe(bg,{title:h("labels.convertToCode"),icon:Ii,checked:!1,onChange:()=>this.onMagicFrameGenerate(p,"button")})}),this.isDefaultUIEnabled()&&o.length===1&&ca(p)&&p.customData?.generationData?.status==="done"&&om(ax,{element:p,elementsMap:l,children:[Oe(bg,{title:h("labels.copySource"),icon:Ca,checked:!1,onChange:()=>this.onIframeSrcCopy(p)}),Oe(bg,{title:"Enter fullscreen",icon:u1,checked:!1,onChange:()=>{let b=this.getHTMLIFrameElement(p);if(b)try{b.requestFullscreen(),this.setState({activeEmbeddable:{element:p,state:"active"},selectedElementIds:{[p.id]:!0},newElement:null,selectionElement:null})}catch(f){console.warn(f),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.isDefaultUIEnabled()&&this.state.contextMenu&&Oe(M3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:b=>{this.setState({contextMenu:null},()=>{this.focusContainer(),b?.()})}}),Oe(CE,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:d,visibleElements:a,canvasNonce:s,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Gi(this),renderLinks:this.isLinksEnabled(),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Oe(xM,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:d,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Oe(TE,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:a,allElementsMap:d,selectedElements:o,canvasNonce:s,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Oe(Hh,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Oe(CM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Oe(VC,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}setPlugins(o){Object.assign(this.plugins,o)}async onMagicFrameGenerate(o,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=Xm(this.scene.getNonDeletedElements(),o,this.scene.getNonDeletedElementsMap()).filter(a=>!Lm(a));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),Ee("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let l=this.insertIframeElement({sceneX:o.x+o.width+30,sceneY:o.y,width:o.width,height:o.height});if(l){this.updateMagicGeneration({frameElement:l,data:{status:"pending"}}),this.setState({selectedElementIds:{[l.id]:!0}}),Ee("ai","generate (start)","d2c");try{let{html:a}=await n({frame:o,children:i,onPartial:c=>{if(this.magicGenerations.get(l.id)?.status!=="pending")return;let d=c.search(/<!doctype html|<html[\s>]/i);d!==-1&&this.getHTMLIFrameElement(l)?.contentWindow?.postMessage({type:"excalidraw:diagramToCode:partial",html:c.slice(d)},"*")}});if(Ee("ai","generate (success)","d2c"),!a.trim()){this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=a.includes("<!DOCTYPE html>")&&a.includes("</html>")?a.slice(a.indexOf("<!DOCTYPE html>"),a.indexOf("</html>")+7):a;this.updateMagicGeneration({frameElement:l,data:{status:"done",html:s}})}catch(a){Ee("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:l,data:{status:"error",code:"ERR_OAI",message:a.message||"Unknown error during generation"}})}}}onIframeSrcCopy(o){o.customData?.generationData?.status==="done"&&(_r(o.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(o){let r=o??this.files;this.scene.getNonDeletedElements().forEach(n=>{si(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),tr.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Wr()||Bt()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},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.onDurableIncrementEmitter.on(n=>{this.history.record(n.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(n=>{this.props.onIncrement?.(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),sm&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),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),ky()&&!mv()&&this.setState({errorMessage:Oe(C3,{})});let r={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",r),this.props.onMount?.(r),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let o of Object.keys(this.api))if((o.startsWith("get")||o==="onStateChange"||o==="onEvent")&&typeof this.api[o]=="function"){let r=this.api[o];this.api[o]=(...n)=>{let i=`ExcalidrawAPI.${o}() called after the editor has been unmounted and may return invalid/empty data. Check \`ExcalidrawAPI.isDestroyed\` before calling get* methods or subscribing to state/event changes.`;if(Wr()||Bt())throw new Error(i);return console.warn(i),r.apply(this.api,n)}}this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new Sf,this.fonts=new kn(this.scene),this.renderer=new Ad(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),tr.destroy(),mr.destroy(),Zv(),clearTimeout(qi),Ge.clearCache(),kt.clearCache(),qi=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(_e(window,"message",this.onWindowMessage,!1),_e(document,"pointerup",this.removePointer,{passive:!1}),_e(document.fonts,"loadingdone",o=>{let r=o.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),_e(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),_e(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,"keydown",this.handleNavigationModeKeyDown,!1),_e(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),_e(document,"gesturestart",this.onGestureStart,!1),_e(document,"gesturechange",this.onGestureChange,!1),_e(document,"gestureend",this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,"wheel",this.preventBrowserZoomWheel,{passive:!1}),_e(this.excalidrawContainerRef.current,"gesturestart",this.disableEvent,!1),_e(this.excalidrawContainerRef.current,"gesturechange",this.disableEvent,!1),_e(this.excalidrawContainerRef.current,"gestureend",this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(_e(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,"keydown",this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(_e(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),_e(document,"copy",this.onCopy,{passive:!1}),_e(document,"keyup",this.onKeyUp,{passive:!0}),_e(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),_e(document,"gesturestart",this.onGestureStart,!1),_e(document,"gesturechange",this.onGestureChange,!1),_e(document,"gestureend",this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(_e(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),_e(document,"paste",this.pasteFromClipboard,{passive:!1}),_e(document,"cut",this.onCut,{passive:!1}),_e(window,"resize",this.onResize,!1),_e(window,"unload",this.onUnload,!1),_e(window,"blur",this.onBlur,!1),_e(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),_e(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),_e(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(_e(By(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(o,r){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(o,r),this.handleForcedToolChange(o,r),this.appStateObserver.flush(r),this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),l=(kM??this.state.theme)===J.DARK;this.state.exportWithDarkMode!==l&&this.setState({exportWithDarkMode:l}),!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.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)),Object.keys(this.state.selectedElementIds).length&&rr(this.state)&&this.setState({activeTool:ft(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&r.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),o.langCode!==this.props.langCode&&this.updateLanguage(),rr(r)&&!rr(this.state)&&this.eraserTrail.endPath(),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),o.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),o.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),!this.props.UIOptions.canvasActions&&this.state.openMenu==="canvas"&&this.setState({openMenu:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===J.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(Gt)});let a=Object.keys(this.state.selectedElementIds);if(a.length){let c=a.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:Be(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let s=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==s&&this.setState({scrolledOutside:s}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files,this.props.id),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){qd=!1,Qd=null}async insertClipboardContent(o,r,n){let{x:i,y:l}=ze({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(o.errorMessage){this.setState({errorMessage:o.errorMessage});return}if(r.length===0&&!n&&o.mixedContent){await this.addElementsFromMixedContentPaste(o.mixedContent,{isPlainPaste:n,sceneX:i,sceneY:l});return}if(!n&&o.text){let d=_h(o.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:o.text}});return}}let a=r.map(d=>d.file);if(a.length===0&&o.text&&!n){let d=o.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&a.push(Kf(d))}if(a.length>0){this.isToolSupported("image")?await this.insertImages(a,i,l):this.setState({errorMessage:h("errors.imageToolNotSupported")});return}if(o.elements){let d=o.programmaticAPI?xl(o.elements):o.elements;this.addElementsFromPasteOrLibrary({elements:d,files:o.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:n,preserveFrameChildrenOrder:!0});return}if(!o.text)return;if(!n&&WS(o.text)){let d=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:m,files:p={}}=await d.parseMermaidToExcalidraw(o.text),u=xl(m,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:this.editorInterface.formFactor==="desktop"?"cursor":"center"});return}catch(m){console.warn(`parsing pasted text as mermaid definition failed: ${m.message}`)}}let s=Xy(o.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=s.map(d=>Tw(d)).filter(d=>fl(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||fa(d)?.type==="video"));if(!n&&c.length>0&&c.length===s.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:l,link:Sr(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(o.text,n)}async addElementsFromMixedContentPaste(o,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&o.some(l=>l.type==="imageUrl")&&this.isToolSupported("image")){let l=o.filter(d=>d.type==="imageUrl").map(d=>d.value),a=await Promise.all(l.map(async d=>{try{return{file:await m2(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=h("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=h("errors.unsupportedFileType")),{errorMessage:p}}})),s=a.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(s,n,i);let c=a.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let l=o.filter(a=>a.type==="text");l.length&&this.addTextFromPaste(l.map(a=>a.value).join(`
|
|
131
107
|
|
|
132
|
-
`),r)}}addTextFromPaste(
|
|
133
|
-
`),f=b.reduce((E,v,x)=>{let y=fs(v).trim();if(y.length){let w=this.getTopLayerFrameAtSceneCoords({x:n,y:h}),C=Kt(y,l,s),S=C.width>p,A=S?Ii(y,l,p):y;C=S?Kt(A,l,s):C;let M=n-C.width/2,N=h-C.height/2,R=Cr({...i,x:M,y:N,text:A,originalText:y,lineHeight:s,autoResize:!S,frameId:w?w.id:null});E.push(R),h+=R.height+d}else b[x-1]?.trim()&&(h+=Yx(i.fontSize,s)+d);return E},[]);f.length!==0&&(this.scene.insertElements(f),this.store.scheduleCapture(),this.setState({selectedElementIds:Oe(Object.fromEntries(f.map(E=>[E.id,!0])),this.state)}),!r&&f.length>1&&CC===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:u("toast.pasteAsSingleElement",{shortcut:B("CtrlOrCmd+Shift+V")}),duration:5e3}),CC=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),a=(i,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&$(s)?re(s,{originalText:i,isDeleted:l??s.isDeleted,...Ry(s,Do(s,n),n,i)}):s)])};T3({id:t.id,canvas:this.canvas,getViewportCoords:(i,l)=>{let{x:s,y:c}=kt({sceneX:i,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:ct(i=>{a(i,!1),Gh(t)&&on(t,this.scene)}),onSubmit:ct(({viaKeyboard:i,nextOriginalText:l})=>{let s=!l.trim();if(a(l,s),!s&&i){let c=t.containerId?t.containerId:t.id;Jo(()=>{this.setState(m=>({selectedElementIds:Oe({...m.selectedElementIds,[c]:!0},m)}))})}s&&Gd(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),Jo(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Uo(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Oe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&$(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let a=[];if(n&&"allHitElements"in n?a=n?.allHitElements||[]:a=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),a.length>1){if(n?.preferSelected){for(let l=a.length-1;l>-1;l--)if(this.state.selectedElementIds[a[l].id])return a[l]}let i=a[a.length-1];return Si({point:L(t,r),element:i,threshold:this.getElementHitThreshold(i)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:le(i)?this.frameNameBoundsCache.get(i):null})?i:a[a.length-2]}return a.length===1?a[0]:null}getElementsAtPosition(t,r,n){let a=[],i=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!($(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let c=ka(s,i);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Ch({x:t,y:r},c,i):!0}).filter(s=>Ta(s)?(a.push(s),!1):!0).concat(a)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(ju/this.state.zoom.value))}hitElement(t,r,n,a=!0){return a&&this.state.selectedElementIds[n.id]&&am([n],this.state,this.editorInterface)&&zd(L(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||Jx(L(t,r),n,this.scene.getNonDeletedElementsMap())?!0:Si({point:L(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:le(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),a=this.scene.getSelectedElements(this.state);if(a.length===1)return en(a[0],!1)?a[0]:null;let i=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,c,m,p]=At(n[l],this.scene.getNonDeletedElementsMap());if(Me(n[l])&&Si({point:L(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){i=n[l];break}else if(s<t&&t<m&&c<r&&r<p){i=n[l];break}}return en(i,!1)?i:null}handleHoverSelectedLinearElement(t,r,n){let a=this.scene.getNonDeletedElementsMap(),i=X.getElement(t.elementId,a);if(i)if(this.state.selectedLinearElement){let l=-1,s=null;Si({point:L(r,n),element:i,elementsMap:a,threshold:this.getElementHitThreshold(i)})?(l=X.getPointIndexUnderCursor(i,a,this.state.zoom,r,n),s=X.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(Se(i)?l===0||l===i.points.length-1:l>=0)||s?He(this.interactiveCanvas,Pe.POINTER):this.hitElement(r,n,i)&&(!Se(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&He(this.interactiveCanvas,Pe.MOVE)):this.hitElement(r,n,i)&&(!Se(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&He(this.interactiveCanvas,Pe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),X.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else He(this.interactiveCanvas,Pe.AUTO)}updateGestureOnPointerDown(t){De.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),De.pointers.size===2&&(De.lastCenter=rb(De.pointers),De.initialScale=this.state.zoom.value,De.initialDistance=nb(Array.from(De.pointers.values())))}initialPointerDownState(t){let r=Ye(t,this.state),n=this.scene.getSelectedElements(this.state),[a,i,l,s]=_e(n),c=n.findIndex(Se)===0;return{origin:r,withCmdOrCtrl:t[T.CTRL_OR_CMD],originInGrid:wd(Ft(r.x,r.y,t[T.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:sb($c,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,p)=>(m.set(p.id,ar(p)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+a)/2,y:(s+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;l0=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=nu(i=>{i.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(i,r)}),a=ct(()=>{Jc=null,l0=!1,Uo(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",a),n.flush()});return Jc=a,window.addEventListener("pointermove",n),window.addEventListener("pointerup",a),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(ju/this.state.zoom.value,1),[a,i,l,s]=_e(r);return t.x>a-n&&t.x<l+n&&t.y>i-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:_n(t)?Lt.ADAPTIVE_RADIUS:Lt.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){fn({event:t,app:this,selectedElements:r})&&(n||!Yo.getReferenceSnapPoints())&&Yo.setReferenceSnapPoints(b3(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){fn({event:t,app:this,selectedElements:r})&&(n||!Yo.getVisibleGaps())&&Yo.setVisibleGaps(f3(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return ct(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return ct(r=>{r.key===T.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return nu(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Ye(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[d,h]=Ft(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),b=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(b<0){let E=X.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:d,y:h},this.state,this.scene.getNonDeletedElementsMap());b=E?X.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,E,this.scene.getNonDeletedElementsMap()):-1}let f=X.moveFixedSegment(this.state.selectedLinearElement,b,d,h,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:f.segmentMidPointHoveredCoords,initialState:f.initialState}});return}let a=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=wd(_y(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(po(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=Ft(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement;if(X.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let h=X.addMidpoint(this.state.selectedLinearElement,n,this,!r[T.CTRL_OR_CMD],this.scene);if(!h)return;Jo(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else{if(d.initialState.segmentMidpoint.value!==null&&!d.initialState.segmentMidpoint.added)return;if(d.initialState.lastClickedPoint>-1){let h=X.getElement(d.elementId,c);if(h?.isDeleted)return;if(co(h)){let f=Ro(L(n.x,n.y),this.scene.getNonDeletedElements(),c);_o("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(h,f)}if(r.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&_o("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),d.initialState.lastClickedPoint===-1)return;let b=X.handlePointDragging(r,this,n.x,n.y,d);if(b){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,(b.suggestedBinding!==this.state.suggestedBinding||!at(b.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||b.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||b.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==b.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==b.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(b);return}}}}let m=t.hit.allHitElements.some(d=>this.isASelectedElement(d)),p=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let d=this.scene.getSelectedElements(this.state);if(d.length>0&&d.every(E=>E.locked))return;let h=d.find(E=>le(E)),b=this.getTopLayerFrameAtSceneCoords(n),f=b&&!h?b:null;if(this.state.frameToHighlight!==f&&Jo(()=>{this.setState({frameToHighlight:f})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&d.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),d.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let E={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},v=[...t.originalElements.values()],x=r.shiftKey;if(x){let C=Math.abs(E.x),S=Math.abs(E.y),A=x&&C<S,M=x&&C>S;A&&(E.x=0),M&&(E.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&Ue(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,A=An(C)&&this.imageCache.get(C.fileId)?.image;if(A&&!(A instanceof Promise)){let M=A0(Gu(n.x-a.x,n.y-a.y),Math.max(this.state.zoom.value,2)),[N,R,P,O,Y,Q]=At(C,c),q=od(Ge(L(N,R),L(Y,Q),C.angle)),Z=od(Ge(L(P,R),L(Y,Q),C.angle)),z=od(Ge(L(N,O),L(Y,Q),C.angle)),U=Vu(Yu(Z,q)),ee=Vu(Yu(z,q)),Ie=Gu(Wu(M,U),Wu(M,ee)),V={...S,x:$e(S.x+Ie[0]*Math.sign(C.scale[0]),0,A.naturalWidth-S.width),y:$e(S.y+Ie[1]*Math.sign(C.scale[1]),0,A.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:V});return}}}this.maybeCacheVisibleGaps(r,d),this.maybeCacheReferenceSnapPoints(r,d);let{snapOffset:y,snapLines:w}=x3(v,E,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:w}),this.state.editingFrame||Ay(t,d,E,this.scene,y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,A=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!A.find(Z=>Z.id===S.id)&&A.push(S);let M=new Map(A.map(Z=>[Z.id,Z])),{duplicatedElements:N,duplicateElementsMap:R,elementsWithDuplicates:P,origIdToDuplicateId:O}=nn({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:M,overrides:({duplicateElement:Z,origElement:z})=>({frameId:Z.frameId??z.frameId,seed:va()})});N.forEach(Z=>{t.originalElements.set(Z.id,ar(Z))});let Y=P.map(Z=>{if(M.has(Z.id)){let z=t.originalElements.get(Z.id);if(z)return re(Z,{x:z.x,y:z.y})}return Z}),Q=this.props.onDuplicate?.(Y,C),q=wr(Q||Y,ie(N));Jo(()=>{if(t.hit.element){let Z=O.get(t.hit.element.id),z=Z&&R.get(Z);t.hit.element=z||null}t.hit.allHitElements=t.hit.allHitElements.reduce((Z,z)=>{let U=O.get(z.id),ee=U&&R.get(U);return ee&&Z.push(ee),Z},[]),t.drag.origin=Ye(r,this.state),this.setState(Z=>({...Kd(N,this.scene.getNonDeletedElements(),Z)})),this.scene.replaceAllElements(q),A.forEach(Z=>{Dd(Z)&&Z.boundElements?.some(z=>z.type==="arrow")&&on(Z,this.scene)}),this.maybeCacheVisibleGaps(r,A,!0),this.maybeCacheReferenceSnapPoints(r,A,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let d=this.state.newElement;if(!d)return;if(d.type==="freedraw"){let h=d.points,b=n.x-d.x,f=n.y-d.y,E=h.length>0&&h[h.length-1];if(!(E&&E[0]===b&&E[1]===f)){let x=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];this.scene.mutateElement(d,{points:[...h,L(b,f)],pressures:x},{informMutation:!1,isDragging:!1}),this.setState({newElement:d})}}else if(ge(d)&&!d.isDeleted){t.drag.hasOccurred=!0;let h=d.points;je(h.length>1,"Do not create linear elements with less than 2 points");let b=this.state.selectedLinearElement;b||(b=new X(d,this.scene.getNonDeletedElementsMap()),b={...b,selectedPointsIndices:[1],initialState:{...b.initialState,lastClickedPoint:1}}),this.setState({newElement:d,...X.handlePointDragging(r,this,l,s,b)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let d=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)X.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let h=!0;!r.shiftKey&&Be(d,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(f=>bt({...f,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),f,this)):h=!1);let b=this.state.selectionElement?iy(d,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(f=>{let E={...h&&f.selectedElementIds,...b.reduce((v,x)=>(v[x.id]=!0,v),{})};return t.hit.element&&(b.length?delete E[t.hit.element.id]:E[t.hit.element.id]=!0),f=h?f:{...f,selectedGroupIds:{},editingGroupId:null},{...bt({editingGroupId:f.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),f,this),selectedLinearElement:b.length===1&&ge(b[0])?new X(b[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:b.length===1&&(b[0].link||Vt(b[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,a=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-a*($c.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,a=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-a*($c.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return ct(r=>{let n=this.scene.getNonDeletedElementsMap();this.removePointer(r),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:a,resizingElement:i,croppingElementId:l,multiElement:s,activeTool:c,isResizing:m,isRotating:p,isCropping:d}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:wi(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),Yo.setReferenceSnapPoints(null),Yo.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let h=t.hit.allHitElements,b=Ye({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!h.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(b.x,b.y,{includeLockedElements:!0});this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(_o("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=n.get(t.hit.element.id);Dd(x)&&x.boundElements?.filter(y=>y.type==="arrow").map(y=>n.get(y.id)).filter(y=>Se(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction($t);else{let x=X.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction($t,"ui",{event:r,sceneCoords:b}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=X.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction($t,"ui",{event:r,sceneCoords:b}),this.state.newElement&&this.state.multiElement&&ge(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),a?.type==="freedraw"){let x=Ye(r,this.state),y=a.points,w=x.x-a.x,C=x.y-a.y;w===y[0][0]&&C===y[0][1]&&(C+=1e-4,w+=1e-4);let S=a.simulatePressure?[]:[...a.pressures,r.pressure];this.scene.mutateElement(a,{points:[...y,L(w,C)],pressures:S}),this.actionManager.executeAction($t);return}if(ge(a)){a.points.length>1&&a.points[1][0]!==0&&a.points[1][1]!==0&&this.store.scheduleCapture();let x=Ye(r,this.state),y=wn(L(x.x,x.y),L(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<R0)&&a&&!s)if(this.editorInterface.isTouchScreen){let w=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(a,{x:a.x-w/2,points:[L(0,0),L(w,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction($t)}else{let w=x.x-a.x,C=x.y-a.y;this.scene.mutateElement(a,{points:[a.points[0],L(w,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:a,newElement:a})}else t.drag.hasOccurred&&!s&&(ge(a)&&this.actionManager.executeAction($t,"ui",{event:r,sceneCoords:b}),this.setState({suggestedBinding:null,startBoundElement:null}),c.locked?this.setState(w=>({newElement:null})):(Co(this.interactiveCanvas),this.setState(w=>({newElement:null,activeTool:Ne(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Oe({...w.selectedElementIds,[a.id]:!0},w),selectedLinearElement:new X(a,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if($(a)){let x=Gx(yt({fontSize:a.fontSize,fontFamily:a.fontFamily}),a.lineHeight);a.width<x&&this.scene.mutateElement(a,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(a,{isExistingElement:!0})}if(c.type!=="selection"&&a&&vr(a)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),appState:{newElement:null},captureUpdate:D.NEVER});return}if(le(a)){let x=my(this.scene.getElementsIncludingDeleted(),a,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Pi(this.scene.getElementsMapIncludingDeleted(),x,a,this.state))}if(a&&(this.scene.mutateElement(a,Ty(a),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ye(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let w=ka(y,n);w&&y&&(ly(y,w,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),Zd([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(x),w=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=A=>{if(A.length>0){for(let M of A){let N=M.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(M,{groupIds:M.groupIds.slice(0,N)},{informMutation:!1,isDragging:!1})}C.forEach(M=>{M.groupIds.length&&Ke(C,M.groupIds[M.groupIds.length-1]).length<2&&this.scene.mutateElement(M,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let A=w.filter(M=>M.frameId!==y.id&&Ih(M,C,this.state));this.state.editingGroupId&&S(A),C=Pi(C,A,y,this.state)}else if(!y&&this.state.editingGroupId){let A=w.filter(M=>M.frameId&&!Ih(M,C,this.state));S(A)}C=xr(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&vr(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),captureUpdate:D.NEVER}),t.resize.isResizing){let x=xr(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(w=>le(w));for(let w of y)x=br(x,mo(this.scene.getElementsIncludingDeleted(),w,this.state,n),w,this);this.scene.replaceAllElements(x)}let f=t.hit.element;this.state.selectedLinearElement?.elementId!==f?.id&&ge(f)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new X(f,this.scene.getNonDeletedElementsMap())}),(!l||l&&(!f&&!d||f&&f.id!==l))&&this.finishImageCropping();let E=this.lastPointerDownEvent,v=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(po(this.state)&&E&&v){if(this.eraserTrail.endPath(),wn(L(E.clientX,E.clientY),L(v.clientX,v.clientY))===0){let y=Ye({clientX:v.clientX,clientY:v.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(f&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[f.id]?Wd(this.state,f)?this.setState(x=>{let y={...x.selectedElementIds};for(let w of f.groupIds.flatMap(C=>Ke(this.scene.getNonDeletedElements(),C)))delete y[w.id];return{selectedGroupIds:{...x.selectedElementIds,...f.groupIds.map(w=>({[w]:!1})).reduce((w,C)=>({...w,...C}),{})},selectedElementIds:Oe(y,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let y={...x.selectedElementIds};delete y[f.id];let w=ae(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...bt({editingGroupId:x.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&ge(w[0])?new X(w[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):f.frameId&&this.state.selectedElementIds[f.frameId]?this.setState(x=>{let y={...x.selectedElementIds,[f.id]:!0};return delete y[f.frameId],(this.scene.getElement(f.frameId)?.groupIds??[]).flatMap(w=>Ke(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete y[w.id]}),{...bt({editingGroupId:x.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:f.link||Vt(f)?"info":!1}}):this.setState(x=>({selectedElementIds:Oe({...x.selectedElementIds,[f.id]:!0},x)})):this.setState(x=>({...bt({editingGroupId:x.editingGroupId,selectedElementIds:{[f.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:ge(f)&&x.selectedLinearElement?.elementId!==f.id?new X(f,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(f&&Se(f))&&!t.drag.hasOccurred&&!this.state.isResizing&&(f&&qx({point:L(t.origin.x,t.origin.y),element:f,elementsMap:n,threshold:this.getElementHitThreshold(f),frameNameBound:le(f)?this.frameNameBoundsCache.get(f):null},n)||!f&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(ai):this.setState({selectedElementIds:Oe({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),He(this.interactiveCanvas,Pe.AUTO);return}if(!c.locked&&c.type!=="freedraw"&&a&&this.setState(x=>({selectedElementIds:Oe({...x.selectedElementIds,[a.id]:!0},x),showHyperlinkPopup:Vt(a)&&!a.link?"editor":x.showHyperlinkPopup})),(c.type!=="selection"||Be(this.scene.getNonDeletedElements(),this.state)||!at(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||p||d){let x=this.scene.getSelectedElements(this.state).filter(Me);ys(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}!c.locked&&c.type!=="freedraw"&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?(Co(this.interactiveCanvas),this.setState({newElement:null,suggestedBinding:null,activeTool:Ne(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBinding:null}),f&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&De.pointers.size<=1&&Ti(f)&&this.isIframeLikeElementCenter(f,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(f)})}clearSelection(t){this.setState(r=>({selectedElementIds:Oe({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ai(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Oe({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,r,n,a){if(a){let i=a.x+a.width/2,l=a.y+a.height/2,s=Nd(a,n,this.scene.getNonDeletedElementsMap());if(s&&(i=s.x,l=s.y),Math.hypot(t-i,r-l)<O0){let{x:p,y:d}=kt({sceneX:i,sceneY:l},n);return{viewportX:p,viewportY:d,elementCenterX:i,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Zi.find(r=>r.code===this.props.langCode)||Mr;await bm(t),this.setAppState({})}},E7=()=>{(Qr()||Ht())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Oi(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};E7();var SC=m0;import{useEffect as w7,useState as T7}from"react";import{jsx as C7}from"react/jsx-runtime";var MC=e=>{let[o,t]=T7(!0);return w7(()=>{let r=async()=>{await bm(n),t(!1)},n=Zi.find(a=>a.code===e.langCode)||Mr;r()},[e.langCode]),o?C7(lu,{theme:e.theme}):e.children};import I7 from"clsx";import{jsx as LC}from"react/jsx-runtime";var AC=({children:e})=>{let{FooterCenterTunnel:o}=Xe(),t=Le();return LC(o.In,{children:LC("div",{className:I7("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},k7=AC;AC.displayName="FooterCenter";import M7 from"clsx";import{jsx as A7,jsxs as _7}from"react/jsx-runtime";var _C=({isCollaborating:e,onSelect:o,editorInterface:t,...r})=>{let n=Le(),a=t?.formFactor!=="desktop"||n.width<1440;return _7(ro,{...r,className:M7("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:a?void 0:"auto"},title:u("labels.liveCollaboration"),children:[a?Eg:u("labels.share"),n.collaborators.size>0&&A7("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},L7=_C;_C.displayName="LiveCollaborationTrigger";import{jsx as ma,jsxs as DC}from"react/jsx-runtime";var P7=()=>ma("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:ma("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"})}),D7=()=>DC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[ma("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)"}),ma("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)"}),ma("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)"}),ma("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)"})]}),PC=({style:e,size:o="small",withText:t})=>DC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[ma(P7,{}),t&&ma(D7,{})]});import{Fragment as OC,jsx as Ct,jsxs as x0}from"react/jsx-runtime";var y0=({icon:e,shortcut:o,children:t})=>{let r=Te();return x0(OC,{children:[Ct("div",{className:"welcome-screen-menu-item__icon",children:e}),Ct("div",{className:"welcome-screen-menu-item__text",children:t}),o&&r.formFactor!=="phone"&&Ct("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};y0.displayName="WelcomeScreenMenuItemContent";var Qc=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...a})=>Ct("button",{...a,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ct(y0,{icon:t,shortcut:r,children:o})});Qc.displayName="WelcomeScreenMenuItem";var RC=({children:e,href:o,icon:t,shortcut:r,className:n="",...a})=>Ct("a",{...a,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:Ct(y0,{icon:t,shortcut:r,children:e})});RC.displayName="WelcomeScreenMenuItemLink";var Qo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Xe();return Ct(o.In,{children:Ct("div",{className:"welcome-screen-center",children:e||x0(OC,{children:[Ct(E0,{}),Ct(v0,{children:u("welcomeScreen.defaults.center_heading")}),x0(w0,{children:[Ct(C0,{}),Ct(T0,{})]})]})})})};Qo.displayName="Center";var E0=({children:e})=>Ct("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ct(PC,{withText:!0})});E0.displayName="Logo";var v0=({children:e})=>Ct("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});v0.displayName="Heading";var w0=({children:e})=>Ct("div",{className:"welcome-screen-menu",children:e});w0.displayName="Menu";var T0=()=>{let e=vt();return Ct(Qc,{onSelect:()=>e.executeAction(qn),shortcut:"?",icon:Ha,children:u("helpDialog.title")})};T0.displayName="MenuItemHelp";var C0=()=>{let e=Le(),o=vt();return e.viewModeEnabled?null:Ct(Qc,{onSelect:()=>o.executeAction(Ja),shortcut:ht("loadScene"),icon:Ua,children:u("buttons.load")})};C0.displayName="MenuItemLoadScene";var NC=({onSelect:e})=>{let{t:o}=dt();return Ct(Qc,{shortcut:null,onSelect:e,icon:Bs,children:o("labels.liveCollaboration")})};NC.displayName="MenuItemLiveCollaborationTrigger";Qo.Logo=E0;Qo.Heading=v0;Qo.Menu=w0;Qo.MenuItem=Qc;Qo.MenuItemLink=RC;Qo.MenuItemHelp=T0;Qo.MenuItemLoadScene=C0;Qo.MenuItemLiveCollaborationTrigger=NC;import{jsx as ql,jsxs as I0}from"react/jsx-runtime";var Ou=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Xe();return ql(o.In,{children:I0("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[rg,ql("div",{className:"welcome-screen-decor-hint__label",children:e||u("welcomeScreen.defaults.menuHint")})]})})};Ou.displayName="MenuHint";var zu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Xe();return ql(o.In,{children:I0("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ql("div",{className:"welcome-screen-decor-hint__label",children:e||u("welcomeScreen.defaults.toolbarHint")}),ag]})})};zu.displayName="ToolbarHint";var Bu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Xe();return ql(o.In,{children:I0("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ql("div",{children:e||u("welcomeScreen.defaults.helpHint")}),ng]})})};Bu.displayName="HelpHint";import{Fragment as zC,jsx as ed,jsxs as N7}from"react/jsx-runtime";var Fu=e=>ed(zC,{children:e.children||N7(zC,{children:[ed(Qo,{}),ed(Ou,{}),ed(zu,{}),ed(Bu,{})]})});Fu.displayName="WelcomeScreen";Fu.Center=Qo;Fu.Hints={MenuHint:Ou,ToolbarHint:zu,HelpHint:Bu};var R7=Fu;var O7=()=>{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)})},BC=O7;import z7 from"lodash.throttle";var B7=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<=t.versionNonce)),F7=z7((e,o,t)=>{if(Ht()||Qr()||window?.DEBUG_FRACTIONAL_INDICES){let r=Oi(e.map(n=>({...n})));My(r,{shouldThrow:Qr()||Ht(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),H7=(e,o,t)=>{let r=ie(e),n=[],a=new Set;for(let l of o)if(!a.has(l.id)){let s=r.get(l.id),c=B7(t,s,l);s&&c?(n.push(s),a.add(s.id)):(n.push(l),a.add(l.id))}for(let l of e)a.has(l.id)||(n.push(l),a.add(l.id));let i=Qd(n);return F7(i,e,o),Oi(i),i};import{jsx as FC,jsxs as U7}from"react/jsx-runtime";var HC=({children:e,icon:o})=>{let{t}=dt(),{TTDDialogTriggerTunnel:r}=Xe(),n=ye();return FC(r.In,{children:U7(de.Item,{onSelect:()=>{pe("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??ff,children:[e??t("labels.textToDiagram"),FC(de.Item.Badge,{children:"AI"})]})})};HC.displayName="TTDDialogTrigger";function G7(e){let o=e.get("X-Ratelimit-Limit"),t=e.get("X-Ratelimit-Remaining");return{rateLimit:o?parseInt(o,10):void 0,rateLimitRemaining:t?parseInt(t,10):void 0}}async function*W7(e){let o=new TextDecoder,t="";try{for(;;){let{done:r,value:n}=await e.read();if(r)break;t+=o.decode(n,{stream:!0});let a=t.split(`
|
|
134
|
-
`);
|
|
108
|
+
`),r)}}addTextFromPaste(o,r=!1){let{x:n,y:i}=ze({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:o,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:dm,verticalAlign:Wg,locked:!1},a=dt({fontSize:l.fontSize,fontFamily:l.fontFamily}),s=ho(l.fontFamily),[c,,d]=wf(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,b=r?[o]:o.split(`
|
|
109
|
+
`),f=b.reduce((x,v,y)=>{let E=cc(v).trim();if(E.length){let w=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),T=lt(E,a,s),S=T.width>m,A=S?wn(E,a,m):E;T=S?lt(A,a,s):T;let M=n-T.width/2,O=u-T.height/2,P=eo({...l,x:M,y:O,text:A,originalText:E,lineHeight:s,autoResize:!S,frameId:w?w.id:null});x.push(P),u+=P.height+p}else b[y-1]?.trim()&&(u+=dc(l.fontSize,s)+p);return x},[]);f.length!==0&&(this.insertNewElements(f),this.store.scheduleCapture(),this.setState({selectedElementIds:Be(Object.fromEntries(f.map(x=>[x.id,!0])),this.state)}),!r&&f.length>1&&SM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:h("toast.pasteAsSingleElement",{shortcut:H("CtrlOrCmd+Shift+V")}),duration:5e3}),SM=!0))}handleTextWysiwyg(o,{isExistingElement:r=!1,initialCaretSceneCoords:n=null}){let i=this.scene.getElementsMapIncludingDeleted(),l=(a,s)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===o.id&&ee(c)?se(c,{originalText:a,isDeleted:s??c.isDeleted,...iw(c,Vr(c,i),i,a)}):c)])};this.textWysiwygSubmitHandler=HS({canvas:this.canvas,getViewportCoords:(a,s)=>{let{x:c,y:d}=Ft({sceneX:a,sceneY:s},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Tt(a=>{l(a,!1),or(o)&&ko(o,this.scene)}),onSubmit:Tt(({viaKeyboard:a,nextOriginalText:s})=>{this.textWysiwygSubmitHandler=null;let c=!s.trim();l(s,c);let d=a&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?o.containerId||(c?null:o.id):null;d&&Bo(()=>{this.setState(m=>({selectedElementIds:Be({...m.selectedElementIds,[d]:!0},m)}))}),c&&zm(this.scene.getNonDeletedElements(),[o]),(!c||r)&&this.store.scheduleCapture(),Bo(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:o,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:n,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),l(o.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Be({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1)return null;let n=r[0];return ee(n)?n:o?ve(n,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(o,r){let n=this.scene.getSelectedElements(this.state);if(n.length!==1||!o||o.id!==n[0].id)return null;let i=n[0];if(ee(i))return null;if(!mf(i))return;let l=this.getSelectedTextElement(i),a=this.getTextElementAtPosition(r.x,r.y);if(!(!l||a?.id!==l.id))return i}getTextElementAtPosition(o,r){let n=this.getElementAtPosition(o,r,{includeBoundTextElement:!0});return n&&ee(n)&&!n.isDeleted?n:null}getElementAtPosition(o,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(o,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let a=i.length-1;a>-1;a--)if(this.state.selectedElementIds[i[a].id])return i[a]}let l=i[i.length-1];return pi({point:_(o,r),element:l,threshold:this.getElementHitThreshold(l)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:re(l)?this.frameNameBoundsCache.get(l):null})?l:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(o,r,n){let i=[],l=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(ee(s)&&s.containerId)))).filter(s=>this.hitElement(o,r,s)).filter(s=>{let c=Cn(s,l);return c&&!or(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!al(s)?Ef({x:o,y:r},c,l):!0}).filter(s=>al(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(o){return Math.max(o.strokeWidth/2+.1,.85*(Vg/this.state.zoom.value))}hitElement(o,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&np([n],this.state,this.editorInterface)&&Fm(_(o,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||Sv(_(o,r),n,this.scene.getNonDeletedElementsMap())?!0:pi({point:_(o,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:re(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(o,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return vn(i[0],!1)?i[0]:null;let l=null;for(let a=n.length-1;a>=0;--a){if(n[a].isDeleted)continue;let[s,c,d,m]=Yt(n[a],this.scene.getNonDeletedElementsMap());if(Te(n[a])&&pi({point:_(o,r),element:n[a],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[a])})){l=n[a];break}else if(s<o&&o<d&&c<r&&r<m){if(re(n[a]))continue;l=n[a];break}}return vn(l,!1)?l:null}isEditingTextContent(){return!!this.state.editingTextElement||ee(this.state.newElement)}handleHoverSelectedLinearElement(o,r,n){let i=this.scene.getNonDeletedElementsMap(),l=Z.getElement(o.elementId,i);if(l)if(this.state.selectedLinearElement){let a=-1,s=null;pi({point:_(r,n),element:l,elementsMap:i,threshold:this.getElementHitThreshold(l)})?(a=Z.getPointIndexUnderCursor(l,i,this.state.zoom,r,n),s=Z.getSegmentMidpointHitCoords(o,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(Re(l)?a===0||a===l.points.length-1:a>=0)||s?this.cursor.set(Fe.POINTER):this.hitElement(r,n,l)&&(!Re(l)||!(l.startBinding||l.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Fe.MOVE)):this.hitElement(r,n,l)&&(!Re(l)||!(l.startBinding||l.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Fe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),Z.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}});let c=null,d=l;(d.startBinding||d.endBinding)&&(c=Nw(l,r,n,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Fe.POINTER)}else this.cursor.set(Fe.AUTO)}updateGestureOnPointerDown(o){Le.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY}),Le.pointers.size===2&&(Le.lastCenter=ox(Le.pointers),Le.initialScale=this.state.zoom.value,Le.initialDistance=rx(Array.from(Le.pointers.values())))}initialPointerDownState(o){let r=ze(o,this.state),n=this.scene.getSelectedElements(this.state),[i,l,a,s]=we(n),c=n.findIndex(Re)===0;return{origin:r,withCmdOrCtrl:o[I.CTRL_OR_CMD],originInGrid:wm(Qt(r.x,r.y,o[I.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:dx(em,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,Mr(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+i)/2,y:(s+l)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(o,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;vg=!0,r.lastCoords.x=o.clientX,r.lastCoords.y=o.clientY;let n=yh(l=>{l.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(l,r)}),i=Tt(()=>{Vs=null,vg=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",i),n.flush()});return Vs=i,window.addEventListener("pointermove",n),window.addEventListener("pointerup",i),!0}isASelectedElement(o){return o!=null&&this.state.selectedElementIds[o.id]}isHittingCommonBoundingBoxOfSelectedElements(o,r){if(r.length<2)return!1;let n=Math.max(Vg/this.state.zoom.value,1),i=oa*2/this.state.zoom.value,[l,a,s,c]=we(r);return o.x>l-i-n&&o.x<s+i+n&&o.y>a-i-n&&o.y<c+i+n}getCurrentItemRoundness(o){return this.state.currentItemRoundness==="round"?{type:ci(o)?At.ADAPTIVE_RADIUS:At.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(o){return Gr(o,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(o,r,n=!1){Gn({event:o,app:this,selectedElements:r})&&(n||!mr.getReferenceSnapPoints())&&mr.setReferenceSnapPoints(DS(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(o,r,n=!1){Gn({event:o,app:this,selectedElements:r})&&(n||!mr.getVisibleGaps())&&mr.setVisibleGaps(PS(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(o){return Tt(r=>{this.maybeHandleResize(o,r)||this.maybeDragNewGenericElement(o,r)})}onKeyUpFromPointerDownHandler(o){return Tt(r=>{r.key===I.ALT&&r.preventDefault(),!this.maybeHandleResize(o,r)&&this.maybeDragNewGenericElement(o,r)})}onPointerMoveFromPointerDownHandler(o){return yh(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=ze(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Qt(n.x,n.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),b=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(b<0){let x=Z.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());b=x?Z.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let f=Z.moveFixedSegment(this.state.selectedLinearElement,b,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:f.segmentMidPointHoveredCoords,initialState:f.initialState}});return}let i=this.previousPointerMoveCoords??o.origin;if(this.previousPointerMoveCoords=n,o.drag.offset===null&&(o.drag.offset=wm(yw(this.scene.getSelectedElements(this.state),o.origin.x,o.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,o))return;if(rr(this.state)){this.handleEraser(r,n);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y),this.drawShape.handlePointerMove(n))return;let[a,s]=Qt(n.x,n.y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(o.resize.isResizing&&(o.lastCoords.x=n.x,o.lastCoords.y=n.y,this.maybeHandleCrop(o,r)||this.maybeHandleResize(o,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){Pw(p,c,n,this.scene,this.state,this.getEffectiveGridSize(),r.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(Z.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let u=Z.addMidpoint(this.state.selectedLinearElement,n,this,!r[I.CTRL_OR_CMD],this.scene);if(!u)return;Bo(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=Z.getElement(p.elementId,c);if(u?.isDeleted)return;if(zt(u)){let f=Qo(_(n.x,n.y),this.scene.getNonDeletedElements(),c);qo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,f)}if(r.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&qo("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let b=Z.handlePointDragging(r,this,n.x,n.y,p);if(b){o.lastCoords.x=n.x,o.lastCoords.y=n.y,o.drag.hasOccurred=!0,(b.suggestedBinding!==this.state.suggestedBinding||!Lt(b.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||b.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||b.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==b.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==b.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(b);return}}}}let d=o.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===o.hit.element?.id;if((d||o.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!o.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(f=>f.locked))return;let b=p.some(f=>re(f))?null:this.getTopLayerFrameAtSceneCoords(n,{currentFrameId:Tc(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(b),o.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&o.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&o.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!o.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let f={x:n.x-o.drag.origin.x,y:n.y-o.drag.origin.y},x=[...o.originalElements.values()],v=r.shiftKey;if(v){let w=Math.abs(f.x),T=Math.abs(f.y),S=v&&w<T,A=v&&w>T;S&&(f.x=0),A&&(f.y=0)}if(this.state.croppingElementId){let w=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(w&&ot(w)&&w.crop!==null&&o.hit.element===w){let T=w.crop,S=si(w)&&this.imageCache.get(w.fileId)?.image;if(S&&!(S instanceof Promise)){let A=yn(w),M=Ng(n.x-i.x,n.y-i.y);M[0]*=S.naturalWidth/A.width,M[1]*=S.naturalHeight/A.height;let[O,P,L,D,U,K]=Yt(w,c),F=am(ke(_(O,P),_(U,K),w.angle)),$=am(ke(_(L,P),_(U,K),w.angle)),W=am(ke(_(O,D),_(U,K),w.angle)),q=Bg(Fg($,F)),oe=Bg(Fg(W,F)),B=Ng(Og(M,q),Og(M,oe)),V={...T,x:qe(T.x-B[0]*Math.sign(w.scale[0]),0,S.naturalWidth-T.width),y:qe(T.y-B[1]*Math.sign(w.scale[1]),0,S.naturalHeight-T.height)};this.scene.mutateElement(w,{crop:V});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:E}=RS(x,f,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:E}),this.state.editingFrame||Ew(o,p,f,this.scene,y,r[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),r.altKey&&!o.hit.hasBeenDuplicated){o.hit.hasBeenDuplicated=!0;let w=this.scene.getElementsIncludingDeleted(),T=o.hit.element,S=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&o.hit.wasAddedToSelection&&!S.find(F=>F.id===T.id)&&S.push(T);let A=new Map(S.map(F=>[F.id,F])),{duplicatedElements:M,duplicateElementsMap:O,elementsWithDuplicates:P,origIdToDuplicateId:L}=Sn({type:"in-place",elements:w,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:A,overrides:({duplicateElement:F,origElement:$})=>({frameId:F.frameId??$.frameId,seed:En()})});M.forEach(F=>{o.originalElements.set(F.id,Mr(F))});let D=P.map(F=>{if(A.has(F.id)){let $=o.originalElements.get(F.id);if($)return se(F,{x:$.x,y:$.y})}return F}),U=this.props.onDuplicate?.(D,w),K=Yr(U||D,ie(M));Bo(()=>{if(o.hit.element){let F=L.get(o.hit.element.id),$=F&&O.get(F);o.hit.element=$||null}o.hit.allHitElements=o.hit.allHitElements.reduce((F,$)=>{let W=L.get($.id),q=W&&O.get(W);return q&&F.push(q),F},[]),o.drag.origin=ze(r,this.state),this.setState(F=>({...vc(M,this.scene.getNonDeletedElements(),F)})),this.scene.replaceAllElements(K),S.forEach(F=>{da(F)&&F.boundElements?.some($=>$.type==="arrow")&&ko(F,this.scene)}),this.maybeCacheVisibleGaps(r,S,!0),this.maybeCacheReferenceSnapPoints(r,S,!0)})}return}}if(this.state.selectionElement){if(o.lastCoords.x=n.x,o.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:r.shiftKey}),this.lassoTrail.startPath(o.origin.x,o.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(o,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",o),o.lastCoords.x=n.x,o.lastCoords.y=n.y,this.maybeDragNewGenericElement(o,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,b=n.x-p.x,f=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===b&&x[1]===f)){let y=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,_(b,f)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Se(p)&&!p.isDeleted){o.drag.hasOccurred=!0;let u=p.points;it(u.length>1,"Do not create linear elements with less than 2 points");let b=this.state.selectedLinearElement;(!b||b.elementId!==p.id)&&(b=new Z(p,this.scene.getNonDeletedElementsMap())),b&&(b.initialState.lastClickedPoint<0||b.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),b={...b,selectedPointsIndices:[u.length-1],initialState:{...b.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...Z.handlePointDragging(r,this,a,s,b)})}else o.lastCoords.x=n.x,o.lastCoords.y=n.y,this.maybeDragNewGenericElement(o,r,!1)}if(this.state.activeTool.type==="selection"){o.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Z.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&Ge(p,this.state)&&(o.withCmdOrCtrl&&o.hit.element?this.setState(f=>kt({...f,selectedElementIds:{[o.hit.element.id]:!0}},this.scene.getNonDeletedElements(),f,this)):u=!1);let b=this.state.selectionElement?Fv(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(f=>{let x={...u&&f.selectedElementIds,...b.reduce((v,y)=>(v[y.id]=!0,v),{})};return o.hit.element&&(b.length?delete x[o.hit.element.id]:x[o.hit.element.id]=!0),f=u?f:{...f,selectedGroupIds:{},editingGroupId:null},{...kt({editingGroupId:f.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),f,this),selectedLinearElement:b.length===1&&Se(b[0])?new Z(b[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:b.length===1&&(b[0].link||so(b[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(o,r){if(r.scrollbars.isOverHorizontal){let n=o.clientX,i=n-r.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(em.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=o.clientY,i=n-r.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(em.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(o){return Tt(r=>{let n=this.scene.getNonDeletedElementsMap();this.removePointer(r),o.drag.blockDragging=!1,o.eventListeners.onMove&&o.eventListeners.onMove.flush(),r.type==="pointerup"&&this.state.activeTool.type===ht.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:l,croppingElementId:a,multiElement:s,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:il(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,mr.setReferenceSnapPoints(null),mr.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let u=o.hit.allHitElements,b=ze({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!o.boxSelection.hasOccurred&&!o.resize.isResizing&&!u.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(b.x,b.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(qo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),o.drag.hasOccurred&&o.hit?.element?.id){let E=n.get(o.hit.element.id);da(E)&&E.boundElements?.filter(w=>w.type==="arrow").map(w=>n.get(w.id)).filter(w=>Re(w)).forEach(w=>{w&&this.scene.mutateElement(w,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!o.boxSelection.hasOccurred&&o.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(Gt);else{let E=Z.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(Gt,"ui",{event:r,sceneCoords:b}),E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Z.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(Rw(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):o.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(Gt,"ui",{event:r,sceneCoords:b})),this.state.newElement&&this.state.multiElement&&Se(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:E}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:E.points[E.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",o.eventListeners.onMove),window.removeEventListener("pointerup",o.eventListeners.onUp),window.removeEventListener("keydown",o.eventListeners.onKeyDown),window.removeEventListener("keyup",o.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,o),this.onPointerUpEmitter.trigger(this.state.activeTool,o,r),i?.type==="freedraw"){let E=ze(r,this.state),w=i.points,T=E.x-i.x,S=E.y-i.y;T===w[0][0]&&S===w[0][1]&&(S+=1e-4,T+=1e-4);let A=i.simulatePressure?[]:[...i.pressures,r.pressure];this.scene.mutateElement(i,{points:[...w,_(T,S)],pressures:A}),this.actionManager.executeAction(Gt);return}if(Se(i)&&this.state.activeTool.type!=="autoshape"){let E=ze(r,this.state),w=Ko(_(E.x,E.y),_(o.origin.x,o.origin.y))*this.state.zoom.value;if((!o.drag.hasOccurred||w<qE)&&i&&!s)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[_(0,0),_(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(Gt)}else this.setState({multiElement:i,newElement:i});else o.drag.hasOccurred&&!s&&(this.store.scheduleCapture(),Se(i)&&this.actionManager.executeAction(Gt,"ui",{event:r,sceneCoords:b}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:ft(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Be({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new Z(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(ee(i)){let E=dv(dt({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<E&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&$r(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),appState:{newElement:null},captureUpdate:N.NEVER});return}if(re(i)){let E=Gv(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(hl(this.scene.getElementsMapIncludingDeleted(),E,i))}if(i&&(this.scene.mutateElement(i,tw(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),o.drag.hasOccurred){let E=ze(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let w=this.scene.getElement(this.state.selectedLinearElement.elementId);if(w?.frameId){let T=Cn(w,n);T&&w&&(Vm(w,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(w,{groupIds:[]}),Km([w],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let w=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(E,{currentFrameId:Tc(w),excludeElementIds:this.state.selectedElementIds}),S=this.scene.getElementsMapIncludingDeleted(),A=M=>{if(M.length>0){for(let O of M){let P=O.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(O,{groupIds:O.groupIds.slice(0,P)},{informMutation:!1,isDragging:!1})}S.forEach(O=>{O.groupIds.length&&He(S,O.groupIds[O.groupIds.length-1]).length<2&&this.scene.mutateElement(O,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=w.filter(O=>yf(O,S,this.state));this.state.editingGroupId&&A(M),S=hl(S,M,T)}else if(!T&&this.state.editingGroupId){let M=w.filter(O=>O.frameId&&!yf(O,S,this.state));A(M)}S=Xr(S,this.state,this),this.scene.replaceAllElements(S)}}if(l&&this.store.scheduleCapture(),l&&$r(l)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==l.id),captureUpdate:N.NEVER}),o.resize.isResizing){let E=Xr(this.scene.getElementsIncludingDeleted(),this.state,this),w=this.scene.getSelectedElements(this.state).filter(re);for(let T of w)E=Kr(E,Mo(this.scene.getElementsIncludingDeleted(),T,this.state,n),T);this.scene.replaceAllElements(E)}let f=o.hit.element;this.state.selectedLinearElement?.elementId!==f?.id&&Se(f)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Z(f,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!f&&!p||f&&f.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,v=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(rr(this.state)&&x&&v){if(this.eraserTrail.endPath(),Ko(_(x.clientX,x.clientY),_(v.clientX,v.clientY))===0){let w=ze({clientX:v.clientX,clientY:v.clientY},this.state);this.getElementsAtPosition(w.x,w.y).forEach(S=>this.elementsPendingErasure.add(S.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(f&&!o.drag.hasOccurred&&!o.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!o.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[f.id]?Hm(this.state,f)?this.setState(E=>{let w={...E.selectedElementIds};for(let T of f.groupIds.flatMap(S=>He(this.scene.getNonDeletedElements(),S)))delete w[T.id];return{selectedGroupIds:{...E.selectedElementIds,...f.groupIds.map(T=>({[T]:!1})).reduce((T,S)=>({...T,...S}),{})},selectedElementIds:Be(w,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let w={...E.selectedElementIds};delete w[f.id];let T=ae(this.scene.getNonDeletedElements(),{selectedElementIds:w});return{...kt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:T.length===1&&Se(T[0])?new Z(T[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):f.frameId&&this.state.selectedElementIds[f.frameId]?this.setState(E=>{let w={...E.selectedElementIds,[f.id]:!0};return delete w[f.frameId],(this.scene.getElement(f.frameId)?.groupIds??[]).flatMap(T=>He(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete w[T.id]}),{...kt({editingGroupId:E.editingGroupId,selectedElementIds:w},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:f.link||so(f)?"info":!1}}):this.setState(E=>({selectedElementIds:Be({...E.selectedElementIds,[f.id]:!0},E)})):this.setState(E=>({...kt({editingGroupId:E.editingGroupId,selectedElementIds:{[f.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Se(f)&&E.selectedLinearElement?.elementId!==f.id?new Z(f,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(f&&Re(f))&&!o.drag.hasOccurred&&!this.state.isResizing&&(f&&Iv({point:_(o.origin.x,o.origin.y),element:f,elementsMap:n,threshold:this.getElementHitThreshold(f),frameNameBound:re(f)?this.frameNameBoundsCache.get(f):null},n)||!f&&o.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ba):this.setState({selectedElementIds:Be({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Fe.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(f,b);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!o.drag.hasOccurred&&!o.hit.wasAddedToSelection&&!r.shiftKey&&!r[I.CTRL_OR_CMD]&&!r.altKey&&r.pointerType!=="touch"&&f&&(ee(f)&&this.state.selectedElementIds[f.id]&&this.scene.getSelectedElements(this.state).length===1||y)){this.startTextEditing({sceneX:b.x,sceneY:b.y,container:y,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:b});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(E=>({selectedElementIds:Be({...E.selectedElementIds,[i.id]:!0},E),showHyperlinkPopup:so(i)&&!i.link?"editor":E.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Ge(this.scene.getNonDeletedElements(),this.state)||!Lt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),o.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let E=this.scene.getSelectedElements(this.state).filter(Te);Ec(E,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(Gt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==ht.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:ft(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(o){this.setState(r=>({selectedElementIds:Be({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&o!=null&&ml(o,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Be({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(o,r,n,i){if(i){let l=i.x+i.width/2,a=i.y+i.height/2,s=Nm(i,this.scene.getNonDeletedElementsMap());if(s&&(l=s.x,a=s.y),Math.hypot(o-l,r-a)<QE){let{x:m,y:p}=Ft({sceneX:l,sceneY:a},n);return{viewportX:m,viewportY:p,elementCenterX:l,elementCenterY:a}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{left:r,top:n}=o.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let o=Sl.find(r=>r.code===this.props.langCode)||Jr;await gp(o),this.setAppState({})}},X9=()=>{(Wr()||Bt())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(ul(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};X9();var LM=kE;import{useEffect as Z9,useState as j9}from"react";import{jsx as q9}from"react/jsx-runtime";var _M=e=>{let[t,o]=j9(!0);return Z9(()=>{let r=async()=>{await gp(n),o(!1)},n=Sl.find(i=>i.code===e.langCode)||Jr;r()},[e.langCode]),t?q9(Gh,{theme:e.theme}):e.children};import J9 from"clsx";import{jsx as PM}from"react/jsx-runtime";var DM=({children:e})=>{let{FooterCenterTunnel:t}=nt(),o=be();return PM(t.In,{children:PM("div",{className:J9("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":o.zenModeEnabled}),children:e})})},Q9=DM;DM.displayName="FooterCenter";import tO from"clsx";import{jsx as rO,jsxs as nO}from"react/jsx-runtime";var RM=({isCollaborating:e,onSelect:t,editorInterface:o,...r})=>{let n=be(),i=o?.formFactor!=="desktop"||n.width<1440;return nO(no,{...r,className:tO("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:i?void 0:"auto"},title:h("labels.liveCollaboration"),children:[i?fb:h("labels.share"),n.collaborators.size>0&&rO("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},oO=RM;RM.displayName="LiveCollaborationTrigger";import{jsx as Ji,jsxs as OM}from"react/jsx-runtime";var iO=()=>Ji("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Ji("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"})}),aO=()=>OM("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Ji("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)"}),Ji("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)"}),Ji("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)"}),Ji("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)"})]}),NM=({style:e,size:t="small",withText:o})=>OM("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Ji(iO,{}),o&&Ji(aO,{})]});import{Fragment as zM,jsx as Ot,jsxs as RE}from"react/jsx-runtime";var NE=({icon:e,shortcut:t,children:o})=>{let r=Me();return RE(zM,{children:[Ot("div",{className:"welcome-screen-menu-item__icon",children:e}),Ot("div",{className:"welcome-screen-menu-item__text",children:o}),t&&r.formFactor!=="phone"&&Ot("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};NE.displayName="WelcomeScreenMenuItemContent";var rm=({onSelect:e,children:t,icon:o,shortcut:r,className:n="",...i})=>Ot("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ot(NE,{icon:o,shortcut:r,children:t})});rm.displayName="WelcomeScreenMenuItem";var FM=({children:e,href:t,icon:o,shortcut:r,className:n="",...i})=>Ot("a",{...i,className:`welcome-screen-menu-item ${n}`,href:t,target:"_blank",rel:"noopener",children:Ot(NE,{icon:o,shortcut:r,children:e})});FM.displayName="WelcomeScreenMenuItemLink";var vr=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=nt();return Ot(t.In,{children:Ot("div",{className:"welcome-screen-center",children:e||RE(zM,{children:[Ot(OE,{}),Ot(FE,{children:h("welcomeScreen.defaults.center_heading")}),RE(BE,{children:[Ot(HE,{}),Ot(zE,{})]})]})})})};vr.displayName="Center";var OE=({children:e})=>Ot("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ot(NM,{withText:!0})});OE.displayName="Logo";var FE=({children:e})=>Ot("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});FE.displayName="Heading";var BE=({children:e})=>Ot("div",{className:"welcome-screen-menu",children:e});BE.displayName="Menu";var zE=()=>{let e=Qe();return Ot(rm,{onSelect:()=>e.executeAction(Ri),shortcut:"?",icon:wa,children:h("helpDialog.title")})};zE.displayName="MenuItemHelp";var HE=()=>{let e=be(),t=Qe();return e.viewModeEnabled?null:Ot(rm,{onSelect:()=>t.executeAction(Pa),shortcut:rt("loadScene"),icon:Ta,children:h("buttons.load")})};HE.displayName="MenuItemLoadScene";var BM=({onSelect:e})=>{let{t}=Ue();return Ot(rm,{shortcut:null,onSelect:e,icon:Uc,children:t("labels.liveCollaboration")})};BM.displayName="MenuItemLiveCollaborationTrigger";vr.Logo=OE;vr.Heading=FE;vr.Menu=BE;vr.MenuItem=rm;vr.MenuItemLink=FM;vr.MenuItemHelp=zE;vr.MenuItemLoadScene=HE;vr.MenuItemLiveCollaborationTrigger=BM;import{jsx as Ks,jsxs as UE}from"react/jsx-runtime";var Ig=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=nt();return Ks(t.In,{children:UE("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[qf,Ks("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.menuHint")})]})})};Ig.displayName="MenuHint";var Sg=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=nt();return Ks(t.In,{children:UE("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ks("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.toolbarHint")}),Qf]})})};Sg.displayName="ToolbarHint";var kg=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=nt();return Ks(t.In,{children:UE("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ks("div",{children:e||h("welcomeScreen.defaults.helpHint")}),Jf]})})};kg.displayName="HelpHint";import{Fragment as HM,jsx as nm,jsxs as sO}from"react/jsx-runtime";var Mg=e=>nm(HM,{children:e.children||sO(HM,{children:[nm(vr,{}),nm(Ig,{}),nm(Sg,{}),nm(kg,{})]})});Mg.displayName="WelcomeScreen";Mg.Center=vr;Mg.Hints={MenuHint:Ig,ToolbarHint:Sg,HelpHint:kg};var lO=Mg;var cO=()=>{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}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,t){return this.slice().reverse().find((o,r)=>e.call(t,o,this.length-r-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,t){for(let o=0;o<this.length;o++)if(e.call(t,this[o],o,this))return o;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,t){let o=this.slice().reverse().findIndex((r,n)=>e.call(t,r,this.length-n-1,this));return o===-1?-1:this.length-o-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},UM=cO;import dO from"lodash.throttle";var mO=(e,t,o)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>o.version||t.version===o.version&&t.versionNonce<=o.versionNonce)),pO=dO((e,t,o)=>{if(Bt()||Wr()||window?.DEBUG_FRACTIONAL_INDICES){let r=ul(e.map(n=>({...n})));Bv(r,{shouldThrow:Wr()||Bt(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:o}})}},1e3*60,{leading:!0,trailing:!1}),uO=(e,t,o)=>{let r=ie(e),n=[],i=new Set;for(let a of t)if(!i.has(a.id)){let s=r.get(a.id),c=mO(o,s,a);s&&c?(n.push(s),i.add(s.id)):(n.push(a),i.add(a.id))}for(let a of e)i.has(a.id)||(n.push(a),i.add(a.id));let l=Wm(n);return pO(l,e,t),ul(l),l};import{jsx as GE}from"react/jsx-runtime";var GM=({children:e,icon:t})=>{let{t:o}=Ue(),{TTDDialogTriggerTunnel:r}=nt(),n=Ie();return GE(r.In,{children:GE(ue.Item,{onSelect:()=>{Ee("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??g1,badge:GE(ue.Item.Badge,{children:"AI"}),children:e??o("labels.textToDiagram")})})};GM.displayName="TTDDialogTrigger";function hO(e){let t=e.get("X-Ratelimit-Limit"),o=e.get("X-Ratelimit-Remaining");return{rateLimit:t?parseInt(t,10):void 0,rateLimitRemaining:o?parseInt(o,10):void 0}}async function*WM(e){let t=new TextDecoder,o="";try{for(;;){let{done:r,value:n}=await e.read();if(r)break;o+=t.decode(n,{stream:!0});let i=o.split(`
|
|
110
|
+
`);o=i.pop()||"";for(let l of i){let a=l.trim();a&&a.startsWith("data: ")&&(yield a.slice(6))}}}finally{e.releaseLock()}}async function gO(e){let{url:t,messages:o,onChunk:r,onStreamCreated:n,extractRateLimits:i=!0,signal:l}=e;try{let a="",s={},c=null,d=await fetch(t,{method:"POST",headers:{Accept:"text/event-stream","Content-Type":"application/json"},body:JSON.stringify({messages:o}),signal:l});if(i&&(s=hO(d.headers)),!d.ok){if(d.status===429)return{...s,error:new jr({message:"Rate limit exceeded",status:429})};let p=await d.text();throw new jr({message:p||"Generation failed...",status:d.status})}let m=d.body?.getReader();if(!m)throw new jr({message:"Couldn't get reader from response body",status:500});n?.();try{for await(let p of WM(m)){if(p==="[DONE]")break;try{let u=JSON.parse(p);if(u===null)break;switch(u.type){case"content":{let b=u.delta;b&&(a+=b,r?.(b));break}case"error":c=new jr({message:u.error.message,status:500});break;case"done":break}}catch(u){console.warn("Failed to parse SSE data:",p,u)}}}catch(p){p.name==="AbortError"?c=new jr({message:"Request aborted",status:499}):c=new jr({message:p.message||"Streaming error",status:500})}return c?{...s,error:c}:a?{generatedResponse:a,error:null,...s}:{...s,error:new jr({message:"Generation failed...",status:d.status})}}catch(a){return a.name==="AbortError"?{error:new jr({message:"Request aborted",status:499})}:{error:new jr({message:a.message||"Request failed",status:500})}}}import{useLayoutEffect as fO}from"react";var bO=e=>{let t=Xe();return fO(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};import{parseMermaidToExcalidraw as QMe}from"@excalidraw/mermaid-to-excalidraw";import{jsx as im}from"react/jsx-runtime";UM();var dMe=({children:e})=>{let[t,o]=TO(null);return im(Ys.Provider,{value:t,children:im(Cg.Provider,{value:o,children:e})})},CO=e=>{let{onExport:t,className:o,onChange:r,onThemeChange:n,onIncrement:i,initialData:l,initialState:a,onExcalidrawAPI:s,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:b,renderTopRightUI:f,langCode:x=Jr.code,viewModeEnabled:v,interaction:y,ui:E,activeTool:w,zenModeEnabled:T,gridModeEnabled:S,libraryReturnUrl:A,theme:M,name:O,renderCustomStats:P,onPaste:L,detectScroll:D=!0,handleKeyboardGlobally:U=!1,onLibraryChange:K,autoFocus:F=!1,generateIdForFile:$,onLinkOpen:W,generateLinkForSelection:q,onPointerDown:oe,onPointerUp:B,onScrollChange:V,onUserFollow:fe,userToFollow:Ne,onDuplicate:Ze,id:ye,children:Ye,validateEmbeddable:me,renderEmbeddable:je,aiEnabled:It,showDeprecatedFonts:wr,renderScrollbars:Hr,viewportStatusFrame:qn,currentUserControls:$a,imageOptions:Xs}=e,Za=e.UIOptions?.canvasActions,Qi={...e.UIOptions,canvasActions:{...Xg.canvasActions,...Za},tools:{image:e.UIOptions?.tools?.image??!0}};Za?.export&&(Qi.canvasActions.export.saveFileToDisk=Za.export?.saveFileToDisk??Xg.canvasActions.export.saveFileToDisk),Qi.canvasActions.toggleTheme===null&&(M==null||n)&&(Qi.canvasActions.toggleTheme=!0);let Ag={maxFileSizeBytes:Xs?.maxFileSizeBytes??na.maxFileSizeBytes,maxWidthOrHeight:Xs?.maxWidthOrHeight??na.maxWidthOrHeight},Jn=yO(Cg),Tr=wO(s);Tr.current=s;let Lg=EO(_g=>{Jn?.(_g),Tr.current?.(_g)},[Jn]),WE=typeof y=="object"&&y!==null&&y.enabled?.browserZoom===!0&&y.enabled?.navigation!==!0;return vO(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),WE)return;let VE=Pg=>{typeof Pg.scale=="number"&&Pg.scale!==1&&Pg.preventDefault()};return document.addEventListener("touchmove",VE,{passive:!1}),()=>{document.removeEventListener("touchmove",VE)}},[WE]),im(g2,{store:bt,children:im(_M,{langCode:x,theme:M,children:im(LM,{id:ye,onExport:t,className:o,onChange:r,onThemeChange:n,onIncrement:i,initialData:l,initialState:a,onExcalidrawAPI:Lg,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:b,renderTopRightUI:f,langCode:x,viewModeEnabled:v,interaction:y,ui:E,activeTool:w,zenModeEnabled:T,gridModeEnabled:S,libraryReturnUrl:A,theme:M,name:O,renderCustomStats:P,UIOptions:Qi,onPaste:L,detectScroll:D,handleKeyboardGlobally:U,onLibraryChange:K,autoFocus:F,generateIdForFile:$,onLinkOpen:W,generateLinkForSelection:q,onPointerDown:oe,onPointerUp:B,onScrollChange:V,onUserFollow:fe,userToFollow:Ne,onDuplicate:Ze,validateEmbeddable:me,renderEmbeddable:je,aiEnabled:It!==!1,showDeprecatedFonts:wr,renderScrollbars:Hr,viewportStatusFrame:qn,currentUserControls:$a,imageOptions:Ag,children:Ye})})})},IO=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:o,UIOptions:r={},imageOptions:n,interaction:i,ui:l,activeTool:a,...s}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:b,...f}=t;if(!(a===b||a?.type===b?.type&&(a?.type==="custom"?a.customType:null)===(b?.type==="custom"?b.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(l===u||typeof l=="object"&&l!==null&&typeof u=="object"&&u!==null&&!!l.enabled?.zoom==!!u.enabled?.zoom&&!!l.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let E=Object.keys(r),w=Object.keys(d);if(E.length!==w.length)return!1;let T=E.every(A=>A==="getFormFactor"?!0:A==="canvasActions"?Object.keys(r.canvasActions).every(O=>O==="export"&&r?.canvasActions?.export&&d?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:r?.canvasActions?.[O]===d?.canvasActions?.[O]):r[A]===d[A]),S=(n?.maxWidthOrHeight??na.maxWidthOrHeight)===(m?.maxWidthOrHeight??na.maxWidthOrHeight)&&(n?.maxFileSizeBytes??na.maxFileSizeBytes)===(m?.maxFileSizeBytes??na.maxFileSizeBytes);return T&&S&&Lt(s,f)},SO=xO.memo(CO,IO);SO.displayName="Excalidraw";function mMe(e){return Gl(e,!1)}export{no as Button,N as CaptureUpdateAction,WP as CommandPalette,Gg as DEFAULT_LASER_COLOR,Bf as DEFAULT_OVERSCROLL,eg as DefaultSidebar,bO as DiagramToCodePlugin,Ma as Ellipsify,SO as Excalidraw,Ys as ExcalidrawAPIContext,dMe as ExcalidrawAPIProvider,ct as FONT_FAMILY,kn as Fonts,Q9 as Footer,oO as LiveCollaborationTrigger,pe as MIME_TYPES,uo as MainMenu,At as ROUNDNESS,hr as Sidebar,Xd as Stats,J as THEME,pg as TTDDialog,GM as TTDDialogTrigger,gO as TTDStreamFetch,py as UserIdleState,lO as WelcomeScreen,xS as actions,Jt as applyDarkModeFilter,Tn as bumpVersion,ZM as cleanAppStateForExport,$M as clearAppStateForLocalStorage,xl as convertToExcalidrawElements,Jr as defaultLang,KM as duplicateElement,Sn as duplicateElements,YM as elementsOverlappingBBox,$C as exportToBlob,Tl as exportToCanvas,qL as exportToClipboard,ss as exportToSvg,we as getCommonBounds,Yf as getDataURL,Mn as getDefaultAppState,ef as getFormFactor,Qu as getLibraryItemsHash,de as getNonDeletedElements,XM as getSceneVersion,Gr as getStrokeWidthByKey,uc as getTextFromElements,wf as getVisibleSceneBounds,Nf as hashElementsVersion,Of as hashString,v2 as icons,ga as isElementLink,$r as isInvisiblySmallElement,Se as isLinearElement,vs as isSpreadsheetValidForChartType,Sl as languages,sn as libraryItemsAtom,mp as loadFromBlob,Vf as loadLibraryFromBlob,Wf as loadSceneOrLibraryFromBlob,tI as mergeLibraryItems,co as mutateElement,se as newElementWith,Sr as normalizeLink,N0 as parseLibraryTokensFromUrl,QMe as parseMermaidToExcalidraw,WM as parseSSEStream,uO as reconcileElements,fx as renderSpreadsheet,_c as restoreAppState,qM as restoreElement,wl as restoreElements,Pc as restoreLibraryItems,Ft as sceneCoordsToViewportCoords,Mc as serializeAsJSON,jM as serializeLibraryAsJSON,VM as setCustomTextMetricsProvider,rc as throttleRAF,_h as tryParseSpreadsheet,Me as useEditorInterface,fu as useExcalidrawAPI,mMe as useExcalidrawStateValue,o_ as useHandleLibrary,Ue as useI18n,DA as useOnExcalidrawStateChange,Ut as useStylesPanelMode,ze as viewportCoordsToSceneCoords,ba as zoomToFitBounds};
|